II.
Page JSON
Structured · livepage:docs-agent-mux-tutorials-mock-harness
Mock Harness json
Inspect the normalized record payload exactly as the atlas UI reads it.
{
"id": "page:docs-agent-mux-tutorials-mock-harness",
"_kind": "Page",
"_file": "wiki/docs/agent-mux/tutorials/mock-harness.md",
"_cluster": "wiki",
"attributes": {
"nodeKind": "Page",
"sourcePath": "docs/agent-mux/tutorials/mock-harness.md",
"sourceKind": "repo-docs",
"title": "Mock Harness",
"displayName": "Mock Harness",
"slug": "docs/agent-mux/tutorials/mock-harness",
"articlePath": "wiki/docs/agent-mux/tutorials/mock-harness.md",
"article": "\n# Mock Harness\n\nThe mock harness replaces the real CLI spawn with a scripted event stream. Use it for tests, CI, and demos where real credentials or network access are undesirable.\n\n## Enabling\n\nTwo equivalent switches:\n\n```bash\namux run claude --use-mock-harness --prompt \"test\"\n```\n\nor globally:\n\n```bash\nexport USE_MOCK_HARNESS=1\namux run claude --prompt \"test\"\n```\n\nProgrammatically:\n\n```ts\nawait client.run({\n agent: 'claude',\n prompt: 'test',\n useMockHarness: true,\n});\n```\n\n## Scenarios\n\nThe mock emits a deterministic sequence of `AgentEvent`s chosen by scenario name:\n\n| Scenario | What it emits |\n| ----------------- | ----------------------------------------------------------- |\n| `text` | A few `text_delta` events and a final `done`. |\n| `tool-call` | `text_delta` → `tool_call_start` → `tool_call_result` → `done`. |\n| `thinking` | `thinking_delta` events before the final message. |\n| `error` | Emits an `error` event with `recoverable: false`. |\n| `session-resume` | Replays a prior session snapshot. |\n\nPick one with `--scenario`:\n\n```bash\namux run claude --use-mock-harness --scenario tool-call --prompt \"x\"\n```\n\nIf you invoke the package binary directly, the same agent scoping is available\nthere too:\n\n```bash\nmock-harness --agent claude --list\nmock-harness --agent claude --scenario tool-call\n```\n\nInteractive approval scenarios under `packages/agent-mux/harness-mock` now model real gating semantics rather than timer-only replay:\n\n- `interactive:yolo` auto-approves and then emits the post-approval output.\n- `interactive:prompt` waits for stdin before it emits the post-approval output and exits.\n- `interactive:deny` auto-denies, emits the denial path, and exits non-zero.\n- `interactive:timeout` waits for approval until the configured timeout, emits a timeout error, and exits non-zero.\n\n## Why use it\n\n- **CI**: No API keys, no flakiness.\n- **Adapter tests**: Validate `parseEvent` without invoking the real CLI.\n- **Integration tests**: Exercise hooks, session-save paths, and the event stream in isolation.\n\nSee [Harness & Mock](../reference/14-harness-mock.md) for the full event script format.\n",
"documents": []
},
"outgoingEdges": [],
"incomingEdges": [
{
"from": "page:docs-agent-mux-tutorials",
"to": "page:docs-agent-mux-tutorials-mock-harness",
"kind": "contains_page"
}
]
}