@vatio-ai/cli 0.86.0 → 0.86.1

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 CHANGED
@@ -18,7 +18,7 @@ import { keepClaimedTrial } from "../lib/trial.mjs";
18
18
  import { UserError, fail } from "../lib/support.mjs";
19
19
  import { helpText } from "../lib/help.mjs";
20
20
  import { login, logout } from "../lib/commands/auth.mjs";
21
- import { configCommand, doctor, init, version } from "../lib/commands/misc.mjs";
21
+ import { configCommand, doctor, init, version, whoami } from "../lib/commands/misc.mjs";
22
22
  import { diff, publish, push, rollback, status } from "../lib/commands/deploy.mjs";
23
23
  import { env } from "../lib/commands/env.mjs";
24
24
  import { keys, secrets, tokens } from "../lib/commands/workspace-admin.mjs";
@@ -91,7 +91,9 @@ async function run(command, args) {
91
91
  case "-v":
92
92
  return version();
93
93
  case "doctor":
94
- return doctor(config);
94
+ return await doctor(config);
95
+ case "whoami":
96
+ return await whoami(config);
95
97
  case "login":
96
98
  return await login(config, args);
97
99
  case "logout":
@@ -41,6 +41,14 @@ const SECRET_PATTERNS = [
41
41
  /\b([A-Z0-9_]*(?:SECRET|TOKEN|PASSWORD|PASSWD|API_KEY|APIKEY|PRIVATE_KEY|ACCESS_KEY)[A-Z0-9_]*)(\s*[=:]\s*)(["']?)([^\s"'$]{6,})\3/g,
42
42
  `$1$2$3${REDACTED}$3`
43
43
  ],
44
+ // key=value on its own line in a .properties file (gradle.properties,
45
+ // key.properties), where names are dotted or camelCase:
46
+ // android.injected.signing.store.password, storePassword. A line number in
47
+ // front, as grep -n or cat -n prints it, is kept.
48
+ [
49
+ /^([ \t]*(?:\d+[:\t-])?[ \t]*[A-Za-z][\w.-]*(?:password|passwd|secret|token)[\w.-]*[ \t]*=[ \t]*)(?!\[REDACTED\])([^\s"'$]{6,})[ \t]*$/gim,
50
+ `$1${REDACTED}`
51
+ ],
44
52
  // "password": "…" in a JSON or YAML file.
45
53
  [
46
54
  /(["']?\b(?:password|secret|client_secret|api_key|apiKey|access_token|refresh_token|private_key)["']?\s*:\s*)(["'])([^"'\s]{6,})\2/g,
@@ -40,7 +40,8 @@ export async function deviceLogin({ config, baseUrl, message, workspace = null }
40
40
  config.clearPendingLogin();
41
41
  return {
42
42
  token: result.token,
43
- baseUrl: String(result.base_url ?? "").trim() || resolved
43
+ baseUrl: String(result.base_url ?? "").trim() || resolved,
44
+ email: String(result.email ?? "").trim() || null
44
45
  };
45
46
  } catch (error) {
46
47
  if (error instanceof PendingError) {
@@ -77,14 +78,14 @@ async function startLogin({ config, client, resolved, workspace }) {
77
78
 
78
79
  export async function login(config, args) {
79
80
  const baseUrl = takeValue(args, "--base-url");
80
- const { token, baseUrl: resolved } = await deviceLogin({
81
+ const { token, baseUrl: resolved, email } = await deviceLogin({
81
82
  config,
82
83
  baseUrl,
83
84
  message: "Signing this machine in to Vatio…"
84
85
  });
85
86
 
86
87
  config.writeAuth({ baseUrl: resolved, token });
87
- console.log(`Logged in to ${resolved}`);
88
+ console.log(email ? `Logged in to ${resolved} as ${email}` : `Logged in to ${resolved}`);
88
89
  console.log(`Token saved to ${config.configPath}`);
89
90
  }
90
91
 
@@ -28,6 +28,7 @@ export async function ensureAuthorized(config, { workspace = null, message = "Be
28
28
 
29
29
  const auth = await deviceLogin({ config, workspace, message });
30
30
  config.writeAuth({ baseUrl: auth.baseUrl, token: auth.token });
31
+ if (auth.email) console.log(`Signed in as ${auth.email}`);
31
32
  console.log(`Token saved to ${config.configPath}`);
32
33
  console.log("");
33
34
  }
@@ -19,7 +19,7 @@ export function version() {
19
19
 
20
20
  // What to read when a command fails for a reason that does not look like the
21
21
  // workspace itself.
22
- export function doctor(config) {
22
+ export async function doctor(config) {
23
23
  version();
24
24
  console.log(`CLI executable: ${process.argv[1]}`);
25
25
  console.log(`Node executable: ${process.execPath}`);
@@ -39,6 +39,7 @@ export function doctor(config) {
39
39
  if (slug) console.log(`Workspace: ${slug}`);
40
40
  const token = config.resolveToken();
41
41
  console.log(`Token: ${token ? "configured" : "missing — run `vatio login`"}`);
42
+ if (token) console.log(`Account: ${await accountLine(config)}`);
42
43
  // Where this directory pushes with no account. The link to keep it is not
43
44
  // printed: whoever holds it can take the trial, and this output is the one
44
45
  // that gets pasted into issues.
@@ -50,6 +51,41 @@ export function doctor(config) {
50
51
  console.log(`Docs: ${DOCS_URL}`);
51
52
  }
52
53
 
54
+ // Which account the token is, and the workspaces it reaches. A developer can
55
+ // hold several accounts -- an email, a Google and a GitHub sign-in are separate
56
+ // unless they share the address -- and a workspace belongs to one of them, so
57
+ // `workspace_forbidden` is often just the wrong one signed in here.
58
+ export async function whoami(config) {
59
+ const payload = await workspacesClient(config).listWorkspaces();
60
+ const email = payload?.account?.email;
61
+ console.log(email ? `Signed in as ${email}` : "Signed in (this Vatio does not say as whom)");
62
+ console.log(`Base URL: ${config.resolveBaseUrl()}`);
63
+ const slugs = (Array.isArray(payload?.workspaces) ? payload.workspaces : []).map((workspace) => workspace.slug);
64
+ console.log(slugs.length > 0 ? `Workspaces: ${slugs.join(", ")}` : "Workspaces: none yet");
65
+ let slug = null;
66
+ try {
67
+ slug = config.resolveWorkspace();
68
+ } catch {
69
+ slug = null;
70
+ }
71
+ if (slug && !slugs.includes(slug)) {
72
+ console.log("");
73
+ console.log(`This directory's workspace, ${slug}, is not one of them: it does not exist yet (\`vatio push\` ` +
74
+ "creates it) or belongs to another account (`vatio login` with that account's email or sign-in).");
75
+ }
76
+ }
77
+
78
+ // doctor's one line about the account. Never fails: doctor is what gets run
79
+ // when other commands do.
80
+ async function accountLine(config) {
81
+ try {
82
+ const payload = await workspacesClient(config).listWorkspaces();
83
+ return payload?.account?.email ?? "signed in (this Vatio does not say as whom)";
84
+ } catch (error) {
85
+ return `unknown — ${String(error?.message ?? error).split("\n")[0]}`;
86
+ }
87
+ }
88
+
53
89
  export function configCommand(config, args) {
54
90
  const sub = args.shift();
55
91
 
@@ -178,7 +178,8 @@ async function checkSigningKeys(url) {
178
178
  fail(
179
179
  `${url} still signs with the legacy JWT secret (HS256), which Vatio cannot verify without being able\n` +
180
180
  "to mint tokens too. In the Supabase dashboard: Project Settings → JWT Keys → migrate, then rotate\n" +
181
- "to an ES256 key. Your app keeps working through the switch. Then run this again."
181
+ "to an ES256 key, then run this again. Before rotating, check for code that verifies tokens with the\n" +
182
+ "legacy secret and for Edge Functions with Verify JWT on: https://vatio.ai/docs/integrations/supabase"
182
183
  );
183
184
  }
184
185
 
@@ -107,6 +107,7 @@ export async function tokens(config, args) {
107
107
  const environment = environmentOption(args, "live");
108
108
  const label = takeValue(args, "--label") ?? takeValue(args, "-l");
109
109
  const origins = takeOrigins(args);
110
+ const json = takeFlag(args, "--json");
110
111
  const workspace = config.resolveWorkspaceRequired();
111
112
  const client = deployClient(config, workspace);
112
113
  const sub = args.shift() ?? "list";
@@ -114,6 +115,10 @@ export async function tokens(config, args) {
114
115
  if (sub === "list") {
115
116
  const payload = await client.listPublishableTokens();
116
117
  const list = asArray(payload.publishable_tokens);
118
+ if (json) {
119
+ console.log(JSON.stringify(list, null, 2));
120
+ return;
121
+ }
117
122
  if (list.length === 0) {
118
123
  console.log(`No publishable tokens on workspace ${workspace}`);
119
124
  console.log(" Create one: vatio tokens create --env live --origin https://your-site.com");
@@ -130,6 +135,12 @@ export async function tokens(config, args) {
130
135
  }
131
136
  if (sub === "create") {
132
137
  const payload = await client.createPublishableToken({ environment, label, allowedOrigins: origins });
138
+ // For a script that hands the token straight to something else: the token
139
+ // or a failed command, never a line of prose to grep it out of.
140
+ if (json) {
141
+ console.log(JSON.stringify({ ...payload, token: payload.token ?? payload.publishable_token, workspace }, null, 2));
142
+ return;
143
+ }
133
144
  console.log(`Created a publishable token for ${environment} on workspace ${workspace}`);
134
145
  console.log(` origins: ${originsLine(payload.allowed_origins)}`);
135
146
  console.log("");
@@ -156,7 +167,7 @@ export async function tokens(config, args) {
156
167
  }
157
168
 
158
169
  fail(
159
- "Usage: vatio tokens list|create [--env live|preview] [--label NAME] [--origin URL]...|" +
170
+ "Usage: vatio tokens list|create [--env live|preview] [--label NAME] [--origin URL]... [--json]|" +
160
171
  "origins PREFIX URL...|revoke PREFIX"
161
172
  );
162
173
  }
package/lib/help.mjs CHANGED
@@ -21,7 +21,9 @@ Commands default as listed.
21
21
  login [--base-url URL] Sign this machine in from the browser: email link,
22
22
  Google or GitHub. Creates the account if needed
23
23
  logout Revoke and forget the token
24
- doctor Node, config, workspace and token status
24
+ whoami The account this machine is signed in as, and
25
+ the workspaces it reaches
26
+ doctor Node, config, workspace, token and account status
25
27
  version What this CLI is
26
28
  docs [--save [PATH]] The whole developer contract, live from Vatio
27
29
  feedback "TEXT" Tell the Vatio team what got in the way
@@ -116,7 +118,7 @@ Commands default as listed.
116
118
  With --env, the value only that environment uses;
117
119
  otherwise the value everywhere. With --tests, the
118
120
  value preview and every test run use, like a staging URL
119
- tokens list|create [--env NAME] [--label NAME] [--origin URL]...|revoke PREFIX
121
+ tokens list|create [--env NAME] [--label NAME] [--origin URL]... [--json]|revoke PREFIX
120
122
  tokens origins PREFIX URL...
121
123
  The origins a token is accepted from (replaces the list)
122
124
  keys list|create [--env NAME] [--label NAME]|revoke PREFIX
package/lib/trial.mjs CHANGED
@@ -106,6 +106,7 @@ export async function keepClaimedTrial(config, error) {
106
106
  message: `You kept this agent: it is workspace ${workspace} now. Sign this terminal in to keep working on it.`
107
107
  });
108
108
  config.writeAuth({ baseUrl: auth.baseUrl, token: auth.token });
109
+ if (auth.email) console.log(`Signed in as ${auth.email}`);
109
110
  console.log(`Token saved to ${config.configPath}`);
110
111
 
111
112
  const root = config.workspaceRoot;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vatio-ai/cli",
3
- "version": "0.86.0",
3
+ "version": "0.86.1",
4
4
  "description": "Vatio CLI — deploy and manage Vatio agent workspaces",
5
5
  "keywords": [
6
6
  "vatio",