@vatio-ai/cli 0.73.0 → 0.76.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 +3 -0
- package/lib/api-client.mjs +26 -0
- package/lib/claude-session.mjs +18 -2
- package/lib/commands/chat.mjs +5 -1
- package/lib/commands/routines.mjs +176 -0
- package/lib/commands/support-commands.mjs +31 -4
- package/lib/config.mjs +5 -2
- package/lib/help.mjs +5 -0
- package/lib/telemetry.mjs +1 -0
- package/lib/workspace.mjs +30 -2
- package/package.json +1 -1
package/bin/vatio.mjs
CHANGED
|
@@ -14,6 +14,7 @@ import { diff, publish, push, rollback, status } from "../lib/commands/deploy.mj
|
|
|
14
14
|
import { env } from "../lib/commands/env.mjs";
|
|
15
15
|
import { keys, secrets, tokens } from "../lib/commands/workspace-admin.mjs";
|
|
16
16
|
import { templates, webhooks } from "../lib/commands/webhooks.mjs";
|
|
17
|
+
import { routines } from "../lib/commands/routines.mjs";
|
|
17
18
|
import { auth } from "../lib/commands/identity-key.mjs";
|
|
18
19
|
import { chat } from "../lib/commands/chat.mjs";
|
|
19
20
|
import { kb } from "../lib/commands/knowledge.mjs";
|
|
@@ -89,6 +90,8 @@ async function run(command, args) {
|
|
|
89
90
|
return await templates(config, args);
|
|
90
91
|
case "webhooks":
|
|
91
92
|
return await webhooks(config, args);
|
|
93
|
+
case "routines":
|
|
94
|
+
return await routines(config, args);
|
|
92
95
|
case "auth":
|
|
93
96
|
return await auth(config, args);
|
|
94
97
|
case "chat":
|
package/lib/api-client.mjs
CHANGED
|
@@ -231,6 +231,32 @@ export class ApiClient extends HttpClient {
|
|
|
231
231
|
return this.get(`/webhook_endpoints/${encode(id)}/deliveries`);
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
+
// --- routines -------------------------------------------------------
|
|
235
|
+
|
|
236
|
+
listRoutines() {
|
|
237
|
+
return this.get("/routines");
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
createRoutine(body) {
|
|
241
|
+
return this.post("/routines", body);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
updateRoutine({ id, ...attrs }) {
|
|
245
|
+
return this.patch(`/routines/${encode(id)}`, attrs);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
deleteRoutine({ id }) {
|
|
249
|
+
return this.delete(`/routines/${encode(id)}`);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
testRoutine({ id }) {
|
|
253
|
+
return this.post(`/routines/${encode(id)}/test`);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
listRoutineRuns({ id }) {
|
|
257
|
+
return this.get(`/routines/${encode(id)}/runs`);
|
|
258
|
+
}
|
|
259
|
+
|
|
234
260
|
// --- chats ----------------------------------------------------------
|
|
235
261
|
|
|
236
262
|
createChat({ environment }) {
|
package/lib/claude-session.mjs
CHANGED
|
@@ -48,6 +48,15 @@ const SECRET_PATTERNS = [
|
|
|
48
48
|
]
|
|
49
49
|
];
|
|
50
50
|
|
|
51
|
+
// The people a session is about rather than the one who sends it: customers
|
|
52
|
+
// that came up in a query or a log. The team never needs who they were. A
|
|
53
|
+
// phone counts only in international form; a bare run of digits is as likely
|
|
54
|
+
// an id.
|
|
55
|
+
const PERSONAL_PATTERNS = [
|
|
56
|
+
[/(?<![\w.%+/-])(?!git@|no-?reply@)[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}\b/g, "[EMAIL]"],
|
|
57
|
+
[/(?<![\w+])\+\d(?:[ .-]?\d){7,14}\b/g, "[PHONE]"]
|
|
58
|
+
];
|
|
59
|
+
|
|
51
60
|
export function claudeHome() {
|
|
52
61
|
return process.env.CLAUDE_CONFIG_DIR || join(homedir(), ".claude");
|
|
53
62
|
}
|
|
@@ -120,10 +129,11 @@ export function describe(session) {
|
|
|
120
129
|
}
|
|
121
130
|
|
|
122
131
|
// The session as it is sent: only what was said and done, without images,
|
|
123
|
-
// with anything that looks like a secret
|
|
132
|
+
// with anything that looks like a secret, an email or a phone replaced and the
|
|
133
|
+
// home directory as ~.
|
|
124
134
|
export function clean(session) {
|
|
125
135
|
const lines = [];
|
|
126
|
-
const counts = { messages: 0, images: 0, redactions: 0 };
|
|
136
|
+
const counts = { messages: 0, images: 0, redactions: 0, personal: 0 };
|
|
127
137
|
let startedAt = null;
|
|
128
138
|
let endedAt = null;
|
|
129
139
|
let gitBranch = null;
|
|
@@ -197,6 +207,12 @@ function redact(text, counts) {
|
|
|
197
207
|
return replacement.replace(/\$(\d)/g, (_, index) => match[Number(index)] ?? "");
|
|
198
208
|
});
|
|
199
209
|
}
|
|
210
|
+
for (const [pattern, replacement] of PERSONAL_PATTERNS) {
|
|
211
|
+
result = result.replace(pattern, () => {
|
|
212
|
+
counts.personal += 1;
|
|
213
|
+
return replacement;
|
|
214
|
+
});
|
|
215
|
+
}
|
|
200
216
|
return HOME.length > 1 ? result.replaceAll(HOME, "~") : result;
|
|
201
217
|
}
|
|
202
218
|
|
package/lib/commands/chat.mjs
CHANGED
|
@@ -80,7 +80,11 @@ workspace has never met.`;
|
|
|
80
80
|
function client(config, options) {
|
|
81
81
|
const apiUrl = config.resolveApiUrl({ explicit: options.apiUrl });
|
|
82
82
|
const token = options.token ?? config.resolveToken();
|
|
83
|
-
if (!apiUrl)
|
|
83
|
+
if (!apiUrl) {
|
|
84
|
+
// Says which: no vatio.yml here (and where one is), or one without `workspace:`.
|
|
85
|
+
config.resolveWorkspaceRequired();
|
|
86
|
+
fail("A workspace API url is required (--api-url, or base_url + a vatio.yml with `workspace:`)");
|
|
87
|
+
}
|
|
84
88
|
if (!token) fail("VATIO_TOKEN is required (env or `vatio login`)");
|
|
85
89
|
return new ApiClient({ baseUrl: apiUrl, token });
|
|
86
90
|
}
|
|
@@ -0,0 +1,176 @@
|
|
|
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).
|
|
5
|
+
|
|
6
|
+
import { deployClient } from "./deploy.mjs";
|
|
7
|
+
import { askSecret, fail, paint, sleep, takeEnv, takeFlag, takeValue } from "../support.mjs";
|
|
8
|
+
|
|
9
|
+
const WAIT_INTERVAL_MS = 2_000;
|
|
10
|
+
|
|
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]";
|
|
15
|
+
const USAGE = `Usage: vatio routines list|create NAME …|update ID …|test ID|runs ID|enable ID|rm ID\n` +
|
|
16
|
+
` ${CREATE_USAGE}\n ${UPDATE_USAGE}`;
|
|
17
|
+
|
|
18
|
+
// Repeatable: `--phone +56911111111 --phone +56922222222`.
|
|
19
|
+
function takeAll(args, name) {
|
|
20
|
+
const values = [];
|
|
21
|
+
for (let value = takeValue(args, name); value !== null; value = takeValue(args, name)) values.push(value);
|
|
22
|
+
return values;
|
|
23
|
+
}
|
|
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
|
+
export async function routines(config, args) {
|
|
34
|
+
const json = takeFlag(args, "--json");
|
|
35
|
+
const workspace = config.resolveWorkspaceRequired();
|
|
36
|
+
const client = deployClient(config, workspace);
|
|
37
|
+
const sub = args.shift() ?? "list";
|
|
38
|
+
|
|
39
|
+
if (sub === "list") {
|
|
40
|
+
const { routines: list = [] } = await client.listRoutines();
|
|
41
|
+
if (json) return console.log(JSON.stringify(list, null, 2));
|
|
42
|
+
if (list.length === 0) {
|
|
43
|
+
console.log(`No routines on workspace ${workspace}`);
|
|
44
|
+
console.log(" Add one: vatio routines create encargos --url https://api.anthropic.com/v1/claude_code/routines/trig_…/fire " +
|
|
45
|
+
"--phone +56912345678");
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
console.log(`Routines on workspace ${workspace} (${list.length}):`);
|
|
49
|
+
for (const routine of list) printRoutine(routine);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (sub === "create") {
|
|
54
|
+
const environment = takeEnv(args, { fallback: "live" });
|
|
55
|
+
const url = takeValue(args, "--url");
|
|
56
|
+
const phoneNumbers = takeAll(args, "--phone");
|
|
57
|
+
const quiet = takeQuiet(args);
|
|
58
|
+
const name = args.shift();
|
|
59
|
+
if (!name || !url || phoneNumbers.length === 0 || args.length > 0) fail(`Usage: ${CREATE_USAGE}`);
|
|
60
|
+
|
|
61
|
+
// Asked for rather than typed on the command line, where it would stay in
|
|
62
|
+
// shell history; piped in works too: `op read … | vatio routines create …`.
|
|
63
|
+
const token = await askSecret(`${paint("green", "?")} Paste the routine's API token (sk-ant-oat01-…): `);
|
|
64
|
+
if (token === "") fail("No token given. claude.ai shows it once, when you generate it on the routine's API trigger.");
|
|
65
|
+
|
|
66
|
+
const body = { environment, name, url, token, phone_numbers: phoneNumbers };
|
|
67
|
+
if (quiet !== null) body.quiet_seconds = quiet;
|
|
68
|
+
const routine = await client.createRoutine(body);
|
|
69
|
+
if (json) return console.log(JSON.stringify(routine, null, 2));
|
|
70
|
+
console.log(`${paint("green", "✓")} Created routine #${routine.id} (${routine.name}) on ${routine.environment}`);
|
|
71
|
+
printRoutine(routine);
|
|
72
|
+
console.log("");
|
|
73
|
+
console.log("Give the routine a server key so it can read the conversation: vatio keys create --env " +
|
|
74
|
+
`${routine.environment} --label ${routine.name}`);
|
|
75
|
+
console.log(`Then check it starts: vatio routines test ${routine.id}`);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (sub === "update") {
|
|
80
|
+
const name = takeValue(args, "--name");
|
|
81
|
+
const url = takeValue(args, "--url");
|
|
82
|
+
const phoneNumbers = takeAll(args, "--phone");
|
|
83
|
+
const newToken = takeFlag(args, "--new-token");
|
|
84
|
+
const quiet = takeQuiet(args);
|
|
85
|
+
const id = args.shift();
|
|
86
|
+
if (!id || args.length > 0) fail(`Usage: ${UPDATE_USAGE}`);
|
|
87
|
+
|
|
88
|
+
const body = {};
|
|
89
|
+
if (name !== null) body.name = name;
|
|
90
|
+
if (url !== null) body.url = url;
|
|
91
|
+
if (phoneNumbers.length > 0) body.phone_numbers = phoneNumbers;
|
|
92
|
+
if (quiet !== null) body.quiet_seconds = quiet;
|
|
93
|
+
if (newToken) {
|
|
94
|
+
body.token = await askSecret(`${paint("green", "?")} Paste the new API token: `);
|
|
95
|
+
if (body.token === "") fail("No token given");
|
|
96
|
+
}
|
|
97
|
+
if (Object.keys(body).length === 0) fail(`Nothing to change. ${UPDATE_USAGE}`);
|
|
98
|
+
|
|
99
|
+
const routine = await client.updateRoutine({ id, ...body });
|
|
100
|
+
if (json) return console.log(JSON.stringify(routine, null, 2));
|
|
101
|
+
console.log(`${paint("green", "✓")} Updated routine #${routine.id}`);
|
|
102
|
+
printRoutine(routine);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (sub === "test") {
|
|
107
|
+
const id = args.shift();
|
|
108
|
+
if (!id) fail("Usage: vatio routines test ID");
|
|
109
|
+
const run = await client.testRoutine({ id });
|
|
110
|
+
console.log(`Fired a ping (run #${run.id}). It starts a real Claude session; the routine's prompt decides what a ping does.`);
|
|
111
|
+
const deadline = Date.now() + 30_000;
|
|
112
|
+
for (;;) {
|
|
113
|
+
await sleep(WAIT_INTERVAL_MS);
|
|
114
|
+
const { runs: list = [] } = await client.listRoutineRuns({ id });
|
|
115
|
+
const current = list.find((entry) => entry.id === run.id);
|
|
116
|
+
if (current && current.status !== "pending") {
|
|
117
|
+
printRun(current);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (Date.now() > deadline) {
|
|
121
|
+
console.log(`No answer yet. Check later with: vatio routines runs ${id}`);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (sub === "runs") {
|
|
128
|
+
const id = args.shift();
|
|
129
|
+
if (!id) fail("Usage: vatio routines runs ID");
|
|
130
|
+
const { runs: list = [] } = await client.listRoutineRuns({ id });
|
|
131
|
+
if (json) return console.log(JSON.stringify(list, null, 2));
|
|
132
|
+
if (list.length === 0) {
|
|
133
|
+
console.log("No runs yet.");
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
for (const run of list) printRun(run);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (sub === "enable") {
|
|
141
|
+
const id = args.shift();
|
|
142
|
+
if (!id) fail("Usage: vatio routines enable ID");
|
|
143
|
+
await client.updateRoutine({ id, enabled: true });
|
|
144
|
+
console.log(`Enabled routine #${id}`);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (sub === "rm" || sub === "remove" || sub === "delete") {
|
|
149
|
+
const id = args.shift();
|
|
150
|
+
if (!id) fail("Usage: vatio routines rm ID");
|
|
151
|
+
await client.deleteRoutine({ id });
|
|
152
|
+
console.log(`Removed routine #${id}`);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
fail(USAGE);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function printRoutine(routine) {
|
|
160
|
+
const state = routine.enabled ? paint("green", "enabled") : paint("red", "disabled");
|
|
161
|
+
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` +
|
|
164
|
+
(routine.consecutive_failures > 0 ? ` failing: ${routine.consecutive_failures} in a row` : ""));
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function printRun(run) {
|
|
168
|
+
const status = run.status === "fired"
|
|
169
|
+
? paint("green", "fired")
|
|
170
|
+
: run.status === "failed" ? paint("red", "failed") : paint("cyan", "pending");
|
|
171
|
+
const http = run.response_status ? ` HTTP ${run.response_status}` : "";
|
|
172
|
+
const chat = run.chat_id ? ` chat ${run.chat_id}` : "";
|
|
173
|
+
console.log(` #${run.id} ${run.event} ${status}${http}${chat} attempts ${run.attempts} ${run.created_at}`);
|
|
174
|
+
if (run.session_url) console.log(` ${run.session_url}`);
|
|
175
|
+
if (run.last_error) console.log(` ${paint("red", run.last_error)}`);
|
|
176
|
+
}
|
|
@@ -97,7 +97,8 @@ export async function shareSession(config, args) {
|
|
|
97
97
|
console.log(` ${size(Buffer.byteLength(transcript.jsonl))}, ${size(gzipped.length)} compressed`);
|
|
98
98
|
console.log(
|
|
99
99
|
` Left out: ${transcript.images > 0 ? `${transcript.images} image(s) and ` : ""}Claude Code's own bookkeeping.` +
|
|
100
|
-
(transcript.redactions > 0 ? ` ${transcript.redactions} thing(s) that looked like a key, token or password are [REDACTED].` : "")
|
|
100
|
+
(transcript.redactions > 0 ? ` ${transcript.redactions} thing(s) that looked like a key, token or password are [REDACTED].` : "") +
|
|
101
|
+
(transcript.personal > 0 ? ` ${transcript.personal} email address(es) and phone number(s) are [EMAIL] and [PHONE].` : "")
|
|
101
102
|
);
|
|
102
103
|
|
|
103
104
|
if (savePath) {
|
|
@@ -108,7 +109,10 @@ export async function shareSession(config, args) {
|
|
|
108
109
|
return;
|
|
109
110
|
}
|
|
110
111
|
|
|
111
|
-
console.log(
|
|
112
|
+
console.log(
|
|
113
|
+
"\nOnly the Vatio team reads it, to see where you and your coding agent got stuck. Every read is logged,\n" +
|
|
114
|
+
"and it is deleted 30 days after it arrives."
|
|
115
|
+
);
|
|
112
116
|
if (!yes) {
|
|
113
117
|
if (!process.stdin.isTTY) {
|
|
114
118
|
fail(
|
|
@@ -153,7 +157,8 @@ export async function shareSession(config, args) {
|
|
|
153
157
|
if (response.status === 401) fail("Your sign-in has expired. Run `vatio login`, then this again.");
|
|
154
158
|
if (!response.ok) fail(`Could not send it: ${body.error_description ?? `HTTP ${response.status}`}`);
|
|
155
159
|
|
|
156
|
-
console.log(`Sent to the Vatio team (#${body.id}). Thank you.`);
|
|
160
|
+
console.log(`Sent to the Vatio team (#${body.id}).${body.expires_at ? ` It is deleted on ${when(body.expires_at)}.` : ""} Thank you.`);
|
|
161
|
+
rememberSent(session.id, body.id);
|
|
157
162
|
rememberOffer(session.id);
|
|
158
163
|
}
|
|
159
164
|
|
|
@@ -201,6 +206,26 @@ function rememberOffer(sessionId) {
|
|
|
201
206
|
}
|
|
202
207
|
}
|
|
203
208
|
|
|
209
|
+
// Which sessions went, so `--list` can say so: when a permission check stops
|
|
210
|
+
// the coding agent and the developer sends it from a terminal, this is how the
|
|
211
|
+
// agent learns it arrived.
|
|
212
|
+
const SENT_KEPT = 20;
|
|
213
|
+
|
|
214
|
+
function rememberSent(sessionId, transcriptId) {
|
|
215
|
+
try {
|
|
216
|
+
const state = readOfferState();
|
|
217
|
+
const { [sessionId]: _previous, ...others } = sentSessions(state);
|
|
218
|
+
const sent = Object.entries({ ...others, [sessionId]: { id: transcriptId, at: new Date().toISOString() } });
|
|
219
|
+
writeOfferState({ ...state, sent: Object.fromEntries(sent.slice(-SENT_KEPT)) });
|
|
220
|
+
} catch {
|
|
221
|
+
// Not remembering only means `--list` does not mark it.
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function sentSessions(state = readOfferState()) {
|
|
226
|
+
return state.sent && typeof state.sent === "object" && !Array.isArray(state.sent) ? state.sent : {};
|
|
227
|
+
}
|
|
228
|
+
|
|
204
229
|
function offerStatePath() {
|
|
205
230
|
return join(configHome(), "share-session.json");
|
|
206
231
|
}
|
|
@@ -243,11 +268,13 @@ function listSessions() {
|
|
|
243
268
|
if (sessions.length === 0) fail("No Claude Code sessions for this directory.");
|
|
244
269
|
|
|
245
270
|
const current = process.env.CLAUDE_CODE_SESSION_ID;
|
|
271
|
+
const sent = sentSessions();
|
|
246
272
|
for (const session of sessions) {
|
|
247
273
|
const mark = session.id === current ? "*" : " ";
|
|
248
274
|
const title = session.title ? truncate(session.title, 60) : "";
|
|
249
275
|
const modified = when(new Date(session.modifiedAt).toISOString());
|
|
250
|
-
|
|
276
|
+
const shared = sent[session.id] ? ` (sent #${sent[session.id].id}, ${when(sent[session.id].at)})` : "";
|
|
277
|
+
console.log(`${mark} ${short(session.id)} ${modified} ${String(session.messages).padStart(5)} msgs ${title}${shared}`);
|
|
251
278
|
}
|
|
252
279
|
console.log("\nSend one with `vatio share-session --id ID`.");
|
|
253
280
|
}
|
package/lib/config.mjs
CHANGED
|
@@ -15,7 +15,7 @@ import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "n
|
|
|
15
15
|
import { homedir } from "node:os";
|
|
16
16
|
import { dirname, join, resolve } from "node:path";
|
|
17
17
|
|
|
18
|
-
import { MANIFEST_FILE, SLUG_FORMAT, findWorkspaceRoot, manifestPath, workspaceSlug } from "./workspace.mjs";
|
|
18
|
+
import { MANIFEST_FILE, SLUG_FORMAT, findWorkspaceRoot, manifestPath, workspaceSlug, workspacesBelow } from "./workspace.mjs";
|
|
19
19
|
|
|
20
20
|
export const KEYS = ["base_url", "token"];
|
|
21
21
|
export const DEFAULT_BASE_URL = "https://vatio.ai";
|
|
@@ -122,9 +122,12 @@ export class Config {
|
|
|
122
122
|
|
|
123
123
|
workspaceRootRequired() {
|
|
124
124
|
if (this.workspaceRoot) return this.workspaceRoot;
|
|
125
|
+
const below = workspacesBelow(this.startDir);
|
|
125
126
|
throw new ConfigError(
|
|
126
127
|
`Not inside a Vatio workspace (no ${MANIFEST_FILE} found walking up from ${this.startDir}).\n` +
|
|
127
|
-
|
|
128
|
+
(below.length > 0
|
|
129
|
+
? `There is one in ${below.map((dir) => `./${dir}`).join(", ")}: run it from there (\`cd ${below[0]}\`).`
|
|
130
|
+
: "Run `vatio init SLUG` here to create one.")
|
|
128
131
|
);
|
|
129
132
|
}
|
|
130
133
|
|
package/lib/help.mjs
CHANGED
|
@@ -127,6 +127,11 @@ Commands default as listed.
|
|
|
127
127
|
webhooks list|create URL [--event NAME]...|test ID|deliveries ID|enable ID|rm ID
|
|
128
128
|
Where Vatio tells your backend what happened
|
|
129
129
|
|
|
130
|
+
Claude Code routines (WhatsApp):
|
|
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
|
|
134
|
+
|
|
130
135
|
Channels:
|
|
131
136
|
whatsapp Set up in the console; prints the link (Test page
|
|
132
137
|
until you publish, then Integrations)
|
package/lib/telemetry.mjs
CHANGED
|
@@ -34,6 +34,7 @@ const SUBCOMMANDS = {
|
|
|
34
34
|
keys: ["list", "create", "revoke"],
|
|
35
35
|
templates: ["list", "create"],
|
|
36
36
|
webhooks: ["list", "create", "test", "deliveries", "enable", "rm"],
|
|
37
|
+
routines: ["list", "create", "update", "test", "runs", "enable", "rm"],
|
|
37
38
|
config: ["show", "get", "set", "unset"],
|
|
38
39
|
"share-session": ["--should-ask", "--never"]
|
|
39
40
|
};
|
package/lib/workspace.mjs
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
// thing a client cannot ask the platform for is the address of that call: the
|
|
8
8
|
// slug is in its URL. So this reads `workspace:` and stops.
|
|
9
9
|
|
|
10
|
-
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
11
|
-
import { dirname, join, parse as parsePath, resolve } from "node:path";
|
|
10
|
+
import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
11
|
+
import { dirname, join, parse as parsePath, relative, resolve } from "node:path";
|
|
12
12
|
import { parse as parseYaml } from "yaml";
|
|
13
13
|
|
|
14
14
|
export const MANIFEST_FILE = "vatio.yml";
|
|
@@ -42,6 +42,34 @@ export function findWorkspaceRoot(startDir) {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
// The workspaces just below a directory that is not in one, for the error that
|
|
46
|
+
// says so: a coding agent started at the top of a repository is usually one
|
|
47
|
+
// `cd` away from its vatio.yml.
|
|
48
|
+
const SKIPPED_DIRS = new Set(["node_modules", "vendor", "dist", "build"]);
|
|
49
|
+
|
|
50
|
+
export function workspacesBelow(startDir, { depth = 2, limit = 3 } = {}) {
|
|
51
|
+
const root = resolve(startDir);
|
|
52
|
+
const found = [];
|
|
53
|
+
const visit = (dir, level) => {
|
|
54
|
+
if (level > depth || found.length >= limit) return;
|
|
55
|
+
let names;
|
|
56
|
+
try {
|
|
57
|
+
names = readdirSync(dir, { withFileTypes: true });
|
|
58
|
+
} catch {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
for (const entry of names) {
|
|
62
|
+
if (!entry.isDirectory() || entry.name.startsWith(".") || SKIPPED_DIRS.has(entry.name)) continue;
|
|
63
|
+
const child = join(dir, entry.name);
|
|
64
|
+
if (manifestPath(child)) found.push(relative(root, child));
|
|
65
|
+
else visit(child, level + 1);
|
|
66
|
+
if (found.length >= limit) return;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
visit(root, 1);
|
|
70
|
+
return found;
|
|
71
|
+
}
|
|
72
|
+
|
|
45
73
|
// Which workspace this directory deploys to. Addressing, not content: it names
|
|
46
74
|
// the remote, so it never rides along in the deployed manifest. Null when the
|
|
47
75
|
// file does not declare one.
|