@vatio-ai/cli 0.121.0 → 0.122.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/lib/telemetry.mjs +63 -7
- package/package.json +1 -1
package/lib/telemetry.mjs
CHANGED
|
@@ -4,18 +4,22 @@
|
|
|
4
4
|
//
|
|
5
5
|
// Every request says which CLI made it, which coding agent is driving it, the
|
|
6
6
|
// session it belongs to and the command it is part of. When a command ends,
|
|
7
|
-
// one event says how: the exit code
|
|
8
|
-
//
|
|
7
|
+
// one event says how: the exit code, how long it took, which Vatio skills the
|
|
8
|
+
// project has and, on failure, what was printed. Never sent: arguments, file
|
|
9
|
+
// contents, secrets, or what a chat said.
|
|
9
10
|
//
|
|
10
11
|
// VATIO_TELEMETRY=0 (or DO_NOT_TRACK=1) turns all of it off except the
|
|
11
12
|
// User-Agent, which only says which version is calling.
|
|
12
13
|
|
|
14
|
+
import { spawnSync } from "node:child_process";
|
|
13
15
|
import { randomUUID } from "node:crypto";
|
|
14
16
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
15
|
-
import { dirname, join } from "node:path";
|
|
17
|
+
import { basename, dirname, join, sep } from "node:path";
|
|
16
18
|
import { arch, homedir, platform } from "node:os";
|
|
19
|
+
import { fileURLToPath } from "node:url";
|
|
17
20
|
|
|
18
21
|
import { configHome } from "./config.mjs";
|
|
22
|
+
import { findSkills } from "./skills-hint.mjs";
|
|
19
23
|
import { VERSION } from "./version.mjs";
|
|
20
24
|
|
|
21
25
|
const SESSION_IDLE_MS = 30 * 60 * 1000;
|
|
@@ -45,7 +49,7 @@ const SUBCOMMANDS = {
|
|
|
45
49
|
|
|
46
50
|
export const USER_AGENT = `vatio-cli/${VERSION} (node ${process.version}; ${platform()} ${arch()})`;
|
|
47
51
|
|
|
48
|
-
const run = { command: null };
|
|
52
|
+
const run = { command: null, startedAt: null };
|
|
49
53
|
|
|
50
54
|
export function telemetryEnabled() {
|
|
51
55
|
const off = ["0", "false", "off", "no"];
|
|
@@ -65,8 +69,51 @@ export function codingAgent() {
|
|
|
65
69
|
// of Codex's once reported as "unknown".
|
|
66
70
|
if (env.CODEX_THREAD_ID || env.CODEX_SESSION_ID || env.CODEX_SANDBOX || env.CODEX_MANAGED_BY_NPM) return "codex";
|
|
67
71
|
if (env.GEMINI_CLI) return "gemini-cli";
|
|
72
|
+
if (env.REPL_ID) return "replit";
|
|
68
73
|
if (env.CI) return "ci";
|
|
69
|
-
|
|
74
|
+
if (process.stdout.isTTY) return "human";
|
|
75
|
+
const parent = launcher();
|
|
76
|
+
return parent ? `unknown:${parent}` : "unknown";
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Run from a checkout of the CLI's own source rather than an installed
|
|
80
|
+
// package: the Vatio team working on the CLI, whose runs are not anyone's
|
|
81
|
+
// usage and are left out of what the team reads.
|
|
82
|
+
export function fromCheckout() {
|
|
83
|
+
return !fileURLToPath(import.meta.url).split(sep).includes("node_modules");
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function reportedAgent() {
|
|
87
|
+
return fromCheckout() ? "vatio-dev" : codingAgent();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// What started this CLI, when no coding agent said so: the first ancestor
|
|
91
|
+
// that is not a shell or Node itself, by its process name ("Windsurf",
|
|
92
|
+
// "opencode"). Nothing else about it is read.
|
|
93
|
+
const NOT_LAUNCHERS = new Set(["sh", "bash", "zsh", "fish", "dash", "ksh", "env", "node", "npm", "npx", "pnpm", "yarn", "bun", "sudo", "xargs", "timeout", "login"]);
|
|
94
|
+
|
|
95
|
+
function launcher() {
|
|
96
|
+
if (platform() === "win32") return null;
|
|
97
|
+
return safely(() => {
|
|
98
|
+
let pid = process.ppid;
|
|
99
|
+
for (let depth = 0; depth < 6 && pid > 1; depth++) {
|
|
100
|
+
const out = spawnSync("ps", ["-o", "ppid=,comm=", "-p", String(pid)], { encoding: "utf8", timeout: 500 });
|
|
101
|
+
const match = /^\s*(\d+)\s+(.+?)\s*$/.exec(out.stdout ?? "");
|
|
102
|
+
if (!match) return null;
|
|
103
|
+
const name = basename(match[2]).replace(/^-/, "");
|
|
104
|
+
if (!NOT_LAUNCHERS.has(name)) return name.replace(/[^\w .-]/g, "").slice(0, 40) || null;
|
|
105
|
+
pid = Number(match[1]);
|
|
106
|
+
}
|
|
107
|
+
return null;
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Which Vatio skills the project has, as `npx @vatio-ai/skills` or the Claude
|
|
112
|
+
// Code plugin left them: "copy 1.28.0", "plugin 1.28.0", or "none".
|
|
113
|
+
function skillsInstalled() {
|
|
114
|
+
const found = safely(() => findSkills(process.cwd())) ?? [];
|
|
115
|
+
const install = found.find((candidate) => candidate.kind === "plugin") ?? found[0];
|
|
116
|
+
return install ? `${install.kind} ${install.version ?? "unknown"}` : "none";
|
|
70
117
|
}
|
|
71
118
|
|
|
72
119
|
export function isCodingAgent() {
|
|
@@ -75,6 +122,7 @@ export function isCodingAgent() {
|
|
|
75
122
|
|
|
76
123
|
export function beginRun(command, args) {
|
|
77
124
|
run.command = commandLabel(command, args);
|
|
125
|
+
run.startedAt = performance.now();
|
|
78
126
|
noticeOnce();
|
|
79
127
|
}
|
|
80
128
|
|
|
@@ -108,7 +156,7 @@ export function clientHeaders() {
|
|
|
108
156
|
if (!telemetryEnabled()) return headers;
|
|
109
157
|
|
|
110
158
|
headers["X-Vatio-Session"] = sessionId();
|
|
111
|
-
headers["X-Vatio-Agent"] =
|
|
159
|
+
headers["X-Vatio-Agent"] = agentHeader();
|
|
112
160
|
if (run.command) headers["X-Vatio-Command"] = run.command;
|
|
113
161
|
return headers;
|
|
114
162
|
}
|
|
@@ -123,6 +171,8 @@ export async function reportRun(config, { exitCode, error = null }) {
|
|
|
123
171
|
kind: "run",
|
|
124
172
|
command: run.command,
|
|
125
173
|
exit_code: exitCode,
|
|
174
|
+
duration_ms: run.startedAt == null ? undefined : Math.round(performance.now() - run.startedAt),
|
|
175
|
+
skills: skillsInstalled(),
|
|
126
176
|
error: error ? describeError(error) : undefined
|
|
127
177
|
}).catch(() => {});
|
|
128
178
|
}
|
|
@@ -136,7 +186,13 @@ export async function sendFeedback(config, message) {
|
|
|
136
186
|
// What the developer chose to send -- `vatio feedback`, `vatio share-session` --
|
|
137
187
|
// says which session and coding agent it came from even with telemetry off.
|
|
138
188
|
export function chosenHeaders() {
|
|
139
|
-
return { ...clientHeaders(), "X-Vatio-Session": sessionId(), "X-Vatio-Agent":
|
|
189
|
+
return { ...clientHeaders(), "X-Vatio-Session": sessionId(), "X-Vatio-Agent": agentHeader() };
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Worked out once per run: finding the launcher asks `ps`.
|
|
193
|
+
function agentHeader() {
|
|
194
|
+
run.agent ??= reportedAgent();
|
|
195
|
+
return run.agent;
|
|
140
196
|
}
|
|
141
197
|
|
|
142
198
|
async function post(config, body, { strict = false } = {}) {
|