@moda-ai/cli 1.55.15 → 1.55.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/dist/cli.js CHANGED
@@ -684,10 +684,14 @@ async function runReplaysCommand(context) {
684
684
  }
685
685
 
686
686
  // src/telemetry.ts
687
+ import { spawn } from "node:child_process";
687
688
  import { randomUUID } from "node:crypto";
688
- var TELEMETRY_TIMEOUT_MS = 500;
689
+ var INLINE_TELEMETRY_TIMEOUT_MS = 500;
690
+ var DETACHED_TELEMETRY_TIMEOUT_MS = 5000;
689
691
  var INVOCATION_ID = randomUUID();
690
692
  var TELEMETRY_FLAG = "no-telemetry";
693
+ var TELEMETRY_REQUEST_ENV = "MODA_CLI_TELEMETRY_REQUEST";
694
+ var TELEMETRY_TRANSPORT_ENV = "MODA_CLI_TELEMETRY_TRANSPORT";
691
695
  var MAX_TELEMETRY_DURATION_MS = 86400000;
692
696
  var MAX_TELEMETRY_API_REQUEST_COUNT = 1e6;
693
697
  var SEARCH_SURFACE_BY_COMMAND = {
@@ -715,6 +719,8 @@ function buildSearchAdoptionTelemetry(input) {
715
719
  };
716
720
  if (positional && input.subcommands?.includes(positional)) {
717
721
  adoption.subcommand = positional;
722
+ } else if (positional === undefined && input.defaultSubcommand) {
723
+ adoption.subcommand = input.defaultSubcommand;
718
724
  }
719
725
  let queryText;
720
726
  if (command === "search")
@@ -742,6 +748,8 @@ function buildSearchAdoptionTelemetry(input) {
742
748
  }
743
749
  if (recorded.has_more)
744
750
  adoption.has_more = recorded.has_more;
751
+ if (recorded.degrade_reason)
752
+ adoption.degrade_reason = recorded.degrade_reason;
745
753
  const skill = input.skillVersion?.trim();
746
754
  if (skill)
747
755
  adoption.skill_version = skill.slice(0, 64);
@@ -776,6 +784,9 @@ function serializeAdoption(adoption) {
776
784
  out.zero_result = adoption.zero_result;
777
785
  if (adoption.has_more)
778
786
  out.has_more = adoption.has_more;
787
+ const degradeReason = sanitizeReasonCode(adoption.degrade_reason, DEGRADE_REASON_MAX);
788
+ if (degradeReason)
789
+ out.degrade_reason = degradeReason;
779
790
  if (adoption.used_msg_index !== undefined) {
780
791
  out.used_msg_index = adoption.used_msg_index ? 1 : 0;
781
792
  }
@@ -791,52 +802,152 @@ function isTelemetryDisabled(flags) {
791
802
  return flags[TELEMETRY_FLAG] === "true" || process.env.MODA_CLI_TELEMETRY === "0" || process.env.DO_NOT_TRACK === "1";
792
803
  }
793
804
  var VALIDATION_REASON_MAX = 128;
794
- function sanitizeValidationReason(reason) {
795
- const cleaned = reason?.replace(/[^A-Za-z0-9_.:-]/g, "_").slice(0, VALIDATION_REASON_MAX);
805
+ var DEGRADE_REASON_MAX = 64;
806
+ function sanitizeReasonCode(reason, max) {
807
+ const cleaned = reason?.replace(/[^A-Za-z0-9_.:-]/g, "_").slice(0, max);
796
808
  return cleaned ? cleaned : undefined;
797
809
  }
810
+ function sanitizeValidationReason(reason) {
811
+ return sanitizeReasonCode(reason, VALIDATION_REASON_MAX);
812
+ }
798
813
  function sanitizedFlagNames(flags) {
799
814
  return Object.keys(stripTelemetryFlag(flags)).sort();
800
815
  }
801
- async function sendCliUsageTelemetry(input) {
802
- if (!input.apiKey || isTelemetryDisabled(input.flags)) {
803
- return;
816
+ var TELEMETRY_SENDER_SCRIPT = [
817
+ "try {",
818
+ ` const raw = process.env.${TELEMETRY_REQUEST_ENV};`,
819
+ ` delete process.env.${TELEMETRY_REQUEST_ENV};`,
820
+ " const r = raw ? JSON.parse(raw) : null;",
821
+ " if (r && typeof r.url === 'string' && typeof fetch === 'function') {",
822
+ " const c = new AbortController();",
823
+ ` const t = setTimeout(() => c.abort(), ${DETACHED_TELEMETRY_TIMEOUT_MS});`,
824
+ " fetch(r.url, { method: 'POST', headers: r.headers, body: r.body, signal: c.signal })",
825
+ " .then((res) => (res.body && res.body.cancel ? res.body.cancel() : undefined))",
826
+ " .catch(() => {})",
827
+ " .finally(() => clearTimeout(t));",
828
+ " }",
829
+ "} catch {}"
830
+ ].join(`
831
+ `);
832
+ var INSPECTOR_VALUE_OPTIONS = new Set(["--inspect-port", "--debug-port", "--inspect-publish-uid"]);
833
+ function nodeOptionTokens(nodeOptions) {
834
+ const tokens = [];
835
+ let start = -1;
836
+ let quoted = false;
837
+ for (let i = 0;i < nodeOptions.length; i += 1) {
838
+ const ch = nodeOptions[i];
839
+ if (start === -1) {
840
+ if (/\s/.test(ch))
841
+ continue;
842
+ start = i;
843
+ }
844
+ if (quoted && ch === "\\") {
845
+ i += 1;
846
+ } else if (ch === '"') {
847
+ quoted = !quoted;
848
+ } else if (!quoted && /\s/.test(ch)) {
849
+ tokens.push(nodeOptions.slice(start, i));
850
+ start = -1;
851
+ }
804
852
  }
805
- const validationReason = sanitizeValidationReason(input.validationReason);
853
+ if (start !== -1)
854
+ tokens.push(nodeOptions.slice(start));
855
+ return tokens;
856
+ }
857
+ function withoutInspectorOptions(nodeOptions) {
858
+ const tokens = nodeOptionTokens(nodeOptions);
859
+ const kept = [];
860
+ for (let i = 0;i < tokens.length; i += 1) {
861
+ const name = tokens[i].split("=")[0];
862
+ if (!name.startsWith("--inspect") && name !== "--debug-port") {
863
+ kept.push(tokens[i]);
864
+ continue;
865
+ }
866
+ if (INSPECTOR_VALUE_OPTIONS.has(tokens[i]) && tokens[i + 1] && !tokens[i + 1].startsWith("-"))
867
+ i += 1;
868
+ }
869
+ return kept.join(" ");
870
+ }
871
+ function spawnDetachedTelemetrySender(request, spawnImpl = spawn) {
872
+ try {
873
+ const env = { ...process.env, [TELEMETRY_REQUEST_ENV]: JSON.stringify(request) };
874
+ if (env.NODE_OPTIONS?.includes("--inspect")) {
875
+ const kept = withoutInspectorOptions(env.NODE_OPTIONS);
876
+ if (kept)
877
+ env.NODE_OPTIONS = kept;
878
+ else
879
+ delete env.NODE_OPTIONS;
880
+ }
881
+ const child = spawnImpl(process.execPath, ["-e", TELEMETRY_SENDER_SCRIPT], {
882
+ detached: true,
883
+ stdio: "ignore",
884
+ windowsHide: true,
885
+ env
886
+ });
887
+ child.on("error", () => {});
888
+ if (child.pid === undefined)
889
+ return false;
890
+ child.unref();
891
+ return true;
892
+ } catch {
893
+ return false;
894
+ }
895
+ }
896
+ async function sendInline(request) {
806
897
  const controller = new AbortController;
807
- const timeout = setTimeout(() => controller.abort(), TELEMETRY_TIMEOUT_MS);
898
+ const timeout = setTimeout(() => controller.abort(), INLINE_TELEMETRY_TIMEOUT_MS);
808
899
  if (typeof timeout.unref === "function") {
809
900
  timeout.unref();
810
901
  }
811
902
  try {
812
- await fetch(`${resolveModaBaseUrl({ profile: input.profile })}/api/v1/data/cli-usage`, {
903
+ await fetch(request.url, {
813
904
  method: "POST",
814
- headers: {
815
- ...apiKeyHeaders(input.apiKey),
816
- "Content-Type": "application/json"
817
- },
818
- body: JSON.stringify({
819
- invocation_id: INVOCATION_ID,
820
- command: input.command.slice(0, 64),
821
- status: input.status,
822
- error_type: input.errorType,
823
- ...validationReason ? { validation_reason: validationReason } : {},
824
- exit_code: input.exitCode,
825
- duration_ms: clampInt(input.durationMs, 0, MAX_TELEMETRY_DURATION_MS) ?? 0,
826
- api_request_count: clampInt(input.apiRequestCount, 0, MAX_TELEMETRY_API_REQUEST_COUNT) ?? 0,
827
- cli_version: VERSION,
828
- node_version: process.versions.node,
829
- platform: process.platform,
830
- arch: process.arch,
831
- flags_json: { names: sanitizedFlagNames(input.flags) },
832
- ...serializeAdoption(input.adoption)
833
- }),
905
+ headers: request.headers,
906
+ body: request.body,
834
907
  signal: controller.signal
835
908
  });
836
909
  } catch {} finally {
837
910
  clearTimeout(timeout);
838
911
  }
839
912
  }
913
+ function buildCliUsageRequest(input) {
914
+ const validationReason = sanitizeValidationReason(input.validationReason);
915
+ return {
916
+ url: `${resolveModaBaseUrl({ profile: input.profile })}/api/v1/data/cli-usage`,
917
+ headers: {
918
+ ...apiKeyHeaders(input.apiKey),
919
+ "Content-Type": "application/json"
920
+ },
921
+ body: JSON.stringify({
922
+ invocation_id: INVOCATION_ID,
923
+ command: input.command.slice(0, 64),
924
+ status: input.status,
925
+ error_type: input.errorType,
926
+ ...validationReason ? { validation_reason: validationReason } : {},
927
+ exit_code: input.exitCode,
928
+ duration_ms: clampInt(input.durationMs, 0, MAX_TELEMETRY_DURATION_MS) ?? 0,
929
+ api_request_count: clampInt(input.apiRequestCount, 0, MAX_TELEMETRY_API_REQUEST_COUNT) ?? 0,
930
+ cli_version: VERSION,
931
+ node_version: process.versions.node,
932
+ platform: process.platform,
933
+ arch: process.arch,
934
+ flags_json: { names: sanitizedFlagNames(input.flags) },
935
+ ...serializeAdoption(input.adoption)
936
+ })
937
+ };
938
+ }
939
+ async function sendCliUsageTelemetry(input) {
940
+ try {
941
+ if (!input.apiKey || isTelemetryDisabled(input.flags)) {
942
+ return;
943
+ }
944
+ const request = buildCliUsageRequest({ ...input, apiKey: input.apiKey });
945
+ if (process.env[TELEMETRY_TRANSPORT_ENV] !== "inline" && spawnDetachedTelemetrySender(request)) {
946
+ return;
947
+ }
948
+ await sendInline(request);
949
+ } catch {}
950
+ }
840
951
 
841
952
  // src/update-check.ts
842
953
  import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
@@ -2255,6 +2366,7 @@ var META_SWITCHES = new Set([
2255
2366
  "no-telemetry",
2256
2367
  "no-update-check"
2257
2368
  ]);
2369
+ var AGENT_VALUE_COMMANDS = new Set(["harness", "sync"]);
2258
2370
  var COMMAND_BOOLEAN_FLAGS = {
2259
2371
  context: new Set(["all", "metadata-only"])
2260
2372
  };
@@ -2280,7 +2392,7 @@ function parseFlag(args, index, flags, beforeCommand, bareFlags, command = "") {
2280
2392
  return index;
2281
2393
  }
2282
2394
  const switchName = key.replace(/_/g, "-");
2283
- if (META_SWITCHES.has(switchName)) {
2395
+ if (META_SWITCHES.has(switchName) || switchName === "agent" && !AGENT_VALUE_COMMANDS.has(command)) {
2284
2396
  set(key, "true", true);
2285
2397
  return index;
2286
2398
  }
@@ -3123,7 +3235,8 @@ function recordSearchTelemetry(context, data) {
3123
3235
  context.recordTelemetry({
3124
3236
  search_mode_effective: SEARCH_MODES2.includes(effective) ? effective : undefined,
3125
3237
  result_count: results.length,
3126
- has_more: hasMore === true ? "yes" : hasMore === false ? "no" : "na"
3238
+ has_more: hasMore === true ? "yes" : hasMore === false ? "no" : "na",
3239
+ ...typeof record.degrade_reason === "string" && record.degrade_reason ? { degrade_reason: record.degrade_reason.slice(0, 64) } : {}
3127
3240
  });
3128
3241
  }
3129
3242
  function recordConversationsTelemetry(context, data) {
@@ -4879,6 +4992,13 @@ async function runCommand(command, positional, flags, positionals = positional ?
4879
4992
  function telemetryCommandName(definition) {
4880
4993
  return definition.telemetryCommand ?? definition.name;
4881
4994
  }
4995
+ var TELEMETRY_EXEMPT_COMMANDS = {};
4996
+ function telemetrySubcommandNames(definition) {
4997
+ return [
4998
+ ...definition.subcommands?.map((subcommand) => subcommand.name) ?? [],
4999
+ ...definition.telemetrySubcommands ?? []
5000
+ ];
5001
+ }
4882
5002
  var OFFLINE_PROMPTS_SUBCOMMANDS = new Set(["init", "status", "diff", "migrate"]);
4883
5003
  function legacyCommand(metadata) {
4884
5004
  return {
@@ -4973,7 +5093,7 @@ var commandRegistry = createCommandRegistry([
4973
5093
  mutability: "write",
4974
5094
  validateConfigBeforeRun: false,
4975
5095
  resetApiRequestCountBeforeRun: true,
4976
- telemetry: "result",
5096
+ telemetry: "result-and-error",
4977
5097
  handler: async (context) => {
4978
5098
  const { runInit } = await import("./index-ccdpy9ma.js");
4979
5099
  if (context.outputMode === "agent-stream") {
@@ -5031,7 +5151,7 @@ var commandRegistry = createCommandRegistry([
5031
5151
  mutability: "read",
5032
5152
  validateConfigBeforeRun: false,
5033
5153
  resetApiRequestCountBeforeRun: false,
5034
- telemetry: "none",
5154
+ telemetry: "result-and-error",
5035
5155
  handler: async (context) => {
5036
5156
  const manifest = buildManifest(commandRegistry.all());
5037
5157
  if (context.outputMode === "human") {
@@ -5138,7 +5258,7 @@ var commandRegistry = createCommandRegistry([
5138
5258
  mutability: "write",
5139
5259
  validateConfigBeforeRun: false,
5140
5260
  resetApiRequestCountBeforeRun: false,
5141
- telemetry: "none",
5261
+ telemetry: "result-and-error",
5142
5262
  handler: runAuthCommand
5143
5263
  },
5144
5264
  {
@@ -5150,7 +5270,7 @@ var commandRegistry = createCommandRegistry([
5150
5270
  mutability: "read",
5151
5271
  validateConfigBeforeRun: false,
5152
5272
  resetApiRequestCountBeforeRun: false,
5153
- telemetry: "none",
5273
+ telemetry: "result-and-error",
5154
5274
  handler: runStatusCommand
5155
5275
  },
5156
5276
  {
@@ -5163,7 +5283,7 @@ var commandRegistry = createCommandRegistry([
5163
5283
  mutability: "read",
5164
5284
  validateConfigBeforeRun: false,
5165
5285
  resetApiRequestCountBeforeRun: false,
5166
- telemetry: "none",
5286
+ telemetry: "result-and-error",
5167
5287
  handler: runDoctorCommand
5168
5288
  },
5169
5289
  {
@@ -5175,7 +5295,8 @@ var commandRegistry = createCommandRegistry([
5175
5295
  mutability: "write",
5176
5296
  validateConfigBeforeRun: false,
5177
5297
  resetApiRequestCountBeforeRun: false,
5178
- telemetry: "none",
5298
+ telemetry: "result-and-error",
5299
+ telemetrySubcommands: ["list", "use", "create", "doctor"],
5179
5300
  handler: runProfilesCommand
5180
5301
  },
5181
5302
  {
@@ -5187,7 +5308,8 @@ var commandRegistry = createCommandRegistry([
5187
5308
  mutability: "read",
5188
5309
  validateConfigBeforeRun: false,
5189
5310
  resetApiRequestCountBeforeRun: false,
5190
- telemetry: "none",
5311
+ telemetry: "result-and-error",
5312
+ telemetrySubcommands: ["show"],
5191
5313
  handler: runConfigCommand
5192
5314
  },
5193
5315
  {
@@ -5210,7 +5332,8 @@ var commandRegistry = createCommandRegistry([
5210
5332
  mutability: "write",
5211
5333
  validateConfigBeforeRun: false,
5212
5334
  resetApiRequestCountBeforeRun: false,
5213
- telemetry: "none",
5335
+ telemetry: "result-and-error",
5336
+ defaultSubcommand: "scan",
5214
5337
  handler: runHarnessCommand
5215
5338
  },
5216
5339
  {
@@ -5226,7 +5349,9 @@ var commandRegistry = createCommandRegistry([
5226
5349
  mutability: "read",
5227
5350
  validateConfigBeforeRun: false,
5228
5351
  resetApiRequestCountBeforeRun: false,
5229
- telemetry: "none",
5352
+ telemetry: "result-and-error",
5353
+ telemetrySubcommands: ["context", "next-action", "next-actions", "evidence", "investigate"],
5354
+ defaultSubcommand: "context",
5230
5355
  handler: runAgentCommand
5231
5356
  },
5232
5357
  {
@@ -5242,7 +5367,9 @@ var commandRegistry = createCommandRegistry([
5242
5367
  mutability: "write",
5243
5368
  validateConfigBeforeRun: false,
5244
5369
  resetApiRequestCountBeforeRun: false,
5245
- telemetry: "none",
5370
+ telemetry: "result-and-error",
5371
+ telemetrySubcommands: ["harness", "prompts", "skills"],
5372
+ defaultSubcommand: "harness",
5246
5373
  handler: runSyncCommand
5247
5374
  },
5248
5375
  {
@@ -5382,7 +5509,8 @@ var commandRegistry = createCommandRegistry([
5382
5509
  mutability: "write",
5383
5510
  validateConfigBeforeRun: false,
5384
5511
  resetApiRequestCountBeforeRun: false,
5385
- telemetry: "none",
5512
+ telemetry: "result-and-error",
5513
+ defaultSubcommand: "push",
5386
5514
  handler: runRegistryCommand
5387
5515
  },
5388
5516
  legacyCommand({
@@ -5520,6 +5648,7 @@ var commandRegistry = createCommandRegistry([
5520
5648
  description: "Rank cross-signal Problems by root cause (what to fix first)",
5521
5649
  examples: ["moda problems", "moda problems --days-back=7 --limit=10", "moda problems remainder --family=emotion"],
5522
5650
  subcommands: PROBLEMS_SUBCOMMAND_HELP,
5651
+ defaultSubcommand: "list",
5523
5652
  ...dataApiDefaults
5524
5653
  }),
5525
5654
  legacyCommand({
@@ -5634,6 +5763,7 @@ var commandRegistry = createCommandRegistry([
5634
5763
  "moda signals activate <signal_id>"
5635
5764
  ],
5636
5765
  subcommands: SIGNALS_SUBCOMMAND_HELP,
5766
+ defaultSubcommand: "list",
5637
5767
  ...dataApiDefaults,
5638
5768
  mutability: "write"
5639
5769
  }),
@@ -5821,7 +5951,8 @@ var commandRegistry = createCommandRegistry([
5821
5951
  mutability: "write",
5822
5952
  validateConfigBeforeRun: (parsed) => !OFFLINE_PROMPTS_SUBCOMMANDS.has(parsed.positional ?? "status"),
5823
5953
  resetApiRequestCountBeforeRun: true,
5824
- telemetry: "result-and-error"
5954
+ telemetry: "result-and-error",
5955
+ defaultSubcommand: "status"
5825
5956
  }),
5826
5957
  {
5827
5958
  name: "skills",
@@ -5841,7 +5972,7 @@ var commandRegistry = createCommandRegistry([
5841
5972
  mutability: "write",
5842
5973
  validateConfigBeforeRun: false,
5843
5974
  resetApiRequestCountBeforeRun: false,
5844
- telemetry: "result",
5975
+ telemetry: "result-and-error",
5845
5976
  handler: async (context) => ({
5846
5977
  exitCode: await runSkillsCommand(context)
5847
5978
  })
@@ -5861,9 +5992,10 @@ var commandRegistry = createCommandRegistry([
5861
5992
  outputModes: ["human", "json", "agent"],
5862
5993
  mutability: "write",
5863
5994
  subcommands: FIXES_SUBCOMMAND_HELP,
5995
+ defaultSubcommand: "list",
5864
5996
  validateConfigBeforeRun: false,
5865
5997
  resetApiRequestCountBeforeRun: false,
5866
- telemetry: "result",
5998
+ telemetry: "result-and-error",
5867
5999
  handler: async (context) => ({
5868
6000
  exitCode: await runFixesCommand(context)
5869
6001
  })
@@ -5887,7 +6019,7 @@ var commandRegistry = createCommandRegistry([
5887
6019
  mutability: "write",
5888
6020
  validateConfigBeforeRun: false,
5889
6021
  resetApiRequestCountBeforeRun: false,
5890
- telemetry: "result",
6022
+ telemetry: "result-and-error",
5891
6023
  handler: async (context) => ({
5892
6024
  exitCode: await runFixCommand(context)
5893
6025
  })
@@ -6003,6 +6135,12 @@ function printAgentCliError(command, error, mode = "agent") {
6003
6135
  });
6004
6136
  output.writeError(error);
6005
6137
  }
6138
+ function existingFlagProfile(flags) {
6139
+ const name = flags.profile;
6140
+ if (!name || name === "true")
6141
+ return;
6142
+ return Object.hasOwn(loadProfileConfig({ env: process.env }).profiles, name) ? name : undefined;
6143
+ }
6006
6144
  async function dispatchParsedCommand(parsed, startedAt = Date.now()) {
6007
6145
  const previousProfileEnv = process.env.MODA_PROFILE;
6008
6146
  try {
@@ -6055,8 +6193,7 @@ async function dispatchParsedCommandInner(parsed, startedAt) {
6055
6193
  const telemetryOptOut = telemetryDisabled || flags["no-telemetry"] !== undefined && flags["no-telemetry"] !== "false";
6056
6194
  if (commandDefinition && !telemetryOptOut && commandDefinition.telemetry === "result-and-error") {
6057
6195
  const telemetryCommand2 = telemetryCommandName(commandDefinition);
6058
- const flagProfile = commandFlags.profile && commandFlags.profile !== "true" ? commandFlags.profile : undefined;
6059
- const telemetryProfile = flagProfile && Object.hasOwn(loadProfileConfig({ env: process.env }).profiles, flagProfile) ? flagProfile : undefined;
6196
+ const telemetryProfile = existingFlagProfile(commandFlags);
6060
6197
  sendCliUsageTelemetry({
6061
6198
  apiKey: resolveApiKey({ profile: telemetryProfile }),
6062
6199
  profile: telemetryProfile,
@@ -6075,7 +6212,8 @@ async function dispatchParsedCommandInner(parsed, startedAt) {
6075
6212
  outputMode: mode,
6076
6213
  recorded: {},
6077
6214
  skillVersion: process.env.MODA_SKILL_VERSION,
6078
- subcommands: commandDefinition.subcommands?.map((subcommand) => subcommand.name)
6215
+ subcommands: telemetrySubcommandNames(commandDefinition),
6216
+ defaultSubcommand: commandDefinition.defaultSubcommand
6079
6217
  })
6080
6218
  });
6081
6219
  }
@@ -6130,15 +6268,17 @@ async function dispatchParsedCommandInner(parsed, startedAt) {
6130
6268
  });
6131
6269
  setActiveContext(context);
6132
6270
  const telemetryCommand = telemetryCommandName(definition);
6133
- const telemetrySubcommands = definition.subcommands?.map((subcommand) => subcommand.name);
6271
+ const telemetrySubcommands = telemetrySubcommandNames(definition);
6134
6272
  const needsConfig = typeof definition.validateConfigBeforeRun === "function" ? definition.validateConfigBeforeRun(parsed) : definition.validateConfigBeforeRun;
6135
6273
  if (needsConfig) {
6136
6274
  try {
6137
6275
  validateConfig();
6138
6276
  } catch (error) {
6139
6277
  if (!telemetryDisabled && definition.telemetry === "result-and-error") {
6278
+ const telemetryProfile = existingFlagProfile(commandFlags);
6140
6279
  sendCliUsageTelemetry({
6141
- apiKey: resolveApiKey(),
6280
+ apiKey: resolveApiKey({ profile: telemetryProfile }),
6281
+ profile: telemetryProfile,
6142
6282
  command: telemetryCommand,
6143
6283
  flags: commandFlags,
6144
6284
  status: "error",
@@ -6154,7 +6294,8 @@ async function dispatchParsedCommandInner(parsed, startedAt) {
6154
6294
  outputMode: context.outputMode,
6155
6295
  recorded: context.getTelemetryMeta(),
6156
6296
  skillVersion: process.env.MODA_SKILL_VERSION,
6157
- subcommands: telemetrySubcommands
6297
+ subcommands: telemetrySubcommands,
6298
+ defaultSubcommand: definition.defaultSubcommand
6158
6299
  })
6159
6300
  });
6160
6301
  }
@@ -6172,8 +6313,10 @@ async function dispatchParsedCommandInner(parsed, startedAt) {
6172
6313
  try {
6173
6314
  const result = await definition.handler(context);
6174
6315
  if (!telemetryDisabled && definition.telemetry !== "none") {
6316
+ const telemetryProfile = existingFlagProfile(commandFlags);
6175
6317
  sendCliUsageTelemetry({
6176
- apiKey: result.apiKey ?? resolveApiKey(),
6318
+ apiKey: result.apiKey ?? resolveApiKey({ profile: telemetryProfile }),
6319
+ profile: telemetryProfile,
6177
6320
  command: telemetryCommand,
6178
6321
  flags: commandFlags,
6179
6322
  status: result.exitCode === 0 ? "success" : "error",
@@ -6187,7 +6330,8 @@ async function dispatchParsedCommandInner(parsed, startedAt) {
6187
6330
  outputMode: context.outputMode,
6188
6331
  recorded: context.getTelemetryMeta(),
6189
6332
  skillVersion: process.env.MODA_SKILL_VERSION,
6190
- subcommands: telemetrySubcommands
6333
+ subcommands: telemetrySubcommands,
6334
+ defaultSubcommand: definition.defaultSubcommand
6191
6335
  })
6192
6336
  });
6193
6337
  }
@@ -6198,8 +6342,10 @@ async function dispatchParsedCommandInner(parsed, startedAt) {
6198
6342
  return finishRun(context, { kind: "completed", exitCode: result.exitCode });
6199
6343
  } catch (error) {
6200
6344
  if (!telemetryDisabled && definition.telemetry === "result-and-error") {
6345
+ const telemetryProfile = existingFlagProfile(commandFlags);
6201
6346
  sendCliUsageTelemetry({
6202
- apiKey: resolveApiKey(),
6347
+ apiKey: resolveApiKey({ profile: telemetryProfile }),
6348
+ profile: telemetryProfile,
6203
6349
  command: telemetryCommand,
6204
6350
  flags: commandFlags,
6205
6351
  status: "error",
@@ -6215,7 +6361,8 @@ async function dispatchParsedCommandInner(parsed, startedAt) {
6215
6361
  outputMode: context.outputMode,
6216
6362
  recorded: context.getTelemetryMeta(),
6217
6363
  skillVersion: process.env.MODA_SKILL_VERSION,
6218
- subcommands: telemetrySubcommands
6364
+ subcommands: telemetrySubcommands,
6365
+ defaultSubcommand: definition.defaultSubcommand
6219
6366
  })
6220
6367
  });
6221
6368
  }
@@ -6267,6 +6414,7 @@ if (isMain) {
6267
6414
  });
6268
6415
  }
6269
6416
  export {
6417
+ telemetrySubcommandNames,
6270
6418
  telemetryCommandName,
6271
6419
  stripLoneSurrogates,
6272
6420
  searchOutcomeWarnings,
@@ -6290,6 +6438,7 @@ export {
6290
6438
  capProblemsBlocks,
6291
6439
  buildResumeCommand,
6292
6440
  auditCapStatus,
6441
+ TELEMETRY_EXEMPT_COMMANDS,
6293
6442
  TAIL_LIMITS,
6294
6443
  RAW_BOOLEAN_FLAGS,
6295
6444
  LEGACY_WINDOW_MAX_MESSAGES,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moda-ai/cli",
3
- "version": "1.55.15",
3
+ "version": "1.55.16",
4
4
  "description": "CLI for Moda: production monitoring and evals for AI agents.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schema_version": "moda.skill_index.v1",
3
- "bundled_at": "2026-10-15T06:17:15.907Z",
4
- "cli_version": "1.55.15",
3
+ "bundled_at": "2026-10-15T06:39:15.616Z",
4
+ "cli_version": "1.55.16",
5
5
  "skills": [
6
6
  {
7
7
  "id": "integration-cloudflare-think",