@withone/cli 1.46.0 → 1.47.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 +1 -1
- package/dist/{chunk-MQU7UK5J.js → chunk-4RZSK5LD.js} +2 -2
- package/dist/{chunk-GDKMOLZ5.js → chunk-5NLP47QP.js} +2 -2
- package/dist/{chunk-EDVE3BQZ.js → chunk-CESNNUKJ.js} +2 -2
- package/dist/{chunk-OEN5DNG7.js → chunk-K6MWE2ZH.js} +54 -1
- package/dist/{chunk-GIMKPA2J.js → chunk-OADHUAEU.js} +2 -2
- package/dist/{chunk-56QOOA5V.js → chunk-Q3OY2F6W.js} +2 -2
- package/dist/{chunk-BKD7A42U.js → chunk-TXTRXV74.js} +1 -1
- package/dist/{embedding-4T4VYFEI.js → embedding-NVFDR5PK.js} +2 -2
- package/dist/{flow-runner-VIKPVLBL.js → flow-runner-UWIM4Z2Y.js} +2 -2
- package/dist/index.js +107 -25
- package/dist/{migrate-SJXHOA2G.js → migrate-DHZ3SI65.js} +5 -5
- package/dist/{runtime-ZN7NZILR.js → runtime-B5GCQ34P.js} +3 -3
- package/dist/sql-5XR53LV5.js +12 -0
- package/package.json +1 -1
- package/dist/sql-YMHNH3DT.js +0 -12
package/README.md
CHANGED
|
@@ -566,7 +566,7 @@ Run `one update` manually whenever you want to upgrade.
|
|
|
566
566
|
|
|
567
567
|
### Telemetry
|
|
568
568
|
|
|
569
|
-
The CLI collects **usage analytics** — which command was run, the CLI version, OS/arch, and whether it ran in `--agent` mode — to help us prioritize improvements. Events are linked to your One account (user id, email, name, org) so they line up with your dashboard activity. **Command arguments, inputs, connection data, and secrets are never collected** (only the command name, e.g. `actions execute`). A one-time notice is shown on first run.
|
|
569
|
+
The CLI collects **usage analytics** — which command was run, the CLI version, OS/arch, and whether it ran in `--agent` mode — to help us prioritize improvements. Events are linked to your One account (user id, email, name, org) so they line up with your dashboard activity. **Command arguments, inputs, connection data, and secrets are never collected** (only the command name, e.g. `actions execute`). A one-time notice is shown on first run. Commands are aggregated locally and sent as periodic, batched roll-ups in the background, so telemetry never slows down or blocks a command (and stays lightweight even under heavy automation).
|
|
570
570
|
|
|
571
571
|
To opt out, set any of:
|
|
572
572
|
|
|
@@ -6,11 +6,11 @@ import {
|
|
|
6
6
|
note,
|
|
7
7
|
okJson,
|
|
8
8
|
requireMemoryInit
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-Q3OY2F6W.js";
|
|
10
10
|
import {
|
|
11
11
|
getBackend,
|
|
12
12
|
upsertRecord
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-OADHUAEU.js";
|
|
14
14
|
|
|
15
15
|
// src/commands/mem/migrate.ts
|
|
16
16
|
import fs4 from "fs";
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-44CV5IMX.js";
|
|
5
5
|
import {
|
|
6
6
|
getCacheTtl
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-K6MWE2ZH.js";
|
|
8
8
|
|
|
9
9
|
// src/lib/flow-runner.ts
|
|
10
10
|
import fs3 from "fs";
|
|
@@ -1271,7 +1271,7 @@ async function executeSubflowStep(step, context, api, permissions, allowedAction
|
|
|
1271
1271
|
if (flowStack.includes(resolvedKey)) {
|
|
1272
1272
|
throw new Error(`Circular flow detected: ${[...flowStack, resolvedKey].join(" \u2192 ")}`);
|
|
1273
1273
|
}
|
|
1274
|
-
const { loadFlowWithMeta: loadFlowWithMeta2 } = await import("./flow-runner-
|
|
1274
|
+
const { loadFlowWithMeta: loadFlowWithMeta2 } = await import("./flow-runner-UWIM4Z2Y.js");
|
|
1275
1275
|
const { flow: subFlow, rootDir: subRootDir } = loadFlowWithMeta2(resolvedKey);
|
|
1276
1276
|
const subContext = await executeFlow(
|
|
1277
1277
|
subFlow,
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
isAgentMode,
|
|
4
4
|
json,
|
|
5
5
|
requireMemoryInit
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-Q3OY2F6W.js";
|
|
7
7
|
import {
|
|
8
8
|
getBackend
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-OADHUAEU.js";
|
|
10
10
|
|
|
11
11
|
// src/commands/mem/sql.ts
|
|
12
12
|
async function memSqlCommand(sql) {
|
|
@@ -303,6 +303,54 @@ function writeAnalyticsQueue(lines) {
|
|
|
303
303
|
} catch {
|
|
304
304
|
}
|
|
305
305
|
}
|
|
306
|
+
function usageLogFile() {
|
|
307
|
+
return path.join(configDir(), ".cli-usage-log.jsonl");
|
|
308
|
+
}
|
|
309
|
+
function usageStateFile() {
|
|
310
|
+
return path.join(configDir(), ".cli-usage-state.json");
|
|
311
|
+
}
|
|
312
|
+
var USAGE_LOG_MAX = 5e3;
|
|
313
|
+
function appendUsageLog(line) {
|
|
314
|
+
try {
|
|
315
|
+
if (!fs.existsSync(configDir())) fs.mkdirSync(configDir(), { mode: 448 });
|
|
316
|
+
fs.appendFileSync(usageLogFile(), `${line}
|
|
317
|
+
`, { mode: 384 });
|
|
318
|
+
} catch {
|
|
319
|
+
}
|
|
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
|
+
function writeUsageLog(lines) {
|
|
329
|
+
try {
|
|
330
|
+
if (lines.length === 0) {
|
|
331
|
+
fs.rmSync(usageLogFile(), { force: true });
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
if (!fs.existsSync(configDir())) fs.mkdirSync(configDir(), { mode: 448 });
|
|
335
|
+
fs.writeFileSync(usageLogFile(), `${lines.slice(-USAGE_LOG_MAX).join("\n")}
|
|
336
|
+
`, { mode: 384 });
|
|
337
|
+
} catch {
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
function readUsageState() {
|
|
341
|
+
try {
|
|
342
|
+
return JSON.parse(fs.readFileSync(usageStateFile(), "utf-8"));
|
|
343
|
+
} catch {
|
|
344
|
+
return {};
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
function writeUsageState(state) {
|
|
348
|
+
try {
|
|
349
|
+
if (!fs.existsSync(configDir())) fs.mkdirSync(configDir(), { mode: 448 });
|
|
350
|
+
fs.writeFileSync(usageStateFile(), JSON.stringify(state), { mode: 384 });
|
|
351
|
+
} catch {
|
|
352
|
+
}
|
|
353
|
+
}
|
|
306
354
|
|
|
307
355
|
export {
|
|
308
356
|
getProjectRoot,
|
|
@@ -334,5 +382,10 @@ export {
|
|
|
334
382
|
markTelemetryNoticeShown,
|
|
335
383
|
appendAnalyticsQueue,
|
|
336
384
|
readAnalyticsQueue,
|
|
337
|
-
writeAnalyticsQueue
|
|
385
|
+
writeAnalyticsQueue,
|
|
386
|
+
appendUsageLog,
|
|
387
|
+
readUsageLog,
|
|
388
|
+
writeUsageLog,
|
|
389
|
+
readUsageState,
|
|
390
|
+
writeUsageState
|
|
338
391
|
};
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
getMemoryConfig,
|
|
6
6
|
getMemoryConfigOrDefault,
|
|
7
7
|
updateMemoryConfig
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-TXTRXV74.js";
|
|
9
9
|
import {
|
|
10
10
|
getOpenAiApiKey
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-K6MWE2ZH.js";
|
|
12
12
|
|
|
13
13
|
// src/lib/memory/schema.ts
|
|
14
14
|
var SCHEMA_VERSION = "2.1.0";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getMemoryConfigOrDefault
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-TXTRXV74.js";
|
|
4
4
|
import {
|
|
5
5
|
getOpenAiApiKey,
|
|
6
6
|
readConfig
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-K6MWE2ZH.js";
|
|
8
8
|
|
|
9
9
|
// src/lib/output.ts
|
|
10
10
|
import * as p from "@clack/prompts";
|
|
@@ -11,9 +11,9 @@ import {
|
|
|
11
11
|
saveFlow,
|
|
12
12
|
summarizeFlowInputs,
|
|
13
13
|
walkSteps
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-5NLP47QP.js";
|
|
15
15
|
import "./chunk-44CV5IMX.js";
|
|
16
|
-
import "./chunk-
|
|
16
|
+
import "./chunk-K6MWE2ZH.js";
|
|
17
17
|
export {
|
|
18
18
|
FlowRunner,
|
|
19
19
|
collectStepTypes,
|
package/dist/index.js
CHANGED
|
@@ -30,10 +30,10 @@ import {
|
|
|
30
30
|
searchCachePath,
|
|
31
31
|
validateActionInput,
|
|
32
32
|
writeCache
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-5NLP47QP.js";
|
|
34
34
|
import {
|
|
35
35
|
memSqlCommand
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-CESNNUKJ.js";
|
|
37
37
|
import {
|
|
38
38
|
countRecords,
|
|
39
39
|
deleteDatabase,
|
|
@@ -58,7 +58,7 @@ import {
|
|
|
58
58
|
upsertRecords,
|
|
59
59
|
writeDraftProfile,
|
|
60
60
|
writeProfile
|
|
61
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-4RZSK5LD.js";
|
|
62
62
|
import {
|
|
63
63
|
getByDotPath
|
|
64
64
|
} from "./chunk-44CV5IMX.js";
|
|
@@ -81,7 +81,7 @@ import {
|
|
|
81
81
|
semanticSearchUpgradeHint,
|
|
82
82
|
semanticSearchUpgradeLine,
|
|
83
83
|
setAgentMode
|
|
84
|
-
} from "./chunk-
|
|
84
|
+
} from "./chunk-Q3OY2F6W.js";
|
|
85
85
|
import {
|
|
86
86
|
SCHEMA_VERSION,
|
|
87
87
|
addRecord,
|
|
@@ -91,7 +91,7 @@ import {
|
|
|
91
91
|
listBackendPlugins,
|
|
92
92
|
loadBackendFromConfig,
|
|
93
93
|
upsertRecord
|
|
94
|
-
} from "./chunk-
|
|
94
|
+
} from "./chunk-OADHUAEU.js";
|
|
95
95
|
import {
|
|
96
96
|
DEFAULT_MEMORY_CONFIG,
|
|
97
97
|
defaultSearchableText,
|
|
@@ -101,9 +101,10 @@ import {
|
|
|
101
101
|
memoryConfigExists,
|
|
102
102
|
setOpenAiApiKey,
|
|
103
103
|
updateMemoryConfig
|
|
104
|
-
} from "./chunk-
|
|
104
|
+
} from "./chunk-TXTRXV74.js";
|
|
105
105
|
import {
|
|
106
106
|
appendAnalyticsQueue,
|
|
107
|
+
appendUsageLog,
|
|
107
108
|
configExists,
|
|
108
109
|
ensureWhoAmI,
|
|
109
110
|
getAccessControl,
|
|
@@ -124,14 +125,18 @@ import {
|
|
|
124
125
|
readConfig,
|
|
125
126
|
readGlobalConfig,
|
|
126
127
|
readProjectConfig,
|
|
128
|
+
readUsageLog,
|
|
129
|
+
readUsageState,
|
|
127
130
|
resolveConfig,
|
|
128
131
|
telemetryNoticeShown,
|
|
129
132
|
updateAccessControl,
|
|
130
133
|
updateApiBase,
|
|
131
134
|
updateWhoAmI,
|
|
132
135
|
writeAnalyticsQueue,
|
|
133
|
-
writeConfig
|
|
134
|
-
|
|
136
|
+
writeConfig,
|
|
137
|
+
writeUsageLog,
|
|
138
|
+
writeUsageState
|
|
139
|
+
} from "./chunk-K6MWE2ZH.js";
|
|
135
140
|
|
|
136
141
|
// src/cli.ts
|
|
137
142
|
import { createRequire as createRequire3 } from "module";
|
|
@@ -5726,7 +5731,7 @@ async function syncModel(api, profile, options) {
|
|
|
5726
5731
|
updateModelState(platform, model, { status: "failed", pagesProcessed, lastCursor }),
|
|
5727
5732
|
(async () => {
|
|
5728
5733
|
try {
|
|
5729
|
-
const { getBackend: getBackend2 } = await import("./runtime-
|
|
5734
|
+
const { getBackend: getBackend2 } = await import("./runtime-B5GCQ34P.js");
|
|
5730
5735
|
const backend = await getBackend2();
|
|
5731
5736
|
await Promise.race([
|
|
5732
5737
|
backend.close(),
|
|
@@ -6081,7 +6086,7 @@ async function syncModel(api, profile, options) {
|
|
|
6081
6086
|
db.exec(`DROP TABLE IF EXISTS _seen_ids`);
|
|
6082
6087
|
}
|
|
6083
6088
|
if (options.toMemory !== false) {
|
|
6084
|
-
const backend = await (await import("./runtime-
|
|
6089
|
+
const backend = await (await import("./runtime-B5GCQ34P.js")).getBackend();
|
|
6085
6090
|
const type = `${platform}/${model}`;
|
|
6086
6091
|
const existing = await backend.listKeysByType(type);
|
|
6087
6092
|
const sourcePrefix = `${type}:`;
|
|
@@ -6161,7 +6166,7 @@ async function syncModel(api, profile, options) {
|
|
|
6161
6166
|
let statusCounts;
|
|
6162
6167
|
if (options.toMemory !== false) {
|
|
6163
6168
|
try {
|
|
6164
|
-
const backend = await (await import("./runtime-
|
|
6169
|
+
const backend = await (await import("./runtime-B5GCQ34P.js")).getBackend();
|
|
6165
6170
|
const typeName = `${platform}/${model}`;
|
|
6166
6171
|
const [active, archived] = await Promise.all([
|
|
6167
6172
|
backend.count(typeName, { status: "active" }),
|
|
@@ -7794,7 +7799,7 @@ ${result.total} results`);
|
|
|
7794
7799
|
}
|
|
7795
7800
|
}
|
|
7796
7801
|
async function syncSqlCommand(platformModel, sql) {
|
|
7797
|
-
const { syncSqlCommand: runSyncSql } = await import("./sql-
|
|
7802
|
+
const { syncSqlCommand: runSyncSql } = await import("./sql-5XR53LV5.js");
|
|
7798
7803
|
await runSyncSql(platformModel, sql);
|
|
7799
7804
|
}
|
|
7800
7805
|
async function syncDeleteCommand(platformModel, options) {
|
|
@@ -7872,7 +7877,7 @@ async function syncDeleteCommand(platformModel, options) {
|
|
|
7872
7877
|
async function maybeAutoMigrateLegacy(platform, models) {
|
|
7873
7878
|
const dbSize = getDatabaseSize(platform);
|
|
7874
7879
|
if (!dbSize || dbSize === "0 B") return;
|
|
7875
|
-
const { getBackend: getBackend2 } = await import("./runtime-
|
|
7880
|
+
const { getBackend: getBackend2 } = await import("./runtime-B5GCQ34P.js");
|
|
7876
7881
|
const backend = await getBackend2();
|
|
7877
7882
|
let memoryHasData = false;
|
|
7878
7883
|
for (const model of models) {
|
|
@@ -7888,7 +7893,7 @@ async function maybeAutoMigrateLegacy(platform, models) {
|
|
|
7888
7893
|
` detected legacy .one/sync/data/${platform}.db (${dbSize}) \u2014 auto-migrating into memory before sync.
|
|
7889
7894
|
`
|
|
7890
7895
|
);
|
|
7891
|
-
const { memMigrateCommand: memMigrateCommand3 } = await import("./migrate-
|
|
7896
|
+
const { memMigrateCommand: memMigrateCommand3 } = await import("./migrate-DHZ3SI65.js");
|
|
7892
7897
|
await memMigrateCommand3({ platform, yes: true });
|
|
7893
7898
|
return;
|
|
7894
7899
|
}
|
|
@@ -7897,7 +7902,7 @@ async function maybeAutoMigrateLegacy(platform, models) {
|
|
|
7897
7902
|
initialValue: true
|
|
7898
7903
|
});
|
|
7899
7904
|
if (p7.isCancel(shouldMigrate) || !shouldMigrate) return;
|
|
7900
|
-
const { memMigrateCommand: memMigrateCommand2 } = await import("./migrate-
|
|
7905
|
+
const { memMigrateCommand: memMigrateCommand2 } = await import("./migrate-DHZ3SI65.js");
|
|
7901
7906
|
await memMigrateCommand2({ platform, yes: true });
|
|
7902
7907
|
}
|
|
7903
7908
|
async function syncSuggestSearchableCommand(platformModel, options = {}) {
|
|
@@ -7958,7 +7963,7 @@ async function syncSuggestSearchableCommand(platformModel, options = {}) {
|
|
|
7958
7963
|
async function syncListCommand(platform) {
|
|
7959
7964
|
const profiles = listProfiles(platform);
|
|
7960
7965
|
const state = await readSyncState();
|
|
7961
|
-
const { getBackend: getBackend2 } = await import("./runtime-
|
|
7966
|
+
const { getBackend: getBackend2 } = await import("./runtime-B5GCQ34P.js");
|
|
7962
7967
|
const backend = await getBackend2();
|
|
7963
7968
|
const syncs = await Promise.all(profiles.map(async (p10) => {
|
|
7964
7969
|
const modelState = state[p10.platform]?.[p10.model];
|
|
@@ -8876,7 +8881,7 @@ async function memDoctorCommand() {
|
|
|
8876
8881
|
}
|
|
8877
8882
|
if (cfg.embedding.provider === "openai") {
|
|
8878
8883
|
try {
|
|
8879
|
-
const { embed: embed2 } = await import("./embedding-
|
|
8884
|
+
const { embed: embed2 } = await import("./embedding-NVFDR5PK.js");
|
|
8880
8885
|
const result = await embed2("connectivity check");
|
|
8881
8886
|
checks.push({
|
|
8882
8887
|
name: "OpenAI embedding provider reachable",
|
|
@@ -10822,24 +10827,100 @@ function send(item) {
|
|
|
10822
10827
|
}
|
|
10823
10828
|
})();
|
|
10824
10829
|
}
|
|
10825
|
-
function capture(event, properties = {}) {
|
|
10830
|
+
function capture(event, properties = {}, opts = {}) {
|
|
10826
10831
|
if (isTelemetryDisabled()) {
|
|
10827
10832
|
debugLog(`disabled \u2014 skipping "${event}"`);
|
|
10828
10833
|
return;
|
|
10829
10834
|
}
|
|
10835
|
+
const did = opts.distinctId ?? distinctId();
|
|
10830
10836
|
const props = { ...baseProperties(), ...properties, $insert_id: randomUUID() };
|
|
10831
|
-
|
|
10832
|
-
|
|
10837
|
+
if (did === distinctId()) {
|
|
10838
|
+
const set = personSet();
|
|
10839
|
+
if (set) props.$set = set;
|
|
10840
|
+
}
|
|
10833
10841
|
const item = {
|
|
10834
10842
|
event,
|
|
10835
|
-
distinct_id:
|
|
10843
|
+
distinct_id: did,
|
|
10836
10844
|
properties: props,
|
|
10837
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
10845
|
+
timestamp: opts.timestamp ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
10838
10846
|
};
|
|
10839
10847
|
appendAnalyticsQueue(JSON.stringify(item));
|
|
10840
10848
|
}
|
|
10841
|
-
|
|
10842
|
-
|
|
10849
|
+
var ROLLUP_WINDOW_MS = 5 * 60 * 1e3;
|
|
10850
|
+
var ROLLUP_MAX_BATCH = 500;
|
|
10851
|
+
function utcDay(ts) {
|
|
10852
|
+
return new Date(ts).toISOString().slice(0, 10);
|
|
10853
|
+
}
|
|
10854
|
+
function recordCommand(command) {
|
|
10855
|
+
if (isTelemetryDisabled()) {
|
|
10856
|
+
writeUsageLog([]);
|
|
10857
|
+
return;
|
|
10858
|
+
}
|
|
10859
|
+
const did = distinctId();
|
|
10860
|
+
const entry = { ts: Date.now(), command: commandPath(command), agent: isAgentMode(), did };
|
|
10861
|
+
appendUsageLog(JSON.stringify(entry));
|
|
10862
|
+
const today = utcDay(entry.ts);
|
|
10863
|
+
const state = readUsageState();
|
|
10864
|
+
const firstTouch = state.lastDay !== today || state.distinctId !== did;
|
|
10865
|
+
flushUsageRollups({ force: firstTouch });
|
|
10866
|
+
if (firstTouch) writeUsageState({ lastDay: today, distinctId: did });
|
|
10867
|
+
}
|
|
10868
|
+
function flushUsageRollups(opts = {}) {
|
|
10869
|
+
if (isTelemetryDisabled()) {
|
|
10870
|
+
writeUsageLog([]);
|
|
10871
|
+
return;
|
|
10872
|
+
}
|
|
10873
|
+
const entries = [];
|
|
10874
|
+
for (const line of readUsageLog()) {
|
|
10875
|
+
try {
|
|
10876
|
+
const e = JSON.parse(line);
|
|
10877
|
+
if (e && typeof e.ts === "number" && typeof e.command === "string" && typeof e.did === "string") {
|
|
10878
|
+
entries.push(e);
|
|
10879
|
+
}
|
|
10880
|
+
} catch {
|
|
10881
|
+
}
|
|
10882
|
+
}
|
|
10883
|
+
if (entries.length === 0) {
|
|
10884
|
+
writeUsageLog([]);
|
|
10885
|
+
return;
|
|
10886
|
+
}
|
|
10887
|
+
const currentDid = entries[entries.length - 1].did;
|
|
10888
|
+
const now = Date.now();
|
|
10889
|
+
const groups = /* @__PURE__ */ new Map();
|
|
10890
|
+
for (const e of entries) {
|
|
10891
|
+
const g = groups.get(e.did);
|
|
10892
|
+
if (g) g.push(e);
|
|
10893
|
+
else groups.set(e.did, [e]);
|
|
10894
|
+
}
|
|
10895
|
+
const kept = [];
|
|
10896
|
+
for (const [did, group] of groups) {
|
|
10897
|
+
const due = opts.force === true || did !== currentDid || // a superseded login's batch — flush it now
|
|
10898
|
+
group.length >= ROLLUP_MAX_BATCH || now - group[0].ts >= ROLLUP_WINDOW_MS;
|
|
10899
|
+
if (due) emitRollup(did, group);
|
|
10900
|
+
else kept.push(...group);
|
|
10901
|
+
}
|
|
10902
|
+
writeUsageLog(kept.map((e) => JSON.stringify(e)));
|
|
10903
|
+
}
|
|
10904
|
+
function emitRollup(did, group) {
|
|
10905
|
+
const byCommand = {};
|
|
10906
|
+
let agentCount = 0;
|
|
10907
|
+
for (const e of group) {
|
|
10908
|
+
byCommand[e.command] = (byCommand[e.command] ?? 0) + 1;
|
|
10909
|
+
if (e.agent) agentCount += 1;
|
|
10910
|
+
}
|
|
10911
|
+
capture(
|
|
10912
|
+
"CLI Usage Rollup",
|
|
10913
|
+
{
|
|
10914
|
+
command_count: group.length,
|
|
10915
|
+
by_command: byCommand,
|
|
10916
|
+
agent_count: agentCount,
|
|
10917
|
+
human_count: group.length - agentCount,
|
|
10918
|
+
window_start: new Date(group[0].ts).toISOString(),
|
|
10919
|
+
window_end: new Date(group[group.length - 1].ts).toISOString()
|
|
10920
|
+
},
|
|
10921
|
+
{ distinctId: did, timestamp: new Date(group[group.length - 1].ts).toISOString() }
|
|
10922
|
+
);
|
|
10923
|
+
debugLog(`rollup \u2014 ${group.length} command(s) for ${did}`);
|
|
10843
10924
|
}
|
|
10844
10925
|
function commandPath(command) {
|
|
10845
10926
|
const parts = [];
|
|
@@ -10970,7 +11051,7 @@ program.hook("preAction", (thisCommand, actionCommand) => {
|
|
|
10970
11051
|
setAgentMode(true);
|
|
10971
11052
|
}
|
|
10972
11053
|
maybeShowTelemetryNotice();
|
|
10973
|
-
|
|
11054
|
+
recordCommand(actionCommand);
|
|
10974
11055
|
drainQueue();
|
|
10975
11056
|
const commandName = thisCommand.args?.[0];
|
|
10976
11057
|
if (commandName !== "update") {
|
|
@@ -10985,6 +11066,7 @@ program.hook("preAction", (thisCommand, actionCommand) => {
|
|
|
10985
11066
|
});
|
|
10986
11067
|
program.hook("postAction", async () => {
|
|
10987
11068
|
await closeBackendIfCached();
|
|
11069
|
+
flushUsageRollups();
|
|
10988
11070
|
flush();
|
|
10989
11071
|
if (!updateCheckPromise) return;
|
|
10990
11072
|
const info = await updateCheckPromise;
|
|
@@ -3,12 +3,12 @@ import {
|
|
|
3
3
|
dotPathToJsonbExpr,
|
|
4
4
|
memMigrateCommand,
|
|
5
5
|
reviveStringifiedJson
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-4RZSK5LD.js";
|
|
7
7
|
import "./chunk-44CV5IMX.js";
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-Q3OY2F6W.js";
|
|
9
|
+
import "./chunk-OADHUAEU.js";
|
|
10
|
+
import "./chunk-TXTRXV74.js";
|
|
11
|
+
import "./chunk-K6MWE2ZH.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-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-OADHUAEU.js";
|
|
8
|
+
import "./chunk-TXTRXV74.js";
|
|
9
|
+
import "./chunk-K6MWE2ZH.js";
|
|
10
10
|
export {
|
|
11
11
|
addRecord,
|
|
12
12
|
closeBackendIfCached,
|
package/package.json
CHANGED
package/dist/sql-YMHNH3DT.js
DELETED