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.

Merge branch 'main' of https://github.com/autonomous-ai/autonomous-harness

Dev jacob77c39dc98882
diff --cc cli/src/cli.ts
index 15bd3ec18,5f77d5ebc..f5e3cb463
--- a/cli/src/cli.ts
+++ b/cli/src/cli.ts
@@@ -47,9 -47,8 +47,9 @@@ import { warnIfGridSignInRemains } fro
import { ENGINE_CLI_COMMANDS, ENGINES, engineBin } from './lib/engineBin.js'
import type { AgentEngine } from './engines/types.js'
import { engineInstallRecipe } from './lib/engineInstall.js'
- import { buildEngineCommandArgv, buildEngineLaunchArgv, commandAvailableInInteractiveShell, interactiveEngineShell } from './lib/engineLaunch.js'
+ import { buildEngineCommandArgv, buildEngineLaunchArgv, commandAvailableInInteractiveShell } from './lib/engineLaunch.js'
-import { buildGridEngineLaunch, describeGridLaunch, gridConflictingEnvToClear, gridEnvVarNames } from './lib/gridLaunch.js'
+import { buildGridEngineLaunch, describeGridLaunch, gridConflictingEnvToClear, gridEnvVarNames, type GridEngineLaunch } from './lib/gridLaunch.js'
+import { HERMES_SYSTEM_MANAGED_DIR } from './lib/gridWebMcp.js'
import { writeGridConfigDir } from './lib/gridConfigDir.js'
import { tmuxSupportsSessionEnv, TMUX_SESSION_ENV_MIN } from './lib/tmuxVersion.js'
import { clearDeleted, isRecentlyDeleted, markDeleted } from './lib/deletedSessions.js'
@@@ -154,7 -147,7 +148,7 @@@ import
lastCommandCodeTurnText,
} from './engines/commandcode/normalizer.js'
import { probeGatewayRuntime } from './lib/gatewayRuntime.js'
- import { gridAssignmentFromEnv, probeGridAssignment, sameGridAssignment } from './lib/gridAssignment.js'
-import { probeGridAssignment } from './lib/gridAssignment.js'
++import { probeGridAssignment, sameGridAssignment } from './lib/gridAssignment.js'
import { agentFrame, type AgentFrame } from './lib/agentFrame.js'
import { SessionInputController } from './lib/sessionInput.js'
import { adaptSlashCommand } from './lib/goalCommand.js'
@@@ -2309,14 -2305,12 +2306,16 @@@ async function runForeground(session: A
},
onObserved: async (observed, current) => {
const wasDormant = !current.active
+ // Read BEFORE the update, because the update is what overwrites it. `undefined` means the probe
+ // could not look, which never counts as a move — see `probeGridAssignment`'s three answers.
+ const gridMoved = observed.grid !== undefined
+ && !sameGridAssignment(current.grid ?? null, observed.grid)
+ const wasLaunching = current.launch?.state !== undefined && current.launch.state !== 'ready'
registry.updateRuntimes(current.agentId, observed.runtimes, observed.primaryRuntimeKey)
registry.updateProcessIdentity(current.agentId, observed.processIdentity, observed.gateway, observed.grid)
+ if (wasLaunching) registry.setLaunch(current.agentId, { state: 'ready' })
await bindObservedAgent(observed)
- if (wasDormant) {
+ if (wasDormant || wasLaunching) {
const active = registry.byAgent(current.agentId)
if (!active) return
if (active.sessionId && !await attachSession(active)) {
diff --cc cli/src/lib/gridAssignment.ts
index 25dbc9e80,23dc9dece..9e93e56fc
--- a/cli/src/lib/gridAssignment.ts
+++ b/cli/src/lib/gridAssignment.ts
@@@ -214,40 -214,10 +214,39 @@@ export async function probeGridAssignme
): Promise<GridAssignment | null | undefined> {
const processEnv = await readProcessEnv(identity)
if (!processEnv) return undefined
- // The two engines whose provider lives in a file this daemon wrote, rather than in a variable.
- if (engine === 'pi') return await readPiGridAssignment(processEnv, args)
- if (engine === 'opencode') return await readOpencodeGridAssignment(processEnv)
- return classifyGridAssignment(engine, processEnv, args)
+ return await gridAssignmentFromEnv(engine, processEnv, args)
+}
+
+/**
+ * The same classification, over an environment the caller already holds.
+ *
- * Split out for the one window where no readable process exists yet: between `tmux new-session` and
- * the engine's `exec`, the pane belongs to `/bin/zsh`, whose environment macOS will not show to
- * `ps` at all. `tmuxPaneEnvironment` can still say what that pane was given, and this turns it into
- * the same answer by the same rules — including the two engines whose provider lives in a file
- * rather than a variable, which is precisely the part a caller would get wrong on its own.
++ * Split from the read so the RULES live in one place: which variable each engine's endpoint is in,
++ * and the two engines whose provider is in a file rather than a variable at all. That last part is
++ * what a second caller would get wrong on its own, which is the whole reason this is a function and
++ * not a comment.
+ *
+ * There is no `undefined` here: the caller decided it could look, and did. Only [probeGridAssignment]
+ * distinguishes "could not read the process".
+ */
+export async function gridAssignmentFromEnv(
+ engine: AgentEngine,
+ env: Record<string, string>,
+ args = '',
+): Promise<GridAssignment | null> {
+ if (engine === 'pi') return await readPiGridAssignment(env, args)
+ if (engine === 'opencode') return await readOpencodeGridAssignment(env)
+ return classifyGridAssignment(engine, env, args)
+}
+
+/**
+ * Do these two describe the same assignment?
+ *
+ * `undefined` is not compared here and must not reach this: it means the probe could not look, which
+ * is never evidence that anything moved. Callers guard on it before asking.
+ */
+export function sameGridAssignment(a: GridAssignment | null, b: GridAssignment | null): boolean {
+ if (a === null || b === null) return a === b
+ return a.baseUrl === b.baseUrl && (a.model ?? null) === (b.model ?? null)
}
/** Is this agent already where `networkId` is served, on `model`? */