trajectories-sh 1.14.0 → 1.16.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/dist/{auth-UD3KTSHK.js → auth-4UEZSE4C.js} +1 -1
- package/dist/{chunk-P6J5X7LP.js → chunk-Q2ZEN43L.js} +5 -0
- package/dist/cli.js +35 -27
- package/dist/{config-NOIAMV2U.js → config-4XJRECIW.js} +1 -1
- package/dist/{download-O3JONHXT.js → download-HTNOD7O4.js} +1 -1
- package/dist/{push-task-PUGFXEBK.js → push-task-IZZNF3ZA.js} +1 -1
- package/dist/{upload-DKXZOGUF.js → upload-C2LTKXS2.js} +2 -2
- package/package.json +1 -1
|
@@ -29,6 +29,8 @@ function getAccessToken() {
|
|
|
29
29
|
return loadConfig().access_token;
|
|
30
30
|
}
|
|
31
31
|
async function getAuthHeader() {
|
|
32
|
+
const envKey = process.env.TRAJECTORIES_API_KEY;
|
|
33
|
+
if (envKey && envKey.trim()) return `Bearer ${envKey.trim()}`;
|
|
32
34
|
const config = loadConfig();
|
|
33
35
|
if (config.api_key) return `Bearer ${config.api_key}`;
|
|
34
36
|
if (config.access_token && config.refresh_token) {
|
|
@@ -99,6 +101,9 @@ function clearAuth() {
|
|
|
99
101
|
if (existsSync(CONFIG_FILE)) unlinkSync(CONFIG_FILE);
|
|
100
102
|
}
|
|
101
103
|
function isLoggedIn() {
|
|
104
|
+
if (process.env.TRAJECTORIES_API_KEY && process.env.TRAJECTORIES_API_KEY.trim()) {
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
102
107
|
const config = loadConfig();
|
|
103
108
|
return !!(config.api_key || config.access_token);
|
|
104
109
|
}
|
package/dist/cli.js
CHANGED
|
@@ -21,7 +21,7 @@ auth.command("login").description("Log in to trajectories.sh via your browser").
|
|
|
21
21
|
if (opts.apiKey) {
|
|
22
22
|
const spinner = ora("Validating API key...").start();
|
|
23
23
|
try {
|
|
24
|
-
const { loginWithApiKey } = await import("./auth-
|
|
24
|
+
const { loginWithApiKey } = await import("./auth-4UEZSE4C.js");
|
|
25
25
|
await loginWithApiKey(opts.apiKey);
|
|
26
26
|
spinner.succeed("Logged in with API key");
|
|
27
27
|
} catch (e) {
|
|
@@ -33,7 +33,7 @@ auth.command("login").description("Log in to trajectories.sh via your browser").
|
|
|
33
33
|
console.log(chalk.bold("\n Opening browser to log in...\n"));
|
|
34
34
|
console.log(chalk.dim(" If the browser doesn't open, visit:"));
|
|
35
35
|
try {
|
|
36
|
-
const { loginWithBrowser } = await import("./auth-
|
|
36
|
+
const { loginWithBrowser } = await import("./auth-4UEZSE4C.js");
|
|
37
37
|
const { email } = await loginWithBrowser();
|
|
38
38
|
console.log(chalk.green(`
|
|
39
39
|
\u2713 Logged in as ${email}
|
|
@@ -48,13 +48,13 @@ auth.command("login").description("Log in to trajectories.sh via your browser").
|
|
|
48
48
|
});
|
|
49
49
|
auth.command("logout").description("Log out and remove saved credentials").action(async () => {
|
|
50
50
|
const chalk = (await import("chalk")).default;
|
|
51
|
-
const { logout } = await import("./auth-
|
|
51
|
+
const { logout } = await import("./auth-4UEZSE4C.js");
|
|
52
52
|
logout();
|
|
53
53
|
console.log(chalk.green(" \u2713 Logged out. Credentials removed."));
|
|
54
54
|
});
|
|
55
55
|
auth.command("status").description("Show current authentication status").action(async () => {
|
|
56
56
|
const chalk = (await import("chalk")).default;
|
|
57
|
-
const { status } = await import("./auth-
|
|
57
|
+
const { status } = await import("./auth-4UEZSE4C.js");
|
|
58
58
|
const s = status();
|
|
59
59
|
if (s.loggedIn) {
|
|
60
60
|
console.log(chalk.green(" \u2713 Authenticated"));
|
|
@@ -71,29 +71,34 @@ async function uploadTrajectoryAction(directory, opts) {
|
|
|
71
71
|
console.error(chalk.red(` \u2717 Directory not found: ${directory}`));
|
|
72
72
|
process.exit(1);
|
|
73
73
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
console.error(chalk.red(" \u2717 Not authenticated. Run: trajectories auth login"));
|
|
77
|
-
process.exit(1);
|
|
74
|
+
if (opts.apiKey) {
|
|
75
|
+
process.env.TRAJECTORIES_API_KEY = String(opts.apiKey);
|
|
78
76
|
}
|
|
79
|
-
|
|
77
|
+
const { isLoggedIn } = await import("./config-4XJRECIW.js");
|
|
78
|
+
if (!isLoggedIn()) {
|
|
80
79
|
console.error(
|
|
81
80
|
chalk.red(
|
|
82
|
-
" \u2717
|
|
81
|
+
" \u2717 Not authenticated.\n Pass --api-key YOUR_KEY, set TRAJECTORIES_API_KEY in your env,\n or run: trajectories auth login"
|
|
83
82
|
)
|
|
84
83
|
);
|
|
85
84
|
process.exit(1);
|
|
86
85
|
}
|
|
86
|
+
if (opts.visibility) {
|
|
87
|
+
console.warn(
|
|
88
|
+
chalk.yellow(
|
|
89
|
+
" \u26A0 --visibility is deprecated and ignored \u2014 every upload is now unlisted.\n Change visibility from the trajectory page on trajectories.sh after upload."
|
|
90
|
+
)
|
|
91
|
+
);
|
|
92
|
+
}
|
|
87
93
|
const slug = opts.slug ?? directory.replace(/\/+$/, "").split("/").pop();
|
|
88
94
|
console.log(chalk.bold(`
|
|
89
95
|
Uploading trajectory ${directory} \u2192 ${chalk.cyan(slug)}
|
|
90
96
|
`));
|
|
91
97
|
try {
|
|
92
|
-
const { uploadJob } = await import("./upload-
|
|
98
|
+
const { uploadJob } = await import("./upload-C2LTKXS2.js");
|
|
93
99
|
const result = await uploadJob(directory, {
|
|
94
100
|
slug,
|
|
95
|
-
name: opts.name
|
|
96
|
-
visibility: opts.visibility
|
|
101
|
+
name: opts.name
|
|
97
102
|
});
|
|
98
103
|
console.log(chalk.green.bold("\n \u2713 Uploaded successfully!"));
|
|
99
104
|
console.log(` Trials: ${result.nTrials}`);
|
|
@@ -119,9 +124,16 @@ async function uploadTaskAction(directory, opts) {
|
|
|
119
124
|
console.error(chalk.red(` \u2717 Directory not found: ${directory}`));
|
|
120
125
|
process.exit(1);
|
|
121
126
|
}
|
|
122
|
-
|
|
127
|
+
if (opts.apiKey) {
|
|
128
|
+
process.env.TRAJECTORIES_API_KEY = String(opts.apiKey);
|
|
129
|
+
}
|
|
130
|
+
const { isLoggedIn } = await import("./config-4XJRECIW.js");
|
|
123
131
|
if (!isLoggedIn()) {
|
|
124
|
-
console.error(
|
|
132
|
+
console.error(
|
|
133
|
+
chalk.red(
|
|
134
|
+
" \u2717 Not authenticated.\n Pass --api-key YOUR_KEY, set TRAJECTORIES_API_KEY in your env,\n or run: trajectories auth login"
|
|
135
|
+
)
|
|
136
|
+
);
|
|
125
137
|
process.exit(1);
|
|
126
138
|
}
|
|
127
139
|
const name = opts.name ?? directory.replace(/\/+$/, "").split("/").pop();
|
|
@@ -129,7 +141,7 @@ async function uploadTaskAction(directory, opts) {
|
|
|
129
141
|
Uploading task ${directory} \u2192 ${chalk.cyan(name)}
|
|
130
142
|
`));
|
|
131
143
|
try {
|
|
132
|
-
const { pushTask } = await import("./push-task-
|
|
144
|
+
const { pushTask } = await import("./push-task-IZZNF3ZA.js");
|
|
133
145
|
const result = await pushTask(directory, {
|
|
134
146
|
name: opts.name,
|
|
135
147
|
visibility: opts.visibility
|
|
@@ -156,7 +168,7 @@ async function downloadTrajectoryAction(url, opts) {
|
|
|
156
168
|
Downloading trajectory...
|
|
157
169
|
`));
|
|
158
170
|
try {
|
|
159
|
-
const { downloadJob, parseJobId } = await import("./download-
|
|
171
|
+
const { downloadJob, parseJobId } = await import("./download-HTNOD7O4.js");
|
|
160
172
|
const outputDir = opts.output ?? parseJobId(url).replace(/^org:/, "").replace(/:/g, "-");
|
|
161
173
|
const result = await downloadJob(url, outputDir);
|
|
162
174
|
console.log(chalk.green.bold(` \u2713 Downloaded ${result.files} files`));
|
|
@@ -172,8 +184,8 @@ async function downloadTrajectoryAction(url, opts) {
|
|
|
172
184
|
}
|
|
173
185
|
async function deleteTrajectoryAction(url, opts) {
|
|
174
186
|
const chalk = (await import("chalk")).default;
|
|
175
|
-
const { parseJobId } = await import("./download-
|
|
176
|
-
const { getApiUrl, getAuthHeader } = await import("./config-
|
|
187
|
+
const { parseJobId } = await import("./download-HTNOD7O4.js");
|
|
188
|
+
const { getApiUrl, getAuthHeader } = await import("./config-4XJRECIW.js");
|
|
177
189
|
let jobId = parseJobId(url);
|
|
178
190
|
if (jobId.startsWith("org:")) {
|
|
179
191
|
console.error(chalk.red("\n \u2717 Please use a direct job URL or UUID for deletion.\n"));
|
|
@@ -230,20 +242,16 @@ async function deleteTrajectoryAction(url, opts) {
|
|
|
230
242
|
}
|
|
231
243
|
}
|
|
232
244
|
var upload = program.command("upload").description("Upload trajectories or tasks");
|
|
233
|
-
upload.command("trajectory <directory>").description("Upload a trajectory job directory").option("-s, --slug <slug>", "URL slug (default: directory name)").option("-n, --name <name>", "Display name (default: slug)").option(
|
|
234
|
-
|
|
235
|
-
"unlisted or private (use the UI to flip a trajectory to public after upload)",
|
|
236
|
-
"private"
|
|
237
|
-
).action(uploadTrajectoryAction);
|
|
238
|
-
upload.command("task <directory>").description("Upload a benchmark task directory").option("-n, --name <name>", "Task name (default: directory name)").option("-v, --visibility <vis>", "public or private", "public").action(uploadTaskAction);
|
|
245
|
+
upload.command("trajectory <directory>").description("Upload a trajectory job directory (always uploaded as unlisted)").option("-s, --slug <slug>", "URL slug (default: directory name)").option("-n, --name <name>", "Display name (default: slug)").option("--api-key <key>", "API key (or set TRAJECTORIES_API_KEY in your env)").option("-v, --visibility <vis>", "(deprecated, ignored \u2014 set visibility in the UI)").action(uploadTrajectoryAction);
|
|
246
|
+
upload.command("task <directory>").description("Upload a benchmark task directory").option("-n, --name <name>", "Task name (default: directory name)").option("--api-key <key>", "API key (or set TRAJECTORIES_API_KEY in your env)").option("-v, --visibility <vis>", "public or private", "public").action(uploadTaskAction);
|
|
239
247
|
var download = program.command("download").description("Download trajectories");
|
|
240
248
|
download.command("trajectory <url>").description("Download a trajectory job from trajectories.sh").option("-o, --output <dir>", "Output directory (default: slug name)").action(downloadTrajectoryAction);
|
|
241
249
|
var del = program.command("delete").description("Delete trajectories");
|
|
242
250
|
del.command("trajectory <url>").description("Delete a trajectory job from trajectories.sh").option("-y, --yes", "Skip confirmation prompt").action(deleteTrajectoryAction);
|
|
243
251
|
program.command("whoami").description("Show current authentication status").action(async () => {
|
|
244
252
|
const chalk = (await import("chalk")).default;
|
|
245
|
-
const { status } = await import("./auth-
|
|
246
|
-
const { getApiUrl } = await import("./config-
|
|
253
|
+
const { status } = await import("./auth-4UEZSE4C.js");
|
|
254
|
+
const { getApiUrl } = await import("./config-4XJRECIW.js");
|
|
247
255
|
const s = status();
|
|
248
256
|
if (s.loggedIn) {
|
|
249
257
|
console.log(chalk.green(" \u2713 Authenticated"));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getApiUrl,
|
|
3
3
|
getAuthHeader
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-Q2ZEN43L.js";
|
|
5
5
|
|
|
6
6
|
// src/upload.ts
|
|
7
7
|
import { readdirSync, statSync, readFileSync, writeFileSync, mkdirSync, copyFileSync, unlinkSync } from "fs";
|
|
@@ -295,7 +295,7 @@ function validateAtifFormat(dir) {
|
|
|
295
295
|
async function uploadJob(dir, opts) {
|
|
296
296
|
const slug = opts.slug ?? dir.replace(/\/+$/, "").split("/").pop();
|
|
297
297
|
const name = opts.name ?? slug;
|
|
298
|
-
const visibility =
|
|
298
|
+
const visibility = "unlisted";
|
|
299
299
|
const validationErrors = validateAtifFormat(dir);
|
|
300
300
|
if (validationErrors.length > 0) {
|
|
301
301
|
throw new Error(
|