@vatio-ai/cli 0.76.0 → 0.78.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.
@@ -15,6 +15,16 @@ export class ApiClient extends HttpClient {
15
15
  return this.get("/status");
16
16
  }
17
17
 
18
+ // --- whatsapp -------------------------------------------------------
19
+
20
+ getWhatsapp() {
21
+ return this.get("/whatsapp");
22
+ }
23
+
24
+ updateWhatsapp(body) {
25
+ return this.patch("/whatsapp", body);
26
+ }
27
+
18
28
  deployedManifest({ environment = "live" } = {}) {
19
29
  return this.get("/manifest", { environment });
20
30
  }
@@ -3,11 +3,33 @@
3
3
  // accounts are a form with a code. The CLI only says where, and that depends
4
4
  // on whether the workspace has published: before, only the Test page is in the
5
5
  // console's sidebar; after, the channel's own page under Integrations.
6
+ //
7
+ // One thing about your own WhatsApp number is set here too: who the agent
8
+ // answers on it (`vatio whatsapp only` / `everyone`). Everyone else's messages
9
+ // still reach the inbox.
6
10
 
7
11
  import { deployClient } from "./deploy.mjs";
12
+ import { fail, paint } from "../support.mjs";
13
+
14
+ const WHATSAPP_USAGE = "Usage: vatio whatsapp [only NUMBER [NUMBER]... | everyone]";
15
+
16
+ export async function whatsapp(config, args = []) {
17
+ const sub = args.shift();
18
+ if (sub === undefined) {
19
+ await inConsole(config, { name: "WhatsApp", key: "whatsapp", own: "number", test: "phone" });
20
+ return printAgentNumbers(config);
21
+ }
22
+ if (sub === "only") {
23
+ if (args.length === 0) fail(WHATSAPP_USAGE);
24
+ return setAgentNumbers(config, args.splice(0));
25
+ }
26
+ if (sub === "everyone") {
27
+ if (args.length > 0) fail(WHATSAPP_USAGE);
28
+ return setAgentNumbers(config, []);
29
+ }
30
+ fail(WHATSAPP_USAGE);
31
+ }
8
32
 
9
- export const whatsapp = (config) =>
10
- inConsole(config, { name: "WhatsApp", key: "whatsapp", own: "number", test: "phone" });
11
33
  export const instagram = (config) =>
12
34
  inConsole(config, { name: "Instagram", key: "instagram", own: "account", test: "account" });
13
35
 
@@ -24,3 +46,33 @@ async function inConsole(config, channel) {
24
46
  }
25
47
  console.log(` ${url}`);
26
48
  }
49
+
50
+ async function setAgentNumbers(config, numbers) {
51
+ const client = deployClient(config, config.resolveWorkspaceRequired());
52
+ printAnswers(await client.updateWhatsapp({ agent_numbers: numbers }));
53
+ }
54
+
55
+ // After the console link: a workspace with no number of its own has nothing
56
+ // more to show, and the link already says what to do.
57
+ async function printAgentNumbers(config) {
58
+ const client = deployClient(config, config.resolveWorkspaceRequired());
59
+ try {
60
+ printAnswers(await client.getWhatsapp());
61
+ } catch (error) {
62
+ if (error?.body?.error?.code === "whatsapp_not_connected") return;
63
+ throw error;
64
+ }
65
+ }
66
+
67
+ function printAnswers(number) {
68
+ const list = Array.isArray(number.agent_numbers) ? number.agent_numbers : [];
69
+ const live = number.live ? paint("green", "live") : paint("cyan", "paused: Live is off in the console");
70
+ console.log(`\n${number.display_phone_number ?? "Your number"}: ${live}`);
71
+ if (list.length === 0) {
72
+ console.log(" The agent answers everyone. To answer only some numbers: vatio whatsapp only +56912345678");
73
+ return;
74
+ }
75
+ console.log(` The agent answers only: ${list.join(", ")}`);
76
+ console.log(" Everyone else's messages reach the inbox unanswered; your routines' numbers always count.");
77
+ console.log(" Back to everyone: vatio whatsapp everyone");
78
+ }
@@ -1,17 +1,17 @@
1
- // `vatio routines` — Claude Code routines that a WhatsApp number starts. When
2
- // one of a routine's numbers writes to the workspace, Vatio waits for them to
3
- // finish and calls the routine's API trigger with where the conversation is;
4
- // Claude reads it with a server key (GET /api/server/v1/:ws/chats/:id/messages).
1
+ // `vatio routines` — Claude Code routines the agent can hand work to. A routine
2
+ // is the trigger and token of one on claude.ai, and the WhatsApp numbers whose
3
+ // conversations may use it; the agent gets it as a tool in the manifest
4
+ // (tools/<key>.yml with `routine: <name>`). Calling it starts the routine with
5
+ // where the conversation is, and Claude reads it with a server key
6
+ // (GET /api/server/v1/:ws/chats/:id/messages).
5
7
 
6
8
  import { deployClient } from "./deploy.mjs";
7
9
  import { askSecret, fail, paint, sleep, takeEnv, takeFlag, takeValue } from "../support.mjs";
8
10
 
9
11
  const WAIT_INTERVAL_MS = 2_000;
10
12
 
11
- const CREATE_USAGE = "vatio routines create NAME --url URL --phone NUMBER [--phone NUMBER]... " +
12
- "[--quiet SECONDS] [--env NAME]";
13
- const UPDATE_USAGE = "vatio routines update ID [--name NAME] [--url URL] [--phone NUMBER]... [--new-token] " +
14
- "[--quiet SECONDS]";
13
+ const CREATE_USAGE = "vatio routines create NAME --url URL --phone NUMBER [--phone NUMBER]... [--env NAME]";
14
+ const UPDATE_USAGE = "vatio routines update ID [--name NAME] [--url URL] [--phone NUMBER]... [--new-token]";
15
15
  const USAGE = `Usage: vatio routines list|create NAME …|update ID …|test ID|runs ID|enable ID|rm ID\n` +
16
16
  ` ${CREATE_USAGE}\n ${UPDATE_USAGE}`;
17
17
 
@@ -22,14 +22,6 @@ function takeAll(args, name) {
22
22
  return values;
23
23
  }
24
24
 
25
- function takeQuiet(args) {
26
- const raw = takeValue(args, "--quiet");
27
- if (raw === null) return null;
28
- const seconds = Number(raw);
29
- if (!Number.isInteger(seconds)) fail("--quiet is a whole number of seconds, between 5 and 600");
30
- return seconds;
31
- }
32
-
33
25
  export async function routines(config, args) {
34
26
  const json = takeFlag(args, "--json");
35
27
  const workspace = config.resolveWorkspaceRequired();
@@ -54,7 +46,6 @@ export async function routines(config, args) {
54
46
  const environment = takeEnv(args, { fallback: "live" });
55
47
  const url = takeValue(args, "--url");
56
48
  const phoneNumbers = takeAll(args, "--phone");
57
- const quiet = takeQuiet(args);
58
49
  const name = args.shift();
59
50
  if (!name || !url || phoneNumbers.length === 0 || args.length > 0) fail(`Usage: ${CREATE_USAGE}`);
60
51
 
@@ -64,7 +55,6 @@ export async function routines(config, args) {
64
55
  if (token === "") fail("No token given. claude.ai shows it once, when you generate it on the routine's API trigger.");
65
56
 
66
57
  const body = { environment, name, url, token, phone_numbers: phoneNumbers };
67
- if (quiet !== null) body.quiet_seconds = quiet;
68
58
  const routine = await client.createRoutine(body);
69
59
  if (json) return console.log(JSON.stringify(routine, null, 2));
70
60
  console.log(`${paint("green", "✓")} Created routine #${routine.id} (${routine.name}) on ${routine.environment}`);
@@ -72,7 +62,9 @@ export async function routines(config, args) {
72
62
  console.log("");
73
63
  console.log("Give the routine a server key so it can read the conversation: vatio keys create --env " +
74
64
  `${routine.environment} --label ${routine.name}`);
75
- console.log(`Then check it starts: vatio routines test ${routine.id}`);
65
+ console.log(`Check it starts: vatio routines test ${routine.id}`);
66
+ console.log(`Then give it to the agent: tools/${routine.name}.yml with \`routine: ${routine.name}\`, ` +
67
+ `${routine.name} in agent.tools, and vatio push`);
76
68
  return;
77
69
  }
78
70
 
@@ -81,7 +73,6 @@ export async function routines(config, args) {
81
73
  const url = takeValue(args, "--url");
82
74
  const phoneNumbers = takeAll(args, "--phone");
83
75
  const newToken = takeFlag(args, "--new-token");
84
- const quiet = takeQuiet(args);
85
76
  const id = args.shift();
86
77
  if (!id || args.length > 0) fail(`Usage: ${UPDATE_USAGE}`);
87
78
 
@@ -89,7 +80,6 @@ export async function routines(config, args) {
89
80
  if (name !== null) body.name = name;
90
81
  if (url !== null) body.url = url;
91
82
  if (phoneNumbers.length > 0) body.phone_numbers = phoneNumbers;
92
- if (quiet !== null) body.quiet_seconds = quiet;
93
83
  if (newToken) {
94
84
  body.token = await askSecret(`${paint("green", "?")} Paste the new API token: `);
95
85
  if (body.token === "") fail("No token given");
@@ -159,8 +149,7 @@ export async function routines(config, args) {
159
149
  function printRoutine(routine) {
160
150
  const state = routine.enabled ? paint("green", "enabled") : paint("red", "disabled");
161
151
  console.log(` #${routine.id} ${routine.name} ${routine.environment} ${state}`);
162
- console.log(` numbers: ${routine.phone_numbers.join(", ")}`);
163
- console.log(` waits ${routine.quiet_seconds}s after the last message, then fires and the agent answers` +
152
+ console.log(` the agent can use it with: ${routine.phone_numbers.join(", ")}` +
164
153
  (routine.consecutive_failures > 0 ? ` failing: ${routine.consecutive_failures} in a row` : ""));
165
154
  }
166
155
 
package/lib/help.mjs CHANGED
@@ -129,12 +129,16 @@ Commands default as listed.
129
129
 
130
130
  Claude Code routines (WhatsApp):
131
131
  routines list|create NAME --url URL --phone NUMBER...|update ID|test ID|runs ID|enable ID|rm ID
132
- A routine on claude.ai that a message from these
133
- numbers starts; it reads the chat with a server key
132
+ A routine on claude.ai the agent hands work to, as a
133
+ tool (tools/NAME.yml with routine: NAME), in
134
+ conversations with these numbers
134
135
 
135
136
  Channels:
136
137
  whatsapp Set up in the console; prints the link (Test page
137
138
  until you publish, then Integrations)
139
+ whatsapp only NUMBER...|everyone
140
+ Who the agent answers on your own number; the
141
+ rest still reach the inbox
138
142
  instagram The same, for Instagram
139
143
 
140
144
  Everything else:
package/lib/telemetry.mjs CHANGED
@@ -35,6 +35,7 @@ const SUBCOMMANDS = {
35
35
  templates: ["list", "create"],
36
36
  webhooks: ["list", "create", "test", "deliveries", "enable", "rm"],
37
37
  routines: ["list", "create", "update", "test", "runs", "enable", "rm"],
38
+ whatsapp: ["only", "everyone"],
38
39
  config: ["show", "get", "set", "unset"],
39
40
  "share-session": ["--should-ask", "--never"]
40
41
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vatio-ai/cli",
3
- "version": "0.76.0",
3
+ "version": "0.78.0",
4
4
  "description": "Vatio CLI — deploy and manage Vatio agent workspaces",
5
5
  "keywords": [
6
6
  "vatio",