@solidactions/cli 3.23.0 → 3.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -281,6 +281,7 @@ Workspace: <name> — organization <org> (<workspaceId>)
281
281
  - `--global` — write config to `~/.solidactions/config.json` (today's default).
282
282
  - `--gitignore` — with `--local`, auto-add `.solidactions/` to `.gitignore` without prompting.
283
283
  - `login` uses `SOLIDACTIONS_HOST` when it is set.
284
+ - A host with a username and password in it (`http://user:pass@host`) is refused: the CLI authenticates with your API key.
284
285
  - An agent that should be credited as itself in SolidActions (for example, docs it pushes are recorded as Agent) logs the CLI in with its own agent token, not a person's key.
285
286
 
286
287
  In interactive shells, `login` without `--local`/`--global` prompts for a location. In non-interactive contexts, one of the flags is required.
@@ -295,7 +296,7 @@ If the target config file already exists and its contents would change, `login`
295
296
 
296
297
  ### Debugging resolution
297
298
 
298
- Set `SOLIDACTIONS_DEBUG=1` on any command to print the resolved configuration and per-field sources to stderr before the command runs. `solidactions whoami` also shows this information.
299
+ Set `SOLIDACTIONS_DEBUG=1` on any command to print the resolved configuration and per-field sources to stderr before the command runs. `solidactions whoami` also shows this information. Node's generic `DEBUG` variable never prints your API key: the CLI turns off the HTTP library's `follow-redirects` debug output, which would dump request headers. The CLI refuses to run when `NODE_DEBUG` turns on Node's network debug output (`http`, `https`, `http2`, `net`, `tls`), which would print them too.
299
300
 
300
301
  ### Use case: multiple AI agents in parallel
301
302
 
@@ -522,6 +523,8 @@ solidactions doc upload logo-v2.png --replace marketing/logo.png
522
523
 
523
524
  **`doc pull` never writes through a link or over bytes it does not own.** It refuses before writing anything when a target is a symbolic link, sits under a linked folder inside the destination, or resolves outside it, with or without `--overwrite`. A local file the destination does not track (or tracks without a recorded hash) is replaced only with `--overwrite`; `-y` only answers the confirmation. A file that already holds exactly the server's bytes is simply adopted. A media doc whose download fails is not tracked over a local file.
524
525
 
526
+ **`doc pull` stops on the first error and records exactly what it wrote.** `doc pull` writes each file through a temp file beside it and renames it into place, in order, and saves the manifest last. If a write fails, or a file you changed in the meantime (or a folder where a doc goes) is in the way, the pull stops there with one line saying how many files were updated: the files before it stay written and are recorded in the manifest with their own checksums, the rest keep their bytes and their earlier entries, and nothing is rolled back or deleted. Pull again and it completes the job; a file that already holds exactly the bytes the pull would write is never treated as a local change. While it runs, a pull keeps one lock file, `.solidactions-docs.json.lock`, in the destination: a second pull into the same destination (or two started together) refuses and changes nothing, so two pulls never write into one folder; run it again when the first has finished. The pull removes its lock when it ends, including on an error or an interrupt. If the process is killed (SIGKILL) while writing, the manifest is the old one, the lock file is left behind, and tracked files are always re-checked by hash, so nothing is overwritten silently: if the line says another pull may be writing but none is running, delete that lock file and pull again. A doc or folder whose name would be `.solidactions-docs.json`, `.solidactions-docs.json.lock` or start with `.sa-write-` is written under a name with a leading `_`, and names that differ only by case or Unicode normalisation always get distinct names. There is no guarantee after a power loss.
527
+
525
528
  You do **not** need `--overwrite` to keep an edited file whose doc was deleted on the server — that case is handled by deletion propagation above, on the default path, and the file is kept with a warning.
526
529
 
527
530
  **Getting a doc id.** `doc upload --replace` accepts a docs path (`marketing/hero.png`), so you rarely need an id. If you want one, `doc pull` records it per file in the destination's `.solidactions-docs.json` sidecar, and `import_outputs` returns the ids it created. Note that `--replace` does not update a pulled directory's manifest. If you replace a tracked image out-of-band and leave the local file untouched, the next `doc push` reports it as **unchanged** and does nothing — the content hash matches, so `push` never asks the server. (Edit the local file too, and the drift guard fires as expected.) Re-pull to resync the manifest.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schema_version": 1,
3
3
  "cli_name": "solidactions",
4
- "cli_version": "3.23.0",
4
+ "cli_version": "3.25.0",
5
5
  "global_options": [
6
6
  {
7
7
  "flags": "-V, --version",
@@ -169,6 +169,18 @@ function teachingError(error) {
169
169
  }
170
170
  throw error;
171
171
  }
172
+ /**
173
+ * Throw the host-naming 401 for a 401 response, in either export call
174
+ * (cli#186). A non-string, blank or whitespace-only server code becomes
175
+ * 'unauthenticated', the way safeDatabaseRequestError trims it.
176
+ */
177
+ function throwIfUnauthenticated(error, config) {
178
+ if (error?.response?.status !== 401) {
179
+ return;
180
+ }
181
+ const candidate = typeof error.response.data?.code === 'string' ? error.response.data.code.trim() : '';
182
+ throw new ExportCommandError(candidate.length > 0 ? candidate : 'unauthenticated', (0, api_1.authFailedLine)(config.host), 401);
183
+ }
172
184
  async function operation(config, body) {
173
185
  try {
174
186
  const response = await axios_1.default.post(`${config.host}/api/v1/databases`, body, {
@@ -178,6 +190,7 @@ async function operation(config, body) {
178
190
  return applyRetryAfter(response.data, response.headers['retry-after']);
179
191
  }
180
192
  catch (error) {
193
+ throwIfUnauthenticated(error, config);
181
194
  const response = error?.response;
182
195
  const code = typeof response?.data?.code === 'string' ? response.data.code : 'upstream_unavailable';
183
196
  const message = typeof response?.data?.message === 'string' ? response.data.message : 'Database request failed.';
@@ -196,6 +209,7 @@ async function startExport(config, name, tables, replace, requestId) {
196
209
  return stableMetadata(applyRetryAfter(response.data, response.headers['retry-after']));
197
210
  }
198
211
  catch (error) {
212
+ throwIfUnauthenticated(error, config);
199
213
  const data = error?.response?.data;
200
214
  const code = typeof data?.code === 'string' ? data.code : 'upstream_unavailable';
201
215
  const message = typeof data?.message === 'string' ? data.message : 'Database request failed.';
@@ -325,8 +325,9 @@ async function databasePushWithConfig(name, file, options, config, dependencies
325
325
  clearInterval(renewalTimer);
326
326
  await renewing;
327
327
  }
328
- if (renewalFailure)
329
- throw new database_data_plane_1.DatabaseOperationError('upstream_unavailable', 'The database upload lease could not be renewed; the source database was not changed.');
328
+ if (renewalFailure) {
329
+ throw (0, database_data_plane_1.preserveAuthFailure)(renewalFailure, 'The database upload lease could not be renewed; the source database was not changed.', 'upstream_unavailable', 'The database upload lease could not be renewed; the source database was not changed.');
330
+ }
330
331
  if (uploaded.status < 200 || uploaded.status > 299) {
331
332
  if (uploaded.status === 413)
332
333
  throw new database_data_plane_1.DatabaseOperationError('bulk_load_too_large', 'The upstream database service rejected the upload size; the source database was not changed.');
@@ -368,7 +369,8 @@ async function databasePushWithConfig(name, file, options, config, dependencies
368
369
  }
369
370
  }
370
371
  if (operationId && promoteAccepted && !terminalObserved) {
371
- throw new database_data_plane_1.DatabaseOperationError('upstream_unavailable', `Promotion was accepted, but status could not be confirmed. Operation ${operationId} remains active; retry with idempotency key ${key}.`);
372
+ const stateLine = `Promotion was accepted, but status could not be confirmed. Operation ${operationId} remains active; retry with idempotency key ${key}.`;
373
+ throw (0, database_data_plane_1.preserveAuthFailure)(error, stateLine, 'upstream_unavailable', stateLine);
372
374
  }
373
375
  throw error;
374
376
  }
@@ -895,6 +895,10 @@ async function databaseCreateWithConfig(name, options, config, dependencies = {}
895
895
  }
896
896
  }
897
897
  catch (error) {
898
+ if (error instanceof database_data_plane_1.DatabaseOperationError && error.status === 401) {
899
+ const stateLine = `Database "${data.database.name}" was created, but its SQL import failed. The database remains in place.`;
900
+ throw (0, database_data_plane_1.preserveAuthFailure)(error, stateLine, 'import_failed', stateLine);
901
+ }
898
902
  const safeGuidance = error instanceof database_data_plane_1.DatabaseOperationError
899
903
  && error.code === 'import_failed'
900
904
  && error.message.includes('Resume with:')
@@ -51,6 +51,7 @@ const chalk_1 = __importDefault(require("chalk"));
51
51
  const js_yaml_1 = __importDefault(require("js-yaml"));
52
52
  const crypto_1 = require("crypto");
53
53
  const module_1 = require("module");
54
+ const api_1 = require("../utils/api");
54
55
  const config_1 = require("../utils/config");
55
56
  /**
56
57
  * Does this mapping declare a database in `solidactions.yaml` that the platform
@@ -94,6 +95,7 @@ const WRITE_AUTHORITY_REFUSAL_CODES = new Set([
94
95
  function buildSaApiClient(config, projectSlug) {
95
96
  const client = {
96
97
  projectSlug,
98
+ host: config.host,
97
99
  revealDenied: false,
98
100
  async fetchVarsAndConnections(_env) {
99
101
  const axios = (await Promise.resolve().then(() => __importStar(require('axios')))).default;
@@ -431,6 +433,16 @@ async function runDev(opts) {
431
433
  function err(msg) {
432
434
  stderrLines.push(msg);
433
435
  }
436
+ const isUnauthenticated = (e) => e?.response?.status === 401 || e?.status === 401;
437
+ const authFailed = () => ({
438
+ stdout: stdoutLines.join('\n'),
439
+ stderr: stderrLines.join('\n'),
440
+ result: {
441
+ status: 'failed',
442
+ phase: 'auth',
443
+ error: { name: 'AuthenticationError', message: (0, api_1.authFailedLine)(apiClient?.host ?? 'the configured host') },
444
+ },
445
+ });
434
446
  // 1. Determine the API client (only when an env was requested). With no
435
447
  // --env, we run fully locally: NO platform fetch, ctx.vars starts empty.
436
448
  let apiClient;
@@ -459,6 +471,8 @@ async function runDev(opts) {
459
471
  platformVars = await apiClient.fetchVarsAndConnections(opts.env);
460
472
  }
461
473
  catch (e) {
474
+ if (isUnauthenticated(e))
475
+ return authFailed();
462
476
  let msg = `failed to fetch platform vars: ${e?.message ?? e}`;
463
477
  if (e?.response?.status === 404 && opts.env !== 'production') {
464
478
  msg += `\nThe '${opts.env}' environment project doesn't exist — staging/dev environments require a paid plan. On the free plan, use --env production.`;
@@ -553,6 +567,8 @@ async function runDev(opts) {
553
567
  }
554
568
  }
555
569
  catch (e) {
570
+ if (isUnauthenticated(e))
571
+ return authFailed();
556
572
  err(`${pv.env_name}: failed to resolve database '${dbName}': ${e?.message ?? e}`);
557
573
  }
558
574
  }
@@ -894,6 +910,10 @@ async function dev(file, options) {
894
910
  console.log(chalk_1.default.yellow('Workflow cancelled'));
895
911
  process.exit(1);
896
912
  }
913
+ if (r.status === 'failed' && r.phase === 'auth') {
914
+ console.error(chalk_1.default.red(r.error.message));
915
+ process.exit(1);
916
+ }
897
917
  // failed
898
918
  console.error(chalk_1.default.red(`✗ failed (${r.phase ?? 'run'}):`), r.error?.message ?? String(r.error));
899
919
  process.exit(1);