@2kw/ai 6.3.0-dev.43 → 6.3.0-dev.45

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.
@@ -1,10 +1,11 @@
1
1
  import { Command } from "commander";
2
2
  import { getClient, runAction } from "../lib/client.js";
3
3
  import { formatDetail, formatList } from "../lib/output.js";
4
+ import { tracingSettingsBody } from "../lib/tracing-settings.js";
4
5
  export function makeTracingCommand() {
5
6
  const cmd = new Command("tracing").description("Traces and per-org tracing settings (prompt / completion capture)");
6
7
  // ── settings ──────────────────────────────────────────────────
7
- const settings = new Command("settings").description("Manage per-org tracing settings (includePrompts / includeCompletions)");
8
+ const settings = new Command("settings").description("Manage per-org tracing settings (PII capture and trace retention)");
8
9
  settings
9
10
  .command("get")
10
11
  .description("Show current tracing settings")
@@ -20,6 +21,7 @@ export function makeTracingCommand() {
20
21
  .description("Update tracing settings. Both toggles control PII capture — default is false for both.")
21
22
  .option("--include-prompts <bool>", "Retain prompt content on ingested spans (true/false)")
22
23
  .option("--include-completions <bool>", "Retain completion content on ingested spans (true/false)")
24
+ .option("--retention-days <days>", 'Trace retention in days, at most your plan\'s limit, or "plan" to follow the plan. Shortening deletes older traces at the next daily sweep.')
23
25
  .action(async (opts, command) => {
24
26
  await runAction(command, async () => {
25
27
  const client = getClient(command);
@@ -27,17 +29,8 @@ export function makeTracingCommand() {
27
29
  // resetting the other. Otherwise an unset flag defaults to false
28
30
  // and silently disables capture the admin had already enabled.
29
31
  const { data: current } = await client.GET("/v1/tracing/settings");
30
- const body = {
31
- includePrompts: opts.includePrompts !== undefined
32
- ? opts.includePrompts === "true"
33
- : (current?.includePrompts ?? false),
34
- includeCompletions: opts.includeCompletions !== undefined
35
- ? opts.includeCompletions === "true"
36
- : (current?.includeCompletions ?? false),
37
- };
38
- const { data } = await client.PUT("/v1/tracing/settings", {
39
- body,
40
- });
32
+ const body = tracingSettingsBody(current, opts);
33
+ const { data } = await client.PUT("/v1/tracing/settings", { body });
41
34
  formatDetail(data, command);
42
35
  });
43
36
  });
@@ -0,0 +1,26 @@
1
+ /** The options of `tracing settings set`, as commander hands them over. */
2
+ export interface TracingSettingsOptions {
3
+ includePrompts?: string;
4
+ includeCompletions?: string;
5
+ retentionDays?: string;
6
+ }
7
+ /** The fields of a GET this command carries through. */
8
+ export interface TracingSettingsCurrent {
9
+ includePrompts?: boolean;
10
+ includeCompletions?: boolean;
11
+ retentionDays?: number | null;
12
+ }
13
+ export interface TracingSettingsBody {
14
+ includePrompts: boolean;
15
+ includeCompletions: boolean;
16
+ retentionDays: number | null;
17
+ }
18
+ /**
19
+ * The PUT body: the options given, and the current value of everything else. The PUT is a
20
+ * full replace (#1015), so a field left out would reset: a missing retentionDays would
21
+ * follow the plan again and undo the admin's shorter choice.
22
+ */
23
+ export declare function tracingSettingsBody(current: TracingSettingsCurrent | undefined, opts: TracingSettingsOptions): TracingSettingsBody;
24
+ /** `plan` follows the plan's limit; anything else must be a whole number of days, 1 or more. */
25
+ export declare function parseRetentionDays(value: string): number | null;
26
+ //# sourceMappingURL=tracing-settings.d.ts.map
@@ -0,0 +1,25 @@
1
+ import { CliUsageError } from "./errors.js";
2
+ /**
3
+ * The PUT body: the options given, and the current value of everything else. The PUT is a
4
+ * full replace (#1015), so a field left out would reset: a missing retentionDays would
5
+ * follow the plan again and undo the admin's shorter choice.
6
+ */
7
+ export function tracingSettingsBody(current, opts) {
8
+ return {
9
+ includePrompts: opts.includePrompts !== undefined ? opts.includePrompts === "true" : (current?.includePrompts ?? false),
10
+ includeCompletions: opts.includeCompletions !== undefined
11
+ ? opts.includeCompletions === "true"
12
+ : (current?.includeCompletions ?? false),
13
+ retentionDays: opts.retentionDays !== undefined ? parseRetentionDays(opts.retentionDays) : (current?.retentionDays ?? null),
14
+ };
15
+ }
16
+ /** `plan` follows the plan's limit; anything else must be a whole number of days, 1 or more. */
17
+ export function parseRetentionDays(value) {
18
+ if (value === "plan")
19
+ return null;
20
+ if (!/^[1-9]\d*$/.test(value)) {
21
+ throw new CliUsageError(`--retention-days must be a whole number of days (1 or more) or "plan", got "${value}".`);
22
+ }
23
+ return Number(value);
24
+ }
25
+ //# sourceMappingURL=tracing-settings.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@2kw/ai",
3
- "version": "6.3.0-dev.43",
3
+ "version": "6.3.0-dev.45",
4
4
  "description": "CLI for 2kw.ai — schema-driven document extraction, an OpenAI-compatible EU LLM gateway, transcription, prompts, datasets, and experiments from your terminal or agentic workflows. Ships as 2kw, backbone, and bb.",
5
5
  "keywords": [
6
6
  "cli",