@vatio-ai/cli 0.87.0 → 0.89.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 +2 -3
- package/bin/vatio.mjs +8 -49
- package/lib/api-client.mjs +14 -1
- package/lib/commands/chat.mjs +6 -12
- package/lib/commands/deploy.mjs +165 -80
- package/lib/commands/misc.mjs +1 -15
- package/lib/config.mjs +36 -42
- package/lib/help.mjs +9 -5
- package/lib/http.mjs +7 -10
- package/lib/pull.mjs +605 -0
- package/lib/support.mjs +17 -0
- package/lib/workspace.mjs +1 -17
- package/package.json +1 -1
- package/lib/trial.mjs +0 -135
package/lib/trial.mjs
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
// `vatio push` on a machine with no account: a trial workspace.
|
|
2
|
-
//
|
|
3
|
-
// The platform makes one (POST /api/developer/v1/trials) and answers with two
|
|
4
|
-
// secrets. The deploy key (`vtk_`) stays on this machine, in the config file,
|
|
5
|
-
// next to this directory's path: it pushes, checks, chats and writes knowledge
|
|
6
|
-
// on the trial's preview, and nothing else. The link to keep it (`claim_url`)
|
|
7
|
-
// is for the person: opened signed in, it makes the trial theirs.
|
|
8
|
-
//
|
|
9
|
-
// Keeping it hands this machine nothing. The key answers `409 trial_claimed`
|
|
10
|
-
// from then on, naming the workspace the trial became, and the next command
|
|
11
|
-
// signs this terminal in with a device code like `vatio login` does
|
|
12
|
-
// (keepClaimedTrial). A link that sent a token back here would send one to
|
|
13
|
-
// whoever made the trial and got someone else to open its link.
|
|
14
|
-
|
|
15
|
-
import { MANIFEST_FILE, rewriteWorkspaceSlug, workspaceSlug } from "./workspace.mjs";
|
|
16
|
-
import { HttpError, throwIfOutdated } from "./http.mjs";
|
|
17
|
-
import { clientHeaders } from "./telemetry.mjs";
|
|
18
|
-
import { deviceLogin } from "./commands/auth.mjs";
|
|
19
|
-
|
|
20
|
-
// Asks for a trial, and remembers it for this directory. `requested` is the
|
|
21
|
-
// slug vatio.yml names, which the trial takes when it is kept if it is free.
|
|
22
|
-
export async function startTrial(config, requested) {
|
|
23
|
-
const baseUrl = config.resolveBaseUrl();
|
|
24
|
-
const url = `${baseUrl}/api/developer/v1/trials`;
|
|
25
|
-
let response;
|
|
26
|
-
try {
|
|
27
|
-
response = await fetch(url, {
|
|
28
|
-
method: "POST",
|
|
29
|
-
headers: { ...clientHeaders(), "Content-Type": "application/json", Accept: "application/json" },
|
|
30
|
-
body: JSON.stringify({ workspace: requested }),
|
|
31
|
-
signal: AbortSignal.timeout(30_000)
|
|
32
|
-
});
|
|
33
|
-
} catch (error) {
|
|
34
|
-
const reason = error?.cause?.code ?? error?.name ?? "request failed";
|
|
35
|
-
throw new HttpError(`${reason}: ${url}`);
|
|
36
|
-
}
|
|
37
|
-
await throwIfOutdated(response);
|
|
38
|
-
|
|
39
|
-
const raw = await response.text();
|
|
40
|
-
let body;
|
|
41
|
-
try {
|
|
42
|
-
body = JSON.parse(raw);
|
|
43
|
-
} catch {
|
|
44
|
-
body = {};
|
|
45
|
-
}
|
|
46
|
-
if (response.status !== 201 || !body.trial_key || !body.workspace) {
|
|
47
|
-
const message = body.error_description ?? body.error ?? (raw.trim().slice(0, 200) || `HTTP ${response.status}`);
|
|
48
|
-
throw new HttpError(`Could not start a trial: ${message}`, {
|
|
49
|
-
status: response.status,
|
|
50
|
-
requestId: body.request_id ?? null,
|
|
51
|
-
body
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
console.log(
|
|
56
|
-
"No Vatio account on this machine, so this goes to a trial workspace. Nothing to sign up for until you keep it."
|
|
57
|
-
);
|
|
58
|
-
const trial = {
|
|
59
|
-
workspace: body.workspace,
|
|
60
|
-
requested,
|
|
61
|
-
key: body.trial_key,
|
|
62
|
-
claim_url: body.claim_url,
|
|
63
|
-
expires_at: body.expires_at
|
|
64
|
-
};
|
|
65
|
-
config.writeTrial(trial);
|
|
66
|
-
return config.trial();
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// What a push to a trial prints: the two links, what a trial cannot do, and
|
|
70
|
-
// how long it lasts.
|
|
71
|
-
export function printTrialPush(trial, payload, { started }) {
|
|
72
|
-
const where = started ? "preview" : `preview of trial ${trial.workspace}`;
|
|
73
|
-
console.log(`Pushed deployment #${payload.deployment_id} to ${where} (git_sha=${JSON.stringify(payload.git_sha ?? null)})`);
|
|
74
|
-
for (const warning of Array.isArray(payload.warnings) ? payload.warnings : []) console.log(` warning: ${warning}`);
|
|
75
|
-
console.log("");
|
|
76
|
-
printTrialLinks(trial);
|
|
77
|
-
console.log("");
|
|
78
|
-
console.log(
|
|
79
|
-
`Deleted ${formatUtc(trial.expires_at)} unless you keep it. Until then: preview only, tools make no writes, no secrets.`
|
|
80
|
-
);
|
|
81
|
-
console.log('Talk to it: vatio chat "hello" Already have an account? vatio login, then vatio push.');
|
|
82
|
-
console.log("(A coding agent running this: give the person you work for both links.)");
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export function printTrialLinks(trial) {
|
|
86
|
-
if (trial.try_url) {
|
|
87
|
-
console.log("Try it (anyone with this link can chat with it):");
|
|
88
|
-
console.log(` ${trial.try_url}`);
|
|
89
|
-
}
|
|
90
|
-
console.log("Keep it (sign in or create an account; this link makes it yours, so don't share it):");
|
|
91
|
-
console.log(` ${trial.claim_url}`);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// Someone opened the link and kept the trial since the last command: the key
|
|
95
|
-
// stopped working, and this terminal signs in to the account that kept it --
|
|
96
|
-
// with a device code its owner approves in the browser, never with anything
|
|
97
|
-
// the platform sent here. vatio.yml then names the workspace the trial became,
|
|
98
|
-
// if that is not the slug it asked for.
|
|
99
|
-
export async function keepClaimedTrial(config, error) {
|
|
100
|
-
const trial = config.trial();
|
|
101
|
-
const workspace = error.workspace;
|
|
102
|
-
const auth = await deviceLogin({
|
|
103
|
-
config,
|
|
104
|
-
baseUrl: config.resolveBaseUrl(),
|
|
105
|
-
workspace,
|
|
106
|
-
message: `You kept this agent: it is workspace ${workspace} now. Sign this terminal in to keep working on it.`
|
|
107
|
-
});
|
|
108
|
-
config.writeAuth({ baseUrl: auth.baseUrl, token: auth.token });
|
|
109
|
-
if (auth.email) console.log(`Signed in as ${auth.email}`);
|
|
110
|
-
console.log(`Token saved to ${config.configPath}`);
|
|
111
|
-
|
|
112
|
-
const root = config.workspaceRoot;
|
|
113
|
-
let current = null;
|
|
114
|
-
try {
|
|
115
|
-
current = root ? workspaceSlug(root) : null;
|
|
116
|
-
} catch {
|
|
117
|
-
current = null;
|
|
118
|
-
}
|
|
119
|
-
if (root && workspace && current !== workspace && rewriteWorkspaceSlug(root, workspace)) {
|
|
120
|
-
const why = current && current === trial?.requested ? `${current} was taken` : "the workspace you kept";
|
|
121
|
-
console.log(`${MANIFEST_FILE}: workspace ${current ?? "(none)"} → ${workspace} (${why})`);
|
|
122
|
-
}
|
|
123
|
-
config.clearTrial();
|
|
124
|
-
console.log("");
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// "Fri Oct 16 03:40 UTC": when, to the minute, in the zone every terminal shows
|
|
128
|
-
// the same.
|
|
129
|
-
export function formatUtc(iso) {
|
|
130
|
-
const date = new Date(iso);
|
|
131
|
-
if (Number.isNaN(date.getTime())) return "soon";
|
|
132
|
-
const day = date.toLocaleDateString("en-US", { weekday: "short", month: "short", day: "numeric", timeZone: "UTC" });
|
|
133
|
-
const time = date.toLocaleTimeString("en-GB", { hour: "2-digit", minute: "2-digit", timeZone: "UTC" });
|
|
134
|
-
return `${day.replace(",", "")} ${time} UTC`;
|
|
135
|
-
}
|