@worldlabsai/cli 0.3.0 → 0.4.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 +20 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
|
-
import { readFileSync } from "node:fs";
|
|
5
4
|
import { parseArgs as parseArgs2 } from "node:util";
|
|
6
5
|
|
|
7
6
|
// ../client/dist/core/network-error.js
|
|
@@ -444,8 +443,18 @@ var createTasks = (transport) => ({
|
|
|
444
443
|
splats2Mesh: async (body, options) => await submitTask(transport, "/api/v2/tasks:splats2Mesh", body, options)
|
|
445
444
|
});
|
|
446
445
|
|
|
446
|
+
// ../client/dist/version.js
|
|
447
|
+
var VERSION = "0.0.0";
|
|
448
|
+
|
|
447
449
|
// ../client/dist/client.js
|
|
448
450
|
var DEFAULT_BASE_URL = "https://api.atlas-beta.worldlabs.ai";
|
|
451
|
+
var userAgentMiddleware = (callerTokens) => {
|
|
452
|
+
const node = globalThis.process?.versions?.node;
|
|
453
|
+
if (node === void 0)
|
|
454
|
+
return [];
|
|
455
|
+
const value = [callerTokens, `worldlabsai-client/${VERSION}`, `node/${node}`].filter(Boolean).join(" ");
|
|
456
|
+
return [async (request, next) => await next(withHeader(request, "User-Agent", value))];
|
|
457
|
+
};
|
|
449
458
|
var createClient = (options) => {
|
|
450
459
|
const middleware = [
|
|
451
460
|
...options.apiKey === void 0 ? [] : [apiKeyAuth(options.apiKey)],
|
|
@@ -457,7 +466,7 @@ var createClient = (options) => {
|
|
|
457
466
|
const transport = createTransport({
|
|
458
467
|
baseUrl: options.baseUrl ?? DEFAULT_BASE_URL,
|
|
459
468
|
...options.fetch ? { fetch: options.fetch } : {},
|
|
460
|
-
middleware
|
|
469
|
+
middleware: [...userAgentMiddleware(options.userAgent), ...middleware]
|
|
461
470
|
});
|
|
462
471
|
return {
|
|
463
472
|
assets: createAssets(transport, assetsPath),
|
|
@@ -600,7 +609,14 @@ async function openBrowser(url) {
|
|
|
600
609
|
});
|
|
601
610
|
}
|
|
602
611
|
|
|
612
|
+
// src/version.ts
|
|
613
|
+
import { readFileSync } from "node:fs";
|
|
614
|
+
var { version } = JSON.parse(
|
|
615
|
+
readFileSync(new URL("../package.json", import.meta.url), "utf8")
|
|
616
|
+
);
|
|
617
|
+
|
|
603
618
|
// src/auth.ts
|
|
619
|
+
var userAgent = `worldlabsai-cli/${version}`;
|
|
604
620
|
async function authenticatedClient() {
|
|
605
621
|
const { apiOrigin } = configuration();
|
|
606
622
|
let apiKey = process.env.WLT_API_KEY?.trim();
|
|
@@ -608,7 +624,7 @@ async function authenticatedClient() {
|
|
|
608
624
|
apiKey = await readApiKey(apiOrigin);
|
|
609
625
|
}
|
|
610
626
|
if (!apiKey) throw new CliError("Run worldlabs auth login or set WLT_API_KEY.");
|
|
611
|
-
return createClient({ apiKey, baseUrl: apiOrigin });
|
|
627
|
+
return createClient({ apiKey, baseUrl: apiOrigin, userAgent });
|
|
612
628
|
}
|
|
613
629
|
async function authStatus() {
|
|
614
630
|
const client = await authenticatedClient();
|
|
@@ -655,7 +671,7 @@ The key will be saved in plaintext at ${credentialPath(apiOrigin)}.
|
|
|
655
671
|
}
|
|
656
672
|
async function saveValidatedKey(apiKey) {
|
|
657
673
|
const { apiOrigin } = configuration();
|
|
658
|
-
await createClient({ apiKey, baseUrl: apiOrigin }).assets.list({
|
|
674
|
+
await createClient({ apiKey, baseUrl: apiOrigin, userAgent }).assets.list({
|
|
659
675
|
pageSize: 1,
|
|
660
676
|
signal: AbortSignal.timeout(3e4)
|
|
661
677
|
});
|
|
@@ -1084,9 +1100,6 @@ async function setup(client, noBrowser, yes = false, keyFromStdin = false) {
|
|
|
1084
1100
|
}
|
|
1085
1101
|
|
|
1086
1102
|
// src/index.ts
|
|
1087
|
-
var { version } = JSON.parse(
|
|
1088
|
-
readFileSync(new URL("../package.json", import.meta.url), "utf8")
|
|
1089
|
-
);
|
|
1090
1103
|
var help = `worldlabs - World Labs Developer API CLI
|
|
1091
1104
|
|
|
1092
1105
|
Usage: worldlabs [--json] <command>
|