@camunda8/cli 4.3.0-alpha.2 → 4.3.0-alpha.4

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
@@ -70,6 +70,9 @@ c8ctl cluster start
70
70
  # Store a secret for local development (values are never shown or stored by c8ctl)
71
71
  c8ctl cluster secrets set OPENAI_API_KEY
72
72
 
73
+ # Manage isolated local physical tenants (requires a supporting c8run 8.10+ build)
74
+ c8ctl cluster tenants add sales
75
+
73
76
  # Deploy a process and start an instance
74
77
  c8ctl deploy ./my-process.bpmn
75
78
  c8ctl run my-process
@@ -43,6 +43,22 @@ c8ctl cluster install 8.8
43
43
  c8ctl cluster delete 8.8
44
44
  ```
45
45
 
46
+ ## Physical tenants
47
+
48
+ For physical tenants (supporting Camunda 8.10+ builds):
49
+
50
+ ```bash
51
+ c8ctl cluster tenants --c8-version 8.10 add sales
52
+ c8ctl cluster start 8.10
53
+ c8ctl cluster tenants list
54
+ c8ctl cluster secrets --tenant sales set OPENAI_API_KEY
55
+ c8ctl cluster tenants remove sales --yes
56
+ # Or choose tenants for one start only:
57
+ c8ctl cluster start 8.10 --physical-tenants sales,hr
58
+ ```
59
+
60
+ Tenant commands delegate to the selected installed c8run, following the same version selection and terminal behavior as `cluster secrets`. c8run owns tenant configuration and storage. See [local physical tenants](../../docs/getting-started.md#local-physical-tenants) for authentication, profiles, relative paths, and limitations.
61
+
46
62
  ## Version aliases
47
63
 
48
64
  The `stable` and `alpha` aliases are resolved dynamically by querying the
@@ -83,6 +99,22 @@ and always leaves the install directory itself in place. Stop the cluster first.
83
99
  If a process does end up orphaned (e.g. the directory was removed outside
84
100
  c8ctl), `cluster stop` terminates it directly using the recorded PID.
85
101
 
102
+ When `cluster start` exits nonzero with surviving Camunda or connector processes,
103
+ the PID record also retains the failed startup outcome. `cluster status` reports
104
+ **`running after failed startup`**, even if the shared health endpoint responds:
105
+ that response does not establish readiness of every physical tenant. Review the
106
+ startup error or c8run logs, then run `c8ctl cluster stop` before retrying. The
107
+ original startup exit code is preserved. Stop clears the record once all recorded
108
+ processes are gone; a successful start replaces any stale failure metadata.
109
+ This also applies when c8run exits successfully but c8ctl's readiness check times
110
+ out: `cluster start` exits 1 and retains the failed startup outcome. Retrying
111
+ while processes survive without an active marker exits 1 without launching a new
112
+ instance or replacing the recovery record.
113
+
114
+ Without a known failed startup, live processes lacking an active marker are
115
+ reported as **`running (untracked)`**, with neutral recovery guidance. Both text
116
+ and JSON status include instructions to stop the surviving processes.
117
+
86
118
  ## How it works
87
119
 
88
120
  1. **Download**: Automatically downloads the correct c8run binary for your platform from the Camunda Download Center
@@ -114,6 +146,18 @@ The c8run archive is several hundred MB. If the connection drops, `c8ctl cluster
114
146
  - Set `C8CTL_C8RUN_DOWNLOAD_URL` to download from a mirror with the same layout as the Camunda Download Center.
115
147
  - Add `--verbose` to print HTTP details for each download attempt: request and response headers, timing, throughput, and the full error cause chain.
116
148
 
149
+ ## Physical-tenant verification
150
+
151
+ The opt-in integration test owns the local cluster lifecycle and needs an installed c8run build with physical-tenant CLI support. Run it separately from the general integration suite, with no other cluster running and a dedicated cache containing that distribution:
152
+
153
+ ```bash
154
+ C8RUN_CACHE_DIR=/path/to/scratch-cache \
155
+ C8CTL_PHYSICAL_TENANTS_VERSION=8.10.1 \
156
+ node --experimental-strip-types --test tests/integration/physical-tenants.test.ts
157
+ ```
158
+
159
+ Set the version to the actual installed cache version. The test uses temporary tenant/secrets/profile files, validates authenticated profile routing and deployment isolation, restarts the cluster, and stops it on completion. Its tenant's engine data remains in the dedicated cache. The normal unit suite tests forwarding and failure handling without downloading or launching Java.
160
+
117
161
  ## Supported platforms
118
162
 
119
163
  - macOS (x86_64, aarch64)
@@ -331,11 +331,12 @@ export const metadata = {
331
331
  // so the subcommand flags are documented via `flagsHint` instead.
332
332
  passthrough: true,
333
333
  passthroughHint:
334
- '--purge, --debug and --c8-version are read by the plugin; everything after `secrets` is forwarded to c8run',
334
+ '--purge, --debug, --physical-tenants and --c8-version are read by the plugin; arguments after `secrets` or `tenants` are forwarded to c8run',
335
335
  flagsHint: [
336
336
  '--c8-version <version> Camunda version, alias or major.minor (alternative to the positional <version>)',
337
337
  '--debug (start, stop) Stream raw c8run output',
338
338
  '--purge (stop only) Also delete runtime data after stopping',
339
+ '--physical-tenants <ids> (start only) Comma-separated physical tenants for this run (repeatable; Camunda 8.10+)',
339
340
  ],
340
341
  subcommands: [
341
342
  { name: 'start', description: 'Start local Camunda 8 cluster' },
@@ -349,6 +350,7 @@ export const metadata = {
349
350
  { name: 'logs', description: 'Stream cluster logs' },
350
351
  { name: 'purge', description: 'Delete runtime data (keeps binary) so the next start is fresh' },
351
352
  { name: 'secrets', description: 'Manage local development secrets (passed through to c8run)' },
353
+ { name: 'tenants', description: 'Manage local physical tenants (passed through to c8run; Camunda 8.10+)' },
352
354
  ],
353
355
  examples: [
354
356
  { command: 'c8ctl cluster start', description: 'Start a local Camunda 8 cluster (latest stable)' },
@@ -367,6 +369,9 @@ export const metadata = {
367
369
  { command: 'c8ctl cluster secrets list', description: 'List secret names (values are never shown)' },
368
370
  { command: 'c8ctl cluster secrets import .env.secrets', description: 'Import secrets from a dotenv file' },
369
371
  { command: 'c8ctl cluster secrets delete OPENAI_API_KEY --yes', description: 'Delete a secret without prompting' },
372
+ { command: 'c8ctl cluster tenants --c8-version 8.10 add sales', description: 'Save a physical tenant using an installed 8.10 build' },
373
+ { command: 'c8ctl cluster start 8.10 --physical-tenants sales,hr', description: 'Start physical tenants for one run only' },
374
+ { command: 'c8ctl cluster secrets --tenant sales set OPENAI_API_KEY', description: 'Store a secret for one physical tenant' },
370
375
  ],
371
376
  },
372
377
  },
@@ -1591,7 +1596,7 @@ function printSummary(rawOutput, version) {
1591
1596
  console.log('');
1592
1597
  }
1593
1598
 
1594
- async function startC8Run(config, debug = false) {
1599
+ async function startC8Run(config, debug = false, startArgs = []) {
1595
1600
  const logger = getLogger();
1596
1601
  const binaryPath = getC8RunBinaryPath(config);
1597
1602
  const logDir = join(dirname(binaryPath), 'log');
@@ -1639,15 +1644,15 @@ async function startC8Run(config, debug = false) {
1639
1644
  if (record?.version) {
1640
1645
  logger.info(`Detected running version from the durable PID record: ${record.version}`);
1641
1646
  }
1642
- logger.info('Stop it first with "c8ctl cluster stop".');
1643
- return;
1647
+ throw new Error('Refusing to start while cluster processes survive without an active marker. Stop them first with "c8ctl cluster stop".');
1644
1648
  }
1645
1649
 
1646
1650
  logger.info('Starting Camunda 8 local cluster...');
1647
1651
 
1648
- const proc = spawn(binaryPath, ['start'], {
1652
+ const proc = spawn(binaryPath, ['start', ...startArgs], {
1649
1653
  stdio: ['ignore', 'pipe', 'pipe'],
1650
1654
  cwd: dirname(binaryPath),
1655
+ env: { ...resolveLocalStoreEnv(process.env, process.cwd()), C8RUN_CLI_NAME },
1651
1656
  });
1652
1657
 
1653
1658
  if (typeof proc.pid !== 'number') {
@@ -1691,9 +1696,19 @@ async function startC8Run(config, debug = false) {
1691
1696
  });
1692
1697
 
1693
1698
  if (exitCode !== 0) {
1699
+ // A failed tenant probe leaves healthy engines alive; preserve their identity
1700
+ // for stop/status even if the installation directory is subsequently replaced.
1701
+ try {
1702
+ recordRunningClusterPids(config, { skipEmpty: true, startupFailed: true });
1703
+ } catch (error) {
1704
+ logger.warn(`Could not record surviving cluster processes: ${formatErrorWithCause(error)}. Use "c8ctl cluster stop" while the installation is still present.`);
1705
+ }
1694
1706
  if (startupOutput.trim()) {
1695
1707
  logger.error(`c8run output:\n${startupOutput.trim()}`);
1696
1708
  }
1709
+ if (startArgs.length > 0 && /flag provided but not defined: -physical-tenants/.test(startupOutput)) {
1710
+ logger.error('This cached c8run build lacks --physical-tenants. Install a Camunda 8.10+ build containing physical-tenant CLI support with "c8ctl cluster install 8.10".');
1711
+ }
1697
1712
  logger.error(
1698
1713
  `c8run start exited with code ${exitCode ?? 'unknown'}${exitSignal ? ` (signal: ${exitSignal})` : ''}. Cluster will not be marked as running.`,
1699
1714
  );
@@ -1731,6 +1746,13 @@ async function startC8Run(config, debug = false) {
1731
1746
  writeFileSync(versionFile, config.version);
1732
1747
  printSummary(startupOutput, config.version);
1733
1748
  } else {
1749
+ // Readiness can fail even after c8run exits successfully. Retain the same
1750
+ // recovery handle as a nonzero launcher exit before reporting failure.
1751
+ try {
1752
+ recordRunningClusterPids(config, { skipEmpty: true, startupFailed: true });
1753
+ } catch (error) {
1754
+ logger.warn(`Could not record surviving cluster processes: ${formatErrorWithCause(error)}. Use "c8ctl cluster stop" while the installation is still present.`);
1755
+ }
1734
1756
  logger.error(
1735
1757
  'Cluster failed to start within timeout.',
1736
1758
  );
@@ -1998,11 +2020,11 @@ export function readRunningClusterRecord(cacheDir) {
1998
2020
  } catch {
1999
2021
  return null;
2000
2022
  }
2001
- return { version, pids, signatures };
2023
+ return { version, pids, signatures, ...(parsed.startupFailed === true ? { startupFailed: true } : {}) };
2002
2024
  }
2003
2025
 
2004
2026
  /** Persist the durable running-cluster PID record. */
2005
- export function writeRunningClusterRecord(cacheDir, { version, pids, signatures }) {
2027
+ export function writeRunningClusterRecord(cacheDir, { version, pids, signatures, startupFailed }) {
2006
2028
  mkdirSync(cacheDir, { recursive: true });
2007
2029
  const cleanPids = Array.isArray(pids)
2008
2030
  ? [...new Set(pids.filter((pid) => Number.isInteger(pid) && pid > 0))]
@@ -2027,6 +2049,7 @@ export function writeRunningClusterRecord(cacheDir, { version, pids, signatures
2027
2049
  version: version ?? null,
2028
2050
  pids: cleanPids,
2029
2051
  signatures: cleanSignatures,
2052
+ ...(startupFailed === true ? { startupFailed: true } : {}),
2030
2053
  });
2031
2054
  try {
2032
2055
  writeFileSync(tmpPath, payload);
@@ -2080,7 +2103,7 @@ export function liveRecordedPids(cacheDir) {
2080
2103
  * with a start signature so a later stop/status can tell the recorded process
2081
2104
  * apart from an unrelated one that reused its PID.
2082
2105
  */
2083
- export function recordRunningClusterPids(config, { signatureOf = processStartSignature } = {}) {
2106
+ export function recordRunningClusterPids(config, { signatureOf = processStartSignature, skipEmpty = false, startupFailed = false } = {}) {
2084
2107
  const canFingerprint = platformSupportsProcessSignature();
2085
2108
  const pids = [];
2086
2109
  const signatures = {};
@@ -2108,7 +2131,9 @@ export function recordRunningClusterPids(config, { signatureOf = processStartSig
2108
2131
  pids.push(pid);
2109
2132
  }
2110
2133
  }
2111
- writeRunningClusterRecord(config.cacheDir, { version: config.version, pids, signatures });
2134
+ if (skipEmpty && pids.length === 0) return 0;
2135
+ writeRunningClusterRecord(config.cacheDir, { version: config.version, pids, signatures, startupFailed });
2136
+ return pids.length;
2112
2137
  }
2113
2138
 
2114
2139
  /**
@@ -2475,13 +2500,15 @@ export async function stopC8Run(config, debug = false) {
2475
2500
  * `--yes` / `-y` are c8ctl GLOBAL flags, so the host consumes them (it sets
2476
2501
  * `ctx.yes`) and strips them from a passthrough command's args. c8run's own
2477
2502
  * `secrets delete` has a `--yes` flag that skips its confirmation prompt, so
2478
- * restore it when the user asked for it. Scoped to `delete` — the only verb
2479
- * documented to take it — so it is never appended to a c8run verb that may
2480
- * not accept the flag. Never mutates `tail`.
2503
+ * restore it when the user asked for it. Tenant removal/reset also require
2504
+ * confirmation. Skip tenant selectors when locating a secrets verb, and never
2505
+ * append confirmation to a verb that does not accept it. Never mutates `tail`.
2481
2506
  */
2482
- export function withForwardedYes(tail, ctx) {
2483
- const verbIndex = tail[0]?.startsWith('--c8-version=') ? 1 : tail[0] === '--c8-version' ? 2 : 0;
2484
- if (ctx?.yes !== true || tail[verbIndex] !== 'delete') return tail;
2507
+ export function withForwardedYes(tail, ctx, command = 'secrets') {
2508
+ const versionEnd = tail[0]?.startsWith('--c8-version=') ? 1 : tail[0] === '--c8-version' ? 2 : 0;
2509
+ const positions = forwardedPositionals(tail, versionEnd, command === 'secrets');
2510
+ const verbs = command === 'tenants' ? ['remove', 'rm', 'reset'] : ['delete'];
2511
+ if (ctx?.yes !== true || !verbs.includes(tail[positions[0]])) return tail;
2485
2512
  // Everything after a `--` terminator is literal for c8run, so the flag goes
2486
2513
  // immediately before it, and a `--yes` that only appears after it does not count.
2487
2514
  const terminator = tail.indexOf('--');
@@ -2504,7 +2531,7 @@ export function withForwardedYes(tail, ctx) {
2504
2531
  * unreleased c8run's verb set (including one c8ctl has never heard of) is
2505
2532
  * still forwarded and its own error surfaces as-is.
2506
2533
  */
2507
- export function parseSecretsArgs(tail) {
2534
+ export function parseSecretsArgs(tail, command = 'secrets') {
2508
2535
  let version = null;
2509
2536
  let passthrough = tail;
2510
2537
 
@@ -2520,14 +2547,14 @@ export function parseSecretsArgs(tail) {
2520
2547
  }
2521
2548
  if (!version || version.startsWith('-')) {
2522
2549
  throw new Error(
2523
- 'Missing value for --c8-version. Example: c8ctl cluster secrets --c8-version 8.10 list',
2550
+ `Missing value for --c8-version. Example: c8ctl cluster ${command} --c8-version 8.10 list`,
2524
2551
  );
2525
2552
  }
2526
2553
  }
2527
2554
 
2528
2555
  if (passthrough.length === 0) {
2529
2556
  throw new Error(
2530
- 'usage: c8ctl cluster secrets [--c8-version <version>] <set|list|path|delete|import|...>',
2557
+ `usage: c8ctl cluster ${command} [--c8-version <version>] <${command === 'tenants' ? 'add|list|remove|reset|path|help|...' : 'set|list|path|delete|import|...'}>`,
2531
2558
  );
2532
2559
  }
2533
2560
 
@@ -2541,30 +2568,55 @@ export function parseSecretsArgs(tail) {
2541
2568
  * C8RUN_SECRETS_DIR would otherwise resolve against the wrong directory and
2542
2569
  * silently miss the file the user meant.
2543
2570
  *
2544
- * Only touches an `import` positional and C8RUN_SECRETS_DIR; every other
2571
+ * Only touches an `import` positional and the local store environment paths; every other
2545
2572
  * verb and flag passes through untouched. "-" (stdin) and already-absolute
2546
2573
  * paths are left alone. Never mutates the passthrough array or env object
2547
2574
  * it receives.
2548
2575
  */
2549
2576
  export function resolveSecretsPaths(passthrough, { cwd = process.cwd(), env = process.env } = {}) {
2550
2577
  let resolvedPassthrough = passthrough;
2578
+ const positions = forwardedPositionals(passthrough, 0, true);
2579
+ const [verbIndex, fileIndex] = positions;
2551
2580
  if (
2552
- passthrough[0] === 'import' &&
2553
- passthrough[1] &&
2554
- passthrough[1] !== '-' &&
2555
- !isAbsolute(passthrough[1])
2581
+ passthrough[verbIndex] === 'import' &&
2582
+ passthrough[fileIndex] &&
2583
+ passthrough[fileIndex] !== '-' &&
2584
+ !isAbsolute(passthrough[fileIndex])
2556
2585
  ) {
2557
2586
  resolvedPassthrough = [...passthrough];
2558
- resolvedPassthrough[1] = resolve(cwd, passthrough[1]);
2587
+ resolvedPassthrough[fileIndex] = resolve(cwd, passthrough[fileIndex]);
2559
2588
  }
2560
2589
 
2561
- let resolvedEnv = env;
2562
- const secretsDir = env.C8RUN_SECRETS_DIR;
2563
- if (secretsDir && !isAbsolute(secretsDir)) {
2564
- resolvedEnv = { ...env, C8RUN_SECRETS_DIR: resolve(cwd, secretsDir) };
2590
+ return { passthrough: resolvedPassthrough, env: resolveLocalStoreEnv(env, cwd) };
2591
+ }
2592
+
2593
+ function forwardedPositionals(args, start, tenantScoped) {
2594
+ const positions = [];
2595
+ for (let i = start; i < args.length; i++) {
2596
+ if (args[i] === '--') break;
2597
+ if (tenantScoped && args[i] === '--tenant') {
2598
+ i++;
2599
+ continue;
2600
+ }
2601
+ if (tenantScoped && args[i].startsWith('--tenant=')) continue;
2602
+ // Unknown options belong to c8run. Do not guess which tokens they consume.
2603
+ positions.push(i);
2565
2604
  }
2605
+ return positions;
2606
+ }
2607
+
2608
+ // Tells c8run which command prefix to print in its hints ("c8ctl cluster tenants list"
2609
+ // instead of "c8run tenants list"); c8run builds without support ignore it.
2610
+ const C8RUN_CLI_NAME = 'c8ctl cluster';
2566
2611
 
2567
- return { passthrough: resolvedPassthrough, env: resolvedEnv };
2612
+ function resolveLocalStoreEnv(env, cwd) {
2613
+ let resolvedEnv = env;
2614
+ for (const name of ['C8RUN_SECRETS_DIR', 'C8RUN_TENANTS_FILE']) {
2615
+ if (env[name] && !isAbsolute(env[name])) {
2616
+ resolvedEnv = { ...resolvedEnv, [name]: resolve(cwd, env[name]) };
2617
+ }
2618
+ }
2619
+ return resolvedEnv;
2568
2620
  }
2569
2621
 
2570
2622
  /**
@@ -2637,6 +2689,15 @@ export function mapSecretsFailure(exitCode, stderrTail, version) {
2637
2689
  * environment).
2638
2690
  */
2639
2691
  export async function runClusterSecrets(
2692
+ cacheDir,
2693
+ tail,
2694
+ options = {},
2695
+ ) {
2696
+ return runClusterLocalCommand('secrets', cacheDir, tail, options);
2697
+ }
2698
+
2699
+ async function runClusterLocalCommand(
2700
+ command,
2640
2701
  cacheDir,
2641
2702
  tail,
2642
2703
  { explicitVersion, spawnFn = spawn, cwd = process.cwd(), env = process.env } = {},
@@ -2646,7 +2707,7 @@ export async function runClusterSecrets(
2646
2707
  const version = await selectSecretsVersion(cacheDir, { explicit: explicitVersion });
2647
2708
  if (!version) {
2648
2709
  logger.error(
2649
- 'No c8run installed locally. Install one first: c8ctl cluster install alpha',
2710
+ `No c8run installed locally. Install one first: c8ctl cluster install ${command === 'tenants' ? '8.10' : 'alpha'}`,
2650
2711
  );
2651
2712
  process.exit(1);
2652
2713
  return;
@@ -2656,18 +2717,20 @@ export async function runClusterSecrets(
2656
2717
  try {
2657
2718
  binaryPath = getC8RunBinaryPath({ cacheDir, version });
2658
2719
  } catch (error) {
2659
- logger.error(`Failed to run secrets command: ${error.message}`);
2720
+ logger.error(`Failed to run ${command} command: ${error.message}`);
2660
2721
  process.exit(1);
2661
2722
  return;
2662
2723
  }
2663
2724
 
2664
- const { passthrough, env: resolvedEnv } = resolveSecretsPaths(tail, { cwd, env });
2725
+ const { passthrough, env: resolvedEnv } = command === 'secrets'
2726
+ ? resolveSecretsPaths(tail, { cwd, env })
2727
+ : { passthrough: tail, env: resolveLocalStoreEnv(env, cwd) };
2665
2728
 
2666
2729
  const exitCode = await new Promise((resolvePromise, reject) => {
2667
- const proc = spawnFn(binaryPath, ['secrets', ...passthrough], {
2730
+ const proc = spawnFn(binaryPath, [command, ...passthrough], {
2668
2731
  stdio: ['inherit', 'inherit', 'pipe'],
2669
2732
  cwd: dirname(binaryPath),
2670
- env: resolvedEnv,
2733
+ env: { ...resolvedEnv, C8RUN_CLI_NAME },
2671
2734
  });
2672
2735
 
2673
2736
  let stderrTail = '';
@@ -2681,7 +2744,11 @@ export async function runClusterSecrets(
2681
2744
  reject(new Error(`Failed to spawn c8run: ${err.message}`));
2682
2745
  });
2683
2746
  proc.on('close', (code) => {
2684
- const hint = mapSecretsFailure(code ?? 1, stderrTail, version);
2747
+ const hint = command === 'secrets'
2748
+ ? mapSecretsFailure(code ?? 1, stderrTail, version)
2749
+ : code !== 0 && /unsupported operation:\s*tenants/i.test(stderrTail)
2750
+ ? `c8run ${version} does not support "tenants" yet. Install a Camunda 8.10+ c8run build containing physical-tenant CLI support with "c8ctl cluster install 8.10"; older cached builds may predate this feature.`
2751
+ : null;
2685
2752
  if (hint) {
2686
2753
  logger.error(hint);
2687
2754
  }
@@ -2740,16 +2807,18 @@ export async function clusterStatus(cacheDir) {
2740
2807
  // Health endpoint not reachable
2741
2808
  }
2742
2809
 
2743
- // A cluster process is alive but not tracked by a marker — typically an
2744
- // orphan left after its install dir was replaced/removed (#560).
2810
+ // Only attribute a failure to survivors of that startup, never to unrelated
2811
+ // pidfiles or a shared health endpoint that happens to respond.
2812
+ const startupFailed = record?.startupFailed === true && liveRecordedPids(cacheDir).length > 0;
2813
+ // A missing marker alone does not explain why processes are still running.
2745
2814
  const untracked = !markerExists && processesRunning;
2746
2815
 
2747
- // `untracked` takes precedence over a healthy probe: an orphaned process can
2748
- // still serve the health endpoint while holding its ports, and the operator
2749
- // must be told it is no longer tracked (and how to recover) rather than shown
2750
- // a plain "running". Healthy connection URLs are still surfaced below.
2816
+ // Startup failure and missing-marker diagnostics take precedence over shared
2817
+ // health: a responding endpoint does not establish readiness of every tenant.
2751
2818
  let status;
2752
- if (untracked) {
2819
+ if (startupFailed) {
2820
+ status = 'running after failed startup';
2821
+ } else if (untracked) {
2753
2822
  status = 'running (untracked)';
2754
2823
  } else if (isHealthy) {
2755
2824
  status = 'running';
@@ -2759,17 +2828,19 @@ export async function clusterStatus(cacheDir) {
2759
2828
  status = 'stopped';
2760
2829
  }
2761
2830
 
2831
+ const recovery = startupFailed
2832
+ ? 'Cluster processes are still running after a failed startup. Review the startup error or c8run logs; a responding shared health endpoint does not mean all tenants are ready. Run c8ctl cluster stop before retrying.'
2833
+ : untracked
2834
+ ? 'Cluster processes are still running without an active c8ctl marker. The startup outcome is unknown. Stop them with: c8ctl cluster stop'
2835
+ : undefined;
2836
+
2762
2837
  if (globalThis.c8ctl?.getLogger().mode === 'json') {
2763
- // Machine-readable status must carry the SAME recovery guidance the text
2764
- // renderer prints below for an orphan, otherwise a `--json` consumer sees
2765
- // `running (untracked)` with no actionable instruction (#560).
2838
+ // Machine-readable status carries the same recovery guidance as text.
2766
2839
  logger.json({
2767
2840
  status,
2768
2841
  version,
2769
2842
  urls: isHealthy ? CLUSTER_URLS : undefined,
2770
- recovery: untracked
2771
- ? 'A cluster process is still running but is no longer tracked by c8ctl (its install directory was likely replaced or removed while running). Stop it with: c8ctl cluster stop'
2772
- : undefined,
2843
+ recovery,
2773
2844
  });
2774
2845
  return;
2775
2846
  }
@@ -2797,12 +2868,10 @@ export async function clusterStatus(cacheDir) {
2797
2868
  console.log(' Default credentials: demo / demo');
2798
2869
  }
2799
2870
 
2800
- if (untracked) {
2801
- // Shown even when the orphan is healthy: it is still not tracked by c8ctl.
2871
+ if (recovery) {
2872
+ // Keep text and JSON diagnostics identical even when shared health is UP.
2802
2873
  console.log('');
2803
- console.log(' A cluster process is still running but is no longer tracked by c8ctl');
2804
- console.log(' (its install directory was likely replaced or removed while running).');
2805
- console.log(' Stop it with: c8ctl cluster stop');
2874
+ console.log(` ${recovery}`);
2806
2875
  } else if (!isHealthy) {
2807
2876
  console.log('');
2808
2877
  console.log(' The cluster appears to have been started but is not yet responding.');
@@ -3169,6 +3238,16 @@ export function parsePluginArgs(args) {
3169
3238
  while (i < args.length) {
3170
3239
  const arg = args[i];
3171
3240
 
3241
+ if (arg === '--physical-tenants' || arg.startsWith('--physical-tenants=')) {
3242
+ const value = arg === '--physical-tenants' ? args[i + 1] : arg.slice('--physical-tenants='.length);
3243
+ if (!value || value.startsWith('-')) throw new Error('--physical-tenants requires comma-separated tenant IDs');
3244
+ result.startArgs ??= [];
3245
+ result.startArgs.push(arg);
3246
+ if (arg === '--physical-tenants') { result.startArgs.push(value); i++; }
3247
+ i++;
3248
+ continue;
3249
+ }
3250
+
3172
3251
  if (arg === '--c8-version') {
3173
3252
  const next = args[i + 1];
3174
3253
  if (!next || next.startsWith('-')) {
@@ -3221,6 +3300,9 @@ export function parsePluginArgs(args) {
3221
3300
  i += 1;
3222
3301
  }
3223
3302
 
3303
+ if (result.startArgs && result.subcommand !== 'start') {
3304
+ throw new Error('--physical-tenants can only be used with the start subcommand');
3305
+ }
3224
3306
  return result;
3225
3307
  }
3226
3308
 
@@ -3237,20 +3319,32 @@ export const commands = {
3237
3319
  'cluster': async (args, _flags, ctx) => {
3238
3320
  const logger = getLogger();
3239
3321
 
3240
- // Secrets passthrough (#314) is intercepted before parsePluginArgs:
3322
+ // Local management passthrough is intercepted before parsePluginArgs:
3241
3323
  // its arguments (verbs, flags, positionals) belong to c8run, not to
3242
3324
  // c8ctl's own version/--debug/--purge parsing.
3243
- if (args[0] === 'secrets') {
3244
- let parsedSecrets;
3325
+ if (args[0] === 'secrets' || args[0] === 'tenants') {
3326
+ const command = args[0];
3327
+ let parsedLocal;
3245
3328
  try {
3246
- parsedSecrets = parseSecretsArgs(withForwardedYes(args.slice(1), ctx));
3329
+ parsedLocal = parseSecretsArgs(withForwardedYes(args.slice(1), ctx, command), command);
3247
3330
  } catch (error) {
3248
3331
  logger.error(error.message);
3249
3332
  process.exit(1);
3250
3333
  return;
3251
3334
  }
3252
- await runClusterSecrets(getCacheDir(), parsedSecrets.passthrough, {
3253
- explicitVersion: parsedSecrets.version,
3335
+ if (ctx?.dryRun) {
3336
+ // Local-only lookup (no download) so the preview shows the c8run that would run.
3337
+ let version = null;
3338
+ try {
3339
+ version = await selectSecretsVersion(getCacheDir(), { explicit: parsedLocal.version });
3340
+ } catch {
3341
+ version = parsedLocal.version;
3342
+ }
3343
+ console.log(JSON.stringify({ dryRun: true, command: `cluster ${command}`, version, args: parsedLocal.passthrough }));
3344
+ return;
3345
+ }
3346
+ await runClusterLocalCommand(command, getCacheDir(), parsedLocal.passthrough, {
3347
+ explicitVersion: parsedLocal.version,
3254
3348
  });
3255
3349
  return;
3256
3350
  }
@@ -3276,6 +3370,7 @@ export const commands = {
3276
3370
  console.log(' c8ctl cluster delete <version>');
3277
3371
  console.log(' c8ctl cluster purge <version>');
3278
3372
  console.log(' c8ctl cluster secrets [--c8-version <version>] <set|list|path|delete|import|...>');
3373
+ console.log(' c8ctl cluster tenants [--c8-version <version>] <add|list|remove|reset|path|help>');
3279
3374
  console.log('');
3280
3375
  console.log('Subcommands:');
3281
3376
  console.log(' start Download (if needed) and start a local Camunda 8 cluster');
@@ -3288,12 +3383,14 @@ export const commands = {
3288
3383
  console.log(' delete Remove a locally cached version to reclaim disk space');
3289
3384
  console.log(' purge Delete runtime data for a version (binary stays intact, next start is fresh)');
3290
3385
  console.log(' secrets Manage local development secrets (forwarded verbatim to c8run)');
3386
+ console.log(' tenants Manage local physical tenants (Camunda 8.10+; forwarded to c8run)');
3291
3387
  console.log('');
3292
3388
  console.log('Options:');
3293
3389
  console.log(' <version> Camunda version, alias, or major.minor (default: stable)');
3294
3390
  console.log(' --c8-version <version> Alternative flag form for version');
3295
3391
  console.log(' --debug Stream raw c8run output during start');
3296
3392
  console.log(' --purge (stop only) also delete runtime data after stopping');
3393
+ console.log(' --physical-tenants <ids> (start only) Extra physical tenants for this run; repeatable');
3297
3394
  console.log('');
3298
3395
  console.log('A <version> can be:');
3299
3396
  console.log(' stable / alpha Named aliases');
@@ -3326,6 +3423,9 @@ export const commands = {
3326
3423
  console.log(' c8ctl cluster secrets list');
3327
3424
  console.log(' c8ctl cluster secrets import .env.secrets');
3328
3425
  console.log(' c8ctl cluster secrets delete OPENAI_API_KEY --yes');
3426
+ console.log(' c8ctl cluster tenants --c8-version 8.10 add sales');
3427
+ console.log(' c8ctl cluster start 8.10 --physical-tenants sales,hr');
3428
+ console.log(' c8ctl cluster secrets --tenant sales set OPENAI_API_KEY');
3329
3429
  console.log('');
3330
3430
  console.log('secrets forwards everything after it to c8run\'s own "secrets" command —');
3331
3431
  console.log('c8ctl never sees or stores a secret value. Run "c8ctl cluster secrets help"');
@@ -3427,6 +3527,14 @@ export const commands = {
3427
3527
  preferLocal: isStart,
3428
3528
  cacheDir: theCacheDir,
3429
3529
  });
3530
+
3531
+ // Dry-run start: report the version a real start would select (same
3532
+ // local-preferred resolution), but skip install and launch.
3533
+ if (ctx?.dryRun && isStart) {
3534
+ console.log(JSON.stringify({ dryRun: true, command: 'cluster start', version, requestedVersion: versionSpec, args: ['start', ...(parsed.startArgs || [])] }));
3535
+ return;
3536
+ }
3537
+
3430
3538
  if (isVersionAlias(versionSpec)) {
3431
3539
  logger.info(`Resolved alias "${versionSpec}" → ${version}`);
3432
3540
  }
@@ -3452,7 +3560,7 @@ export const commands = {
3452
3560
  if (parsed.subcommand === 'start') {
3453
3561
  try {
3454
3562
  await ensureC8RunInstalled(config);
3455
- await startC8Run(config, parsed.debug);
3563
+ await startC8Run(config, parsed.debug, parsed.startArgs);
3456
3564
  } catch (error) {
3457
3565
  logger.error(`Failed to start cluster: ${formatErrorWithCause(error)}`);
3458
3566
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camunda8/cli",
3
- "version": "4.3.0-alpha.2",
3
+ "version": "4.3.0-alpha.4",
4
4
  "description": "Camunda 8 CLI - minimal-dependency CLI for Camunda 8 operations",
5
5
  "type": "module",
6
6
  "engines": {