@vatio-ai/cli 0.84.1 → 0.86.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.
@@ -294,6 +294,15 @@ export class ApiClient extends HttpClient {
294
294
  return this.post(`/chats/${encode(chatId)}/messages`, { content });
295
295
  }
296
296
 
297
+ exportChats({ from, to = null, environment = null, channel = null, after = null }) {
298
+ const params = { from };
299
+ if (to) params.to = to;
300
+ if (environment) params.environment = environment;
301
+ if (channel) params.channel = channel;
302
+ if (after) params.after = after;
303
+ return this.get("/chats/export", params);
304
+ }
305
+
297
306
  }
298
307
 
299
308
  // /api/developer/v1/workspaces -- not workspace-scoped, so it takes the bare host.
@@ -6,7 +6,7 @@
6
6
  // accounts do that for real, and a simulated channel was only ever a second
7
7
  // answer to keep in step with the true one.
8
8
 
9
- import { existsSync, readFileSync, writeFileSync } from "node:fs";
9
+ import { appendFileSync, existsSync, readFileSync, writeFileSync } from "node:fs";
10
10
  import { join } from "node:path";
11
11
 
12
12
  import { ApiClient } from "../api-client.mjs";
@@ -26,6 +26,10 @@ const RETIRED = {
26
26
  const REMOVED_FLAGS = ["--channel", "--from", "--as", "--sandbox-url"];
27
27
 
28
28
  export async function chat(config, args) {
29
+ // Not a conversation of your own, so none of what follows applies to it,
30
+ // and its --from and --channel mean dates and a channel to read.
31
+ if (args[0] === "export") return await exportChats(config, args.slice(1));
32
+
29
33
  for (const arg of args) {
30
34
  if (REMOVED_FLAGS.some((flag) => arg === flag || arg.startsWith(`${flag}=`))) {
31
35
  fail(
@@ -63,6 +67,7 @@ export function chatHelp() {
63
67
  return `Usage:
64
68
  vatio chat "message" [--env NAME] [--new] [--timeout N]
65
69
  vatio chat show [CHAT_ID] [--env NAME] [--last N] [--json]
70
+ ${EXPORT_USAGE}
66
71
 
67
72
  --env picks the deployment that answers: preview (default), live, or a preview
68
73
  name like pr-42. A chat against live is a real conversation and shows up in
@@ -78,7 +83,59 @@ none: why, and whether anything in your workspace caused it.
78
83
 
79
84
  The open chat per deployment is remembered in ${STATE_FILE}, so a second
80
85
  \`vatio chat\` continues the first. \`--new\` starts over as a visitor the
81
- workspace has never met.`;
86
+ workspace has never met.
87
+
88
+ \`export\` prints what people said and what they were answered between two
89
+ dates (live unless --env says otherwise), one conversation per line as JSON,
90
+ for reading them in bulk -- with a coding agent, say. Vatio redacts it before
91
+ it leaves: names, emails, phone numbers and RUTs it knows are [FILTERED], and
92
+ \`person\` stands for whoever it was without naming them. Anyone on the
93
+ workspace's team can run it, a viewer too, and every call is in the
94
+ workspace's activity. Dates are whole days; --to defaults to now.`;
95
+ }
96
+
97
+ const EXPORT_USAGE = "vatio chat export --from DATE [--to DATE] [--env NAME] [--channel NAME] [--out FILE]";
98
+
99
+ // One page at a time, written as it arrives: a month of a busy WhatsApp number
100
+ // does not have to fit in memory to be read.
101
+ async function exportChats(config, args) {
102
+ const environment = takeEnv(args, { fallback: "live" });
103
+ const from = takeValue(args, "--from");
104
+ const to = takeValue(args, "--to");
105
+ const channel = takeValue(args, "--channel");
106
+ const out = takeValue(args, "--out");
107
+ const apiUrl = takeValue(args, "--api-url");
108
+ const token = takeValue(args, "--token");
109
+ if (args.length > 0) fail(`Unexpected ${args[0]}. Usage: ${EXPORT_USAGE}`);
110
+ if (!from) fail(`--from is required, a date like 2026-09-01. Usage: ${EXPORT_USAGE}`);
111
+
112
+ const api = client(config, { apiUrl, token });
113
+ if (out) writeFileSync(out, "");
114
+
115
+ let after = null;
116
+ let chats = 0;
117
+ let messages = 0;
118
+ for (;;) {
119
+ const page = await api.exportChats({ from, to, environment, channel, after });
120
+ const rows = Array.isArray(page.data) ? page.data : [];
121
+ if (rows.length > 0) {
122
+ const lines = `${rows.map((row) => JSON.stringify(row)).join("\n")}\n`;
123
+ if (out) appendFileSync(out, lines);
124
+ else await new Promise((resolve) => process.stdout.write(lines, resolve));
125
+ }
126
+ chats += rows.length;
127
+ messages += rows.reduce((sum, row) => sum + (Array.isArray(row.messages) ? row.messages.length : 0), 0);
128
+ if (!page.next_after) {
129
+ const window = page.window ?? {};
130
+ console.error(
131
+ `vatio: ${chats} conversation${chats === 1 ? "" : "s"}, ${messages} message${messages === 1 ? "" : "s"}, ` +
132
+ `${window.from} → ${window.to} on ${page.environment ?? environment}${out ? `, in ${out}` : ""}. ` +
133
+ "Redacted by Vatio: what identifies someone reads [FILTERED]."
134
+ );
135
+ return;
136
+ }
137
+ after = page.next_after;
138
+ }
82
139
  }
83
140
 
84
141
  // With no account on this machine, the trial this directory pushed to, with
package/lib/help.mjs CHANGED
@@ -61,6 +61,11 @@ Commands default as listed.
61
61
  chat show [CHAT_ID] [--json] [--last N]
62
62
  The chat you are in, or any chat in the workspace
63
63
  (web, WhatsApp, ...): messages, tool calls, channel
64
+ chat export --from DATE [--to DATE] [--env NAME] [--channel NAME] [--out FILE]
65
+ What people said and were answered between two
66
+ dates, redacted by Vatio, one conversation per
67
+ line as JSON. Default: live. Any team member,
68
+ viewers included; every call is in the activity
64
69
 
65
70
  Improve it from what supervisors reported and how its tools answered
66
71
  (flags, fix, push, test, publish):
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vatio-ai/cli",
3
- "version": "0.84.1",
3
+ "version": "0.86.0",
4
4
  "description": "Vatio CLI — deploy and manage Vatio agent workspaces",
5
5
  "keywords": [
6
6
  "vatio",