@solidactions/cli 3.25.0 → 3.27.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.
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.PLAN_LIMIT_NON_INTERACTIVE_HINT = exports.SKILLS_TIP_LINES = void 0;
7
+ exports.validateProject = validateProject;
7
8
  exports.cacheBusterEntry = cacheBusterEntry;
8
9
  exports.projectStatusUrl = projectStatusUrl;
9
10
  exports.fetchDeploymentConfirmation = fetchDeploymentConfirmation;
@@ -26,6 +27,8 @@ const chalk_1 = __importDefault(require("chalk"));
26
27
  const js_yaml_1 = __importDefault(require("js-yaml"));
27
28
  const prompts_1 = __importDefault(require("prompts"));
28
29
  const env_1 = require("../utils/env");
30
+ const validate_items_1 = require("../utils/validate-items");
31
+ const pages_sync_1 = require("../utils/pages-sync");
29
32
  const api_1 = require("../utils/api");
30
33
  const host_display_1 = require("../utils/host-display");
31
34
  const deploy_ignore_1 = require("../utils/deploy-ignore");
@@ -33,6 +36,7 @@ const slug_1 = require("../utils/slug");
33
36
  const project_ref_1 = require("../utils/project-ref");
34
37
  const skills_1 = require("../utils/skills");
35
38
  const tar_archive_1 = require("../utils/tar-archive");
39
+ const deploy_status_poll_1 = require("../utils/deploy-status-poll");
36
40
  const source_provenance_1 = require("../utils/source-provenance");
37
41
  const project_view_1 = require("./project-view");
38
42
  /** Printed when a deploy target has no SolidActions skill files installed. */
@@ -54,62 +58,81 @@ function validateProject(sourceDir) {
54
58
  errors.push('solidactions.yaml not found. This file defines your workflows.');
55
59
  return { valid: false, errors, warnings };
56
60
  }
57
- // Check for package.json
58
- const packageJsonPath = path_1.default.join(sourceDir, 'package.json');
59
- if (!fs_1.default.existsSync(packageJsonPath)) {
60
- errors.push('package.json not found. Initialize with: npm init');
61
+ // Parse solidactions.yaml
62
+ let config;
63
+ try {
64
+ const configContent = fs_1.default.readFileSync(solidactionsPath, 'utf8');
65
+ config = js_yaml_1.default.load(configContent);
66
+ }
67
+ catch (err) {
68
+ errors.push(`Failed to parse solidactions.yaml: ${err.message}`);
61
69
  return { valid: false, errors, warnings };
62
70
  }
63
- // Read and validate package.json
64
- const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, 'utf8'));
65
- const allDeps = { ...packageJson.dependencies, ...packageJson.devDependencies };
66
- // Check for SDK - either @solidactions/sdk or bundled sdk folder
67
- const hasSdkPackage = '@solidactions/sdk' in allDeps;
68
- const hasBundledSdk = fs_1.default.existsSync(path_1.default.join(sourceDir, 'sdk'));
69
- if (!hasSdkPackage && !hasBundledSdk) {
70
- errors.push('Missing SDK in package.json dependencies. Run: npm install @solidactions/sdk');
71
- }
72
- // Check for TypeScript config if .ts files are used
73
- const srcDir = path_1.default.join(sourceDir, 'src');
74
- const hasTypeScriptFiles = fs_1.default.existsSync(srcDir) &&
75
- fs_1.default.readdirSync(srcDir).some(f => f.endsWith('.ts') || f.endsWith('.tsx'));
76
- if (hasTypeScriptFiles) {
77
- const tsconfigPath = path_1.default.join(sourceDir, 'tsconfig.json');
78
- if (!fs_1.default.existsSync(tsconfigPath)) {
79
- warnings.push('TypeScript files detected but tsconfig.json not found. Build may fail.');
80
- }
71
+ const raw = (config ?? {});
72
+ // Presence selects the retained workflow checks: an explicit `workflows: []`
73
+ // still requires package.json and the SDK.
74
+ const hasWorkflows = Array.isArray(raw.workflows);
75
+ const hasPages = Array.isArray(raw.pages) && raw.pages.length > 0;
76
+ const hasFunctions = Array.isArray(raw.functions) && raw.functions.length > 0;
77
+ if (config?.workflows !== undefined && !Array.isArray(config.workflows)) {
78
+ errors.push('Invalid solidactions.yaml: workflows section is required.');
79
+ }
80
+ else if (!hasWorkflows && !hasPages && !hasFunctions) {
81
+ errors.push('solidactions.yaml must declare at least one of workflows, pages, functions.');
82
+ return { valid: false, errors, warnings };
81
83
  }
82
- // Parse and validate solidactions.yaml
83
- try {
84
- const configContent = fs_1.default.readFileSync(solidactionsPath, 'utf8');
85
- const config = js_yaml_1.default.load(configContent);
86
- if (!config || !config.workflows || !Array.isArray(config.workflows)) {
87
- errors.push('Invalid solidactions.yaml: workflows section is required.');
84
+ if (hasWorkflows) {
85
+ // Check for package.json
86
+ const packageJsonPath = path_1.default.join(sourceDir, 'package.json');
87
+ if (!fs_1.default.existsSync(packageJsonPath)) {
88
+ errors.push('package.json not found. Initialize with: npm init');
89
+ return { valid: false, errors, warnings };
88
90
  }
89
- else {
90
- // Validate each workflow
91
- for (const wf of config.workflows) {
92
- if (!wf.name) {
93
- errors.push(`Workflow missing required 'name' field.`);
94
- continue;
95
- }
96
- // Must have either command: or file:
97
- if (!wf.command && !wf.file) {
98
- errors.push(`Workflow "${wf.name}": must specify either 'command:' or 'file:'.`);
99
- continue;
100
- }
101
- // If file: is specified, verify the file exists
102
- if (wf.file) {
103
- const filePath = path_1.default.join(sourceDir, wf.file);
104
- if (!fs_1.default.existsSync(filePath)) {
105
- errors.push(`Workflow "${wf.name}": file "${wf.file}" not found.`);
106
- }
91
+ // Read and validate package.json
92
+ const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, 'utf8'));
93
+ const allDeps = { ...packageJson.dependencies, ...packageJson.devDependencies };
94
+ // Check for SDK - either @solidactions/sdk or bundled sdk folder
95
+ const hasSdkPackage = '@solidactions/sdk' in allDeps;
96
+ const hasBundledSdk = fs_1.default.existsSync(path_1.default.join(sourceDir, 'sdk'));
97
+ if (!hasSdkPackage && !hasBundledSdk) {
98
+ errors.push('Missing SDK in package.json dependencies. Run: npm install @solidactions/sdk');
99
+ }
100
+ // Check for TypeScript config if .ts files are used
101
+ const srcDir = path_1.default.join(sourceDir, 'src');
102
+ const hasTypeScriptFiles = fs_1.default.existsSync(srcDir) &&
103
+ fs_1.default.readdirSync(srcDir).some(f => f.endsWith('.ts') || f.endsWith('.tsx'));
104
+ if (hasTypeScriptFiles) {
105
+ const tsconfigPath = path_1.default.join(sourceDir, 'tsconfig.json');
106
+ if (!fs_1.default.existsSync(tsconfigPath)) {
107
+ warnings.push('TypeScript files detected but tsconfig.json not found. Build may fail.');
108
+ }
109
+ }
110
+ // Validate each workflow
111
+ for (const wf of config.workflows ?? []) {
112
+ if (typeof wf !== 'object' || wf === null) {
113
+ errors.push(`Workflow entry must be an object with a 'name' field.`);
114
+ continue;
115
+ }
116
+ if (!wf.name) {
117
+ errors.push(`Workflow missing required 'name' field.`);
118
+ continue;
119
+ }
120
+ // Must have either command: or file:
121
+ if (!wf.command && !wf.file) {
122
+ errors.push(`Workflow "${wf.name}": must specify either 'command:' or 'file:'.`);
123
+ continue;
124
+ }
125
+ // If file: is specified, verify the file exists
126
+ if (wf.file) {
127
+ const filePath = path_1.default.join(sourceDir, wf.file);
128
+ if (!fs_1.default.existsSync(filePath)) {
129
+ errors.push(`Workflow "${wf.name}": file "${wf.file}" not found.`);
107
130
  }
108
131
  }
109
132
  }
110
133
  }
111
- catch (err) {
112
- errors.push(`Failed to parse solidactions.yaml: ${err.message}`);
134
+ for (const itemError of (0, validate_items_1.validateItems)(config, sourceDir)) {
135
+ errors.push(`${itemError.entry}.${itemError.field}: ${itemError.message}`);
113
136
  }
114
137
  return { valid: errors.length === 0, errors, warnings };
115
138
  }
@@ -581,9 +604,57 @@ async function deploy(projectName, sourcePath, options = {}) {
581
604
  const sourceMetadata = safeCollectSourceMetadata(sourceDir, options, (directory) => (0, source_provenance_1.collectSourceMetadata)(directory, process.env, (hint) => {
582
605
  console.log(chalk_1.default.yellow(`Git provenance hint: ${hint}`));
583
606
  }));
584
- if (sourceMetadata) {
607
+ if (sourceMetadata && yamlConfig?.workflows) {
585
608
  console.log(chalk_1.default.gray(`Revision to upload (client-reported): ${(0, source_provenance_1.formatRevisionSummary)(sourceMetadata)}`));
586
609
  }
610
+ const pageFiles = (0, pages_sync_1.listCodePages)(yamlConfig ?? {});
611
+ let pageBodies;
612
+ try {
613
+ pageBodies = (0, pages_sync_1.readPageBodies)(sourceDir, pageFiles);
614
+ }
615
+ catch (error) {
616
+ console.error(chalk_1.default.red(`Failed to read page: ${error.message}`));
617
+ process.exit(1);
618
+ }
619
+ const finishDeploy = async ({ deploymentId, buildFailed }) => {
620
+ let yamlSyncFailed = false;
621
+ if (yamlConfig) {
622
+ try {
623
+ await pushYamlDeclarations(config, projectSlug, yamlConfig);
624
+ }
625
+ catch (error) {
626
+ yamlSyncFailed = true;
627
+ if (error.response?.status === 401) {
628
+ console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
629
+ }
630
+ else {
631
+ console.error(chalk_1.default.red(`Config sync FAILED: ${error.response?.data?.message || error.message}`));
632
+ }
633
+ }
634
+ }
635
+ const codeRef = sourceMetadata ? {
636
+ branch: sourceMetadata.branch,
637
+ short_sha: sourceMetadata.short_sha,
638
+ commit_sha: sourceMetadata.commit_sha,
639
+ dirty: sourceMetadata.dirty,
640
+ } : null;
641
+ const payload = (0, pages_sync_1.buildPagesSyncPayload)(pageFiles, pageBodies, deploymentId, codeRef);
642
+ const result = await (0, pages_sync_1.syncPages)(config, projectSlug, payload);
643
+ const rows = result.body?.pages ?? [];
644
+ const trashed = result.body?.trashed ?? [];
645
+ const trashErrors = result.body?.trash_errors ?? [];
646
+ const input = { httpStatus: result.httpStatus, transportError: result.transportError, sentPageCount: pageFiles.length };
647
+ const failure = (0, pages_sync_1.formatPagesSyncFailure)({ ...input, body: result.body });
648
+ for (const line of (0, pages_sync_1.formatPagesSummary)(rows, trashed, trashErrors))
649
+ console.log(line);
650
+ if (failure)
651
+ console.error(chalk_1.default.red(failure));
652
+ const outcome = (0, pages_sync_1.pagesSyncOutcome)({ ...input, rows, trashErrors, stamp: result.body?.stamp });
653
+ process.exit((0, pages_sync_1.terminalExitCode)({ buildFailed, yamlSyncFailed, outcome }));
654
+ };
655
+ if (!yamlConfig?.workflows) {
656
+ return finishDeploy({ deploymentId: null, buildFailed: false });
657
+ }
587
658
  // Plan the file list BEFORE creating the archive write stream so a walk error
588
659
  // (permission error, unreadable dir) aborts cleanly with no orphan tarball.
589
660
  let plan;
@@ -650,99 +721,67 @@ async function deploy(projectName, sourcePath, options = {}) {
650
721
  process.stderr.write(`[deploy-debug] poll URL = ${(0, host_display_1.displayHost)(config.host)}/api/v1/projects/${projectSlug} (workspace=${config.workspaceId ?? '(none)'})\n`);
651
722
  }
652
723
  // Poll for completion
653
- let attempts = 0;
654
- const maxAttempts = 600; // 10 minutes of inactivity timeout
655
- let lastLogLength = 0;
656
- const poll = setInterval(async () => {
657
- try {
658
- attempts++;
659
- const statusRes = await axios_1.default.get(projectStatusUrl(config.host, projectSlug), {
724
+ (0, deploy_status_poll_1.startDeployStatusPoll)({
725
+ read: async () => {
726
+ const response = await axios_1.default.get(projectStatusUrl(config.host, projectSlug), {
660
727
  headers: (0, api_1.getApiHeaders)(config),
661
728
  });
662
- const { status, build_log } = statusRes.data;
663
- // Stream new log content
664
- if (build_log && build_log.length > lastLogLength) {
665
- const newContent = build_log.substring(lastLogLength);
666
- process.stdout.write(chalk_1.default.gray(newContent));
667
- if (!newContent.endsWith('\n')) {
668
- process.stdout.write('\n');
729
+ return response.data;
730
+ },
731
+ schedule: (tick) => {
732
+ const poll = setInterval(tick, 1000);
733
+ return () => clearInterval(poll);
734
+ },
735
+ maxAttempts: 600, // 10 minutes of inactivity timeout
736
+ onLog: (newContent) => {
737
+ process.stdout.write(chalk_1.default.gray(newContent));
738
+ if (!newContent.endsWith('\n')) {
739
+ process.stdout.write('\n');
740
+ }
741
+ },
742
+ onWaiting: () => console.log(chalk_1.default.gray('Still waiting for build to start...')),
743
+ onDeployed: async () => {
744
+ console.log(chalk_1.default.green(`\n✓ Deployed to ${projectSlug}${envLabel}!`));
745
+ try {
746
+ const confirmedProject = await confirmDeploymentWithRetry(acceptedDeployment.deploymentId, () => fetchDeploymentConfirmation(config, projectSlug));
747
+ for (const line of formatDeploymentConfirmation(confirmedProject, acceptedDeployment.deploymentId, acceptedDeployment.sourceMetadataRejected)) {
748
+ console.log(line);
669
749
  }
670
- lastLogLength = build_log.length;
671
- attempts = 0; // Reset timeout — build is still progressing
672
750
  }
673
- // Periodic waiting indicator when no logs yet
674
- if (attempts > 0 && attempts % 15 === 0 && lastLogLength === 0) {
675
- console.log(chalk_1.default.gray('Still waiting for build to start...'));
751
+ catch {
752
+ console.log(chalk_1.default.yellow('Build finished; server revision confirmation was unavailable.'));
676
753
  }
677
- if (status === 'deployed') {
678
- clearInterval(poll);
679
- console.log(chalk_1.default.green(`\n✓ Deployed to ${projectSlug}${envLabel}!`));
680
- try {
681
- const confirmedProject = await confirmDeploymentWithRetry(acceptedDeployment.deploymentId, () => fetchDeploymentConfirmation(config, projectSlug));
682
- for (const line of formatDeploymentConfirmation(confirmedProject, acceptedDeployment.deploymentId, acceptedDeployment.sourceMetadataRejected)) {
683
- console.log(line);
684
- }
685
- }
686
- catch {
687
- console.log(chalk_1.default.yellow('Build finished; server revision confirmation was unavailable.'));
688
- }
689
- // Always sync YAML declarations (registers variables and their mappings)
690
- if (yamlConfig) {
691
- try {
692
- await pushYamlDeclarations(config, projectSlug, yamlConfig);
693
- }
694
- catch (error) {
695
- if (error.response?.status === 401) {
696
- console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
697
- }
698
- else {
699
- console.error(chalk_1.default.red(`Config sync FAILED: ${error.response?.data?.message || error.message}`));
700
- }
701
- cleanupArchive();
702
- process.exit(1);
703
- }
704
- }
705
- if (yamlConfig && shouldPrintWebhookSecretNotice(yamlConfig.workflows ?? [])) {
706
- const envFlag = environment !== 'dev' ? ` -e ${environment}` : '';
707
- console.log('');
708
- console.log(chalk_1.default.blue(`ℹ Webhook secret: run \`solidactions webhook secret ${(0, slug_1.slugifyName)(projectName) || projectName}${envFlag}\` to retrieve the generated secret.`));
709
- console.log(chalk_1.default.gray(` Set the same value in your sender (e.g. Telegram setWebhook secret_token).`));
710
- }
711
- if (options.paused) {
712
- console.log('');
713
- if (acceptedDeployment.schedulesPaused === true) {
714
- console.log(chalk_1.default.green('Schedules deployed paused.'));
715
- console.log(chalk_1.default.gray(`Enable one when ready with: solidactions schedule enable ${projectSlug} <schedule-id>`));
716
- }
717
- else {
718
- console.log(chalk_1.default.yellow('Warning: server did not acknowledge paused schedules; verify schedules before relying on them being paused.'));
719
- }
720
- }
721
- cleanupArchive();
722
- process.exit(0);
754
+ if (yamlConfig && shouldPrintWebhookSecretNotice(yamlConfig.workflows ?? [])) {
755
+ const envFlag = environment !== 'dev' ? ` -e ${environment}` : '';
756
+ console.log('');
757
+ console.log(chalk_1.default.blue(`ℹ Webhook secret: run \`solidactions webhook secret ${(0, slug_1.slugifyName)(projectName) || projectName}${envFlag}\` to retrieve the generated secret.`));
758
+ console.log(chalk_1.default.gray(` Set the same value in your sender (e.g. Telegram setWebhook secret_token).`));
723
759
  }
724
- else if (status === 'error') {
725
- clearInterval(poll);
726
- console.error(chalk_1.default.red('\n✗ Build Failed!'));
727
- if (build_log) {
728
- console.log(chalk_1.default.yellow('\n--- Full Build Log ---'));
729
- console.log(chalk_1.default.gray(build_log));
730
- console.log(chalk_1.default.yellow('--- End Build Log ---\n'));
760
+ if (options.paused) {
761
+ console.log('');
762
+ if (acceptedDeployment.schedulesPaused === true) {
763
+ console.log(chalk_1.default.green('Schedules deployed paused.'));
764
+ console.log(chalk_1.default.gray(`Enable one when ready with: solidactions schedule enable ${projectSlug} <schedule-id>`));
765
+ }
766
+ else {
767
+ console.log(chalk_1.default.yellow('Warning: server did not acknowledge paused schedules; verify schedules before relying on them being paused.'));
731
768
  }
732
- cleanupArchive();
733
- process.exit(1);
734
769
  }
735
- else if (attempts >= maxAttempts) {
736
- clearInterval(poll);
737
- console.error(chalk_1.default.red('\nTimeout waiting for build. It might still finish.'));
738
- cleanupArchive();
739
- process.exit(1);
770
+ },
771
+ onFailed: (build_log) => {
772
+ console.error(chalk_1.default.red('\n✗ Build Failed!'));
773
+ if (build_log) {
774
+ console.log(chalk_1.default.yellow('\n--- Full Build Log ---'));
775
+ console.log(chalk_1.default.gray(build_log));
776
+ console.log(chalk_1.default.yellow('--- End Build Log ---\n'));
740
777
  }
741
- }
742
- catch {
743
- // Ignore transient errors
744
- }
745
- }, 1000);
778
+ },
779
+ onTimeout: () => console.error(chalk_1.default.red('\nTimeout waiting for build. It might still finish.')),
780
+ finalize: async (buildFailed) => {
781
+ cleanupArchive();
782
+ await finishDeploy({ deploymentId: acceptedDeployment.deploymentId, buildFailed });
783
+ },
784
+ });
746
785
  }
747
786
  catch (error) {
748
787
  console.error(chalk_1.default.red('Deployment failed:'));
@@ -25,6 +25,11 @@ const CLI_OAUTH_CLIENT_ID = '9f1b6e2a-9c1e-4b6e-8f0a-6c9f2b1e7d4c';
25
25
  // added at consent time, because the device code's scope set is frozen when
26
26
  // the code is created (#1252).
27
27
  const CLI_SCOPES_WITH_REVEAL = 'env env:reveal deploy runs docs databases';
28
+ // `connections:request` (cli#219, connect links) is granted with the token
29
+ // like the other CLI scopes. It comes first; a server that has not
30
+ // registered it rejects the whole request with `invalid_scope`, and the
31
+ // next list is tried.
32
+ const CLI_SCOPES_WITH_CONNECT_LINKS = 'env env:reveal deploy runs docs databases connections:request';
28
33
  // Pre-#1252 scope list, kept as the fallback for servers that haven't
29
34
  // registered `env:reveal` yet (older production, a lagging staging, a
30
35
  // self-hosted install). Passport rejects the entire device-code request with
@@ -32,30 +37,33 @@ const CLI_SCOPES_WITH_REVEAL = 'env env:reveal deploy runs docs databases';
32
37
  // `env:reveal` unconditionally would hard-break device login everywhere
33
38
  // until every server picks up the companion change.
34
39
  const CLI_SCOPES_LEGACY = 'env deploy runs docs databases';
40
+ // Tried in order; each retry only on 400 `invalid_scope`.
41
+ const CLI_SCOPE_LISTS = [CLI_SCOPES_WITH_CONNECT_LINKS, CLI_SCOPES_WITH_REVEAL, CLI_SCOPES_LEGACY];
35
42
  /**
36
- * Request a device code with the full (env:reveal-including) scope list. If
37
- * the server doesn't yet recognize `env:reveal` it rejects the whole request
38
- * with 400 `invalid_scope` — retry once with the legacy scope list so login
39
- * still succeeds. Any other rejection (e.g. a bad client_id) still fails
40
- * loudly; only this specific, detectable condition is swallowed.
43
+ * Request a device code with the full scope list (`connections:request` and
44
+ * `env:reveal` included). If the server doesn't yet recognize a scope it
45
+ * rejects the whole request with 400 `invalid_scope` — retry with the next,
46
+ * shorter list (without `connections:request`, then the legacy list without
47
+ * `env:reveal`) so login still succeeds: at most 3 requests. Any other
48
+ * rejection (e.g. a bad client_id) still fails loudly; only this specific,
49
+ * detectable condition is swallowed.
41
50
  */
42
51
  async function requestDeviceCode(host) {
43
- try {
44
- const response = await axios_1.default.post(`${host}/oauth/device/code`, {
45
- client_id: CLI_OAUTH_CLIENT_ID,
46
- scope: CLI_SCOPES_WITH_REVEAL,
47
- });
48
- return response.data;
49
- }
50
- catch (e) {
51
- if (e?.response?.status === 400 && e.response.data?.error === 'invalid_scope') {
52
+ for (let i = 0;; i++) {
53
+ try {
52
54
  const response = await axios_1.default.post(`${host}/oauth/device/code`, {
53
55
  client_id: CLI_OAUTH_CLIENT_ID,
54
- scope: CLI_SCOPES_LEGACY,
56
+ scope: CLI_SCOPE_LISTS[i],
55
57
  });
56
58
  return response.data;
57
59
  }
58
- throw e;
60
+ catch (e) {
61
+ const invalidScope = e?.response?.status === 400 && e.response.data?.error === 'invalid_scope';
62
+ if (invalidScope && i < CLI_SCOPE_LISTS.length - 1) {
63
+ continue;
64
+ }
65
+ throw e;
66
+ }
59
67
  }
60
68
  }
61
69
  function sleep(ms) {
package/dist/index.js CHANGED
@@ -73,6 +73,8 @@ const oauth_action_search_1 = require("./commands/oauth-action-search");
73
73
  const oauth_action_list_1 = require("./commands/oauth-action-list");
74
74
  const oauth_action_view_1 = require("./commands/oauth-action-view");
75
75
  const oauth_action_platforms_1 = require("./commands/oauth-action-platforms");
76
+ const connection_connect_1 = require("./commands/connection-connect");
77
+ const connection_wait_1 = require("./commands/connection-wait");
76
78
  const connection_list_1 = require("./commands/connection-list");
77
79
  const workspaces_1 = require("./commands/workspaces");
78
80
  const skill_push_1 = require("./commands/skill-push");
@@ -904,6 +906,22 @@ connection
904
906
  .action(() => {
905
907
  (0, connection_list_1.connectionList)();
906
908
  });
909
+ connection
910
+ .command('connect [platform]')
911
+ .description('Mint a connect link a person clicks to connect an app, then print it and the wait command')
912
+ .option('--name <name>', 'Name of the new connection')
913
+ .option('--reconnect <name>', 'Refresh an existing connection instead (its platform is looked up when omitted)')
914
+ .option('--bind <project:var>', 'Bind a project variable to the connection once it is connected (repeatable, up to 10)', (value, previous = []) => [...previous, value], [])
915
+ .action((platform, options) => {
916
+ (0, connection_connect_1.connectionConnect)(platform, options);
917
+ });
918
+ connection
919
+ .command('wait <request-id>')
920
+ .description('Wait until a connect link is used: exit 0 connected, 1 expired, cancelled or failed, 2 still open at --timeout, 130 on Ctrl-C')
921
+ .option('--timeout <duration>', 'How long to wait, e.g. 30s, 15m, 1h', '15m')
922
+ .action((requestId, options) => {
923
+ (0, connection_wait_1.connectionWait)(requestId, options);
924
+ });
907
925
  // =============================================================================
908
926
  // ai <subcommand>
909
927
  // =============================================================================
package/dist/utils/api.js CHANGED
@@ -149,9 +149,10 @@ function augmentWorkspaceForbiddenMessage(error) {
149
149
  return error;
150
150
  }
151
151
  /**
152
- * Existing device tokens predate the coarse `databases` scope. Turn the app's
153
- * stable missing-ability response into a re-login instruction while preserving
154
- * its original message. Other ability failures retain their existing behavior.
152
+ * Existing device tokens predate the coarse `databases`, `env:reveal` and
153
+ * `connections:request` abilities. Turn the app's stable missing-ability
154
+ * response into a re-login instruction while preserving its original message.
155
+ * Other ability failures retain their existing behavior.
155
156
  */
156
157
  function augmentTokenMissingAbilityMessage(error) {
157
158
  const response = error?.response;
@@ -184,6 +185,19 @@ function augmentTokenMissingAbilityMessage(error) {
184
185
  response.data.message = `${message}\n\n${hint}`;
185
186
  }
186
187
  }
188
+ if (response?.status === 403
189
+ && response.data?.code === 'token_missing_ability'
190
+ && requiredAbility === 'connections:request') {
191
+ const hint = "Connect links need the 'connections:request' ability. "
192
+ + 'Run `solidactions login --device` again to get it, or create an API key with '
193
+ + "'connections:request' checked at Settings → API keys and `solidactions login` with that key.";
194
+ const message = typeof response.data.message === 'string' && response.data.message.length > 0
195
+ ? response.data.message
196
+ : "This session does not have the 'connections:request' ability.";
197
+ if (!message.includes('Connect links need')) {
198
+ response.data.message = `${message}\n\n${hint}`;
199
+ }
200
+ }
187
201
  return error;
188
202
  }
189
203
  axios_1.default.interceptors.response.use((response) => response, (error) => Promise.reject(augmentTokenMissingAbilityMessage(augmentWorkspaceForbiddenMessage(augmentNotFoundMessage(augmentSandboxEgressMessage(error))))));
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CONNECT_LINK_MAX_BINDINGS = void 0;
4
+ exports.parseBinding = parseBinding;
5
+ exports.plainText = plainText;
6
+ exports.shellArg = shellArg;
7
+ exports.waitCommandLine = waitCommandLine;
8
+ exports.formatExpiry = formatExpiry;
9
+ exports.connectLinkFailureLine = connectLinkFailureLine;
10
+ const api_1 = require("./api");
11
+ exports.CONNECT_LINK_MAX_BINDINGS = 10;
12
+ /** 'PROJECT:VAR' → {project, var}; split at the first ':'; both sides trimmed and non-empty, else throws Error with a one-line message. */
13
+ function parseBinding(value) {
14
+ const index = value.indexOf(':');
15
+ const project = index === -1 ? '' : value.slice(0, index).trim();
16
+ const variable = index === -1 ? '' : value.slice(index + 1).trim();
17
+ if (project === '' || variable === '') {
18
+ throw new Error(`--bind must be PROJECT:VAR (got "${plainText(value)}")`);
19
+ }
20
+ return { project, var: variable };
21
+ }
22
+ /** Removes C0/C1 control characters (U+0000-U+0008, U+000B-U+001F, U+007F-U+009F), keeping '\n' and '\t'. */
23
+ function plainText(value) {
24
+ return value.replace(/[\u0000-\u0008\u000B-\u001F\u007F-\u009F]/g, '');
25
+ }
26
+ const SHELL_SAFE = /^[A-Za-z0-9_@%+=:,.\/-]+$/;
27
+ /**
28
+ * Quote a value for pasting into a POSIX shell command line. Values of
29
+ * letters, digits and a few safe punctuation marks stay bare; anything else
30
+ * (spaces, quotes, `;`, `&`, …) is single-quoted (`'` → `'\''`), so the
31
+ * suggestion still parses as the same single argument.
32
+ */
33
+ function shellArg(value) {
34
+ if (SHELL_SAFE.test(value)) {
35
+ return value;
36
+ }
37
+ return `'${value.replace(/'/g, `'\\''`)}'`;
38
+ }
39
+ /** 'solidactions connection wait <id>' (the id is quoted unless it is shell-safe, e.g. a ULID). */
40
+ function waitCommandLine(id) {
41
+ return `solidactions connection wait ${shellArg(id)}`;
42
+ }
43
+ /** '2026-10-29T19:00:00Z' → '2026-10-29 19:00 UTC' (the server's own `text` format); a value Date cannot parse → plainText(value); a non-string → 'unknown'. */
44
+ function formatExpiry(iso) {
45
+ if (typeof iso !== 'string') {
46
+ return 'unknown';
47
+ }
48
+ const d = new Date(iso);
49
+ if (Number.isNaN(d.getTime())) {
50
+ return plainText(iso);
51
+ }
52
+ return `${d.toISOString().slice(0, 10)} ${d.toISOString().slice(11, 16)} UTC`;
53
+ }
54
+ /** The one line for a failed request: 401 → authFailedLine(host); a response → formatApiFailure(status, data); none → 'Connection failed: <message>'. */
55
+ function connectLinkFailureLine(error, host) {
56
+ if (error?.response?.status === 401) {
57
+ return (0, api_1.authFailedLine)(host);
58
+ }
59
+ if (error?.response) {
60
+ return (0, api_1.formatApiFailure)(error.response.status, error.response.data);
61
+ }
62
+ return `Connection failed: ${error?.message ?? String(error)}`;
63
+ }
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.startDeployStatusPoll = startDeployStatusPoll;
4
+ const terminal_gate_1 = require("./terminal-gate");
5
+ function startDeployStatusPoll(options) {
6
+ let attempts = 0;
7
+ let lastLogLength = 0;
8
+ let pollInFlight = false;
9
+ const terminalGate = (0, terminal_gate_1.createTerminalGate)();
10
+ const stop = options.schedule(async () => {
11
+ if (pollInFlight)
12
+ return;
13
+ pollInFlight = true;
14
+ try {
15
+ attempts++;
16
+ const { status, build_log } = await options.read();
17
+ if (build_log && build_log.length > lastLogLength) {
18
+ options.onLog(build_log.substring(lastLogLength));
19
+ lastLogLength = build_log.length;
20
+ attempts = 0;
21
+ }
22
+ if (attempts > 0 && attempts % 15 === 0 && lastLogLength === 0) {
23
+ options.onWaiting();
24
+ }
25
+ if (status === 'deployed') {
26
+ if (!terminalGate.claim())
27
+ return;
28
+ stop();
29
+ await options.onDeployed();
30
+ await options.finalize(false);
31
+ }
32
+ else if (status === 'error') {
33
+ if (!terminalGate.claim())
34
+ return;
35
+ stop();
36
+ options.onFailed(build_log);
37
+ await options.finalize(true);
38
+ }
39
+ else if (attempts >= options.maxAttempts) {
40
+ if (!terminalGate.claim())
41
+ return;
42
+ stop();
43
+ options.onTimeout();
44
+ await options.finalize(true);
45
+ }
46
+ }
47
+ catch {
48
+ // Ignore transient errors
49
+ }
50
+ finally {
51
+ pollInFlight = false;
52
+ }
53
+ });
54
+ }
@@ -100,6 +100,8 @@ exports.MUTATING_COMMANDS = new Set([
100
100
  'role push',
101
101
  'doc push',
102
102
  'doc upload',
103
+ // POSTs a connect-link request (a row the workspace counts against its open-link limit).
104
+ 'connection connect',
103
105
  ]);
104
106
  /** Space-joined command paths that do not mutate server state. */
105
107
  exports.READONLY_COMMANDS = new Set([
@@ -149,6 +151,7 @@ exports.READONLY_COMMANDS = new Set([
149
151
  'oauth-action view',
150
152
  'oauth-action platforms',
151
153
  'connection list',
154
+ 'connection wait',
152
155
  'ai init',
153
156
  'ai examples',
154
157
  'skill pull',