@mutagent/cli 0.2.25 → 0.2.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.
Files changed (2) hide show
  1. package/dist/bin/cli.js +41 -6
  2. package/package.json +2 -2
package/dist/bin/cli.js CHANGED
@@ -17280,16 +17280,19 @@ function readRegistration(diagnostics, launch, artifactDigest) {
17280
17280
  function isRecord(value) {
17281
17281
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
17282
17282
  }
17283
+ function sameModel(declared, observed) {
17284
+ return observed === declared || Object.hasOwn(HELIX_MODEL_ALIASES, declared) && observed === HELIX_MODEL_ALIASES[declared];
17285
+ }
17283
17286
  function completedLocalResult(process2, launch, artifactDigest) {
17284
17287
  const registration = readRegistration(process2.diagnostics, launch, artifactDigest);
17285
17288
  const end = process2.frames.filter((frame) => frame.type === "agent_end").at(-1);
17286
17289
  if (!end && process2.exitCode === 0)
17287
17290
  throw new MutagentError("AGENT_COMPLETION_MISSING", "The runtime exited without an agent_end event.", "Use a compatible Helix runtime; a started process is not a completed task.");
17288
- const messages = Array.isArray(end?.messages) ? end.messages.filter(isRecord) : [];
17291
+ const messages = Array.isArray(end?.messages) ? end.messages.filter(isRecord).filter((message) => message.role !== "system") : [];
17289
17292
  const assistant = messages.filter((message) => message.role === "assistant").at(-1);
17290
17293
  if (process2.exitCode === 0 && !assistant)
17291
17294
  throw new MutagentError("AGENT_RESULT_MISSING", "The runtime completed without an assistant result.");
17292
- if (assistant && (assistant.provider !== launch.model.provider || assistant.model !== launch.model.id))
17295
+ if (assistant && (assistant.provider !== launch.model.provider || !sameModel(launch.model.id, assistant.model)))
17293
17296
  throw new MutagentError("AGENT_MODEL_MISMATCH", "The runtime result used a different provider or model than the package declares.");
17294
17297
  const failedTurn = assistant?.stopReason === "error" || assistant?.stopReason === "aborted";
17295
17298
  const exitCode = process2.exitCode || (failedTurn ? 1 : 0);
@@ -17312,11 +17315,12 @@ function completedLocalResult(process2, launch, artifactDigest) {
17312
17315
  `).trim()
17313
17316
  };
17314
17317
  }
17315
- var RECEIPT_PREFIX;
17318
+ var RECEIPT_PREFIX, HELIX_MODEL_ALIASES;
17316
17319
  var init_local_result = __esm(() => {
17317
17320
  init_src();
17318
17321
  init_errors();
17319
17322
  RECEIPT_PREFIX = AGENT_REGISTRATION_RECEIPT_PREFIX;
17323
+ HELIX_MODEL_ALIASES = { "glm-5": "glm-5.3" };
17320
17324
  });
17321
17325
 
17322
17326
  // src/lib/agent/worker-location.ts
@@ -24282,6 +24286,35 @@ import { Command as Command10 } from "commander";
24282
24286
  import chalk19 from "chalk";
24283
24287
 
24284
24288
  // src/commands/hooks/import-transcript.ts
24289
+ var finite2 = (value) => typeof value === "number" && Number.isFinite(value) ? value : 0;
24290
+ function recordUsage(r) {
24291
+ let usage;
24292
+ if (r.type === "message") {
24293
+ const role = r.message?.role;
24294
+ if (role === "assistant" || role === "toolResult")
24295
+ usage = r.message?.usage;
24296
+ } else if (r.type === "usage" || r.type === "compaction" || r.type === "branch_summary") {
24297
+ usage = r.usage;
24298
+ }
24299
+ return usage !== null && typeof usage === "object" && !Array.isArray(usage) ? usage : null;
24300
+ }
24301
+ function totalUsage(records) {
24302
+ let totals = null;
24303
+ for (const r of records) {
24304
+ const usage = recordUsage(r);
24305
+ if (usage === null)
24306
+ continue;
24307
+ totals ??= { inputTokens: 0, outputTokens: 0, cacheReadTokens: 0, cacheWriteTokens: 0, costTotal: 0 };
24308
+ totals.inputTokens += finite2(usage.input);
24309
+ totals.outputTokens += finite2(usage.output);
24310
+ totals.cacheReadTokens += finite2(usage.cacheRead);
24311
+ totals.cacheWriteTokens += finite2(usage.cacheWrite);
24312
+ const cost = usage.cost;
24313
+ if (cost !== null && typeof cost === "object")
24314
+ totals.costTotal += finite2(cost.total);
24315
+ }
24316
+ return totals;
24317
+ }
24285
24318
  var MAX_SPAN_TEXT = 4000;
24286
24319
  function contentToText(content) {
24287
24320
  if (typeof content === "string")
@@ -24301,7 +24334,7 @@ function convertTranscript(records, opts) {
24301
24334
  let ignored = 0;
24302
24335
  let lastTs = session.timestamp ?? new Date().toISOString();
24303
24336
  for (const r of records) {
24304
- if (r.type !== "message" && r.type !== "custom_message") {
24337
+ if (r.type !== "message" && r.type !== "custom_message" || r.message?.role === "system") {
24305
24338
  ignored += 1;
24306
24339
  continue;
24307
24340
  }
@@ -24324,6 +24357,7 @@ function convertTranscript(records, opts) {
24324
24357
  span.output = text;
24325
24358
  spans.push(span);
24326
24359
  }
24360
+ const usage = totalUsage(records);
24327
24361
  return {
24328
24362
  trace: {
24329
24363
  traceId: `helix-${session.id}`.slice(0, 128),
@@ -24338,7 +24372,8 @@ function convertTranscript(records, opts) {
24338
24372
  harness: "helix",
24339
24373
  transcript: opts.fileName,
24340
24374
  ...session.cwd !== undefined ? { cwd: session.cwd } : {},
24341
- ...session.version !== undefined ? { version: session.version } : {}
24375
+ ...session.version !== undefined ? { version: session.version } : {},
24376
+ ...usage ?? {}
24342
24377
  }
24343
24378
  },
24344
24379
  skipped: opts.skipped ?? 0,
@@ -37994,4 +38029,4 @@ if (process.env.CLI_VERSION) {
37994
38029
  }
37995
38030
  runCli(process.argv.slice(2), cliVersion);
37996
38031
 
37997
- //# debugId=02AF2BDB9E29C77264756E2164756E21
38032
+ //# debugId=B78FA1E6E4FCE6E164756E2164756E21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mutagent/cli",
3
- "version": "0.2.25",
3
+ "version": "0.2.27",
4
4
  "description": "Bun-native CLI for the MutagenT AI platform - auth, provider config, and lifecycle-tool installer for AI-native workflows",
5
5
  "type": "module",
6
6
  "bin": {
@@ -45,7 +45,7 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "@inquirer/prompts": "^8.7.2",
48
- "@mutagent/sdk": "0.8.12",
48
+ "@mutagent/sdk": "0.8.13",
49
49
  "@sinclair/typebox": "^0.34.0",
50
50
  "chalk": "^5.3.0",
51
51
  "commander": "^12.1.0",