Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

desktop: reinstall a Harness CLI older than the app's minimum

bubu-dudu542befb51d4f
diff --git a/desktop/lib/bootstrap/environment_provisioner.dart b/desktop/lib/bootstrap/environment_provisioner.dart
index bcb3e1954..88675d8b0 100644
--- a/desktop/lib/bootstrap/environment_provisioner.dart
+++ b/desktop/lib/bootstrap/environment_provisioner.dart
@@ -6,6 +6,7 @@ import 'dart:io';
import 'dart:typed_data';
import '../core/harness_cli_runner.dart';
+import '../update/desktop_updater.dart' show semverGt;
/// The CLI-only installer contract for callers that already own host setup.
/// Desktop verifies tmux, the active Linux clipboard helper and the rest of
@@ -26,6 +27,11 @@ const String kHarnessHostSetupCommand =
const int _linuxClockSyncFailureExitCode = 31;
const int _linuxAptUpdateFailureExitCode = 32;
+
+/// The oldest Harness CLI this app runs against: 0.2.48 is the first that
+/// starts its daemon for this computer without a sign-in, which the app's
+/// first run relies on. Raise it when the app starts needing a newer daemon.
+const kMinimumHarnessCliVersion = '0.2.48';
const int _linuxAptInstallFailureExitCode = 33;
const String _linuxClockRepairCommand =
'if command -v chronyc >/dev/null 2>&1; then '
@@ -481,9 +487,14 @@ class EnvironmentProvisioner {
: EnvironmentStepStatus.failed,
message: probe.harnessRuns
? 'Harness CLI and managed Node are ready.'
+ : _harnessOutdated != null
+ ? 'Harness CLI $_harnessOutdated is out of date; this app needs '
+ '$kMinimumHarnessCliVersion or newer.'
: 'Harness CLI or its managed Node runtime is missing.',
output: probe.harnessRuns
? '✓ managed Node >= 20 · harness version'
+ : _harnessOutdated != null
+ ? '✗ harness $_harnessOutdated < $kMinimumHarnessCliVersion'
: '✗ managed Node >= 20 · harness version',
plan: probe.plan,
);
@@ -1274,7 +1285,12 @@ fi''';
return 'sudo apt-get install -y $names';
}
+ /// The installed CLI's version when [_hasHarness] turned it down as older
+ /// than [kMinimumHarnessCliVersion]; null otherwise.
+ String? _harnessOutdated;
+
Future<bool> _hasHarness() async {
+ _harnessOutdated = null;
final currentNode = File('${harnessHome.path}/runtime/current-node');
if (!await currentNode.exists()) return false;
final nodePath = (await currentNode.readAsString()).trim();
@@ -1297,7 +1313,20 @@ fi''';
cli.path,
'version',
]);
- return version.exitCode == 0;
+ if (version.exitCode != 0) return false;
+ // A CLI that runs is not enough: one from before the app's minimum
+ // refuses `harness start` without a sign-in, and it only self-updates
+ // from a running daemon — so it would never get past that on its own.
+ // Treated as missing, the installer lays the current one over it. An
+ // unparseable version (a local development build) is left alone.
+ final installed = '${version.stdout}'.trim().replaceFirst(
+ RegExp('^v'),
+ '',
+ );
+ _harnessOutdated = semverGt(kMinimumHarnessCliVersion, installed)
+ ? installed
+ : null;
+ return _harnessOutdated == null;
} on ProcessException {
return false;
} on StateError {