Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix: refuse a below-floor staged Bun in in-agent setup

garrytan54dc9b0f6dfe
diff --git a/skills/migrations/v0.60.467.0.md b/skills/migrations/v0.60.467.0.md
index 76c1cc7570..f3911e235f 100644
--- a/skills/migrations/v0.60.467.0.md
+++ b/skills/migrations/v0.60.467.0.md
@@ -54,7 +54,12 @@ so ask before running `bun upgrade` on their behalf.
`gbrain bootstrap cloud-setup-script` may keep a Bun 1.4.0 to 1.4.3 (that
script accepted any Bun 1.4.0 or newer): paste
the current script (`gbrain bootstrap cloud-setup-script`) into the
- environment's setup script again.
+ environment's setup script again. An in-agent install (Grok Bot, Muse)
+ upgrades with a freshly fetched helper: a `bin/gbrain-setup` written
+ before v0.60.379.0 stages Bun 1.4.3, and setup then stops with
+ `runtime_below_floor` without changing the install. Fetch the current
+ `setup-in-agent.sh` (see `docs/guides/in-agent-setup.md`) and run it with
+ `--upgrade`.
5. **Verify.**
```bash
diff --git a/skills/skills.lock.json b/skills/skills.lock.json
index cc6a9ce8be..394f4ad094 100644
--- a/skills/skills.lock.json
+++ b/skills/skills.lock.json
@@ -170,7 +170,7 @@
"migrations/v0.60.37.0.md": "e0e9d8ab0adb14cfb55d67f821614f25e0ab2f6281a1a1bfc10faefc95312015",
"migrations/v0.60.44.0.md": "415d05b4587e49c7bdad40b55878b0b50f5330915a5e49065638fb6680ced3fe",
"migrations/v0.60.45.0.md": "ed92f7b642f1e84e6381ef9e7e855db1ac7d20abd9b79a7bb359c707a04b8b9d",
- "migrations/v0.60.467.0.md": "ad441a41d713481bf5d3dc85907cb32e49cd4f428d78da4b81260e5c31216d97",
+ "migrations/v0.60.467.0.md": "0e7b362ff68e320dfa782fcc53a476a9ad0a6d24ea124387825d6f041b332f11",
"migrations/v0.60.47.0.md": "91a6015e3b85c6f2c8048680ee5873895ae2b1948bad8ba6cebce679c3ec7085",
"migrations/v0.60.5.0.md": "0d3ee19359a2740de08ac9ec388ddc15e7c72d663afe33832e1e54170528acab",
"migrations/v0.60.52.0.md": "ae49b2f51ba6288e4883d8bfda9f494f821e160e227164aa065a645d4e9ae87b",
diff --git a/src/core/agent-install/entry.ts b/src/core/agent-install/entry.ts
index 35d032b140..8cf993c52a 100644
--- a/src/core/agent-install/entry.ts
+++ b/src/core/agent-install/entry.ts
@@ -2,8 +2,9 @@ import { setupInAgent, type AgentSetupOptions } from './setup.ts';
import { AgentInstallError } from './state.ts';
import { BootstrapError } from '../bootstrap/lock.ts';
import { PgliteBusyError } from '../pglite-lock.ts';
+import { MINIMUM_BUN_VERSION, bunVersionMeets } from '../runtime-version.ts';
-export async function runAgentSetupCli(args: string[]): Promise<number> {
+export async function runAgentSetupCli(args: string[], bunVersion = Bun.version): Promise<number> {
const json = args.includes('--json');
if (args.includes('--help') || args.includes('-h')) {
console.log('setup-in-agent.sh --root ABS --harness grok-bot|muse [--adopt] [--upgrade] [--skills follow|memory-only] [--json]\nFresh installs follow the shared catalog with manual native loading; existing/adopted roots need explicit approval. Existing memory is never reset.');
@@ -19,6 +20,7 @@ export async function runAgentSetupCli(args: string[]): Promise<number> {
values[args[i]] = args[++i];
}
if (!values['--root'] || !values['--harness'] || !values['--bundle'] || !values['--source-ref']) throw new AgentInstallError('usage', 'Use the package-shipped setup-in-agent.sh helper with an absolute --root and --harness.');
+ if (!bunVersionMeets(bunVersion, MINIMUM_BUN_VERSION)) throw new AgentInstallError('runtime_below_floor', `This GBrain release needs Bun ${MINIMUM_BUN_VERSION} or newer, but the setup helper staged Bun ${bunVersion}. Nothing was changed. Fetch the current helper from https://raw.githubusercontent.com/garrytan/gbrain/latest-stable/scripts/setup-in-agent.sh and rerun it with --upgrade.`);
const result = await setupInAgent({ root: values['--root'], harness: values['--harness'] as AgentSetupOptions['harness'], bundle: values['--bundle'], sourceRef: values['--source-ref'], adopt: args.includes('--adopt'), upgrade: args.includes('--upgrade'), skills: values['--skills'] as AgentSetupOptions['skills'] });
if (json) console.log(JSON.stringify({ ok: true, ...result }));
else console.log(`${result.status}: ${result.launcher}\nInstructions: ${result.instructions}\nMaintenance: ${result.maintenance}\nShared skills: ${result.shared_skills.status} (${result.shared_skills.reason}). ${result.shared_skills.next_action}\nNative harness integration is unverified; enable the skill and test a new conversation.${result.search_mode_confirmation_required ? '\nRelay the init search-mode matrix and confirm the user’s choice before optional provider setup.' : ''}`);
diff --git a/test/agent-install-bun-floor.test.ts b/test/agent-install-bun-floor.test.ts
new file mode 100644
index 0000000000..d0ed12cda7
--- /dev/null
+++ b/test/agent-install-bun-floor.test.ts
@@ -0,0 +1,31 @@
+/**
+ * An in-agent helper written before Bun 1.4.4 became the floor stages Bun 1.4.3
+ * for --upgrade. The new package's setup entry must refuse that runtime before
+ * it commits an artifact the CLI then refuses to start (#7674).
+ */
+import { afterEach, expect, spyOn, test } from 'bun:test';
+import { existsSync, mkdtempSync, readdirSync, rmSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+import { runAgentSetupCli } from '../src/core/agent-install/entry.ts';
+import { MINIMUM_BUN_VERSION } from '../src/core/runtime-version.ts';
+
+const roots: string[] = [];
+afterEach(() => { for (const root of roots.splice(0)) rmSync(root, { recursive: true, force: true }); });
+
+test('setup refuses a staged Bun below the floor before touching the install root', async () => {
+ const root = mkdtempSync(join(tmpdir(), 'gbrain-agent-floor-'));
+ roots.push(root);
+ const calls: string[] = [];
+ const output = spyOn(console, 'log').mockImplementation((line: string) => { calls.push(line); });
+ try {
+ const args = ['--root', root, '--harness', 'grok-bot', '--bundle', join(root, 'bundle'), '--source-ref', 'a'.repeat(40), '--json'];
+ expect(await runAgentSetupCli(args, '1.4.3')).toBe(1);
+ } finally { output.mockRestore(); }
+ const result = JSON.parse(calls.pop()!);
+ expect(result).toMatchObject({ ok: false, reason: 'runtime_below_floor' });
+ expect(result.message).toContain(`needs Bun ${MINIMUM_BUN_VERSION} or newer, but the setup helper staged Bun 1.4.3`);
+ expect(result.message).toContain('--upgrade');
+ expect(readdirSync(root)).toEqual([]);
+ expect(existsSync(join(root, '.gbrain'))).toBe(false);
+});