impel-cli 0.20.26 → 0.20.27
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/package.json
CHANGED
|
@@ -144,6 +144,27 @@ function rolloutSessionMetadata(events) {
|
|
|
144
144
|
} : { threadId: null, parentThreadId: null };
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
+
function nativeTerminalStatus(output) {
|
|
148
|
+
if (typeof output !== "string") return null;
|
|
149
|
+
const objectStart = output.indexOf("{");
|
|
150
|
+
if (objectStart < 0) return null;
|
|
151
|
+
let value;
|
|
152
|
+
try {
|
|
153
|
+
value = JSON.parse(output.slice(objectStart));
|
|
154
|
+
} catch {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
158
|
+
if (value.schema === "impel.native-agent-answer.v1" && value.status === "succeeded") {
|
|
159
|
+
return "succeeded";
|
|
160
|
+
}
|
|
161
|
+
if (value.schema === "impel.native-agent-result.v1"
|
|
162
|
+
&& ["succeeded", "failed", "cancelled", "canceled"].includes(value.status)) {
|
|
163
|
+
return value.status;
|
|
164
|
+
}
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
|
|
147
168
|
export function summarizeCodexRollouts(rollouts) {
|
|
148
169
|
const toolCounts = {};
|
|
149
170
|
const parentToolCounts = {};
|
|
@@ -156,6 +177,10 @@ export function summarizeCodexRollouts(rollouts) {
|
|
|
156
177
|
let outputTokens = 0;
|
|
157
178
|
let mcpDurationMs = 0;
|
|
158
179
|
let mcpCompletedCalls = 0;
|
|
180
|
+
let terminalResults = 0;
|
|
181
|
+
let successfulTerminalResults = 0;
|
|
182
|
+
let parentSuccessfulTerminalResults = 0;
|
|
183
|
+
let childSuccessfulTerminalResults = 0;
|
|
159
184
|
|
|
160
185
|
for (const events of rollouts) {
|
|
161
186
|
eventCount += events.length;
|
|
@@ -194,6 +219,17 @@ export function summarizeCodexRollouts(rollouts) {
|
|
|
194
219
|
mcpStarts.delete(payload.call_id);
|
|
195
220
|
}
|
|
196
221
|
}
|
|
222
|
+
if (event.type === "response_item" && payload.type === "function_call_output") {
|
|
223
|
+
const terminalStatus = nativeTerminalStatus(payload.output);
|
|
224
|
+
if (terminalStatus) {
|
|
225
|
+
terminalResults += 1;
|
|
226
|
+
if (terminalStatus === "succeeded") {
|
|
227
|
+
successfulTerminalResults += 1;
|
|
228
|
+
if (metadata.parentThreadId) childSuccessfulTerminalResults += 1;
|
|
229
|
+
else parentSuccessfulTerminalResults += 1;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
197
233
|
if (event.type === "event_msg" && payload.type === "token_count") {
|
|
198
234
|
const usage = payload.info?.total_token_usage;
|
|
199
235
|
if (usage && typeof usage === "object") latestUsage = usage;
|
|
@@ -219,6 +255,10 @@ export function summarizeCodexRollouts(rollouts) {
|
|
|
219
255
|
outputTokens,
|
|
220
256
|
mcpDurationMs,
|
|
221
257
|
mcpCompletedCalls,
|
|
258
|
+
terminalResults,
|
|
259
|
+
successfulTerminalResults,
|
|
260
|
+
parentSuccessfulTerminalResults,
|
|
261
|
+
childSuccessfulTerminalResults,
|
|
222
262
|
};
|
|
223
263
|
}
|
|
224
264
|
|
|
@@ -281,6 +321,10 @@ export function summarizeRawAttempt({ stdoutText, telemetryText = "", rolloutTex
|
|
|
281
321
|
outputTokens: rollout.outputTokens,
|
|
282
322
|
mcpDurationMs: rollout.mcpDurationMs,
|
|
283
323
|
mcpCompletedCalls: rollout.mcpCompletedCalls,
|
|
324
|
+
terminalResults: rollout.terminalResults,
|
|
325
|
+
successfulTerminalResults: rollout.successfulTerminalResults,
|
|
326
|
+
parentSuccessfulTerminalResults: rollout.parentSuccessfulTerminalResults,
|
|
327
|
+
childSuccessfulTerminalResults: rollout.childSuccessfulTerminalResults,
|
|
284
328
|
} : {}),
|
|
285
329
|
parentToolCounts: rollout.parentToolCounts,
|
|
286
330
|
childToolCounts: rollout.childToolCounts,
|
|
@@ -336,6 +380,9 @@ function directGate(report) {
|
|
|
336
380
|
structure: report.structure.maximumThreadCount <= 1
|
|
337
381
|
&& report.structure.totalCodeCells === 0
|
|
338
382
|
&& report.structure.totalCodeWaits === 0
|
|
383
|
+
&& report.structure.successfulTerminalResults === report.successfulSamples
|
|
384
|
+
&& report.structure.parentSuccessfulTerminalResults === report.successfulSamples
|
|
385
|
+
&& report.structure.childSuccessfulTerminalResults === 0
|
|
339
386
|
&& ["spawn_agent", "wait_agent", "send_message", "exec", "wait", "tool_search", "ALL_TOOLS"]
|
|
340
387
|
.every((tool) => !report.structure.allToolCounts[tool])
|
|
341
388
|
&& (report.structure.toolCounts.answer_native_agent || 0) === report.successfulSamples
|
|
@@ -350,6 +397,8 @@ function compatibleGate(report) {
|
|
|
350
397
|
&& report.timings.durationMs.p50 <= (report.sloClass === "cibi" ? 55_000 : 100_000),
|
|
351
398
|
childStructure: report.structure.totalCodeCells === 0
|
|
352
399
|
&& report.structure.totalCodeWaits === 0
|
|
400
|
+
&& report.structure.successfulTerminalResults === report.successfulSamples
|
|
401
|
+
&& report.structure.childSuccessfulTerminalResults === report.successfulSamples
|
|
353
402
|
&& ["exec", "wait", "send_message", "tool_search", "ALL_TOOLS"]
|
|
354
403
|
.every((tool) => !report.structure.childToolCounts[tool]),
|
|
355
404
|
};
|
|
@@ -405,6 +454,19 @@ export function analyzeAggregates(aggregates) {
|
|
|
405
454
|
allToolCounts: mergedCounts(attempts, "toolCounts"),
|
|
406
455
|
parentToolCounts: mergedCounts(successful, "parentToolCounts"),
|
|
407
456
|
childToolCounts: mergedCounts(successful, "childToolCounts"),
|
|
457
|
+
terminalResults: successful.reduce((total, attempt) => total + (attempt.terminalResults || 0), 0),
|
|
458
|
+
successfulTerminalResults: successful.reduce(
|
|
459
|
+
(total, attempt) => total + (attempt.successfulTerminalResults || 0),
|
|
460
|
+
0,
|
|
461
|
+
),
|
|
462
|
+
parentSuccessfulTerminalResults: successful.reduce(
|
|
463
|
+
(total, attempt) => total + (attempt.parentSuccessfulTerminalResults || 0),
|
|
464
|
+
0,
|
|
465
|
+
),
|
|
466
|
+
childSuccessfulTerminalResults: successful.reduce(
|
|
467
|
+
(total, attempt) => total + (attempt.childSuccessfulTerminalResults || 0),
|
|
468
|
+
0,
|
|
469
|
+
),
|
|
408
470
|
maximumThreadCount: successful.reduce((maximum, attempt) => Math.max(maximum, attempt.threadCount || 0), 0),
|
|
409
471
|
totalCodeCells: successful.reduce((total, attempt) => total + (attempt.codeCells || 0), 0),
|
|
410
472
|
totalCodeWaits: successful.reduce((total, attempt) => total + (attempt.codeWaits || 0), 0),
|
|
@@ -390,6 +390,7 @@ export function safeAttemptRecord({ options, index, processResult, summary, json
|
|
|
390
390
|
&& jsonValid
|
|
391
391
|
&& codex.turnCompleted === true
|
|
392
392
|
&& (codex.agentMessages || 0) >= 1
|
|
393
|
+
&& (codex.successfulTerminalResults || 0) === 1
|
|
393
394
|
&& (telemetry.localFailures || 0) === 0
|
|
394
395
|
&& startCalls === 1;
|
|
395
396
|
return {
|
|
@@ -420,6 +421,10 @@ export function safeAttemptRecord({ options, index, processResult, summary, json
|
|
|
420
421
|
childToolCounts: codex.childToolCounts || {},
|
|
421
422
|
codeCells: codex.codeCells || 0,
|
|
422
423
|
codeWaits: codex.codeWaits || 0,
|
|
424
|
+
terminalResults: codex.terminalResults || 0,
|
|
425
|
+
successfulTerminalResults: codex.successfulTerminalResults || 0,
|
|
426
|
+
parentSuccessfulTerminalResults: codex.parentSuccessfulTerminalResults || 0,
|
|
427
|
+
childSuccessfulTerminalResults: codex.childSuccessfulTerminalResults || 0,
|
|
423
428
|
inputTokens: codex.inputTokens || 0,
|
|
424
429
|
cachedInputTokens: codex.cachedInputTokens || 0,
|
|
425
430
|
outputTokens: codex.outputTokens || 0,
|
package/src/agents.js
CHANGED
|
@@ -16,6 +16,8 @@ import {
|
|
|
16
16
|
redactSecretText,
|
|
17
17
|
} from "./config.js";
|
|
18
18
|
import {
|
|
19
|
+
CODEX_NATIVE_AGENT_ATTACHMENT_WINDOW_MS,
|
|
20
|
+
IMPEL_NATIVE_AGENT_ATTACHMENT_WINDOW_ENV,
|
|
19
21
|
IMPEL_NATIVE_AGENT_TELEMETRY_ENV_NAMES,
|
|
20
22
|
IMPEL_NATIVE_AGENT_MCP_TARGET,
|
|
21
23
|
impelNativeAgentMcpInvocation,
|
|
@@ -52,7 +54,7 @@ export const NATIVE_AGENT_RUN_TOOL = "run_native_agent";
|
|
|
52
54
|
export const NATIVE_AGENT_RESUME_TOOL = "resume_native_agent_run";
|
|
53
55
|
export const NATIVE_AGENT_RECOVER_TOOL = "recover_native_agent_runs";
|
|
54
56
|
export const MANAGED_AGENT_MCP_SERVER = "impel_agent";
|
|
55
|
-
export const MANAGED_AGENT_MANIFEST_VERSION =
|
|
57
|
+
export const MANAGED_AGENT_MANIFEST_VERSION = 17;
|
|
56
58
|
|
|
57
59
|
// The host model only selects the fixed MCP tool and faithfully returns its
|
|
58
60
|
// result. Luna preserves deterministic direct-only code-mode routing while the
|
|
@@ -748,9 +750,11 @@ function renderClaudeAgent({ tenantId, agent, name, invocation, recoveryOnly = f
|
|
|
748
750
|
|
|
749
751
|
function codexInvocationEnvironment(invocation, { durableProfile = false } = {}) {
|
|
750
752
|
const entries = Object.entries(invocation.env || {});
|
|
751
|
-
if (!durableProfile) return entries;
|
|
752
753
|
const transient = new Set(IMPEL_NATIVE_AGENT_TELEMETRY_ENV_NAMES);
|
|
753
|
-
return
|
|
754
|
+
return [
|
|
755
|
+
...(durableProfile ? entries.filter(([key]) => !transient.has(key)) : entries),
|
|
756
|
+
[IMPEL_NATIVE_AGENT_ATTACHMENT_WINDOW_ENV, String(CODEX_NATIVE_AGENT_ATTACHMENT_WINDOW_MS)],
|
|
757
|
+
];
|
|
754
758
|
}
|
|
755
759
|
|
|
756
760
|
function renderCodexConfiguration({
|
|
@@ -800,6 +804,7 @@ function renderCodexConfiguration({
|
|
|
800
804
|
`[mcp_servers.${MANAGED_AGENT_MCP_SERVER}]`,
|
|
801
805
|
`command = ${JSON.stringify(invocation.command)}`,
|
|
802
806
|
`args = [${invocation.args.map((argument) => JSON.stringify(argument)).join(", ")}]`,
|
|
807
|
+
"tool_timeout_sec = 120",
|
|
803
808
|
...(eager
|
|
804
809
|
? [`enabled_tools = [${toolNames.map((tool) => JSON.stringify(tool)).join(", ")}]`]
|
|
805
810
|
: []),
|
|
@@ -21,6 +21,9 @@ import {
|
|
|
21
21
|
normalizeNativeAgentCatalog,
|
|
22
22
|
} from "./agents.js";
|
|
23
23
|
import { extractAnswerFinalText } from "./directAnswer.js";
|
|
24
|
+
import {
|
|
25
|
+
IMPEL_NATIVE_AGENT_ATTACHMENT_WINDOW_ENV,
|
|
26
|
+
} from "./selfInvocation.js";
|
|
24
27
|
import { normalizeTenantId } from "./tenants.js";
|
|
25
28
|
import { renameWithWindowsRetry } from "./windowsFs.js";
|
|
26
29
|
|
|
@@ -62,6 +65,19 @@ const CTOS_START_TIMEOUT_MESSAGE = `MCP tool call failed for ${NATIVE_AGENT_STAR
|
|
|
62
65
|
const MCP_TOOL_RESULT_ERROR = Symbol("native-agent MCP tool result error");
|
|
63
66
|
const TERMINAL_STATUSES = new Set(["succeeded", "failed", "cancelled", "canceled"]);
|
|
64
67
|
|
|
68
|
+
export function nativeAgentAttachmentWindowMs(environment = process.env) {
|
|
69
|
+
const configured = environment?.[IMPEL_NATIVE_AGENT_ATTACHMENT_WINDOW_ENV];
|
|
70
|
+
if (configured === undefined) return DEFAULT_ATTACHMENT_WINDOW_MS;
|
|
71
|
+
if (!/^\d{1,6}$/u.test(configured)) {
|
|
72
|
+
throw new Error(`${IMPEL_NATIVE_AGENT_ATTACHMENT_WINDOW_ENV} must be an integer from 1000 through 300000`);
|
|
73
|
+
}
|
|
74
|
+
const parsed = Number(configured);
|
|
75
|
+
if (!Number.isSafeInteger(parsed) || parsed < 1_000 || parsed > 300_000) {
|
|
76
|
+
throw new Error(`${IMPEL_NATIVE_AGENT_ATTACHMENT_WINDOW_ENV} must be an integer from 1000 through 300000`);
|
|
77
|
+
}
|
|
78
|
+
return parsed;
|
|
79
|
+
}
|
|
80
|
+
|
|
65
81
|
function stableValue(value) {
|
|
66
82
|
if (Array.isArray(value)) return value.map(stableValue);
|
|
67
83
|
if (!value || typeof value !== "object") return value;
|
|
@@ -773,7 +789,7 @@ export class NativeAgentCompositeTransport {
|
|
|
773
789
|
gatewayUrl,
|
|
774
790
|
credential,
|
|
775
791
|
runsRoot = path.join(CONFIG_DIR, "native-agent-runs"),
|
|
776
|
-
attachmentWindowMs =
|
|
792
|
+
attachmentWindowMs = nativeAgentAttachmentWindowMs(),
|
|
777
793
|
maxPolls = DEFAULT_MAX_POLLS,
|
|
778
794
|
now = Date.now,
|
|
779
795
|
randomUUID = crypto.randomUUID,
|
package/src/selfInvocation.js
CHANGED
|
@@ -72,6 +72,8 @@ export const IMPEL_NATIVE_AGENT_TELEMETRY_ENV_NAMES = [
|
|
|
72
72
|
"IMPEL_NATIVE_HOST",
|
|
73
73
|
"IMPEL_NATIVE_HOST_BUILD",
|
|
74
74
|
];
|
|
75
|
+
export const IMPEL_NATIVE_AGENT_ATTACHMENT_WINDOW_ENV = "IMPEL_NATIVE_AGENT_ATTACHMENT_WINDOW_MS";
|
|
76
|
+
export const CODEX_NATIVE_AGENT_ATTACHMENT_WINDOW_MS = 100_000;
|
|
75
77
|
|
|
76
78
|
function managedMcpEnvironment(environment = process.env) {
|
|
77
79
|
const telemetry = Object.fromEntries(
|