@vatio-ai/cli 0.56.0 → 0.57.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/bin/vatio.mjs CHANGED
@@ -16,6 +16,7 @@ import { secrets, tokens } from "../lib/commands/workspace-admin.mjs";
16
16
  import { auth } from "../lib/commands/identity-key.mjs";
17
17
  import { chat } from "../lib/commands/chat.mjs";
18
18
  import { kb } from "../lib/commands/knowledge.mjs";
19
+ import { business } from "../lib/commands/business.mjs";
19
20
  import { instagram, whatsapp } from "../lib/commands/channels.mjs";
20
21
  import { docs } from "../lib/commands/support-commands.mjs";
21
22
  import { evalCommand, flags } from "../lib/commands/improve.mjs";
@@ -84,6 +85,8 @@ async function run(command, args) {
84
85
  return await chat(config, args);
85
86
  case "kb":
86
87
  return await kb(config, args);
88
+ case "business":
89
+ return await business(config, args);
87
90
  case "secrets":
88
91
  return await secrets(config, args);
89
92
  case "whatsapp":
@@ -158,6 +158,19 @@ export class ApiClient extends HttpClient {
158
158
  return this.delete(`/publishable_tokens/${encode(prefix)}`);
159
159
  }
160
160
 
161
+ // --- business -------------------------------------------------------
162
+
163
+ // Name, description and opening hours: one row for every environment,
164
+ // the same one the inbox's Business page edits.
165
+ business() {
166
+ return this.get("/business");
167
+ }
168
+
169
+ // Only the keys given change. `hours: null` clears the schedule.
170
+ updateBusiness(fields) {
171
+ return this.patch("/business", fields);
172
+ }
173
+
161
174
  // --- chats ----------------------------------------------------------
162
175
 
163
176
  createChat({ environment }) {
@@ -0,0 +1,128 @@
1
+ // business — the business the agent works for: name, description and opening
2
+ // hours. Not part of vatio.yml: it belongs to whoever runs the business and is
3
+ // usually edited on the inbox's Business page. This is the same row, for a
4
+ // developer setting a workspace up from a terminal. One value for every
5
+ // environment, live on save.
6
+
7
+ import { readFileSync } from "node:fs";
8
+ import { deployClient } from "./deploy.mjs";
9
+ import { fail, paint, takeFlag, takeValue } from "../support.mjs";
10
+
11
+ const DAYS = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"];
12
+ const DAY_LABELS = { mon: "Mon", tue: "Tue", wed: "Wed", thu: "Thu", fri: "Fri", sat: "Sat", sun: "Sun" };
13
+ const RANGE = /^\d{2}:\d{2}-\d{2}:\d{2}$/;
14
+
15
+ const USAGE =
16
+ "Usage: vatio business [show]\n" +
17
+ " vatio business set [--name NAME] [--description TEXT | --description-file FILE]\n" +
18
+ " vatio business hours [--timezone ZONE] [--mon 09:00-18:00] [--tue 09:00-13:00,14:00-18:00] ...\n" +
19
+ " vatio business hours --clear";
20
+
21
+ export async function business(config, args) {
22
+ const workspace = config.resolveWorkspaceRequired();
23
+ const client = deployClient(config, workspace);
24
+ const sub = args.shift() ?? "show";
25
+
26
+ if (sub === "show") {
27
+ print(await client.business(), workspace);
28
+ return;
29
+ }
30
+ if (sub === "set") {
31
+ const fields = {};
32
+ const name = takeValue(args, "--name");
33
+ const description = takeValue(args, "--description");
34
+ const file = takeValue(args, "--description-file");
35
+ if (description !== null && file !== null) fail("Give --description or --description-file, not both");
36
+ if (name !== null) fields.name = name;
37
+ if (description !== null) fields.summary = description;
38
+ if (file !== null) fields.summary = readFileSync(file === "-" ? 0 : file, "utf8");
39
+ rejectLeftovers(args);
40
+ if (Object.keys(fields).length === 0) fail(USAGE);
41
+
42
+ print(await client.updateBusiness(fields), workspace);
43
+ return;
44
+ }
45
+ if (sub === "hours") {
46
+ if (takeFlag(args, "--clear")) {
47
+ rejectLeftovers(args);
48
+ print(await client.updateBusiness({ hours: null }), workspace);
49
+ return;
50
+ }
51
+
52
+ const timezone = takeValue(args, "--timezone") ?? takeValue(args, "--tz");
53
+ const days = {};
54
+ for (const day of DAYS) {
55
+ const value = takeValue(args, `--${day}`);
56
+ if (value === null) continue;
57
+ const ranges = value.split(",").map((range) => range.trim()).filter(Boolean);
58
+ const bad = ranges.find((range) => !RANGE.test(range));
59
+ if (bad) fail(`--${day}: "${bad}" is not a range like 09:00-18:00`);
60
+ if (ranges.length > 0) days[day] = ranges;
61
+ }
62
+ rejectLeftovers(args);
63
+
64
+ // Nothing to change: show them.
65
+ if (timezone === null && Object.keys(days).length === 0) {
66
+ print(await client.business(), workspace);
67
+ return;
68
+ }
69
+ if (Object.keys(days).length === 0) {
70
+ fail("Give at least one day (--mon 09:00-18:00 ...), or --clear for someone always available");
71
+ }
72
+
73
+ // The week is replaced as a whole -- a day not given is a day nobody is
74
+ // on -- so the timezone is the only thing worth keeping from before.
75
+ const zone = timezone ?? (await client.business()).hours?.timezone ?? localTimezone();
76
+ print(await client.updateBusiness({ hours: { timezone: zone, days } }), workspace);
77
+ return;
78
+ }
79
+
80
+ fail(USAGE);
81
+ }
82
+
83
+ function rejectLeftovers(args) {
84
+ if (args.length > 0) fail(`Unexpected: ${args.join(" ")}\n\n${USAGE}`);
85
+ }
86
+
87
+ function localTimezone() {
88
+ const zone = Intl.DateTimeFormat().resolvedOptions().timeZone;
89
+ if (zone && zone.includes("/")) return zone;
90
+ fail("Give --timezone, like --timezone America/Santiago");
91
+ }
92
+
93
+ function print(payload, workspace) {
94
+ console.log(`${payload.name} (workspace ${workspace})`);
95
+ console.log("");
96
+ console.log(payload.summary ? indent(payload.summary) : " No description yet. Set one: vatio business set --description \"…\"");
97
+ console.log("");
98
+
99
+ if (!payload.hours) {
100
+ console.log("Hours: none set — someone is always available");
101
+ } else {
102
+ const state = payload.open_now ? paint("green", "open now") : "closed now";
103
+ console.log(`Hours (${payload.hours.timezone}) — ${state}`);
104
+ for (const day of DAYS) {
105
+ const ranges = payload.hours.days?.[day] ?? [];
106
+ console.log(` ${DAY_LABELS[day]} ${ranges.length > 0 ? ranges.join(", ") : "closed"}`);
107
+ }
108
+ if (payload.next_opening) console.log(` Opens next ${payload.next_opening}`);
109
+ }
110
+
111
+ console.log("");
112
+ if (!payload.handoff) {
113
+ console.log("Handoff: not declared in vatio.yml — the agent never hands a conversation over");
114
+ return;
115
+ }
116
+ console.log("Hands over to a person when (from vatio.yml):");
117
+ const rules = [...(payload.handoff.when ?? [])];
118
+ if (payload.handoff.after_turns != null) rules.push(`always after ${payload.handoff.after_turns} visitor messages`);
119
+ if (rules.length === 0) rules.push("the agent judges it");
120
+ for (const rule of rules) console.log(` - ${rule}`);
121
+ }
122
+
123
+ function indent(text) {
124
+ return String(text)
125
+ .split("\n")
126
+ .map((line) => ` ${line}`)
127
+ .join("\n");
128
+ }
package/lib/help.mjs CHANGED
@@ -72,6 +72,14 @@ and the one its pull request deploys to. Elsewhere commands default as listed.
72
72
  kb history BASE What reached live, newest first
73
73
  (entry commands take --env; --env live writes live)
74
74
 
75
+ Business (one value for every environment, live on save; also on the inbox's
76
+ Business page):
77
+ business [show] Name, description, opening hours, handoff rules
78
+ business set [--name NAME] [--description TEXT | --description-file FILE]
79
+ business hours --timezone ZONE --mon 09:00-18:00 --tue 09:00-13:00,14:00-18:00 ...
80
+ Replaces the week: a day not given is closed
81
+ business hours --clear No hours: someone is always available
82
+
75
83
  Credentials:
76
84
  secrets list|set KEY [VALUE]|rm KEY [--env NAME]
77
85
  Without VALUE, set asks for it with the input hidden.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vatio-ai/cli",
3
- "version": "0.56.0",
3
+ "version": "0.57.0",
4
4
  "description": "Vatio CLI — deploy and manage Vatio agent workspaces",
5
5
  "keywords": [
6
6
  "vatio",