impel-cli 0.20.15 → 0.20.16

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.
package/RELEASE_NOTES.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Release notes
2
2
 
3
+ ## 0.20.16 — Correlated Codex transport timing
4
+
5
+ - Derives native-agent MCP duration from correlated, timestamped Codex rollout
6
+ events when durable profiles correctly omit transient telemetry destinations.
7
+ - Retries one unestablished tenant-preflight result while still requiring one
8
+ exact selected tenant before every profiled Codex attempt.
9
+
3
10
  ## 0.20.15 — Direct Codex native agents
4
11
 
5
12
  - Classifies the exact `mcp__impel_agent` namespace as direct-only in generated
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impel-cli",
3
- "version": "0.20.15",
3
+ "version": "0.20.16",
4
4
  "description": "Prepare isolated Claude and Codex workspaces for every accessible Impel tenant",
5
5
  "type": "module",
6
6
  "bin": {
@@ -151,12 +151,15 @@ export function summarizeCodexRollouts(rollouts) {
151
151
  let inputTokens = 0;
152
152
  let cachedInputTokens = 0;
153
153
  let outputTokens = 0;
154
+ let mcpDurationMs = 0;
155
+ let mcpCompletedCalls = 0;
154
156
 
155
157
  for (const events of rollouts) {
156
158
  eventCount += events.length;
157
159
  const metadata = rolloutSessionMetadata(events);
158
160
  const scopedCounts = metadata.parentThreadId ? childToolCounts : parentToolCounts;
159
161
  let latestUsage = null;
162
+ const mcpStarts = new Map();
160
163
  for (const event of events) {
161
164
  const payload = event.payload && typeof event.payload === "object" ? event.payload : {};
162
165
  if (event.type === "response_item"
@@ -166,6 +169,27 @@ export function summarizeCodexRollouts(rollouts) {
166
169
  increment(scopedCounts, tool);
167
170
  if (tool === "exec" || payload.type === "custom_tool_call") codeCells += tool === "exec" ? 1 : 0;
168
171
  if (tool === "wait") codeWaits += 1;
172
+ const startedAt = Date.parse(event.timestamp || "");
173
+ if (SAFE_MCP_TOOLS.has(tool)
174
+ && typeof payload.call_id === "string"
175
+ && Number.isFinite(startedAt)) {
176
+ mcpStarts.set(payload.call_id, startedAt);
177
+ }
178
+ }
179
+ if (event.type === "event_msg"
180
+ && payload.type === "mcp_tool_call_end"
181
+ && typeof payload.call_id === "string") {
182
+ const startedAt = mcpStarts.get(payload.call_id);
183
+ const endedAt = Date.parse(event.timestamp || "");
184
+ const duration = endedAt - startedAt;
185
+ if (Number.isFinite(startedAt)
186
+ && Number.isFinite(endedAt)
187
+ && duration >= 0
188
+ && duration <= 24 * 60 * 60 * 1000) {
189
+ mcpDurationMs += duration;
190
+ mcpCompletedCalls += 1;
191
+ mcpStarts.delete(payload.call_id);
192
+ }
169
193
  }
170
194
  if (event.type === "event_msg" && payload.type === "token_count") {
171
195
  const usage = payload.info?.total_token_usage;
@@ -190,6 +214,8 @@ export function summarizeCodexRollouts(rollouts) {
190
214
  inputTokens,
191
215
  cachedInputTokens,
192
216
  outputTokens,
217
+ mcpDurationMs,
218
+ mcpCompletedCalls,
193
219
  };
194
220
  }
195
221
 
@@ -249,7 +275,9 @@ export function summarizeRawAttempt({ stdoutText, telemetryText = "", rolloutTex
249
275
  codeWaits: rollout.codeWaits,
250
276
  inputTokens: rollout.inputTokens,
251
277
  cachedInputTokens: rollout.cachedInputTokens,
252
- outputTokens: rollout.outputTokens,
278
+ outputTokens: rollout.outputTokens,
279
+ mcpDurationMs: rollout.mcpDurationMs,
280
+ mcpCompletedCalls: rollout.mcpCompletedCalls,
253
281
  } : {}),
254
282
  parentToolCounts: rollout.parentToolCounts,
255
283
  childToolCounts: rollout.childToolCounts,
@@ -211,13 +211,16 @@ function runCaptured(command, args, { environment = process.env, timeoutMs = 60_
211
211
  }
212
212
 
213
213
  async function currentTenant(impelBinary, environment) {
214
- const invocation = impelInvocation(impelBinary, ["tenant", "current"], environment);
215
- const result = await runCaptured(invocation.command, invocation.args, { environment });
216
- const lines = result.stdout.split(/\r?\n/u).map((line) => line.trim()).filter(Boolean);
217
- if (result.code !== 0 || lines.length !== 1 || !/^[A-Za-z0-9_.:-]{1,160}$/u.test(lines[0])) {
218
- throw new Error("could not establish one exact current Impel tenant");
214
+ for (let attempt = 0; attempt < 2; attempt += 1) {
215
+ const invocation = impelInvocation(impelBinary, ["tenant", "current"], environment);
216
+ const result = await runCaptured(invocation.command, invocation.args, { environment });
217
+ const lines = result.stdout.split(/\r?\n/u).map((line) => line.trim()).filter(Boolean);
218
+ if (result.code === 0 && lines.length === 1 && /^[A-Za-z0-9_.:-]{1,160}$/u.test(lines[0])) {
219
+ return lines[0];
220
+ }
221
+ if (attempt === 0) await delay(250);
219
222
  }
220
- return lines[0];
223
+ throw new Error("could not establish one exact current Impel tenant after two bounded attempts");
221
224
  }
222
225
 
223
226
  export async function assertExpectedTenant({ expectedTenant, impelBinary = "impel", environment = process.env }) {
@@ -373,7 +376,10 @@ function safeAttemptRecord({ options, index, processResult, summary, jsonValid,
373
376
  const codex = summary?.codex || {};
374
377
  const telemetry = summary?.telemetry || {};
375
378
  const durationMs = processResult.endedAtMs - processResult.startedAtMs;
376
- const mcpDurationMs = telemetry.mcpDurationMs || 0;
379
+ const telemetryCompleted = telemetry.eventCounts?.local_tool_completed || 0;
380
+ const mcpDurationMs = telemetryCompleted > 0
381
+ ? telemetry.mcpDurationMs || 0
382
+ : codex.mcpDurationMs || 0;
377
383
  const startCalls = (codex.toolCounts?.answer_native_agent || 0)
378
384
  + (codex.toolCounts?.run_native_agent || 0);
379
385
  const success = processResult.exitCode === 0
@@ -414,6 +420,9 @@ function safeAttemptRecord({ options, index, processResult, summary, jsonValid,
414
420
  cachedInputTokens: codex.cachedInputTokens || 0,
415
421
  outputTokens: codex.outputTokens || 0,
416
422
  mcpDurationMs,
423
+ mcpDurationSource: telemetryCompleted > 0
424
+ ? "telemetry"
425
+ : (codex.mcpCompletedCalls || 0) > 0 ? "rollout" : "unavailable",
417
426
  nonMcpOverheadMs: Math.max(0, durationMs - mcpDurationMs),
418
427
  telemetryEventCount: telemetry.eventCount || 0,
419
428
  telemetryCorrelationCount: telemetry.correlationCount || 0,