@primitivedotdev/cli 0.35.0 → 0.35.1

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.
@@ -1,4 +1,4 @@
1
- import { A as createClient, C as saveCliCredentials, D as loadChatConversationByLocalId, E as loadActiveChatState, O as saveActiveChatState, S as resolveCliAuth, T as deleteChatState, _ as deleteCliCredentials, a as normalizeCliEnvironmentName, b as normalizeApiBaseUrl1, c as resolveConfigEnvironment, d as validateCliHeaderName, f as validateCliHeaderValue, g as credentialsPath, h as credentialsLockPath, i as loadCliConfig, j as createConfig, k as PrimitiveApiClient, l as saveCliConfig, m as cliAccessTokenExpiresAt, n as deleteCliConfig, o as redactCliEnvironment, p as acquireCliCredentialsLock, r as emptyCliConfig, s as removeCliEnvironment, u as upsertCliEnvironment, v as deleteCliCredentialsLock, w as chatStatePath, x as normalizeApiBaseUrl2, y as loadCliCredentials } from "../cli-config-SktG2dzR.js";
1
+ import { A as createConfig, C as chatStatePath, D as saveActiveChatState, E as loadChatConversationByLocalId, O as PrimitiveApiClient, S as saveCliCredentials, T as loadActiveChatState, _ as deleteCliCredentials, a as normalizeCliEnvironmentName, b as normalizeApiBaseUrl, c as resolveConfigEnvironment, d as validateCliHeaderName, f as validateCliHeaderValue, g as credentialsPath, h as credentialsLockPath, i as loadCliConfig, k as createClient, l as saveCliConfig, m as cliAccessTokenExpiresAt, n as deleteCliConfig, o as redactCliEnvironment, p as acquireCliCredentialsLock, r as emptyCliConfig, s as removeCliEnvironment, u as upsertCliEnvironment, v as deleteCliCredentialsLock, w as deleteChatState, x as resolveCliAuth, y as loadCliCredentials } from "../cli-config-DREZ2BxT.js";
2
2
  import { Args, Command, Errors, Flags, ux } from "@oclif/core";
3
3
  import { chmodSync, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
4
4
  import { randomUUID } from "node:crypto";
@@ -20,7 +20,7 @@ var __exportAll = (all, no_symbols) => {
20
20
  };
21
21
  //#endregion
22
22
  //#region ../packages/api-core/src/api/client.gen.ts
23
- const client = createClient(createConfig({ baseUrl: "https://www.primitive.dev/api/v1" }));
23
+ const client = createClient(createConfig({ baseUrl: "https://api.primitive.dev/v1" }));
24
24
  //#endregion
25
25
  //#region ../packages/api-core/src/api/sdk.gen.ts
26
26
  var sdk_gen_exports = /* @__PURE__ */ __exportAll({
@@ -934,14 +934,13 @@ const getSendPermissions = (options) => (options?.client ?? client).get({
934
934
  * the request returns once the relay accepts the message for delivery.
935
935
  * Set `wait: true` to wait for the first downstream SMTP delivery outcome.
936
936
  *
937
- * **Host routing.** /send-mail is served by the attachments-
938
- * supporting host (`https://api.primitive.dev/v1`) so the
939
- * request body can carry inline attachments up to ~30 MiB raw.
940
- * The primary host (`https://www.primitive.dev/api/v1`) also
941
- * accepts /send-mail for attachment-free sends; sends WITH
942
- * attachments to the primary host return 413
943
- * `attachments_unsupported_on_this_endpoint`. The typed SDKs
944
- * route /send-mail to the attachments host automatically.
937
+ * **Host routing.** /send-mail is served by the canonical API host
938
+ * (`https://api.primitive.dev/v1`) so the request body can carry
939
+ * inline attachments up to ~30 MiB raw. The legacy dashboard
940
+ * compatibility host (`https://www.primitive.dev/api/v1`) also accepts
941
+ * /send-mail, but Vercel request body limits apply before proxying.
942
+ * The typed SDKs route /send-mail to the canonical API host
943
+ * automatically.
945
944
  *
946
945
  */
947
946
  const sendEmail = (options) => (options.client ?? client).post({
@@ -1383,11 +1382,11 @@ const openapiDocument = {
1383
1382
  }
1384
1383
  },
1385
1384
  "servers": [{
1386
- "url": "https://www.primitive.dev/api/v1",
1387
- "description": "Primary API host (PRIMITIVE_API_BASE_URL_1). Carries every operation\nexcept attachment-supporting send. Vercel-backed; request body is\ncapped at 4.5 MB by the platform.\n"
1388
- }, {
1389
1385
  "url": "https://api.primitive.dev/v1",
1390
- "description": "Attachments-supporting send host (PRIMITIVE_API_BASE_URL_2).\nCloudflare Worker with a ~30 MiB raw request body cap (before\nbase64 encoding). Today only `/send-mail` is hosted here; future\nlarge-body operations will migrate here over time. SDK clients\nroute /send-mail to this server automatically.\n"
1386
+ "description": "Canonical API host (PRIMITIVE_API_BASE_URL). Carries every public\nAPI operation. Cloudflare Workers-backed; attachment-capable send\noperations can carry up to ~30 MiB raw request bodies before base64\nencoding.\n"
1387
+ }, {
1388
+ "url": "https://www.primitive.dev/api/v1",
1389
+ "description": "Legacy dashboard compatibility host. Requests are forwarded to the\ncanonical API host, but Vercel request body limits still apply before\nproxying. New integrations should use https://api.primitive.dev/v1.\n"
1391
1390
  }],
1392
1391
  "security": [{ "BearerAuth": [] }],
1393
1392
  "tags": [
@@ -2410,10 +2409,10 @@ const openapiDocument = {
2410
2409
  "description": "Sends an outbound reply to the inbound email identified by `id`.\nThreading headers (`In-Reply-To`, `References`), recipient\nderivation (Reply-To, then From, then bare sender), and the\n`Re:` subject prefix are all derived server-side from the\nstored inbound row. The request body carries only the message\nbody, optional From override, optional attachments, and optional\n`wait` flag; passing any header or recipient override is\nrejected by the schema (`additionalProperties: false`).\n\nForwards through the same gates as `/send-mail`: the response\nstatus, error envelope, and `idempotent_replay` flag mirror\nthe send-mail contract verbatim.\n",
2411
2410
  "servers": [{
2412
2411
  "url": "https://api.primitive.dev/v1",
2413
- "description": "Attachments-supporting send host (recommended)"
2412
+ "description": "Canonical API host (recommended)"
2414
2413
  }, {
2415
2414
  "url": "https://www.primitive.dev/api/v1",
2416
- "description": "Primary host (attachment-free replies only)"
2415
+ "description": "Legacy compatibility host (Vercel body limit applies)"
2417
2416
  }],
2418
2417
  "tags": ["Sending"],
2419
2418
  "requestBody": {
@@ -2822,13 +2821,13 @@ const openapiDocument = {
2822
2821
  "/send-mail": { "post": {
2823
2822
  "operationId": "sendEmail",
2824
2823
  "summary": "Send outbound email",
2825
- "description": "Sends an outbound email through Primitive's outbound relay. By default\nthe request returns once the relay accepts the message for delivery.\nSet `wait: true` to wait for the first downstream SMTP delivery outcome.\n\n**Host routing.** /send-mail is served by the attachments-\nsupporting host (`https://api.primitive.dev/v1`) so the\nrequest body can carry inline attachments up to ~30 MiB raw.\nThe primary host (`https://www.primitive.dev/api/v1`) also\naccepts /send-mail for attachment-free sends; sends WITH\nattachments to the primary host return 413\n`attachments_unsupported_on_this_endpoint`. The typed SDKs\nroute /send-mail to the attachments host automatically.\n",
2824
+ "description": "Sends an outbound email through Primitive's outbound relay. By default\nthe request returns once the relay accepts the message for delivery.\nSet `wait: true` to wait for the first downstream SMTP delivery outcome.\n\n**Host routing.** /send-mail is served by the canonical API host\n(`https://api.primitive.dev/v1`) so the request body can carry\ninline attachments up to ~30 MiB raw. The legacy dashboard\ncompatibility host (`https://www.primitive.dev/api/v1`) also accepts\n/send-mail, but Vercel request body limits apply before proxying.\nThe typed SDKs route /send-mail to the canonical API host\nautomatically.\n",
2826
2825
  "servers": [{
2827
2826
  "url": "https://api.primitive.dev/v1",
2828
- "description": "Attachments-supporting send host (recommended)"
2827
+ "description": "Canonical API host (recommended)"
2829
2828
  }, {
2830
2829
  "url": "https://www.primitive.dev/api/v1",
2831
- "description": "Primary host (attachment-free sends only)"
2830
+ "description": "Legacy compatibility host (Vercel body limit applies)"
2832
2831
  }],
2833
2832
  "tags": ["Sending"],
2834
2833
  "parameters": [{
@@ -12805,7 +12804,7 @@ const operationManifest = [
12805
12804
  "binaryResponse": false,
12806
12805
  "bodyRequired": true,
12807
12806
  "command": "send-email",
12808
- "description": "Sends an outbound email through Primitive's outbound relay. By default\nthe request returns once the relay accepts the message for delivery.\nSet `wait: true` to wait for the first downstream SMTP delivery outcome.\n\n**Host routing.** /send-mail is served by the attachments-\nsupporting host (`https://api.primitive.dev/v1`) so the\nrequest body can carry inline attachments up to ~30 MiB raw.\nThe primary host (`https://www.primitive.dev/api/v1`) also\naccepts /send-mail for attachment-free sends; sends WITH\nattachments to the primary host return 413\n`attachments_unsupported_on_this_endpoint`. The typed SDKs\nroute /send-mail to the attachments host automatically.\n",
12807
+ "description": "Sends an outbound email through Primitive's outbound relay. By default\nthe request returns once the relay accepts the message for delivery.\nSet `wait: true` to wait for the first downstream SMTP delivery outcome.\n\n**Host routing.** /send-mail is served by the canonical API host\n(`https://api.primitive.dev/v1`) so the request body can carry\ninline attachments up to ~30 MiB raw. The legacy dashboard\ncompatibility host (`https://www.primitive.dev/api/v1`) also accepts\n/send-mail, but Vercel request body limits apply before proxying.\nThe typed SDKs route /send-mail to the canonical API host\nautomatically.\n",
12809
12808
  "hasJsonBody": true,
12810
12809
  "method": "POST",
12811
12810
  "operationId": "sendEmail",
@@ -13302,19 +13301,15 @@ function cliApiHeadersFromEnv(env = process.env) {
13302
13301
  }
13303
13302
  function resolveCliApiRequestConfig(params) {
13304
13303
  const currentEnvironment = resolveConfigEnvironment(loadCliConfig(params.configDir));
13305
- const configuredApiBaseUrl1 = currentEnvironment?.config.api_base_url_1;
13306
- const configuredApiBaseUrl2 = currentEnvironment?.config.api_base_url_2;
13307
- if (currentEnvironment !== null && currentEnvironment.name !== "default" && params.apiBaseUrl1 === void 0 && configuredApiBaseUrl1 === void 0) throw new Errors.CLIError(`The active Primitive CLI environment \`${currentEnvironment.name}\` does not specify an api_base_url_1. Set one with \`primitive config set --environment ${currentEnvironment.name} --api-base-url-1 https://...\`, or switch to a different environment with \`primitive config use <name>\`. Refusing to fall back to the production default for a non-default environment.`, { exit: 1 });
13308
- const apiBaseUrl1 = params.apiBaseUrl1 !== void 0 ? normalizeApiBaseUrl1(params.apiBaseUrl1) : configuredApiBaseUrl1;
13309
- const apiBaseUrl2 = params.apiBaseUrl2 !== void 0 ? normalizeApiBaseUrl2(params.apiBaseUrl2) : configuredApiBaseUrl2;
13304
+ const configuredApiBaseUrl = currentEnvironment?.config.api_base_url;
13305
+ if (currentEnvironment !== null && currentEnvironment.name !== "default" && params.apiBaseUrl === void 0 && configuredApiBaseUrl === void 0) throw new Errors.CLIError(`The active Primitive CLI environment \`${currentEnvironment.name}\` does not specify an api_base_url. Set one with \`primitive config set --environment ${currentEnvironment.name} --api-base-url https://...\`, or switch to a different environment with \`primitive config use <name>\`. Refusing to fall back to the production default for a non-default environment.`, { exit: 1 });
13306
+ const apiBaseUrl = params.apiBaseUrl !== void 0 ? normalizeApiBaseUrl(params.apiBaseUrl) : configuredApiBaseUrl;
13310
13307
  return {
13311
- apiBaseUrl1,
13312
- apiBaseUrl2,
13313
- baseUrlOverridden: apiBaseUrl1 !== void 0 || apiBaseUrl2 !== void 0,
13308
+ apiBaseUrl,
13309
+ baseUrlOverridden: apiBaseUrl !== void 0,
13314
13310
  environmentName: currentEnvironment?.name ?? null,
13315
13311
  headers: mergeHeaders(currentEnvironment?.config.headers, cliApiHeadersFromEnv(params.env)),
13316
- resolvedApiBaseUrl1: normalizeApiBaseUrl1(apiBaseUrl1),
13317
- resolvedApiBaseUrl2: normalizeApiBaseUrl2(apiBaseUrl2)
13312
+ resolvedApiBaseUrl: normalizeApiBaseUrl(apiBaseUrl)
13318
13313
  };
13319
13314
  }
13320
13315
  function createCliApiClient(params) {
@@ -13322,15 +13317,14 @@ function createCliApiClient(params) {
13322
13317
  return {
13323
13318
  apiClient: new PrimitiveApiClient({
13324
13319
  apiKey: params.apiKey,
13325
- apiBaseUrl1: requestConfig.resolvedApiBaseUrl1,
13326
- apiBaseUrl2: requestConfig.resolvedApiBaseUrl2,
13320
+ apiBaseUrl: requestConfig.resolvedApiBaseUrl,
13327
13321
  headers: requestConfig.headers
13328
13322
  }),
13329
13323
  requestConfig
13330
13324
  };
13331
13325
  }
13332
- function oauthTokenEndpoint(apiBaseUrl1) {
13333
- const url = new URL(apiBaseUrl1);
13326
+ function oauthTokenEndpoint(apiBaseUrl) {
13327
+ const url = new URL(apiBaseUrl);
13334
13328
  url.pathname = "/oauth/token";
13335
13329
  url.search = "";
13336
13330
  url.hash = "";
@@ -13378,7 +13372,7 @@ async function refreshStoredCliCredentials(params) {
13378
13372
  });
13379
13373
  let response;
13380
13374
  try {
13381
- response = await fetchImpl(oauthTokenEndpoint(params.apiBaseUrl1), {
13375
+ response = await fetchImpl(oauthTokenEndpoint(params.apiBaseUrl), {
13382
13376
  body,
13383
13377
  headers: {
13384
13378
  ...params.headers ?? {},
@@ -13418,13 +13412,12 @@ async function createAuthenticatedCliApiClient(params) {
13418
13412
  const requestConfig = resolveCliApiRequestConfig(params);
13419
13413
  let auth = resolveCliAuth({
13420
13414
  apiKey: params.apiKey,
13421
- apiBaseUrl1: requestConfig.apiBaseUrl1,
13422
- apiBaseUrl2: requestConfig.apiBaseUrl2,
13415
+ apiBaseUrl: requestConfig.apiBaseUrl,
13423
13416
  configDir: params.configDir
13424
13417
  });
13425
13418
  if (auth.source === "stored" && auth.credentials) {
13426
13419
  const refreshed = await refreshStoredCliCredentials({
13427
- apiBaseUrl1: auth.apiBaseUrl1,
13420
+ apiBaseUrl: auth.apiBaseUrl,
13428
13421
  configDir: params.configDir,
13429
13422
  credentials: auth.credentials,
13430
13423
  credentialsLockHeld: params.credentialsLockHeld,
@@ -13441,8 +13434,7 @@ async function createAuthenticatedCliApiClient(params) {
13441
13434
  return {
13442
13435
  apiClient: new PrimitiveApiClient({
13443
13436
  apiKey: auth.apiKey,
13444
- apiBaseUrl1: auth.apiBaseUrl1,
13445
- apiBaseUrl2: auth.apiBaseUrl2,
13437
+ apiBaseUrl: auth.apiBaseUrl,
13446
13438
  headers: requestConfig.headers
13447
13439
  }),
13448
13440
  auth,
@@ -13758,7 +13750,7 @@ const NETWORK_ERROR_HINTS = {
13758
13750
  ENETUNREACH: "Hint: the network is unreachable. If you're behind a proxy and set HTTP(S)_PROXY, re-run with NODE_USE_ENV_PROXY=1 (Node 22+ ignores those env vars by default). `primitive doctor` reports the local environment in one shot.",
13759
13751
  ECONNREFUSED: "Hint: the server refused the connection. Check that your firewall allows egress to *.primitive.dev, that your PRIMITIVE_API_BASE_URL_* overrides (if any) point at a reachable host, and re-run with NODE_USE_ENV_PROXY=1 if you're behind a proxy. `primitive doctor` reports the local environment in one shot.",
13760
13752
  ETIMEDOUT: "Hint: the connection timed out. Check egress rules and proxy configuration; if you're behind a proxy, re-run with NODE_USE_ENV_PROXY=1 and HTTPS_PROXY set. `primitive doctor` reports the local environment in one shot.",
13761
- EAI_AGAIN: "Hint: DNS lookup failed. Check /etc/resolv.conf inside containers, and try `curl -v https://www.primitive.dev/api/v1/account` to confirm the host resolves. `primitive doctor` reports the local environment in one shot."
13753
+ EAI_AGAIN: "Hint: DNS lookup failed. Check /etc/resolv.conf inside containers, and try `curl -v https://api.primitive.dev/v1/account` to confirm the host resolves. `primitive doctor` reports the local environment in one shot."
13762
13754
  };
13763
13755
  function writeErrorWithHints(payload) {
13764
13756
  process.stderr.write(`${formatErrorPayload(payload)}\n`);
@@ -13787,8 +13779,8 @@ function writeErrorWithHints(payload) {
13787
13779
  */
13788
13780
  function surfaceUnauthorizedHint(params) {
13789
13781
  if (extractErrorCode(params.payload) !== API_ERROR_CODES.unauthorized || params.auth.source !== "stored") return;
13790
- if (params.baseUrlOverridden && params.auth.credentials !== null && params.auth.apiBaseUrl1 !== params.auth.credentials.api_base_url_1) {
13791
- process.stderr.write("Saved Primitive CLI credentials were rejected by the overridden API base URL. The saved credential is preserved; unset PRIMITIVE_API_BASE_URL_1, run `primitive config reset` to clear configured URL overrides, or run `primitive logout` to remove the stored credential.\n");
13782
+ if (params.baseUrlOverridden && params.auth.credentials !== null && params.auth.apiBaseUrl !== params.auth.credentials.api_base_url) {
13783
+ process.stderr.write("Saved Primitive CLI credentials were rejected by the overridden API base URL. The saved credential is preserved; unset PRIMITIVE_API_BASE_URL, run `primitive config reset` to clear configured URL overrides, or run `primitive logout` to remove the stored credential.\n");
13792
13784
  return;
13793
13785
  }
13794
13786
  process.stderr.write("Your saved Primitive CLI OAuth session was rejected. If the command was working a moment ago, please retry; brief retries often clear transient rejections. If it keeps failing, run `primitive logout && primitive signin` to mint a fresh session.\n");
@@ -13809,13 +13801,10 @@ async function runWithTiming(enabled, fn) {
13809
13801
  }
13810
13802
  }
13811
13803
  const TIME_FLAG_DESCRIPTION = "Print the wall-clock duration of this command to stderr after it completes (e.g. `[time: 1.34s]`). Useful for measuring `--wait` send latency, comparing CLI overhead, or capturing timing in scripts.";
13812
- const API_BASE_URL_1_FLAG_DESCRIPTION = "Override the primary API base URL. Internal testing only; not documented to customers.";
13813
- const API_BASE_URL_2_FLAG_DESCRIPTION = "Override the attachments-supporting send host base URL. Internal testing only; not documented to customers.";
13814
- const HOST_2_OPERATIONS = new Set(["sendEmail", "replyToEmail"]);
13804
+ const API_BASE_URL_FLAG_DESCRIPTION = "Override the API base URL. Internal testing only; not documented to customers.";
13815
13805
  const RESERVED_FLAG_NAMES = new Set([
13816
13806
  "api-key",
13817
- "api-base-url-1",
13818
- "api-base-url-2",
13807
+ "api-base-url",
13819
13808
  "raw-body",
13820
13809
  "body-file",
13821
13810
  "envelope",
@@ -13847,14 +13836,9 @@ function buildFlags(operation) {
13847
13836
  description: "Primitive API key override (defaults to PRIMITIVE_API_KEY or saved OAuth login credentials)",
13848
13837
  env: "PRIMITIVE_API_KEY"
13849
13838
  }),
13850
- "api-base-url-1": Flags.string({
13851
- description: "Override the primary API base URL. Internal testing only; not documented to customers.",
13852
- env: "PRIMITIVE_API_BASE_URL_1",
13853
- hidden: true
13854
- }),
13855
- "api-base-url-2": Flags.string({
13856
- description: "Override the attachments-supporting send host base URL. Internal testing only; not documented to customers.",
13857
- env: "PRIMITIVE_API_BASE_URL_2",
13839
+ "api-base-url": Flags.string({
13840
+ description: "Override the API base URL. Internal testing only; not documented to customers.",
13841
+ env: "PRIMITIVE_API_BASE_URL",
13858
13842
  hidden: true
13859
13843
  }),
13860
13844
  time: Flags.boolean({ description: TIME_FLAG_DESCRIPTION })
@@ -13942,8 +13926,7 @@ function createOperationCommand(operation) {
13942
13926
  await runWithTiming(parsedFlags.time === true, async () => {
13943
13927
  const { apiClient, auth, baseUrlOverridden } = await createAuthenticatedCliApiClient({
13944
13928
  apiKey: typeof parsedFlags["api-key"] === "string" ? parsedFlags["api-key"] : void 0,
13945
- apiBaseUrl1: typeof parsedFlags["api-base-url-1"] === "string" ? parsedFlags["api-base-url-1"] : void 0,
13946
- apiBaseUrl2: typeof parsedFlags["api-base-url-2"] === "string" ? parsedFlags["api-base-url-2"] : void 0,
13929
+ apiBaseUrl: typeof parsedFlags["api-base-url"] === "string" ? parsedFlags["api-base-url"] : void 0,
13947
13930
  configDir: this.config.configDir
13948
13931
  });
13949
13932
  let body;
@@ -13964,10 +13947,9 @@ function createOperationCommand(operation) {
13964
13947
  }
13965
13948
  if (operation.bodyRequired && body === void 0) throw new Errors.CLIError(`Operation ${operation.operationId} requires a body. Pass each field as a --flag (see --help) or supply JSON via --raw-body / --body-file.`);
13966
13949
  const operationFn = sdk_gen_exports[operation.sdkName];
13967
- const targetClient = HOST_2_OPERATIONS.has(operation.sdkName) ? apiClient._sendClient : apiClient.client;
13968
13950
  const result = await operationFn({
13969
13951
  body,
13970
- client: targetClient,
13952
+ client: apiClient.client,
13971
13953
  parseAs: operation.binaryResponse ? "blob" : "auto",
13972
13954
  path: collectValues(operation.pathParams, parsedFlags),
13973
13955
  query: collectValues(operation.queryParams, parsedFlags),
@@ -14721,14 +14703,9 @@ var ChatCommand = class ChatCommand extends Command {
14721
14703
  description: "Primitive API key (defaults to PRIMITIVE_API_KEY or saved `primitive signin` credentials)",
14722
14704
  env: "PRIMITIVE_API_KEY"
14723
14705
  }),
14724
- "api-base-url-1": Flags.string({
14706
+ "api-base-url": Flags.string({
14725
14707
  description: "Override the primary API base URL. Internal testing only; not documented to customers.",
14726
- env: "PRIMITIVE_API_BASE_URL_1",
14727
- hidden: true
14728
- }),
14729
- "api-base-url-2": Flags.string({
14730
- description: "Override the attachments-supporting send host base URL. Internal testing only; not documented to customers.",
14731
- env: "PRIMITIVE_API_BASE_URL_2",
14708
+ env: "PRIMITIVE_API_BASE_URL",
14732
14709
  hidden: true
14733
14710
  }),
14734
14711
  from: Flags.string({ description: "Sender address. Defaults to agent@<your-first-verified-outbound-domain>." }),
@@ -14787,8 +14764,7 @@ var ChatCommand = class ChatCommand extends Command {
14787
14764
  await runWithTiming(flags.time, async () => {
14788
14765
  const { apiClient, auth, baseUrlOverridden } = await createAuthenticatedCliApiClient({
14789
14766
  apiKey: flags["api-key"],
14790
- apiBaseUrl1: flags["api-base-url-1"],
14791
- apiBaseUrl2: flags["api-base-url-2"],
14767
+ apiBaseUrl: flags["api-base-url"],
14792
14768
  configDir: this.config.configDir
14793
14769
  });
14794
14770
  const authFailureContext = {
@@ -14859,7 +14835,7 @@ var ChatCommand = class ChatCommand extends Command {
14859
14835
  from,
14860
14836
  ...attachments !== void 0 ? { attachments } : {}
14861
14837
  },
14862
- client: apiClient._sendClient,
14838
+ client: apiClient.client,
14863
14839
  path: { id: parentReply.id },
14864
14840
  responseStyle: "fields"
14865
14841
  }) : await sendEmail({
@@ -14871,7 +14847,7 @@ var ChatCommand = class ChatCommand extends Command {
14871
14847
  ...flags["in-reply-to"] !== void 0 ? { in_reply_to: flags["in-reply-to"] } : {},
14872
14848
  ...attachments !== void 0 ? { attachments } : {}
14873
14849
  },
14874
- client: apiClient._sendClient,
14850
+ client: apiClient.client,
14875
14851
  responseStyle: "fields"
14876
14852
  });
14877
14853
  if (sendResult.error) {
@@ -14996,14 +14972,9 @@ var ChatReplyCommand = class ChatReplyCommand extends Command {
14996
14972
  description: "Primitive API key (defaults to PRIMITIVE_API_KEY or saved `primitive signin` credentials)",
14997
14973
  env: "PRIMITIVE_API_KEY"
14998
14974
  }),
14999
- "api-base-url-1": Flags.string({
14975
+ "api-base-url": Flags.string({
15000
14976
  description: "Override the primary API base URL. Internal testing only; not documented to customers.",
15001
- env: "PRIMITIVE_API_BASE_URL_1",
15002
- hidden: true
15003
- }),
15004
- "api-base-url-2": Flags.string({
15005
- description: "Override the attachments-supporting send host base URL. Internal testing only; not documented to customers.",
15006
- env: "PRIMITIVE_API_BASE_URL_2",
14977
+ env: "PRIMITIVE_API_BASE_URL",
15007
14978
  hidden: true
15008
14979
  }),
15009
14980
  id: Flags.integer({
@@ -15068,8 +15039,7 @@ var ChatReplyCommand = class ChatReplyCommand extends Command {
15068
15039
  String(state.local_id)
15069
15040
  ];
15070
15041
  if (flags["api-key"] !== void 0) argv.push("--api-key", flags["api-key"]);
15071
- if (flags["api-base-url-1"] !== void 0) argv.push("--api-base-url-1", flags["api-base-url-1"]);
15072
- if (flags["api-base-url-2"] !== void 0) argv.push("--api-base-url-2", flags["api-base-url-2"]);
15042
+ if (flags["api-base-url"] !== void 0) argv.push("--api-base-url", flags["api-base-url"]);
15073
15043
  if (flags.json) argv.push("--json");
15074
15044
  if (flags.quiet) argv.push("--quiet");
15075
15045
  for (const attachment of flags.attachment ?? []) argv.push("--attachment", attachment);
@@ -15184,8 +15154,7 @@ function upsertCliEnvironmentAndClearCredentialsIfSwitched(params) {
15184
15154
  const previousActiveEnvironment = resolveConfigEnvironment(previousConfig);
15185
15155
  const previousEnvironment = previousActiveEnvironment?.name ?? null;
15186
15156
  const config = upsertCliEnvironment({
15187
- apiBaseUrl1: params.apiBaseUrl1,
15188
- apiBaseUrl2: params.apiBaseUrl2,
15157
+ apiBaseUrl: params.apiBaseUrl,
15189
15158
  config: previousConfig,
15190
15159
  environmentName: params.environmentName,
15191
15160
  headers: params.headers,
@@ -15193,7 +15162,7 @@ function upsertCliEnvironmentAndClearCredentialsIfSwitched(params) {
15193
15162
  });
15194
15163
  const activeEnvironment = resolveConfigEnvironment(config);
15195
15164
  const environment = activeEnvironment?.name ?? null;
15196
- const shouldClearCredentials = existsSync(credentialsPath(params.configDir)) && (previousEnvironment !== environment || previousActiveEnvironment?.config.api_base_url_1 !== activeEnvironment?.config.api_base_url_1);
15165
+ const shouldClearCredentials = existsSync(credentialsPath(params.configDir)) && (previousEnvironment !== environment || previousActiveEnvironment?.config.api_base_url !== activeEnvironment?.config.api_base_url);
15197
15166
  let removedCredentials = false;
15198
15167
  if (shouldClearCredentials) {
15199
15168
  const releaseLock = acquireCliCredentialsLock(params.configDir);
@@ -15243,10 +15212,9 @@ var ConfigSetCommand = class ConfigSetCommand extends Command {
15243
15212
  static flags = {
15244
15213
  environment: Flags.string({
15245
15214
  char: "e",
15246
- description: "Environment name to create or update"
15215
+ description: "Environment name to create or update. Defaults to the active environment, or default when none is active."
15247
15216
  }),
15248
- "api-base-url-1": Flags.string({ description: "Primary API base URL" }),
15249
- "api-base-url-2": Flags.string({ description: "Attachments-supporting API base URL" }),
15217
+ "api-base-url": Flags.string({ description: "API base URL" }),
15250
15218
  header: Flags.string({
15251
15219
  description: "Request header in name=value form. Repeatable.",
15252
15220
  multiple: true
@@ -15259,10 +15227,9 @@ var ConfigSetCommand = class ConfigSetCommand extends Command {
15259
15227
  async run() {
15260
15228
  const { flags } = await this.parse(ConfigSetCommand);
15261
15229
  const headers = flags.header ?? [];
15262
- if (flags["api-base-url-1"] === void 0 && flags["api-base-url-2"] === void 0 && headers.length === 0 && (flags["unset-header"] ?? []).length === 0) throw new Errors.CLIError("Nothing to set. Pass an API base URL, --header, or --unset-header.", { exit: 1 });
15230
+ if (flags["api-base-url"] === void 0 && headers.length === 0 && (flags["unset-header"] ?? []).length === 0) throw new Errors.CLIError("Nothing to set. Pass an API base URL, --header, or --unset-header.", { exit: 1 });
15263
15231
  const { environment, removedCredentials } = upsertCliEnvironmentAndClearCredentialsIfSwitched({
15264
- apiBaseUrl1: flags["api-base-url-1"],
15265
- apiBaseUrl2: flags["api-base-url-2"],
15232
+ apiBaseUrl: flags["api-base-url"],
15266
15233
  configDir: this.config.configDir,
15267
15234
  environmentName: flags.environment,
15268
15235
  headers,
@@ -15310,8 +15277,7 @@ var ConfigListCommand = class ConfigListCommand extends Command {
15310
15277
  const active = activeEnvironment === name ? "*" : " ";
15311
15278
  const headerNames = Object.keys(environment.headers ?? {});
15312
15279
  this.log(`${active} ${name}`);
15313
- if (environment.api_base_url_1) this.log(` api_base_url_1: ${environment.api_base_url_1}`);
15314
- if (environment.api_base_url_2) this.log(` api_base_url_2: ${environment.api_base_url_2}`);
15280
+ if (environment.api_base_url) this.log(` api_base_url: ${environment.api_base_url}`);
15315
15281
  this.log(` headers: ${headerNames.length > 0 ? headerNames.join(", ") : "(none)"}`);
15316
15282
  }
15317
15283
  }
@@ -15483,7 +15449,7 @@ async function checkAccount(client) {
15483
15449
  } catch (error) {
15484
15450
  const code = error instanceof Error && error.cause && typeof error.cause === "object" && typeof error.cause.code === "string" ? error.cause.code : void 0;
15485
15451
  const message = error instanceof Error ? error.message : String(error);
15486
- const hint = code === "ENETUNREACH" || code === "ECONNREFUSED" || code === "ETIMEDOUT" || code === "EAI_AGAIN" ? "Network unreachable. If you're behind a proxy, re-run with NODE_USE_ENV_PROXY=1 and HTTPS_PROXY set. If you're in a container, check that egress to *.primitive.dev is allowed." : "Inspect the error above. `curl https://www.primitive.dev/api/v1/account -H \"Authorization: Bearer $PRIMITIVE_API_KEY\"` is the fastest way to bisect CLI vs network.";
15452
+ const hint = code === "ENETUNREACH" || code === "ECONNREFUSED" || code === "ETIMEDOUT" || code === "EAI_AGAIN" ? "Network unreachable. If you're behind a proxy, re-run with NODE_USE_ENV_PROXY=1 and HTTPS_PROXY set. If you're in a container, check that egress to *.primitive.dev is allowed." : "Inspect the error above. `curl https://api.primitive.dev/v1/account -H \"Authorization: Bearer $PRIMITIVE_API_KEY\"` is the fastest way to bisect CLI vs network.";
15487
15453
  return {
15488
15454
  outcome: {
15489
15455
  status: "fail",
@@ -15537,14 +15503,9 @@ var DoctorCommand = class DoctorCommand extends Command {
15537
15503
  description: "Primitive API key override (defaults to PRIMITIVE_API_KEY or saved OAuth login credentials)",
15538
15504
  env: "PRIMITIVE_API_KEY"
15539
15505
  }),
15540
- "api-base-url-1": Flags.string({
15506
+ "api-base-url": Flags.string({
15541
15507
  description: "Override the primary API base URL. Internal testing only; not documented to customers.",
15542
- env: "PRIMITIVE_API_BASE_URL_1",
15543
- hidden: true
15544
- }),
15545
- "api-base-url-2": Flags.string({
15546
- description: "Override the attachments-supporting send host base URL. Internal testing only; not documented to customers.",
15547
- env: "PRIMITIVE_API_BASE_URL_2",
15508
+ env: "PRIMITIVE_API_BASE_URL",
15548
15509
  hidden: true
15549
15510
  })
15550
15511
  };
@@ -15570,8 +15531,7 @@ var DoctorCommand = class DoctorCommand extends Command {
15570
15531
  if (apiKeyCheck.status !== "fail") {
15571
15532
  const { apiClient, auth } = await createAuthenticatedCliApiClient({
15572
15533
  apiKey: flags["api-key"],
15573
- apiBaseUrl1: flags["api-base-url-1"],
15574
- apiBaseUrl2: flags["api-base-url-2"],
15534
+ apiBaseUrl: flags["api-base-url"],
15575
15535
  configDir: this.config.configDir
15576
15536
  });
15577
15537
  if (auth.apiKey !== void 0) {
@@ -15657,14 +15617,9 @@ var DomainsZoneFileCommand = class DomainsZoneFileCommand extends Command {
15657
15617
  description: "Primitive API key override (defaults to PRIMITIVE_API_KEY or saved OAuth login credentials)",
15658
15618
  env: "PRIMITIVE_API_KEY"
15659
15619
  }),
15660
- "api-base-url-1": Flags.string({
15620
+ "api-base-url": Flags.string({
15661
15621
  description: "Override the primary API base URL. Internal testing only; not documented to customers.",
15662
- env: "PRIMITIVE_API_BASE_URL_1",
15663
- hidden: true
15664
- }),
15665
- "api-base-url-2": Flags.string({
15666
- description: "Override the attachments-supporting send host base URL. Internal testing only; not documented to customers.",
15667
- env: "PRIMITIVE_API_BASE_URL_2",
15622
+ env: "PRIMITIVE_API_BASE_URL",
15668
15623
  hidden: true
15669
15624
  }),
15670
15625
  domain: Flags.string({ description: "Domain name to look up before downloading its zone file. Prefer --id when you have the domain id from `primitive domains add`." }),
@@ -15683,8 +15638,7 @@ var DomainsZoneFileCommand = class DomainsZoneFileCommand extends Command {
15683
15638
  await runWithTiming(flags.time, async () => {
15684
15639
  const { apiClient, auth, baseUrlOverridden, requestConfig } = await createAuthenticatedCliApiClient({
15685
15640
  apiKey: flags["api-key"],
15686
- apiBaseUrl1: flags["api-base-url-1"],
15687
- apiBaseUrl2: flags["api-base-url-2"],
15641
+ apiBaseUrl: flags["api-base-url"],
15688
15642
  configDir: this.config.configDir
15689
15643
  });
15690
15644
  let domainId = flags.id;
@@ -15711,7 +15665,7 @@ var DomainsZoneFileCommand = class DomainsZoneFileCommand extends Command {
15711
15665
  if (!domainId) throw new Errors.CLIError("Could not resolve a domain id.", { exit: 1 });
15712
15666
  let response;
15713
15667
  try {
15714
- response = await fetch(zoneFileUrl(requestConfig.resolvedApiBaseUrl1, domainId, flags["outbound-only"]), { headers: {
15668
+ response = await fetch(zoneFileUrl(requestConfig.resolvedApiBaseUrl, domainId, flags["outbound-only"]), { headers: {
15715
15669
  ...requestConfig.headers ?? {},
15716
15670
  ...auth.apiKey ? { authorization: `Bearer ${auth.apiKey}` } : {}
15717
15671
  } });
@@ -15746,14 +15700,14 @@ var DomainsZoneFileCommand = class DomainsZoneFileCommand extends Command {
15746
15700
  };
15747
15701
  //#endregion
15748
15702
  //#region src/oclif/commands/emails-latest.ts
15749
- const DEFAULT_LIMIT = 10;
15750
- const MAX_LIMIT = 100;
15703
+ const DEFAULT_LIMIT$1 = 10;
15704
+ const MAX_LIMIT$1 = 100;
15751
15705
  const SUBJECT_DISPLAY_WIDTH = 50;
15752
15706
  const ADDRESS_DISPLAY_WIDTH = 32;
15753
15707
  const ID_DISPLAY_WIDTH_SHORT = 8;
15754
15708
  const ID_DISPLAY_WIDTH_FULL = 36;
15755
15709
  const RECEIVED_DISPLAY_WIDTH = 19;
15756
- function truncate$1(value, width) {
15710
+ function truncate$2(value, width) {
15757
15711
  if (value.length <= width) return value.padEnd(width);
15758
15712
  return `${value.slice(0, width - 3)}...`;
15759
15713
  }
@@ -15767,10 +15721,10 @@ function formatReceivedAt(value) {
15767
15721
  function pickIdWidth(isTty) {
15768
15722
  return isTty ? ID_DISPLAY_WIDTH_SHORT : ID_DISPLAY_WIDTH_FULL;
15769
15723
  }
15770
- function formatRow(email, idWidth) {
15771
- return `${truncate$1(email.id.slice(0, idWidth), idWidth)} ${formatReceivedAt(email.received_at)} ${truncate$1(email.sender ?? "", ADDRESS_DISPLAY_WIDTH)} ${truncate$1(email.recipient ?? "", ADDRESS_DISPLAY_WIDTH)} ${truncate$1((email.subject ?? "").replace(/\s+/g, " "), SUBJECT_DISPLAY_WIDTH)}`;
15724
+ function formatRow$1(email, idWidth) {
15725
+ return `${truncate$2(email.id.slice(0, idWidth), idWidth)} ${formatReceivedAt(email.received_at)} ${truncate$2(email.sender ?? "", ADDRESS_DISPLAY_WIDTH)} ${truncate$2(email.recipient ?? "", ADDRESS_DISPLAY_WIDTH)} ${truncate$2((email.subject ?? "").replace(/\s+/g, " "), SUBJECT_DISPLAY_WIDTH)}`;
15772
15726
  }
15773
- function formatHeader(idWidth) {
15727
+ function formatHeader$1(idWidth) {
15774
15728
  return `${"ID".padEnd(idWidth)} ${"RECEIVED (UTC)".padEnd(RECEIVED_DISPLAY_WIDTH)} ${"FROM".padEnd(ADDRESS_DISPLAY_WIDTH)} ${"TO".padEnd(ADDRESS_DISPLAY_WIDTH)} SUBJECT`;
15775
15729
  }
15776
15730
  var EmailsLatestCommand = class EmailsLatestCommand extends Command {
@@ -15791,21 +15745,16 @@ var EmailsLatestCommand = class EmailsLatestCommand extends Command {
15791
15745
  description: "Primitive API key override (defaults to PRIMITIVE_API_KEY or saved OAuth login credentials)",
15792
15746
  env: "PRIMITIVE_API_KEY"
15793
15747
  }),
15794
- "api-base-url-1": Flags.string({
15748
+ "api-base-url": Flags.string({
15795
15749
  description: "Override the primary API base URL. Internal testing only; not documented to customers.",
15796
- env: "PRIMITIVE_API_BASE_URL_1",
15797
- hidden: true
15798
- }),
15799
- "api-base-url-2": Flags.string({
15800
- description: "Override the attachments-supporting send host base URL. Internal testing only; not documented to customers.",
15801
- env: "PRIMITIVE_API_BASE_URL_2",
15750
+ env: "PRIMITIVE_API_BASE_URL",
15802
15751
  hidden: true
15803
15752
  }),
15804
15753
  limit: Flags.integer({
15805
- description: `Number of rows to print (1-${MAX_LIMIT}, default ${DEFAULT_LIMIT}).`,
15806
- default: DEFAULT_LIMIT,
15754
+ description: `Number of rows to print (1-${MAX_LIMIT$1}, default ${DEFAULT_LIMIT$1}).`,
15755
+ default: DEFAULT_LIMIT$1,
15807
15756
  min: 1,
15808
- max: MAX_LIMIT
15757
+ max: MAX_LIMIT$1
15809
15758
  }),
15810
15759
  json: Flags.boolean({ description: "Print the raw response envelope (with full UUIDs and meta) as JSON on STDOUT instead of the text table. Useful for piping into `jq`, capturing ids for follow-up commands, or scripting." }),
15811
15760
  time: Flags.boolean({ description: TIME_FLAG_DESCRIPTION })
@@ -15815,8 +15764,7 @@ var EmailsLatestCommand = class EmailsLatestCommand extends Command {
15815
15764
  await runWithTiming(flags.time, async () => {
15816
15765
  const { apiClient, auth, baseUrlOverridden } = await createAuthenticatedCliApiClient({
15817
15766
  apiKey: flags["api-key"],
15818
- apiBaseUrl1: flags["api-base-url-1"],
15819
- apiBaseUrl2: flags["api-base-url-2"],
15767
+ apiBaseUrl: flags["api-base-url"],
15820
15768
  configDir: this.config.configDir
15821
15769
  });
15822
15770
  const result = await listEmails({
@@ -15847,8 +15795,8 @@ var EmailsLatestCommand = class EmailsLatestCommand extends Command {
15847
15795
  return;
15848
15796
  }
15849
15797
  const idWidth = pickIdWidth(Boolean(process.stdout.isTTY));
15850
- process.stderr.write(`${formatHeader(idWidth)}\n`);
15851
- for (const row of rows) this.log(formatRow(row, idWidth));
15798
+ process.stderr.write(`${formatHeader$1(idWidth)}\n`);
15799
+ for (const row of rows) this.log(formatRow$1(row, idWidth));
15852
15800
  });
15853
15801
  }
15854
15802
  };
@@ -15871,14 +15819,9 @@ var EmailsWaitCommand = class EmailsWaitCommand extends Command {
15871
15819
  description: "Primitive API key override (defaults to PRIMITIVE_API_KEY or saved OAuth login credentials)",
15872
15820
  env: "PRIMITIVE_API_KEY"
15873
15821
  }),
15874
- "api-base-url-1": Flags.string({
15822
+ "api-base-url": Flags.string({
15875
15823
  description: "Override the primary API base URL. Internal testing only; not documented to customers.",
15876
- env: "PRIMITIVE_API_BASE_URL_1",
15877
- hidden: true
15878
- }),
15879
- "api-base-url-2": Flags.string({
15880
- description: "Override the attachments-supporting send host base URL. Internal testing only; not documented to customers.",
15881
- env: "PRIMITIVE_API_BASE_URL_2",
15824
+ env: "PRIMITIVE_API_BASE_URL",
15882
15825
  hidden: true
15883
15826
  }),
15884
15827
  body: Flags.string({ description: "Full-text body filter" }),
@@ -15922,8 +15865,7 @@ var EmailsWaitCommand = class EmailsWaitCommand extends Command {
15922
15865
  const { flags } = await this.parse(EmailsWaitCommand);
15923
15866
  const { apiClient, auth, baseUrlOverridden } = await createAuthenticatedCliApiClient({
15924
15867
  apiKey: flags["api-key"],
15925
- apiBaseUrl1: flags["api-base-url-1"],
15926
- apiBaseUrl2: flags["api-base-url-2"],
15868
+ apiBaseUrl: flags["api-base-url"],
15927
15869
  configDir: this.config.configDir
15928
15870
  });
15929
15871
  let since;
@@ -15965,10 +15907,10 @@ var EmailsWaitCommand = class EmailsWaitCommand extends Command {
15965
15907
  for (const email of collectNewAcceptedEmails(page.rows, seenIds)) {
15966
15908
  if (flags.table) {
15967
15909
  if (!headerPrinted) {
15968
- process.stderr.write(`${formatHeader(idWidth)}\n`);
15910
+ process.stderr.write(`${formatHeader$1(idWidth)}\n`);
15969
15911
  headerPrinted = true;
15970
15912
  }
15971
- this.log(formatRow(email, idWidth));
15913
+ this.log(formatRow$1(email, idWidth));
15972
15914
  } else this.log(JSON.stringify(email));
15973
15915
  matched += 1;
15974
15916
  if (matched >= flags.number) return;
@@ -15999,14 +15941,9 @@ var EmailsWatchCommand = class EmailsWatchCommand extends Command {
15999
15941
  description: "Primitive API key override (defaults to PRIMITIVE_API_KEY or saved OAuth login credentials)",
16000
15942
  env: "PRIMITIVE_API_KEY"
16001
15943
  }),
16002
- "api-base-url-1": Flags.string({
15944
+ "api-base-url": Flags.string({
16003
15945
  description: "Override the primary API base URL. Internal testing only; not documented to customers.",
16004
- env: "PRIMITIVE_API_BASE_URL_1",
16005
- hidden: true
16006
- }),
16007
- "api-base-url-2": Flags.string({
16008
- description: "Override the attachments-supporting send host base URL. Internal testing only; not documented to customers.",
16009
- env: "PRIMITIVE_API_BASE_URL_2",
15946
+ env: "PRIMITIVE_API_BASE_URL",
16010
15947
  hidden: true
16011
15948
  }),
16012
15949
  body: Flags.string({ description: "Full-text body filter" }),
@@ -16046,8 +15983,7 @@ var EmailsWatchCommand = class EmailsWatchCommand extends Command {
16046
15983
  const { flags } = await this.parse(EmailsWatchCommand);
16047
15984
  const { apiClient, auth, baseUrlOverridden } = await createAuthenticatedCliApiClient({
16048
15985
  apiKey: flags["api-key"],
16049
- apiBaseUrl1: flags["api-base-url-1"],
16050
- apiBaseUrl2: flags["api-base-url-2"],
15986
+ apiBaseUrl: flags["api-base-url"],
16051
15987
  configDir: this.config.configDir
16052
15988
  });
16053
15989
  let since;
@@ -16090,10 +16026,10 @@ var EmailsWatchCommand = class EmailsWatchCommand extends Command {
16090
16026
  if (flags.jsonl) this.log(JSON.stringify(email));
16091
16027
  else {
16092
16028
  if (!headerPrinted) {
16093
- process.stderr.write(`${formatHeader(idWidth)}\n`);
16029
+ process.stderr.write(`${formatHeader$1(idWidth)}\n`);
16094
16030
  headerPrinted = true;
16095
16031
  }
16096
- this.log(formatRow(email, idWidth));
16032
+ this.log(formatRow$1(email, idWidth));
16097
16033
  }
16098
16034
  printed += 1;
16099
16035
  if (flags.number && printed >= flags.number) return;
@@ -16792,14 +16728,9 @@ var FunctionsDeployCommand = class FunctionsDeployCommand extends Command {
16792
16728
  description: "Primitive API key override (defaults to PRIMITIVE_API_KEY or saved OAuth login credentials)",
16793
16729
  env: "PRIMITIVE_API_KEY"
16794
16730
  }),
16795
- "api-base-url-1": Flags.string({
16731
+ "api-base-url": Flags.string({
16796
16732
  description: "Override the primary API base URL. Internal testing only; not documented to customers.",
16797
- env: "PRIMITIVE_API_BASE_URL_1",
16798
- hidden: true
16799
- }),
16800
- "api-base-url-2": Flags.string({
16801
- description: "Override the attachments-supporting send host base URL. Internal testing only; not documented to customers.",
16802
- env: "PRIMITIVE_API_BASE_URL_2",
16733
+ env: "PRIMITIVE_API_BASE_URL",
16803
16734
  hidden: true
16804
16735
  }),
16805
16736
  name: Flags.string({
@@ -16877,8 +16808,7 @@ var FunctionsDeployCommand = class FunctionsDeployCommand extends Command {
16877
16808
  emitRawSendMailFetchWarning(code, (chunk) => process.stderr.write(chunk));
16878
16809
  const { apiClient, auth, baseUrlOverridden } = await createAuthenticatedCliApiClient({
16879
16810
  apiKey: flags["api-key"],
16880
- apiBaseUrl1: flags["api-base-url-1"],
16881
- apiBaseUrl2: flags["api-base-url-2"],
16811
+ apiBaseUrl: flags["api-base-url"],
16882
16812
  configDir: this.config.configDir
16883
16813
  });
16884
16814
  const authFailureContext = {
@@ -16992,8 +16922,7 @@ var FunctionsDeployCommand = class FunctionsDeployCommand extends Command {
16992
16922
  }
16993
16923
  const { apiClient, auth, baseUrlOverridden } = await createAuthenticatedCliApiClient({
16994
16924
  apiKey: flags["api-key"],
16995
- apiBaseUrl1: flags["api-base-url-1"],
16996
- apiBaseUrl2: flags["api-base-url-2"],
16925
+ apiBaseUrl: flags["api-base-url"],
16997
16926
  configDir: this.config.configDir
16998
16927
  });
16999
16928
  const authFailureContext = {
@@ -17082,8 +17011,8 @@ const PRIMITIVE_TEAM_AUTHOR = {
17082
17011
  name: "Primitive Team",
17083
17012
  url: "https://primitive.dev"
17084
17013
  };
17085
- const SDK_VERSION_RANGE = "^0.35.0";
17086
- const CLI_VERSION_RANGE = "^0.35.0";
17014
+ const SDK_VERSION_RANGE = "^0.35.1";
17015
+ const CLI_VERSION_RANGE = "^0.35.1";
17087
17016
  const ESBUILD_VERSION_RANGE = "^0.27.0";
17088
17017
  function renderHandler() {
17089
17018
  return `// env.PRIMITIVE_API_KEY, env.PRIMITIVE_WEBHOOK_SECRET, and
@@ -17240,7 +17169,7 @@ export default {
17240
17169
 
17241
17170
  const client = createPrimitiveClient({
17242
17171
  apiKey: env.PRIMITIVE_API_KEY,
17243
- apiBaseUrl1: env.PRIMITIVE_API_BASE_URL,
17172
+ apiBaseUrl: env.PRIMITIVE_API_BASE_URL,
17244
17173
  });
17245
17174
 
17246
17175
  // To add an LLM or another API, store its key as a Function secret.
@@ -17264,7 +17193,7 @@ export default {
17264
17193
  // route "support@" to a ticketing flow and "sales@" to a lead
17265
17194
  // capture flow before calling client.reply.
17266
17195
 
17267
- // client.reply routes through POST /api/v1/emails/{id}/reply
17196
+ // client.reply routes through POST /v1/emails/{id}/reply
17268
17197
  // (NOT /send-mail) so the server derives recipients, the
17269
17198
  // \`Re: <parent>\` subject, threading headers, and the
17270
17199
  // in_reply_to_email_id foreign key automatically. The FK is
@@ -17645,14 +17574,9 @@ var FunctionsLogsCommand = class FunctionsLogsCommand extends Command {
17645
17574
  description: "Primitive API key override (defaults to PRIMITIVE_API_KEY or saved OAuth login credentials)",
17646
17575
  env: "PRIMITIVE_API_KEY"
17647
17576
  }),
17648
- "api-base-url-1": Flags.string({
17577
+ "api-base-url": Flags.string({
17649
17578
  description: "Override the primary API base URL. Internal testing only; not documented to customers.",
17650
- env: "PRIMITIVE_API_BASE_URL_1",
17651
- hidden: true
17652
- }),
17653
- "api-base-url-2": Flags.string({
17654
- description: "Override the attachments-supporting send host base URL. Internal testing only; not documented to customers.",
17655
- env: "PRIMITIVE_API_BASE_URL_2",
17579
+ env: "PRIMITIVE_API_BASE_URL",
17656
17580
  hidden: true
17657
17581
  }),
17658
17582
  id: Flags.string({
@@ -17683,8 +17607,7 @@ var FunctionsLogsCommand = class FunctionsLogsCommand extends Command {
17683
17607
  await runWithTiming(flags.time, async () => {
17684
17608
  const { apiClient, auth, baseUrlOverridden } = await createAuthenticatedCliApiClient({
17685
17609
  apiKey: flags["api-key"],
17686
- apiBaseUrl1: flags["api-base-url-1"],
17687
- apiBaseUrl2: flags["api-base-url-2"],
17610
+ apiBaseUrl: flags["api-base-url"],
17688
17611
  configDir: this.config.configDir
17689
17612
  });
17690
17613
  const seenIds = /* @__PURE__ */ new Set();
@@ -17843,14 +17766,9 @@ var FunctionsRedeployCommand = class FunctionsRedeployCommand extends Command {
17843
17766
  description: "Primitive API key override (defaults to PRIMITIVE_API_KEY or saved OAuth login credentials)",
17844
17767
  env: "PRIMITIVE_API_KEY"
17845
17768
  }),
17846
- "api-base-url-1": Flags.string({
17769
+ "api-base-url": Flags.string({
17847
17770
  description: "Override the primary API base URL. Internal testing only; not documented to customers.",
17848
- env: "PRIMITIVE_API_BASE_URL_1",
17849
- hidden: true
17850
- }),
17851
- "api-base-url-2": Flags.string({
17852
- description: "Override the attachments-supporting send host base URL. Internal testing only; not documented to customers.",
17853
- env: "PRIMITIVE_API_BASE_URL_2",
17771
+ env: "PRIMITIVE_API_BASE_URL",
17854
17772
  hidden: true
17855
17773
  }),
17856
17774
  id: Flags.string({
@@ -17919,8 +17837,7 @@ var FunctionsRedeployCommand = class FunctionsRedeployCommand extends Command {
17919
17837
  emitRawSendMailFetchWarning(code, (chunk) => process.stderr.write(chunk));
17920
17838
  const { apiClient, auth, baseUrlOverridden } = await createAuthenticatedCliApiClient({
17921
17839
  apiKey: flags["api-key"],
17922
- apiBaseUrl1: flags["api-base-url-1"],
17923
- apiBaseUrl2: flags["api-base-url-2"],
17840
+ apiBaseUrl: flags["api-base-url"],
17924
17841
  configDir: this.config.configDir
17925
17842
  });
17926
17843
  const authFailureContext = {
@@ -18103,14 +18020,9 @@ var FunctionsSetSecretCommand = class FunctionsSetSecretCommand extends Command
18103
18020
  description: "Primitive API key override (defaults to PRIMITIVE_API_KEY or saved OAuth login credentials)",
18104
18021
  env: "PRIMITIVE_API_KEY"
18105
18022
  }),
18106
- "api-base-url-1": Flags.string({
18023
+ "api-base-url": Flags.string({
18107
18024
  description: "Override the primary API base URL. Internal testing only; not documented to customers.",
18108
- env: "PRIMITIVE_API_BASE_URL_1",
18109
- hidden: true
18110
- }),
18111
- "api-base-url-2": Flags.string({
18112
- description: "Override the attachments-supporting send host base URL. Internal testing only; not documented to customers.",
18113
- env: "PRIMITIVE_API_BASE_URL_2",
18025
+ env: "PRIMITIVE_API_BASE_URL",
18114
18026
  hidden: true
18115
18027
  }),
18116
18028
  id: Flags.string({
@@ -18134,8 +18046,7 @@ var FunctionsSetSecretCommand = class FunctionsSetSecretCommand extends Command
18134
18046
  await runWithTiming(flags.time, async () => {
18135
18047
  const { apiClient, auth, baseUrlOverridden } = await createAuthenticatedCliApiClient({
18136
18048
  apiKey: flags["api-key"],
18137
- apiBaseUrl1: flags["api-base-url-1"],
18138
- apiBaseUrl2: flags["api-base-url-2"],
18049
+ apiBaseUrl: flags["api-base-url"],
18139
18050
  configDir: this.config.configDir
18140
18051
  });
18141
18052
  const authFailureContext = {
@@ -18332,14 +18243,9 @@ var FunctionsTestFunctionCommand = class FunctionsTestFunctionCommand extends Co
18332
18243
  description: "Primitive API key override (defaults to PRIMITIVE_API_KEY or saved OAuth login credentials)",
18333
18244
  env: "PRIMITIVE_API_KEY"
18334
18245
  }),
18335
- "api-base-url-1": Flags.string({
18336
- description: API_BASE_URL_1_FLAG_DESCRIPTION,
18337
- env: "PRIMITIVE_API_BASE_URL_1",
18338
- hidden: true
18339
- }),
18340
- "api-base-url-2": Flags.string({
18341
- description: API_BASE_URL_2_FLAG_DESCRIPTION,
18342
- env: "PRIMITIVE_API_BASE_URL_2",
18246
+ "api-base-url": Flags.string({
18247
+ description: API_BASE_URL_FLAG_DESCRIPTION,
18248
+ env: "PRIMITIVE_API_BASE_URL",
18343
18249
  hidden: true
18344
18250
  }),
18345
18251
  id: Flags.string({
@@ -18367,8 +18273,7 @@ var FunctionsTestFunctionCommand = class FunctionsTestFunctionCommand extends Co
18367
18273
  const shouldShowSends = flags["show-sends"];
18368
18274
  const { apiClient, auth, baseUrlOverridden } = await createAuthenticatedCliApiClient({
18369
18275
  apiKey: flags["api-key"],
18370
- apiBaseUrl1: flags["api-base-url-1"],
18371
- apiBaseUrl2: flags["api-base-url-2"],
18276
+ apiBaseUrl: flags["api-base-url"],
18372
18277
  configDir: this.config.configDir
18373
18278
  });
18374
18279
  await runWithTiming(flags.time, async () => {
@@ -18479,7 +18384,7 @@ function formatInboxDate(value) {
18479
18384
  const pad = (n) => String(n).padStart(2, "0");
18480
18385
  return `${d.getUTCFullYear()}-${pad(d.getUTCMonth() + 1)}-${pad(d.getUTCDate())} ${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())}:${pad(d.getUTCSeconds())} UTC`;
18481
18386
  }
18482
- function truncate(value, width) {
18387
+ function truncate$1(value, width) {
18483
18388
  if (value.length <= width) return value.padEnd(width);
18484
18389
  return `${value.slice(0, width - 3)}...`;
18485
18390
  }
@@ -18529,7 +18434,7 @@ function formatDomainHeader() {
18529
18434
  }
18530
18435
  function formatDomainRow(domain) {
18531
18436
  return [
18532
- truncate(domain.domain, DOMAIN_DISPLAY_WIDTH),
18437
+ truncate$1(domain.domain, DOMAIN_DISPLAY_WIDTH),
18533
18438
  statusText(domain.status).padEnd(STATUS_DISPLAY_WIDTH),
18534
18439
  yesNo(domain.receiving_ready).padEnd(BOOL_DISPLAY_WIDTH),
18535
18440
  yesNo(domain.processing_ready).padEnd(BOOL_DISPLAY_WIDTH),
@@ -18575,14 +18480,9 @@ var InboxStatusCommand = class InboxStatusCommand extends Command {
18575
18480
  description: "Primitive API key override (defaults to PRIMITIVE_API_KEY or saved OAuth login credentials)",
18576
18481
  env: "PRIMITIVE_API_KEY"
18577
18482
  }),
18578
- "api-base-url-1": Flags.string({
18579
- description: API_BASE_URL_1_FLAG_DESCRIPTION,
18580
- env: "PRIMITIVE_API_BASE_URL_1",
18581
- hidden: true
18582
- }),
18583
- "api-base-url-2": Flags.string({
18584
- description: API_BASE_URL_2_FLAG_DESCRIPTION,
18585
- env: "PRIMITIVE_API_BASE_URL_2",
18483
+ "api-base-url": Flags.string({
18484
+ description: API_BASE_URL_FLAG_DESCRIPTION,
18485
+ env: "PRIMITIVE_API_BASE_URL",
18586
18486
  hidden: true
18587
18487
  }),
18588
18488
  domain: Flags.string({ description: "Focus domain readiness and recent email fields on one domain returned by the inbox status API." }),
@@ -18594,8 +18494,7 @@ var InboxStatusCommand = class InboxStatusCommand extends Command {
18594
18494
  await runWithTiming(flags.time, async () => {
18595
18495
  const { apiClient, auth, baseUrlOverridden } = await createAuthenticatedCliApiClient({
18596
18496
  apiKey: flags["api-key"],
18597
- apiBaseUrl1: flags["api-base-url-1"],
18598
- apiBaseUrl2: flags["api-base-url-2"],
18497
+ apiBaseUrl: flags["api-base-url"],
18599
18498
  configDir: this.config.configDir
18600
18499
  });
18601
18500
  const result = await getInboxStatus({
@@ -18750,14 +18649,9 @@ var InboxSetupCommand = class InboxSetupCommand extends Command {
18750
18649
  description: "Primitive API key override (defaults to PRIMITIVE_API_KEY or saved OAuth login credentials)",
18751
18650
  env: "PRIMITIVE_API_KEY"
18752
18651
  }),
18753
- "api-base-url-1": Flags.string({
18754
- description: API_BASE_URL_1_FLAG_DESCRIPTION,
18755
- env: "PRIMITIVE_API_BASE_URL_1",
18756
- hidden: true
18757
- }),
18758
- "api-base-url-2": Flags.string({
18759
- description: API_BASE_URL_2_FLAG_DESCRIPTION,
18760
- env: "PRIMITIVE_API_BASE_URL_2",
18652
+ "api-base-url": Flags.string({
18653
+ description: API_BASE_URL_FLAG_DESCRIPTION,
18654
+ env: "PRIMITIVE_API_BASE_URL",
18761
18655
  hidden: true
18762
18656
  }),
18763
18657
  json: Flags.boolean({ description: "Print structured readiness, receive address, commands, proof metadata, and raw status as JSON." }),
@@ -18768,8 +18662,7 @@ var InboxSetupCommand = class InboxSetupCommand extends Command {
18768
18662
  await runWithTiming(flags.time, async () => {
18769
18663
  const { apiClient, auth, baseUrlOverridden } = await createAuthenticatedCliApiClient({
18770
18664
  apiKey: flags["api-key"],
18771
- apiBaseUrl1: flags["api-base-url-1"],
18772
- apiBaseUrl2: flags["api-base-url-2"],
18665
+ apiBaseUrl: flags["api-base-url"],
18773
18666
  configDir: this.config.configDir
18774
18667
  });
18775
18668
  const result = await getInboxStatus({
@@ -18836,14 +18729,14 @@ function retryAfterSeconds$1(result) {
18836
18729
  }
18837
18730
  async function checkExistingLogin(params) {
18838
18731
  const requestConfig = resolveCliApiRequestConfig({
18839
- apiBaseUrl1: params.apiBaseUrl1,
18732
+ apiBaseUrl: params.apiBaseUrl,
18840
18733
  configDir: params.configDir
18841
18734
  });
18842
- const probeApiBaseUrl1 = requestConfig.apiBaseUrl1 ?? params.credentials.api_base_url_1;
18735
+ const probeApiBaseUrl = requestConfig.apiBaseUrl ?? params.credentials.api_base_url;
18843
18736
  let credentials = params.credentials;
18844
18737
  try {
18845
18738
  credentials = await refreshStoredCliCredentials({
18846
- apiBaseUrl1: probeApiBaseUrl1,
18739
+ apiBaseUrl: probeApiBaseUrl,
18847
18740
  configDir: params.configDir,
18848
18741
  credentials,
18849
18742
  credentialsLockHeld: params.credentialsLockHeld,
@@ -18859,8 +18752,7 @@ async function checkExistingLogin(params) {
18859
18752
  }
18860
18753
  const apiClient = new PrimitiveApiClient({
18861
18754
  apiKey: credentials.access_token,
18862
- apiBaseUrl1: probeApiBaseUrl1,
18863
- apiBaseUrl2: requestConfig.resolvedApiBaseUrl2,
18755
+ apiBaseUrl: probeApiBaseUrl,
18864
18756
  headers: requestConfig.headers
18865
18757
  });
18866
18758
  const result = await (params.checkAccount ?? ((client) => getAccount({
@@ -18870,7 +18762,7 @@ async function checkExistingLogin(params) {
18870
18762
  if (!result.error) return { status: "valid" };
18871
18763
  const payload = extractErrorPayload(result.error);
18872
18764
  const code = extractErrorCode(payload);
18873
- const baseUrlDiffersFromSaved = requestConfig.baseUrlOverridden && requestConfig.apiBaseUrl1 !== params.credentials.api_base_url_1;
18765
+ const baseUrlDiffersFromSaved = requestConfig.baseUrlOverridden && requestConfig.apiBaseUrl !== params.credentials.api_base_url;
18874
18766
  if (code === API_ERROR_CODES.unauthorized && !baseUrlDiffersFromSaved) {
18875
18767
  deleteCliCredentials(params.configDir);
18876
18768
  process.stderr.write("Removed saved Primitive CLI OAuth credentials because the existing session was rejected during login. Continuing with a fresh login.\n");
@@ -18891,9 +18783,9 @@ var LoginCommand$1 = class extends Command {
18891
18783
  "<%= config.bin %> login --force"
18892
18784
  ];
18893
18785
  static flags = {
18894
- "api-base-url-1": Flags.string({
18786
+ "api-base-url": Flags.string({
18895
18787
  description: "Override the primary API base URL. Internal testing only; not documented to customers.",
18896
- env: "PRIMITIVE_API_BASE_URL_1",
18788
+ env: "PRIMITIVE_API_BASE_URL",
18897
18789
  hidden: true
18898
18790
  }),
18899
18791
  "device-name": Flags.string({ description: "Device name shown in the browser approval screen" }),
@@ -18926,10 +18818,10 @@ var LoginCommand$1 = class extends Command {
18926
18818
  }
18927
18819
  async runWithCredentialLock(flags, retryCommand) {
18928
18820
  const { apiClient, requestConfig } = createCliApiClient({
18929
- apiBaseUrl1: flags["api-base-url-1"],
18821
+ apiBaseUrl: flags["api-base-url"],
18930
18822
  configDir: this.config.configDir
18931
18823
  });
18932
- const apiBaseUrl1 = requestConfig.resolvedApiBaseUrl1;
18824
+ const apiBaseUrl = requestConfig.resolvedApiBaseUrl;
18933
18825
  let existing;
18934
18826
  try {
18935
18827
  existing = loadCliCredentials(this.config.configDir);
@@ -18942,7 +18834,7 @@ var LoginCommand$1 = class extends Command {
18942
18834
  if (existing && flags.force) process.stderr.write("Replacing saved Primitive CLI credentials after browser approval because --force was set.\n");
18943
18835
  else if (existing) {
18944
18836
  const existingStatus = await checkExistingLogin({
18945
- apiBaseUrl1: flags["api-base-url-1"],
18837
+ apiBaseUrl: flags["api-base-url"],
18946
18838
  configDir: this.config.configDir,
18947
18839
  credentials: existing,
18948
18840
  credentialsLockHeld: true
@@ -18988,7 +18880,7 @@ var LoginCommand$1 = class extends Command {
18988
18880
  deleteChatState(this.config.configDir);
18989
18881
  saveCliCredentials(this.config.configDir, {
18990
18882
  access_token: login.access_token,
18991
- api_base_url_1: apiBaseUrl1,
18883
+ api_base_url: apiBaseUrl,
18992
18884
  auth_method: "oauth",
18993
18885
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
18994
18886
  expires_at: cliAccessTokenExpiresAt(login.expires_in),
@@ -19052,9 +18944,11 @@ function normalizeEmail(email) {
19052
18944
  }
19053
18945
  function pendingSignupFromJson(value) {
19054
18946
  if (!isRecord(value)) return null;
19055
- if (typeof value.signup_token !== "string" || typeof value.email !== "string" || typeof value.expires_in !== "number" || typeof value.resend_after !== "number" || typeof value.verification_code_length !== "number" || typeof value.api_base_url_1 !== "string" || typeof value.created_at !== "string" || typeof value.expires_at !== "string") return null;
18947
+ if (typeof value.signup_token !== "string" || typeof value.email !== "string" || typeof value.expires_in !== "number" || typeof value.resend_after !== "number" || typeof value.verification_code_length !== "number" || typeof value.created_at !== "string" || typeof value.expires_at !== "string") return null;
18948
+ const apiBaseUrl = value.api_base_url ?? value.api_base_url_1;
18949
+ if (typeof apiBaseUrl !== "string") return null;
19056
18950
  return {
19057
- api_base_url_1: value.api_base_url_1,
18951
+ api_base_url: apiBaseUrl,
19058
18952
  created_at: value.created_at,
19059
18953
  email: value.email,
19060
18954
  expires_at: value.expires_at,
@@ -19070,20 +18964,20 @@ function pendingSignupPath(configDir) {
19070
18964
  function deletePendingAgentSignup(configDir) {
19071
18965
  rmSync(pendingSignupPath(configDir), { force: true });
19072
18966
  }
19073
- function pendingSignupFromStart(start, apiBaseUrl1) {
18967
+ function pendingSignupFromStart(start, apiBaseUrl) {
19074
18968
  return {
19075
18969
  ...start,
19076
- api_base_url_1: apiBaseUrl1,
18970
+ api_base_url: apiBaseUrl,
19077
18971
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
19078
18972
  expires_at: new Date(Date.now() + start.expires_in * 1e3).toISOString()
19079
18973
  };
19080
18974
  }
19081
- function savePendingAgentSignup(configDir, start, apiBaseUrl1) {
18975
+ function savePendingAgentSignup(configDir, start, apiBaseUrl) {
19082
18976
  mkdirSync(configDir, {
19083
18977
  mode: 448,
19084
18978
  recursive: true
19085
18979
  });
19086
- const pending = pendingSignupFromStart(start, apiBaseUrl1);
18980
+ const pending = pendingSignupFromStart(start, apiBaseUrl);
19087
18981
  const path = pendingSignupPath(configDir);
19088
18982
  const tempPath = join(configDir, `${PENDING_SIGNUP_FILE}.${process$1.pid}.${randomUUID()}.tmp`);
19089
18983
  try {
@@ -19097,7 +18991,7 @@ function savePendingAgentSignup(configDir, start, apiBaseUrl1) {
19097
18991
  throw error;
19098
18992
  }
19099
18993
  }
19100
- function loadPendingAgentSignup(configDir, apiBaseUrl1) {
18994
+ function loadPendingAgentSignup(configDir, apiBaseUrl) {
19101
18995
  const path = pendingSignupPath(configDir);
19102
18996
  let contents;
19103
18997
  try {
@@ -19116,7 +19010,7 @@ function loadPendingAgentSignup(configDir, apiBaseUrl1) {
19116
19010
  deletePendingAgentSignup(configDir);
19117
19011
  return null;
19118
19012
  }
19119
- if (pending.api_base_url_1 !== apiBaseUrl1) return null;
19013
+ if (pending.api_base_url !== apiBaseUrl) return null;
19120
19014
  if (new Date(pending.expires_at).getTime() <= Date.now()) {
19121
19015
  deletePendingAgentSignup(configDir);
19122
19016
  return null;
@@ -19126,7 +19020,7 @@ function loadPendingAgentSignup(configDir, apiBaseUrl1) {
19126
19020
  expires_in: Math.max(0, Math.ceil((new Date(pending.expires_at).getTime() - Date.now()) / 1e3))
19127
19021
  };
19128
19022
  }
19129
- function readPendingAgentSignupState(configDir, apiBaseUrl1) {
19023
+ function readPendingAgentSignupState(configDir, apiBaseUrl) {
19130
19024
  const path = pendingSignupPath(configDir);
19131
19025
  let contents;
19132
19026
  try {
@@ -19145,7 +19039,7 @@ function readPendingAgentSignupState(configDir, apiBaseUrl1) {
19145
19039
  deletePendingAgentSignup(configDir);
19146
19040
  return null;
19147
19041
  }
19148
- if (pending.api_base_url_1 !== apiBaseUrl1) return null;
19042
+ if (pending.api_base_url !== apiBaseUrl) return null;
19149
19043
  return pending;
19150
19044
  }
19151
19045
  function pendingSignupStartCommand(email) {
@@ -19153,7 +19047,7 @@ function pendingSignupStartCommand(email) {
19153
19047
  }
19154
19048
  function buildSignupStatus(params) {
19155
19049
  const copy = params.copy ?? DEFAULT_SIGNUP_COMMAND_COPY;
19156
- const pending = readPendingAgentSignupState(params.configDir, params.apiBaseUrl1);
19050
+ const pending = readPendingAgentSignupState(params.configDir, params.apiBaseUrl);
19157
19051
  if (!pending) return {
19158
19052
  code_length: null,
19159
19053
  confirm_command: null,
@@ -19200,11 +19094,11 @@ function writeSignupStatus(status) {
19200
19094
  }
19201
19095
  function runSignupStatus(params) {
19202
19096
  const { requestConfig } = createCliApiClient({
19203
- apiBaseUrl1: params.flags["api-base-url-1"],
19097
+ apiBaseUrl: params.flags["api-base-url"],
19204
19098
  configDir: params.configDir
19205
19099
  });
19206
19100
  const status = buildSignupStatus({
19207
- apiBaseUrl1: requestConfig.resolvedApiBaseUrl1,
19101
+ apiBaseUrl: requestConfig.resolvedApiBaseUrl,
19208
19102
  configDir: params.configDir,
19209
19103
  copy: params.copy,
19210
19104
  email: params.email
@@ -19217,7 +19111,7 @@ function runSignupStatus(params) {
19217
19111
  }
19218
19112
  function requirePendingSignupForEmail(params) {
19219
19113
  const copy = params.copy ?? DEFAULT_SIGNUP_COMMAND_COPY;
19220
- const pending = loadPendingAgentSignup(params.configDir, params.apiBaseUrl1);
19114
+ const pending = loadPendingAgentSignup(params.configDir, params.apiBaseUrl);
19221
19115
  if (!pending) throw cliError$2(`No pending ${copy.actionNoun} for ${params.email}. Run \`primitive signup status ${params.email}\` to inspect pending state, or \`primitive ${copy.startCommand(params.email)}\` first.`);
19222
19116
  if (normalizeEmail(pending.email) !== normalizeEmail(params.email)) throw cliError$2(`Pending ${copy.actionNoun} is for ${pending.email}, not ${params.email}. Run \`primitive signup status\` to inspect it, or \`primitive ${copy.startCommand(params.email)} --force\` to replace it.`);
19223
19117
  return pending;
@@ -19280,7 +19174,7 @@ async function checkExistingCredentials(params) {
19280
19174
  }
19281
19175
  if (!existing) return;
19282
19176
  const existingStatus = await checkExistingLoginFn({
19283
- apiBaseUrl1: params.apiBaseUrl1,
19177
+ apiBaseUrl: params.apiBaseUrl,
19284
19178
  configDir: params.configDir,
19285
19179
  credentials: existing,
19286
19180
  credentialsLockHeld: true
@@ -19299,7 +19193,7 @@ function saveSignupCredentials(params) {
19299
19193
  deleteChatState(params.configDir);
19300
19194
  saveCliCredentials(params.configDir, {
19301
19195
  access_token: params.signup.access_token,
19302
- api_base_url_1: params.apiBaseUrl1,
19196
+ api_base_url: params.apiBaseUrl,
19303
19197
  auth_method: "oauth",
19304
19198
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
19305
19199
  expires_at: cliAccessTokenExpiresAt(params.signup.expires_in),
@@ -19318,7 +19212,7 @@ function writeStartInstructions(start, copy = DEFAULT_SIGNUP_COMMAND_COPY) {
19318
19212
  }
19319
19213
  async function startSignup(params) {
19320
19214
  const copy = params.copy ?? DEFAULT_SIGNUP_COMMAND_COPY;
19321
- const existingPending = loadPendingAgentSignup(params.configDir, params.apiBaseUrl1);
19215
+ const existingPending = loadPendingAgentSignup(params.configDir, params.apiBaseUrl);
19322
19216
  if (existingPending && !params.flags.force) {
19323
19217
  if (normalizeEmail(existingPending.email) === normalizeEmail(params.email)) {
19324
19218
  process$1.stderr.write(`Continuing pending Primitive ${copy.actionNoun} for ${existingPending.email}.\n`);
@@ -19353,7 +19247,7 @@ async function startSignup(params) {
19353
19247
  const startResult = unwrapData$1(started.data);
19354
19248
  if (!startResult) throw cliError$2("Primitive API returned an empty agent signup response.");
19355
19249
  return {
19356
- pending: savePendingAgentSignup(params.configDir, startResult, params.apiBaseUrl1),
19250
+ pending: savePendingAgentSignup(params.configDir, startResult, params.apiBaseUrl),
19357
19251
  started: true
19358
19252
  };
19359
19253
  }
@@ -19373,7 +19267,7 @@ async function resendVerificationCode(params) {
19373
19267
  verification_code_length: resend.verification_code_length
19374
19268
  } : params.start;
19375
19269
  return {
19376
- pending: savePendingAgentSignup(params.configDir, next, params.apiBaseUrl1),
19270
+ pending: savePendingAgentSignup(params.configDir, next, params.apiBaseUrl),
19377
19271
  resent: true
19378
19272
  };
19379
19273
  }
@@ -19397,18 +19291,18 @@ async function runSignupStartWithCredentialLock(params) {
19397
19291
  const promptRequiredFn = deps.promptRequired ?? promptRequired;
19398
19292
  const email = params.email ?? await promptRequiredFn("Email: ");
19399
19293
  await checkExistingCredentials({
19400
- apiBaseUrl1: flags["api-base-url-1"],
19294
+ apiBaseUrl: flags["api-base-url"],
19401
19295
  configDir,
19402
19296
  copy: params.copy,
19403
19297
  deps,
19404
19298
  flags
19405
19299
  });
19406
19300
  const { apiClient, requestConfig } = createCliApiClient({
19407
- apiBaseUrl1: flags["api-base-url-1"],
19301
+ apiBaseUrl: flags["api-base-url"],
19408
19302
  configDir
19409
19303
  });
19410
19304
  const start = await startSignup({
19411
- apiBaseUrl1: requestConfig.resolvedApiBaseUrl1,
19305
+ apiBaseUrl: requestConfig.resolvedApiBaseUrl,
19412
19306
  apiClient,
19413
19307
  configDir,
19414
19308
  copy: params.copy,
@@ -19422,19 +19316,19 @@ async function runSignupConfirmWithCredentialLock(params) {
19422
19316
  const { configDir, flags } = params;
19423
19317
  const deps = params.deps ?? {};
19424
19318
  if (!params.skipExistingCredentialCheck) await checkExistingCredentials({
19425
- apiBaseUrl1: flags["api-base-url-1"],
19319
+ apiBaseUrl: flags["api-base-url"],
19426
19320
  configDir,
19427
19321
  copy: params.copy,
19428
19322
  deps,
19429
19323
  flags
19430
19324
  });
19431
19325
  const { apiClient, requestConfig } = createCliApiClient({
19432
- apiBaseUrl1: flags["api-base-url-1"],
19326
+ apiBaseUrl: flags["api-base-url"],
19433
19327
  configDir
19434
19328
  });
19435
- const apiBaseUrl1 = requestConfig.resolvedApiBaseUrl1;
19329
+ const apiBaseUrl = requestConfig.resolvedApiBaseUrl;
19436
19330
  const pending = requirePendingSignupForEmail({
19437
- apiBaseUrl1,
19331
+ apiBaseUrl,
19438
19332
  copy: params.copy,
19439
19333
  configDir,
19440
19334
  email: params.email
@@ -19452,7 +19346,7 @@ async function runSignupConfirmWithCredentialLock(params) {
19452
19346
  const signup = unwrapData$1(verified.data);
19453
19347
  if (!signup) throw cliError$2("Primitive API returned an empty agent signup verification response.");
19454
19348
  saveSignupCredentials({
19455
- apiBaseUrl1,
19349
+ apiBaseUrl,
19456
19350
  configDir,
19457
19351
  signup
19458
19352
  });
@@ -19473,18 +19367,18 @@ async function runSignupResendWithCredentialLock(params) {
19473
19367
  const deps = params.deps ?? {};
19474
19368
  const copy = params.copy ?? DEFAULT_SIGNUP_COMMAND_COPY;
19475
19369
  const { apiClient, requestConfig } = createCliApiClient({
19476
- apiBaseUrl1: params.flags["api-base-url-1"],
19370
+ apiBaseUrl: params.flags["api-base-url"],
19477
19371
  configDir: params.configDir
19478
19372
  });
19479
19373
  const pending = params.email ? requirePendingSignupForEmail({
19480
- apiBaseUrl1: requestConfig.resolvedApiBaseUrl1,
19374
+ apiBaseUrl: requestConfig.resolvedApiBaseUrl,
19481
19375
  copy,
19482
19376
  configDir: params.configDir,
19483
19377
  email: params.email
19484
- }) : loadPendingAgentSignup(params.configDir, requestConfig.resolvedApiBaseUrl1);
19378
+ }) : loadPendingAgentSignup(params.configDir, requestConfig.resolvedApiBaseUrl);
19485
19379
  if (!pending) throw cliError$2(`No pending ${copy.actionNoun} found. Run \`primitive signup status\` to inspect pending state, or start one with \`${pendingSignupStartCommand()}\`.`);
19486
19380
  const resend = await resendVerificationCode({
19487
- apiBaseUrl1: requestConfig.resolvedApiBaseUrl1,
19381
+ apiBaseUrl: requestConfig.resolvedApiBaseUrl,
19488
19382
  apiClient,
19489
19383
  configDir: params.configDir,
19490
19384
  deps,
@@ -19497,20 +19391,20 @@ async function runSignupInteractiveWithCredentialLock(params) {
19497
19391
  const deps = params.deps ?? {};
19498
19392
  const promptRequiredFn = deps.promptRequired ?? promptRequired;
19499
19393
  await checkExistingCredentials({
19500
- apiBaseUrl1: flags["api-base-url-1"],
19394
+ apiBaseUrl: flags["api-base-url"],
19501
19395
  configDir,
19502
19396
  deps,
19503
19397
  flags
19504
19398
  });
19505
19399
  const { apiClient, requestConfig } = createCliApiClient({
19506
- apiBaseUrl1: flags["api-base-url-1"],
19400
+ apiBaseUrl: flags["api-base-url"],
19507
19401
  configDir
19508
19402
  });
19509
- const apiBaseUrl1 = requestConfig.resolvedApiBaseUrl1;
19510
- let start = flags.force ? null : loadPendingAgentSignup(configDir, apiBaseUrl1);
19403
+ const apiBaseUrl = requestConfig.resolvedApiBaseUrl;
19404
+ let start = flags.force ? null : loadPendingAgentSignup(configDir, apiBaseUrl);
19511
19405
  if (start) process$1.stderr.write(`Continuing pending Primitive signup for ${start.email}.\n`);
19512
19406
  else start = (await startSignup({
19513
- apiBaseUrl1,
19407
+ apiBaseUrl,
19514
19408
  apiClient,
19515
19409
  configDir,
19516
19410
  deps,
@@ -19524,7 +19418,7 @@ async function runSignupInteractiveWithCredentialLock(params) {
19524
19418
  const verificationCode = await promptRequiredFn(`Verification code (${start.verification_code_length} digits): `);
19525
19419
  if (verificationCode.toLowerCase() === "resend") {
19526
19420
  const resend = await resendVerificationCode({
19527
- apiBaseUrl1,
19421
+ apiBaseUrl,
19528
19422
  apiClient,
19529
19423
  configDir,
19530
19424
  deps,
@@ -19541,7 +19435,7 @@ async function runSignupInteractiveWithCredentialLock(params) {
19541
19435
  deps,
19542
19436
  email: start.email,
19543
19437
  flags: {
19544
- "api-base-url-1": flags["api-base-url-1"],
19438
+ "api-base-url": flags["api-base-url"],
19545
19439
  force: true
19546
19440
  },
19547
19441
  skipExistingCredentialCheck: true
@@ -19559,9 +19453,9 @@ async function runSignupInteractiveWithCredentialLock(params) {
19559
19453
  function commonStartFlags() {
19560
19454
  return {
19561
19455
  "accept-terms": Flags.boolean({ description: "Confirm acceptance of Primitive's Terms of Service and Privacy Policy" }),
19562
- "api-base-url-1": Flags.string({
19456
+ "api-base-url": Flags.string({
19563
19457
  description: "Override the primary API base URL. Internal testing only; not documented to customers.",
19564
- env: "PRIMITIVE_API_BASE_URL_1",
19458
+ env: "PRIMITIVE_API_BASE_URL",
19565
19459
  hidden: true
19566
19460
  }),
19567
19461
  "device-name": Flags.string({ description: "Device name used for the created CLI OAuth session" }),
@@ -19622,9 +19516,9 @@ var SignupConfirmCommand = class SignupConfirmCommand extends Command {
19622
19516
  static summary = "Confirm account signup";
19623
19517
  static examples = ["<%= config.bin %> signup confirm user@example.com 123456", "<%= config.bin %> signup confirm user@example.com 123456 --org-id 00000000-0000-4000-8000-000000000000"];
19624
19518
  static flags = {
19625
- "api-base-url-1": Flags.string({
19519
+ "api-base-url": Flags.string({
19626
19520
  description: "Override the primary API base URL. Internal testing only; not documented to customers.",
19627
- env: "PRIMITIVE_API_BASE_URL_1",
19521
+ env: "PRIMITIVE_API_BASE_URL",
19628
19522
  hidden: true
19629
19523
  }),
19630
19524
  force: Flags.boolean({
@@ -19661,9 +19555,9 @@ var SignupResendCommand = class SignupResendCommand extends Command {
19661
19555
  static description = "Resend the verification code for a pending signup.";
19662
19556
  static summary = "Resend signup verification code";
19663
19557
  static examples = ["<%= config.bin %> signup resend", "<%= config.bin %> signup resend user@example.com"];
19664
- static flags = { "api-base-url-1": Flags.string({
19558
+ static flags = { "api-base-url": Flags.string({
19665
19559
  description: "Override the primary API base URL. Internal testing only; not documented to customers.",
19666
- env: "PRIMITIVE_API_BASE_URL_1",
19560
+ env: "PRIMITIVE_API_BASE_URL",
19667
19561
  hidden: true
19668
19562
  }) };
19669
19563
  async run() {
@@ -19698,9 +19592,9 @@ var SignupStatusCommand = class SignupStatusCommand extends Command {
19698
19592
  "<%= config.bin %> signup status --json"
19699
19593
  ];
19700
19594
  static flags = {
19701
- "api-base-url-1": Flags.string({
19595
+ "api-base-url": Flags.string({
19702
19596
  description: "Override the primary API base URL. Internal testing only; not documented to customers.",
19703
- env: "PRIMITIVE_API_BASE_URL_1",
19597
+ env: "PRIMITIVE_API_BASE_URL",
19704
19598
  hidden: true
19705
19599
  }),
19706
19600
  json: Flags.boolean({ description: "Print pending signup status as JSON" })
@@ -19768,7 +19662,7 @@ async function runLogoutWithCredentialLock(params) {
19768
19662
  let authenticated;
19769
19663
  try {
19770
19664
  authenticated = await deps.createAuthenticatedCliApiClient({
19771
- apiBaseUrl1: params.flags["api-base-url-1"],
19665
+ apiBaseUrl: params.flags["api-base-url"],
19772
19666
  configDir: params.configDir,
19773
19667
  credentialsLockHeld: true
19774
19668
  });
@@ -19832,9 +19726,9 @@ var LogoutCommand = class LogoutCommand extends Command {
19832
19726
  static summary = "Log out and revoke the saved CLI OAuth grant";
19833
19727
  static examples = ["<%= config.bin %> logout", "<%= config.bin %> logout --force"];
19834
19728
  static flags = {
19835
- "api-base-url-1": Flags.string({
19729
+ "api-base-url": Flags.string({
19836
19730
  description: "Override the primary API base URL. Internal testing only; not documented to customers.",
19837
- env: "PRIMITIVE_API_BASE_URL_1",
19731
+ env: "PRIMITIVE_API_BASE_URL",
19838
19732
  hidden: true
19839
19733
  }),
19840
19734
  force: Flags.boolean({
@@ -19983,14 +19877,9 @@ var ReplyCommand = class ReplyCommand extends Command {
19983
19877
  description: "Primitive API key override (defaults to PRIMITIVE_API_KEY or saved OAuth login credentials)",
19984
19878
  env: "PRIMITIVE_API_KEY"
19985
19879
  }),
19986
- "api-base-url-1": Flags.string({
19987
- description: "Override the primary API base URL. Internal testing only; not documented to customers.",
19988
- env: "PRIMITIVE_API_BASE_URL_1",
19989
- hidden: true
19990
- }),
19991
- "api-base-url-2": Flags.string({
19992
- description: "Override the attachments-supporting send host base URL. Internal testing only; not documented to customers.",
19993
- env: "PRIMITIVE_API_BASE_URL_2",
19880
+ "api-base-url": Flags.string({
19881
+ description: "Override the API base URL. Internal testing only; not documented to customers.",
19882
+ env: "PRIMITIVE_API_BASE_URL",
19994
19883
  hidden: true
19995
19884
  }),
19996
19885
  id: Flags.string({
@@ -20026,8 +19915,7 @@ var ReplyCommand = class ReplyCommand extends Command {
20026
19915
  await runWithTiming(flags.time, async () => {
20027
19916
  const { apiClient, auth, baseUrlOverridden } = await createAuthenticatedCliApiClient({
20028
19917
  apiKey: flags["api-key"],
20029
- apiBaseUrl1: flags["api-base-url-1"],
20030
- apiBaseUrl2: flags["api-base-url-2"],
19918
+ apiBaseUrl: flags["api-base-url"],
20031
19919
  configDir: this.config.configDir
20032
19920
  });
20033
19921
  const attachments = readAttachmentFiles(flags.attachment);
@@ -20039,7 +19927,7 @@ var ReplyCommand = class ReplyCommand extends Command {
20039
19927
  ...attachments !== void 0 ? { attachments } : {},
20040
19928
  ...flags.wait !== void 0 ? { wait: flags.wait } : {}
20041
19929
  },
20042
- client: apiClient._sendClient,
19930
+ client: apiClient.client,
20043
19931
  path: { id: flags.id },
20044
19932
  responseStyle: "fields"
20045
19933
  });
@@ -20064,6 +19952,134 @@ var ReplyCommand = class ReplyCommand extends Command {
20064
19952
  }
20065
19953
  };
20066
19954
  //#endregion
19955
+ //#region src/oclif/commands/semantic-search.ts
19956
+ const DEFAULT_LIMIT = 10;
19957
+ const MAX_LIMIT = 100;
19958
+ const SCORE_WIDTH = 7;
19959
+ const SOURCE_WIDTH = 4;
19960
+ const SUBJECT_WIDTH = 40;
19961
+ const FROM_WIDTH = 26;
19962
+ const SNIPPET_WIDTH = 60;
19963
+ function truncate(value, width) {
19964
+ if (value.length <= width) return value.padEnd(width);
19965
+ return `${value.slice(0, width - 3)}...`;
19966
+ }
19967
+ function sourceLabel(t) {
19968
+ return t === "inbound_email" ? "in" : "out";
19969
+ }
19970
+ function formatRow(r) {
19971
+ return `${r.score.toFixed(3).padStart(SCORE_WIDTH)} ${sourceLabel(r.source_type).padEnd(SOURCE_WIDTH)} ${truncate((r.subject ?? "").replace(/\s+/g, " "), SUBJECT_WIDTH)} ${truncate(r.from ?? "", FROM_WIDTH)} ${truncate((r.snippets[0]?.text ?? "").replace(/\s+/g, " "), SNIPPET_WIDTH)}`;
19972
+ }
19973
+ function formatHeader() {
19974
+ return `${"SCORE".padStart(SCORE_WIDTH)} ${"SRC".padEnd(SOURCE_WIDTH)} ${"SUBJECT".padEnd(SUBJECT_WIDTH)} ${"FROM".padEnd(FROM_WIDTH)} EXCERPT`;
19975
+ }
19976
+ var SemanticSearchCommand = class SemanticSearchCommand extends Command {
19977
+ static description = `Search received and sent mail by meaning or keywords.
19978
+
19979
+ Returns ranked rows. Each row carries a relevance score, the fields it
19980
+ matched, and a match-centered excerpt. Defaults to hybrid mode (blends
19981
+ semantic and keyword signals); use \`--mode keyword\` for plain
19982
+ full-text matching and \`--mode semantic\` for embedding-only.
19983
+
19984
+ Requires the Pro plan with the semantic_search_enabled entitlement.`;
19985
+ static summary = "Semantic / hybrid / keyword search across received and sent mail";
19986
+ static examples = [
19987
+ "<%= config.bin %> semantic-search \"invoice from acme\"",
19988
+ "<%= config.bin %> semantic-search \"shipping update\" --mode keyword",
19989
+ "<%= config.bin %> semantic-search \"kickoff\" --corpus inbound --limit 25",
19990
+ "<%= config.bin %> semantic-search renewal --json | jq '.data[].id'"
19991
+ ];
19992
+ static args = { query: Args.string({
19993
+ description: "The search query.",
19994
+ required: true
19995
+ }) };
19996
+ static flags = {
19997
+ "api-key": Flags.string({
19998
+ description: "Primitive API key override (defaults to PRIMITIVE_API_KEY or saved OAuth login credentials)",
19999
+ env: "PRIMITIVE_API_KEY"
20000
+ }),
20001
+ "api-base-url": Flags.string({
20002
+ description: API_BASE_URL_FLAG_DESCRIPTION,
20003
+ env: "PRIMITIVE_API_BASE_URL",
20004
+ hidden: true
20005
+ }),
20006
+ mode: Flags.string({
20007
+ description: "Ranking strategy.",
20008
+ options: [
20009
+ "hybrid",
20010
+ "semantic",
20011
+ "keyword"
20012
+ ],
20013
+ default: "hybrid"
20014
+ }),
20015
+ corpus: Flags.string({
20016
+ description: "Restrict to inbound or outbound. Pass twice to include both (the default).",
20017
+ options: ["inbound", "outbound"],
20018
+ multiple: true
20019
+ }),
20020
+ "date-from": Flags.string({ description: "Only include mail at or after this ISO-8601 timestamp." }),
20021
+ "date-to": Flags.string({ description: "Only include mail at or before this ISO-8601 timestamp." }),
20022
+ limit: Flags.integer({
20023
+ description: `Maximum results to return (1-${MAX_LIMIT}, default ${DEFAULT_LIMIT}).`,
20024
+ default: DEFAULT_LIMIT,
20025
+ min: 1,
20026
+ max: MAX_LIMIT
20027
+ }),
20028
+ cursor: Flags.string({ description: "Opaque pagination cursor from a prior response's meta.cursor." }),
20029
+ json: Flags.boolean({ description: "Print the raw response envelope as JSON on STDOUT instead of the text table." }),
20030
+ time: Flags.boolean({ description: TIME_FLAG_DESCRIPTION })
20031
+ };
20032
+ async run() {
20033
+ const { args, flags } = await this.parse(SemanticSearchCommand);
20034
+ await runWithTiming(flags.time, async () => {
20035
+ const { apiClient, auth, baseUrlOverridden } = await createAuthenticatedCliApiClient({
20036
+ apiKey: flags["api-key"],
20037
+ apiBaseUrl: flags["api-base-url"],
20038
+ configDir: this.config.configDir
20039
+ });
20040
+ const result = await semanticSearch({
20041
+ client: apiClient.client,
20042
+ body: {
20043
+ query: args.query,
20044
+ mode: flags.mode,
20045
+ ...flags.corpus ? { corpus: flags.corpus } : {},
20046
+ ...flags["date-from"] ? { date_from: flags["date-from"] } : {},
20047
+ ...flags["date-to"] ? { date_to: flags["date-to"] } : {},
20048
+ limit: flags.limit,
20049
+ ...flags.cursor ? { cursor: flags.cursor } : {}
20050
+ },
20051
+ responseStyle: "fields"
20052
+ });
20053
+ if (result.error) {
20054
+ const errorPayload = extractErrorPayload(result.error);
20055
+ writeErrorWithHints(errorPayload);
20056
+ surfaceUnauthorizedHint({
20057
+ auth,
20058
+ baseUrlOverridden,
20059
+ configDir: this.config.configDir,
20060
+ payload: errorPayload
20061
+ });
20062
+ process.exitCode = 1;
20063
+ return;
20064
+ }
20065
+ const envelope = result.data;
20066
+ if (flags.json) {
20067
+ this.log(JSON.stringify(envelope ?? null, null, 2));
20068
+ return;
20069
+ }
20070
+ const rows = envelope?.data ?? [];
20071
+ if (rows.length === 0) {
20072
+ process.stderr.write("No matching mail.\n");
20073
+ return;
20074
+ }
20075
+ process.stderr.write(`${formatHeader()}\n`);
20076
+ for (const row of rows) this.log(formatRow(row));
20077
+ const nextCursor = envelope?.meta?.cursor ?? null;
20078
+ if (nextCursor) process.stderr.write(`\nNext page: pass --cursor ${nextCursor}\n`);
20079
+ });
20080
+ }
20081
+ };
20082
+ //#endregion
20067
20083
  //#region src/oclif/commands/send.ts
20068
20084
  var SendCommand = class SendCommand extends Command {
20069
20085
  static description = `Send an outbound email. Agent-grade shortcut for \`sending send\` with sensible defaults.
@@ -20089,14 +20105,9 @@ var SendCommand = class SendCommand extends Command {
20089
20105
  description: "Primitive API key override (defaults to PRIMITIVE_API_KEY or saved OAuth login credentials)",
20090
20106
  env: "PRIMITIVE_API_KEY"
20091
20107
  }),
20092
- "api-base-url-1": Flags.string({
20093
- description: "Override the primary API base URL. Internal testing only; not documented to customers.",
20094
- env: "PRIMITIVE_API_BASE_URL_1",
20095
- hidden: true
20096
- }),
20097
- "api-base-url-2": Flags.string({
20098
- description: "Override the attachments-supporting send host base URL. Internal testing only; not documented to customers.",
20099
- env: "PRIMITIVE_API_BASE_URL_2",
20108
+ "api-base-url": Flags.string({
20109
+ description: "Override the API base URL. Internal testing only; not documented to customers.",
20110
+ env: "PRIMITIVE_API_BASE_URL",
20100
20111
  hidden: true
20101
20112
  }),
20102
20113
  to: Flags.string({
@@ -20135,8 +20146,7 @@ var SendCommand = class SendCommand extends Command {
20135
20146
  await runWithTiming(flags.time, async () => {
20136
20147
  const { apiClient, auth, baseUrlOverridden } = await createAuthenticatedCliApiClient({
20137
20148
  apiKey: flags["api-key"],
20138
- apiBaseUrl1: flags["api-base-url-1"],
20139
- apiBaseUrl2: flags["api-base-url-2"],
20149
+ apiBaseUrl: flags["api-base-url"],
20140
20150
  configDir: this.config.configDir
20141
20151
  });
20142
20152
  const authFailureContext = {
@@ -20158,7 +20168,7 @@ var SendCommand = class SendCommand extends Command {
20158
20168
  ...flags.wait !== void 0 ? { wait: flags.wait } : {},
20159
20169
  ...flags["wait-timeout-ms"] !== void 0 ? { wait_timeout_ms: flags["wait-timeout-ms"] } : {}
20160
20170
  },
20161
- client: apiClient._sendClient,
20171
+ client: apiClient.client,
20162
20172
  responseStyle: "fields"
20163
20173
  });
20164
20174
  if (result.error) {
@@ -20229,9 +20239,9 @@ function acquireCredentialsLock(configDir) {
20229
20239
  function commonOtpStartFlags() {
20230
20240
  return {
20231
20241
  "accept-terms": Flags.boolean({ description: "Confirm acceptance of Primitive's Terms of Service and Privacy Policy" }),
20232
- "api-base-url-1": Flags.string({
20242
+ "api-base-url": Flags.string({
20233
20243
  description: "Override the primary API base URL. Internal testing only; not documented to customers.",
20234
- env: "PRIMITIVE_API_BASE_URL_1",
20244
+ env: "PRIMITIVE_API_BASE_URL",
20235
20245
  hidden: true
20236
20246
  }),
20237
20247
  "device-name": Flags.string({ description: "Device name used for the created CLI OAuth session" }),
@@ -20410,9 +20420,9 @@ var SigninOtpConfirmCommand = class extends Command {
20410
20420
  static summary = "Confirm OTP sign-in";
20411
20421
  static examples = ["<%= config.bin %> signin otp confirm user@example.com 123456", "<%= config.bin %> signin otp confirm user@example.com 123456 --org-id 00000000-0000-4000-8000-000000000000"];
20412
20422
  static flags = {
20413
- "api-base-url-1": Flags.string({
20423
+ "api-base-url": Flags.string({
20414
20424
  description: "Override the primary API base URL. Internal testing only; not documented to customers.",
20415
- env: "PRIMITIVE_API_BASE_URL_1",
20425
+ env: "PRIMITIVE_API_BASE_URL",
20416
20426
  hidden: true
20417
20427
  }),
20418
20428
  force: Flags.boolean({
@@ -20489,9 +20499,9 @@ var SigninOtpResendCommand = class extends Command {
20489
20499
  static description = "Resend the verification code for a pending OTP sign-in.";
20490
20500
  static summary = "Resend OTP sign-in code";
20491
20501
  static examples = ["<%= config.bin %> signin otp resend user@example.com"];
20492
- static flags = { "api-base-url-1": Flags.string({
20502
+ static flags = { "api-base-url": Flags.string({
20493
20503
  description: "Override the primary API base URL. Internal testing only; not documented to customers.",
20494
- env: "PRIMITIVE_API_BASE_URL_1",
20504
+ env: "PRIMITIVE_API_BASE_URL",
20495
20505
  hidden: true
20496
20506
  }) };
20497
20507
  async run() {
@@ -20577,14 +20587,9 @@ var WhoamiCommand = class WhoamiCommand extends Command {
20577
20587
  description: "Primitive API key override (defaults to PRIMITIVE_API_KEY or saved OAuth login credentials)",
20578
20588
  env: "PRIMITIVE_API_KEY"
20579
20589
  }),
20580
- "api-base-url-1": Flags.string({
20581
- description: API_BASE_URL_1_FLAG_DESCRIPTION,
20582
- env: "PRIMITIVE_API_BASE_URL_1",
20583
- hidden: true
20584
- }),
20585
- "api-base-url-2": Flags.string({
20586
- description: API_BASE_URL_2_FLAG_DESCRIPTION,
20587
- env: "PRIMITIVE_API_BASE_URL_2",
20590
+ "api-base-url": Flags.string({
20591
+ description: API_BASE_URL_FLAG_DESCRIPTION,
20592
+ env: "PRIMITIVE_API_BASE_URL",
20588
20593
  hidden: true
20589
20594
  }),
20590
20595
  json: Flags.boolean({ description: "Print the full account JSON response. Default output hides setup and billing internals." }),
@@ -20595,8 +20600,7 @@ var WhoamiCommand = class WhoamiCommand extends Command {
20595
20600
  await runWithTiming(flags.time, async () => {
20596
20601
  const { apiClient, auth, baseUrlOverridden } = await createAuthenticatedCliApiClient({
20597
20602
  apiKey: flags["api-key"],
20598
- apiBaseUrl1: flags["api-base-url-1"],
20599
- apiBaseUrl2: flags["api-base-url-2"],
20603
+ apiBaseUrl: flags["api-base-url"],
20600
20604
  configDir: this.config.configDir
20601
20605
  });
20602
20606
  const result = await getAccount({
@@ -20927,6 +20931,7 @@ const COMMANDS = {
20927
20931
  "emails:latest": EmailsLatestCommand,
20928
20932
  "emails:watch": EmailsWatchCommand,
20929
20933
  "emails:wait": EmailsWaitCommand,
20934
+ "semantic-search": SemanticSearchCommand,
20930
20935
  "domains:zone-file": DomainsZoneFileCommand,
20931
20936
  "domains:download-domain-zone-file": DomainsZoneFileCommand,
20932
20937
  "inbox:setup": InboxSetupCommand,