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: pin its permission mode where older CLIs accept it (#272)

lingrde4b4e36de9a7
diff --git a/cli/src/cli.ts b/cli/src/cli.ts
index d60a0404f..765b7fbfd 100644
--- a/cli/src/cli.ts
+++ b/cli/src/cli.ts
@@ -100,7 +100,7 @@ import { prepareCodexResume } from './engines/codex/portableHistory.js'
import { buildHarnessSessionLabel } from './lib/harnessSessionLabel.js'
import { adoptLegacyHarnessSessions, listTmuxPanes } from './lib/tmuxAgentDiscovery.js'
import { installedDsh } from './dsh/installed.js'
-import { dshVerdictPath, dshViewerName } from './dsh/manifest.js'
+import { dshPinnedPermissionMode, dshVerdictPath, dshViewerName } from './dsh/manifest.js'
import { catalogEntry } from './dsh/catalog.js'
import { removeDsh } from './dsh/install.js'
import { preTrustClaudeProject, preTrustCodexProject } from './lib/claudeTrust.js'
@@ -4518,10 +4518,11 @@ async function runForeground(session: AuthSession | null): Promise<void> {
} catch {
return { ok: false, error: 'CWD_NOT_FOUND' }
}
- // A harness can pin its permission mode (`agent.permissionMode`): the Grid harness starts model
+ // A harness can pin its permission mode (`dshPinnedPermissionMode`): 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
+ const pinnedDsh = dsh ? installedDsh(dsh) : null
+ const pinnedMode = pinnedDsh ? dshPinnedPermissionMode(pinnedDsh.manifest) : null
if (pinnedMode && permissionModeFlags(engine, pinnedMode)) {
permissionMode = pinnedMode
bypassPermission = permissionModeApproves(pinnedMode)
diff --git a/cli/src/dsh/manifest.ts b/cli/src/dsh/manifest.ts
index 9abdb472c..c816f41f1 100644
--- a/cli/src/dsh/manifest.ts
+++ b/cli/src/dsh/manifest.ts
@@ -74,12 +74,6 @@ 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(),
@@ -131,6 +125,22 @@ export function dshEngine(manifest: DshManifest): DshManifest['engine'] | null {
return manifest.engine ?? null
}
+/**
+ * The `agent.env` key a harness names its permission mode in (`PERMISSION_MODES`), run whatever New
+ * Harness picked — for a harness whose job the engine's sandbox cannot do (Grid starts model servers
+ * that need the GPU).
+ *
+ * An env key rather than a manifest field on purpose: every released CLI parses `agent` strictly, so
+ * a new field made older daemons refuse the whole package, and Get failed until they updated. Every
+ * CLI already accepts an `agent.env` key; an older one only exports it, unused.
+ */
+export const DSH_PERMISSION_MODE_ENV = 'DSH_PERMISSION_MODE'
+
+/** The permission mode [manifest] pins, or null. */
+export function dshPinnedPermissionMode(manifest: DshManifest): string | null {
+ return manifest.agent?.env?.[DSH_PERMISSION_MODE_ENV]?.trim() || null
+}
+
export type ManifestResult =
| { ok: true; manifest: DshManifest }
| { ok: false; error: string }
diff --git a/store/agents/autonomous-grid/harness.json b/store/agents/autonomous-grid/harness.json
index ec43d689d..0c3c5ebc3 100644
--- a/store/agents/autonomous-grid/harness.json
+++ b/store/agents/autonomous-grid/harness.json
@@ -17,9 +17,9 @@
"env": {
"GRID_CLI": "${dsh}/toolchain/grid.sh",
"GRID_FLEET": "${dsh}/toolchain/fleet",
- "GRID_NO_UPDATE_CHECK": "1"
- },
- "permissionMode": "full"
+ "GRID_NO_UPDATE_CHECK": "1",
+ "DSH_PERMISSION_MODE": "full"
+ }
},
"toolchain": {
"setup": "toolchain/setup.sh",