@vatio-ai/cli 0.132.0 → 0.133.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.
@@ -19,7 +19,7 @@ import { basename, dirname, join } from "node:path";
19
19
 
20
20
  import { ApiClient } from "../api-client.mjs";
21
21
  import { configHome } from "../config.mjs";
22
- import { fail, sleep, takeAll, takeEnv, takeFlag, takeValue } from "../support.mjs";
22
+ import { fail, sleep, takeAll, takeEnv, takeFlag, takeSide, takeValue } from "../support.mjs";
23
23
  import { IDENTITY_FLAGS_USAGE, takeIdentity, tokenFor } from "../visitor-identity.mjs";
24
24
 
25
25
  export const STATE_FILE = ".vatio-chat.json";
@@ -53,7 +53,7 @@ export async function chat(config, args) {
53
53
  `\`${arg}\` was removed. A CLI chat is you, the developer holding the token, unless you say who: ` +
54
54
  "--as-phone speaks as your verified WhatsApp (me) or a customer phone, --as-subject ID signs a visitor in " +
55
55
  "with your identity key, and --visitor-token brings a token you have; " +
56
- "to pick a deployment use --env."
56
+ "it talks to the newest version, the one your team has."
57
57
  );
58
58
  }
59
59
  }
@@ -114,7 +114,7 @@ export function chatHelp() {
114
114
  return `Usage:
115
115
  vatio chat "message" [--file PATH]... [--new] [--timeout N] [--as-phone me|PHONE] ${IDENTITY_FLAGS_USAGE}
116
116
  vatio chat --chat CHAT_ID "message" [--file PATH]...
117
- vatio chat show [CHAT_ID] [--env NAME] [--last N] [--json]
117
+ vatio chat show [CHAT_ID] [--last N] [--json]
118
118
  ${EXPORT_USAGE}
119
119
 
120
120
  It talks to the newest version, the one your team has: a change you just
@@ -161,7 +161,7 @@ workspace's customer phones (added in the inbox, under Conversations → Try the
161
161
  agent → WhatsApp) is a customer. It stays a CLI chat: nothing goes to WhatsApp.
162
162
 
163
163
  \`export\` prints what people said and what they were answered between two
164
- dates (live unless --env says otherwise), one conversation per line as JSON,
164
+ dates (your customers', or your team's own with --team), one conversation per line as JSON,
165
165
  for reading them in bulk -- with a coding agent, say. Vatio redacts it before
166
166
  it leaves: names, emails, phone numbers and RUTs it knows are [FILTERED], and
167
167
  \`person\` stands for whoever it was without naming them. Anyone on the
@@ -169,12 +169,12 @@ workspace's team can run it, a viewer too, and every call is in the
169
169
  workspace's activity. Dates are whole days; --to defaults to now.`;
170
170
  }
171
171
 
172
- const EXPORT_USAGE = "vatio chat export --from DATE [--to DATE] [--env NAME] [--channel NAME] [--out FILE]";
172
+ const EXPORT_USAGE = "vatio chat export --from DATE [--to DATE] [--team] [--channel NAME] [--out FILE]";
173
173
 
174
174
  // One page at a time, written as it arrives: a month of a busy WhatsApp number
175
175
  // does not have to fit in memory to be read.
176
176
  async function exportChats(config, args) {
177
- const environment = takeEnv(args, { fallback: "live" });
177
+ const environment = takeSide(args, "--team");
178
178
  const from = takeValue(args, "--from");
179
179
  const to = takeValue(args, "--to");
180
180
  const channel = takeValue(args, "--channel");
@@ -69,7 +69,7 @@ export async function tools(config, args) {
69
69
  const environment = takeEnv(args, { fallback: "live" });
70
70
  const period = takeValue(args, "--period");
71
71
  const json = takeFlag(args, "--json");
72
- if (args.length > 0) fail("Usage: vatio tools [--env NAME] [--period 1h|1d|7d|30d] [--json]");
72
+ if (args.length > 0) fail("Usage: vatio tools [--period 1h|1d|7d|30d] [--json]");
73
73
 
74
74
  if (json) {
75
75
  const { url, token } = workspaceBase(config);
@@ -94,8 +94,8 @@ export async function test(config, args) {
94
94
  }
95
95
 
96
96
  const TEST_ADD_USAGE =
97
- 'vatio test add "QUESTION" "WHAT IT SHOULD DO" [--as-phone me|PHONE] [--as-subject ID] [--env NAME]\n' +
98
- ' vatio test add "WHAT IT SHOULD DO" [--chat ID | --message ID] [--env NAME]';
97
+ 'vatio test add "QUESTION" "WHAT IT SHOULD DO" [--as-phone me|PHONE] [--as-subject ID]\n' +
98
+ ' vatio test add "WHAT IT SHOULD DO" [--chat ID | --message ID]';
99
99
 
100
100
  // What the agent should do when asked something, checked on every version.
101
101
  // With a question, Vatio asks it in a new chat and the test is made on that
@@ -1,13 +1,13 @@
1
1
  // Review terminal failures after Vatio has finished its automatic attempts.
2
2
 
3
3
  import { deployClient } from "./deploy.mjs";
4
- import { fail, takeEnv, takeFlag, takeValue } from "../support.mjs";
4
+ import { fail, takeFlag, takeSide, takeValue } from "../support.mjs";
5
5
 
6
- const USAGE = "vatio whatsapp failed [--since DATE] [--until DATE] [--error-code CODE] " +
6
+ const USAGE = "vatio whatsapp failed [--test] [--since DATE] [--until DATE] [--error-code CODE] " +
7
7
  "[--error-contains TEXT] [--before ID] [--json]";
8
8
 
9
9
  export async function messages(config, args) {
10
- const environment = takeEnv(args, { fallback: "live" });
10
+ const environment = takeSide(args, "--test");
11
11
  const json = takeFlag(args, "--json");
12
12
  const since = takeValue(args, "--since");
13
13
  const until = takeValue(args, "--until");
@@ -7,7 +7,7 @@
7
7
  import { readFileSync } from "node:fs";
8
8
 
9
9
  import { deployClient } from "./deploy.mjs";
10
- import { fail, paint, sleep, takeEnv, takeFlag, takeValue } from "../support.mjs";
10
+ import { fail, paint, sleep, takeFlag, takeSide, takeValue } from "../support.mjs";
11
11
 
12
12
  const WAIT_INTERVAL_MS = 2_000;
13
13
 
@@ -18,7 +18,7 @@ function takeAll(args, name) {
18
18
  return values;
19
19
  }
20
20
 
21
- const LIST_USAGE = "vatio whatsapp templates list [--env live] [--json]";
21
+ const LIST_USAGE = "vatio whatsapp templates list [--test-number] [--json]";
22
22
  const CREATE_USAGE = "vatio whatsapp templates create NAME --language CODE --body TEXT [--example VALUE]... " +
23
23
  "[--category utility|marketing] [--footer TEXT] [--button-url 'TEXT|URL']... [--button-example VALUE]... " +
24
24
  "[--button-phone 'TEXT|PHONE'] [--button-quick-reply TEXT]... [--json]\n" +
@@ -42,7 +42,7 @@ export async function templates(config, args) {
42
42
  args.shift();
43
43
  return deleteTemplate(config, args, json);
44
44
  }
45
- const environment = takeEnv(args, { fallback: "live" });
45
+ const environment = takeSide(args, "--test-number");
46
46
  const workspace = config.resolveWorkspaceRequired();
47
47
  const client = deployClient(config, workspace);
48
48
  const sub = args.shift() ?? "list";
@@ -58,7 +58,7 @@ export async function templates(config, args) {
58
58
  if (list.length === 0) {
59
59
  if (live && payload.whatsapp_connected === false) {
60
60
  console.log("This workspace has no WhatsApp number of its own yet. The templates you create stay on Vatio's " +
61
- "test number until you connect one, and then Vatio moves them to it: vatio whatsapp templates list --env preview");
61
+ "test number until you connect one, and then Vatio moves them to it: vatio whatsapp templates list --test-number");
62
62
  } else if (!live && payload.whatsapp_connected === true) {
63
63
  console.log("This workspace has its own WhatsApp number, so its templates are there: vatio whatsapp templates list");
64
64
  } else {
@@ -141,10 +141,10 @@ function printCreated(template, json, count) {
141
141
  `${own ? "your own number" : "Vatio's test number"}: ${template.category}, ` +
142
142
  `${count} param${count === 1 ? "" : "s"}, ${paint("cyan", template.status)}.`);
143
143
  console.log("Meta usually decides within minutes, at most 24 hours. Check with: vatio whatsapp templates list" +
144
- (own ? "" : " --env preview"));
144
+ (own ? "" : " --test-number"));
145
145
  console.log(own
146
146
  ? "Once APPROVED, your backend sends it with a live key outside the 24-hour window with:"
147
- : "Once APPROVED, a preview key sends it on Vatio's test number, to your team's verified WhatsApps and your " +
147
+ : "Once APPROVED, a test secret key sends it on Vatio's test number, to your team's verified WhatsApps and your " +
148
148
  "customer phones, outside the 24-hour window with:");
149
149
  console.log(` "template": ${JSON.stringify(template.example)}`);
150
150
  if (!own) {
@@ -201,7 +201,7 @@ async function deleteTemplate(config, args, json) {
201
201
  }
202
202
 
203
203
  export async function webhooks(config, args) {
204
- const environment = takeEnv(args, { fallback: "live" });
204
+ const environment = takeSide(args, "--test");
205
205
  const label = takeValue(args, "--label");
206
206
  const events = takeAll(args, "--event");
207
207
  const workspace = config.resolveWorkspaceRequired();
@@ -213,13 +213,13 @@ export async function webhooks(config, args) {
213
213
  const list = Array.isArray(payload.webhook_endpoints) ? payload.webhook_endpoints : [];
214
214
  if (list.length === 0) {
215
215
  console.log(`No webhook endpoints on workspace ${workspace}`);
216
- console.log(" Add one: vatio webhooks create https://your-app.com/vatio/webhooks --env live");
216
+ console.log(" Add one: vatio webhooks create https://your-app.com/vatio/webhooks");
217
217
  return;
218
218
  }
219
219
  console.log(`Webhook endpoints on workspace ${workspace} (${list.length}):`);
220
220
  for (const endpoint of list) {
221
221
  const state = endpoint.enabled ? paint("green", "enabled") : paint("red", "disabled");
222
- console.log(` #${endpoint.id} ${endpoint.environment} ${endpoint.url} ${state}`);
222
+ console.log(` #${endpoint.id} ${endpoint.environment === "preview" ? "test" : endpoint.environment} ${endpoint.url} ${state}`);
223
223
  console.log(` events: ${endpoint.events.length > 0 ? endpoint.events.join(", ") : "all"}` +
224
224
  (endpoint.consecutive_failures > 0 ? ` failing: ${endpoint.consecutive_failures} in a row` : ""));
225
225
  }
@@ -227,9 +227,9 @@ export async function webhooks(config, args) {
227
227
  }
228
228
  if (sub === "create") {
229
229
  const url = args.shift();
230
- if (!url) fail("Usage: vatio webhooks create URL [--event NAME]... [--label NAME] [--env NAME]");
230
+ if (!url) fail("Usage: vatio webhooks create URL [--event NAME]... [--label NAME] [--test]");
231
231
  const payload = await client.createWebhookEndpoint({ environment, url, events, label });
232
- console.log(`Created webhook endpoint #${payload.id} for ${environment}: ${payload.url}`);
232
+ console.log(`Created ${environment === "preview" ? "a test" : "a live"} webhook endpoint #${payload.id}: ${payload.url}`);
233
233
  console.log(` events: ${payload.events.length > 0 ? payload.events.join(", ") : "all"}`);
234
234
  console.log("");
235
235
  // Vatio signs every delivery with it; it is not shown again.
@@ -284,7 +284,7 @@ export async function webhooks(config, args) {
284
284
  return;
285
285
  }
286
286
 
287
- fail("Usage: vatio webhooks list|create URL [--event NAME]...|test ID|deliveries ID|enable ID|rm ID [--env NAME]");
287
+ fail("Usage: vatio webhooks list|create URL [--event NAME]...|test ID|deliveries ID|enable ID|rm ID [--test]");
288
288
  }
289
289
 
290
290
  function printDelivery(delivery) {
@@ -99,7 +99,7 @@ async function listSecrets(client, workspace, environment) {
99
99
 
100
100
  function secretScope({ environment, tests }) {
101
101
  if (tests) return "tests";
102
- return environment ? `only ${environment}` : "every environment";
102
+ return environment ? `only the ${environment === "preview" ? "team's" : "customers'"} version, from before` : "everywhere";
103
103
  }
104
104
 
105
105
  function takeRepeated(args, flag) {
@@ -115,7 +115,7 @@ const KINDS = ["publishable", "secret"];
115
115
  // this list is only for the help text. `team` is never given by default.
116
116
  const SCOPES = ["messages", "instagram", "chats", "team"];
117
117
  const KEYS_USAGE =
118
- "Usage: vatio keys list [--json]|create publishable|secret [--env live|preview] [--label NAME] " +
118
+ "Usage: vatio keys list [--json]|create publishable|secret [--test] [--label NAME] " +
119
119
  "[--scope NAME]... [--code CODE | --recovery-code CODE] [--json]|revoke PREFIX";
120
120
 
121
121
  // A publishable key used to take a list of the sites it worked from. It works
@@ -132,7 +132,8 @@ const NO_ORIGINS = "A publishable key works from any site, so there are no origi
132
132
  // it. A secret key carries scopes; without --scope it gets every one but
133
133
  // `team`.
134
134
  export async function keys(config, args) {
135
- const environment = environmentOption(args, "live");
135
+ const test = takeFlag(args, "--test");
136
+ const environment = environmentOption(args, test ? "preview" : "live");
136
137
  const label = takeValue(args, "--label") ?? takeValue(args, "-l");
137
138
  if (takeRepeated(args, "--origin").length > 0) fail(`--origin was removed. ${NO_ORIGINS}`);
138
139
  const scopes = takeRepeated(args, "--scope");
@@ -152,13 +153,13 @@ export async function keys(config, args) {
152
153
  }
153
154
  if (list.length === 0) {
154
155
  console.log(`No API keys on workspace ${workspace}`);
155
- console.log(" Create one: vatio keys create publishable --env live --label website");
156
- console.log(" vatio keys create secret --env live --label backend");
156
+ console.log(" Create one: vatio keys create publishable --label website");
157
+ console.log(" vatio keys create secret --label backend (--test for one that reaches only your team)");
157
158
  return;
158
159
  }
159
160
  console.log(`API keys on workspace ${workspace} (${list.length}):`);
160
161
  for (const key of list) {
161
- const parts = [key.kind, key.prefix, key.environment];
162
+ const parts = [key.kind, key.prefix, key.environment === "preview" ? "test" : key.environment];
162
163
  if (key.label) parts.push(key.label);
163
164
  if (key.managed) parts.push(`managed${key.managed_kind ? ` (${key.managed_kind})` : ""}`);
164
165
  parts.push(key.last_used_at ? `last used ${key.last_used_at}` : "never used");
@@ -174,7 +175,7 @@ export async function keys(config, args) {
174
175
  if (sub === "create") {
175
176
  const kind = args.shift();
176
177
  if (!KINDS.includes(kind)) {
177
- fail("Say which kind: vatio keys create publishable|secret [--env NAME] [--label NAME] [--scope NAME]...");
178
+ fail("Say which kind: vatio keys create publishable|secret [--test] [--label NAME] [--scope NAME]...");
178
179
  }
179
180
  if (kind === "publishable" && scopes.length > 0) {
180
181
  fail(`--scope only applies to a secret key (${SCOPES.join(", ")}).`);
@@ -193,7 +194,7 @@ export async function keys(config, args) {
193
194
  console.log(JSON.stringify({ ...payload, workspace }, null, 2));
194
195
  return;
195
196
  }
196
- console.log(`Created a ${kind} key for ${environment} on workspace ${workspace}`);
197
+ console.log(`Created a ${environment === "preview" ? "test " : ""}${kind} key on workspace ${workspace}`);
197
198
  if (kind === "publishable") console.log(" works from any site");
198
199
  if (kind === "secret") console.log(` scopes: ${asArray(payload.api_key?.scopes).join(", ")}`);
199
200
  console.log("");
package/lib/help.mjs CHANGED
@@ -91,18 +91,20 @@ it made obsolete, moves it on. \`vatio rollback\` undoes the last change.
91
91
  The chat you are in, or any chat in the workspace
92
92
  (web, WhatsApp, ...): messages, tool calls, channel,
93
93
  and what was read of each file (truncated, unreadable)
94
- chat export --from DATE [--to DATE] [--env NAME] [--channel NAME] [--out FILE]
94
+ chat export --from DATE [--to DATE] [--team] [--channel NAME] [--out FILE]
95
95
  What people said and were answered between two
96
96
  dates, redacted by Vatio, one conversation per
97
- line as JSON. Default: live. Any team member,
97
+ line as JSON: your customers', or your team's own
98
+ with --team. Any team member,
98
99
  viewers included; every call is in the activity
99
100
 
100
101
  Test and improve it: what it should do, what supervisors reported, and how
101
102
  its tools answered (test add, test list, fix, push, test):
102
- tools [--env NAME] [--period 1h|1d|7d|30d] [--json]
103
+ tools [--period 1h|1d|7d|30d] [--json]
103
104
  Each tool's calls, error rate, timeouts and
104
105
  p50/p95, then the calls that failed with what
105
- your backend answered. Default: live, 7d
106
+ your backend answered, in your customers'
107
+ conversations. Default: 7d
106
108
  test [--agent SLUG] [--as-subject ID | --visitor-token JWT]
107
109
  Test every report and test against your team's
108
110
  version: starts the runs on Vatio's servers,
@@ -176,6 +178,9 @@ it made obsolete, moves it on. \`vatio rollback\` undoes the last change.
176
178
  backend, with its scopes)
177
179
  keys create publishable|secret [--label NAME] [--json]
178
180
  A publishable key works from any site
181
+ keys create secret --test A secret key that reaches only your team and the
182
+ customer phones you added, through Vatio's test
183
+ number: for your backend's development and staging
179
184
  keys create secret --scope NAME... [--code CODE | --recovery-code CODE]
180
185
  What the secret key may call: messages, instagram,
181
186
  chats, team (repeatable). Without --scope, all but
@@ -185,7 +190,7 @@ it made obsolete, moves it on. \`vatio rollback\` undoes the last change.
185
190
  auth --new-key Keypair that signs the JWT saying who a visitor is
186
191
 
187
192
  Sending from your backend (with a server key):
188
- webhooks list|create URL [--event NAME]...|test ID|deliveries ID|enable ID|rm ID
193
+ webhooks list|create URL [--event NAME]... [--test]|test ID|deliveries ID|enable ID|rm ID
189
194
  Where Vatio tells your backend what happened
190
195
 
191
196
  Contacts (privacy requests on one person; the ID is the contact's number in the inbox):
@@ -213,8 +218,9 @@ it made obsolete, moves it on. \`vatio rollback\` undoes the last change.
213
218
  whatsapp team The team and each person's own WhatsApp: the
214
219
  phone the agent knows them by, and that reaches
215
220
  it on Vatio's number
216
- whatsapp templates [list] [--env live]
217
- The number's templates and the "template" to send
221
+ whatsapp templates [list] [--test-number]
222
+ The number's templates and the "template" to send;
223
+ --test-number lists those on Vatio's test number
218
224
  whatsapp templates create NAME --language CODE --body TEXT [--example VALUE]...
219
225
  [--category utility|marketing] [--footer TEXT]
220
226
  [--button-url 'TEXT|URL']... [--button-example VALUE]...
@@ -226,10 +232,11 @@ it made obsolete, moves it on. \`vatio rollback\` undoes the last change.
226
232
  on Vatio's test number until you connect one
227
233
  whatsapp templates rm NAME [--language CODE] | sync
228
234
  Delete one at Meta; pull back ones made elsewhere
229
- whatsapp failed [--since DATE] [--until DATE] [--error-code CODE]
235
+ whatsapp failed [--test] [--since DATE] [--until DATE] [--error-code CODE]
230
236
  [--error-contains TEXT] [--before ID]
231
237
  Messages Vatio gave up retrying, with your
232
- external_ref (default: live)
238
+ external_ref; --test for what your test secret
239
+ key sent
233
240
 
234
241
  Channels:
235
242
  instagram The same, for Instagram
package/lib/support.mjs CHANGED
@@ -47,6 +47,15 @@ export function takeEnv(args, { fallback = null } = {}) {
47
47
  return environment !== undefined ? environment : fallback;
48
48
  }
49
49
 
50
+ // The side a command reads or acts on, said plainly: `flag` (--team, --test,
51
+ // --test-number) names the team's or the test side, which the platform still
52
+ // calls preview. `--env NAME` from before still works.
53
+ export function takeSide(args, flag, { fallback = "live" } = {}) {
54
+ const environment = takeEnv(args, { fallback: null });
55
+ const flagged = takeFlag(args, flag);
56
+ return environment ?? (flagged ? "preview" : fallback);
57
+ }
58
+
50
59
  export function takeFlag(args, name) {
51
60
  const index = args.indexOf(name);
52
61
  if (index === -1) return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vatio-ai/cli",
3
- "version": "0.132.0",
3
+ "version": "0.133.0",
4
4
  "description": "Vatio CLI — deploy and manage Vatio agent workspaces",
5
5
  "keywords": [
6
6
  "vatio",