@vatio-ai/cli 0.90.0 → 0.91.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/chat.mjs +7 -1
- package/lib/commands/improve.mjs +54 -1
- package/lib/help.mjs +5 -0
- package/package.json +1 -1
package/lib/commands/chat.mjs
CHANGED
|
@@ -76,6 +76,7 @@ your inbox.
|
|
|
76
76
|
\`show\` prints the chat you are in, with every tool call the agent made. Give
|
|
77
77
|
it an id to read any chat in the workspace -- one a visitor had on the web,
|
|
78
78
|
WhatsApp or Instagram -- with the environment and deployment that answered it.
|
|
79
|
+
Each message carries its id (#4821), the one \`vatio flags add --message\` takes.
|
|
79
80
|
A [your backend] line under a tool call is how your backend answered it.
|
|
80
81
|
A [safeguard] line says which of Vatio's checks discarded or rewrote a draft,
|
|
81
82
|
and a [vatio] line marks a reply Vatio wrote because the agent's turn produced
|
|
@@ -175,6 +176,11 @@ function chatsFor(config, apiUrl) {
|
|
|
175
176
|
return state.chats && typeof state.chats === "object" ? state.chats : {};
|
|
176
177
|
}
|
|
177
178
|
|
|
179
|
+
// The chat `vatio chat` is in on this environment, for `vatio flags add`.
|
|
180
|
+
export function rememberedChatId(config, environment) {
|
|
181
|
+
return chatsFor(config, config.resolveApiUrl())[environment] ?? null;
|
|
182
|
+
}
|
|
183
|
+
|
|
178
184
|
function rememberChat(config, { apiUrl, environment, chatId }) {
|
|
179
185
|
const chats = { ...chatsFor(config, apiUrl), [environment]: chatId };
|
|
180
186
|
writeFileSync(statePath(config), `${JSON.stringify({ api_url: apiUrl, chats }, null, 2)}\n`);
|
|
@@ -310,7 +316,7 @@ async function showChat(config, options, args) {
|
|
|
310
316
|
? ` (discarded by the ${safeguard.policy} safeguard)`
|
|
311
317
|
: " (discarded)"
|
|
312
318
|
: "";
|
|
313
|
-
if (content !== "" || flags) console.log(`[${message.role}]${flags} ${content}`);
|
|
319
|
+
if (content !== "" || flags) console.log(`[${message.role} #${message.id}]${flags} ${content}`);
|
|
314
320
|
for (const call of Array.isArray(message.tool_calls) ? message.tool_calls : []) {
|
|
315
321
|
console.log(` -> ${call.name}(${truncate(JSON.stringify(call.arguments ?? {}), 400)})`);
|
|
316
322
|
if (call.backend) console.log(` [your backend] ${backendLine(call.backend)}`);
|
package/lib/commands/improve.mjs
CHANGED
|
@@ -11,6 +11,7 @@ import { mkdirSync, writeFileSync } from "node:fs";
|
|
|
11
11
|
import { dirname, resolve } from "node:path";
|
|
12
12
|
|
|
13
13
|
import { HttpClient, NotFoundError, throwIfOutdated } from "../http.mjs";
|
|
14
|
+
import { rememberedChatId } from "./chat.mjs";
|
|
14
15
|
import { clientHeaders } from "../telemetry.mjs";
|
|
15
16
|
import { fail, sleep, takeEnv, takeFlag, takeValue } from "../support.mjs";
|
|
16
17
|
import { printSkillsHint } from "../skills-hint.mjs";
|
|
@@ -44,6 +45,7 @@ async function fetchMarkdown(config, path, what) {
|
|
|
44
45
|
// before it, every tool call of that turn with what your backend answered,
|
|
45
46
|
// and what the supervisor says should have happened.
|
|
46
47
|
export async function flags(config, args) {
|
|
48
|
+
if (args[0] === "add") return await addFlag(config, args.slice(1));
|
|
47
49
|
if (["rm", "remove", "delete"].includes(args[0])) return await removeFlags(config, args.slice(1));
|
|
48
50
|
|
|
49
51
|
const json = takeFlag(args, "--json");
|
|
@@ -71,6 +73,54 @@ export async function flags(config, args) {
|
|
|
71
73
|
await printSkillsHint();
|
|
72
74
|
}
|
|
73
75
|
|
|
76
|
+
const ADD_USAGE = 'vatio flags add "WHAT IT SHOULD DO" [--passes] [--chat ID | --message ID] [--env NAME]';
|
|
77
|
+
|
|
78
|
+
// What the inbox's Reportar does, from the terminal: the agent's last reply in
|
|
79
|
+
// the chat `vatio chat` is in (or --chat's, or --message), and what it should
|
|
80
|
+
// have done. The note makes it a test case, so a set of `vatio chat --new` +
|
|
81
|
+
// `vatio flags add` is a test suite `vatio test` replays on every version.
|
|
82
|
+
// --passes is for a reply that is already right: the case keeps it so, filed
|
|
83
|
+
// resolved, with nothing for Vatio to triage or fix.
|
|
84
|
+
async function addFlag(config, args) {
|
|
85
|
+
const environment = takeEnv(args, { fallback: "preview" });
|
|
86
|
+
const chatId = takeValue(args, "--chat");
|
|
87
|
+
const messageId = takeValue(args, "--message");
|
|
88
|
+
const passing = takeFlag(args, "--passes");
|
|
89
|
+
const note = args.join(" ").trim();
|
|
90
|
+
if (note === "" || args.some((arg) => arg.startsWith("--"))) fail(`Usage: ${ADD_USAGE}`);
|
|
91
|
+
if (chatId && messageId) fail(`--chat or --message, not both. Usage: ${ADD_USAGE}`);
|
|
92
|
+
|
|
93
|
+
const target = messageId ? { message_id: messageId } : { chat_id: chatId ?? rememberedChatId(config, environment) };
|
|
94
|
+
if (!target.message_id && !target.chat_id) {
|
|
95
|
+
fail(`No ${environment} chat yet: run \`vatio chat "hello"\` first, or pass --chat ID or --message ID.`);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const { url, token } = workspaceBase(config);
|
|
99
|
+
let flag;
|
|
100
|
+
try {
|
|
101
|
+
flag = await new HttpClient({ baseUrl: url, token }).post("/flags", { ...target, note, passing });
|
|
102
|
+
} catch (error) {
|
|
103
|
+
// The platform's own words name the chat or message and where to find the right one.
|
|
104
|
+
if (error instanceof NotFoundError) fail(error.message);
|
|
105
|
+
throw error;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const reply = String(flag.reply ?? "").trim().replace(/\s+/g, " ");
|
|
109
|
+
const verb = flag.passing ? "Kept as right" : flag.rewritten ? "Rewrote" : "Reported";
|
|
110
|
+
console.log(`${verb} ${flag.public_id}, chat ${flag.chat_id} on ${flag.environment}:`);
|
|
111
|
+
console.log(` [agent #${flag.message_id}] ${reply.length > 200 ? `${reply.slice(0, 200)}…` : reply}`);
|
|
112
|
+
if (flag.test_case && flag.passing) {
|
|
113
|
+
console.log(
|
|
114
|
+
`It is a test case, resolved${flag.resolved_in ? ` in ${flag.resolved_in}` : ""}: nothing for Vatio to fix, nothing pending\n` +
|
|
115
|
+
"in the inbox. `vatio test` replays it; once live passes it, `vatio publish` refuses a version that fails it."
|
|
116
|
+
);
|
|
117
|
+
} else if (flag.test_case) {
|
|
118
|
+
console.log("It is a test case now: `vatio test` replays it, `vatio flags` lists it, `vatio flags rm` removes it.");
|
|
119
|
+
} else {
|
|
120
|
+
console.log("No visitor message comes before that reply, so there is nothing to replay: it is not a test case.");
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
74
124
|
// What the inbox's Quitar does, by the ids `vatio flags` prints: the flag and
|
|
75
125
|
// its test case go, for everyone in the workspace. The developer's call, not
|
|
76
126
|
// the coding agent's: the vatio-improve skill says to run it only when asked.
|
|
@@ -149,7 +199,10 @@ async function runTests(config, args, { name, waitByDefault }) {
|
|
|
149
199
|
}
|
|
150
200
|
const runs = started.runs ?? [];
|
|
151
201
|
if (runs.length === 0) {
|
|
152
|
-
console.log(
|
|
202
|
+
console.log(
|
|
203
|
+
"No reports to test yet. Report a reply in the inbox, or after a `vatio chat` with\n" +
|
|
204
|
+
'`vatio flags add "what it should have done"`.'
|
|
205
|
+
);
|
|
153
206
|
return;
|
|
154
207
|
}
|
|
155
208
|
|
package/lib/help.mjs
CHANGED
|
@@ -78,6 +78,11 @@ Commands default as listed.
|
|
|
78
78
|
flags [--save [PATH]|--json]
|
|
79
79
|
Every open report: the conversation, what each tool
|
|
80
80
|
answered, and what should have happened
|
|
81
|
+
flags add "NOTE" [--passes] [--chat ID|--message ID] [--env NAME]
|
|
82
|
+
Report a reply and what should have happened:
|
|
83
|
+
the agent's last one in the chat \`vatio chat\`
|
|
84
|
+
is in (default: preview). It is a test case now.
|
|
85
|
+
--passes: the reply is right; the case keeps it so
|
|
81
86
|
flags rm ID [ID...] Remove a report and its test case, open or
|
|
82
87
|
resolved, as the inbox's Remove does
|
|
83
88
|
tools [--env NAME] [--period 1h|1d|7d|30d] [--json]
|