Commit cf0557e
feat: structured logging across harness + engines + substrates (Wedge 1.9)
Every lifecycle step of every harness and every substrate now emits one
structured log line to stderr, configurable by env:
COMPUTERAGENT_LOG=debug|info|warn|error|silent (default: info)
COMPUTERAGENT_LOG_FORMAT=pretty|json (default: auto by TTY)
What you see at info:
substrate.local.boot, harness.boot, harness.ready, session.create,
session.start, engine.start, session.end, engine.turn.end,
substrate.local.dispose
What you additionally see at debug:
http.request (every REST hit), engine.tool_use, engine.tool_result,
engine.assistant_text, engine.usage, fs.read/write/edit/delete, etc.
Architecture (per Wedge 1.9 in the plan):
- Tiny ~80 LOC zero-dep `Logger` in @computeragent/protocol.
Stable interface; pino can replace the implementation later.
- Additive `logger?: Logger` on `EngineContext`, `ServerDeps`, and
`CreateHarnessServerOptions`. `nopLogger` is the default.
- Engines (claude-agent-sdk, gitagent, deepagents): one log call per
tool_use, tool_result, assistant_text, usage_snapshot; plus start +
turn.end + error.
- Harness server: per-route http.request logs; create-session,
run-session, permission_request, permission_decision, cancel,
http.error.
- Substrates (local, e2b, vzvm): boot, harness.ready, dispose, plus
per-runtime steps (upload, install, vm.clone, port_forward).
- SDK `new ComputerAgent({ debug: true })`: forces
COMPUTERAGENT_LOG=debug in the spawned harness env AND emits a
one-line client-side summary per HarnessEvent consumed.
- LocalSubstrate (and E2B/VZVM) defaults onLog to relay child stderr
to parent stderr verbatim, so harness-side structured logs surface
in the parent terminal without extra wiring.
Bundle size: +20KB across all three substrate bundles (1.0M of which
is the engine code + 80 LOC logger). Acceptable.
Known limitation: on sub-second `agent.dispose()` flows, the very last
1-2 engine + session.end lines may be truncated by the stderr flush
race when the harness child is SIGTERM'd. A 250ms drain in
killProcess covers most cases; not all. Doesn't affect real-length
agent runs.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent 9d9b249 commit cf0557e
33 files changed
Lines changed: 2472 additions & 729 deletions
File tree
- packages
- engine-claude-agent-sdk/src
- engine-deepagents/src
- engine-gitagent/src
- harness-server/src
- routes
- services
- protocol/src
- runtime-e2b
- assets
- src
- runtime-local
- assets
- src
- runtime-vzvm
- assets
- src
- sdk/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
42 | 52 | | |
43 | 53 | | |
44 | 54 | | |
| |||
93 | 103 | | |
94 | 104 | | |
95 | 105 | | |
96 | | - | |
97 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
98 | 109 | | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
| 110 | + | |
107 | 111 | | |
108 | | - | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
109 | 170 | | |
110 | 171 | | |
111 | 172 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
| 9 | + | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
| |||
52 | 54 | | |
53 | 55 | | |
54 | 56 | | |
| 57 | + | |
55 | 58 | | |
56 | 59 | | |
57 | 60 | | |
| |||
97 | 100 | | |
98 | 101 | | |
99 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
100 | 111 | | |
101 | 112 | | |
102 | 113 | | |
103 | 114 | | |
104 | 115 | | |
105 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
106 | 123 | | |
107 | 124 | | |
108 | 125 | | |
| |||
111 | 128 | | |
112 | 129 | | |
113 | 130 | | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
114 | 140 | | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
133 | 159 | | |
134 | | - | |
135 | 160 | | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
136 | 168 | | |
137 | 169 | | |
138 | 170 | | |
139 | 171 | | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
140 | 177 | | |
141 | 178 | | |
142 | 179 | | |
| |||
158 | 195 | | |
159 | 196 | | |
160 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
161 | 238 | | |
162 | 239 | | |
163 | 240 | | |
| |||
0 commit comments