@vatio-ai/cli 0.68.0 → 0.70.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/README.md +1 -1
- package/bin/vatio.mjs +1 -1
- package/lib/commands/auth.mjs +24 -1
- package/lib/commands/chat.mjs +17 -0
- package/lib/commands/workspace-admin.mjs +51 -31
- package/lib/help.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -50,7 +50,7 @@ is no `--workspace` flag.
|
|
|
50
50
|
|
|
51
51
|
```
|
|
52
52
|
init [SLUG] Create vatio.yml here, and the remote to match
|
|
53
|
-
login | logout Authorize this machine in a browser, or forget it
|
|
53
|
+
login | logout Authorize this machine in a browser, or revoke and forget it
|
|
54
54
|
doctor Node, config, workspace and token status
|
|
55
55
|
|
|
56
56
|
push [--env NAME] Validate the workspace, then update a preview
|
package/bin/vatio.mjs
CHANGED
package/lib/commands/auth.mjs
CHANGED
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
import { DeniedError, DeviceAuthClient, ExpiredError, PendingError } from "../device-auth.mjs";
|
|
4
4
|
import { DEFAULT_BASE_URL } from "../config.mjs";
|
|
5
5
|
import { fail, openBrowser, sleep, takeValue } from "../support.mjs";
|
|
6
|
+
import { clientHeaders } from "../telemetry.mjs";
|
|
7
|
+
|
|
8
|
+
const LOGOUT_TIMEOUT_MS = 10_000;
|
|
6
9
|
|
|
7
10
|
// A token is minted by a human signing in on the page this opens -- email,
|
|
8
11
|
// Google or GitHub -- never by the CLI alone, which is why it asks nothing
|
|
@@ -85,7 +88,27 @@ export async function login(config, args) {
|
|
|
85
88
|
console.log(`Token saved to ${config.configPath}`);
|
|
86
89
|
}
|
|
87
90
|
|
|
88
|
-
|
|
91
|
+
// Revokes the saved token on the server before forgetting it, so a copy of
|
|
92
|
+
// the config file stops working too. Offline or already revoked, the local
|
|
93
|
+
// copy is still removed. A token in VATIO_TOKEN is left alone: it was never
|
|
94
|
+
// this file's to forget.
|
|
95
|
+
export async function logout(config) {
|
|
96
|
+
const token = config.load().token;
|
|
97
|
+
let revoked = false;
|
|
98
|
+
if (token) {
|
|
99
|
+
try {
|
|
100
|
+
const response = await fetch(`${config.resolveBaseUrl()}/api/developer/v1/session`, {
|
|
101
|
+
method: "DELETE",
|
|
102
|
+
headers: { ...clientHeaders(), Accept: "application/json", Authorization: `Bearer ${token}` },
|
|
103
|
+
signal: AbortSignal.timeout(LOGOUT_TIMEOUT_MS)
|
|
104
|
+
});
|
|
105
|
+
revoked = response.ok;
|
|
106
|
+
} catch {
|
|
107
|
+
revoked = false;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
89
111
|
config.clearToken();
|
|
90
112
|
console.log(`Removed the token from ${config.configPath}`);
|
|
113
|
+
if (token && !revoked) console.log("Could not reach Vatio to revoke it; it expires 90 days after its last use.");
|
|
91
114
|
}
|
package/lib/commands/chat.mjs
CHANGED
|
@@ -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
|
-
|
|
16
|
-
|
|
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
|
-
|
|
34
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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 ${
|
|
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 ${
|
|
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/lib/help.mjs
CHANGED
|
@@ -21,7 +21,7 @@ and the one its pull request deploys to. Elsewhere commands default as listed.
|
|
|
21
21
|
init [SLUG] [--name NAME] Create vatio.yml here, and the remote to match
|
|
22
22
|
login [--base-url URL] Sign this machine in from the browser: email link,
|
|
23
23
|
Google or GitHub. Creates the account if needed
|
|
24
|
-
logout
|
|
24
|
+
logout Revoke and forget the token
|
|
25
25
|
doctor Node, config, workspace and token status
|
|
26
26
|
version What this CLI is
|
|
27
27
|
docs [--save [PATH]] The whole developer contract, live from Vatio
|