@solidactions/cli 3.22.0 → 3.24.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 +6 -1
- package/dist/command-manifest.json +1 -1
- package/dist/commands/crew-env-map-database.js +4 -1
- package/dist/commands/database-export.js +14 -0
- package/dist/commands/database-push.js +7 -4
- package/dist/commands/database.js +4 -0
- package/dist/commands/deploy.js +3 -2
- package/dist/commands/dev.js +20 -0
- package/dist/commands/device-login.js +3 -2
- package/dist/commands/doc-pull.js +274 -46
- package/dist/commands/doc-push.js +4 -0
- package/dist/commands/login.js +101 -13
- package/dist/commands/skill-exec.js +4 -1
- package/dist/commands/skill-run.js +4 -1
- package/dist/commands/workflow-view.js +20 -4
- package/dist/index.js +4 -1
- package/dist/utils/api.js +10 -25
- package/dist/utils/config.js +10 -4
- package/dist/utils/database-data-plane.js +22 -3
- package/dist/utils/debug-guard.js +60 -0
- package/dist/utils/host-display.js +66 -0
- package/dist/utils/mcp.js +10 -0
- package/dist/utils/source-provenance.js +12 -1
- package/dist/utils/workspace-lookup.js +11 -1
- package/package.json +1 -1
package/dist/commands/login.js
CHANGED
|
@@ -3,10 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DEVICE_LOGIN_REFUSAL_MESSAGE = exports.API_KEY_PROMPT = exports.selectWorkspaceInteractively = void 0;
|
|
6
|
+
exports.DEVICE_LOGIN_REFUSAL_MESSAGE = exports.LoginHostUserinfoError = exports.LoginHostInvalidError = exports.LoginHostConflictError = exports.API_KEY_PROMPT = exports.selectWorkspaceInteractively = void 0;
|
|
7
7
|
exports.resolveLoginApiKey = resolveLoginApiKey;
|
|
8
8
|
exports.clearConfig = clearConfig;
|
|
9
9
|
exports.resolveLoginHost = resolveLoginHost;
|
|
10
|
+
exports.resolveLoginHostOrExit = resolveLoginHostOrExit;
|
|
10
11
|
exports.backupPathFor = backupPathFor;
|
|
11
12
|
exports.preflightDeviceLoginWrite = preflightDeviceLoginWrite;
|
|
12
13
|
exports.persistPreflightedLoginCredential = persistPreflightedLoginCredential;
|
|
@@ -22,6 +23,7 @@ const prompts_1 = __importDefault(require("prompts"));
|
|
|
22
23
|
const config_1 = require("../utils/config");
|
|
23
24
|
const config_write_target_1 = require("../utils/config-write-target");
|
|
24
25
|
const workspace_lookup_1 = require("../utils/workspace-lookup");
|
|
26
|
+
const host_display_1 = require("../utils/host-display");
|
|
25
27
|
var workspace_lookup_2 = require("../utils/workspace-lookup");
|
|
26
28
|
Object.defineProperty(exports, "selectWorkspaceInteractively", { enumerable: true, get: function () { return workspace_lookup_2.selectWorkspaceInteractively; } });
|
|
27
29
|
exports.API_KEY_PROMPT = {
|
|
@@ -73,15 +75,97 @@ async function resolveLoginApiKey(apiKey, options = {}, dependencies = {}) {
|
|
|
73
75
|
function clearConfig() {
|
|
74
76
|
(0, config_1.removeConfigFile)((0, config_1.getGlobalConfigPath)());
|
|
75
77
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
class LoginHostConflictError extends Error {
|
|
79
|
+
flag;
|
|
80
|
+
envHost;
|
|
81
|
+
constructor(flag, envHost) {
|
|
82
|
+
super(`${flag} disagrees with SOLIDACTIONS_HOST=${(0, host_display_1.displayHost)(envHost)}; refusing to send the API key.`);
|
|
83
|
+
this.flag = flag;
|
|
84
|
+
this.envHost = envHost;
|
|
79
85
|
}
|
|
80
|
-
|
|
81
|
-
|
|
86
|
+
}
|
|
87
|
+
exports.LoginHostConflictError = LoginHostConflictError;
|
|
88
|
+
class LoginHostInvalidError extends Error {
|
|
89
|
+
label;
|
|
90
|
+
raw;
|
|
91
|
+
constructor(label, raw) {
|
|
92
|
+
super(`${label}=${JSON.stringify(raw)} is not a usable host; refusing to send the API key.`);
|
|
93
|
+
this.label = label;
|
|
94
|
+
this.raw = raw;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.LoginHostInvalidError = LoginHostInvalidError;
|
|
98
|
+
class LoginHostUserinfoError extends Error {
|
|
99
|
+
label;
|
|
100
|
+
host;
|
|
101
|
+
constructor(label, host) {
|
|
102
|
+
super(`${label} "${(0, host_display_1.displayHost)(host)}" contains a username/password; remove "user:pass@" — the CLI authenticates with your API key.`);
|
|
103
|
+
this.label = label;
|
|
104
|
+
this.host = host;
|
|
82
105
|
}
|
|
106
|
+
}
|
|
107
|
+
exports.LoginHostUserinfoError = LoginHostUserinfoError;
|
|
108
|
+
function resolveLoginHost(options, env = process.env) {
|
|
109
|
+
const strip = (h) => h.trim().replace(/\/+$/, '');
|
|
110
|
+
// Ruling 9: a non-empty value that strips to nothing is INVALID, never "absent".
|
|
111
|
+
const usable = (raw, label) => {
|
|
112
|
+
const value = strip(raw);
|
|
113
|
+
if (value === '')
|
|
114
|
+
throw new LoginHostInvalidError(label, raw);
|
|
115
|
+
return value;
|
|
116
|
+
};
|
|
117
|
+
const rawEnv = env.SOLIDACTIONS_HOST;
|
|
118
|
+
const noUserinfo = (host, label) => {
|
|
119
|
+
if ((0, host_display_1.hostHasUserinfo)(host))
|
|
120
|
+
throw new LoginHostUserinfoError(label, host);
|
|
121
|
+
return host;
|
|
122
|
+
};
|
|
123
|
+
const envHost = rawEnv !== undefined && rawEnv.trim() !== ''
|
|
124
|
+
? noUserinfo(usable(rawEnv, 'SOLIDACTIONS_HOST'), 'SOLIDACTIONS_HOST')
|
|
125
|
+
: undefined;
|
|
126
|
+
const explicitHostFlag = (raw) => {
|
|
127
|
+
const host = noUserinfo(usable(raw, '--host'), '--host');
|
|
128
|
+
return { host, flag: `--host ${(0, host_display_1.displayHost)(host)}` };
|
|
129
|
+
};
|
|
130
|
+
const explicit = options.host !== undefined
|
|
131
|
+
? explicitHostFlag(options.host)
|
|
132
|
+
: options.dev
|
|
133
|
+
? { host: 'http://localhost:8000', flag: '--dev (http://localhost:8000)' }
|
|
134
|
+
: undefined;
|
|
135
|
+
if (explicit && envHost && (0, config_1.normalizeHost)(explicit.host) !== (0, config_1.normalizeHost)(envHost)) {
|
|
136
|
+
throw new LoginHostConflictError(explicit.flag, envHost);
|
|
137
|
+
}
|
|
138
|
+
if (explicit)
|
|
139
|
+
return { host: explicit.host, isDefault: false };
|
|
140
|
+
if (envHost)
|
|
141
|
+
return { host: envHost, isDefault: false };
|
|
83
142
|
return { host: 'https://app.solidactions.com', isDefault: true };
|
|
84
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* `resolveLoginHost` for the login commands: a refused host prints the
|
|
146
|
+
* refusal to stderr and exits 1 before any request or config write.
|
|
147
|
+
*/
|
|
148
|
+
function resolveLoginHostOrExit(options) {
|
|
149
|
+
try {
|
|
150
|
+
return resolveLoginHost(options);
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
if (error instanceof LoginHostConflictError) {
|
|
154
|
+
console.error(chalk_1.default.red(`error: ${error.message}`));
|
|
155
|
+
console.error(chalk_1.default.red('Unset SOLIDACTIONS_HOST or pass the same host to --host.'));
|
|
156
|
+
process.exit(1);
|
|
157
|
+
}
|
|
158
|
+
if (error instanceof LoginHostInvalidError) {
|
|
159
|
+
console.error(chalk_1.default.red(`error: ${error.message}`));
|
|
160
|
+
process.exit(1);
|
|
161
|
+
}
|
|
162
|
+
if (error instanceof LoginHostUserinfoError) {
|
|
163
|
+
console.error(chalk_1.default.red(`error: ${error.message}`));
|
|
164
|
+
process.exit(1);
|
|
165
|
+
}
|
|
166
|
+
throw error;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
85
169
|
/**
|
|
86
170
|
* Path for a timestamped backup of `targetPath`, e.g.
|
|
87
171
|
* `config.json.bak-2026-07-05T12-30-00Z`. Pure — takes `now` so tests are
|
|
@@ -203,9 +287,9 @@ async function persistPreflightedLoginCredential(config, preflight, options) {
|
|
|
203
287
|
}
|
|
204
288
|
function loginHostLines(resolved) {
|
|
205
289
|
if (resolved.isDefault) {
|
|
206
|
-
return [`Logging into ${resolved.host} (SolidActions Cloud)`];
|
|
290
|
+
return [`Logging into ${(0, host_display_1.displayHost)(resolved.host)} (SolidActions Cloud)`];
|
|
207
291
|
}
|
|
208
|
-
return [`Host: ${resolved.host}`];
|
|
292
|
+
return [`Host: ${(0, host_display_1.displayHost)(resolved.host)}`];
|
|
209
293
|
}
|
|
210
294
|
/**
|
|
211
295
|
* Shared tail of API-key and device login: resolve the workspace against an
|
|
@@ -361,11 +445,11 @@ async function completeLogin(config, workspaces, options, scope = null, prefligh
|
|
|
361
445
|
}
|
|
362
446
|
}
|
|
363
447
|
async function login(apiKey, options) {
|
|
364
|
-
const resolved =
|
|
448
|
+
const resolved = resolveLoginHostOrExit(options);
|
|
365
449
|
const host = resolved.host;
|
|
366
450
|
if (!apiKey || apiKey.trim().length === 0) {
|
|
367
451
|
console.error(chalk_1.default.red('Error: API key is required.'));
|
|
368
|
-
console.log(chalk_1.default.gray('Generate an API key at: ') + chalk_1.default.blue(`${host}/settings/api-keys`));
|
|
452
|
+
console.log(chalk_1.default.gray('Generate an API key at: ') + chalk_1.default.blue(`${(0, host_display_1.displayHost)(host)}/settings/api-keys`));
|
|
369
453
|
process.exit(1);
|
|
370
454
|
}
|
|
371
455
|
console.log(chalk_1.default.blue(`Initializing SolidActions CLI...`));
|
|
@@ -384,10 +468,10 @@ async function login(apiKey, options) {
|
|
|
384
468
|
}
|
|
385
469
|
catch (e) {
|
|
386
470
|
if (e.response?.status === 401) {
|
|
387
|
-
console.error(chalk_1.default.red(`Invalid API key for ${host}.`));
|
|
471
|
+
console.error(chalk_1.default.red(`Invalid API key for ${(0, host_display_1.displayHost)(host)}.`));
|
|
388
472
|
}
|
|
389
473
|
else {
|
|
390
|
-
console.error(chalk_1.default.red(`Could not reach ${host}: ${e.message}`));
|
|
474
|
+
console.error(chalk_1.default.red(`Could not reach ${(0, host_display_1.displayHost)(host)}: ${e.message}`));
|
|
391
475
|
}
|
|
392
476
|
process.exit(1);
|
|
393
477
|
return;
|
|
@@ -431,6 +515,10 @@ function whoami() {
|
|
|
431
515
|
console.error(chalk_1.default.red((0, config_1.credentialConflictMessage)(resolved.credentialConflict)));
|
|
432
516
|
process.exit(1);
|
|
433
517
|
}
|
|
518
|
+
if (resolved && (0, host_display_1.hostHasUserinfo)(resolved.config.host)) {
|
|
519
|
+
console.error(chalk_1.default.red((0, config_1.userinfoHostMessage)(resolved.config.host, resolved.sources.host)));
|
|
520
|
+
process.exit(1);
|
|
521
|
+
}
|
|
434
522
|
if (!resolved || !resolved.config.apiKey) {
|
|
435
523
|
console.log(chalk_1.default.yellow('Not initialized.'));
|
|
436
524
|
console.log(chalk_1.default.gray('Run "solidactions login --global" to configure.'));
|
|
@@ -460,7 +548,7 @@ function whoami() {
|
|
|
460
548
|
? `${workspaceName} — organization ${config.workspaceOrg}${config.workspaceId ? ` (${config.workspaceId})` : ''}`
|
|
461
549
|
: `${workspaceName}${config.workspaceId ? ` (${config.workspaceId})` : ''}`;
|
|
462
550
|
console.log(chalk_1.default.blue('Current configuration:'));
|
|
463
|
-
console.log(` Host: ${config.host.padEnd(50)} ${fmt(sources.host)}`);
|
|
551
|
+
console.log(` Host: ${(0, host_display_1.displayHost)(config.host).padEnd(50)} ${fmt(sources.host)}`);
|
|
464
552
|
console.log(` API Key: ${maskedKey.padEnd(50)} ${fmt(sources.apiKey)}`);
|
|
465
553
|
console.log(` Workspace: ${workspaceLabel.padEnd(50)} ${fmt(sources.workspaceId)}`);
|
|
466
554
|
}
|
|
@@ -208,7 +208,10 @@ async function execOnHost(name, commandParts, options, environment, config) {
|
|
|
208
208
|
skippedSecrets = response.data?.skipped_secrets ?? [];
|
|
209
209
|
}
|
|
210
210
|
catch (e) {
|
|
211
|
-
|
|
211
|
+
const message = e?.response?.status === 401
|
|
212
|
+
? (0, api_1.authFailedLine)(config.host)
|
|
213
|
+
: `error: failed to resolve crew variables: ${e?.response?.data?.message ?? e.message}`;
|
|
214
|
+
process.stderr.write(chalk_1.default.red(`${message}\n`));
|
|
212
215
|
process.exit(1);
|
|
213
216
|
}
|
|
214
217
|
}
|
|
@@ -166,7 +166,10 @@ async function skillRunWithConfig(dir, commandParts, options, config) {
|
|
|
166
166
|
skippedSecrets = response.data?.skipped_secrets ?? [];
|
|
167
167
|
}
|
|
168
168
|
catch (e) {
|
|
169
|
-
|
|
169
|
+
const message = e?.response?.status === 401
|
|
170
|
+
? (0, api_1.authFailedLine)(config.host)
|
|
171
|
+
: `error: failed to resolve crew variables: ${e?.response?.data?.message ?? e.message}`;
|
|
172
|
+
process.stderr.write(chalk_1.default.red(`${message}\n`));
|
|
170
173
|
process.exit(1);
|
|
171
174
|
}
|
|
172
175
|
}
|
|
@@ -57,13 +57,13 @@ function printAmbiguity(error) {
|
|
|
57
57
|
}
|
|
58
58
|
console.error('Re-run with an exact slug.');
|
|
59
59
|
}
|
|
60
|
-
function printWorkflowViewError(error,
|
|
60
|
+
async function printWorkflowViewError(error, config, project, environment) {
|
|
61
61
|
if (!error.response) {
|
|
62
62
|
console.error(chalk_1.default.red('Connection failed:'), display(error.message, 'Unknown network error.', 500));
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
65
|
if (error.response.status === 401) {
|
|
66
|
-
console.error(chalk_1.default.red((0, api_1.authFailedLine)(host)));
|
|
66
|
+
console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
69
|
// The GET workflow endpoint uses the v1 {code, message} convention;
|
|
@@ -74,6 +74,21 @@ function printWorkflowViewError(error, host) {
|
|
|
74
74
|
printAmbiguity(error);
|
|
75
75
|
return;
|
|
76
76
|
}
|
|
77
|
+
if (error.response.status === 404) {
|
|
78
|
+
// The workflow route cannot say which environment is missing, so ask
|
|
79
|
+
// the family lookup; any failure falls through to the server message.
|
|
80
|
+
try {
|
|
81
|
+
const family = await (0, api_1.lookupProjectFamilyEnvironments)(config, project);
|
|
82
|
+
const environments = family?.environments ?? [];
|
|
83
|
+
if (environments.length > 0 && !environments.includes(environment)) {
|
|
84
|
+
console.error(chalk_1.default.red(`Project "${display(project)}" has no ${display(environment)} environment (exists in: ${environments.map((e) => display(e)).join(', ')}). Pass -e <env> to target a different environment.`));
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
// fall through to the server's message
|
|
90
|
+
}
|
|
91
|
+
}
|
|
77
92
|
const fallback = error.response.status === 404
|
|
78
93
|
? 'Project or workflow not found.'
|
|
79
94
|
: `Failed to view workflow: ${error.response.status}`;
|
|
@@ -81,8 +96,9 @@ function printWorkflowViewError(error, host) {
|
|
|
81
96
|
}
|
|
82
97
|
async function workflowViewWithConfig(project, workflow, options, config) {
|
|
83
98
|
let projectSlug;
|
|
99
|
+
let environment;
|
|
84
100
|
try {
|
|
85
|
-
|
|
101
|
+
environment = (0, state_1.resolveStateEnvironment)(options.env);
|
|
86
102
|
projectSlug = (0, state_1.projectSlugForState)(project, environment);
|
|
87
103
|
}
|
|
88
104
|
catch (error) {
|
|
@@ -102,7 +118,7 @@ async function workflowViewWithConfig(project, workflow, options, config) {
|
|
|
102
118
|
}
|
|
103
119
|
}
|
|
104
120
|
catch (error) {
|
|
105
|
-
printWorkflowViewError(error, config
|
|
121
|
+
await printWorkflowViewError(error, config, project, environment);
|
|
106
122
|
process.exit(1);
|
|
107
123
|
}
|
|
108
124
|
}
|
package/dist/index.js
CHANGED
|
@@ -38,6 +38,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
};
|
|
39
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
40
|
exports.program = void 0;
|
|
41
|
+
// Must stay first: it edits DEBUG before any dependency can load `debug`, and refuses a network NODE_DEBUG (cli#194).
|
|
42
|
+
require("./utils/debug-guard");
|
|
41
43
|
const chalk_1 = __importDefault(require("chalk"));
|
|
42
44
|
const commander_1 = require("commander");
|
|
43
45
|
const deploy_1 = require("./commands/deploy");
|
|
@@ -97,6 +99,7 @@ const database_1 = require("./commands/database");
|
|
|
97
99
|
const database_push_1 = require("./commands/database-push");
|
|
98
100
|
const database_export_1 = require("./commands/database-export");
|
|
99
101
|
const config_1 = require("./utils/config");
|
|
102
|
+
const host_display_1 = require("./utils/host-display");
|
|
100
103
|
const mutating_commands_1 = require("./utils/mutating-commands");
|
|
101
104
|
const agent_freshness_1 = require("./utils/agent-freshness");
|
|
102
105
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
@@ -117,7 +120,7 @@ if (process.env.SOLIDACTIONS_DEBUG === '1') {
|
|
|
117
120
|
return `(from ${src})`;
|
|
118
121
|
};
|
|
119
122
|
process.stderr.write('[SOLIDACTIONS_DEBUG] resolved configuration:\n');
|
|
120
|
-
process.stderr.write(` host: ${resolved.config.host} ${fmt(resolved.sources.host)}\n`);
|
|
123
|
+
process.stderr.write(` host: ${(0, host_display_1.displayHost)(resolved.config.host)} ${fmt(resolved.sources.host)}\n`);
|
|
121
124
|
process.stderr.write(` apiKey: <redacted> ${fmt(resolved.sources.apiKey)}\n`);
|
|
122
125
|
process.stderr.write(` workspaceId: ${resolved.config.workspaceId ?? ''} ${fmt(resolved.sources.workspaceId)}\n`);
|
|
123
126
|
process.stderr.write(` activePath: ${resolved.activePath}\n`);
|
package/dist/utils/api.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.WorkspaceGuardAbort = exports.SANDBOX_EGRESS_MESSAGE = void 0;
|
|
6
|
+
exports.WorkspaceGuardAbort = exports.SANDBOX_EGRESS_MESSAGE = exports.displayHost = void 0;
|
|
7
7
|
exports.augmentSandboxEgressMessage = augmentSandboxEgressMessage;
|
|
8
8
|
exports.augmentNotFoundMessage = augmentNotFoundMessage;
|
|
9
9
|
exports.augmentWorkspaceForbiddenMessage = augmentWorkspaceForbiddenMessage;
|
|
@@ -15,7 +15,6 @@ exports.describeProjectEnvironments = describeProjectEnvironments;
|
|
|
15
15
|
exports.formatValidationError = formatValidationError;
|
|
16
16
|
exports.requireResolvedConfig = requireResolvedConfig;
|
|
17
17
|
exports.requireConfig = requireConfig;
|
|
18
|
-
exports.displayHost = displayHost;
|
|
19
18
|
exports.authFailureMessage = authFailureMessage;
|
|
20
19
|
exports.formatApiFailure = formatApiFailure;
|
|
21
20
|
exports.authFailedLine = authFailedLine;
|
|
@@ -29,6 +28,8 @@ const path_1 = __importDefault(require("path"));
|
|
|
29
28
|
const prompts_1 = __importDefault(require("prompts"));
|
|
30
29
|
const config_1 = require("./config");
|
|
31
30
|
const workspace_lookup_1 = require("./workspace-lookup");
|
|
31
|
+
const host_display_1 = require("./host-display");
|
|
32
|
+
Object.defineProperty(exports, "displayHost", { enumerable: true, get: function () { return host_display_1.displayHost; } });
|
|
32
33
|
const mutating_commands_1 = require("./mutating-commands");
|
|
33
34
|
const project_ref_1 = require("./project-ref");
|
|
34
35
|
const workspace_guard_1 = require("./workspace-guard");
|
|
@@ -291,6 +292,10 @@ function requireResolvedConfig() {
|
|
|
291
292
|
console.error(chalk_1.default.red((0, config_1.credentialConflictMessage)(resolved.credentialConflict)));
|
|
292
293
|
process.exit(1);
|
|
293
294
|
}
|
|
295
|
+
if (resolved && (0, host_display_1.hostHasUserinfo)(resolved.config.host)) {
|
|
296
|
+
console.error(chalk_1.default.red((0, config_1.userinfoHostMessage)(resolved.config.host, resolved.sources.host)));
|
|
297
|
+
process.exit(1);
|
|
298
|
+
}
|
|
294
299
|
if (!resolved || !resolved.config.apiKey) {
|
|
295
300
|
console.error(chalk_1.default.red('Not initialized. Run `solidactions login --global` first.'));
|
|
296
301
|
process.exit(1);
|
|
@@ -300,26 +305,6 @@ function requireResolvedConfig() {
|
|
|
300
305
|
function requireConfig() {
|
|
301
306
|
return requireResolvedConfig().config;
|
|
302
307
|
}
|
|
303
|
-
/**
|
|
304
|
-
* Host as shown in user-facing output: a URL with any userinfo stripped
|
|
305
|
-
* (credentials must never reach the terminal), otherwise shown as
|
|
306
|
-
* configured. Shared by every authentication-failure message (cli#156).
|
|
307
|
-
*/
|
|
308
|
-
function displayHost(host) {
|
|
309
|
-
let shown = host;
|
|
310
|
-
try {
|
|
311
|
-
const url = new URL(host);
|
|
312
|
-
if (url.username || url.password) {
|
|
313
|
-
url.username = '';
|
|
314
|
-
url.password = '';
|
|
315
|
-
shown = url.toString().replace(/\/$/, '');
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
catch {
|
|
319
|
-
// Not a URL: show it as configured.
|
|
320
|
-
}
|
|
321
|
-
return shown;
|
|
322
|
-
}
|
|
323
308
|
/**
|
|
324
309
|
* Contextual 401 message — names the host being called and where the (now
|
|
325
310
|
* apparently invalid/expired) API key came from, instead of a bare
|
|
@@ -327,7 +312,7 @@ function displayHost(host) {
|
|
|
327
312
|
*/
|
|
328
313
|
function authFailureMessage(config, sources) {
|
|
329
314
|
const keySource = sources?.apiKey ?? 'config';
|
|
330
|
-
return `Authentication failed against ${displayHost(config.host)} (key from ${keySource}). Run \`solidactions login --global\` to re-configure.`;
|
|
315
|
+
return `Authentication failed against ${(0, host_display_1.displayHost)(config.host)} (key from ${keySource}). Run \`solidactions login --global\` to re-configure.`;
|
|
331
316
|
}
|
|
332
317
|
/**
|
|
333
318
|
* One line for a failed API response: the server's `message` when it sent one, else the
|
|
@@ -344,7 +329,7 @@ function formatApiFailure(status, data) {
|
|
|
344
329
|
}
|
|
345
330
|
/** The one-line 401 every command prints: names the host that refused the key (cli#156), never its userinfo. */
|
|
346
331
|
function authFailedLine(host) {
|
|
347
|
-
return `Authentication failed against ${displayHost(host)}. Run "solidactions login --global" to re-configure.`;
|
|
332
|
+
return `Authentication failed against ${(0, host_display_1.displayHost)(host)}. Run "solidactions login --global" to re-configure.`;
|
|
348
333
|
}
|
|
349
334
|
async function ensureWorkspaceSelected(config, dependencies = {}) {
|
|
350
335
|
if (config.workspaceId) {
|
|
@@ -549,7 +534,7 @@ async function applyWorkspaceGuard(config, sources, options, io = {}) {
|
|
|
549
534
|
}
|
|
550
535
|
if (options.mutating && config.workspaceId) {
|
|
551
536
|
// Name the host too (cli#124): the same workspace name on two hosts confirms nothing.
|
|
552
|
-
announce(chalk_1.default.gray(`Workspace: ${describeWorkspace(config, sources)} on ${config.host}`));
|
|
537
|
+
announce(chalk_1.default.gray(`Workspace: ${describeWorkspace(config, sources)} on ${(0, host_display_1.displayHost)(config.host)}`));
|
|
553
538
|
}
|
|
554
539
|
// state.json means "the workspace you last WROTE to" — that is precisely what the write
|
|
555
540
|
// confirmation above compares against. A read must never consume the change that gates a
|
package/dist/utils/config.js
CHANGED
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.DEFAULT_HOST = void 0;
|
|
7
7
|
exports.normalizeHost = normalizeHost;
|
|
8
|
+
exports.userinfoHostMessage = userinfoHostMessage;
|
|
8
9
|
exports.credentialConflictMessage = credentialConflictMessage;
|
|
9
10
|
exports.setCliWorkspaceOverride = setCliWorkspaceOverride;
|
|
10
11
|
exports.getGlobalConfigPath = getGlobalConfigPath;
|
|
@@ -20,6 +21,7 @@ exports.resolveConfig = resolveConfig;
|
|
|
20
21
|
const fs_1 = __importDefault(require("fs"));
|
|
21
22
|
const os_1 = __importDefault(require("os"));
|
|
22
23
|
const path_1 = __importDefault(require("path"));
|
|
24
|
+
const host_display_1 = require("./host-display");
|
|
23
25
|
/** The host an env key goes to when no layer names one (PM ruling 10); the same default `login` uses. */
|
|
24
26
|
exports.DEFAULT_HOST = 'https://app.solidactions.com';
|
|
25
27
|
/** Hosts compare equal ignoring surrounding space, trailing slashes and case. */
|
|
@@ -29,16 +31,20 @@ function normalizeHost(host) {
|
|
|
29
31
|
function describeSource(source, envVar) {
|
|
30
32
|
return source === 'env' ? `$${envVar}` : String(source);
|
|
31
33
|
}
|
|
34
|
+
/** The refusal for a resolved host that carries userinfo (cli#195). Never includes the userinfo. */
|
|
35
|
+
function userinfoHostMessage(host, source) {
|
|
36
|
+
return `error: the host "${(0, host_display_1.displayHost)(host)}" (from ${describeSource(source, 'SOLIDACTIONS_HOST')}) contains a username/password; remove "user:pass@" — the CLI authenticates with your API key.`;
|
|
37
|
+
}
|
|
32
38
|
/** The refusal shown when a key would be sent to a host it was not configured with. Never includes the key. */
|
|
33
39
|
function credentialConflictMessage(conflict) {
|
|
34
40
|
if (conflict.keySource === 'env') {
|
|
35
41
|
// An env key with no SOLIDACTIONS_HOST may only go to the global config's host or the
|
|
36
42
|
// default host — never to a host a folder's config names (PM rulings 1 and 10).
|
|
37
43
|
const globalNote = conflict.otherHost !== undefined
|
|
38
|
-
? ` (the global config names ${conflict.otherHost})`
|
|
44
|
+
? ` (the global config names ${(0, host_display_1.displayHost)(conflict.otherHost)})`
|
|
39
45
|
: '';
|
|
40
46
|
return [
|
|
41
|
-
`Refusing to send the API key from $SOLIDACTIONS_API_KEY to ${conflict.host} (host from ${describeSource(conflict.hostSource, 'SOLIDACTIONS_HOST')}): without SOLIDACTIONS_HOST, a key from the environment only goes to the host in the global config or the default host ${exports.DEFAULT_HOST}${globalNote}.`,
|
|
47
|
+
`Refusing to send the API key from $SOLIDACTIONS_API_KEY to ${(0, host_display_1.displayHost)(conflict.host)} (host from ${describeSource(conflict.hostSource, 'SOLIDACTIONS_HOST')}): without SOLIDACTIONS_HOST, a key from the environment only goes to the host in the global config or the default host ${exports.DEFAULT_HOST}${globalNote}.`,
|
|
42
48
|
'Fix: set SOLIDACTIONS_HOST to the host that key belongs to.',
|
|
43
49
|
].join('\n');
|
|
44
50
|
}
|
|
@@ -47,12 +53,12 @@ function credentialConflictMessage(conflict) {
|
|
|
47
53
|
const keyHome = conflict.keyHost ?? 'no host (that config sets none)';
|
|
48
54
|
const fixes = conflict.hostSource === 'env'
|
|
49
55
|
? ['unset SOLIDACTIONS_HOST', 'or set SOLIDACTIONS_API_KEY to a key for that host as well']
|
|
50
|
-
: [`run \`solidactions login --local --host ${conflict.host}\` in this folder to store a key for ${conflict.host}`, `or remove "host" from ${hostFrom}`];
|
|
56
|
+
: [`run \`solidactions login --local --host ${(0, host_display_1.displayHost)(conflict.host)}\` in this folder to store a key for ${(0, host_display_1.displayHost)(conflict.host)}`, `or remove "host" from ${hostFrom}`];
|
|
51
57
|
if (conflict.keyHost === undefined) {
|
|
52
58
|
fixes.push(`or add "host" to ${keyFrom}`);
|
|
53
59
|
}
|
|
54
60
|
return [
|
|
55
|
-
`Refusing to send the API key from ${keyFrom} to ${conflict.host} (host from ${hostFrom}): that key is configured for ${keyHome}.`,
|
|
61
|
+
`Refusing to send the API key from ${keyFrom} to ${(0, host_display_1.displayHost)(conflict.host)} (host from ${hostFrom}): that key is configured for ${(0, host_display_1.displayHost)(keyHome)}.`,
|
|
56
62
|
`Fix: ${fixes.join(', ')}.`,
|
|
57
63
|
].join('\n');
|
|
58
64
|
}
|
|
@@ -8,6 +8,7 @@ exports.databaseCredentialDeadline = databaseCredentialDeadline;
|
|
|
8
8
|
exports.isDatabaseCredentialAuthFailure = isDatabaseCredentialAuthFailure;
|
|
9
9
|
exports.databaseCredentialFailureCode = databaseCredentialFailureCode;
|
|
10
10
|
exports.safeDatabaseRequestError = safeDatabaseRequestError;
|
|
11
|
+
exports.preserveAuthFailure = preserveAuthFailure;
|
|
11
12
|
exports.runDatabaseClientOperationWithDeadline = runDatabaseClientOperationWithDeadline;
|
|
12
13
|
exports.requestDatabaseOperation = requestDatabaseOperation;
|
|
13
14
|
exports.requestDatabaseDumpStream = requestDatabaseDumpStream;
|
|
@@ -80,7 +81,7 @@ class DatabaseOperationError extends Error {
|
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
83
|
exports.DatabaseOperationError = DatabaseOperationError;
|
|
83
|
-
function safeDatabaseRequestError(error) {
|
|
84
|
+
function safeDatabaseRequestError(error, host) {
|
|
84
85
|
const augmented = (0, api_1.augmentTokenMissingAbilityMessage)(error);
|
|
85
86
|
const response = augmented?.response;
|
|
86
87
|
const status = typeof response?.status === 'number' ? response.status : undefined;
|
|
@@ -88,6 +89,10 @@ function safeDatabaseRequestError(error) {
|
|
|
88
89
|
? response.data.code.trim()
|
|
89
90
|
: '';
|
|
90
91
|
const stableCode = codeCandidate.length > 0 ? codeCandidate : null;
|
|
92
|
+
if (status === 401) {
|
|
93
|
+
// The one-line, host-naming 401 every command prints (cli#186).
|
|
94
|
+
return new DatabaseOperationError(stableCode ?? 'unauthenticated', (0, api_1.authFailedLine)(host), 401);
|
|
95
|
+
}
|
|
91
96
|
const code = stableCode ?? 'upstream_unavailable';
|
|
92
97
|
const appMessage = stableCode !== null
|
|
93
98
|
&& typeof response?.data?.message === 'string'
|
|
@@ -102,6 +107,20 @@ function safeDatabaseRequestError(error) {
|
|
|
102
107
|
: undefined;
|
|
103
108
|
return new DatabaseOperationError(code, message, status, sizeLimitBytes);
|
|
104
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* A wrapper that adds operational state disclosure must not lose a 401's
|
|
112
|
+
* host line and status (cli#186). When the underlying failure is a 401 (a
|
|
113
|
+
* DatabaseOperationError whose message is already the shared host line),
|
|
114
|
+
* the surfaced error keeps its code and status and starts with that line,
|
|
115
|
+
* followed by the disclosure on a second line. Any other failure keeps the
|
|
116
|
+
* wrapper's existing error exactly.
|
|
117
|
+
*/
|
|
118
|
+
function preserveAuthFailure(error, disclosure, fallbackCode, fallbackMessage) {
|
|
119
|
+
if (error instanceof DatabaseOperationError && error.status === 401) {
|
|
120
|
+
return new DatabaseOperationError(error.code, `${error.message}\n${disclosure}`, 401);
|
|
121
|
+
}
|
|
122
|
+
return new DatabaseOperationError(fallbackCode, fallbackMessage);
|
|
123
|
+
}
|
|
105
124
|
function positiveTimeout(value, fallback) {
|
|
106
125
|
return typeof value === 'number' && Number.isFinite(value) && value > 0
|
|
107
126
|
? value
|
|
@@ -170,7 +189,7 @@ async function requestDatabaseOperation(config, body, dependencies = {}) {
|
|
|
170
189
|
return response.data;
|
|
171
190
|
}
|
|
172
191
|
catch (error) {
|
|
173
|
-
throw safeDatabaseRequestError(error);
|
|
192
|
+
throw safeDatabaseRequestError(error, config.host);
|
|
174
193
|
}
|
|
175
194
|
}
|
|
176
195
|
/** Request the existing server-side SQL dump as a stream. */
|
|
@@ -190,7 +209,7 @@ async function requestDatabaseDumpStream(config, name, dependencies = {}) {
|
|
|
190
209
|
return response.data;
|
|
191
210
|
}
|
|
192
211
|
catch (error) {
|
|
193
|
-
throw safeDatabaseRequestError(error);
|
|
212
|
+
throw safeDatabaseRequestError(error, config.host);
|
|
194
213
|
}
|
|
195
214
|
}
|
|
196
215
|
function safeDirectClientError() {
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.guardDebugNamespaces = guardDebugNamespaces;
|
|
7
|
+
exports.nodeDebugNetworkSection = nodeDebugNetworkSection;
|
|
8
|
+
exports.refuseNetworkNodeDebug = refuseNetworkNodeDebug;
|
|
9
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
+
/**
|
|
11
|
+
* cli#194: keep the API key out of every debug channel.
|
|
12
|
+
*
|
|
13
|
+
* - `DEBUG` (the `debug` package): axios sends every request through
|
|
14
|
+
* follow-redirects, whose `debug` namespace dumps the request options (the
|
|
15
|
+
* Authorization header, a URL's userinfo). `debug` reads DEBUG once, when it
|
|
16
|
+
* first loads, and a skip (`-name`) beats any match, so appending the skip
|
|
17
|
+
* here turns that namespace off while every other one keeps working.
|
|
18
|
+
* - `NODE_DEBUG` (Node's util.debuglog): the http/net/tls sections dump
|
|
19
|
+
* connection options, headers included, for the axios path and the MCP
|
|
20
|
+
* transport. Node fixes the enabled sections during bootstrap, before any
|
|
21
|
+
* user code, so they cannot be turned off here: refuse to run instead
|
|
22
|
+
* (recorded on cli#194).
|
|
23
|
+
*
|
|
24
|
+
* src/index.ts imports this module first, before anything can load `debug`
|
|
25
|
+
* or make a request.
|
|
26
|
+
*/
|
|
27
|
+
const DEBUG_SKIP = '-follow-redirects';
|
|
28
|
+
const NETWORK_SECTIONS = ['http', 'https', 'http2', 'net', 'tls'];
|
|
29
|
+
function guardDebugNamespaces(env = process.env) {
|
|
30
|
+
const value = env.DEBUG;
|
|
31
|
+
if (value === undefined || value.trim() === '') {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (value.split(/[\s,]+/).includes(DEBUG_SKIP)) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
env.DEBUG = `${value},${DEBUG_SKIP}`;
|
|
38
|
+
}
|
|
39
|
+
/** The first network section NODE_DEBUG enables, matched exactly as Node's initializeDebugEnv does; null when none. */
|
|
40
|
+
function nodeDebugNetworkSection(value) {
|
|
41
|
+
if (!value) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
const pattern = value
|
|
45
|
+
.replace(/[|\\{}()[\]^$+?.]/g, '\\$&')
|
|
46
|
+
.replace(/\*/g, '.*')
|
|
47
|
+
.replace(/,/g, '$|^');
|
|
48
|
+
const enabled = new RegExp(`^${pattern}$`, 'i');
|
|
49
|
+
return NETWORK_SECTIONS.find((section) => enabled.test(section)) ?? null;
|
|
50
|
+
}
|
|
51
|
+
function refuseNetworkNodeDebug(env = process.env) {
|
|
52
|
+
const section = nodeDebugNetworkSection(env.NODE_DEBUG);
|
|
53
|
+
if (section === null) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
process.stderr.write(`${chalk_1.default.red(`error: NODE_DEBUG=${JSON.stringify(env.NODE_DEBUG)} turns on Node's "${section}" debug output, which prints request headers including your API key. Remove http, https, http2, net and tls from NODE_DEBUG (or unset it) and run again.`)}\n`);
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
refuseNetworkNodeDebug();
|
|
60
|
+
guardDebugNamespaces();
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.displayHost = displayHost;
|
|
4
|
+
exports.hostHasUserinfo = hostHasUserinfo;
|
|
5
|
+
/**
|
|
6
|
+
* Host as shown in user-facing output: a URL with any userinfo stripped
|
|
7
|
+
* (credentials must never reach the terminal), otherwise shown as
|
|
8
|
+
* configured. Every printed host goes through this (cli#156, cli#163);
|
|
9
|
+
* tests/host-display-guard.test.ts fails on a raw host in a printed template.
|
|
10
|
+
*/
|
|
11
|
+
function displayHost(host) {
|
|
12
|
+
let shown = host;
|
|
13
|
+
try {
|
|
14
|
+
const url = new URL(host);
|
|
15
|
+
if (url.host === '') {
|
|
16
|
+
// Parses as an opaque `scheme:rest` (`u:secret@host`): no authority to trust.
|
|
17
|
+
shown = stripUnparsedUserinfo(host);
|
|
18
|
+
}
|
|
19
|
+
else if (url.username || url.password) {
|
|
20
|
+
url.username = '';
|
|
21
|
+
url.password = '';
|
|
22
|
+
shown = url.toString().replace(/\/$/, '');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
shown = stripUnparsedUserinfo(host);
|
|
27
|
+
}
|
|
28
|
+
return shown;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* True when a host carries userinfo (`user:pass@`, `user@`). axios turns URL
|
|
32
|
+
* userinfo into a Basic Authorization header that replaces the CLI's API-key header, so
|
|
33
|
+
* such a host can never authenticate; config resolution and login refuse it
|
|
34
|
+
* (cli#195, Peter's ruling on CrewOps ask task-cliahostwithuser-922c).
|
|
35
|
+
*/
|
|
36
|
+
function hostHasUserinfo(host) {
|
|
37
|
+
try {
|
|
38
|
+
const url = new URL(host);
|
|
39
|
+
if (url.host !== '') {
|
|
40
|
+
return url.username !== '' || url.password !== '';
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
// Not a URL `new URL` accepts: look at the authority by hand below.
|
|
45
|
+
}
|
|
46
|
+
return /^([a-z][a-z0-9+.-]*:\/\/)?[^/?#]*@/i.test(host);
|
|
47
|
+
}
|
|
48
|
+
const INVALID_HOST_PLACEHOLDER = '<invalid host>';
|
|
49
|
+
/**
|
|
50
|
+
* Fallback for a value `new URL` rejects (`http://u:secret@localhost:bad-port`),
|
|
51
|
+
* which must not keep its userinfo (cli#163): cut the authority at its LAST `@`
|
|
52
|
+
* (an `@` inside a password cannot leak), and if an `@` is still left after
|
|
53
|
+
* that, or nothing is, show a placeholder rather than guess. A value without
|
|
54
|
+
* `@` is shown as configured.
|
|
55
|
+
*/
|
|
56
|
+
function stripUnparsedUserinfo(host) {
|
|
57
|
+
if (!host.includes('@')) {
|
|
58
|
+
return host;
|
|
59
|
+
}
|
|
60
|
+
const [, scheme = '', authority = '', rest = ''] = host.match(/^([a-z][a-z0-9+.-]*:\/\/)?([^/?#]*)(.*)$/is) ?? [];
|
|
61
|
+
const afterUserinfo = authority.slice(authority.lastIndexOf('@') + 1);
|
|
62
|
+
if (afterUserinfo === '' || rest.includes('@')) {
|
|
63
|
+
return INVALID_HOST_PLACEHOLDER;
|
|
64
|
+
}
|
|
65
|
+
return scheme + afterUserinfo + rest;
|
|
66
|
+
}
|
package/dist/utils/mcp.js
CHANGED
|
@@ -39,6 +39,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
39
39
|
return result;
|
|
40
40
|
};
|
|
41
41
|
})();
|
|
42
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
43
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
44
|
+
};
|
|
42
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
46
|
exports.McpRpcError = void 0;
|
|
44
47
|
exports.retryAfterSeconds = retryAfterSeconds;
|
|
@@ -47,6 +50,7 @@ exports.callCrewsTool = callCrewsTool;
|
|
|
47
50
|
exports.resolveDocsCall = resolveDocsCall;
|
|
48
51
|
exports.callDocsTool = callDocsTool;
|
|
49
52
|
exports.callCrewsToolContent = callCrewsToolContent;
|
|
53
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
50
54
|
const http = __importStar(require("http"));
|
|
51
55
|
const https = __importStar(require("https"));
|
|
52
56
|
const url_1 = require("url");
|
|
@@ -140,6 +144,12 @@ async function postMcpTool(config, endpointPath, toolName, args) {
|
|
|
140
144
|
process.stderr.write(`solidactions: rate limited by server (429); retrying in ${waitSec}s (attempt ${n + 1}/${RATE_LIMIT_MAX_ATTEMPTS})\n`);
|
|
141
145
|
await new Promise((resolve) => setTimeout(resolve, waitSec * 1000));
|
|
142
146
|
}
|
|
147
|
+
if (last.status === 401) {
|
|
148
|
+
// One transport-level 401 branch for every MCP caller (cli#184): the host
|
|
149
|
+
// line every other command prints, never the raw body.
|
|
150
|
+
process.stderr.write(chalk_1.default.red((0, api_1.authFailedLine)(config.host)) + '\n');
|
|
151
|
+
process.exit(1);
|
|
152
|
+
}
|
|
143
153
|
if (last.status === 404) {
|
|
144
154
|
throw new Error(`MCP request failed: ${parsed.host} has no ${endpointPath} endpoint — the server may be older or newer than this CLI (${CLI_VERSION}). Raw: HTTP 404 ${last.raw}`);
|
|
145
155
|
}
|