lua-cli 3.39.2 → 3.39.3

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/index.js CHANGED
@@ -1586,6 +1586,7 @@ function utf8Bytes(value3) {
1586
1586
  }
1587
1587
  function isPlainFieldKey(key) {
1588
1588
  if (!LOG_FIELD_KEY_PATTERN.test(key)) return false;
1589
+ if (key === LOG_FIELDS_CLAMPED_KEY) return false;
1589
1590
  return !LOG_FIELD_SECRET_SHAPED_KEY_PATTERNS.some((pattern) => pattern.test(key));
1590
1591
  }
1591
1592
  function describeAgentLogFieldsViolation(value3) {
@@ -50379,7 +50380,7 @@ function wantsContent(options, sources) {
50379
50380
  return (sources ?? []).some((source) => LOG_DRAIN_CONTENT_SOURCES.includes(source));
50380
50381
  }
50381
50382
  __name(wantsContent, "wantsContent");
50382
- async function acknowledgeContent(options, becauseOfFlag = true) {
50383
+ async function acknowledgeContent(options, becauseOfFlag = true, nothingHint = "Nothing was created") {
50383
50384
  emitAside("", options.json);
50384
50385
  emitAside(CONTENT_WARNING_TEXT, options.json);
50385
50386
  emitAside("", options.json);
@@ -50387,7 +50388,7 @@ async function acknowledgeContent(options, becauseOfFlag = true) {
50387
50388
  emitAside("", options.json);
50388
50389
  if (options.yes) return true;
50389
50390
  if (isCiModeEnabled()) {
50390
- throw CliError.usage(becauseOfFlag ? "--include-content needs the acknowledgement above; pass --yes to give it non-interactively." : "Selecting user_message or agent_response needs the acknowledgement above; pass --yes to give it non-interactively. (Content bodies stay OFF unless you also pass --include-content.)", "Nothing was created");
50391
+ throw CliError.usage(becauseOfFlag ? "--include-content needs the acknowledgement above; pass --yes to give it non-interactively." : "Selecting user_message or agent_response needs the acknowledgement above; pass --yes to give it non-interactively. (Content bodies stay OFF unless you also pass --include-content.)", nothingHint);
50391
50392
  }
50392
50393
  const answer = await safePrompt([
50393
50394
  {
@@ -50398,7 +50399,7 @@ async function acknowledgeContent(options, becauseOfFlag = true) {
50398
50399
  }
50399
50400
  ]);
50400
50401
  if (!answer?.acknowledged) {
50401
- throw CliError.usage("Content was not enabled: the acknowledgement was declined.", "Nothing was created");
50402
+ throw CliError.usage("Content was not enabled: the acknowledgement was declined.", nothingHint);
50402
50403
  }
50403
50404
  return true;
50404
50405
  }
@@ -51710,6 +51711,8 @@ var LOG_EXPORT_DOWNLOAD = {
51710
51711
  };
51711
51712
  var ALREADY_RUNNING = "EXPORT_ALREADY_RUNNING";
51712
51713
  var MISSING_EXPORT_SCOPE_MESSAGE = "Missing scope: logs:read. Create a key with that scope (lua auth key) or ask an org admin.";
51714
+ var EXPORT_CONTENT_FORBIDDEN = "EXPORT_CONTENT_FORBIDDEN";
51715
+ var MISSING_EXPORT_CONTENT_SCOPE_MESSAGE = "Missing scope: logs:manage. Create a key with that scope (lua auth key) or ask an org admin.";
51713
51716
  var TERMINAL2 = /* @__PURE__ */ new Set([
51714
51717
  "succeeded",
51715
51718
  "failed",
@@ -51726,6 +51729,10 @@ async function logsExportCommand(cmdObj) {
51726
51729
  }
51727
51730
  const sources = parseTypeFlag(options.type);
51728
51731
  const outDir = options.out ? resolveOutDir(String(options.out)) : void 0;
51732
+ const includeContent = options.includeContent === true;
51733
+ if (includeContent) {
51734
+ await acknowledgeContent(options, true, "Nothing was exported");
51735
+ }
51729
51736
  const context = await resolveDrainsContext(options);
51730
51737
  const api = new LogExportApi(BASE_URLS.API, context.apiKey, context.orgId);
51731
51738
  const say = /* @__PURE__ */ __name((line) => {
@@ -51734,7 +51741,8 @@ async function logsExportCommand(cmdObj) {
51734
51741
  const jobId = await startOrAttach(api, {
51735
51742
  from: since,
51736
51743
  to: until ?? (/* @__PURE__ */ new Date()).toISOString(),
51737
- sources
51744
+ sources,
51745
+ includeContent
51738
51746
  }, say);
51739
51747
  if (options.noWait || options.wait === false) {
51740
51748
  emit2(options, {
@@ -51745,7 +51753,8 @@ async function logsExportCommand(cmdObj) {
51745
51753
  trackEvent("cli_logs_export", {
51746
51754
  waited: false,
51747
51755
  json_output: !!options.json,
51748
- downloaded: 0
51756
+ downloaded: 0,
51757
+ include_content: includeContent
51749
51758
  });
51750
51759
  return;
51751
51760
  }
@@ -51786,7 +51795,8 @@ async function logsExportCommand(cmdObj) {
51786
51795
  waited: true,
51787
51796
  json_output: !!options.json,
51788
51797
  downloaded: written.length,
51789
- truncated: !!job.truncated
51798
+ truncated: !!job.truncated,
51799
+ include_content: includeContent
51790
51800
  });
51791
51801
  },
51792
51802
  "logs export",
@@ -51820,6 +51830,11 @@ async function startOrAttach(api, input, say) {
51820
51830
  to: input.to,
51821
51831
  ...input.sources ? {
51822
51832
  sources: input.sources
51833
+ } : {},
51834
+ // Only ever sent as `true` — PRO-2182. `false`/absent both mean "no content", and the
51835
+ // server's own default is `false`, so there is nothing an omitted key would lose.
51836
+ ...input.includeContent ? {
51837
+ includeContent: true
51823
51838
  } : {}
51824
51839
  };
51825
51840
  const started = await callExport(() => api.startExport(body));
@@ -51874,7 +51889,7 @@ async function callExport(call) {
51874
51889
  return await call();
51875
51890
  } catch (error) {
51876
51891
  if (CliError.isCliError(error) && error.statusCode === 403) {
51877
- throw CliError.forbidden(MISSING_EXPORT_SCOPE_MESSAGE);
51892
+ throw CliError.forbidden(error.serverCode === EXPORT_CONTENT_FORBIDDEN ? MISSING_EXPORT_CONTENT_SCOPE_MESSAGE : MISSING_EXPORT_SCOPE_MESSAGE);
51878
51893
  }
51879
51894
  throw error;
51880
51895
  }
@@ -71704,7 +71719,7 @@ Notes:
71704
71719
  shift the window. --type calls reads voice calls and ignores --since/--until/--environment
71705
71720
  /--follow. --since is INCLUSIVE; the boundary row is de-duplicated by id while following.
71706
71721
  `).action(logsCommand);
71707
- logsGroup.command("export").description("\u{1F4E6} Export this organization's logs as gzip NDJSON (asynchronous job)").option("--since <when>", "Inclusive lower bound (REQUIRED): an ISO 8601 instant, or 24h | 7d").option("--until <when>", "Inclusive upper bound; same formats (default: now)").option("--type <type>", "Comma-separated log sources, or all (default: all)").option("--out <dir>", "Download the parts into this directory (created if missing)").option("--org <id>", "The organization to export (default: the project, or the key when it reaches one org)").option("--no-wait", "Start the export and print the job id without polling it").option("--json", "Output as JSON").addHelpText("after", `
71722
+ logsGroup.command("export").description("\u{1F4E6} Export this organization's logs as gzip NDJSON (asynchronous job)").option("--since <when>", "Inclusive lower bound (REQUIRED): an ISO 8601 instant, or 24h | 7d").option("--until <when>", "Inclusive upper bound; same formats (default: now)").option("--type <type>", "Comma-separated log sources, or all (default: all)").option("--out <dir>", "Download the parts into this directory (created if missing)").option("--org <id>", "The organization to export (default: the project, or the key when it reaches one org)").option("--no-wait", "Start the export and print the job id without polling it").option("--include-content", "Include user_message / agent_response bodies (requires logs:manage; prints an acknowledgement)").option("-y, --yes", "Give the --include-content acknowledgement non-interactively").option("--json", "Output as JSON").addHelpText("after", `
71708
71723
  Options:
71709
71724
  --since <when> REQUIRED. Inclusive lower bound: an ISO 8601 instant, or 24h | 7d
71710
71725
  --until <when> Inclusive upper bound, same formats (default: now)
@@ -71712,19 +71727,26 @@ Options:
71712
71727
  --out <dir> Download every part into this local directory
71713
71728
  --org <id> The organization, when the key reaches more than one
71714
71729
  --no-wait Start it and print the job id; poll later
71730
+ --include-content Include user_message / agent_response bodies. Requires logs:manage;
71731
+ prints the same content warning and acknowledgement as
71732
+ lua drains create --include-content
71733
+ -y, --yes Give that acknowledgement non-interactively
71715
71734
  --json Output as JSON for scripting
71716
71735
 
71717
71736
  Examples:
71718
71737
  $ lua logs export --since 7d --out ./export A week, downloaded
71719
71738
  $ lua logs export --since 30d --type skill,job A month, two sources
71720
71739
  $ lua logs export --since 24h --no-wait --json Start it and return
71740
+ $ lua logs export --since 24h --include-content --yes Include message bodies (logs:manage)
71721
71741
 
71722
71742
  Notes:
71723
71743
  The window is at most 31 days and the job at most 10 000 000 records; narrow the window
71724
71744
  or the sources rather than raising either. One export runs per organization at a time \u2014
71725
71745
  a second invocation FOLLOWS the running one instead of refusing. Download links expire
71726
- 24 h after the export finishes and the files are removed after 7 days. Message bodies
71727
- are excluded unless the export was started with the logs:manage scope.
71746
+ 24 h after the export finishes and the files are removed after 7 days. Message bodies are
71747
+ EXCLUDED BY DEFAULT and only ever included when --include-content is passed AND the
71748
+ acknowledgement is given AND the credential holds logs:manage \u2014 the scope alone is not
71749
+ enough, the flag is required too.
71728
71750
  `).action((options, command) => logsExportCommand(withGroupOptions(options ?? {}, command)));
71729
71751
  program2.command("skills [actionOrEnv] [action]").description("\u2699\uFE0F Manage and view skills").option("--skill-name <name>", "Skill name").option("--skill-version <version>", "Version for deploy action (or 'latest')").addHelpText("after", `
71730
71752
  Arguments: