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.

Grid harness: run Codex unsandboxed and know the account's own grid

Timd3c244b4e12e
diff --git a/cli/src/backendSocket.ts b/cli/src/backendSocket.ts
index aff639508..56fadbddb 100644
--- a/cli/src/backendSocket.ts
+++ b/cli/src/backendSocket.ts
@@ -753,6 +753,10 @@ export class BackendSocket {
/** Which grid this machine's agents can be pointed at — for `harness status` and the models RPC. */
gridName(): string | null { return this.harnessGridName }
+ /** The account's private grid, resolved the way the models RPC resolves it — for a harness
+ * workspace that must be told which grid is "yours" rather than work it out or ask. */
+ privateGridName(): Promise<string | null> { return this.resolveGridName() }
+
/**
* The account's private grid: the backend's word when it gave one, else what this machine can
* work out for itself (`lib/gridDerive.ts`). A backend that predates `machine_meta.gridName`
diff --git a/cli/src/cli.ts b/cli/src/cli.ts
index d0c59711f..0c9d40e42 100644
--- a/cli/src/cli.ts
+++ b/cli/src/cli.ts
@@ -72,7 +72,7 @@ import { gridAvailable } from './lib/gridExec.js'
import { ENGINE_CLI_COMMANDS, ENGINES, PROCESS_ENGINES, engineBin, enginePathOverride } from './lib/engineBin.js'
import { isTerminalEngine, type AgentEngine } from './engines/types.js'
import { engineInstallRecipe } from './lib/engineInstall.js'
-import { buildEngineCommandArgv, buildEngineLaunchArgv, commandAvailableInInteractiveShell, commandSupportsFlagInInteractiveShell, namedAgentArgs, permissionModeFlags } from './lib/engineLaunch.js'
+import { buildEngineCommandArgv, buildEngineLaunchArgv, commandAvailableInInteractiveShell, commandSupportsFlagInInteractiveShell, namedAgentArgs, permissionModeApproves, permissionModeFlags } from './lib/engineLaunch.js'
import { workspaceMissing } from './lib/workspaceCheck.js'
import { buildGridEngineLaunch, describeGridLaunch, gridConflictingEnvToClear, gridEnvVarNames, type GridLaunchMachine, type GridWebSearchStatus } from './lib/gridLaunch.js'
import { HERMES_SYSTEM_MANAGED_DIR } from './lib/gridWebMcp.js'
@@ -104,7 +104,7 @@ import { catalogEntry } from './dsh/catalog.js'
import { removeDsh } from './dsh/install.js'
import { preTrustClaudeProject, preTrustCodexProject } from './lib/claudeTrust.js'
import { materializeWorkspace } from './dsh/materialize.js'
-import { dshLaunch } from './dsh/launch.js'
+import { dshLaunch, type DshAccount } from './dsh/launch.js'
import { DshViewerManager } from './dsh/viewer.js'
import { ViewerLedger } from './dsh/viewerLedger.js'
import { DshVerdictWatcher, type DshVerdict } from './dsh/verdict.js'
@@ -4046,7 +4046,7 @@ async function runForeground(session: AuthSession): Promise<void> {
console.warn(`[dsh] ${id} is not installed on this machine · relaunching as its plain base engine`)
return null
}
- return dshLaunch(installed, workspace)
+ return dshLaunch(installed, workspace, { privateGrid: backend.gridName() })
},
}
// Whatever the source (the row itself, or a grid override the desktop just sent), the agent's DSH,
@@ -4398,6 +4398,14 @@ async function runForeground(session: AuthSession): Promise<void> {
} catch {
return { ok: false, error: 'CWD_NOT_FOUND' }
}
+ // A harness can pin its permission mode (`agent.permissionMode`): the Grid harness starts model
+ // servers, which Codex's sandbox would start without a GPU. Pinned before anything reads the mode,
+ // and recorded on the row like a chosen one, so a relaunch keeps it.
+ const pinnedMode = dsh ? installedDsh(dsh)?.manifest.agent?.permissionMode : undefined
+ if (pinnedMode && permissionModeFlags(engine, pinnedMode)) {
+ permissionMode = pinnedMode
+ bypassPermission = permissionModeApproves(pinnedMode)
+ }
// `--approve-for-me` was added after older Codex CLI releases. Refuse the
// incompatible Auto mode before opening a pane, rather than letting Codex
// reject the flag and leaving the person in an unexpected fallback shell.
@@ -4425,6 +4433,8 @@ async function runForeground(session: AuthSession): Promise<void> {
let dshArgs: string[] = []
/** A DSH's own name ("Blender"), which the agent is named after instead of its engine. */
let dshLabel: string | undefined
+ /** What the harness is told about the signed-in account (its private grid), not left to guess. */
+ let dshAccount: DshAccount = {}
if (dsh) {
const installed = installedDsh(dsh)
if (!installed) return { ok: false, error: 'INVALID_DSH', detail: `${dsh} is not installed on this machine` }
@@ -4440,7 +4450,8 @@ async function runForeground(session: AuthSession): Promise<void> {
return { ok: false, error: 'TMUX_TOO_OLD_FOR_DSH', detail }
}
try {
- const materialized = await materializeWorkspace(installed, cwd)
+ dshAccount = { privateGrid: await backend.privateGridName().catch(() => null) }
+ const materialized = await materializeWorkspace(installed, cwd, dshAccount)
for (const warning of materialized.warnings) console.warn(`[dsh] ${dsh} materialize · ${warning}`)
console.log(`[dsh] ${dsh} materialized ${cwd} · created ${materialized.created.length} · kept ${materialized.kept.length}`)
// The template just went in: the folder is the harness's, and Claude Code need not ask.
@@ -4455,7 +4466,7 @@ async function runForeground(session: AuthSession): Promise<void> {
console.warn(`[agent] create ${dsh} refused · ${detail}`)
return { ok: false, error: 'DSH_MATERIALIZE_FAILED', detail }
}
- const launch = dshLaunch(installed, cwd)
+ const launch = dshLaunch(installed, cwd, dshAccount)
dshEnv = launch.env
dshArgs = launch.args
dshLabel = installed.manifest.name
@@ -4617,7 +4628,7 @@ async function runForeground(session: AuthSession): Promise<void> {
if (source.dsh) {
const installed = installedDsh(source.dsh)
if (!installed) return { ok: false, error: 'INVALID_DSH', detail: `${source.dsh} is no longer installed on this machine` }
- const launch = dshLaunch(installed, source.cwd)
+ const launch = dshLaunch(installed, source.cwd, { privateGrid: backend.gridName() })
dshEnv = launch.env
dshArgs = launch.args
dshLabel = installed.manifest.name
diff --git a/cli/src/dsh/launch.ts b/cli/src/dsh/launch.ts
index c5e436aa1..cfa6561d2 100644
--- a/cli/src/dsh/launch.ts
+++ b/cli/src/dsh/launch.ts
@@ -14,12 +14,24 @@ export interface DshLaunch {
args: string[]
}
-export function dshLaunch(dsh: InstalledDsh, workspace: string): DshLaunch {
+/** Facts about the signed-in account a harness is told rather than left to guess or ask. */
+export interface DshAccount {
+ /** The account's private grid — what "my grid" means to the person. */
+ privateGrid?: string | null
+}
+
+/** [account] as `HARNESS_*` variables, for the workspace init and the agent alike. */
+export function dshAccountEnv(account: DshAccount): Record<string, string> {
+ return account.privateGrid ? { HARNESS_PRIVATE_GRID: account.privateGrid } : {}
+}
+
+export function dshLaunch(dsh: InstalledDsh, workspace: string, account: DshAccount = {}): DshLaunch {
const vars = { dsh: dsh.realDir, workspace }
const env: Record<string, string> = {
HARNESS_DSH: dsh.id,
HARNESS_DSH_DIR: dsh.realDir,
HARNESS_WORKSPACE: workspace,
+ ...dshAccountEnv(account),
}
for (const [key, value] of Object.entries(dsh.manifest.agent?.env ?? {})) {
if (key.startsWith('HARNESS_')) continue // ours; a manifest cannot rename itself
diff --git a/cli/src/dsh/manifest.ts b/cli/src/dsh/manifest.ts
index 44e795291..9abdb472c 100644
--- a/cli/src/dsh/manifest.ts
+++ b/cli/src/dsh/manifest.ts
@@ -74,6 +74,12 @@ export const DshManifestSchema = z.strictObject({
skills: z.array(relativePath).max(32).optional(),
env: z.record(z.string().regex(/^[A-Z_][A-Z0-9_]*$/, 'env keys are UPPER_SNAKE'), z.string().max(4096)).optional(),
args: z.array(z.string().max(4096)).max(64).optional(),
+ /**
+ * A permission mode the harness always runs in (`PERMISSION_MODES`), whatever New Harness
+ * picked — for a harness whose job the engine's sandbox cannot do (starting a model server
+ * that needs the GPU). A mode the base engine lacks is ignored.
+ */
+ permissionMode: z.string().regex(/^[A-Za-z]{1,32}$/).optional(),
}).optional(),
toolchain: z.strictObject({
setup: command.optional(),
diff --git a/cli/src/dsh/materialize.ts b/cli/src/dsh/materialize.ts
index c5baef5b9..c35a23269 100644
--- a/cli/src/dsh/materialize.ts
+++ b/cli/src/dsh/materialize.ts
@@ -15,6 +15,7 @@
import { cpSync, existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, readlinkSync, rmSync, statSync, symlinkSync, writeFileSync } from 'node:fs'
import { basename, join, relative } from 'node:path'
import type { InstalledDsh } from './installed.js'
+import { dshAccountEnv, type DshAccount } from './launch.js'
import { dshSkillsDirFor } from './manifest.js'
import { runDshCommand } from './shell.js'
@@ -150,7 +151,7 @@ function dshBaseEngine(dsh: InstalledDsh): NonNullable<InstalledDsh['manifest'][
return dsh.manifest.engine ?? 'claude'
}
-export async function materializeWorkspace(dsh: InstalledDsh, workspace: string): Promise<MaterializeResult> {
+export async function materializeWorkspace(dsh: InstalledDsh, workspace: string, account: DshAccount = {}): Promise<MaterializeResult> {
const result: MaterializeResult = { created: [], kept: [], warnings: [], initLines: [] }
if (dsh.manifest.kind === 'viewer') {
result.warnings.push(`${dsh.id} is a viewer package; it has no workspace to lay out`)
@@ -168,7 +169,7 @@ export async function materializeWorkspace(dsh: InstalledDsh, workspace: string)
// install directory first; anything else is a shell line and runs as written.
const init = await runDshCommand(resolveDshCommand(dsh, ws.init), {
cwd: workspace,
- env: { HARNESS_DSH: dsh.id, HARNESS_DSH_DIR: dsh.realDir, HARNESS_WORKSPACE: workspace },
+ env: { HARNESS_DSH: dsh.id, HARNESS_DSH_DIR: dsh.realDir, HARNESS_WORKSPACE: workspace, ...dshAccountEnv(account) },
onLine: (line) => result.initLines.push(line),
timeoutMs: 5 * 60_000,
})
diff --git a/store/agents/autonomous-grid/AGENTS.md b/store/agents/autonomous-grid/AGENTS.md
index d670c4279..173271759 100644
--- a/store/agents/autonomous-grid/AGENTS.md
+++ b/store/agents/autonomous-grid/AGENTS.md
@@ -32,16 +32,21 @@ the conversation; do not build another chat UI or run a second background agent.
At the start of a fleet task, inspect `grid-fleet.json` and run `"$GRID_FLEET" status`. This reads the
viewer's published observations without network access. For questions about running models and
machines, use a fresh, live snapshot and its observation time; do not start a second network poll.
-Downloaded files and catalog entries are not proof of serving models. A fresh workspace connects to
-the user's **own private grid** (the skill says how it is recognised); if none is found and several
-grids are reachable, ask which one with the question tool — never pick for them and never assume
-one named `home`. Add `--remember` when the user wants that fleet reused by future Grid workspaces.
-
-`refresh`, `connect`, machine discovery and most `run` commands need network access. In a restricted
-agent sandbox, request the normal scoped network approval before those commands. An EPERM/network
-denial is a permission boundary, not proof that a machine or model is offline. Do not disable the
-sandbox or change global permissions. If the viewer observation is stale, obtain an approved live
-refresh before reporting current health. If there is no grid yet, inventory the machine and explain
+Downloaded files and catalog entries are not proof of serving models. The user's own grid is
+`personalGrid` in `grid-fleet.json`, named by Harness from the signed-in account: "my grid" means
+that exact name, never asked for. Which grid to use otherwise: `grid`, the workspace's selected
+fleet; never assume one named `home`. Add `--remember` when the user wants that fleet reused by future Grid workspaces.
+
+**This harness runs without Codex's sandbox**, the way a terminal does: `join` starts an engine
+with the GPU, and every Grid command reaches the network. So run fleet commands directly
+(`"$GRID_FLEET" run -- …`) — never request escalation, and never treat a failure as a sandbox
+problem. Every fleet operation goes through the runner or `$GRID_CLI`: never `ps`, `pgrep`, `lsof`,
+`sysctl`, `kill`, llama logs or hand-written scripts to start, stop, inspect or diagnose an engine;
+the command's own output is the evidence.
+
+**Two failed attempts at the same step is the limit.** Report what failed in one line, with the
+command's own error, and wait — never improvise a workaround. If the viewer observation is stale,
+run `"$GRID_FLEET" refresh` before reporting current health. If there is no grid yet, inventory the machine and explain
the smallest useful first deployment. When deployment is requested, perform it and test it; a plan
alone is not completion. Continue through a failed model load to diagnosis or rollback, preserving
other workloads.
diff --git a/store/agents/autonomous-grid/harness.json b/store/agents/autonomous-grid/harness.json
index 08f6a4faf..ec43d689d 100644
--- a/store/agents/autonomous-grid/harness.json
+++ b/store/agents/autonomous-grid/harness.json
@@ -18,7 +18,8 @@
"GRID_CLI": "${dsh}/toolchain/grid.sh",
"GRID_FLEET": "${dsh}/toolchain/fleet",
"GRID_NO_UPDATE_CHECK": "1"
- }
+ },
+ "permissionMode": "full"
},
"toolchain": {
"setup": "toolchain/setup.sh",
diff --git a/store/agents/autonomous-grid/lib/connect.mjs b/store/agents/autonomous-grid/lib/connect.mjs
index 99d791d57..c14a54cde 100644
--- a/store/agents/autonomous-grid/lib/connect.mjs
+++ b/store/agents/autonomous-grid/lib/connect.mjs
@@ -52,7 +52,7 @@ export function mergeMachines(config, found) {
}
/** Resolve a fresh workspace without changing Grid's global mode/default or starting a service. */
-export async function initializeWorkspace(workspace, { runJson = gridJson, select = gridSelect, discover = discoverMachines, profilePath = defaultsPath(), email = signedInEmail } = {}) {
+export async function initializeWorkspace(workspace, { runJson = gridJson, select = gridSelect, discover = discoverMachines, profilePath = defaultsPath(), email = signedInEmail, env = process.env } = {}) {
let config = await readConfig(workspace), source = 'workspace', message = '', candidates = [];
const controller = () => config.machines.find(m => m.id === config.controller);
const read = (mode, args) => runJson(controller(), mode, args, { timeoutMs: 5000 }).catch(() => ({ ok: false }));
@@ -79,7 +79,11 @@ export async function initializeWorkspace(workspace, { runJson = gridJson, selec
if (engines.ok && Array.isArray(engines.value)) { config.grid = active; source = 'Grid selection'; }
}
const remote = listings.find(l => l.mode === 'remote')?.result;
- const own = config.grid ? null : pickPrivateGrid(await email(), remote?.value);
+ // Harness names the account's grid (HARNESS_PRIVATE_GRID, from the backend that minted it);
+ // the name rule is the fallback for a daemon that predates it. Recorded either way, so the
+ // agent reads "my grid" from grid-fleet.json instead of working it out or asking.
+ config.personalGrid = env.HARNESS_PRIVATE_GRID?.trim() || pickPrivateGrid(await email(), remote?.value);
+ const own = config.grid ? null : config.personalGrid;
if (own) {
const engines = await read('remote', ['engines', own]);
if (engines.ok && Array.isArray(engines.value)) {
@@ -106,6 +110,8 @@ export async function initializeWorkspace(workspace, { runJson = gridJson, selec
if (config.grid) message = `Connected this workspace to ${config.mode} grid ${config.grid}.`;
}
}
+ // A remembered or already-selected fleet skipped the lookup above; the account's grid is still recorded.
+ if (!config.personalGrid && env.HARNESS_PRIVATE_GRID?.trim()) config.personalGrid = env.HARNESS_PRIVATE_GRID.trim();
config = mergeMachines(config, await discover().catch(() => []));
await atomicJson(join(workspace,'grid-fleet.json'),config);
const connection = { source, mode:config.mode, grid:config.grid, message, candidates, observedAt:now() };
diff --git a/store/agents/autonomous-grid/lib/fleet.mjs b/store/agents/autonomous-grid/lib/fleet.mjs
index fafde3230..a276da9ab 100644
--- a/store/agents/autonomous-grid/lib/fleet.mjs
+++ b/store/agents/autonomous-grid/lib/fleet.mjs
@@ -51,7 +51,9 @@ export function validateConfig(raw) {
// The controller is explicit, so editing the order of an inventory cannot redirect fleet reads.
const controller = raw.controller || machines.find(m => m.transport === 'local')?.id || machines[0].id;
if (!ids.has(controller)) throw new Error('controller must name a configured machine.');
- return { spec: 1, mode: raw.mode, grid: raw.grid, controller, machines, preferences: { goal: text(raw.preferences?.goal, 500) || DEFAULT_CONFIG.preferences.goal, keepFreeMemoryGb: number(raw.preferences?.keepFreeMemoryGb) ?? 4, allowAutomaticChanges: raw.preferences?.allowAutomaticChanges === true } };
+ // The account's own grid, as Harness named it — what "my grid" means. Recorded, never chosen here.
+ const personalGrid = typeof raw.personalGrid === 'string' && /^[A-Za-z0-9][A-Za-z0-9._-]{0,239}$/.test(raw.personalGrid) ? raw.personalGrid : null;
+ return { spec: 1, mode: raw.mode, grid: raw.grid, personalGrid, controller, machines, preferences: { goal: text(raw.preferences?.goal, 500) || DEFAULT_CONFIG.preferences.goal, keepFreeMemoryGb: number(raw.preferences?.keepFreeMemoryGb) ?? 4, allowAutomaticChanges: raw.preferences?.allowAutomaticChanges === true } };
}
export async function readConfig(workspace) { return validateConfig(await readJson(join(workspace, 'grid-fleet.json'), DEFAULT_CONFIG)); }
diff --git a/store/agents/autonomous-grid/skills/grid-operations/SKILL.md b/store/agents/autonomous-grid/skills/grid-operations/SKILL.md
index 59e024fba..5aa2d611e 100644
--- a/store/agents/autonomous-grid/skills/grid-operations/SKILL.md
+++ b/store/agents/autonomous-grid/skills/grid-operations/SKILL.md
@@ -12,11 +12,10 @@ observations to answer ordinary inventory questions. A downloaded weight file or
is not a serving model. The viewer reads actual CLI data, and the
runner records operation start/completion without recording prompts, credentials or full argv.
-In a restricted agent sandbox, `refresh`, `connect`, `discover` and network-using `run` commands
-require the engine's normal scoped network approval. Request it before calling them rather than
-repeating commands that fail with EPERM. This also applies to the loopback Harness bridge. Do not
-disable the sandbox or broaden global permissions. A denied network call does not prove a host is
-offline; use fresh viewer observations or an approved live check.
+This harness runs without Codex's sandbox, so these commands run as they would in a terminal —
+`join` gets the GPU, every call reaches the network. Never request escalation, and never read a
+failure as a sandbox problem: the command's own error is the answer. Never diagnose an engine with
+`ps`, `lsof`, `sysctl` or logs; report the error after two failed attempts and wait.
## Targets and access
@@ -32,7 +31,20 @@ non-alphanumerics → `-`, trimmed), then `-` and eight hex, of type `permission
one row of `ls --json` matches — and selects it, so the CLI agrees from the first minute. A person
who asks to "switch to", "use" or "work on" another grid they are in (`ls`) gets `connect` with
that name: it verifies the grid answers, then selects it. Pass the selected grid to every command
-that takes one. With no private grid and several reachable, ask which with the question tool.
+that takes one. **Shared grids** are every other row of `"$GRID_FLEET" run -- ls --json` — a
+company's, a team's, a community one. A request that names one ("on the team grid", "on the
+company grid") goes to that row's exact `grid` name; a request that names none goes to `grid` in
+`grid-fleet.json`. Read the names from `ls`, never from memory.
+
+**"My grid", "my personal grid", "my private grid" all mean `personalGrid` in `grid-fleet.json`**
+(also `$HARNESS_PRIVATE_GRID`). Harness put it there from the account that is signed in, so it is
+the answer, not a guess: pass that exact name to `join`, `leave`, `engines` and `models`, and do not
+ask the person which grid is theirs. It can differ from `grid` (the workspace's selected fleet) —
+a request that says "my grid" goes to `personalGrid`, whatever is selected. The `type` column of
+`ls --json` is what kind of grid a row is, not a permission to ask about: `permissioned-public` is
+a person's own grid, `private-domain` a company's, `domain-restricted` a team's, `os-community` a
+public one. Only when `personalGrid` is null: say in one line that Harness has not named this
+account's grid yet and ask them to sign in to Harness — never pick one from `ls`.
Connect with
`"$GRID_FLEET" connect --mode remote --grid NAME --remember` to select a verified grid and reuse it
in future workspaces. `--remember` writes this controller's `~/.harness/grid-fleet/default.json`;