@vatio-ai/cli 0.130.0 → 0.132.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 +32 -24
- package/bin/vatio.mjs +19 -5
- package/lib/api-client.mjs +1 -5
- package/lib/commands/business.mjs +1 -1
- package/lib/commands/chat.mjs +20 -10
- package/lib/commands/deploy.mjs +64 -159
- package/lib/commands/env.mjs +1 -2
- package/lib/commands/improve.mjs +3 -3
- package/lib/commands/knowledge.mjs +36 -52
- package/lib/commands/misc.mjs +14 -6
- package/lib/commands/support-commands.mjs +6 -1
- package/lib/commands/workspace-admin.mjs +23 -37
- package/lib/config.mjs +158 -12
- package/lib/help.mjs +68 -68
- package/lib/telemetry.mjs +1 -1
- package/lib/visitor-identity.mjs +5 -3
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// secrets / keys — the things a workspace has that its manifest deliberately
|
|
2
|
-
// does not carry. A secret is a credential, and so are the API keys (publishable
|
|
3
|
-
//
|
|
2
|
+
// does not carry. A secret is a credential, and so are the API keys (publishable
|
|
3
|
+
// and secret); none of them is in vatio.yml.
|
|
4
4
|
|
|
5
5
|
import { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
6
6
|
import { join } from "node:path";
|
|
@@ -102,11 +102,6 @@ function secretScope({ environment, tests }) {
|
|
|
102
102
|
return environment ? `only ${environment}` : "every environment";
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
// Repeatable: `--origin https://a.com --origin https://b.com`.
|
|
106
|
-
function takeOrigins(args) {
|
|
107
|
-
return takeRepeated(args, "--origin");
|
|
108
|
-
}
|
|
109
|
-
|
|
110
105
|
function takeRepeated(args, flag) {
|
|
111
106
|
const values = [];
|
|
112
107
|
for (let value = takeValue(args, flag); value !== null; value = takeValue(args, flag)) {
|
|
@@ -120,11 +115,17 @@ const KINDS = ["publishable", "secret"];
|
|
|
120
115
|
// this list is only for the help text. `team` is never given by default.
|
|
121
116
|
const SCOPES = ["messages", "instagram", "chats", "team"];
|
|
122
117
|
const KEYS_USAGE =
|
|
123
|
-
"Usage: vatio keys list [--json]|create publishable|secret [--env live|preview] [--label NAME]
|
|
124
|
-
"[--scope NAME]... [--code CODE | --recovery-code CODE] [--json]|
|
|
118
|
+
"Usage: vatio keys list [--json]|create publishable|secret [--env live|preview] [--label NAME] " +
|
|
119
|
+
"[--scope NAME]... [--code CODE | --recovery-code CODE] [--json]|revoke PREFIX";
|
|
120
|
+
|
|
121
|
+
// A publishable key used to take a list of the sites it worked from. It works
|
|
122
|
+
// from any site now, so there is nothing to set, and saying so beats an
|
|
123
|
+
// unknown flag.
|
|
124
|
+
const NO_ORIGINS = "A publishable key works from any site, so there are no origins to set. " +
|
|
125
|
+
"`vatio keys list` shows where each key has been used.";
|
|
125
126
|
|
|
126
127
|
// API keys, of two kinds. A publishable key is for a page or an app: public by
|
|
127
|
-
// design,
|
|
128
|
+
// design, working from any site. A secret key is for the
|
|
128
129
|
// developer's own backend (to have the agent write to a contact first, read a
|
|
129
130
|
// chat, keep the team): it never goes in a page or an app, and unlike the
|
|
130
131
|
// CLI's own token it belongs to the workspace, so it outlives whoever created
|
|
@@ -133,7 +134,7 @@ const KEYS_USAGE =
|
|
|
133
134
|
export async function keys(config, args) {
|
|
134
135
|
const environment = environmentOption(args, "live");
|
|
135
136
|
const label = takeValue(args, "--label") ?? takeValue(args, "-l");
|
|
136
|
-
|
|
137
|
+
if (takeRepeated(args, "--origin").length > 0) fail(`--origin was removed. ${NO_ORIGINS}`);
|
|
137
138
|
const scopes = takeRepeated(args, "--scope");
|
|
138
139
|
const code = takeValue(args, "--code");
|
|
139
140
|
const recoveryCode = takeValue(args, "--recovery-code");
|
|
@@ -151,7 +152,7 @@ export async function keys(config, args) {
|
|
|
151
152
|
}
|
|
152
153
|
if (list.length === 0) {
|
|
153
154
|
console.log(`No API keys on workspace ${workspace}`);
|
|
154
|
-
console.log(" Create one: vatio keys create publishable --env live --
|
|
155
|
+
console.log(" Create one: vatio keys create publishable --env live --label website");
|
|
155
156
|
console.log(" vatio keys create secret --env live --label backend");
|
|
156
157
|
return;
|
|
157
158
|
}
|
|
@@ -162,7 +163,10 @@ export async function keys(config, args) {
|
|
|
162
163
|
if (key.managed) parts.push(`managed${key.managed_kind ? ` (${key.managed_kind})` : ""}`);
|
|
163
164
|
parts.push(key.last_used_at ? `last used ${key.last_used_at}` : "never used");
|
|
164
165
|
console.log(` ${parts.filter(Boolean).join(" ")}`);
|
|
165
|
-
if (key.kind === "publishable")
|
|
166
|
+
if (key.kind === "publishable") {
|
|
167
|
+
const seen = asArray(key.seen_origins).map((row) => row.origin);
|
|
168
|
+
console.log(` used from: ${seen.length > 0 ? seen.join(", ") : "nowhere yet"}`);
|
|
169
|
+
}
|
|
166
170
|
if (key.kind === "secret") console.log(` scopes: ${asArray(key.scopes).join(", ") || "none"}`);
|
|
167
171
|
}
|
|
168
172
|
return;
|
|
@@ -170,10 +174,7 @@ export async function keys(config, args) {
|
|
|
170
174
|
if (sub === "create") {
|
|
171
175
|
const kind = args.shift();
|
|
172
176
|
if (!KINDS.includes(kind)) {
|
|
173
|
-
fail("Say which kind: vatio keys create publishable|secret [--env NAME] [--label NAME] [--
|
|
174
|
-
}
|
|
175
|
-
if (kind === "secret" && origins.length > 0) {
|
|
176
|
-
fail("--origin only applies to a publishable key. A secret key is for your backend and has no origins.");
|
|
177
|
+
fail("Say which kind: vatio keys create publishable|secret [--env NAME] [--label NAME] [--scope NAME]...");
|
|
177
178
|
}
|
|
178
179
|
if (kind === "publishable" && scopes.length > 0) {
|
|
179
180
|
fail(`--scope only applies to a secret key (${SCOPES.join(", ")}).`);
|
|
@@ -182,7 +183,6 @@ export async function keys(config, args) {
|
|
|
182
183
|
kind,
|
|
183
184
|
environment,
|
|
184
185
|
label,
|
|
185
|
-
allowedOrigins: kind === "publishable" ? origins : [],
|
|
186
186
|
scopes: kind === "secret" && scopes.length > 0 ? scopes : null,
|
|
187
187
|
code,
|
|
188
188
|
recoveryCode
|
|
@@ -194,7 +194,7 @@ export async function keys(config, args) {
|
|
|
194
194
|
return;
|
|
195
195
|
}
|
|
196
196
|
console.log(`Created a ${kind} key for ${environment} on workspace ${workspace}`);
|
|
197
|
-
if (kind === "publishable") console.log(
|
|
197
|
+
if (kind === "publishable") console.log(" works from any site");
|
|
198
198
|
if (kind === "secret") console.log(` scopes: ${asArray(payload.api_key?.scopes).join(", ")}`);
|
|
199
199
|
console.log("");
|
|
200
200
|
// Shown in full exactly once: the platform stores a digest, so this is the
|
|
@@ -221,13 +221,7 @@ export async function keys(config, args) {
|
|
|
221
221
|
}
|
|
222
222
|
return;
|
|
223
223
|
}
|
|
224
|
-
if (sub === "origins") {
|
|
225
|
-
const prefix = args.shift();
|
|
226
|
-
if (!prefix) fail("Usage: vatio keys origins PREFIX [URL...] (no URL clears the list)");
|
|
227
|
-
const payload = await client.setApiKeyOrigins({ prefix, allowedOrigins: args.splice(0) });
|
|
228
|
-
console.log(`Origins for ${prefix}: ${originsLine(payload.api_key?.allowed_origins)}`);
|
|
229
|
-
return;
|
|
230
|
-
}
|
|
224
|
+
if (sub === "origins") fail(`\`vatio keys origins\` was removed. ${NO_ORIGINS}`);
|
|
231
225
|
if (sub === "revoke") {
|
|
232
226
|
const prefix = args.shift();
|
|
233
227
|
if (!prefix) fail("Usage: vatio keys revoke PREFIX");
|
|
@@ -317,13 +311,9 @@ function readLocalEnv(config, name) {
|
|
|
317
311
|
const exported = process.env[name];
|
|
318
312
|
if (exported !== undefined && exported !== "") return exported;
|
|
319
313
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
} catch {
|
|
324
|
-
// No workspace yet: the cwd is still worth reading.
|
|
325
|
-
}
|
|
326
|
-
roots.push(process.cwd());
|
|
314
|
+
// With no workspace directory -- none yet, or a workspace named by
|
|
315
|
+
// --workspace that has none here -- the cwd is still worth reading.
|
|
316
|
+
const roots = [config.workspaceDirectory(), process.cwd()].filter(Boolean);
|
|
327
317
|
|
|
328
318
|
const seen = [];
|
|
329
319
|
for (const root of roots) {
|
|
@@ -394,10 +384,6 @@ function valueIn(text, name) {
|
|
|
394
384
|
const UNTERMINATED = Symbol("unterminated");
|
|
395
385
|
|
|
396
386
|
// An empty list is not "anywhere": only Vatio's own pages can use the key.
|
|
397
|
-
function originsLine(origins) {
|
|
398
|
-
const list = asArray(origins);
|
|
399
|
-
return list.length > 0 ? list.join(", ") : "none (add one with `vatio keys origins PREFIX URL`)";
|
|
400
|
-
}
|
|
401
387
|
|
|
402
388
|
function asArray(value) {
|
|
403
389
|
return Array.isArray(value) ? value : [];
|
package/lib/config.mjs
CHANGED
|
@@ -7,9 +7,16 @@
|
|
|
7
7
|
// credential -- the developer's home does.
|
|
8
8
|
//
|
|
9
9
|
// Two scopes, as before: credentials are per developer and live here; workspace
|
|
10
|
-
// identity is per directory and lives in that workspace's own vatio.yml.
|
|
11
|
-
//
|
|
12
|
-
//
|
|
10
|
+
// identity is per directory and lives in that workspace's own vatio.yml.
|
|
11
|
+
//
|
|
12
|
+
// A workspace built through the Vatio MCP has no vatio.yml, and the commands
|
|
13
|
+
// that only talk to the platform (`vatio status`, `vatio business`, `vatio
|
|
14
|
+
// keys`...) are as useful to it as to one kept as files. So `--workspace SLUG`
|
|
15
|
+
// and VATIO_WORKSPACE name a workspace too, ahead of the vatio.yml. The
|
|
16
|
+
// commands that read or write the workspace's files (init, push, pull, diff,
|
|
17
|
+
// auth --new-key) still go by the directory alone and refuse both: for them
|
|
18
|
+
// the slug is a property of the files, and reading it anywhere else is how a
|
|
19
|
+
// push lands in the wrong workspace.
|
|
13
20
|
|
|
14
21
|
import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
15
22
|
import { homedir } from "node:os";
|
|
@@ -18,6 +25,7 @@ import { dirname, join, resolve } from "node:path";
|
|
|
18
25
|
import { MANIFEST_FILE, SLUG_FORMAT, findWorkspaceRoot, manifestPath, workspaceSlug, workspacesBelow } from "./workspace.mjs";
|
|
19
26
|
|
|
20
27
|
export const KEYS = ["base_url", "token"];
|
|
28
|
+
export const WORKSPACE_ENV = "VATIO_WORKSPACE";
|
|
21
29
|
export const DEFAULT_BASE_URL = "https://vatio.ai";
|
|
22
30
|
// `as`, `channel` and `from` configured a simulated visitor for `vatio chat`.
|
|
23
31
|
// That simulation is gone from the platform, so they are refused as keys and
|
|
@@ -36,12 +44,43 @@ export function configHome() {
|
|
|
36
44
|
return override === "" ? join(homedir(), ".vatio") : resolve(override);
|
|
37
45
|
}
|
|
38
46
|
|
|
47
|
+
// `--workspace SLUG` or `--workspace=SLUG`, wherever it is on the command line,
|
|
48
|
+
// taken out of `args` before anything reads the command: it means the same for
|
|
49
|
+
// every command, and none of them should take it for a message or a value.
|
|
50
|
+
export function takeWorkspaceFlag(args) {
|
|
51
|
+
let found = null;
|
|
52
|
+
for (let i = 0; i < args.length; ) {
|
|
53
|
+
let value;
|
|
54
|
+
if (args[i] === "--workspace") {
|
|
55
|
+
value = args[i + 1];
|
|
56
|
+
if (value === undefined || value.startsWith("-")) value = "";
|
|
57
|
+
args.splice(i, value === "" ? 1 : 2);
|
|
58
|
+
} else if (args[i].startsWith("--workspace=")) {
|
|
59
|
+
value = args[i].slice("--workspace=".length);
|
|
60
|
+
args.splice(i, 1);
|
|
61
|
+
} else {
|
|
62
|
+
i += 1;
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (value.trim() === "") throw new ConfigError("--workspace needs the workspace's slug: --workspace SLUG");
|
|
66
|
+
if (found !== null && found !== value) throw new ConfigError(`--workspace is given twice (${found}, ${value}): name one workspace.`);
|
|
67
|
+
found = value;
|
|
68
|
+
}
|
|
69
|
+
return found;
|
|
70
|
+
}
|
|
71
|
+
|
|
39
72
|
export class Config {
|
|
73
|
+
#differenceSaid = false;
|
|
74
|
+
|
|
40
75
|
constructor({ startDir = process.cwd() } = {}) {
|
|
41
76
|
this.startDir = resolve(startDir);
|
|
42
77
|
this.configPath = join(configHome(), "config.json");
|
|
43
78
|
this.workspaceRoot = findWorkspaceRoot(this.startDir);
|
|
44
79
|
this.legacyKeysRemoved = [];
|
|
80
|
+
// `--workspace`'s value, which bin/vatio.mjs takes out of the arguments.
|
|
81
|
+
this.workspaceFlag = null;
|
|
82
|
+
// Set for a command that works on the files (bindToDirectory).
|
|
83
|
+
this.directoryCommand = null;
|
|
45
84
|
}
|
|
46
85
|
|
|
47
86
|
load() {
|
|
@@ -103,12 +142,67 @@ export class Config {
|
|
|
103
142
|
return presence(process.env.VATIO_TOKEN) ?? presence(this.load().token);
|
|
104
143
|
}
|
|
105
144
|
|
|
106
|
-
//
|
|
107
|
-
|
|
145
|
+
// --workspace, then VATIO_WORKSPACE, then the manifest of the workspace the
|
|
146
|
+
// cwd is in. `quiet` keeps a vatio.yml that names another workspace from
|
|
147
|
+
// being mentioned, for a caller that is not running the command.
|
|
148
|
+
resolveWorkspace({ quiet = false } = {}) {
|
|
149
|
+
const named = this.namedWorkspace();
|
|
150
|
+
if (!named) return this.directoryWorkspace();
|
|
151
|
+
if (!quiet) this.#sayWhenDirectoryDiffers(named);
|
|
152
|
+
return named.slug;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// The `workspace:` of the vatio.yml at or above the cwd.
|
|
156
|
+
directoryWorkspace() {
|
|
108
157
|
if (!this.workspaceRoot) return null;
|
|
109
158
|
return presence(workspaceSlug(this.workspaceRoot))?.toLowerCase() ?? null;
|
|
110
159
|
}
|
|
111
160
|
|
|
161
|
+
// The workspace named without a vatio.yml, and by what; null when neither
|
|
162
|
+
// the flag nor the variable is given. A slug that is not one is refused
|
|
163
|
+
// here, where it can still be a sentence rather than a 404.
|
|
164
|
+
namedWorkspace() {
|
|
165
|
+
const flagged = this.workspaceFlag !== null;
|
|
166
|
+
const value = flagged ? this.workspaceFlag : presence(process.env[WORKSPACE_ENV]);
|
|
167
|
+
if (value === null) return null;
|
|
168
|
+
|
|
169
|
+
const source = flagged ? "--workspace" : WORKSPACE_ENV;
|
|
170
|
+
const slug = value.trim().toLowerCase();
|
|
171
|
+
if (!SLUG_FORMAT.test(slug)) {
|
|
172
|
+
throw new ConfigError(
|
|
173
|
+
`${source} ${JSON.stringify(value)} is not a workspace slug (lowercase letters, numbers, hyphens). ` +
|
|
174
|
+
"`vatio whoami` lists the workspaces this machine reaches."
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
return { slug, source };
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// What named the workspace, for a message that has to say so.
|
|
181
|
+
workspaceSource() {
|
|
182
|
+
if (this.workspaceFlag !== null) return "--workspace";
|
|
183
|
+
if (presence(process.env[WORKSPACE_ENV])) return WORKSPACE_ENV;
|
|
184
|
+
return this.workspaceRoot ? MANIFEST_FILE : null;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// For a command that reads or writes the workspace's files, called before it
|
|
188
|
+
// does anything. The flag is refused outright; VATIO_WORKSPACE only when it
|
|
189
|
+
// names a workspace other than the directory's, since an app's own config
|
|
190
|
+
// reads the same variable and having it exported should not stop a push.
|
|
191
|
+
bindToDirectory(command) {
|
|
192
|
+
this.directoryCommand = command;
|
|
193
|
+
const [takes, there] =
|
|
194
|
+
command === "init"
|
|
195
|
+
? [`writes ${MANIFEST_FILE} here and takes the workspace from its SLUG argument`, ""]
|
|
196
|
+
: [`works from the directory that holds ${MANIFEST_FILE} and takes the workspace from it`, " there"];
|
|
197
|
+
const refusal = `\`vatio ${command}\` ${takes}`;
|
|
198
|
+
if (this.workspaceFlag !== null) throw new ConfigError(`${refusal}: run it${there} without --workspace.`);
|
|
199
|
+
|
|
200
|
+
const named = presence(process.env[WORKSPACE_ENV]);
|
|
201
|
+
if (named !== null && named.toLowerCase() !== this.#directorySlugOrNull()) {
|
|
202
|
+
throw new ConfigError(`${refusal}, not from ${WORKSPACE_ENV} (${named}): run it${there} with ${WORKSPACE_ENV} unset.`);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
112
206
|
resolveWorkspaceRequired() {
|
|
113
207
|
const slug = this.resolveWorkspace();
|
|
114
208
|
if (slug) return slug;
|
|
@@ -124,14 +218,64 @@ export class Config {
|
|
|
124
218
|
}
|
|
125
219
|
|
|
126
220
|
workspaceRootRequired() {
|
|
221
|
+
const named = this.namedWorkspace();
|
|
222
|
+
if (named && named.slug !== this.#directorySlugOrNull()) {
|
|
223
|
+
throw new ConfigError(
|
|
224
|
+
`This works on the workspace's files, and ${named.source} names ${named.slug}, which has none here: ` +
|
|
225
|
+
`run it from the directory whose ${MANIFEST_FILE} says \`workspace: ${named.slug}\`, without ${named.source}.`
|
|
226
|
+
);
|
|
227
|
+
}
|
|
127
228
|
if (this.workspaceRoot) return this.workspaceRoot;
|
|
229
|
+
|
|
128
230
|
const below = workspacesBelow(this.startDir);
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
)
|
|
231
|
+
const lines = [`Not inside a Vatio workspace (no ${MANIFEST_FILE} found walking up from ${this.startDir}).`];
|
|
232
|
+
if (below.length > 0) {
|
|
233
|
+
lines.push(`There is one in ${below.map((dir) => `./${dir}`).join(", ")}: run it from there (\`cd ${below[0]}\`).`);
|
|
234
|
+
}
|
|
235
|
+
// Only a command that takes --workspace is told about it.
|
|
236
|
+
if (this.directoryCommand) {
|
|
237
|
+
if (below.length === 0) lines.push("Run `vatio init SLUG` here to create one.");
|
|
238
|
+
} else {
|
|
239
|
+
lines.push(
|
|
240
|
+
`A workspace with no ${MANIFEST_FILE}, built through the Vatio MCP, is named with --workspace SLUG ` +
|
|
241
|
+
`(\`vatio whoami\` lists yours)${below.length === 0 ? "; `vatio init SLUG` starts one kept as files here" : ""}.`
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
throw new ConfigError(lines.join("\n"));
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// The directory that holds the addressed workspace's files, or null: a
|
|
248
|
+
// workspace named by --workspace or VATIO_WORKSPACE has one here only when
|
|
249
|
+
// the vatio.yml here names it too. For what may sit beside vatio.yml without
|
|
250
|
+
// being required (identity.pem, .env, the chat state), so it never throws.
|
|
251
|
+
workspaceDirectory() {
|
|
252
|
+
if (!this.workspaceRoot) return null;
|
|
253
|
+
let named;
|
|
254
|
+
try {
|
|
255
|
+
named = this.namedWorkspace();
|
|
256
|
+
} catch {
|
|
257
|
+
return null;
|
|
258
|
+
}
|
|
259
|
+
if (!named) return this.workspaceRoot;
|
|
260
|
+
return named.slug === this.#directorySlugOrNull() ? this.workspaceRoot : null;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
#directorySlugOrNull() {
|
|
264
|
+
try {
|
|
265
|
+
return this.directoryWorkspace();
|
|
266
|
+
} catch {
|
|
267
|
+
return null;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// Said once, on stderr, so that a vatio.yml naming another workspace is
|
|
272
|
+
// never a surprise: the named one wins.
|
|
273
|
+
#sayWhenDirectoryDiffers(named) {
|
|
274
|
+
if (this.#differenceSaid) return;
|
|
275
|
+
const here = this.#directorySlugOrNull();
|
|
276
|
+
if (here === null || here === named.slug) return;
|
|
277
|
+
this.#differenceSaid = true;
|
|
278
|
+
console.error(`vatio: using workspace ${named.slug} from ${named.source}, not ${here} from ${this.manifestPath()}`);
|
|
135
279
|
}
|
|
136
280
|
|
|
137
281
|
manifestPath() {
|
|
@@ -243,7 +387,9 @@ export class Config {
|
|
|
243
387
|
);
|
|
244
388
|
}
|
|
245
389
|
if (normalized === "workspace") {
|
|
246
|
-
throw new ConfigError(
|
|
390
|
+
throw new ConfigError(
|
|
391
|
+
`the workspace is named by \`workspace:\` in ${MANIFEST_FILE}, or by --workspace or ${WORKSPACE_ENV}, never by config`
|
|
392
|
+
);
|
|
247
393
|
}
|
|
248
394
|
if (REMOVED_KEYS.includes(normalized)) {
|
|
249
395
|
throw new ConfigError(
|
package/lib/help.mjs
CHANGED
|
@@ -8,15 +8,24 @@ export function helpText() {
|
|
|
8
8
|
|
|
9
9
|
(installed globally with \`npm i -g @vatio-ai/cli\`, the command is just \`vatio\`)
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
the
|
|
11
|
+
To build and test an agent from a coding agent, connect the Vatio MCP
|
|
12
|
+
(https://vatio.ai/mcp) instead: \`npx @vatio-ai/skills\` adds it to the
|
|
13
|
+
project, then /vatio-init. Vatio holds the agent, and nothing goes in your
|
|
14
|
+
repository. The CLI is for a team that keeps the agent as files.
|
|
15
|
+
|
|
16
|
+
A workspace is any directory with a vatio.yml: commands read \`workspace:\`
|
|
17
|
+
from the vatio.yml at or above the cwd. --workspace SLUG (anywhere on the
|
|
18
|
+
command line) or VATIO_WORKSPACE names one instead, such as a workspace built
|
|
19
|
+
through the MCP, which has no vatio.yml; it wins over a vatio.yml, and the
|
|
20
|
+
command says so when the two differ. init, push, pull, diff and auth work on
|
|
21
|
+
the files, so they go by the directory alone: they refuse --workspace, and a
|
|
22
|
+
VATIO_WORKSPACE that names another workspace.
|
|
23
|
+
|
|
24
|
+
A push reaches your team at once (\`vatio chat\` and Try the agent talk to
|
|
25
|
+
it) and everyone once the tests that pass today pass on it, a few minutes
|
|
26
|
+
later; with no tests, at once. A test it breaks holds it back from everyone:
|
|
27
|
+
\`vatio status\` says which, and another push that fixes it, or removing a test
|
|
28
|
+
it made obsolete, moves it on. \`vatio rollback\` undoes the last change.
|
|
20
29
|
|
|
21
30
|
Getting started:
|
|
22
31
|
init [SLUG] [--name NAME] Create vatio.yml here, and the remote to match
|
|
@@ -45,40 +54,28 @@ the two you are in. Commands default as listed.
|
|
|
45
54
|
share-session --never Stop coding agents from offering
|
|
46
55
|
|
|
47
56
|
Deploy:
|
|
48
|
-
push [--force] Validate the workspace, then deploy it
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
push from another git branch; --force replaces
|
|
55
|
-
either
|
|
56
|
-
pull [--env NAME] [--force]
|
|
57
|
-
Write the deployed agent into vatio.yml's agent:
|
|
57
|
+
push [--force] Validate the workspace, then deploy it (the first
|
|
58
|
+
push signs in like \`login\`): your team has it
|
|
59
|
+
at once, everyone once its tests pass. Refused
|
|
60
|
+
over edits made outside your files (pull them
|
|
61
|
+
first); --force overwrites them
|
|
62
|
+
pull [--force] Write the deployed agent into vatio.yml's agent:
|
|
58
63
|
block and tools/, edits from the Vatio MCP
|
|
59
|
-
included
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
changes, who pushed it and when, published or
|
|
69
|
-
not), the replies Vatio wrote for the agent, and
|
|
70
|
-
your WhatsApp number when Meta refuses its sends
|
|
71
|
-
env [preview|live] An environment: token, widget snippet, link,
|
|
72
|
-
knowledge changes and conflicts (default: preview)
|
|
73
|
-
env list Both environments and what each runs
|
|
74
|
-
diff [--env NAME] What this directory would change (default: preview)
|
|
75
|
-
--env live answers "what would publishing change?"
|
|
64
|
+
included. Wants vatio.yml and tools/ committed
|
|
65
|
+
to git; --force writes anyway
|
|
66
|
+
rollback Put everyone, your team included, back on the
|
|
67
|
+
version before the last change: config and knowledge
|
|
68
|
+
status Where the newest change stands (everyone has it,
|
|
69
|
+
its tests are running, or a test held it and
|
|
70
|
+
which), the replies Vatio wrote for the agent,
|
|
71
|
+
and your WhatsApp number when Meta refuses its sends
|
|
72
|
+
diff What this directory would change
|
|
76
73
|
diff --stat|--name-only|--format json|--full
|
|
77
74
|
|
|
78
75
|
Talk to your agent (as yourself by default — the token is the identity):
|
|
79
|
-
chat "message" [--file PATH]... [--
|
|
76
|
+
chat "message" [--file PATH]... [--new] [--as-phone me|PHONE]
|
|
80
77
|
[--as-subject ID | --visitor-token JWT]
|
|
81
|
-
|
|
78
|
+
The newest version, the one your team has; --new
|
|
82
79
|
starts over as a visitor the agent never met,
|
|
83
80
|
in a new chat whose id it prints.
|
|
84
81
|
--file attaches an image, PDF, text or audio file
|
|
@@ -101,16 +98,16 @@ the two you are in. Commands default as listed.
|
|
|
101
98
|
viewers included; every call is in the activity
|
|
102
99
|
|
|
103
100
|
Test and improve it: what it should do, what supervisors reported, and how
|
|
104
|
-
its tools answered (test add, test list, fix, push, test
|
|
101
|
+
its tools answered (test add, test list, fix, push, test):
|
|
105
102
|
tools [--env NAME] [--period 1h|1d|7d|30d] [--json]
|
|
106
103
|
Each tool's calls, error rate, timeouts and
|
|
107
104
|
p50/p95, then the calls that failed with what
|
|
108
105
|
your backend answered. Default: live, 7d
|
|
109
|
-
test [--
|
|
110
|
-
Test every report and test against
|
|
111
|
-
|
|
112
|
-
prints their ids and returns.
|
|
113
|
-
|
|
106
|
+
test [--agent SLUG] [--as-subject ID | --visitor-token JWT]
|
|
107
|
+
Test every report and test against your team's
|
|
108
|
+
version: starts the runs on Vatio's servers,
|
|
109
|
+
prints their ids and returns. A run that passes
|
|
110
|
+
also releases a change a test held back.
|
|
114
111
|
--as-subject replays every case signed in as
|
|
115
112
|
that visitor (see \`vatio chat\`)
|
|
116
113
|
test --wait [--timeout N] Wait for the judge and print the report; exits 1
|
|
@@ -118,7 +115,7 @@ the two you are in. Commands default as listed.
|
|
|
118
115
|
test --show RUN_ID One run's report so far, with the replay chat of
|
|
119
116
|
each case that did not pass (vatio chat show ID)
|
|
120
117
|
test add "QUESTION" "WHAT IT SHOULD DO" [--as-phone me|PHONE] [--as-subject ID]
|
|
121
|
-
Ask it in a new chat
|
|
118
|
+
Ask it in a new chat and keep
|
|
122
119
|
the turn as a test, judged at once
|
|
123
120
|
test add "WHAT IT SHOULD DO" [--chat ID|--message ID]
|
|
124
121
|
The same on a reply you already have: the agent's
|
|
@@ -134,17 +131,15 @@ the two you are in. Commands default as listed.
|
|
|
134
131
|
kb [list] Bases, and whether a deployed agent reads each
|
|
135
132
|
kb show NAME One base and its entries
|
|
136
133
|
kb create NAME | rm NAME
|
|
137
|
-
kb write BASE ENTRY [FILE] Write an entry
|
|
134
|
+
kb write BASE ENTRY [FILE] Write an entry, from FILE or stdin: your team has
|
|
135
|
+
it at once, everyone once the tests pass
|
|
138
136
|
kb cat BASE ENTRY [--version N]
|
|
139
137
|
Print an entry's markdown, or one old version
|
|
140
|
-
kb rm-entry BASE ENTRY Delete one entry
|
|
141
|
-
kb status BASE What
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
(entry commands take --env; --env live writes live)
|
|
146
|
-
|
|
147
|
-
Business (one value for every environment, live on save; also in the inbox,
|
|
138
|
+
kb rm-entry BASE ENTRY Delete one entry
|
|
139
|
+
kb status BASE What your team has that everyone does not have yet
|
|
140
|
+
kb history BASE What reached everyone, newest first
|
|
141
|
+
|
|
142
|
+
Business (one value, everyone has it on save; also in the inbox,
|
|
148
143
|
on the Web chat page):
|
|
149
144
|
business [show] Name and brand, and the old business description
|
|
150
145
|
if there is one
|
|
@@ -152,8 +147,8 @@ the two you are in. Commands default as listed.
|
|
|
152
147
|
[--logo FILE | --remove-logo] [--clear-description]
|
|
153
148
|
What the business does goes in agent.instructions
|
|
154
149
|
|
|
155
|
-
Quiet hours (when the agent does not answer; one schedule
|
|
156
|
-
|
|
150
|
+
Quiet hours (when the agent does not answer; one schedule, everyone has it on
|
|
151
|
+
save; also in the inbox, under Channels):
|
|
157
152
|
quiet-hours [show] The weekly schedule, and whether it is silent now
|
|
158
153
|
quiet-hours set --timezone ZONE --range "DAYS HH:MM-HH:MM" [--range ...]
|
|
159
154
|
Replace the schedule. DAYS: mon, mon-fri, sat,sun, all
|
|
@@ -168,26 +163,24 @@ the two you are in. Commands default as listed.
|
|
|
168
163
|
someone or changing a role stays in the inbox
|
|
169
164
|
|
|
170
165
|
Credentials:
|
|
171
|
-
secrets list|set KEY [VALUE] [--from-env [NAME]]|rm KEY [--
|
|
166
|
+
secrets list|set KEY [VALUE] [--from-env [NAME]]|rm KEY [--tests]
|
|
172
167
|
Without VALUE, set asks for it with the input hidden.
|
|
173
168
|
--from-env takes the value from your shell or the
|
|
174
169
|
.env beside the workspace, so a coding agent can set
|
|
175
170
|
a secret without being shown it (NAME defaults to KEY).
|
|
176
|
-
With --
|
|
177
|
-
|
|
178
|
-
|
|
171
|
+
With --tests, the value your team's conversations
|
|
172
|
+
with the agent and every test run use, like a
|
|
173
|
+
staging URL; otherwise the value everywhere
|
|
179
174
|
keys list [--json] API keys of both kinds: publishable (for a page or
|
|
180
|
-
app) and secret (for your
|
|
181
|
-
|
|
182
|
-
|
|
175
|
+
app, with where it was used) and secret (for your
|
|
176
|
+
backend, with its scopes)
|
|
177
|
+
keys create publishable|secret [--label NAME] [--json]
|
|
178
|
+
A publishable key works from any site
|
|
183
179
|
keys create secret --scope NAME... [--code CODE | --recovery-code CODE]
|
|
184
180
|
What the secret key may call: messages, instagram,
|
|
185
181
|
chats, team (repeatable). Without --scope, all but
|
|
186
182
|
team. team (add people to the team) is the owner's,
|
|
187
183
|
with a code from their authenticator app
|
|
188
|
-
keys origins PREFIX URL...
|
|
189
|
-
The origins a publishable key is accepted from
|
|
190
|
-
(replaces the list)
|
|
191
184
|
keys revoke PREFIX
|
|
192
185
|
auth --new-key Keypair that signs the JWT saying who a visitor is
|
|
193
186
|
|
|
@@ -244,9 +237,16 @@ the two you are in. Commands default as listed.
|
|
|
244
237
|
Everything else:
|
|
245
238
|
config show|get KEY|set KEY VALUE|unset KEY
|
|
246
239
|
Keys: base_url, token
|
|
240
|
+
env [list] The version your team has and the one everyone
|
|
241
|
+
has, with the deployment each runs
|
|
242
|
+
publish Nothing to do: a push reaches everyone once its
|
|
243
|
+
tests pass. Prints that and exits 0, for scripts
|
|
244
|
+
|
|
245
|
+
Global flag: --workspace SLUG names the workspace (not for init, push, pull,
|
|
246
|
+
diff, auth)
|
|
247
247
|
|
|
248
|
-
Environment: VATIO_BASE_URL, VATIO_TOKEN,
|
|
249
|
-
VATIO_TELEMETRY=0 (see vatio.ai/docs/cli/workspace#telemetry)
|
|
248
|
+
Environment: VATIO_BASE_URL, VATIO_TOKEN, VATIO_WORKSPACE, VATIO_HOME,
|
|
249
|
+
VATIO_NO_UPDATE_NOTIFIER, VATIO_TELEMETRY=0 (see vatio.ai/docs/cli/workspace#telemetry)
|
|
250
250
|
|
|
251
251
|
Docs: https://vatio.ai/docs
|
|
252
252
|
`;
|
package/lib/telemetry.mjs
CHANGED
|
@@ -206,7 +206,7 @@ async function post(config, body, { strict = false } = {}) {
|
|
|
206
206
|
headers,
|
|
207
207
|
body: JSON.stringify({
|
|
208
208
|
...body,
|
|
209
|
-
workspace: safely(() => config.resolveWorkspace())
|
|
209
|
+
workspace: safely(() => config.resolveWorkspace({ quiet: true }))
|
|
210
210
|
}),
|
|
211
211
|
signal: AbortSignal.timeout(strict ? 10_000 : REPORT_TIMEOUT_MS)
|
|
212
212
|
});
|
package/lib/visitor-identity.mjs
CHANGED
|
@@ -87,8 +87,8 @@ function loadKey(config, keyFile) {
|
|
|
87
87
|
} else if (process.env[KEY_ENV]) {
|
|
88
88
|
pem = process.env[KEY_ENV];
|
|
89
89
|
} else {
|
|
90
|
-
const
|
|
91
|
-
if (existsSync(
|
|
90
|
+
const root = config.workspaceDirectory();
|
|
91
|
+
if (root && existsSync(join(root, KEY_FILE))) pem = readFileSync(join(root, KEY_FILE), "utf8");
|
|
92
92
|
}
|
|
93
93
|
if (pem === null) {
|
|
94
94
|
fail(
|
|
@@ -107,8 +107,10 @@ function loadKey(config, keyFile) {
|
|
|
107
107
|
// Vatio verifies with the algorithm the manifest declares, never the token's
|
|
108
108
|
// own header, so a token signed with another one would simply not verify.
|
|
109
109
|
function declaredAlgorithm(config) {
|
|
110
|
+
const root = config.workspaceDirectory();
|
|
111
|
+
if (!root) return null;
|
|
110
112
|
try {
|
|
111
|
-
const manifest = parseYaml(readFileSync(join(
|
|
113
|
+
const manifest = parseYaml(readFileSync(join(root, MANIFEST_FILE), "utf8"));
|
|
112
114
|
const algorithm = String(manifest?.auth?.algorithm ?? "").trim().toUpperCase();
|
|
113
115
|
return ALGORITHMS.includes(algorithm) ? algorithm : null;
|
|
114
116
|
} catch {
|