MCPcopy Index your code
hub / github.com/TanStack/ai / resolveHarness

Function resolveHarness

examples/sandbox-cloudflare/src/agent.ts:190–208  ·  view source on GitHub ↗

* Resolve the active harness for a run. A per-run `metadata.harness` (chosen in * the UI and forwarded through the trigger) wins; otherwise the deploy default * `env.HARNESS`; otherwise `claude-code`. Throws on an unknown value.

(input: StartRunInput, env: AppEnv)

Source from the content-addressed store, hash-verified

188 * `env.HARNESS`; otherwise `claude-code`. Throws on an unknown value.
189 */
190function resolveHarness(input: StartRunInput, env: AppEnv): HarnessName {
191 const override = input.metadata?.harness
192 if (override !== undefined) {
193 if (!isHarness(override)) {
194 throw new Error(
195 `Unknown harness "${String(override)}". Use claude-code | codex | grok.`,
196 )
197 }
198 return override
199 }
200 const fromEnv = env.HARNESS
201 if (fromEnv === undefined || fromEnv === '') return 'claude-code'
202 if (!isHarness(fromEnv)) {
203 throw new Error(
204 `Unknown HARNESS "${fromEnv}". Set it to claude-code | codex | grok.`,
205 )
206 }
207 return fromEnv
208}
209
210/**
211 * The demo host tool: the canonical recipe for scaffolding a **self-contained**

Callers 1

agent.tsFile · 0.85

Calls 1

isHarnessFunction · 0.90

Tested by

no test coverage detected