@mainwave/cli 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -106,5 +106,102 @@
106
106
  "session id, prompt id, Claude account id and email"
107
107
  ],
108
108
  "why": "StopFailure fires instead of Stop when a turn ends on an API error. Rate-limit and billing errors are the developer's own limit hits, joined to the plan snapshot. No matcher: every error type is rare enough, and the feature sends only the type enum, never the error details or the rendered message. Notification is deliberately not used: Claude Code's usage-limit auto-resume notices (`quota_auto_resume_*`) can fire while the developer is idle, which would move the use case's last-seen with no work then, the same reason SessionEnd is not used."
109
+ },
110
+ {
111
+ "event": "UserPromptSubmit",
112
+ "route": "turns",
113
+ "features": ["codex-turns"],
114
+ "optOut": "markers",
115
+ "hosts": ["codex"],
116
+ "dataClasses": ["session id, turn id and agent id", "working directory", "start and end times"],
117
+ "why": "Opens a Codex turn. The input carries `turn_id` (a turn with no tool calls has one too), `session_id` and `cwd`; the feature reads only those and never the prompt. Takes no matcher. The group is async, so the prompt never waits on it."
118
+ },
119
+ {
120
+ "event": "Stop",
121
+ "route": "turns",
122
+ "features": ["codex-turns"],
123
+ "optOut": "markers",
124
+ "hosts": ["codex"],
125
+ "dataClasses": ["session id, turn id and agent id", "working directory", "start and end times"],
126
+ "why": "Closes the turn that UserPromptSubmit opened and sends it as one span, so Developer Work gets a turn and its duration. Codex fires no Stop for an interrupted turn (Interrupt closes that one). Takes no matcher. Synchronous with `timeout: 5`, unlike the other groups: `codex exec` exits without waiting for an async hook, so an async Stop never sends a headless run's last turn. Codex waits for it at the end of each turn, as long as one post takes (its lock wait is capped at 1.5 s and its post at 1.2 s)."
127
+ },
128
+ {
129
+ "event": "Interrupt",
130
+ "route": "turns",
131
+ "features": ["codex-turns"],
132
+ "optOut": "markers",
133
+ "hosts": ["codex"],
134
+ "dataClasses": ["session id, turn id and agent id", "working directory", "start and end times"],
135
+ "why": "Closes a turn the developer interrupted: Codex fires Interrupt with the turn's `turn_id` and no Stop after it, so without this group the turn would stay open. Codex gives Interrupt a 1 s default timeout and prints a clamp warning above 3 s, so the group sets `timeout: 2`; the hook waits at most 0.6 s for the state lock, sends one span and does no other work. Takes no matcher. Synchronous like Stop, so `codex exec` waits for it (the post is capped at 1 s)."
136
+ },
137
+ {
138
+ "event": "PermissionRequest",
139
+ "route": "turns",
140
+ "features": ["codex-turns"],
141
+ "optOut": "markers",
142
+ "hosts": ["codex"],
143
+ "dataClasses": [
144
+ "session id, turn id and agent id",
145
+ "working directory",
146
+ "start and end times",
147
+ "tool name of the call waiting for approval"
148
+ ],
149
+ "why": "Opens a permission wait: Codex asks the developer to approve a tool call. The feature reads `tool_name` (an id such as `shell`, never `tool_input`) and sends the wait when the next event closes it, so Developer Work counts the time as waiting, not working. Takes no matcher; async."
150
+ },
151
+ {
152
+ "event": "PostToolUse",
153
+ "route": "turns",
154
+ "matcher": ".*",
155
+ "features": ["codex-turns"],
156
+ "optOut": "markers",
157
+ "hosts": ["codex"],
158
+ "dataClasses": ["session id, turn id and agent id", "working directory", "start and end times"],
159
+ "why": "Ends a permission wait after an approved call ran, and records the turn's last event time so a turn that never ends can be closed at the last thing it did. It runs on every tool call, so its matcher is `.*`: it reads only `session_id`, `turn_id`, `agent_id`, `tool_name` and `cwd`, and the tool's input and response are never read. A second PostToolUse group (route `bash`) runs the pull-request and commit markers on the same call. Async."
160
+ },
161
+ {
162
+ "event": "PreModelRequest",
163
+ "route": "turns",
164
+ "features": ["codex-turns"],
165
+ "optOut": "markers",
166
+ "hosts": ["codex"],
167
+ "dataClasses": ["session id, turn id and agent id", "working directory", "start and end times"],
168
+ "why": "Ends a permission wait after a denied call: with no tool to run, the next thing Codex does is its next model request. It also records the turn's last event time. PreToolUse is not hooked because Codex runs it before the approval, and PostModelRequest is not because this event already ended any wait. Takes no matcher; async."
169
+ },
170
+ {
171
+ "event": "SubagentStart",
172
+ "route": "turns",
173
+ "features": ["codex-turns"],
174
+ "optOut": "markers",
175
+ "hosts": ["codex"],
176
+ "dataClasses": [
177
+ "session id, turn id and agent id",
178
+ "working directory",
179
+ "start and end times",
180
+ "agent type"
181
+ ],
182
+ "why": "Opens a subagent run. Subagent events keep the parent's `session_id` and add `agent_id` (the child's own conversation id) and `agent_type`. The span exists so a subagent's own telemetry can be attributed to the parent's turn; it is no turn in any count. Takes no matcher; async."
183
+ },
184
+ {
185
+ "event": "SubagentStop",
186
+ "route": "turns",
187
+ "features": ["codex-turns"],
188
+ "optOut": "markers",
189
+ "hosts": ["codex"],
190
+ "dataClasses": [
191
+ "session id, turn id and agent id",
192
+ "working directory",
193
+ "start and end times",
194
+ "agent type"
195
+ ],
196
+ "why": "Closes a subagent run and sends it as one span. Takes no matcher; async."
197
+ },
198
+ {
199
+ "event": "SessionStart",
200
+ "route": "turns",
201
+ "features": ["codex-turns"],
202
+ "optOut": "markers",
203
+ "hosts": ["codex"],
204
+ "dataClasses": ["session id, turn id and agent id", "working directory", "start and end times"],
205
+ "why": "Closes a turn that was still open when the session started, resumed or forked: the turn is sent ending at the last event it saw, never at the new start, so a killed Codex can't stretch a turn across the developer's absence. It also deletes turn state older than 7 days. It takes no matcher, so it runs for every source (the session-start refresh is a separate group that runs for `startup|resume|fork` only). Async."
109
206
  }
110
207
  ]
@@ -104,6 +104,7 @@ export const PACKS = {
104
104
 
105
105
  export const BUILTIN_EXEMPT_KEYS = [
106
106
  'agent.decision',
107
+ 'agent_id',
107
108
  'ccr.session.id',
108
109
  'cowork.surface',
109
110
  'decision',
@@ -116,6 +117,7 @@ export const BUILTIN_EXEMPT_KEYS = [
116
117
  'devtool.wi_prev_state_category',
117
118
  'devtool.wi_state_category',
118
119
  'devtool.wi_url',
120
+ 'event.kind',
119
121
  'gen_ai.agent.id',
120
122
  'gen_ai.agent.name',
121
123
  'gen_ai.conversation.id',
@@ -147,6 +149,12 @@ export const BUILTIN_EXEMPT_KEYS = [
147
149
  'mainwave.caller.span_id',
148
150
  'mainwave.caller.trace_id',
149
151
  'mainwave.claude_code.stop_failure.error',
152
+ 'mainwave.codex.agent_type',
153
+ 'mainwave.codex.parent_turn_id',
154
+ 'mainwave.codex.tool_name',
155
+ 'mainwave.codex.turn.end_reason',
156
+ 'mainwave.codex.turn_id',
157
+ 'mainwave.codex.wait.end_event',
150
158
  'mainwave.connector_id',
151
159
  'mainwave.connector_type',
152
160
  'mainwave.devtool_vendor',
@@ -68,8 +68,9 @@ export const ATTR_CALLER_SPAN_ID = 'mainwave.caller.span_id'
68
68
  // this key, so the marker joins its tool span on one key name. A marker is not
69
69
  // a tool span; readers that want tool spans select on `gen_ai.operation.name`.
70
70
  export const ATTR_TOOL_CALL_ID = 'gen_ai.tool.call.id'
71
- // Claude Code's per-spawn subagent id (its own spans carry it as a bare
72
- // `agent_id`). Not `gen_ai.agent.id`: upstream defines that as a stable agent
71
+ // The per-spawn subagent id. Claude Code's own spans carry it as a bare
72
+ // `agent_id`; the Codex turn hook and Codex-hosted markers emit the hook
73
+ // payload's `agent_id` (the child's conversation id) under this key too. Not `gen_ai.agent.id`: upstream defines that as a stable agent
73
74
  // identity, and this id is minted fresh for every spawn.
74
75
  export const ATTR_SUBAGENT_ID = 'mainwave.subagent.id'
75
76
 
@@ -347,6 +348,43 @@ export const ATTR_STOP_FAILURE_ERROR = 'mainwave.claude_code.stop_failure.error'
347
348
  // against the registry.
348
349
  export const STOP_FAILURE_KEYS = [ATTR_STOP_FAILURE_ERROR, ATTR_PROMPT_ID]
349
350
 
351
+ // ── Codex turns — CLI hook feature ───────────────────────────────────────────
352
+ // Codex's own export has no turn-end signal, so the hook sends each turn,
353
+ // permission wait and subagent run as ONE closed span (start and end), when it
354
+ // ends. The resource carries the Codex export's own source tag, so the spans
355
+ // derive the export's ucid, and its own service name. `session.id` is the hook
356
+ // input's `session_id`, which equals the export's `conversation.id`. Ids only,
357
+ // the working directory and a tool name: never the prompt, the assistant
358
+ // message, a tool's input or output, or the transcript path.
359
+ export const CODEX_TURN_SOURCE = 'coding_agent.codex_cli'
360
+ export const CODEX_TURN_SERVICE = 'mainwave-codex-hook'
361
+
362
+ export const CODEX_TURN = 'mainwave.codex.turn'
363
+ export const CODEX_PERMISSION_WAIT = 'mainwave.codex.permission_wait'
364
+ export const CODEX_SUBAGENT_TURN = 'mainwave.codex.subagent_turn'
365
+
366
+ export const ATTR_CODEX_TURN_ID = 'mainwave.codex.turn_id'
367
+ export const ATTR_CODEX_END_REASON = 'mainwave.codex.turn.end_reason'
368
+ export const ATTR_CODEX_CWD = 'mainwave.codex.cwd'
369
+ export const ATTR_CODEX_AGENT_TYPE = 'mainwave.codex.agent_type'
370
+ export const ATTR_CODEX_PARENT_TURN_ID = 'mainwave.codex.parent_turn_id'
371
+ export const ATTR_CODEX_TOOL_NAME = 'mainwave.codex.tool_name'
372
+ export const ATTR_CODEX_WAIT_END_EVENT = 'mainwave.codex.wait.end_event'
373
+
374
+ export const CODEX_TURN_SPANS = [CODEX_TURN, CODEX_PERMISSION_WAIT, CODEX_SUBAGENT_TURN]
375
+
376
+ // The exact literal keys the three spans may emit beyond `session.id`.
377
+ export const CODEX_TURN_KEYS = [
378
+ ATTR_CODEX_TURN_ID,
379
+ ATTR_CODEX_END_REASON,
380
+ ATTR_CODEX_CWD,
381
+ ATTR_SUBAGENT_ID,
382
+ ATTR_CODEX_AGENT_TYPE,
383
+ ATTR_CODEX_PARENT_TURN_ID,
384
+ ATTR_CODEX_TOOL_NAME,
385
+ ATTR_CODEX_WAIT_END_EVENT,
386
+ ]
387
+
350
388
  // ── What each hook feature may send ─────────────────────────────────────────
351
389
  // The dispatcher drops every span attribute a feature's entry here doesn't
352
390
  // bind, and every span whose name isn't the feature's, before anything is
@@ -381,6 +419,7 @@ export const FEATURE_EMITS = Object.freeze({
381
419
  prefixes: [],
382
420
  },
383
421
  'stop-failure': { spans: [CLAUDE_CODE_STOP_FAILURE], keys: STOP_FAILURE_KEYS, prefixes: [] },
422
+ 'codex-turns': { spans: CODEX_TURN_SPANS, keys: CODEX_TURN_KEYS, prefixes: [] },
384
423
  })
385
424
 
386
425
  // The hook spans outside the work / vcs families, each under `hook.anthropic`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mainwave/cli",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "Setup wizard for connecting third-party coding tools to Mainwave AI.",
5
5
  "type": "module",
6
6
  "bin": {