@vatio-ai/cli 0.81.0 → 0.82.1
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 +21 -4
- package/bin/vatio.mjs +7 -1
- package/lib/commands/improve.mjs +26 -1
- package/lib/commands/knowledge.mjs +2 -2
- package/lib/commands/supabase-auth.mjs +1 -1
- package/lib/device-auth.mjs +2 -0
- package/lib/help.mjs +2 -0
- package/lib/http.mjs +22 -0
- package/lib/run-latest.mjs +36 -0
- package/lib/support.mjs +14 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
# @vatio-ai/cli
|
|
2
2
|
|
|
3
|
-
The CLI for [Vatio](https://vatio.ai)
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
The CLI for [Vatio](https://vatio.ai), which gives the app you're building with
|
|
4
|
+
a coding agent — Claude Code, Cursor or Codex — an AI agent that knows the app
|
|
5
|
+
and its users. Your coding agent writes the agent into your project and drives
|
|
6
|
+
this CLI; Vatio runs the conversations, with your users signed in, an inbox for
|
|
7
|
+
your team, handoff to a person, and the replies your team reports turned into
|
|
8
|
+
tests.
|
|
9
|
+
|
|
10
|
+
## Start here
|
|
11
|
+
|
|
12
|
+
In your app's project:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npx @vatio-ai/skills
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Then, in Claude Code, run `/vatio-init` (in Cursor or Codex, ask it to use
|
|
19
|
+
vatio-init). It reads your app, asks only what the code can't answer, and
|
|
20
|
+
pushes a preview for you to try. Then `/vatio-add-to-app` puts the agent in
|
|
21
|
+
your web, iOS or Android app. See the [docs](https://vatio.ai/docs/).
|
|
22
|
+
|
|
23
|
+
## By hand
|
|
7
24
|
|
|
8
25
|
```bash
|
|
9
26
|
npx @vatio-ai/cli init my-agent
|
package/bin/vatio.mjs
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// terminal; the credential lives in ~/.vatio/config.json.
|
|
6
6
|
|
|
7
7
|
import { Config, ConfigError } from "../lib/config.mjs";
|
|
8
|
-
import { HttpError, UnauthorizedError, ForbiddenError, NotFoundError } from "../lib/http.mjs";
|
|
8
|
+
import { CliOutdatedError, HttpError, UnauthorizedError, ForbiddenError, NotFoundError } from "../lib/http.mjs";
|
|
9
9
|
import { UserError, fail } from "../lib/support.mjs";
|
|
10
10
|
import { helpText } from "../lib/help.mjs";
|
|
11
11
|
import { login, logout } from "../lib/commands/auth.mjs";
|
|
@@ -23,6 +23,7 @@ import { instagram, whatsapp } from "../lib/commands/channels.mjs";
|
|
|
23
23
|
import { docs, feedback, shareSession } from "../lib/commands/support-commands.mjs";
|
|
24
24
|
import { evalCommand, flags, test, tools } from "../lib/commands/improve.mjs";
|
|
25
25
|
import { printUpdateNotice, startUpdateCheck } from "../lib/update-notice.mjs";
|
|
26
|
+
import { runLatest } from "../lib/run-latest.mjs";
|
|
26
27
|
import { beginRun, isCodingAgent, reportRun, telemetryEnabled } from "../lib/telemetry.mjs";
|
|
27
28
|
|
|
28
29
|
// Commands that existed and are gone, answered by name rather than as
|
|
@@ -139,6 +140,11 @@ async function run(command, args) {
|
|
|
139
140
|
|
|
140
141
|
|
|
141
142
|
main(process.argv).catch(async (error) => {
|
|
143
|
+
if (error instanceof CliOutdatedError) {
|
|
144
|
+
// The run it starts reports itself; this one would count the command twice.
|
|
145
|
+
const code = runLatest(error, process.argv);
|
|
146
|
+
if (code !== null) process.exit(code);
|
|
147
|
+
}
|
|
142
148
|
printError(error);
|
|
143
149
|
await reportRun(config, { exitCode: 1, error });
|
|
144
150
|
process.exit(1);
|
package/lib/commands/improve.mjs
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import { mkdirSync, writeFileSync } from "node:fs";
|
|
11
11
|
import { dirname, resolve } from "node:path";
|
|
12
12
|
|
|
13
|
-
import { HttpClient } from "../http.mjs";
|
|
13
|
+
import { HttpClient, NotFoundError, throwIfOutdated } from "../http.mjs";
|
|
14
14
|
import { clientHeaders } from "../telemetry.mjs";
|
|
15
15
|
import { fail, sleep, takeEnv, takeFlag, takeValue } from "../support.mjs";
|
|
16
16
|
import { printSkillsHint } from "../skills-hint.mjs";
|
|
@@ -31,6 +31,7 @@ async function fetchMarkdown(config, path, what) {
|
|
|
31
31
|
headers: { ...clientHeaders(), Accept: "text/markdown, text/plain", Authorization: `Bearer ${token}` },
|
|
32
32
|
signal: AbortSignal.timeout(30_000)
|
|
33
33
|
});
|
|
34
|
+
await throwIfOutdated(response);
|
|
34
35
|
if (!response.ok) {
|
|
35
36
|
const body = await response.json().catch(() => null);
|
|
36
37
|
const reason = body?.error?.message ?? `HTTP ${response.status}`;
|
|
@@ -43,6 +44,8 @@ async function fetchMarkdown(config, path, what) {
|
|
|
43
44
|
// before it, every tool call of that turn with what your backend answered,
|
|
44
45
|
// and what the supervisor says should have happened.
|
|
45
46
|
export async function flags(config, args) {
|
|
47
|
+
if (["rm", "remove", "delete"].includes(args[0])) return await removeFlags(config, args.slice(1));
|
|
48
|
+
|
|
46
49
|
const json = takeFlag(args, "--json");
|
|
47
50
|
const save = takeFlag(args, "--save");
|
|
48
51
|
const savePath = save ? args.shift() ?? null : null;
|
|
@@ -68,6 +71,28 @@ export async function flags(config, args) {
|
|
|
68
71
|
await printSkillsHint();
|
|
69
72
|
}
|
|
70
73
|
|
|
74
|
+
// What the inbox's Quitar does, by the ids `vatio flags` prints: the flag and
|
|
75
|
+
// its test case go, for everyone in the workspace. The developer's call, not
|
|
76
|
+
// the coding agent's: the vatio-improve skill says to run it only when asked.
|
|
77
|
+
async function removeFlags(config, ids) {
|
|
78
|
+
if (ids.length === 0 || ids.some((id) => id.startsWith("-"))) fail("Usage: vatio flags rm ID [ID...]");
|
|
79
|
+
|
|
80
|
+
const { url, token } = workspaceBase(config);
|
|
81
|
+
const client = new HttpClient({ baseUrl: url, token });
|
|
82
|
+
for (const id of ids) {
|
|
83
|
+
let removed;
|
|
84
|
+
try {
|
|
85
|
+
removed = await client.delete(`/flags/${encodeURIComponent(id)}`);
|
|
86
|
+
} catch (error) {
|
|
87
|
+
// The platform's own words name the id and where to find the right one.
|
|
88
|
+
if (error instanceof NotFoundError) fail(error.message);
|
|
89
|
+
throw error;
|
|
90
|
+
}
|
|
91
|
+
const was = removed.state === "resolved" ? "a resolved flag, so no longer a regression case" : "an open flag";
|
|
92
|
+
console.log(`Removed ${removed.id} (${was}) and its test case.`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
71
96
|
// Each tool's calls, error rate, timeouts and p50/p95 latency over a period,
|
|
72
97
|
// then the calls that failed with what your backend answered: the inbox's
|
|
73
98
|
// Tools page.
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import { readFileSync, statSync } from "node:fs";
|
|
17
17
|
|
|
18
18
|
import { deployClient } from "./deploy.mjs";
|
|
19
|
-
import { fail, takeEnv, takeValue } from "../support.mjs";
|
|
19
|
+
import { fail, rememberStdin, takeEnv, takeValue } from "../support.mjs";
|
|
20
20
|
|
|
21
21
|
// Only what reads or writes entries takes an environment; bases belong to the
|
|
22
22
|
// workspace.
|
|
@@ -272,7 +272,7 @@ function readStdin() {
|
|
|
272
272
|
if (process.stdin.isTTY) return "";
|
|
273
273
|
|
|
274
274
|
try {
|
|
275
|
-
return readFileSync(0, "utf8");
|
|
275
|
+
return rememberStdin(readFileSync(0, "utf8"));
|
|
276
276
|
} catch {
|
|
277
277
|
return "";
|
|
278
278
|
}
|
|
@@ -94,7 +94,7 @@ export async function supabaseAuth(config, args) {
|
|
|
94
94
|
console.log(" data: { orders: \"$\" }");
|
|
95
95
|
console.log(" message: { when_empty: No orders yet., default: \"Found {{count}} orders.\" }");
|
|
96
96
|
console.log("");
|
|
97
|
-
console.log("Docs: https://vatio.ai/docs/
|
|
97
|
+
console.log("Docs: https://vatio.ai/docs/integrations/supabase");
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
async function connectedProject(config, workspace) {
|
package/lib/device-auth.mjs
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
// Unauthenticated by definition -- this is what mints the token -- so it does
|
|
6
6
|
// not go through HttpClient, which requires one.
|
|
7
7
|
|
|
8
|
+
import { throwIfOutdated } from "./http.mjs";
|
|
8
9
|
import { clientHeaders } from "./telemetry.mjs";
|
|
9
10
|
|
|
10
11
|
export class DeviceAuthError extends Error {}
|
|
@@ -43,6 +44,7 @@ export class DeviceAuthClient {
|
|
|
43
44
|
const reason = error?.cause?.code ?? error?.name ?? "request failed";
|
|
44
45
|
throw new DeviceAuthError(`${reason}: ${url}`);
|
|
45
46
|
}
|
|
47
|
+
await throwIfOutdated(response);
|
|
46
48
|
|
|
47
49
|
const raw = await response.text();
|
|
48
50
|
let parsed;
|
package/lib/help.mjs
CHANGED
|
@@ -65,6 +65,8 @@ Commands default as listed.
|
|
|
65
65
|
flags [--save [PATH]|--json]
|
|
66
66
|
Every open report: the conversation, what each tool
|
|
67
67
|
answered, and what should have happened
|
|
68
|
+
flags rm ID [ID...] Remove a report and its test case, open or
|
|
69
|
+
resolved, as the inbox's Remove does
|
|
68
70
|
tools [--env NAME] [--period 1h|1d|7d|30d] [--json]
|
|
69
71
|
The inbox's Tools page: each tool's calls, error
|
|
70
72
|
rate, timeouts and p50/p95, then the calls that
|
package/lib/http.mjs
CHANGED
|
@@ -21,6 +21,27 @@ export class UnauthorizedError extends HttpError {}
|
|
|
21
21
|
export class ForbiddenError extends HttpError {}
|
|
22
22
|
export class NotFoundError extends HttpError {}
|
|
23
23
|
|
|
24
|
+
// The platform takes calls only from the CLI's current release
|
|
25
|
+
// (RequiresLatestCli on the backend): `latest` is the version to run instead.
|
|
26
|
+
// The refused call did nothing, so bin/vatio.mjs runs the whole command again
|
|
27
|
+
// as that version (run-latest.mjs).
|
|
28
|
+
export class CliOutdatedError extends HttpError {
|
|
29
|
+
constructor(message, options) {
|
|
30
|
+
super(message, options);
|
|
31
|
+
this.latest = typeof options.body?.latest === "string" ? options.body.latest : null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// For the calls made with fetch() directly rather than through HttpClient.
|
|
36
|
+
export async function throwIfOutdated(response) {
|
|
37
|
+
if (response.status !== 426) return;
|
|
38
|
+
|
|
39
|
+
const raw = await response.clone().text();
|
|
40
|
+
const body = parseJson(raw) ?? {};
|
|
41
|
+
if (body.error_key !== "cli_outdated") return;
|
|
42
|
+
throw new CliOutdatedError(responseMessage(body, raw, response), { status: 426, requestId: body.request_id ?? null, body });
|
|
43
|
+
}
|
|
44
|
+
|
|
24
45
|
export class UnprocessableError extends HttpError {
|
|
25
46
|
constructor(body) {
|
|
26
47
|
const hash = body && typeof body === "object" ? body : {};
|
|
@@ -125,6 +146,7 @@ export class HttpClient {
|
|
|
125
146
|
}
|
|
126
147
|
|
|
127
148
|
const options = { status, requestId, body: body ?? {} };
|
|
149
|
+
if (status === 426 && body?.error_key === "cli_outdated") throw new CliOutdatedError(message, options);
|
|
128
150
|
if (status === 401) throw new UnauthorizedError(message, options);
|
|
129
151
|
if (status === 403) throw new ForbiddenError(message, options);
|
|
130
152
|
if (status === 404) throw new NotFoundError(message, options);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// What the CLI does when the platform refuses a call because this is not its
|
|
2
|
+
// current release (426 cli_outdated, see CliOutdatedError): it runs the
|
|
3
|
+
// release it was told to through npx, with the same arguments, and exits with
|
|
4
|
+
// that run's code. The refused call did nothing, so the whole command can run
|
|
5
|
+
// again; stdin a command already read is handed on, so
|
|
6
|
+
// `op read … | vatio secrets set KEY` still works.
|
|
7
|
+
//
|
|
8
|
+
// Returns null when it cannot, and the caller prints the refusal, which says
|
|
9
|
+
// how to update: never twice in a row (a release published in between), and
|
|
10
|
+
// not on Windows, where npx is a .cmd that Node starts only through a shell
|
|
11
|
+
// that would split the arguments again.
|
|
12
|
+
|
|
13
|
+
import { spawnSync } from "node:child_process";
|
|
14
|
+
|
|
15
|
+
import { consumedStdin } from "./support.mjs";
|
|
16
|
+
import { VERSION } from "./version.mjs";
|
|
17
|
+
|
|
18
|
+
const RAN_LATEST = "VATIO_CLI_RAN_LATEST";
|
|
19
|
+
|
|
20
|
+
export function runLatest(error, argv) {
|
|
21
|
+
const latest = error.latest;
|
|
22
|
+
if (!/^\d+\.\d+\.\d+$/.test(latest ?? "") || process.env[RAN_LATEST] || process.platform === "win32") return null;
|
|
23
|
+
|
|
24
|
+
console.error(
|
|
25
|
+
`vatio: ${VERSION} is not the current release, so this runs ${latest} through npx. ` +
|
|
26
|
+
"`npm install -g @vatio-ai/cli@latest` installs it."
|
|
27
|
+
);
|
|
28
|
+
const input = consumedStdin();
|
|
29
|
+
const child = spawnSync("npx", ["--yes", `@vatio-ai/cli@${latest}`, ...argv.slice(2)], {
|
|
30
|
+
stdio: input === null ? "inherit" : ["pipe", "inherit", "inherit"],
|
|
31
|
+
input: input ?? undefined,
|
|
32
|
+
env: { ...process.env, [RAN_LATEST]: latest }
|
|
33
|
+
});
|
|
34
|
+
if (child.error) return null;
|
|
35
|
+
return child.status ?? 1;
|
|
36
|
+
}
|
package/lib/support.mjs
CHANGED
|
@@ -178,8 +178,21 @@ export async function askSecret(question) {
|
|
|
178
178
|
});
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
+
// What a command read from stdin, kept for the run of the current release
|
|
182
|
+
// that may follow a refused call (run-latest.mjs): stdin can only be read once.
|
|
183
|
+
let stdinRead = null;
|
|
184
|
+
|
|
185
|
+
export function rememberStdin(text) {
|
|
186
|
+
stdinRead = text;
|
|
187
|
+
return text;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export function consumedStdin() {
|
|
191
|
+
return stdinRead;
|
|
192
|
+
}
|
|
193
|
+
|
|
181
194
|
async function readStdin() {
|
|
182
195
|
const chunks = [];
|
|
183
196
|
for await (const chunk of process.stdin) chunks.push(chunk);
|
|
184
|
-
return Buffer.concat(chunks).toString("utf8");
|
|
197
|
+
return rememberStdin(Buffer.concat(chunks).toString("utf8"));
|
|
185
198
|
}
|