@withone/cli 1.47.10 → 1.48.0

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/README.md CHANGED
@@ -272,7 +272,7 @@ one actions execute stripe <actionId> <connectionKey> \
272
272
  | `--dry-run` | Show the request without executing it |
273
273
  | `--mock` | Return example response without making an API call |
274
274
  | `--skip-validation` | Skip input validation against the action schema |
275
- | `--output <path>` | Save response to a file (for binary downloads) |
275
+ | `--output <path>` | Save response to a file (for genuine binary downloads — PDFs, images). Text responses (text/plain, HTML, CSV, XML) render inline automatically. |
276
276
  | `--no-cache` | Bypass the cached action details and re-fetch them; the fresh details still refresh the cache (execution itself is never cached) |
277
277
 
278
278
  The CLI validates required parameters (path variables, query params, body fields) against the action schema before executing. Missing params return a clear error with the flag name and description. Pass `--skip-validation` to bypass.
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-44CV5IMX.js";
5
5
  import {
6
6
  getCacheTtl
7
- } from "./chunk-K6MWE2ZH.js";
7
+ } from "./chunk-SO323PZP.js";
8
8
 
9
9
  // src/lib/flow-runner.ts
10
10
  import fs3 from "fs";
@@ -31,6 +31,31 @@ var ApiError = class extends Error {
31
31
  this.name = "ApiError";
32
32
  }
33
33
  };
34
+ function isTextualContentType(contentType) {
35
+ const ct = contentType.toLowerCase().split(";")[0].trim();
36
+ if (ct.startsWith("text/")) return true;
37
+ if (ct.endsWith("+json") || ct.endsWith("+xml")) return true;
38
+ return [
39
+ "application/json",
40
+ "application/xml",
41
+ "application/javascript",
42
+ "application/ecmascript",
43
+ "application/x-www-form-urlencoded",
44
+ "application/yaml",
45
+ "application/x-yaml",
46
+ "application/csv"
47
+ ].includes(ct);
48
+ }
49
+ function looksLikeText(s) {
50
+ if (s.length === 0) return true;
51
+ if (s.includes("\0") || s.includes("\uFFFD")) return false;
52
+ let control = 0;
53
+ for (let i = 0; i < s.length; i++) {
54
+ const c = s.charCodeAt(i);
55
+ if (c < 9 || c > 13 && c < 32 || c === 127) control++;
56
+ }
57
+ return control / s.length < 0.05;
58
+ }
34
59
  function parseRetryAfter(value) {
35
60
  if (!value) return void 0;
36
61
  const seconds = parseInt(value, 10);
@@ -388,11 +413,17 @@ var OneApi = class {
388
413
  throw new ApiError(response.status, text || `HTTP ${response.status}`);
389
414
  }
390
415
  const responseContentType = response.headers.get("content-type") || "";
391
- const isExplicitJson = responseContentType.includes("application/json") || responseContentType.includes("text/");
392
- if (isExplicitJson || !responseContentType) {
416
+ if (isTextualContentType(responseContentType) || !responseContentType) {
393
417
  const responseText2 = await response.text();
394
- const responseData = responseText2 ? JSON.parse(responseText2) : {};
395
- return { requestConfig: sanitizedConfig, responseData };
418
+ if (!responseText2) return { requestConfig: sanitizedConfig, responseData: {} };
419
+ try {
420
+ return { requestConfig: sanitizedConfig, responseData: JSON.parse(responseText2) };
421
+ } catch {
422
+ return {
423
+ requestConfig: sanitizedConfig,
424
+ responseData: { text: responseText2, contentType: responseContentType || "text/plain" }
425
+ };
426
+ }
396
427
  }
397
428
  if (args.output) {
398
429
  const outputPath = resolve(args.output);
@@ -414,6 +445,12 @@ var OneApi = class {
414
445
  const responseData = responseText ? JSON.parse(responseText) : {};
415
446
  return { requestConfig: sanitizedConfig, responseData };
416
447
  } catch {
448
+ if (looksLikeText(responseText)) {
449
+ return {
450
+ requestConfig: sanitizedConfig,
451
+ responseData: { text: responseText, contentType: responseContentType }
452
+ };
453
+ }
417
454
  const contentLength = response.headers.get("content-length");
418
455
  const size = contentLength ? parseInt(contentLength, 10) : responseText.length;
419
456
  return {
@@ -2282,7 +2319,7 @@ async function executeSubflowStep(step, context, api, permissions, allowedAction
2282
2319
  if (flowStack.includes(resolvedKey)) {
2283
2320
  throw new Error(`Circular flow detected: ${[...flowStack, resolvedKey].join(" \u2192 ")}`);
2284
2321
  }
2285
- const { loadFlowWithMeta: loadFlowWithMeta2 } = await import("./flow-runner-JNEFFR2U.js");
2322
+ const { loadFlowWithMeta: loadFlowWithMeta2 } = await import("./flow-runner-IBB42ED2.js");
2286
2323
  const { flow: subFlow, rootDir: subRootDir } = loadFlowWithMeta2(resolvedKey);
2287
2324
  const subContext = await executeFlow(
2288
2325
  subFlow,
@@ -5,10 +5,10 @@ import {
5
5
  getMemoryConfig,
6
6
  getMemoryConfigOrDefault,
7
7
  updateMemoryConfig
8
- } from "./chunk-TXTRXV74.js";
8
+ } from "./chunk-BV2NYIA7.js";
9
9
  import {
10
10
  getOpenAiApiKey
11
- } from "./chunk-K6MWE2ZH.js";
11
+ } from "./chunk-SO323PZP.js";
12
12
 
13
13
  // src/lib/memory/schema.ts
14
14
  var SCHEMA_VERSION = "2.1.0";
@@ -3,7 +3,7 @@ import {
3
3
  readConfig,
4
4
  setOpenAiApiKey,
5
5
  writeConfig
6
- } from "./chunk-K6MWE2ZH.js";
6
+ } from "./chunk-SO323PZP.js";
7
7
 
8
8
  // src/lib/memory/config.ts
9
9
  var DEFAULT_MEMORY_CONFIG = {
@@ -3,10 +3,10 @@ import {
3
3
  isAgentMode,
4
4
  json,
5
5
  requireMemoryInit
6
- } from "./chunk-HS5AHQ4V.js";
6
+ } from "./chunk-M326Y5X6.js";
7
7
  import {
8
8
  getBackend
9
- } from "./chunk-OADHUAEU.js";
9
+ } from "./chunk-BHAEEALR.js";
10
10
 
11
11
  // src/commands/mem/sql.ts
12
12
  async function memSqlCommand(sql) {
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  getMemoryConfigOrDefault
3
- } from "./chunk-TXTRXV74.js";
3
+ } from "./chunk-BV2NYIA7.js";
4
4
  import {
5
5
  getOpenAiApiKey,
6
6
  readConfig
7
- } from "./chunk-K6MWE2ZH.js";
7
+ } from "./chunk-SO323PZP.js";
8
8
 
9
9
  // src/lib/output.ts
10
10
  import * as p from "@clack/prompts";
@@ -6,11 +6,11 @@ import {
6
6
  note,
7
7
  okJson,
8
8
  requireMemoryInit
9
- } from "./chunk-HS5AHQ4V.js";
9
+ } from "./chunk-M326Y5X6.js";
10
10
  import {
11
11
  getBackend,
12
12
  upsertRecord
13
- } from "./chunk-OADHUAEU.js";
13
+ } from "./chunk-BHAEEALR.js";
14
14
 
15
15
  // src/commands/mem/migrate.ts
16
16
  import fs4 from "fs";
@@ -318,13 +318,6 @@ function appendUsageLog(line) {
318
318
  } catch {
319
319
  }
320
320
  }
321
- function readUsageLog() {
322
- try {
323
- return fs.readFileSync(usageLogFile(), "utf-8").split("\n").filter(Boolean).slice(-USAGE_LOG_MAX);
324
- } catch {
325
- return [];
326
- }
327
- }
328
321
  function writeUsageLog(lines) {
329
322
  try {
330
323
  if (lines.length === 0) {
@@ -337,6 +330,25 @@ function writeUsageLog(lines) {
337
330
  } catch {
338
331
  }
339
332
  }
333
+ function claimUsageLog() {
334
+ const src = usageLogFile();
335
+ const tmp = `${src}.claim.${process.pid}.${randomUUID()}`;
336
+ try {
337
+ fs.renameSync(src, tmp);
338
+ } catch {
339
+ return null;
340
+ }
341
+ try {
342
+ return fs.readFileSync(tmp, "utf-8").split("\n").filter(Boolean).slice(-USAGE_LOG_MAX);
343
+ } catch {
344
+ return [];
345
+ } finally {
346
+ try {
347
+ fs.rmSync(tmp, { force: true });
348
+ } catch {
349
+ }
350
+ }
351
+ }
340
352
  function readUsageState() {
341
353
  try {
342
354
  return JSON.parse(fs.readFileSync(usageStateFile(), "utf-8"));
@@ -384,8 +396,8 @@ export {
384
396
  readAnalyticsQueue,
385
397
  writeAnalyticsQueue,
386
398
  appendUsageLog,
387
- readUsageLog,
388
399
  writeUsageLog,
400
+ claimUsageLog,
389
401
  readUsageState,
390
402
  writeUsageState
391
403
  };
@@ -2,8 +2,8 @@ import {
2
2
  defaultSearchableText,
3
3
  embed,
4
4
  embedBatch
5
- } from "./chunk-TXTRXV74.js";
6
- import "./chunk-K6MWE2ZH.js";
5
+ } from "./chunk-BV2NYIA7.js";
6
+ import "./chunk-SO323PZP.js";
7
7
  export {
8
8
  defaultSearchableText,
9
9
  embed,
@@ -12,9 +12,9 @@ import {
12
12
  stripStepsAlias,
13
13
  summarizeFlowInputs,
14
14
  walkSteps
15
- } from "./chunk-4AYHJFH3.js";
15
+ } from "./chunk-2TWFL3CS.js";
16
16
  import "./chunk-44CV5IMX.js";
17
- import "./chunk-K6MWE2ZH.js";
17
+ import "./chunk-SO323PZP.js";
18
18
  export {
19
19
  FlowRunner,
20
20
  collectStepTypes,
package/dist/index.js CHANGED
@@ -31,10 +31,10 @@ import {
31
31
  validateActionInput,
32
32
  walkSteps,
33
33
  writeCache
34
- } from "./chunk-4AYHJFH3.js";
34
+ } from "./chunk-2TWFL3CS.js";
35
35
  import {
36
36
  memSqlCommand
37
- } from "./chunk-QV3Y5N5G.js";
37
+ } from "./chunk-H2PP5XEQ.js";
38
38
  import {
39
39
  countRecords,
40
40
  deleteDatabase,
@@ -59,7 +59,7 @@ import {
59
59
  upsertRecords,
60
60
  writeDraftProfile,
61
61
  writeProfile
62
- } from "./chunk-PLMFRFTT.js";
62
+ } from "./chunk-QE6Z676D.js";
63
63
  import {
64
64
  getByDotPath
65
65
  } from "./chunk-44CV5IMX.js";
@@ -83,7 +83,7 @@ import {
83
83
  semanticSearchUpgradeLine,
84
84
  setAgentMode,
85
85
  silenceWarningsInAgentMode
86
- } from "./chunk-HS5AHQ4V.js";
86
+ } from "./chunk-M326Y5X6.js";
87
87
  import {
88
88
  SCHEMA_VERSION,
89
89
  addRecord,
@@ -93,7 +93,7 @@ import {
93
93
  listBackendPlugins,
94
94
  loadBackendFromConfig,
95
95
  upsertRecord
96
- } from "./chunk-OADHUAEU.js";
96
+ } from "./chunk-BHAEEALR.js";
97
97
  import {
98
98
  DEFAULT_MEMORY_CONFIG,
99
99
  defaultSearchableText,
@@ -103,10 +103,11 @@ import {
103
103
  memoryConfigExists,
104
104
  setOpenAiApiKey,
105
105
  updateMemoryConfig
106
- } from "./chunk-TXTRXV74.js";
106
+ } from "./chunk-BV2NYIA7.js";
107
107
  import {
108
108
  appendAnalyticsQueue,
109
109
  appendUsageLog,
110
+ claimUsageLog,
110
111
  configExists,
111
112
  ensureWhoAmI,
112
113
  getAccessControl,
@@ -127,7 +128,6 @@ import {
127
128
  readConfig,
128
129
  readGlobalConfig,
129
130
  readProjectConfig,
130
- readUsageLog,
131
131
  readUsageState,
132
132
  resolveConfig,
133
133
  telemetryNoticeShown,
@@ -138,7 +138,7 @@ import {
138
138
  writeConfig,
139
139
  writeUsageLog,
140
140
  writeUsageState
141
- } from "./chunk-K6MWE2ZH.js";
141
+ } from "./chunk-SO323PZP.js";
142
142
 
143
143
  // src/cli.ts
144
144
  import { createRequire as createRequire3 } from "module";
@@ -2740,7 +2740,13 @@ async function actionsExecuteCommand(platform, actionId, connectionKey, options)
2740
2740
  } else {
2741
2741
  console.log();
2742
2742
  console.log(pc6.bold("Response:"));
2743
- console.log(JSON.stringify(result.responseData, null, 2));
2743
+ const rd = result.responseData;
2744
+ if (rd && typeof rd === "object" && typeof rd.text === "string" && "contentType" in rd) {
2745
+ if (rd.contentType) console.log(pc6.dim(`(${rd.contentType})`));
2746
+ console.log(rd.text);
2747
+ } else {
2748
+ console.log(JSON.stringify(result.responseData, null, 2));
2749
+ }
2744
2750
  }
2745
2751
  } catch (error2) {
2746
2752
  spinner5.stop("Execution failed");
@@ -6056,7 +6062,7 @@ async function syncModel(api, profile, options) {
6056
6062
  updateModelState(platform, model, { status: "failed", pagesProcessed, lastCursor }),
6057
6063
  (async () => {
6058
6064
  try {
6059
- const { getBackend: getBackend2 } = await import("./runtime-B5GCQ34P.js");
6065
+ const { getBackend: getBackend2 } = await import("./runtime-V4PXJJUV.js");
6060
6066
  const backend = await getBackend2();
6061
6067
  await Promise.race([
6062
6068
  backend.close(),
@@ -6411,7 +6417,7 @@ async function syncModel(api, profile, options) {
6411
6417
  db.exec(`DROP TABLE IF EXISTS _seen_ids`);
6412
6418
  }
6413
6419
  if (options.toMemory !== false) {
6414
- const backend = await (await import("./runtime-B5GCQ34P.js")).getBackend();
6420
+ const backend = await (await import("./runtime-V4PXJJUV.js")).getBackend();
6415
6421
  const type = `${platform}/${model}`;
6416
6422
  const existing = await backend.listKeysByType(type);
6417
6423
  const sourcePrefix = `${type}:`;
@@ -6491,7 +6497,7 @@ async function syncModel(api, profile, options) {
6491
6497
  let statusCounts;
6492
6498
  if (options.toMemory !== false) {
6493
6499
  try {
6494
- const backend = await (await import("./runtime-B5GCQ34P.js")).getBackend();
6500
+ const backend = await (await import("./runtime-V4PXJJUV.js")).getBackend();
6495
6501
  const typeName = `${platform}/${model}`;
6496
6502
  const [active, archived] = await Promise.all([
6497
6503
  backend.count(typeName, { status: "active" }),
@@ -8124,7 +8130,7 @@ ${result.total} results`);
8124
8130
  }
8125
8131
  }
8126
8132
  async function syncSqlCommand(platformModel, sql) {
8127
- const { syncSqlCommand: runSyncSql } = await import("./sql-W3ZUOUNR.js");
8133
+ const { syncSqlCommand: runSyncSql } = await import("./sql-CBZQHP4R.js");
8128
8134
  await runSyncSql(platformModel, sql);
8129
8135
  }
8130
8136
  async function syncDeleteCommand(platformModel, options) {
@@ -8202,7 +8208,7 @@ async function syncDeleteCommand(platformModel, options) {
8202
8208
  async function maybeAutoMigrateLegacy(platform, models) {
8203
8209
  const dbSize = getDatabaseSize(platform);
8204
8210
  if (!dbSize || dbSize === "0 B") return;
8205
- const { getBackend: getBackend2 } = await import("./runtime-B5GCQ34P.js");
8211
+ const { getBackend: getBackend2 } = await import("./runtime-V4PXJJUV.js");
8206
8212
  const backend = await getBackend2();
8207
8213
  let memoryHasData = false;
8208
8214
  for (const model of models) {
@@ -8218,7 +8224,7 @@ async function maybeAutoMigrateLegacy(platform, models) {
8218
8224
  ` detected legacy .one/sync/data/${platform}.db (${dbSize}) \u2014 auto-migrating into memory before sync.
8219
8225
  `
8220
8226
  );
8221
- const { memMigrateCommand: memMigrateCommand3 } = await import("./migrate-UDEANXEZ.js");
8227
+ const { memMigrateCommand: memMigrateCommand3 } = await import("./migrate-CO4LQVY6.js");
8222
8228
  await memMigrateCommand3({ platform, yes: true });
8223
8229
  return;
8224
8230
  }
@@ -8227,7 +8233,7 @@ async function maybeAutoMigrateLegacy(platform, models) {
8227
8233
  initialValue: true
8228
8234
  });
8229
8235
  if (p7.isCancel(shouldMigrate) || !shouldMigrate) return;
8230
- const { memMigrateCommand: memMigrateCommand2 } = await import("./migrate-UDEANXEZ.js");
8236
+ const { memMigrateCommand: memMigrateCommand2 } = await import("./migrate-CO4LQVY6.js");
8231
8237
  await memMigrateCommand2({ platform, yes: true });
8232
8238
  }
8233
8239
  async function syncSuggestSearchableCommand(platformModel, options = {}) {
@@ -8288,7 +8294,7 @@ async function syncSuggestSearchableCommand(platformModel, options = {}) {
8288
8294
  async function syncListCommand(platform) {
8289
8295
  const profiles = listProfiles(platform);
8290
8296
  const state = await readSyncState();
8291
- const { getBackend: getBackend2 } = await import("./runtime-B5GCQ34P.js");
8297
+ const { getBackend: getBackend2 } = await import("./runtime-V4PXJJUV.js");
8292
8298
  const backend = await getBackend2();
8293
8299
  const syncs = await Promise.all(profiles.map(async (p10) => {
8294
8300
  const modelState = state[p10.platform]?.[p10.model];
@@ -8563,7 +8569,7 @@ function registerSyncSubcommands(sync) {
8563
8569
  await syncSqlCommand(platformModel, sql);
8564
8570
  });
8565
8571
  sync.command("schema <platform/model>").description("Inspect the JSON structure of synced records (field paths, types, examples) \u2014 useful before writing `sync sql` queries").action(async (platformModel) => {
8566
- const { syncSchemaCommand } = await import("./schema-DXHEU47V.js");
8572
+ const { syncSchemaCommand } = await import("./schema-UC4LBV5V.js");
8567
8573
  await syncSchemaCommand(platformModel);
8568
8574
  });
8569
8575
  sync.command("delete <platform/model>").description('Delete records from local sync data (e.g. one sync delete notion/pages --id "abc-123")').option("--id <value>", "Delete record by ID").option("--where <conditions>", 'Delete records matching conditions (e.g. "status=archived")').option("--where-sql <predicate>", `Delete using a raw SQL WHERE clause (e.g. "json_extract(data, '$.type') = 'promotion'")`).option("--yes", "Skip confirmation prompt").action(async (platformModel, options) => {
@@ -9210,7 +9216,7 @@ async function memDoctorCommand() {
9210
9216
  }
9211
9217
  if (cfg.embedding.provider === "openai") {
9212
9218
  try {
9213
- const { embed: embed2 } = await import("./embedding-NVFDR5PK.js");
9219
+ const { embed: embed2 } = await import("./embedding-K2CFCLXI.js");
9214
9220
  const result = await embed2("connectivity check");
9215
9221
  checks.push({
9216
9222
  name: "OpenAI embedding provider reachable",
@@ -9699,7 +9705,7 @@ one --agent actions execute <platform> <actionId> <key> -d '{}' # Execute it
9699
9705
  - \`--dry-run\` \u2014 Preview request without executing
9700
9706
  - \`--mock\` \u2014 Return example response without making an API call (useful for building UI against a response shape)
9701
9707
  - \`--skip-validation\` \u2014 Skip input validation against the action schema
9702
- - \`--output <path>\` \u2014 Save response to a file (for binary downloads like PDFs, images, documents)
9708
+ - \`--output <path>\` \u2014 Save response to a file (for binary downloads like PDFs, images, documents). Text responses (text/plain, HTML, CSV, XML) render inline automatically \u2014 \`--output\` is only needed for genuinely binary payloads.
9703
9709
  - \`--no-cache\` \u2014 Bypass the cached action details and re-fetch them; the fresh details still refresh the cache (execution itself is never cached)
9704
9710
 
9705
9711
  The CLI validates required parameters against the action schema before executing. If you're missing a required path variable, query param, or body field, you'll get a clear error listing what's missing and which flag to use. Pass \`--skip-validation\` to bypass.
@@ -9831,7 +9837,7 @@ one --agent actions execute <platform> <actionId> <connectionKey> [options]
9831
9837
  - \`--dry-run\` \u2014 Preview without executing
9832
9838
  - \`--mock\` \u2014 Return example response without making an API call
9833
9839
  - \`--skip-validation\` \u2014 Skip input validation against the action schema
9834
- - \`--output <path>\` \u2014 Save response to a file (for binary downloads like PDFs, images, documents)
9840
+ - \`--output <path>\` \u2014 Save response to a file (for binary downloads like PDFs, images, documents). Text responses (text/plain, HTML, CSV, XML) render inline automatically \u2014 \`--output\` is only needed for genuinely binary payloads.
9835
9841
  - \`--no-cache\` \u2014 Bypass the cached action details and re-fetch them; the fresh details still refresh the cache (execution itself is never cached)
9836
9842
 
9837
9843
  Execute reuses the action details cached by \`actions knowledge\` (method, path, schema), so in the standard search \u2192 knowledge \u2192 execute flow it makes a single API call \u2014 the action being executed. The live response is never cached. In \`--agent\` mode the response includes \`"_preflight": {"cache": "hit"|"miss"}\` showing whether the lookup was served from disk.
@@ -11080,7 +11086,7 @@ async function logoutCommand() {
11080
11086
 
11081
11087
  // src/lib/analytics.ts
11082
11088
  import { createRequire as createRequire2 } from "module";
11083
- import { randomUUID } from "crypto";
11089
+ import { randomUUID, createHash } from "crypto";
11084
11090
  import pc13 from "picocolors";
11085
11091
  var require3 = createRequire2(import.meta.url);
11086
11092
  var DEFAULT_POSTHOG_HOST = "https://us.i.posthog.com";
@@ -11123,6 +11129,9 @@ function isTelemetryDisabled() {
11123
11129
  function distinctId() {
11124
11130
  return getWhoAmI()?.user?.id ?? getDeviceId();
11125
11131
  }
11132
+ function isAuthenticated() {
11133
+ return !!getWhoAmI()?.user || !!getApiKey();
11134
+ }
11126
11135
  function baseProperties() {
11127
11136
  return {
11128
11137
  $lib: "one-cli",
@@ -11131,7 +11140,8 @@ function baseProperties() {
11131
11140
  env: envName(),
11132
11141
  os: process.platform,
11133
11142
  arch: process.arch,
11134
- node_version: process.versions.node
11143
+ node_version: process.versions.node,
11144
+ authenticated: isAuthenticated()
11135
11145
  };
11136
11146
  }
11137
11147
  function personSet() {
@@ -11176,7 +11186,8 @@ function capture(event, properties = {}, opts = {}) {
11176
11186
  return;
11177
11187
  }
11178
11188
  const did = opts.distinctId ?? distinctId();
11179
- const props = { ...baseProperties(), ...properties, $insert_id: randomUUID() };
11189
+ const props = { ...baseProperties(), ...properties };
11190
+ if (props.$insert_id === void 0) props.$insert_id = randomUUID();
11180
11191
  if (did === distinctId()) {
11181
11192
  const set = personSet();
11182
11193
  if (set) props.$set = set;
@@ -11194,13 +11205,30 @@ var ROLLUP_MAX_BATCH = 500;
11194
11205
  function utcDay(ts) {
11195
11206
  return new Date(ts).toISOString().slice(0, 10);
11196
11207
  }
11208
+ var PRE_AUTH_COMMANDS = /* @__PURE__ */ new Set([
11209
+ "init",
11210
+ "login",
11211
+ "logout",
11212
+ "guide",
11213
+ "platforms",
11214
+ "onboard",
11215
+ "config",
11216
+ "update",
11217
+ "help"
11218
+ ]);
11219
+ function shouldRecord(commandPath2) {
11220
+ if (isAuthenticated()) return true;
11221
+ return PRE_AUTH_COMMANDS.has(commandPath2.split(" ")[0]);
11222
+ }
11197
11223
  function recordCommand(command) {
11198
11224
  if (isTelemetryDisabled()) {
11199
11225
  writeUsageLog([]);
11200
11226
  return;
11201
11227
  }
11228
+ const cmdPath = commandPath(command);
11229
+ if (!shouldRecord(cmdPath)) return;
11202
11230
  const did = distinctId();
11203
- const entry = { ts: Date.now(), command: commandPath(command), agent: isAgentMode(), did };
11231
+ const entry = { ts: Date.now(), command: cmdPath, agent: isAgentMode(), did };
11204
11232
  appendUsageLog(JSON.stringify(entry));
11205
11233
  const today = utcDay(entry.ts);
11206
11234
  const state = readUsageState();
@@ -11213,8 +11241,10 @@ function flushUsageRollups(opts = {}) {
11213
11241
  writeUsageLog([]);
11214
11242
  return;
11215
11243
  }
11244
+ const lines = claimUsageLog();
11245
+ if (!lines || lines.length === 0) return;
11216
11246
  const entries = [];
11217
- for (const line of readUsageLog()) {
11247
+ for (const line of lines) {
11218
11248
  try {
11219
11249
  const e = JSON.parse(line);
11220
11250
  if (e && typeof e.ts === "number" && typeof e.command === "string" && typeof e.did === "string") {
@@ -11223,10 +11253,7 @@ function flushUsageRollups(opts = {}) {
11223
11253
  } catch {
11224
11254
  }
11225
11255
  }
11226
- if (entries.length === 0) {
11227
- writeUsageLog([]);
11228
- return;
11229
- }
11256
+ if (entries.length === 0) return;
11230
11257
  const currentDid = entries[entries.length - 1].did;
11231
11258
  const now = Date.now();
11232
11259
  const groups = /* @__PURE__ */ new Map();
@@ -11242,7 +11269,7 @@ function flushUsageRollups(opts = {}) {
11242
11269
  if (due) emitRollup(did, group);
11243
11270
  else kept.push(...group);
11244
11271
  }
11245
- writeUsageLog(kept.map((e) => JSON.stringify(e)));
11272
+ for (const e of kept) appendUsageLog(JSON.stringify(e));
11246
11273
  }
11247
11274
  function emitRollup(did, group) {
11248
11275
  const byCommand = {};
@@ -11251,6 +11278,7 @@ function emitRollup(did, group) {
11251
11278
  byCommand[e.command] = (byCommand[e.command] ?? 0) + 1;
11252
11279
  if (e.agent) agentCount += 1;
11253
11280
  }
11281
+ const insertId = createHash("sha1").update(`${did}|${group.map((e) => `${e.ts}:${e.command}:${e.agent ? 1 : 0}`).join("|")}`).digest("hex");
11254
11282
  capture(
11255
11283
  "CLI Usage Rollup",
11256
11284
  {
@@ -11259,7 +11287,8 @@ function emitRollup(did, group) {
11259
11287
  agent_count: agentCount,
11260
11288
  human_count: group.length - agentCount,
11261
11289
  window_start: new Date(group[0].ts).toISOString(),
11262
- window_end: new Date(group[group.length - 1].ts).toISOString()
11290
+ window_end: new Date(group[group.length - 1].ts).toISOString(),
11291
+ $insert_id: insertId
11263
11292
  },
11264
11293
  { distinctId: did, timestamp: new Date(group[group.length - 1].ts).toISOString() }
11265
11294
  );
@@ -3,12 +3,12 @@ import {
3
3
  dotPathToJsonbExpr,
4
4
  memMigrateCommand,
5
5
  reviveStringifiedJson
6
- } from "./chunk-PLMFRFTT.js";
6
+ } from "./chunk-QE6Z676D.js";
7
7
  import "./chunk-44CV5IMX.js";
8
- import "./chunk-HS5AHQ4V.js";
9
- import "./chunk-OADHUAEU.js";
10
- import "./chunk-TXTRXV74.js";
11
- import "./chunk-K6MWE2ZH.js";
8
+ import "./chunk-M326Y5X6.js";
9
+ import "./chunk-BHAEEALR.js";
10
+ import "./chunk-BV2NYIA7.js";
11
+ import "./chunk-SO323PZP.js";
12
12
  export {
13
13
  buildIdentityMap,
14
14
  dotPathToJsonbExpr,
@@ -4,9 +4,9 @@ import {
4
4
  getBackend,
5
5
  resetBackendSingleton,
6
6
  upsertRecord
7
- } from "./chunk-OADHUAEU.js";
8
- import "./chunk-TXTRXV74.js";
9
- import "./chunk-K6MWE2ZH.js";
7
+ } from "./chunk-BHAEEALR.js";
8
+ import "./chunk-BV2NYIA7.js";
9
+ import "./chunk-SO323PZP.js";
10
10
  export {
11
11
  addRecord,
12
12
  closeBackendIfCached,
@@ -3,12 +3,12 @@ import {
3
3
  note,
4
4
  okJson,
5
5
  requireMemoryInit
6
- } from "./chunk-HS5AHQ4V.js";
6
+ } from "./chunk-M326Y5X6.js";
7
7
  import {
8
8
  getBackend
9
- } from "./chunk-OADHUAEU.js";
10
- import "./chunk-TXTRXV74.js";
11
- import "./chunk-K6MWE2ZH.js";
9
+ } from "./chunk-BHAEEALR.js";
10
+ import "./chunk-BV2NYIA7.js";
11
+ import "./chunk-SO323PZP.js";
12
12
 
13
13
  // src/lib/memory/sync/schema.ts
14
14
  import pc from "picocolors";
@@ -0,0 +1,12 @@
1
+ import {
2
+ memSqlCommand,
3
+ syncSqlCommand
4
+ } from "./chunk-H2PP5XEQ.js";
5
+ import "./chunk-M326Y5X6.js";
6
+ import "./chunk-BHAEEALR.js";
7
+ import "./chunk-BV2NYIA7.js";
8
+ import "./chunk-SO323PZP.js";
9
+ export {
10
+ memSqlCommand,
11
+ syncSqlCommand
12
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@withone/cli",
3
- "version": "1.47.10",
3
+ "version": "1.48.0",
4
4
  "description": "CLI for managing One",
5
5
  "type": "module",
6
6
  "files": [
@@ -89,7 +89,7 @@ Options:
89
89
  - `--dry-run` — Preview the request without executing
90
90
  - `--mock` — Return example response without making an API call (useful for building UI)
91
91
  - `--skip-validation` — Skip input validation against the action schema
92
- - `--output <path>` — Save response to a file (for binary downloads like PDFs, images, documents)
92
+ - `--output <path>` — Save response to a file (for binary downloads like PDFs, images, documents). Text responses (text/plain, HTML, CSV, XML) render inline automatically; `--output` is only needed for genuinely binary payloads.
93
93
  - `--no-cache` — Bypass the cached action details and re-fetch them; the fresh details still refresh the cache (execution itself is never cached)
94
94
 
95
95
  The CLI validates required parameters before executing. Missing params return a structured error with the flag name, parameter name, and description. Pass `--skip-validation` to bypass.
@@ -1,12 +0,0 @@
1
- import {
2
- memSqlCommand,
3
- syncSqlCommand
4
- } from "./chunk-QV3Y5N5G.js";
5
- import "./chunk-HS5AHQ4V.js";
6
- import "./chunk-OADHUAEU.js";
7
- import "./chunk-TXTRXV74.js";
8
- import "./chunk-K6MWE2ZH.js";
9
- export {
10
- memSqlCommand,
11
- syncSqlCommand
12
- };