@vatio-ai/cli 0.68.0 → 0.69.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.
@@ -235,6 +235,8 @@ async function showChat(config, options, args) {
235
235
  }
236
236
  if (message.role === "tool") {
237
237
  console.log(` [tool result] ${truncate(content, 400)}`);
238
+ const limit = toolLimit(content);
239
+ if (limit) console.log(` [tool limit] ${limit}`);
238
240
  continue;
239
241
  }
240
242
  const flags = message.discarded ? " (discarded)" : "";
@@ -246,6 +248,21 @@ async function showChat(config, options, args) {
246
248
  if (messages.length === 0) console.log("(no messages)");
247
249
  }
248
250
 
251
+ // Vatio::Runtime::ToolBudget's marks on a tool result, said on a line of their
252
+ // own: the note rides at the end of the result and truncate() can cut it off,
253
+ // which left a turn that ran out of calls looking like one that just stopped.
254
+ function toolLimit(content) {
255
+ let result;
256
+ try {
257
+ result = JSON.parse(content);
258
+ } catch {
259
+ return null;
260
+ }
261
+ if (result?.error_key === "tool_budget_spent") return "call refused: this reply had spent its tool calls";
262
+ if (result?.tool_budget) return "this reply spent its tool calls; the agent was told to answer now";
263
+ return null;
264
+ }
265
+
249
266
  function truncate(text, max) {
250
267
  return text.length > max ? `${text.slice(0, max)}…` : text;
251
268
  }
@@ -4,6 +4,7 @@
4
4
  // them is in vatio.yml.
5
5
 
6
6
  import { deployClient } from "./deploy.mjs";
7
+ import { branchEnvironment } from "../branch.mjs";
7
8
  import { askSecret, branchDefault, fail, paint, takeFlag, takeValue } from "../support.mjs";
8
9
 
9
10
  // live, preview, or a branch's own like fix-pagos.
@@ -12,8 +13,14 @@ const ENVIRONMENT_MAX = 40;
12
13
 
13
14
  // On a branch, its environment unless told otherwise (see branch.mjs).
14
15
  function environmentOption(args, fallback, cwd) {
15
- const given = takeValue(args, "--env") ?? takeValue(args, "--environment") ?? takeValue(args, "-e");
16
- const value = given ?? branchDefault(cwd, fallback);
16
+ return checkEnvironment(givenEnvironment(args) ?? branchDefault(cwd, fallback));
17
+ }
18
+
19
+ function givenEnvironment(args) {
20
+ return takeValue(args, "--env") ?? takeValue(args, "--environment") ?? takeValue(args, "-e");
21
+ }
22
+
23
+ function checkEnvironment(value) {
17
24
  if (value === null) return null;
18
25
  if (String(value).length > ENVIRONMENT_MAX || !ENVIRONMENT_NAME.test(String(value))) {
19
26
  fail(`Unknown environment "${value}" (use live, preview, or a branch's environment like fix-pagos)`);
@@ -26,39 +33,24 @@ function environmentOption(args, fallback, cwd) {
26
33
  // its tools at staging while live keeps production. With --tests, the value
27
34
  // every environment but live and every eval replay uses, branches included,
28
35
  // so it never takes the branch's environment.
36
+ //
37
+ // `list` shows every row, every environment's included, unless --env asks for
38
+ // one: a value set from a branch was otherwise somewhere `list` did not look.
39
+ // Every line names the row's scope, and `set` and `rm` say which one they
40
+ // touched.
29
41
  export async function secrets(config, args) {
30
42
  const workspace = config.resolveWorkspaceRequired();
31
43
  const client = deployClient(config, workspace);
32
44
  const tests = takeFlag(args, "--tests");
33
- if (tests && (takeValue(args, "--env") ?? takeValue(args, "--environment") ?? takeValue(args, "-e"))) {
34
- fail("--tests is the value for every environment but live; drop --env");
35
- }
36
- const environment = tests ? null : environmentOption(args, null, config.workspaceRoot);
37
- const where = tests
38
- ? `workspace ${workspace}, for tests`
39
- : environment
40
- ? `${environment} on workspace ${workspace}`
41
- : `workspace ${workspace}`;
45
+ const given = givenEnvironment(args);
46
+ if (tests && given) fail("--tests is the value for every environment but live; drop --env");
42
47
  const sub = args.shift() ?? "list";
43
48
 
44
- if (sub === "list") {
45
- const payload = await client.listSecrets({ environment });
46
- const keys = asArray(payload.secrets);
47
- if (keys.length === 0) {
48
- console.log(`No secrets on ${where}`);
49
- console.log(" Set one: vatio secrets set STRIPE_KEY sk_live_…");
50
- return;
51
- }
52
- // Keys only, never values. The platform does not hand a value back once it
53
- // is stored, and a CLI that printed them would be a CLI that leaks them
54
- // into a terminal scrollback.
55
- console.log(`Secrets on ${where} (${keys.length}):`);
56
- for (const secret of keys) {
57
- const scope = secret.tests ? " (tests)" : secret.environment ? ` (only ${secret.environment})` : "";
58
- console.log(` ${secret.key ?? secret}${scope}`);
59
- }
60
- return;
61
- }
49
+ if (sub === "list") return listSecrets(client, workspace, checkEnvironment(given), config.workspaceRoot);
50
+
51
+ const environment = tests ? null : checkEnvironment(given ?? branchDefault(config.workspaceRoot, null));
52
+ const scope = secretScope({ environment, tests });
53
+
62
54
  if (sub === "set") {
63
55
  const key = args.shift();
64
56
  if (!key) fail("Usage: vatio secrets set KEY [VALUE] [--env NAME | --tests]");
@@ -67,20 +59,48 @@ export async function secrets(config, args) {
67
59
  const value = args.shift() ?? (await askSecret(`${paint("green", "?")} Paste your secret: `));
68
60
  if (value === "") fail(`No value given for ${key}`);
69
61
  await client.upsertSecret({ key, value, environment, tests });
70
- console.log(`${paint("green", "✓")} Set secret ${key} on ${where}`);
62
+ console.log(`${paint("green", "✓")} Set secret ${key} on workspace ${workspace} (${scope})`);
71
63
  return;
72
64
  }
73
65
  if (sub === "rm" || sub === "remove" || sub === "delete") {
74
66
  const key = args.shift();
75
67
  if (!key) fail("Usage: vatio secrets rm KEY [--env NAME | --tests]");
76
68
  await client.deleteSecret({ key, environment, tests });
77
- console.log(`Removed ${key} from ${where}`);
69
+ console.log(`Removed ${key} from workspace ${workspace} (${scope})`);
78
70
  return;
79
71
  }
80
72
 
81
73
  fail("Usage: vatio secrets list|set KEY [VALUE]|rm KEY [--env NAME | --tests]");
82
74
  }
83
75
 
76
+ async function listSecrets(client, workspace, environment, cwd) {
77
+ const payload = await client.listSecrets({ environment });
78
+ const keys = asArray(payload.secrets);
79
+ const title = environment ? `secrets ${environment} reads on workspace ${workspace}` : `secrets on workspace ${workspace}`;
80
+ if (keys.length === 0) {
81
+ console.log(`No ${title}`);
82
+ console.log(" Set one: vatio secrets set STRIPE_KEY sk_live_…");
83
+ return;
84
+ }
85
+ // Keys only, never values. The platform does not hand a value back once it
86
+ // is stored, and a CLI that printed them would be a CLI that leaks them
87
+ // into a terminal scrollback.
88
+ console.log(`${title[0].toUpperCase()}${title.slice(1)} (${keys.length}):`);
89
+ const width = Math.max(...keys.map((secret) => String(secret.key ?? secret).length));
90
+ for (const secret of keys) {
91
+ console.log(` ${String(secret.key ?? secret).padEnd(width)} ${secretScope(secret)}`);
92
+ }
93
+ const branch = environment || !cwd ? null : branchEnvironment(cwd);
94
+ if (branch) {
95
+ console.log(`On branch ${branch.branch}, \`vatio secrets set\` sets the value only ${branch.environment} uses; --env NAME picks another.`);
96
+ }
97
+ }
98
+
99
+ function secretScope({ environment, tests }) {
100
+ if (tests) return "tests";
101
+ return environment ? `only ${environment}` : "every environment";
102
+ }
103
+
84
104
  // Repeatable: `--origin https://a.com --origin https://b.com`.
85
105
  function takeOrigins(args) {
86
106
  const origins = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vatio-ai/cli",
3
- "version": "0.68.0",
3
+ "version": "0.69.0",
4
4
  "description": "Vatio CLI — deploy and manage Vatio agent workspaces",
5
5
  "keywords": [
6
6
  "vatio",