@vatio-ai/cli 0.100.3 → 0.101.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 -1
- package/bin/vatio.mjs +1 -3
- package/lib/api-client.mjs +10 -26
- package/lib/commands/env.mjs +3 -3
- package/lib/commands/routines.mjs +1 -1
- package/lib/commands/workspace-admin.mjs +56 -83
- package/lib/help.mjs +8 -5
- package/lib/suggest.mjs +4 -5
- package/lib/support.mjs +1 -1
- package/lib/telemetry.mjs +1 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -91,7 +91,7 @@ kb list|show|create|rm Knowledge bases
|
|
|
91
91
|
kb write|cat|rm-entry Entries, from a file or stdin
|
|
92
92
|
|
|
93
93
|
secrets list|set|rm Credentials your tools read
|
|
94
|
-
|
|
94
|
+
keys list|create|origins|revoke API keys: publishable (page, app) and secret (backend)
|
|
95
95
|
auth --new-key Keypair that signs the visitor's JWT
|
|
96
96
|
auth --supabase [URL] Your users sign in with Supabase: no keys, no code
|
|
97
97
|
|
package/bin/vatio.mjs
CHANGED
|
@@ -14,7 +14,7 @@ import { login, logout } from "../lib/commands/auth.mjs";
|
|
|
14
14
|
import { configCommand, doctor, init, version, whoami } from "../lib/commands/misc.mjs";
|
|
15
15
|
import { diff, publish, pull, push, rollback, status } from "../lib/commands/deploy.mjs";
|
|
16
16
|
import { env } from "../lib/commands/env.mjs";
|
|
17
|
-
import { keys, secrets
|
|
17
|
+
import { keys, secrets } from "../lib/commands/workspace-admin.mjs";
|
|
18
18
|
import { templates, webhooks } from "../lib/commands/webhooks.mjs";
|
|
19
19
|
import { routines } from "../lib/commands/routines.mjs";
|
|
20
20
|
import { auth } from "../lib/commands/identity-key.mjs";
|
|
@@ -96,8 +96,6 @@ async function run(command, args) {
|
|
|
96
96
|
return await env(config, args);
|
|
97
97
|
case "diff":
|
|
98
98
|
return await diff(config, args);
|
|
99
|
-
case "tokens":
|
|
100
|
-
return await tokens(config, args);
|
|
101
99
|
case "keys":
|
|
102
100
|
return await keys(config, args);
|
|
103
101
|
case "templates":
|
package/lib/api-client.mjs
CHANGED
|
@@ -174,25 +174,25 @@ export class ApiClient extends HttpClient {
|
|
|
174
174
|
return this.get(`/knowledge_bases/${encode(base)}/history`);
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
// --- publishable
|
|
177
|
+
// --- API keys (publishable and secret) -----------------------------
|
|
178
178
|
|
|
179
|
-
|
|
180
|
-
return this.get("/
|
|
179
|
+
listApiKeys() {
|
|
180
|
+
return this.get("/api_keys");
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
-
|
|
184
|
-
const body = { environment };
|
|
183
|
+
createApiKey({ kind, environment, label = null, allowedOrigins = [] }) {
|
|
184
|
+
const body = { kind, environment };
|
|
185
185
|
if (String(label ?? "").trim() !== "") body.label = String(label).trim();
|
|
186
186
|
if (allowedOrigins.length > 0) body.allowed_origins = allowedOrigins;
|
|
187
|
-
return this.post("/
|
|
187
|
+
return this.post("/api_keys", body);
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
-
|
|
191
|
-
return this.patch(`/
|
|
190
|
+
setApiKeyOrigins({ prefix, allowedOrigins }) {
|
|
191
|
+
return this.patch(`/api_keys/${encode(prefix)}`, { allowed_origins: allowedOrigins });
|
|
192
192
|
}
|
|
193
193
|
|
|
194
|
-
|
|
195
|
-
return this.delete(`/
|
|
194
|
+
revokeApiKey({ prefix }) {
|
|
195
|
+
return this.delete(`/api_keys/${encode(prefix)}`);
|
|
196
196
|
}
|
|
197
197
|
|
|
198
198
|
// --- business -------------------------------------------------------
|
|
@@ -229,22 +229,6 @@ export class ApiClient extends HttpClient {
|
|
|
229
229
|
return this.patch("/quiet_hours", { quiet_hours: quietHours });
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
-
// --- server keys ----------------------------------------------------
|
|
233
|
-
|
|
234
|
-
listServerKeys() {
|
|
235
|
-
return this.get("/server_keys");
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
createServerKey({ environment, label = null }) {
|
|
239
|
-
const body = { environment };
|
|
240
|
-
if (String(label ?? "").trim() !== "") body.label = String(label).trim();
|
|
241
|
-
return this.post("/server_keys", body);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
revokeServerKey({ prefix }) {
|
|
245
|
-
return this.delete(`/server_keys/${encode(prefix)}`);
|
|
246
|
-
}
|
|
247
|
-
|
|
248
232
|
// --- templates, webhooks ---------------------------------------------
|
|
249
233
|
|
|
250
234
|
listTemplates({ environment }) {
|
package/lib/commands/env.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// There are two: preview, the next version, which `vatio push` updates and
|
|
4
4
|
// where its knowledge changes and secret values sit on top of live; and live,
|
|
5
5
|
// what visitors talk to. This hands over what an app needs to talk to one --
|
|
6
|
-
// the publishable
|
|
6
|
+
// the publishable key and the widget snippet -- and the link to try it on
|
|
7
7
|
// the inbox's Try the agent panel.
|
|
8
8
|
|
|
9
9
|
import { deployClient } from "./deploy.mjs";
|
|
@@ -58,12 +58,12 @@ async function show(client, workspace, name) {
|
|
|
58
58
|
if (row.share_url) console.log(` try it: ${row.share_url}`);
|
|
59
59
|
|
|
60
60
|
if (row.token) {
|
|
61
|
-
console.log(` publishable
|
|
61
|
+
console.log(` publishable key: ${row.token}`);
|
|
62
62
|
console.log("\n widget:");
|
|
63
63
|
console.log(` <script src="${row.widget_script_url}"`);
|
|
64
64
|
console.log(` data-workspace="${workspace}"`);
|
|
65
65
|
console.log(` data-token="${row.token}"></script>`);
|
|
66
|
-
console.log("\n SDK: new VatioChat({ workspace, token }) with the
|
|
66
|
+
console.log("\n SDK: new VatioChat({ workspace, token }) with the key above talks to this environment.");
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
const changes = asArray(row.knowledge_changes);
|
|
@@ -60,7 +60,7 @@ export async function routines(config, args) {
|
|
|
60
60
|
console.log(`${paint("green", "✓")} Created routine #${routine.id} (${routine.name}) on ${routine.environment}`);
|
|
61
61
|
printRoutine(routine);
|
|
62
62
|
console.log("");
|
|
63
|
-
console.log("Give the routine a
|
|
63
|
+
console.log("Give the routine a secret key so it can read the conversation: vatio keys create secret --env " +
|
|
64
64
|
`${routine.environment} --label ${routine.name}`);
|
|
65
65
|
console.log(`Check it starts: vatio routines test ${routine.id}`);
|
|
66
66
|
console.log(`Then give it to the agent: tools/${routine.name}.yml with \`routine: ${routine.name}\`, ` +
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
// secrets /
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// them is in vatio.yml.
|
|
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
|
+
// with the origins it accepts, and secret); none of them is in vatio.yml.
|
|
5
4
|
|
|
6
5
|
import { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
7
6
|
import { join } from "node:path";
|
|
@@ -112,7 +111,17 @@ function takeOrigins(args) {
|
|
|
112
111
|
return origins;
|
|
113
112
|
}
|
|
114
113
|
|
|
115
|
-
|
|
114
|
+
const KINDS = ["publishable", "secret"];
|
|
115
|
+
const KEYS_USAGE =
|
|
116
|
+
"Usage: vatio keys list [--json]|create publishable|secret [--env live|preview] [--label NAME] [--origin URL]... [--json]|" +
|
|
117
|
+
"origins PREFIX URL...|revoke PREFIX";
|
|
118
|
+
|
|
119
|
+
// API keys, of two kinds. A publishable key is for a page or an app: public by
|
|
120
|
+
// design, accepted only from the origins it lists. A secret key is for the
|
|
121
|
+
// developer's own backend (today, to have the agent write to a contact first):
|
|
122
|
+
// it never goes in a page or an app, and unlike the CLI's own token it belongs
|
|
123
|
+
// to the workspace, so it outlives whoever created it.
|
|
124
|
+
export async function keys(config, args) {
|
|
116
125
|
const environment = environmentOption(args, "live");
|
|
117
126
|
const label = takeValue(args, "--label") ?? takeValue(args, "-l");
|
|
118
127
|
const origins = takeOrigins(args);
|
|
@@ -122,101 +131,58 @@ export async function tokens(config, args) {
|
|
|
122
131
|
const sub = args.shift() ?? "list";
|
|
123
132
|
|
|
124
133
|
if (sub === "list") {
|
|
125
|
-
const payload = await client.
|
|
126
|
-
const list = asArray(payload.
|
|
134
|
+
const payload = await client.listApiKeys();
|
|
135
|
+
const list = asArray(payload.api_keys);
|
|
127
136
|
if (json) {
|
|
128
137
|
console.log(JSON.stringify(list, null, 2));
|
|
129
138
|
return;
|
|
130
139
|
}
|
|
131
140
|
if (list.length === 0) {
|
|
132
|
-
console.log(`No
|
|
133
|
-
console.log(" Create one: vatio
|
|
141
|
+
console.log(`No API keys on workspace ${workspace}`);
|
|
142
|
+
console.log(" Create one: vatio keys create publishable --env live --origin https://your-site.com");
|
|
143
|
+
console.log(" vatio keys create secret --env live --label backend");
|
|
134
144
|
return;
|
|
135
145
|
}
|
|
136
|
-
console.log(`
|
|
137
|
-
for (const
|
|
138
|
-
const parts = [
|
|
139
|
-
if (
|
|
146
|
+
console.log(`API keys on workspace ${workspace} (${list.length}):`);
|
|
147
|
+
for (const key of list) {
|
|
148
|
+
const parts = [key.kind, key.prefix, key.environment];
|
|
149
|
+
if (key.label) parts.push(key.label);
|
|
150
|
+
if (key.managed) parts.push(`managed${key.managed_kind ? ` (${key.managed_kind})` : ""}`);
|
|
151
|
+
parts.push(key.last_used_at ? `last used ${key.last_used_at}` : "never used");
|
|
140
152
|
console.log(` ${parts.filter(Boolean).join(" ")}`);
|
|
141
|
-
console.log(` origins: ${originsLine(
|
|
153
|
+
if (key.kind === "publishable") console.log(` origins: ${originsLine(key.allowed_origins)}`);
|
|
142
154
|
}
|
|
143
155
|
return;
|
|
144
156
|
}
|
|
145
157
|
if (sub === "create") {
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
158
|
+
const kind = args.shift();
|
|
159
|
+
if (!KINDS.includes(kind)) fail("Say which kind: vatio keys create publishable|secret [--env NAME] [--label NAME] [--origin URL]...");
|
|
160
|
+
if (kind === "secret" && origins.length > 0) {
|
|
161
|
+
fail("--origin only applies to a publishable key. A secret key is for your backend and has no origins.");
|
|
162
|
+
}
|
|
163
|
+
const payload = await client.createApiKey({
|
|
164
|
+
kind,
|
|
165
|
+
environment,
|
|
166
|
+
label,
|
|
167
|
+
allowedOrigins: kind === "publishable" ? origins : []
|
|
168
|
+
});
|
|
169
|
+
// For a script that hands the key straight to something else: the key or a
|
|
170
|
+
// failed command, never a line of prose to grep it out of.
|
|
149
171
|
if (json) {
|
|
150
|
-
console.log(JSON.stringify({ ...payload,
|
|
172
|
+
console.log(JSON.stringify({ ...payload, workspace }, null, 2));
|
|
151
173
|
return;
|
|
152
174
|
}
|
|
153
|
-
console.log(`Created a
|
|
154
|
-
console.log(` origins: ${originsLine(payload.allowed_origins)}`);
|
|
175
|
+
console.log(`Created a ${kind} key for ${environment} on workspace ${workspace}`);
|
|
176
|
+
if (kind === "publishable") console.log(` origins: ${originsLine(payload.api_key?.allowed_origins)}`);
|
|
155
177
|
console.log("");
|
|
156
178
|
// Shown in full exactly once: the platform stores a digest, so this is the
|
|
157
179
|
// only moment the value exists anywhere the developer can copy it.
|
|
158
|
-
console.log(` ${payload.
|
|
180
|
+
console.log(` ${payload.key}`);
|
|
159
181
|
console.log("");
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
if (sub === "origins") {
|
|
164
|
-
const prefix = args.shift();
|
|
165
|
-
if (!prefix) fail("Usage: vatio tokens origins PREFIX [URL...] (no URL clears the list)");
|
|
166
|
-
const payload = await client.setPublishableTokenOrigins({ prefix, allowedOrigins: args.splice(0) });
|
|
167
|
-
console.log(`Origins for ${prefix}: ${originsLine(payload.allowed_origins)}`);
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
if (sub === "revoke") {
|
|
171
|
-
const prefix = args.shift();
|
|
172
|
-
if (!prefix) fail("Usage: vatio tokens revoke PREFIX");
|
|
173
|
-
await client.revokePublishableToken({ prefix });
|
|
174
|
-
console.log(`Revoked ${prefix} on workspace ${workspace}`);
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
fail(
|
|
179
|
-
"Usage: vatio tokens list|create [--env live|preview] [--label NAME] [--origin URL]... [--json]|" +
|
|
180
|
-
"origins PREFIX URL...|revoke PREFIX"
|
|
181
|
-
);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// Server keys: what the developer's own backend calls the server API with --
|
|
185
|
-
// today, to have the agent write to a contact first. Unlike a publishable
|
|
186
|
-
// token it is a secret, and unlike the CLI's own token it belongs to the
|
|
187
|
-
// workspace, so it outlives whoever created it.
|
|
188
|
-
export async function keys(config, args) {
|
|
189
|
-
const environment = environmentOption(args, "live");
|
|
190
|
-
const label = takeValue(args, "--label") ?? takeValue(args, "-l");
|
|
191
|
-
const workspace = config.resolveWorkspaceRequired();
|
|
192
|
-
const client = deployClient(config, workspace);
|
|
193
|
-
const sub = args.shift() ?? "list";
|
|
194
|
-
|
|
195
|
-
if (sub === "list") {
|
|
196
|
-
const payload = await client.listServerKeys();
|
|
197
|
-
const list = asArray(payload.server_keys);
|
|
198
|
-
if (list.length === 0) {
|
|
199
|
-
console.log(`No server keys on workspace ${workspace}`);
|
|
200
|
-
console.log(" Create one: vatio keys create --env live --label backend");
|
|
182
|
+
if (kind === "publishable") {
|
|
183
|
+
console.log("Copy it now — it is not shown again.");
|
|
201
184
|
return;
|
|
202
185
|
}
|
|
203
|
-
console.log(`Server keys on workspace ${workspace} (${list.length}):`);
|
|
204
|
-
for (const key of list) {
|
|
205
|
-
const parts = [key.prefix, key.environment];
|
|
206
|
-
if (key.label) parts.push(key.label);
|
|
207
|
-
parts.push(key.last_used_at ? `last used ${key.last_used_at}` : "never used");
|
|
208
|
-
console.log(` ${parts.join(" ")}`);
|
|
209
|
-
}
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
if (sub === "create") {
|
|
213
|
-
const payload = await client.createServerKey({ environment, label });
|
|
214
|
-
console.log(`Created a server key for ${environment} on workspace ${workspace}`);
|
|
215
|
-
console.log("");
|
|
216
|
-
// The platform keeps only a digest: this is the one time the key exists
|
|
217
|
-
// anywhere it can be copied from.
|
|
218
|
-
console.log(` ${payload.key}`);
|
|
219
|
-
console.log("");
|
|
220
186
|
console.log("Copy it now — it is not shown again. Keep it on your server, never in a page or an app:");
|
|
221
187
|
console.log("");
|
|
222
188
|
console.log(` VATIO_SERVER_KEY=${payload.key}`);
|
|
@@ -226,15 +192,22 @@ export async function keys(config, args) {
|
|
|
226
192
|
console.log(' -H "Authorization: Bearer $VATIO_SERVER_KEY"');
|
|
227
193
|
return;
|
|
228
194
|
}
|
|
195
|
+
if (sub === "origins") {
|
|
196
|
+
const prefix = args.shift();
|
|
197
|
+
if (!prefix) fail("Usage: vatio keys origins PREFIX [URL...] (no URL clears the list)");
|
|
198
|
+
const payload = await client.setApiKeyOrigins({ prefix, allowedOrigins: args.splice(0) });
|
|
199
|
+
console.log(`Origins for ${prefix}: ${originsLine(payload.api_key?.allowed_origins)}`);
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
229
202
|
if (sub === "revoke") {
|
|
230
203
|
const prefix = args.shift();
|
|
231
204
|
if (!prefix) fail("Usage: vatio keys revoke PREFIX");
|
|
232
|
-
await client.
|
|
205
|
+
await client.revokeApiKey({ prefix });
|
|
233
206
|
console.log(`Revoked ${prefix} on workspace ${workspace}`);
|
|
234
207
|
return;
|
|
235
208
|
}
|
|
236
209
|
|
|
237
|
-
fail(
|
|
210
|
+
fail(KEYS_USAGE);
|
|
238
211
|
}
|
|
239
212
|
|
|
240
213
|
// A flag whose value is optional: `--flag`, `--flag VALUE` or `--flag=VALUE`.
|
|
@@ -358,10 +331,10 @@ function valueIn(text, name) {
|
|
|
358
331
|
|
|
359
332
|
const UNTERMINATED = Symbol("unterminated");
|
|
360
333
|
|
|
361
|
-
// An empty list is not "anywhere": only Vatio's own pages can use the
|
|
334
|
+
// An empty list is not "anywhere": only Vatio's own pages can use the key.
|
|
362
335
|
function originsLine(origins) {
|
|
363
336
|
const list = asArray(origins);
|
|
364
|
-
return list.length > 0 ? list.join(", ") : "none (add one with `vatio
|
|
337
|
+
return list.length > 0 ? list.join(", ") : "none (add one with `vatio keys origins PREFIX URL`)";
|
|
365
338
|
}
|
|
366
339
|
|
|
367
340
|
function asArray(value) {
|
package/lib/help.mjs
CHANGED
|
@@ -161,11 +161,14 @@ the two you are in. Commands default as listed.
|
|
|
161
161
|
With --env, the value only that environment uses;
|
|
162
162
|
otherwise the value everywhere. With --tests, the
|
|
163
163
|
value preview and every test run use, like a staging URL
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
164
|
+
keys list [--json] API keys of both kinds: publishable (for a page or
|
|
165
|
+
app) and secret (for your backend)
|
|
166
|
+
keys create publishable|secret [--env NAME] [--label NAME] [--origin URL]... [--json]
|
|
167
|
+
--origin only for a publishable key
|
|
168
|
+
keys origins PREFIX URL...
|
|
169
|
+
The origins a publishable key is accepted from
|
|
170
|
+
(replaces the list)
|
|
171
|
+
keys revoke PREFIX
|
|
169
172
|
auth --new-key Keypair that signs the JWT saying who a visitor is
|
|
170
173
|
auth --supabase [URL] [--sign-in-url URL]
|
|
171
174
|
Your users sign in with Supabase: verify their
|
package/lib/suggest.mjs
CHANGED
|
@@ -56,7 +56,6 @@ export const COMMANDS = [
|
|
|
56
56
|
"team",
|
|
57
57
|
"templates",
|
|
58
58
|
"test",
|
|
59
|
-
"tokens",
|
|
60
59
|
"tools",
|
|
61
60
|
"version",
|
|
62
61
|
"webhooks",
|
|
@@ -75,7 +74,7 @@ export const COMMANDS = [
|
|
|
75
74
|
const SUBCOMMAND_OF = {
|
|
76
75
|
add: ["flags", "test"],
|
|
77
76
|
cat: ["kb"],
|
|
78
|
-
create: ["kb", "
|
|
77
|
+
create: ["kb", "keys", "templates", "webhooks", "routines"],
|
|
79
78
|
deliveries: ["webhooks"],
|
|
80
79
|
enable: ["webhooks", "routines"],
|
|
81
80
|
export: ["chat"],
|
|
@@ -84,12 +83,12 @@ const SUBCOMMAND_OF = {
|
|
|
84
83
|
get: ["config"],
|
|
85
84
|
history: ["kb"],
|
|
86
85
|
invite: ["team"],
|
|
87
|
-
list: ["env", "kb", "secrets", "
|
|
86
|
+
list: ["env", "kb", "secrets", "keys", "team", "templates", "webhooks", "routines", "test"],
|
|
88
87
|
off: ["quiet-hours"],
|
|
89
|
-
origins: ["
|
|
88
|
+
origins: ["keys"],
|
|
90
89
|
refresh: ["kb"],
|
|
91
90
|
remove: ["secrets", "webhooks", "routines", "flags", "test"],
|
|
92
|
-
revoke: ["
|
|
91
|
+
revoke: ["keys"],
|
|
93
92
|
rm: ["env", "kb", "secrets", "webhooks", "routines", "flags", "test"],
|
|
94
93
|
"rm-entry": ["kb"],
|
|
95
94
|
runs: ["routines"],
|
package/lib/support.mjs
CHANGED
|
@@ -20,7 +20,7 @@ export function fail(message) {
|
|
|
20
20
|
// preview or live. The platform validates the name.
|
|
21
21
|
//
|
|
22
22
|
// Without it, the default is the command's own and is passed in, because the
|
|
23
|
-
// sensible answer differs: push writes preview,
|
|
23
|
+
// sensible answer differs: push writes preview, keys are for live. `--as`
|
|
24
24
|
// was the spelling on push and publish and stays as an alias -- it is sitting
|
|
25
25
|
// in CI jobs, and there is nothing wrong with what it does.
|
|
26
26
|
export function takeEnv(args, { fallback = null } = {}) {
|
package/lib/telemetry.mjs
CHANGED
|
@@ -32,8 +32,7 @@ const SUBCOMMANDS = {
|
|
|
32
32
|
business: ["show", "set"],
|
|
33
33
|
"quiet-hours": ["show", "set", "off"],
|
|
34
34
|
secrets: ["list", "set", "rm"],
|
|
35
|
-
|
|
36
|
-
keys: ["list", "create", "revoke"],
|
|
35
|
+
keys: ["list", "create", "origins", "revoke"],
|
|
37
36
|
templates: ["list", "create"],
|
|
38
37
|
webhooks: ["list", "create", "test", "deliveries", "enable", "rm"],
|
|
39
38
|
routines: ["list", "create", "update", "test", "runs", "enable", "rm"],
|