@vatio-ai/cli 0.88.0 → 0.90.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 -0
- package/bin/vatio.mjs +3 -4
- package/lib/api-client.mjs +14 -1
- package/lib/claude-session.mjs +3 -2
- package/lib/codex-session.mjs +223 -0
- package/lib/commands/deploy.mjs +161 -20
- package/lib/commands/support-commands.mjs +57 -23
- package/lib/config.mjs +33 -0
- package/lib/help.mjs +10 -4
- package/lib/http.mjs +12 -0
- package/lib/pull.mjs +605 -0
- package/lib/support.mjs +17 -0
- package/lib/telemetry.mjs +4 -1
- package/package.json +1 -1
|
@@ -6,7 +6,8 @@ import { homedir } from "node:os";
|
|
|
6
6
|
import { dirname, join, resolve } from "node:path";
|
|
7
7
|
import { gzipSync } from "node:zlib";
|
|
8
8
|
|
|
9
|
-
import
|
|
9
|
+
import * as claudeSessions from "../claude-session.mjs";
|
|
10
|
+
import * as codexSessions from "../codex-session.mjs";
|
|
10
11
|
import { configHome } from "../config.mjs";
|
|
11
12
|
import { ask, fail, takeFlag, takeValue } from "../support.mjs";
|
|
12
13
|
import { chosenHeaders, clientHeaders, sendFeedback, telemetryEnabled } from "../telemetry.mjs";
|
|
@@ -86,17 +87,18 @@ export async function shareSession(config, args) {
|
|
|
86
87
|
if (never) return stopOffering();
|
|
87
88
|
|
|
88
89
|
const session = findSession(id);
|
|
89
|
-
const
|
|
90
|
+
const { label, reader } = AGENTS[session.agent];
|
|
91
|
+
const transcript = reader.clean(session);
|
|
90
92
|
if (transcript.messages === 0) fail(`Session ${short(session.id)} has no messages yet.`);
|
|
91
93
|
const gzipped = gzipSync(transcript.jsonl);
|
|
92
94
|
|
|
93
|
-
const { title } = describe(session);
|
|
94
|
-
console.log(
|
|
95
|
+
const { title } = reader.describe(session);
|
|
96
|
+
console.log(`${label} session ${short(session.id)}${title ? ` — ${truncate(title, 70)}` : ""}`);
|
|
95
97
|
console.log(` ${tilde(transcript.cwd ?? process.cwd())}${transcript.gitBranch ? ` (${transcript.gitBranch})` : ""}`);
|
|
96
98
|
console.log(` ${transcript.messages} messages, ${when(transcript.startedAt)} → ${when(transcript.endedAt)}`);
|
|
97
99
|
console.log(` ${size(Buffer.byteLength(transcript.jsonl))}, ${size(gzipped.length)} compressed`);
|
|
98
100
|
console.log(
|
|
99
|
-
` Left out: ${transcript.images > 0 ? `${transcript.images} image(s) and ` : ""}
|
|
101
|
+
` Left out: ${transcript.images > 0 ? `${transcript.images} image(s) and ` : ""}${label}'s own bookkeeping.` +
|
|
100
102
|
(transcript.redactions > 0 ? ` ${transcript.redactions} thing(s) that looked like a key, token or password are [REDACTED].` : "") +
|
|
101
103
|
(transcript.personal > 0 ? ` ${transcript.personal} email address(es) and phone number(s) are [EMAIL] and [PHONE].` : "")
|
|
102
104
|
);
|
|
@@ -133,7 +135,7 @@ export async function shareSession(config, args) {
|
|
|
133
135
|
|
|
134
136
|
const form = new FormData();
|
|
135
137
|
form.set("transcript", new Blob([gzipped], { type: "application/gzip" }), `${session.id}.jsonl.gz`);
|
|
136
|
-
form.set("source",
|
|
138
|
+
form.set("source", session.agent);
|
|
137
139
|
form.set("source_session_id", session.id);
|
|
138
140
|
form.set("messages", String(transcript.messages));
|
|
139
141
|
if (transcript.startedAt) form.set("started_at", transcript.startedAt);
|
|
@@ -173,7 +175,7 @@ function answerShouldAsk() {
|
|
|
173
175
|
console.log(`no — ${reason}`);
|
|
174
176
|
return;
|
|
175
177
|
}
|
|
176
|
-
rememberOffer(
|
|
178
|
+
rememberOffer(currentSession()?.id);
|
|
177
179
|
console.log(
|
|
178
180
|
"yes — ask the person you work for whether to send this session to the Vatio team: send it, " +
|
|
179
181
|
"not now, or don't ask again (`vatio share-session --never`)."
|
|
@@ -185,9 +187,9 @@ function reasonNotToOffer() {
|
|
|
185
187
|
if (!telemetryEnabled()) return "telemetry is off, so they would rather send nothing";
|
|
186
188
|
const state = readOfferState();
|
|
187
189
|
if (state.never) return "they said not to ask again";
|
|
188
|
-
const current =
|
|
189
|
-
if (!current
|
|
190
|
-
if (state.session === current) return "already offered in this session";
|
|
190
|
+
const current = currentSession();
|
|
191
|
+
if (!current) return "only a Claude Code or Codex session can be sent, from inside it";
|
|
192
|
+
if (state.session === current.id) return "already offered in this session";
|
|
191
193
|
if (Date.now() - Date.parse(state.offered_at ?? "") < OFFER_EVERY_MS) return "already offered this week";
|
|
192
194
|
return null;
|
|
193
195
|
}
|
|
@@ -245,36 +247,68 @@ function writeOfferState(state) {
|
|
|
245
247
|
writeFileSync(path, `${JSON.stringify(state)}\n`);
|
|
246
248
|
}
|
|
247
249
|
|
|
248
|
-
// The
|
|
249
|
-
//
|
|
250
|
+
// The coding agents whose sessions can be sent, by the source the upload is
|
|
251
|
+
// tagged with, and how each says which session a command runs in.
|
|
252
|
+
const AGENTS = {
|
|
253
|
+
"claude-code": { label: "Claude Code", reader: claudeSessions, currentId: () => process.env.CLAUDE_CODE_SESSION_ID },
|
|
254
|
+
codex: { label: "Codex", reader: codexSessions, currentId: () => process.env.CODEX_THREAD_ID }
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
// The session this command runs in, when a coding agent we read runs it.
|
|
258
|
+
function currentSession() {
|
|
259
|
+
for (const { reader, currentId } of Object.values(AGENTS)) {
|
|
260
|
+
const id = currentId();
|
|
261
|
+
const session = id ? reader.sessionById(id) : null;
|
|
262
|
+
if (session) return session;
|
|
263
|
+
}
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function sessionById(id) {
|
|
268
|
+
const matches = Object.values(AGENTS).map(({ reader }) => reader.sessionById(id)).filter(Boolean);
|
|
269
|
+
return matches.sort((a, b) => b.modifiedAt - a.modifiedAt)[0] ?? null;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// Every agent's sessions for this directory or the nearest parent, newest
|
|
273
|
+
// first, with what each is about.
|
|
274
|
+
function sessionsHere(limit = Infinity) {
|
|
275
|
+
return Object.values(AGENTS)
|
|
276
|
+
.flatMap(({ reader }) => reader.sessionsFor(process.cwd()).slice(0, limit).map(reader.describe))
|
|
277
|
+
.sort((a, b) => b.modifiedAt - a.modifiedAt);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// The one this coding agent is running in, when it is Claude Code or Codex;
|
|
281
|
+
// otherwise the newest one with a conversation in it, started here or above.
|
|
250
282
|
function findSession(id) {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
const session = sessionById(id ?? current);
|
|
283
|
+
if (id) {
|
|
284
|
+
const session = sessionById(id);
|
|
254
285
|
if (session) return session;
|
|
255
|
-
|
|
286
|
+
fail(`No Claude Code or Codex session ${id} on this machine. \`vatio share-session --list\` shows them.`);
|
|
256
287
|
}
|
|
288
|
+
const current = currentSession();
|
|
289
|
+
if (current) return current;
|
|
257
290
|
|
|
258
|
-
const session =
|
|
291
|
+
const session = sessionsHere().find((candidate) => candidate.messages > 0);
|
|
259
292
|
if (session) return session;
|
|
260
293
|
fail(
|
|
261
|
-
"No Claude Code session found for this directory. Run this from the project
|
|
262
|
-
'
|
|
294
|
+
"No Claude Code or Codex session found for this directory. Run this from the project your coding agent was\n" +
|
|
295
|
+
'working in. From another coding agent, tell us with `vatio feedback "…"`.'
|
|
263
296
|
);
|
|
264
297
|
}
|
|
265
298
|
|
|
266
299
|
function listSessions() {
|
|
267
|
-
const sessions =
|
|
268
|
-
if (sessions.length === 0) fail("No Claude Code sessions for this directory.");
|
|
300
|
+
const sessions = sessionsHere(20).filter((session) => session.messages > 0).slice(0, 10);
|
|
301
|
+
if (sessions.length === 0) fail("No Claude Code or Codex sessions for this directory.");
|
|
269
302
|
|
|
270
|
-
const current =
|
|
303
|
+
const current = currentSession()?.id;
|
|
271
304
|
const sent = sentSessions();
|
|
272
305
|
for (const session of sessions) {
|
|
273
306
|
const mark = session.id === current ? "*" : " ";
|
|
274
307
|
const title = session.title ? truncate(session.title, 60) : "";
|
|
275
308
|
const modified = when(new Date(session.modifiedAt).toISOString());
|
|
276
309
|
const shared = sent[session.id] ? ` (sent #${sent[session.id].id}, ${when(sent[session.id].at)})` : "";
|
|
277
|
-
|
|
310
|
+
const agent = AGENTS[session.agent].label.padEnd(11);
|
|
311
|
+
console.log(`${mark} ${short(session.id)} ${modified} ${agent} ${String(session.messages).padStart(5)} msgs ${title}${shared}`);
|
|
278
312
|
}
|
|
279
313
|
console.log("\nSend one with `vatio share-session --id ID`.");
|
|
280
314
|
}
|
package/lib/config.mjs
CHANGED
|
@@ -177,6 +177,35 @@ export class Config {
|
|
|
177
177
|
return this.save(data);
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
+
// The deployment a workspace's files were last made to match, by a push or
|
|
181
|
+
// a pull, which the next push says it is built on: the platform refuses one
|
|
182
|
+
// that would overwrite edits made since outside the files. Per server and
|
|
183
|
+
// workspace, since a deployment id only means anything on the server that
|
|
184
|
+
// issued it; null when this machine never pushed or pulled it.
|
|
185
|
+
baseDeploymentFor({ baseUrl, workspace }) {
|
|
186
|
+
const all = this.load().base_deployments;
|
|
187
|
+
const id = plainObject(all) && plainObject(all[stripSlash(baseUrl)]) ? all[stripSlash(baseUrl)][workspace] : null;
|
|
188
|
+
return Number.isInteger(id) && id > 0 ? id : null;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// Quietly does nothing when the file cannot be written: the push or pull it
|
|
192
|
+
// follows already happened, and the cost of forgetting is one refused push
|
|
193
|
+
// that says to pull.
|
|
194
|
+
rememberBaseDeployment({ baseUrl, workspace, deploymentId }) {
|
|
195
|
+
const id = Number(deploymentId);
|
|
196
|
+
const server = stripSlash(baseUrl);
|
|
197
|
+
if (!Number.isInteger(id) || id <= 0 || !server || !workspace) return;
|
|
198
|
+
try {
|
|
199
|
+
const data = this.load();
|
|
200
|
+
const all = plainObject(data.base_deployments) ? data.base_deployments : {};
|
|
201
|
+
const forServer = plainObject(all[server]) ? all[server] : {};
|
|
202
|
+
data.base_deployments = { ...all, [server]: { ...forServer, [workspace]: id } };
|
|
203
|
+
this.save(data);
|
|
204
|
+
} catch {
|
|
205
|
+
// See above.
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
180
209
|
displayHash() {
|
|
181
210
|
const out = {};
|
|
182
211
|
const base = this.resolveBaseUrl();
|
|
@@ -238,6 +267,10 @@ function stripSlash(value) {
|
|
|
238
267
|
return value == null ? null : value.replace(/\/$/, "");
|
|
239
268
|
}
|
|
240
269
|
|
|
270
|
+
function plainObject(value) {
|
|
271
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
272
|
+
}
|
|
273
|
+
|
|
241
274
|
function maskSecret(value) {
|
|
242
275
|
if (!value) return null;
|
|
243
276
|
return value.length <= 8 ? value : `${value.slice(0, 4)}…${value.slice(-4)}`;
|
package/lib/help.mjs
CHANGED
|
@@ -27,8 +27,8 @@ Commands default as listed.
|
|
|
27
27
|
version What this CLI is
|
|
28
28
|
docs [--save [PATH]] The whole developer contract, live from Vatio
|
|
29
29
|
feedback "TEXT" Tell the Vatio team what got in the way
|
|
30
|
-
share-session ["FEEDBACK"] Send this Claude Code session to the
|
|
31
|
-
after showing what goes; feedback optional
|
|
30
|
+
share-session ["FEEDBACK"] Send this Claude Code or Codex session to the
|
|
31
|
+
Vatio team, after showing what goes; feedback optional
|
|
32
32
|
(--save FILE, --list, --id ID; --yes from a
|
|
33
33
|
coding agent)
|
|
34
34
|
share-session --should-ask Whether a coding agent should offer to send it
|
|
@@ -38,8 +38,14 @@ Commands default as listed.
|
|
|
38
38
|
Deploy:
|
|
39
39
|
push [--force] Validate the workspace, then update preview; runs
|
|
40
40
|
no tests (the first push signs in like \`login\`).
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
Refused over edits made outside your files (pull
|
|
42
|
+
them first) and over an unpublished push from
|
|
43
|
+
another git branch; --force replaces either
|
|
44
|
+
pull [--env NAME] [--force]
|
|
45
|
+
Write the deployed agent into vatio.yml's agent:
|
|
46
|
+
block and tools/, edits from the Vatio MCP
|
|
47
|
+
included (default: preview). Wants vatio.yml and
|
|
48
|
+
tools/ committed to git; --force writes anyway
|
|
43
49
|
publish [--force] Take preview live, with its knowledge changes.
|
|
44
50
|
Once published, refused until \`vatio test\` has
|
|
45
51
|
tested preview's version, and while it fails a
|
package/lib/http.mjs
CHANGED
|
@@ -21,6 +21,17 @@ export class UnauthorizedError extends HttpError {}
|
|
|
21
21
|
export class ForbiddenError extends HttpError {}
|
|
22
22
|
export class NotFoundError extends HttpError {}
|
|
23
23
|
|
|
24
|
+
// 409: the call would overwrite something it has not seen -- a push over edits
|
|
25
|
+
// made outside the files (preview_edited_outside), or over another branch's
|
|
26
|
+
// unpublished push. `errorKey` says which, for the command that knows what to
|
|
27
|
+
// do next.
|
|
28
|
+
export class ConflictError extends HttpError {
|
|
29
|
+
constructor(message, options) {
|
|
30
|
+
super(message, options);
|
|
31
|
+
this.errorKey = typeof options.body?.error_key === "string" ? options.body.error_key : null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
24
35
|
// The platform takes calls only from the CLI's current release
|
|
25
36
|
// (RequiresLatestCli on the backend): `latest` is the version to run instead.
|
|
26
37
|
// The refused call did nothing, so bin/vatio.mjs runs the whole command again
|
|
@@ -150,6 +161,7 @@ export class HttpClient {
|
|
|
150
161
|
if (status === 401) throw new UnauthorizedError(message, options);
|
|
151
162
|
if (status === 403) throw new ForbiddenError(message, options);
|
|
152
163
|
if (status === 404) throw new NotFoundError(message, options);
|
|
164
|
+
if (status === 409) throw new ConflictError(message, options);
|
|
153
165
|
if (status === 422) throw new UnprocessableError(body);
|
|
154
166
|
throw new HttpError(`HTTP ${status}: ${message}`, options);
|
|
155
167
|
}
|