@vatio-ai/cli 0.85.0 → 0.86.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/bin/vatio.mjs +4 -2
- package/lib/api-client.mjs +9 -0
- package/lib/claude-session.mjs +8 -0
- package/lib/commands/auth.mjs +4 -3
- package/lib/commands/chat.mjs +59 -2
- package/lib/commands/deploy.mjs +1 -0
- package/lib/commands/misc.mjs +37 -1
- package/lib/commands/supabase-auth.mjs +2 -1
- package/lib/commands/workspace-admin.mjs +12 -1
- package/lib/help.mjs +9 -2
- package/lib/trial.mjs +1 -0
- package/package.json +1 -1
package/bin/vatio.mjs
CHANGED
|
@@ -18,7 +18,7 @@ import { keepClaimedTrial } from "../lib/trial.mjs";
|
|
|
18
18
|
import { UserError, fail } from "../lib/support.mjs";
|
|
19
19
|
import { helpText } from "../lib/help.mjs";
|
|
20
20
|
import { login, logout } from "../lib/commands/auth.mjs";
|
|
21
|
-
import { configCommand, doctor, init, version } from "../lib/commands/misc.mjs";
|
|
21
|
+
import { configCommand, doctor, init, version, whoami } from "../lib/commands/misc.mjs";
|
|
22
22
|
import { diff, publish, push, rollback, status } from "../lib/commands/deploy.mjs";
|
|
23
23
|
import { env } from "../lib/commands/env.mjs";
|
|
24
24
|
import { keys, secrets, tokens } from "../lib/commands/workspace-admin.mjs";
|
|
@@ -91,7 +91,9 @@ async function run(command, args) {
|
|
|
91
91
|
case "-v":
|
|
92
92
|
return version();
|
|
93
93
|
case "doctor":
|
|
94
|
-
return doctor(config);
|
|
94
|
+
return await doctor(config);
|
|
95
|
+
case "whoami":
|
|
96
|
+
return await whoami(config);
|
|
95
97
|
case "login":
|
|
96
98
|
return await login(config, args);
|
|
97
99
|
case "logout":
|
package/lib/api-client.mjs
CHANGED
|
@@ -294,6 +294,15 @@ export class ApiClient extends HttpClient {
|
|
|
294
294
|
return this.post(`/chats/${encode(chatId)}/messages`, { content });
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
+
exportChats({ from, to = null, environment = null, channel = null, after = null }) {
|
|
298
|
+
const params = { from };
|
|
299
|
+
if (to) params.to = to;
|
|
300
|
+
if (environment) params.environment = environment;
|
|
301
|
+
if (channel) params.channel = channel;
|
|
302
|
+
if (after) params.after = after;
|
|
303
|
+
return this.get("/chats/export", params);
|
|
304
|
+
}
|
|
305
|
+
|
|
297
306
|
}
|
|
298
307
|
|
|
299
308
|
// /api/developer/v1/workspaces -- not workspace-scoped, so it takes the bare host.
|
package/lib/claude-session.mjs
CHANGED
|
@@ -41,6 +41,14 @@ const SECRET_PATTERNS = [
|
|
|
41
41
|
/\b([A-Z0-9_]*(?:SECRET|TOKEN|PASSWORD|PASSWD|API_KEY|APIKEY|PRIVATE_KEY|ACCESS_KEY)[A-Z0-9_]*)(\s*[=:]\s*)(["']?)([^\s"'$]{6,})\3/g,
|
|
42
42
|
`$1$2$3${REDACTED}$3`
|
|
43
43
|
],
|
|
44
|
+
// key=value on its own line in a .properties file (gradle.properties,
|
|
45
|
+
// key.properties), where names are dotted or camelCase:
|
|
46
|
+
// android.injected.signing.store.password, storePassword. A line number in
|
|
47
|
+
// front, as grep -n or cat -n prints it, is kept.
|
|
48
|
+
[
|
|
49
|
+
/^([ \t]*(?:\d+[:\t-])?[ \t]*[A-Za-z][\w.-]*(?:password|passwd|secret|token)[\w.-]*[ \t]*=[ \t]*)(?!\[REDACTED\])([^\s"'$]{6,})[ \t]*$/gim,
|
|
50
|
+
`$1${REDACTED}`
|
|
51
|
+
],
|
|
44
52
|
// "password": "…" in a JSON or YAML file.
|
|
45
53
|
[
|
|
46
54
|
/(["']?\b(?:password|secret|client_secret|api_key|apiKey|access_token|refresh_token|private_key)["']?\s*:\s*)(["'])([^"'\s]{6,})\2/g,
|
package/lib/commands/auth.mjs
CHANGED
|
@@ -40,7 +40,8 @@ export async function deviceLogin({ config, baseUrl, message, workspace = null }
|
|
|
40
40
|
config.clearPendingLogin();
|
|
41
41
|
return {
|
|
42
42
|
token: result.token,
|
|
43
|
-
baseUrl: String(result.base_url ?? "").trim() || resolved
|
|
43
|
+
baseUrl: String(result.base_url ?? "").trim() || resolved,
|
|
44
|
+
email: String(result.email ?? "").trim() || null
|
|
44
45
|
};
|
|
45
46
|
} catch (error) {
|
|
46
47
|
if (error instanceof PendingError) {
|
|
@@ -77,14 +78,14 @@ async function startLogin({ config, client, resolved, workspace }) {
|
|
|
77
78
|
|
|
78
79
|
export async function login(config, args) {
|
|
79
80
|
const baseUrl = takeValue(args, "--base-url");
|
|
80
|
-
const { token, baseUrl: resolved } = await deviceLogin({
|
|
81
|
+
const { token, baseUrl: resolved, email } = await deviceLogin({
|
|
81
82
|
config,
|
|
82
83
|
baseUrl,
|
|
83
84
|
message: "Signing this machine in to Vatio…"
|
|
84
85
|
});
|
|
85
86
|
|
|
86
87
|
config.writeAuth({ baseUrl: resolved, token });
|
|
87
|
-
console.log(`Logged in to ${resolved}`);
|
|
88
|
+
console.log(email ? `Logged in to ${resolved} as ${email}` : `Logged in to ${resolved}`);
|
|
88
89
|
console.log(`Token saved to ${config.configPath}`);
|
|
89
90
|
}
|
|
90
91
|
|
package/lib/commands/chat.mjs
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// accounts do that for real, and a simulated channel was only ever a second
|
|
7
7
|
// answer to keep in step with the true one.
|
|
8
8
|
|
|
9
|
-
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
9
|
+
import { appendFileSync, existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
10
10
|
import { join } from "node:path";
|
|
11
11
|
|
|
12
12
|
import { ApiClient } from "../api-client.mjs";
|
|
@@ -26,6 +26,10 @@ const RETIRED = {
|
|
|
26
26
|
const REMOVED_FLAGS = ["--channel", "--from", "--as", "--sandbox-url"];
|
|
27
27
|
|
|
28
28
|
export async function chat(config, args) {
|
|
29
|
+
// Not a conversation of your own, so none of what follows applies to it,
|
|
30
|
+
// and its --from and --channel mean dates and a channel to read.
|
|
31
|
+
if (args[0] === "export") return await exportChats(config, args.slice(1));
|
|
32
|
+
|
|
29
33
|
for (const arg of args) {
|
|
30
34
|
if (REMOVED_FLAGS.some((flag) => arg === flag || arg.startsWith(`${flag}=`))) {
|
|
31
35
|
fail(
|
|
@@ -63,6 +67,7 @@ export function chatHelp() {
|
|
|
63
67
|
return `Usage:
|
|
64
68
|
vatio chat "message" [--env NAME] [--new] [--timeout N]
|
|
65
69
|
vatio chat show [CHAT_ID] [--env NAME] [--last N] [--json]
|
|
70
|
+
${EXPORT_USAGE}
|
|
66
71
|
|
|
67
72
|
--env picks the deployment that answers: preview (default), live, or a preview
|
|
68
73
|
name like pr-42. A chat against live is a real conversation and shows up in
|
|
@@ -78,7 +83,59 @@ none: why, and whether anything in your workspace caused it.
|
|
|
78
83
|
|
|
79
84
|
The open chat per deployment is remembered in ${STATE_FILE}, so a second
|
|
80
85
|
\`vatio chat\` continues the first. \`--new\` starts over as a visitor the
|
|
81
|
-
workspace has never met
|
|
86
|
+
workspace has never met.
|
|
87
|
+
|
|
88
|
+
\`export\` prints what people said and what they were answered between two
|
|
89
|
+
dates (live unless --env says otherwise), one conversation per line as JSON,
|
|
90
|
+
for reading them in bulk -- with a coding agent, say. Vatio redacts it before
|
|
91
|
+
it leaves: names, emails, phone numbers and RUTs it knows are [FILTERED], and
|
|
92
|
+
\`person\` stands for whoever it was without naming them. Anyone on the
|
|
93
|
+
workspace's team can run it, a viewer too, and every call is in the
|
|
94
|
+
workspace's activity. Dates are whole days; --to defaults to now.`;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const EXPORT_USAGE = "vatio chat export --from DATE [--to DATE] [--env NAME] [--channel NAME] [--out FILE]";
|
|
98
|
+
|
|
99
|
+
// One page at a time, written as it arrives: a month of a busy WhatsApp number
|
|
100
|
+
// does not have to fit in memory to be read.
|
|
101
|
+
async function exportChats(config, args) {
|
|
102
|
+
const environment = takeEnv(args, { fallback: "live" });
|
|
103
|
+
const from = takeValue(args, "--from");
|
|
104
|
+
const to = takeValue(args, "--to");
|
|
105
|
+
const channel = takeValue(args, "--channel");
|
|
106
|
+
const out = takeValue(args, "--out");
|
|
107
|
+
const apiUrl = takeValue(args, "--api-url");
|
|
108
|
+
const token = takeValue(args, "--token");
|
|
109
|
+
if (args.length > 0) fail(`Unexpected ${args[0]}. Usage: ${EXPORT_USAGE}`);
|
|
110
|
+
if (!from) fail(`--from is required, a date like 2026-09-01. Usage: ${EXPORT_USAGE}`);
|
|
111
|
+
|
|
112
|
+
const api = client(config, { apiUrl, token });
|
|
113
|
+
if (out) writeFileSync(out, "");
|
|
114
|
+
|
|
115
|
+
let after = null;
|
|
116
|
+
let chats = 0;
|
|
117
|
+
let messages = 0;
|
|
118
|
+
for (;;) {
|
|
119
|
+
const page = await api.exportChats({ from, to, environment, channel, after });
|
|
120
|
+
const rows = Array.isArray(page.data) ? page.data : [];
|
|
121
|
+
if (rows.length > 0) {
|
|
122
|
+
const lines = `${rows.map((row) => JSON.stringify(row)).join("\n")}\n`;
|
|
123
|
+
if (out) appendFileSync(out, lines);
|
|
124
|
+
else await new Promise((resolve) => process.stdout.write(lines, resolve));
|
|
125
|
+
}
|
|
126
|
+
chats += rows.length;
|
|
127
|
+
messages += rows.reduce((sum, row) => sum + (Array.isArray(row.messages) ? row.messages.length : 0), 0);
|
|
128
|
+
if (!page.next_after) {
|
|
129
|
+
const window = page.window ?? {};
|
|
130
|
+
console.error(
|
|
131
|
+
`vatio: ${chats} conversation${chats === 1 ? "" : "s"}, ${messages} message${messages === 1 ? "" : "s"}, ` +
|
|
132
|
+
`${window.from} → ${window.to} on ${page.environment ?? environment}${out ? `, in ${out}` : ""}. ` +
|
|
133
|
+
"Redacted by Vatio: what identifies someone reads [FILTERED]."
|
|
134
|
+
);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
after = page.next_after;
|
|
138
|
+
}
|
|
82
139
|
}
|
|
83
140
|
|
|
84
141
|
// With no account on this machine, the trial this directory pushed to, with
|
package/lib/commands/deploy.mjs
CHANGED
|
@@ -28,6 +28,7 @@ export async function ensureAuthorized(config, { workspace = null, message = "Be
|
|
|
28
28
|
|
|
29
29
|
const auth = await deviceLogin({ config, workspace, message });
|
|
30
30
|
config.writeAuth({ baseUrl: auth.baseUrl, token: auth.token });
|
|
31
|
+
if (auth.email) console.log(`Signed in as ${auth.email}`);
|
|
31
32
|
console.log(`Token saved to ${config.configPath}`);
|
|
32
33
|
console.log("");
|
|
33
34
|
}
|
package/lib/commands/misc.mjs
CHANGED
|
@@ -19,7 +19,7 @@ export function version() {
|
|
|
19
19
|
|
|
20
20
|
// What to read when a command fails for a reason that does not look like the
|
|
21
21
|
// workspace itself.
|
|
22
|
-
export function doctor(config) {
|
|
22
|
+
export async function doctor(config) {
|
|
23
23
|
version();
|
|
24
24
|
console.log(`CLI executable: ${process.argv[1]}`);
|
|
25
25
|
console.log(`Node executable: ${process.execPath}`);
|
|
@@ -39,6 +39,7 @@ export function doctor(config) {
|
|
|
39
39
|
if (slug) console.log(`Workspace: ${slug}`);
|
|
40
40
|
const token = config.resolveToken();
|
|
41
41
|
console.log(`Token: ${token ? "configured" : "missing — run `vatio login`"}`);
|
|
42
|
+
if (token) console.log(`Account: ${await accountLine(config)}`);
|
|
42
43
|
// Where this directory pushes with no account. The link to keep it is not
|
|
43
44
|
// printed: whoever holds it can take the trial, and this output is the one
|
|
44
45
|
// that gets pasted into issues.
|
|
@@ -50,6 +51,41 @@ export function doctor(config) {
|
|
|
50
51
|
console.log(`Docs: ${DOCS_URL}`);
|
|
51
52
|
}
|
|
52
53
|
|
|
54
|
+
// Which account the token is, and the workspaces it reaches. A developer can
|
|
55
|
+
// hold several accounts -- an email, a Google and a GitHub sign-in are separate
|
|
56
|
+
// unless they share the address -- and a workspace belongs to one of them, so
|
|
57
|
+
// `workspace_forbidden` is often just the wrong one signed in here.
|
|
58
|
+
export async function whoami(config) {
|
|
59
|
+
const payload = await workspacesClient(config).listWorkspaces();
|
|
60
|
+
const email = payload?.account?.email;
|
|
61
|
+
console.log(email ? `Signed in as ${email}` : "Signed in (this Vatio does not say as whom)");
|
|
62
|
+
console.log(`Base URL: ${config.resolveBaseUrl()}`);
|
|
63
|
+
const slugs = (Array.isArray(payload?.workspaces) ? payload.workspaces : []).map((workspace) => workspace.slug);
|
|
64
|
+
console.log(slugs.length > 0 ? `Workspaces: ${slugs.join(", ")}` : "Workspaces: none yet");
|
|
65
|
+
let slug = null;
|
|
66
|
+
try {
|
|
67
|
+
slug = config.resolveWorkspace();
|
|
68
|
+
} catch {
|
|
69
|
+
slug = null;
|
|
70
|
+
}
|
|
71
|
+
if (slug && !slugs.includes(slug)) {
|
|
72
|
+
console.log("");
|
|
73
|
+
console.log(`This directory's workspace, ${slug}, is not one of them: it does not exist yet (\`vatio push\` ` +
|
|
74
|
+
"creates it) or belongs to another account (`vatio login` with that account's email or sign-in).");
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// doctor's one line about the account. Never fails: doctor is what gets run
|
|
79
|
+
// when other commands do.
|
|
80
|
+
async function accountLine(config) {
|
|
81
|
+
try {
|
|
82
|
+
const payload = await workspacesClient(config).listWorkspaces();
|
|
83
|
+
return payload?.account?.email ?? "signed in (this Vatio does not say as whom)";
|
|
84
|
+
} catch (error) {
|
|
85
|
+
return `unknown — ${String(error?.message ?? error).split("\n")[0]}`;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
53
89
|
export function configCommand(config, args) {
|
|
54
90
|
const sub = args.shift();
|
|
55
91
|
|
|
@@ -178,7 +178,8 @@ async function checkSigningKeys(url) {
|
|
|
178
178
|
fail(
|
|
179
179
|
`${url} still signs with the legacy JWT secret (HS256), which Vatio cannot verify without being able\n` +
|
|
180
180
|
"to mint tokens too. In the Supabase dashboard: Project Settings → JWT Keys → migrate, then rotate\n" +
|
|
181
|
-
"to an ES256 key.
|
|
181
|
+
"to an ES256 key, then run this again. Before rotating, check for code that verifies tokens with the\n" +
|
|
182
|
+
"legacy secret and for Edge Functions with Verify JWT on: https://vatio.ai/docs/integrations/supabase"
|
|
182
183
|
);
|
|
183
184
|
}
|
|
184
185
|
|
|
@@ -107,6 +107,7 @@ export async function tokens(config, args) {
|
|
|
107
107
|
const environment = environmentOption(args, "live");
|
|
108
108
|
const label = takeValue(args, "--label") ?? takeValue(args, "-l");
|
|
109
109
|
const origins = takeOrigins(args);
|
|
110
|
+
const json = takeFlag(args, "--json");
|
|
110
111
|
const workspace = config.resolveWorkspaceRequired();
|
|
111
112
|
const client = deployClient(config, workspace);
|
|
112
113
|
const sub = args.shift() ?? "list";
|
|
@@ -114,6 +115,10 @@ export async function tokens(config, args) {
|
|
|
114
115
|
if (sub === "list") {
|
|
115
116
|
const payload = await client.listPublishableTokens();
|
|
116
117
|
const list = asArray(payload.publishable_tokens);
|
|
118
|
+
if (json) {
|
|
119
|
+
console.log(JSON.stringify(list, null, 2));
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
117
122
|
if (list.length === 0) {
|
|
118
123
|
console.log(`No publishable tokens on workspace ${workspace}`);
|
|
119
124
|
console.log(" Create one: vatio tokens create --env live --origin https://your-site.com");
|
|
@@ -130,6 +135,12 @@ export async function tokens(config, args) {
|
|
|
130
135
|
}
|
|
131
136
|
if (sub === "create") {
|
|
132
137
|
const payload = await client.createPublishableToken({ environment, label, allowedOrigins: origins });
|
|
138
|
+
// For a script that hands the token straight to something else: the token
|
|
139
|
+
// or a failed command, never a line of prose to grep it out of.
|
|
140
|
+
if (json) {
|
|
141
|
+
console.log(JSON.stringify({ ...payload, token: payload.token ?? payload.publishable_token, workspace }, null, 2));
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
133
144
|
console.log(`Created a publishable token for ${environment} on workspace ${workspace}`);
|
|
134
145
|
console.log(` origins: ${originsLine(payload.allowed_origins)}`);
|
|
135
146
|
console.log("");
|
|
@@ -156,7 +167,7 @@ export async function tokens(config, args) {
|
|
|
156
167
|
}
|
|
157
168
|
|
|
158
169
|
fail(
|
|
159
|
-
"Usage: vatio tokens list|create [--env live|preview] [--label NAME] [--origin URL]
|
|
170
|
+
"Usage: vatio tokens list|create [--env live|preview] [--label NAME] [--origin URL]... [--json]|" +
|
|
160
171
|
"origins PREFIX URL...|revoke PREFIX"
|
|
161
172
|
);
|
|
162
173
|
}
|
package/lib/help.mjs
CHANGED
|
@@ -21,7 +21,9 @@ Commands default as listed.
|
|
|
21
21
|
login [--base-url URL] Sign this machine in from the browser: email link,
|
|
22
22
|
Google or GitHub. Creates the account if needed
|
|
23
23
|
logout Revoke and forget the token
|
|
24
|
-
|
|
24
|
+
whoami The account this machine is signed in as, and
|
|
25
|
+
the workspaces it reaches
|
|
26
|
+
doctor Node, config, workspace, token and account status
|
|
25
27
|
version What this CLI is
|
|
26
28
|
docs [--save [PATH]] The whole developer contract, live from Vatio
|
|
27
29
|
feedback "TEXT" Tell the Vatio team what got in the way
|
|
@@ -61,6 +63,11 @@ Commands default as listed.
|
|
|
61
63
|
chat show [CHAT_ID] [--json] [--last N]
|
|
62
64
|
The chat you are in, or any chat in the workspace
|
|
63
65
|
(web, WhatsApp, ...): messages, tool calls, channel
|
|
66
|
+
chat export --from DATE [--to DATE] [--env NAME] [--channel NAME] [--out FILE]
|
|
67
|
+
What people said and were answered between two
|
|
68
|
+
dates, redacted by Vatio, one conversation per
|
|
69
|
+
line as JSON. Default: live. Any team member,
|
|
70
|
+
viewers included; every call is in the activity
|
|
64
71
|
|
|
65
72
|
Improve it from what supervisors reported and how its tools answered
|
|
66
73
|
(flags, fix, push, test, publish):
|
|
@@ -111,7 +118,7 @@ Commands default as listed.
|
|
|
111
118
|
With --env, the value only that environment uses;
|
|
112
119
|
otherwise the value everywhere. With --tests, the
|
|
113
120
|
value preview and every test run use, like a staging URL
|
|
114
|
-
tokens list|create [--env NAME] [--label NAME] [--origin URL]
|
|
121
|
+
tokens list|create [--env NAME] [--label NAME] [--origin URL]... [--json]|revoke PREFIX
|
|
115
122
|
tokens origins PREFIX URL...
|
|
116
123
|
The origins a token is accepted from (replaces the list)
|
|
117
124
|
keys list|create [--env NAME] [--label NAME]|revoke PREFIX
|
package/lib/trial.mjs
CHANGED
|
@@ -106,6 +106,7 @@ export async function keepClaimedTrial(config, error) {
|
|
|
106
106
|
message: `You kept this agent: it is workspace ${workspace} now. Sign this terminal in to keep working on it.`
|
|
107
107
|
});
|
|
108
108
|
config.writeAuth({ baseUrl: auth.baseUrl, token: auth.token });
|
|
109
|
+
if (auth.email) console.log(`Signed in as ${auth.email}`);
|
|
109
110
|
console.log(`Token saved to ${config.configPath}`);
|
|
110
111
|
|
|
111
112
|
const root = config.workspaceRoot;
|