@erdoai/cli 0.31.0 → 0.32.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/index.js +37 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -180,10 +180,13 @@ function looksLikeHTML(text) {
|
|
|
180
180
|
function fetchMe(token, orgId) {
|
|
181
181
|
return rawRequest(resolveApiUrl(), token, orgId, "GET", "/v1/me");
|
|
182
182
|
}
|
|
183
|
+
var announcedOrg = false;
|
|
183
184
|
var ErdoClient = class {
|
|
184
185
|
baseURL;
|
|
185
186
|
token;
|
|
186
187
|
orgId;
|
|
188
|
+
orgPinned;
|
|
189
|
+
orgName;
|
|
187
190
|
constructor(orgOverride) {
|
|
188
191
|
this.baseURL = resolveApiUrl();
|
|
189
192
|
const acct = activeAccount();
|
|
@@ -193,8 +196,27 @@ var ErdoClient = class {
|
|
|
193
196
|
}
|
|
194
197
|
this.token = token;
|
|
195
198
|
this.orgId = resolveOrgId(acct, orgOverride);
|
|
199
|
+
this.orgPinned = Boolean(orgOverride || process.env.ERDO_ORG);
|
|
200
|
+
this.orgName = acct?.organizationName;
|
|
201
|
+
}
|
|
202
|
+
announceOrgOnce(method) {
|
|
203
|
+
if (announcedOrg) return;
|
|
204
|
+
if (method.toUpperCase() === "GET") return;
|
|
205
|
+
announcedOrg = true;
|
|
206
|
+
if (this.orgPinned && this.orgId) {
|
|
207
|
+
process.stderr.write(`org: ${this.orgId} (pinned)
|
|
208
|
+
`);
|
|
209
|
+
} else if (this.orgId) {
|
|
210
|
+
process.stderr.write(
|
|
211
|
+
`org: ${this.orgName ?? this.orgId} (active org \u2014 pass --org to pin)
|
|
212
|
+
`
|
|
213
|
+
);
|
|
214
|
+
} else {
|
|
215
|
+
process.stderr.write("org: token default (no org resolved \u2014 pass --org to pin)\n");
|
|
216
|
+
}
|
|
196
217
|
}
|
|
197
218
|
request(method, path, body) {
|
|
219
|
+
this.announceOrgOnce(method);
|
|
198
220
|
return rawRequest(this.baseURL, this.token, this.orgId, method, path, body);
|
|
199
221
|
}
|
|
200
222
|
me() {
|
|
@@ -1825,6 +1847,19 @@ evalCmd.command("create <name>").description("Create a suite (in the active org)
|
|
|
1825
1847
|
evalCmd.command("run <slug>").description("Run a suite; --watch polls until it completes").option("-w, --watch", "poll until the run finishes and print results").option("-c, --concurrency <n>", "parallel cases", (v) => parseInt(v, 10)).action(async (slug, opts) => {
|
|
1826
1848
|
try {
|
|
1827
1849
|
const api = new ErdoClient();
|
|
1850
|
+
const { suite } = await api.getEvalSuite(slug);
|
|
1851
|
+
if (suite.evaluate_artifact && !process.env.ERDO_ORG) {
|
|
1852
|
+
const resolved = resolveOrgId(activeAccount()) ?? "<org>";
|
|
1853
|
+
console.error(
|
|
1854
|
+
[
|
|
1855
|
+
`Refusing to run "${slug}": it builds real artifacts in the resolved org.`,
|
|
1856
|
+
"The active org is machine-global \u2014 a concurrent session can switch it, so this",
|
|
1857
|
+
"run could land in the wrong org. Re-run with the org pinned:",
|
|
1858
|
+
` erdo --org ${resolved} eval run ${slug}`
|
|
1859
|
+
].join("\n")
|
|
1860
|
+
);
|
|
1861
|
+
process.exit(1);
|
|
1862
|
+
}
|
|
1828
1863
|
const { run_id } = await api.runEvalSuite(slug, opts.concurrency);
|
|
1829
1864
|
console.log(`run_id: ${run_id}`);
|
|
1830
1865
|
if (!opts.watch) return;
|
|
@@ -2066,8 +2101,9 @@ approvalsCmd.command("list").description("List approval requests, optionally fil
|
|
|
2066
2101
|
return;
|
|
2067
2102
|
}
|
|
2068
2103
|
for (const r of res.requests) {
|
|
2104
|
+
const occ = r.occurrence_count && r.occurrence_count > 1 ? ` \xD7${r.occurrence_count}` : "";
|
|
2069
2105
|
console.log(
|
|
2070
|
-
`${r.id} ${r.status} ${r.action_key} ${r.action_display} ${r.created_at}`
|
|
2106
|
+
`${r.id} ${r.status} ${r.action_key} ${r.action_display} ${r.created_at}${occ}`
|
|
2071
2107
|
);
|
|
2072
2108
|
}
|
|
2073
2109
|
} catch (e) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@erdoai/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Erdo CLI
|
|
3
|
+
"version": "0.32.0",
|
|
4
|
+
"description": "Erdo CLI — drive datasets, pages, and evals from the terminal or CI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"erdo": "dist/index.js"
|