@vatio-ai/cli 0.139.0 → 0.140.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/lib/commands/team.mjs +31 -8
- package/lib/help.mjs +5 -2
- package/package.json +1 -1
package/lib/commands/team.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// team — who is in the workspace, and as what: what the inbox's Team page does,
|
|
2
2
|
// for a coding agent that is asked to "add Ana as a supervisor". The owner's
|
|
3
|
-
// alone, like the page. A person is named by their email
|
|
4
|
-
//
|
|
3
|
+
// alone, like the page. A person is named by their email, or by their number
|
|
4
|
+
// when they are on the team by their WhatsApp alone; the platform keys them by
|
|
5
|
+
// membership, which the list gives.
|
|
5
6
|
|
|
6
7
|
import { deployClient } from "./deploy.mjs";
|
|
7
8
|
import { errorCode } from "../http.mjs";
|
|
@@ -21,8 +22,10 @@ function explain(error) {
|
|
|
21
22
|
const ROLES = ["supervisor", "business", "developer"];
|
|
22
23
|
const USAGE = `Usage: vatio team [list] [--json]\n` +
|
|
23
24
|
` vatio team invite EMAIL --role ${ROLES.join("|")} [--code CODE | --recovery-code CODE] [--json]\n` +
|
|
24
|
-
|
|
25
|
-
"
|
|
25
|
+
" vatio team invite --whatsapp +56912345678 --name NAME [--code CODE | --recovery-code CODE] [--json]\n" +
|
|
26
|
+
" a supervisor by their WhatsApp alone: the agent knows them by that number; no email, no inbox\n" +
|
|
27
|
+
` vatio team role EMAIL|PHONE ${ROLES.join("|")} [--code CODE | --recovery-code CODE] [--json]\n` +
|
|
28
|
+
" vatio team rm EMAIL|PHONE [--json]\n" +
|
|
26
29
|
" vatio team resend EMAIL [--json]\n" +
|
|
27
30
|
" With a second factor on your account, --code is the 6-digit code from your authenticator app.\n" +
|
|
28
31
|
" vatio team questions [--to EMAIL...|--none] [--template NAME [--language CODE]|--no-template] [--json]";
|
|
@@ -44,6 +47,18 @@ export async function team(config, args) {
|
|
|
44
47
|
const role = takeValue(args, "--role");
|
|
45
48
|
const code = takeValue(args, "--code");
|
|
46
49
|
const recoveryCode = takeValue(args, "--recovery-code");
|
|
50
|
+
const whatsapp = takeValue(args, "--whatsapp");
|
|
51
|
+
const name = takeValue(args, "--name");
|
|
52
|
+
if (whatsapp) {
|
|
53
|
+
if (!name || role || args.length > 0) fail(`--whatsapp takes --name, and no email or --role: always a supervisor.\n\n${USAGE}`);
|
|
54
|
+
const answer = await invite(client, { whatsapp, name, code, recovery_code: recoveryCode }).catch(explain);
|
|
55
|
+
if (!json) {
|
|
56
|
+
console.log(`${paint("green", "✓")} ${name} is on the team by WhatsApp (${whatsapp}). Nothing was sent to them: ` +
|
|
57
|
+
"the agent knows them from their first message from that number.");
|
|
58
|
+
console.log("");
|
|
59
|
+
}
|
|
60
|
+
return print(answer, workspace, json);
|
|
61
|
+
}
|
|
47
62
|
const email = args.shift();
|
|
48
63
|
if (!email || args.length > 0) fail(USAGE);
|
|
49
64
|
// The platform would make an unknown role a supervisor; here it is asked for.
|
|
@@ -73,8 +88,9 @@ export async function team(config, args) {
|
|
|
73
88
|
answer = await client.removeMember(member.id).catch(explain);
|
|
74
89
|
}
|
|
75
90
|
if (!json) {
|
|
76
|
-
const
|
|
77
|
-
|
|
91
|
+
const who = label(member);
|
|
92
|
+
const done = { role: `${who} is now ${role}`, resend: `Sent ${who} the invitation again`,
|
|
93
|
+
rm: `Removed ${who}: they no longer reach this workspace`, remove: `Removed ${who}` }[sub];
|
|
78
94
|
console.log(`${paint("green", "✓")} ${done}.`);
|
|
79
95
|
console.log("");
|
|
80
96
|
}
|
|
@@ -84,21 +100,28 @@ export async function team(config, args) {
|
|
|
84
100
|
fail(USAGE);
|
|
85
101
|
}
|
|
86
102
|
|
|
103
|
+
// By email, or by number for someone on WhatsApp alone (they have no email).
|
|
87
104
|
async function memberByEmail(client, email) {
|
|
88
105
|
const wanted = email.trim().toLowerCase();
|
|
106
|
+
const digits = wanted.replace(/\D/g, "");
|
|
89
107
|
const list = await client.members().catch(explain);
|
|
90
|
-
const member = (list.data ?? []).find((row) =>
|
|
108
|
+
const member = (list.data ?? []).find((row) =>
|
|
109
|
+
(row.email && String(row.email).toLowerCase() === wanted) ||
|
|
110
|
+
(row.phone_number && digits.length >= 8 && String(row.phone_number).replace(/\D/g, "") === digits));
|
|
91
111
|
if (!member) fail(`${wanted} is not on this workspace's team (vatio team list).`);
|
|
92
112
|
return member;
|
|
93
113
|
}
|
|
94
114
|
|
|
115
|
+
const label = (member) => member.email ?? `${member.name ?? "someone"} (WhatsApp ${member.phone_number})`;
|
|
116
|
+
|
|
95
117
|
function print(answer, workspace, json) {
|
|
96
118
|
if (json) return console.log(JSON.stringify(answer, null, 2));
|
|
97
119
|
const members = answer.data ?? [];
|
|
98
120
|
console.log(`Team on workspace ${workspace}:`);
|
|
99
121
|
if (answer.owner) console.log(` owner ${answer.owner.email}`);
|
|
100
122
|
for (const member of members) {
|
|
101
|
-
|
|
123
|
+
const note = member.whatsapp_only ? " (WhatsApp only, no inbox)" : member.pending ? " (has not signed in yet)" : "";
|
|
124
|
+
console.log(` ${member.role.padEnd(11)} ${label(member)}${note}`);
|
|
102
125
|
}
|
|
103
126
|
if (members.length === 0) console.log(" No one else. Invite someone: vatio team invite EMAIL --role supervisor");
|
|
104
127
|
}
|
package/lib/help.mjs
CHANGED
|
@@ -175,9 +175,12 @@ it made obsolete, moves it on. \`vatio rollback\` undoes the last change.
|
|
|
175
175
|
team invite EMAIL --role supervisor|business|developer [--code CODE]
|
|
176
176
|
Invite them and email them. Needs a second factor on your
|
|
177
177
|
account: --code is your authenticator app's code
|
|
178
|
-
team
|
|
178
|
+
team invite --whatsapp PHONE --name NAME [--code CODE]
|
|
179
|
+
A supervisor by their WhatsApp alone: no email, no
|
|
180
|
+
inbox; the agent knows them by that number
|
|
181
|
+
team role EMAIL|PHONE supervisor|business|developer [--code CODE]
|
|
179
182
|
Change what they reach; the same second factor
|
|
180
|
-
team rm EMAIL
|
|
183
|
+
team rm EMAIL|PHONE Take their access away
|
|
181
184
|
team resend EMAIL Email the invitation again
|
|
182
185
|
team questions [--to EMAIL...|--none] [--template NAME [--language CODE]|--no-template]
|
|
183
186
|
Who the agent asks when it cannot answer a customer
|