@withone/cli 1.45.1 → 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 +12 -0
- package/dist/{chunk-Z4HKASJT.js → chunk-4RZSK5LD.js} +2 -2
- package/dist/{chunk-DZK56R5R.js → chunk-5NLP47QP.js} +2 -2
- package/dist/{chunk-TLRJMJGU.js → chunk-CESNNUKJ.js} +2 -2
- package/dist/{chunk-TVIZC7AC.js → chunk-K6MWE2ZH.js} +122 -1
- package/dist/{chunk-TGWQUBKA.js → chunk-OADHUAEU.js} +2 -2
- package/dist/{chunk-KH4ERRJ5.js → chunk-Q3OY2F6W.js} +2 -2
- package/dist/{chunk-77564KWS.js → chunk-TXTRXV74.js} +1 -1
- package/dist/{embedding-C3E4EAQ7.js → embedding-NVFDR5PK.js} +2 -2
- package/dist/{flow-runner-6KN2ZVXB.js → flow-runner-UWIM4Z2Y.js} +2 -2
- package/dist/index.js +322 -74
- package/dist/{migrate-VV3VOXWJ.js → migrate-DHZ3SI65.js} +5 -5
- package/dist/{runtime-3NDWRLXL.js → runtime-B5GCQ34P.js} +3 -3
- package/dist/sql-5XR53LV5.js +12 -0
- package/package.json +1 -1
- package/dist/sql-ZABEXIXW.js +0 -12
package/README.md
CHANGED
|
@@ -564,6 +564,18 @@ export ONE_NO_AUTO_UPDATE=1
|
|
|
564
564
|
|
|
565
565
|
Run `one update` manually whenever you want to upgrade.
|
|
566
566
|
|
|
567
|
+
### Telemetry
|
|
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. 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
|
+
|
|
571
|
+
To opt out, set any of:
|
|
572
|
+
|
|
573
|
+
```bash
|
|
574
|
+
export ONE_NO_TELEMETRY=1 # also accepted: ONE_DISABLE_TELEMETRY=1, or the cross-tool standard DO_NOT_TRACK=1
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
Telemetry is also disabled automatically when `CI=1`. You can persist the choice by adding `"telemetry": "off"` to `~/.one/config.json`.
|
|
578
|
+
|
|
567
579
|
### Project config (`.onerc`)
|
|
568
580
|
|
|
569
581
|
Drop a `.onerc` file in your project root to override global settings per-project. Simple `KEY=VALUE` format; `#` for comments. Read from the current working directory (no parent lookup).
|
|
@@ -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) {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import path from "path";
|
|
4
4
|
import os from "os";
|
|
5
|
+
import { randomUUID } from "crypto";
|
|
5
6
|
function configDir() {
|
|
6
7
|
return path.join(os.homedir(), ".one");
|
|
7
8
|
}
|
|
@@ -241,6 +242,115 @@ async function ensureWhoAmI(api) {
|
|
|
241
242
|
function getEnvFromApiKey(apiKey) {
|
|
242
243
|
return apiKey.startsWith("sk_test_") ? "test" : "live";
|
|
243
244
|
}
|
|
245
|
+
function deviceIdFile() {
|
|
246
|
+
return path.join(configDir(), "device-id");
|
|
247
|
+
}
|
|
248
|
+
function telemetryNoticeFile() {
|
|
249
|
+
return path.join(configDir(), ".telemetry-notice");
|
|
250
|
+
}
|
|
251
|
+
function getDeviceId() {
|
|
252
|
+
try {
|
|
253
|
+
const existing = fs.readFileSync(deviceIdFile(), "utf-8").trim();
|
|
254
|
+
if (existing) return existing;
|
|
255
|
+
} catch {
|
|
256
|
+
}
|
|
257
|
+
const id = randomUUID();
|
|
258
|
+
try {
|
|
259
|
+
if (!fs.existsSync(configDir())) fs.mkdirSync(configDir(), { mode: 448 });
|
|
260
|
+
fs.writeFileSync(deviceIdFile(), id, { mode: 384 });
|
|
261
|
+
} catch {
|
|
262
|
+
}
|
|
263
|
+
return id;
|
|
264
|
+
}
|
|
265
|
+
function telemetryNoticeShown() {
|
|
266
|
+
return fs.existsSync(telemetryNoticeFile());
|
|
267
|
+
}
|
|
268
|
+
function markTelemetryNoticeShown() {
|
|
269
|
+
try {
|
|
270
|
+
if (!fs.existsSync(configDir())) fs.mkdirSync(configDir(), { mode: 448 });
|
|
271
|
+
fs.writeFileSync(telemetryNoticeFile(), (/* @__PURE__ */ new Date()).toISOString(), { mode: 384 });
|
|
272
|
+
} catch {
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
function analyticsQueueFile() {
|
|
276
|
+
return path.join(configDir(), ".analytics-queue.jsonl");
|
|
277
|
+
}
|
|
278
|
+
var ANALYTICS_QUEUE_MAX = 500;
|
|
279
|
+
function appendAnalyticsQueue(line) {
|
|
280
|
+
try {
|
|
281
|
+
if (!fs.existsSync(configDir())) fs.mkdirSync(configDir(), { mode: 448 });
|
|
282
|
+
fs.appendFileSync(analyticsQueueFile(), `${line}
|
|
283
|
+
`, { mode: 384 });
|
|
284
|
+
} catch {
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
function readAnalyticsQueue() {
|
|
288
|
+
try {
|
|
289
|
+
return fs.readFileSync(analyticsQueueFile(), "utf-8").split("\n").filter(Boolean);
|
|
290
|
+
} catch {
|
|
291
|
+
return [];
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
function writeAnalyticsQueue(lines) {
|
|
295
|
+
try {
|
|
296
|
+
if (lines.length === 0) {
|
|
297
|
+
fs.rmSync(analyticsQueueFile(), { force: true });
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
if (!fs.existsSync(configDir())) fs.mkdirSync(configDir(), { mode: 448 });
|
|
301
|
+
fs.writeFileSync(analyticsQueueFile(), `${lines.slice(-ANALYTICS_QUEUE_MAX).join("\n")}
|
|
302
|
+
`, { mode: 384 });
|
|
303
|
+
} catch {
|
|
304
|
+
}
|
|
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
|
+
}
|
|
244
354
|
|
|
245
355
|
export {
|
|
246
356
|
getProjectRoot,
|
|
@@ -266,5 +376,16 @@ export {
|
|
|
266
376
|
getWhoAmI,
|
|
267
377
|
updateWhoAmI,
|
|
268
378
|
ensureWhoAmI,
|
|
269
|
-
getEnvFromApiKey
|
|
379
|
+
getEnvFromApiKey,
|
|
380
|
+
getDeviceId,
|
|
381
|
+
telemetryNoticeShown,
|
|
382
|
+
markTelemetryNoticeShown,
|
|
383
|
+
appendAnalyticsQueue,
|
|
384
|
+
readAnalyticsQueue,
|
|
385
|
+
writeAnalyticsQueue,
|
|
386
|
+
appendUsageLog,
|
|
387
|
+
readUsageLog,
|
|
388
|
+
writeUsageLog,
|
|
389
|
+
readUsageState,
|
|
390
|
+
writeUsageState
|
|
270
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,14 +101,17 @@ import {
|
|
|
101
101
|
memoryConfigExists,
|
|
102
102
|
setOpenAiApiKey,
|
|
103
103
|
updateMemoryConfig
|
|
104
|
-
} from "./chunk-
|
|
104
|
+
} from "./chunk-TXTRXV74.js";
|
|
105
105
|
import {
|
|
106
|
+
appendAnalyticsQueue,
|
|
107
|
+
appendUsageLog,
|
|
106
108
|
configExists,
|
|
107
109
|
ensureWhoAmI,
|
|
108
110
|
getAccessControl,
|
|
109
111
|
getAccessControlFromAllSources,
|
|
110
112
|
getApiBase,
|
|
111
113
|
getApiKey,
|
|
114
|
+
getDeviceId,
|
|
112
115
|
getEnvFromApiKey,
|
|
113
116
|
getGlobalConfigPath,
|
|
114
117
|
getOpenAiApiKey,
|
|
@@ -116,19 +119,27 @@ import {
|
|
|
116
119
|
getProjectRoot,
|
|
117
120
|
getWhoAmI,
|
|
118
121
|
globalConfigExists,
|
|
122
|
+
markTelemetryNoticeShown,
|
|
119
123
|
projectConfigExists,
|
|
124
|
+
readAnalyticsQueue,
|
|
120
125
|
readConfig,
|
|
121
126
|
readGlobalConfig,
|
|
122
127
|
readProjectConfig,
|
|
128
|
+
readUsageLog,
|
|
129
|
+
readUsageState,
|
|
123
130
|
resolveConfig,
|
|
131
|
+
telemetryNoticeShown,
|
|
124
132
|
updateAccessControl,
|
|
125
133
|
updateApiBase,
|
|
126
134
|
updateWhoAmI,
|
|
127
|
-
|
|
128
|
-
|
|
135
|
+
writeAnalyticsQueue,
|
|
136
|
+
writeConfig,
|
|
137
|
+
writeUsageLog,
|
|
138
|
+
writeUsageState
|
|
139
|
+
} from "./chunk-K6MWE2ZH.js";
|
|
129
140
|
|
|
130
141
|
// src/cli.ts
|
|
131
|
-
import { createRequire as
|
|
142
|
+
import { createRequire as createRequire3 } from "module";
|
|
132
143
|
import path11 from "path";
|
|
133
144
|
import { Command } from "commander";
|
|
134
145
|
|
|
@@ -1018,25 +1029,25 @@ async function loginCommand() {
|
|
|
1018
1029
|
let targetScope = "global";
|
|
1019
1030
|
const existingKey = getApiKey();
|
|
1020
1031
|
if (existingKey) {
|
|
1021
|
-
const
|
|
1032
|
+
const pc15 = (await import("picocolors")).default;
|
|
1022
1033
|
const resolved2 = resolveConfig();
|
|
1023
1034
|
const whoami2 = resolved2.config?.whoami;
|
|
1024
1035
|
const env2 = getEnvFromApiKey(existingKey);
|
|
1025
|
-
const envLabel2 = env2 === "test" ?
|
|
1026
|
-
const currentScope = resolved2.scope === "project" ?
|
|
1036
|
+
const envLabel2 = env2 === "test" ? pc15.yellow("test") : pc15.green("live");
|
|
1037
|
+
const currentScope = resolved2.scope === "project" ? pc15.cyan("local config") : pc15.magenta("global config");
|
|
1027
1038
|
const lines = ["You are already logged in.", ""];
|
|
1028
1039
|
if (whoami2) {
|
|
1029
1040
|
const contextParts2 = [];
|
|
1030
1041
|
if (whoami2.organization) contextParts2.push(whoami2.organization.name);
|
|
1031
1042
|
if (whoami2.project) contextParts2.push(whoami2.project.name);
|
|
1032
1043
|
const scopeDisplay2 = contextParts2.length > 0 ? contextParts2.join(" / ") : "Personal";
|
|
1033
|
-
lines.push(`${
|
|
1034
|
-
lines.push(`${whoami2.user.name} ${
|
|
1035
|
-
if (whoami2.organization) lines.push(`${
|
|
1036
|
-
if (whoami2.project) lines.push(`${
|
|
1044
|
+
lines.push(`${pc15.bold(scopeDisplay2)} ${pc15.dim("\xB7")} ${envLabel2}`);
|
|
1045
|
+
lines.push(`${whoami2.user.name} ${pc15.dim(`(${whoami2.user.email})`)}`);
|
|
1046
|
+
if (whoami2.organization) lines.push(`${pc15.dim("Org:")} ${whoami2.organization.name}`);
|
|
1047
|
+
if (whoami2.project) lines.push(`${pc15.dim("Project:")} ${whoami2.project.name}`);
|
|
1037
1048
|
}
|
|
1038
1049
|
lines.push("");
|
|
1039
|
-
lines.push(`${
|
|
1050
|
+
lines.push(`${pc15.dim("Stored in")} ${currentScope}`);
|
|
1040
1051
|
p2.note(lines.join("\n"));
|
|
1041
1052
|
const scopeChoice = await p2.select({
|
|
1042
1053
|
message: "Where would you like to log in?",
|
|
@@ -1059,40 +1070,40 @@ async function loginCommand() {
|
|
|
1059
1070
|
if (resolved.config) {
|
|
1060
1071
|
writeConfig({ ...resolved.config, whoami }, targetScope);
|
|
1061
1072
|
}
|
|
1062
|
-
const
|
|
1073
|
+
const pc14 = (await import("picocolors")).default;
|
|
1063
1074
|
const env = getEnvFromApiKey(apiKey);
|
|
1064
1075
|
const contextParts = [];
|
|
1065
1076
|
if (whoami.organization) contextParts.push(whoami.organization.name);
|
|
1066
1077
|
if (whoami.project) contextParts.push(whoami.project.name);
|
|
1067
1078
|
const scopeDisplay = contextParts.length > 0 ? contextParts.join(" / ") : "Personal";
|
|
1068
|
-
const envLabel = env === "test" ?
|
|
1069
|
-
const configLabel = targetScope === "project" ?
|
|
1079
|
+
const envLabel = env === "test" ? pc14.yellow("test") : pc14.green("live");
|
|
1080
|
+
const configLabel = targetScope === "project" ? pc14.cyan("local config") : pc14.magenta("global config");
|
|
1070
1081
|
const infoLines = [
|
|
1071
|
-
`${
|
|
1072
|
-
`${whoami.user.name} ${
|
|
1082
|
+
`${pc14.bold(scopeDisplay)} ${pc14.dim("\xB7")} ${envLabel}`,
|
|
1083
|
+
`${whoami.user.name} ${pc14.dim(`(${whoami.user.email})`)}`
|
|
1073
1084
|
];
|
|
1074
|
-
if (whoami.organization) infoLines.push(`${
|
|
1075
|
-
if (whoami.project) infoLines.push(`${
|
|
1085
|
+
if (whoami.organization) infoLines.push(`${pc14.dim("Org:")} ${whoami.organization.name}`);
|
|
1086
|
+
if (whoami.project) infoLines.push(`${pc14.dim("Project:")} ${whoami.project.name}`);
|
|
1076
1087
|
infoLines.push("");
|
|
1077
|
-
infoLines.push(`${
|
|
1088
|
+
infoLines.push(`${pc14.dim("Stored in")} ${configLabel}`);
|
|
1078
1089
|
p2.note(infoLines.join("\n"), "Logged in");
|
|
1079
1090
|
console.log();
|
|
1080
|
-
console.log(` ${
|
|
1081
|
-
console.log(` ${
|
|
1091
|
+
console.log(` ${pc14.dim("Next steps:")}`);
|
|
1092
|
+
console.log(` ${pc14.cyan("one add <platform>")} ${pc14.dim("\u2014")} Connect a platform (e.g. gmail, slack, stripe)`);
|
|
1082
1093
|
console.log();
|
|
1083
|
-
console.log(
|
|
1094
|
+
console.log(pc14.bold(" Copy-paste this to your AI agent:"));
|
|
1084
1095
|
console.log();
|
|
1085
|
-
console.log(
|
|
1086
|
-
console.log(
|
|
1087
|
-
console.log(
|
|
1088
|
-
console.log(
|
|
1089
|
-
console.log(
|
|
1090
|
-
console.log(
|
|
1091
|
-
console.log(
|
|
1092
|
-
console.log(
|
|
1093
|
-
console.log(
|
|
1094
|
-
console.log(
|
|
1095
|
-
console.log(
|
|
1096
|
+
console.log(pc14.cyan(" \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
|
|
1097
|
+
console.log(pc14.cyan(" \u2502"));
|
|
1098
|
+
console.log(pc14.cyan(" \u2502 The One CLI (`one`) is now installed on this machine. It"));
|
|
1099
|
+
console.log(pc14.cyan(" \u2502 lets you interact with 400+ third-party platforms (Gmail,"));
|
|
1100
|
+
console.log(pc14.cyan(" \u2502 Slack, Shopify, HubSpot, Stripe, GitHub, etc.) through"));
|
|
1101
|
+
console.log(pc14.cyan(" \u2502 their APIs. Whenever you need to interact with any"));
|
|
1102
|
+
console.log(pc14.cyan(" \u2502 third-party platform or external service, use the `one`"));
|
|
1103
|
+
console.log(pc14.cyan(" \u2502 skill. Please save this to your project instructions or"));
|
|
1104
|
+
console.log(pc14.cyan(" \u2502 memory so you remember it in future conversations."));
|
|
1105
|
+
console.log(pc14.cyan(" \u2502"));
|
|
1106
|
+
console.log(pc14.cyan(" \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
|
|
1096
1107
|
console.log();
|
|
1097
1108
|
p2.outro("Happy building!");
|
|
1098
1109
|
}
|
|
@@ -5720,7 +5731,7 @@ async function syncModel(api, profile, options) {
|
|
|
5720
5731
|
updateModelState(platform, model, { status: "failed", pagesProcessed, lastCursor }),
|
|
5721
5732
|
(async () => {
|
|
5722
5733
|
try {
|
|
5723
|
-
const { getBackend: getBackend2 } = await import("./runtime-
|
|
5734
|
+
const { getBackend: getBackend2 } = await import("./runtime-B5GCQ34P.js");
|
|
5724
5735
|
const backend = await getBackend2();
|
|
5725
5736
|
await Promise.race([
|
|
5726
5737
|
backend.close(),
|
|
@@ -6075,7 +6086,7 @@ async function syncModel(api, profile, options) {
|
|
|
6075
6086
|
db.exec(`DROP TABLE IF EXISTS _seen_ids`);
|
|
6076
6087
|
}
|
|
6077
6088
|
if (options.toMemory !== false) {
|
|
6078
|
-
const backend = await (await import("./runtime-
|
|
6089
|
+
const backend = await (await import("./runtime-B5GCQ34P.js")).getBackend();
|
|
6079
6090
|
const type = `${platform}/${model}`;
|
|
6080
6091
|
const existing = await backend.listKeysByType(type);
|
|
6081
6092
|
const sourcePrefix = `${type}:`;
|
|
@@ -6155,7 +6166,7 @@ async function syncModel(api, profile, options) {
|
|
|
6155
6166
|
let statusCounts;
|
|
6156
6167
|
if (options.toMemory !== false) {
|
|
6157
6168
|
try {
|
|
6158
|
-
const backend = await (await import("./runtime-
|
|
6169
|
+
const backend = await (await import("./runtime-B5GCQ34P.js")).getBackend();
|
|
6159
6170
|
const typeName = `${platform}/${model}`;
|
|
6160
6171
|
const [active, archived] = await Promise.all([
|
|
6161
6172
|
backend.count(typeName, { status: "active" }),
|
|
@@ -7788,7 +7799,7 @@ ${result.total} results`);
|
|
|
7788
7799
|
}
|
|
7789
7800
|
}
|
|
7790
7801
|
async function syncSqlCommand(platformModel, sql) {
|
|
7791
|
-
const { syncSqlCommand: runSyncSql } = await import("./sql-
|
|
7802
|
+
const { syncSqlCommand: runSyncSql } = await import("./sql-5XR53LV5.js");
|
|
7792
7803
|
await runSyncSql(platformModel, sql);
|
|
7793
7804
|
}
|
|
7794
7805
|
async function syncDeleteCommand(platformModel, options) {
|
|
@@ -7866,7 +7877,7 @@ async function syncDeleteCommand(platformModel, options) {
|
|
|
7866
7877
|
async function maybeAutoMigrateLegacy(platform, models) {
|
|
7867
7878
|
const dbSize = getDatabaseSize(platform);
|
|
7868
7879
|
if (!dbSize || dbSize === "0 B") return;
|
|
7869
|
-
const { getBackend: getBackend2 } = await import("./runtime-
|
|
7880
|
+
const { getBackend: getBackend2 } = await import("./runtime-B5GCQ34P.js");
|
|
7870
7881
|
const backend = await getBackend2();
|
|
7871
7882
|
let memoryHasData = false;
|
|
7872
7883
|
for (const model of models) {
|
|
@@ -7882,7 +7893,7 @@ async function maybeAutoMigrateLegacy(platform, models) {
|
|
|
7882
7893
|
` detected legacy .one/sync/data/${platform}.db (${dbSize}) \u2014 auto-migrating into memory before sync.
|
|
7883
7894
|
`
|
|
7884
7895
|
);
|
|
7885
|
-
const { memMigrateCommand: memMigrateCommand3 } = await import("./migrate-
|
|
7896
|
+
const { memMigrateCommand: memMigrateCommand3 } = await import("./migrate-DHZ3SI65.js");
|
|
7886
7897
|
await memMigrateCommand3({ platform, yes: true });
|
|
7887
7898
|
return;
|
|
7888
7899
|
}
|
|
@@ -7891,7 +7902,7 @@ async function maybeAutoMigrateLegacy(platform, models) {
|
|
|
7891
7902
|
initialValue: true
|
|
7892
7903
|
});
|
|
7893
7904
|
if (p7.isCancel(shouldMigrate) || !shouldMigrate) return;
|
|
7894
|
-
const { memMigrateCommand: memMigrateCommand2 } = await import("./migrate-
|
|
7905
|
+
const { memMigrateCommand: memMigrateCommand2 } = await import("./migrate-DHZ3SI65.js");
|
|
7895
7906
|
await memMigrateCommand2({ platform, yes: true });
|
|
7896
7907
|
}
|
|
7897
7908
|
async function syncSuggestSearchableCommand(platformModel, options = {}) {
|
|
@@ -7952,7 +7963,7 @@ async function syncSuggestSearchableCommand(platformModel, options = {}) {
|
|
|
7952
7963
|
async function syncListCommand(platform) {
|
|
7953
7964
|
const profiles = listProfiles(platform);
|
|
7954
7965
|
const state = await readSyncState();
|
|
7955
|
-
const { getBackend: getBackend2 } = await import("./runtime-
|
|
7966
|
+
const { getBackend: getBackend2 } = await import("./runtime-B5GCQ34P.js");
|
|
7956
7967
|
const backend = await getBackend2();
|
|
7957
7968
|
const syncs = await Promise.all(profiles.map(async (p10) => {
|
|
7958
7969
|
const modelState = state[p10.platform]?.[p10.model];
|
|
@@ -8870,7 +8881,7 @@ async function memDoctorCommand() {
|
|
|
8870
8881
|
}
|
|
8871
8882
|
if (cfg.embedding.provider === "openai") {
|
|
8872
8883
|
try {
|
|
8873
|
-
const { embed: embed2 } = await import("./embedding-
|
|
8884
|
+
const { embed: embed2 } = await import("./embedding-NVFDR5PK.js");
|
|
8874
8885
|
const result = await embed2("connectivity check");
|
|
8875
8886
|
checks.push({
|
|
8876
8887
|
name: "OpenAI embedding provider reachable",
|
|
@@ -10608,20 +10619,20 @@ function buildWorkflowIdeas(connections) {
|
|
|
10608
10619
|
// src/commands/logout.ts
|
|
10609
10620
|
import fs12 from "fs";
|
|
10610
10621
|
import * as p9 from "@clack/prompts";
|
|
10611
|
-
function formatWhoami(config2, apiKey,
|
|
10622
|
+
function formatWhoami(config2, apiKey, pc14) {
|
|
10612
10623
|
const whoami = config2.whoami;
|
|
10613
10624
|
const env = getEnvFromApiKey(apiKey);
|
|
10614
|
-
const envLabel = env === "test" ?
|
|
10625
|
+
const envLabel = env === "test" ? pc14.yellow("test") : pc14.green("live");
|
|
10615
10626
|
const lines = [];
|
|
10616
10627
|
if (whoami) {
|
|
10617
10628
|
const contextParts = [];
|
|
10618
10629
|
if (whoami.organization) contextParts.push(whoami.organization.name);
|
|
10619
10630
|
if (whoami.project) contextParts.push(whoami.project.name);
|
|
10620
10631
|
const scopeDisplay = contextParts.length > 0 ? contextParts.join(" / ") : "Personal";
|
|
10621
|
-
lines.push(`${
|
|
10622
|
-
lines.push(`${whoami.user.name} ${
|
|
10632
|
+
lines.push(`${pc14.bold(scopeDisplay)} ${pc14.dim("\xB7")} ${envLabel}`);
|
|
10633
|
+
lines.push(`${whoami.user.name} ${pc14.dim(`(${whoami.user.email})`)}`);
|
|
10623
10634
|
} else {
|
|
10624
|
-
lines.push(`${
|
|
10635
|
+
lines.push(`${pc14.dim("Key:")} ${apiKey.slice(0, 8)}... ${pc14.dim("\xB7")} ${envLabel}`);
|
|
10625
10636
|
}
|
|
10626
10637
|
return lines;
|
|
10627
10638
|
}
|
|
@@ -10650,7 +10661,7 @@ async function logoutCommand() {
|
|
|
10650
10661
|
json({ status: cleared ? "logged_out" : "not_logged_in", message: cleared ? "Credentials cleared." : "No config found." });
|
|
10651
10662
|
return;
|
|
10652
10663
|
}
|
|
10653
|
-
const
|
|
10664
|
+
const pc14 = (await import("picocolors")).default;
|
|
10654
10665
|
const globalConfig = readGlobalConfig();
|
|
10655
10666
|
const projectConfig = readProjectConfig();
|
|
10656
10667
|
const hasGlobal = globalConfig?.apiKey != null;
|
|
@@ -10659,13 +10670,13 @@ async function logoutCommand() {
|
|
|
10659
10670
|
if (hasGlobal && hasProject) {
|
|
10660
10671
|
const infoLines = ["You are logged in with multiple configs.", ""];
|
|
10661
10672
|
if (projectConfig) {
|
|
10662
|
-
infoLines.push(`${
|
|
10663
|
-
infoLines.push(...formatWhoami(projectConfig, projectConfig.apiKey,
|
|
10673
|
+
infoLines.push(`${pc14.cyan("Local config:")}`);
|
|
10674
|
+
infoLines.push(...formatWhoami(projectConfig, projectConfig.apiKey, pc14));
|
|
10664
10675
|
infoLines.push("");
|
|
10665
10676
|
}
|
|
10666
10677
|
if (globalConfig) {
|
|
10667
|
-
infoLines.push(`${
|
|
10668
|
-
infoLines.push(...formatWhoami(globalConfig, globalConfig.apiKey,
|
|
10678
|
+
infoLines.push(`${pc14.magenta("Global config:")}`);
|
|
10679
|
+
infoLines.push(...formatWhoami(globalConfig, globalConfig.apiKey, pc14));
|
|
10669
10680
|
}
|
|
10670
10681
|
p9.note(infoLines.join("\n"));
|
|
10671
10682
|
const choice = await p9.select({
|
|
@@ -10683,14 +10694,14 @@ async function logoutCommand() {
|
|
|
10683
10694
|
targetScope = choice;
|
|
10684
10695
|
} else if (hasProject) {
|
|
10685
10696
|
const infoLines = ["You are logged in.", ""];
|
|
10686
|
-
infoLines.push(`${
|
|
10687
|
-
infoLines.push(...formatWhoami(projectConfig, projectConfig.apiKey,
|
|
10697
|
+
infoLines.push(`${pc14.dim("Stored in")} ${pc14.cyan("local config")}`);
|
|
10698
|
+
infoLines.push(...formatWhoami(projectConfig, projectConfig.apiKey, pc14));
|
|
10688
10699
|
p9.note(infoLines.join("\n"));
|
|
10689
10700
|
targetScope = "project";
|
|
10690
10701
|
} else if (hasGlobal) {
|
|
10691
10702
|
const infoLines = ["You are logged in.", ""];
|
|
10692
|
-
infoLines.push(`${
|
|
10693
|
-
infoLines.push(...formatWhoami(globalConfig, globalConfig.apiKey,
|
|
10703
|
+
infoLines.push(`${pc14.dim("Stored in")} ${pc14.magenta("global config")}`);
|
|
10704
|
+
infoLines.push(...formatWhoami(globalConfig, globalConfig.apiKey, pc14));
|
|
10694
10705
|
p9.note(infoLines.join("\n"));
|
|
10695
10706
|
targetScope = "global";
|
|
10696
10707
|
} else {
|
|
@@ -10724,9 +10735,241 @@ async function logoutCommand() {
|
|
|
10724
10735
|
p9.outro("Logged out.");
|
|
10725
10736
|
}
|
|
10726
10737
|
|
|
10727
|
-
// src/
|
|
10738
|
+
// src/lib/analytics.ts
|
|
10739
|
+
import { createRequire as createRequire2 } from "module";
|
|
10740
|
+
import { randomUUID } from "crypto";
|
|
10741
|
+
import pc13 from "picocolors";
|
|
10728
10742
|
var require3 = createRequire2(import.meta.url);
|
|
10729
|
-
var
|
|
10743
|
+
var DEFAULT_POSTHOG_HOST = "https://us.i.posthog.com";
|
|
10744
|
+
var DEFAULT_POSTHOG_KEY = "phc_a9ok4w0uxiZcVoSWOISIlin85lHMXQD3vWPaYnuRlRV";
|
|
10745
|
+
var inFlight = /* @__PURE__ */ new Set();
|
|
10746
|
+
var delivered = /* @__PURE__ */ new Set();
|
|
10747
|
+
function posthogHost() {
|
|
10748
|
+
return process.env.ONE_POSTHOG_HOST || DEFAULT_POSTHOG_HOST;
|
|
10749
|
+
}
|
|
10750
|
+
function posthogKey() {
|
|
10751
|
+
return process.env.ONE_POSTHOG_KEY || DEFAULT_POSTHOG_KEY;
|
|
10752
|
+
}
|
|
10753
|
+
function cliVersion() {
|
|
10754
|
+
try {
|
|
10755
|
+
return require3("../package.json").version;
|
|
10756
|
+
} catch {
|
|
10757
|
+
return "unknown";
|
|
10758
|
+
}
|
|
10759
|
+
}
|
|
10760
|
+
function envName() {
|
|
10761
|
+
const key = getApiKey();
|
|
10762
|
+
return key ? getEnvFromApiKey(key) : "live";
|
|
10763
|
+
}
|
|
10764
|
+
function isOn(value) {
|
|
10765
|
+
return value === "1" || value === "true";
|
|
10766
|
+
}
|
|
10767
|
+
function debugLog(message) {
|
|
10768
|
+
if (isOn(process.env.ONE_ANALYTICS_DEBUG)) {
|
|
10769
|
+
process.stderr.write(`[analytics] ${message}
|
|
10770
|
+
`);
|
|
10771
|
+
}
|
|
10772
|
+
}
|
|
10773
|
+
function isTelemetryDisabled() {
|
|
10774
|
+
if (isOn(process.env.ONE_NO_TELEMETRY) || isOn(process.env.ONE_DISABLE_TELEMETRY)) return true;
|
|
10775
|
+
if (isOn(process.env.DO_NOT_TRACK)) return true;
|
|
10776
|
+
if (isOn(process.env.CI)) return true;
|
|
10777
|
+
if (readConfig()?.telemetry === "off") return true;
|
|
10778
|
+
return false;
|
|
10779
|
+
}
|
|
10780
|
+
function distinctId() {
|
|
10781
|
+
return getWhoAmI()?.user?.id ?? getDeviceId();
|
|
10782
|
+
}
|
|
10783
|
+
function baseProperties() {
|
|
10784
|
+
return {
|
|
10785
|
+
$lib: "one-cli",
|
|
10786
|
+
cli_version: cliVersion(),
|
|
10787
|
+
agent_mode: isAgentMode(),
|
|
10788
|
+
env: envName(),
|
|
10789
|
+
os: process.platform,
|
|
10790
|
+
arch: process.arch,
|
|
10791
|
+
node_version: process.versions.node
|
|
10792
|
+
};
|
|
10793
|
+
}
|
|
10794
|
+
function personSet() {
|
|
10795
|
+
const whoami = getWhoAmI();
|
|
10796
|
+
if (!whoami?.user) return void 0;
|
|
10797
|
+
const set = {};
|
|
10798
|
+
if (whoami.user.email) set.email = whoami.user.email;
|
|
10799
|
+
if (whoami.user.name) set.name = whoami.user.name;
|
|
10800
|
+
if (whoami.organization?.id) set.organization_id = whoami.organization.id;
|
|
10801
|
+
return Object.keys(set).length ? set : void 0;
|
|
10802
|
+
}
|
|
10803
|
+
function send(item) {
|
|
10804
|
+
const insertId = item.properties.$insert_id;
|
|
10805
|
+
const controller = new AbortController();
|
|
10806
|
+
inFlight.add(controller);
|
|
10807
|
+
void (async () => {
|
|
10808
|
+
try {
|
|
10809
|
+
const res = await fetch(`${posthogHost()}/i/v0/e/`, {
|
|
10810
|
+
method: "POST",
|
|
10811
|
+
headers: { "Content-Type": "application/json" },
|
|
10812
|
+
body: JSON.stringify({
|
|
10813
|
+
api_key: posthogKey(),
|
|
10814
|
+
event: item.event,
|
|
10815
|
+
distinct_id: item.distinct_id,
|
|
10816
|
+
properties: item.properties,
|
|
10817
|
+
timestamp: item.timestamp
|
|
10818
|
+
}),
|
|
10819
|
+
signal: controller.signal
|
|
10820
|
+
});
|
|
10821
|
+
if (res.ok && insertId) delivered.add(insertId);
|
|
10822
|
+
debugLog(`"${item.event}" -> HTTP ${res.status}${res.ok ? "" : " (retry next run)"}`);
|
|
10823
|
+
} catch (err) {
|
|
10824
|
+
debugLog(`"${item.event}" not sent: ${err instanceof Error ? err.message : String(err)} (retry next run)`);
|
|
10825
|
+
} finally {
|
|
10826
|
+
inFlight.delete(controller);
|
|
10827
|
+
}
|
|
10828
|
+
})();
|
|
10829
|
+
}
|
|
10830
|
+
function capture(event, properties = {}, opts = {}) {
|
|
10831
|
+
if (isTelemetryDisabled()) {
|
|
10832
|
+
debugLog(`disabled \u2014 skipping "${event}"`);
|
|
10833
|
+
return;
|
|
10834
|
+
}
|
|
10835
|
+
const did = opts.distinctId ?? distinctId();
|
|
10836
|
+
const props = { ...baseProperties(), ...properties, $insert_id: randomUUID() };
|
|
10837
|
+
if (did === distinctId()) {
|
|
10838
|
+
const set = personSet();
|
|
10839
|
+
if (set) props.$set = set;
|
|
10840
|
+
}
|
|
10841
|
+
const item = {
|
|
10842
|
+
event,
|
|
10843
|
+
distinct_id: did,
|
|
10844
|
+
properties: props,
|
|
10845
|
+
timestamp: opts.timestamp ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
10846
|
+
};
|
|
10847
|
+
appendAnalyticsQueue(JSON.stringify(item));
|
|
10848
|
+
}
|
|
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}`);
|
|
10924
|
+
}
|
|
10925
|
+
function commandPath(command) {
|
|
10926
|
+
const parts = [];
|
|
10927
|
+
let current = command;
|
|
10928
|
+
while (current && current.name() && current.name() !== "one") {
|
|
10929
|
+
parts.unshift(current.name());
|
|
10930
|
+
current = current.parent;
|
|
10931
|
+
}
|
|
10932
|
+
return parts.join(" ") || command.name();
|
|
10933
|
+
}
|
|
10934
|
+
function drainQueue() {
|
|
10935
|
+
if (isTelemetryDisabled()) {
|
|
10936
|
+
writeAnalyticsQueue([]);
|
|
10937
|
+
return;
|
|
10938
|
+
}
|
|
10939
|
+
for (const line of readAnalyticsQueue()) {
|
|
10940
|
+
try {
|
|
10941
|
+
const item = JSON.parse(line);
|
|
10942
|
+
if (item?.properties?.$insert_id) send(item);
|
|
10943
|
+
} catch {
|
|
10944
|
+
}
|
|
10945
|
+
}
|
|
10946
|
+
}
|
|
10947
|
+
function flush() {
|
|
10948
|
+
for (const controller of inFlight) controller.abort();
|
|
10949
|
+
const remaining = readAnalyticsQueue().filter((line) => {
|
|
10950
|
+
try {
|
|
10951
|
+
const id = JSON.parse(line).properties?.$insert_id;
|
|
10952
|
+
return id ? !delivered.has(id) : false;
|
|
10953
|
+
} catch {
|
|
10954
|
+
return false;
|
|
10955
|
+
}
|
|
10956
|
+
});
|
|
10957
|
+
writeAnalyticsQueue(remaining);
|
|
10958
|
+
}
|
|
10959
|
+
function maybeShowTelemetryNotice() {
|
|
10960
|
+
if (isTelemetryDisabled() || isAgentMode()) return;
|
|
10961
|
+
if (telemetryNoticeShown()) return;
|
|
10962
|
+
markTelemetryNoticeShown();
|
|
10963
|
+
process.stderr.write(
|
|
10964
|
+
pc13.dim(
|
|
10965
|
+
"One CLI collects usage analytics (which commands run, linked to your One account) to improve the product.\nNo arguments, inputs, or secrets are ever collected. Opt out anytime with ONE_NO_TELEMETRY=1.\n"
|
|
10966
|
+
)
|
|
10967
|
+
);
|
|
10968
|
+
}
|
|
10969
|
+
|
|
10970
|
+
// src/cli.ts
|
|
10971
|
+
var require4 = createRequire3(import.meta.url);
|
|
10972
|
+
var { version } = require4("../package.json");
|
|
10730
10973
|
var program = new Command();
|
|
10731
10974
|
program.name("one").option("--agent", "Machine-readable JSON output (no colors, spinners, or prompts)").description(`One CLI \u2014 Connect AI agents to 400+ platforms through one interface.
|
|
10732
10975
|
|
|
@@ -10802,11 +11045,14 @@ program.name("one").option("--agent", "Machine-readable JSON output (no colors,
|
|
|
10802
11045
|
Platform names are lowercase; multi-word names use dashes (e.g. hubspot, ship-station, google-calendar).
|
|
10803
11046
|
Run 'one platforms' to browse all 400+ available platforms.`).version(version);
|
|
10804
11047
|
var updateCheckPromise;
|
|
10805
|
-
program.hook("preAction", (thisCommand) => {
|
|
11048
|
+
program.hook("preAction", (thisCommand, actionCommand) => {
|
|
10806
11049
|
const opts = program.opts();
|
|
10807
11050
|
if (opts.agent) {
|
|
10808
11051
|
setAgentMode(true);
|
|
10809
11052
|
}
|
|
11053
|
+
maybeShowTelemetryNotice();
|
|
11054
|
+
recordCommand(actionCommand);
|
|
11055
|
+
drainQueue();
|
|
10810
11056
|
const commandName = thisCommand.args?.[0];
|
|
10811
11057
|
if (commandName !== "update") {
|
|
10812
11058
|
updateCheckPromise = checkLatestVersionCached();
|
|
@@ -10820,6 +11066,8 @@ program.hook("preAction", (thisCommand) => {
|
|
|
10820
11066
|
});
|
|
10821
11067
|
program.hook("postAction", async () => {
|
|
10822
11068
|
await closeBackendIfCached();
|
|
11069
|
+
flushUsageRollups();
|
|
11070
|
+
flush();
|
|
10823
11071
|
if (!updateCheckPromise) return;
|
|
10824
11072
|
const info = await updateCheckPromise;
|
|
10825
11073
|
if (!info) return;
|
|
@@ -11138,21 +11386,21 @@ program.command("whoami").description("Show the user, organization, and project
|
|
|
11138
11386
|
});
|
|
11139
11387
|
return;
|
|
11140
11388
|
}
|
|
11141
|
-
const
|
|
11389
|
+
const pc14 = (await import("picocolors")).default;
|
|
11142
11390
|
const contextParts = [];
|
|
11143
11391
|
if (whoami.organization) contextParts.push(whoami.organization.name);
|
|
11144
11392
|
if (whoami.project) contextParts.push(whoami.project.name);
|
|
11145
11393
|
const scopeDisplay = contextParts.length > 0 ? contextParts.join(" / ") : "Personal";
|
|
11146
|
-
const envLabel = env === "test" ?
|
|
11147
|
-
const configLabel = configScope === "project" ?
|
|
11394
|
+
const envLabel = env === "test" ? pc14.yellow("test") : pc14.green("live");
|
|
11395
|
+
const configLabel = configScope === "project" ? pc14.cyan("project config") : pc14.magenta("global config");
|
|
11148
11396
|
console.log();
|
|
11149
|
-
console.log(` ${
|
|
11150
|
-
console.log(` ${whoami.user.name} ${
|
|
11151
|
-
if (whoami.organization) console.log(` ${
|
|
11152
|
-
if (whoami.project) console.log(` ${
|
|
11397
|
+
console.log(` ${pc14.bold(scopeDisplay)} ${pc14.dim("\xB7")} ${envLabel}`);
|
|
11398
|
+
console.log(` ${whoami.user.name} ${pc14.dim(`(${whoami.user.email})`)}`);
|
|
11399
|
+
if (whoami.organization) console.log(` ${pc14.dim("Org:")} ${whoami.organization.name} ${pc14.dim(`(${whoami.organization.id})`)}`);
|
|
11400
|
+
if (whoami.project) console.log(` ${pc14.dim("Project:")} ${whoami.project.name} ${pc14.dim(`(${whoami.project.id})`)}`);
|
|
11153
11401
|
console.log();
|
|
11154
|
-
console.log(` ${
|
|
11155
|
-
console.log(` ${
|
|
11402
|
+
console.log(` ${pc14.dim("Using")} ${configLabel}`);
|
|
11403
|
+
console.log(` ${pc14.dim("API:")} ${apiBase}`);
|
|
11156
11404
|
console.log();
|
|
11157
11405
|
});
|
|
11158
11406
|
program.command("add [platform]").description("Shortcut for: connection add").action(async (platform) => {
|
|
@@ -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-ZABEXIXW.js
DELETED