@flatkey-ai/cli 0.2.1 → 0.2.2
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/package.json +1 -1
- package/src/api.js +3 -1
- package/src/artifacts.js +3 -1
- package/src/cli.js +2 -0
- package/src/requestHeaders.js +10 -0
package/package.json
CHANGED
package/src/api.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { withCliRequestHeaders } from "./requestHeaders.js";
|
|
2
|
+
|
|
1
3
|
export const DEFAULT_BASE_URL = "https://router.flatkey.ai";
|
|
2
4
|
export const DEFAULT_MODELS_BASE_URL = "https://console.flatkey.ai";
|
|
3
5
|
export const DEFAULT_CONSOLE_URL = "https://console.flatkey.ai";
|
|
@@ -231,7 +233,7 @@ function planRequest(options, path, init = {}) {
|
|
|
231
233
|
return {
|
|
232
234
|
url: buildUrl(options.baseUrl, path),
|
|
233
235
|
method: init.method ?? "GET",
|
|
234
|
-
headers: init.headers ?? authHeaders(options.apiKey),
|
|
236
|
+
headers: withCliRequestHeaders(init.headers ?? authHeaders(options.apiKey)),
|
|
235
237
|
body: init.body,
|
|
236
238
|
};
|
|
237
239
|
}
|
package/src/artifacts.js
CHANGED
|
@@ -2,6 +2,8 @@ import { mkdir, writeFile } from "node:fs/promises";
|
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
3
|
import { dirname, extname, join } from "node:path";
|
|
4
4
|
|
|
5
|
+
import { CLI_REQUEST_HEADERS } from "./requestHeaders.js";
|
|
6
|
+
|
|
5
7
|
const DEFAULT_EXTENSIONS = {
|
|
6
8
|
audio: "mp3",
|
|
7
9
|
image: "png",
|
|
@@ -80,7 +82,7 @@ async function persistItem({ kind, item, outDir, output, index, fetchImpl }) {
|
|
|
80
82
|
}
|
|
81
83
|
|
|
82
84
|
async function downloadArtifact({ url, path, fetchImpl }) {
|
|
83
|
-
const response = await fetchImpl(url);
|
|
85
|
+
const response = await fetchImpl(url, { headers: CLI_REQUEST_HEADERS });
|
|
84
86
|
if (!response.ok) {
|
|
85
87
|
throw new Error(`Failed to download artifact ${url}: HTTP ${response.status}`);
|
|
86
88
|
}
|
package/src/cli.js
CHANGED
|
@@ -1051,9 +1051,11 @@ async function maybeWriteUpdateNotice(command, deps = {}) {
|
|
|
1051
1051
|
}
|
|
1052
1052
|
|
|
1053
1053
|
async function fetchLatestPackageVersion(deps = {}) {
|
|
1054
|
+
const { CLI_REQUEST_HEADERS } = await import("./requestHeaders.js");
|
|
1054
1055
|
const fetchImpl = deps.fetch ?? globalThis.fetch;
|
|
1055
1056
|
if (typeof fetchImpl !== "function") return undefined;
|
|
1056
1057
|
const response = await fetchImpl("https://registry.npmjs.org/@flatkey-ai%2fcli/latest", {
|
|
1058
|
+
headers: CLI_REQUEST_HEADERS,
|
|
1057
1059
|
signal: typeof AbortSignal !== "undefined" && typeof AbortSignal.timeout === "function"
|
|
1058
1060
|
? AbortSignal.timeout(750)
|
|
1059
1061
|
: undefined,
|