@haven_ai/cli 0.0.0-dev.202609251338.80a72cc → 0.0.0-dev.202609251630.f6bd8a6
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/cli.cjs +6 -3
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +6 -3
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +6 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -23,13 +23,19 @@ interface CreateCliApiOptions {
|
|
|
23
23
|
baseUrl: string;
|
|
24
24
|
token?: string;
|
|
25
25
|
fetchImpl?: typeof fetch;
|
|
26
|
+
/**
|
|
27
|
+
* #3303: `@haven_ai/cli/<version>`, sent as `X-Haven-Client` so the backend
|
|
28
|
+
* can tell an outdated CLI what to run. Passed in by `commands.ts`, which
|
|
29
|
+
* owns `CLI_VERSION`, rather than imported here (commands.ts imports this file).
|
|
30
|
+
*/
|
|
31
|
+
clientIdentity?: string;
|
|
26
32
|
}
|
|
27
33
|
/**
|
|
28
34
|
* Minimal JSON client for the Haven backend. Sends the user JWT as a Bearer
|
|
29
35
|
* token when present, and surfaces backend `{ error }` messages as
|
|
30
36
|
* `CliApiError` so commands can print something human.
|
|
31
37
|
*/
|
|
32
|
-
declare function createCliApi({ baseUrl, token, fetchImpl }: CreateCliApiOptions): CliApi;
|
|
38
|
+
declare function createCliApi({ baseUrl, token, fetchImpl, clientIdentity }: CreateCliApiOptions): CliApi;
|
|
33
39
|
|
|
34
40
|
/**
|
|
35
41
|
* The signed-in user session. The token is a *user* JWT (same credential the
|
package/dist/index.d.ts
CHANGED
|
@@ -23,13 +23,19 @@ interface CreateCliApiOptions {
|
|
|
23
23
|
baseUrl: string;
|
|
24
24
|
token?: string;
|
|
25
25
|
fetchImpl?: typeof fetch;
|
|
26
|
+
/**
|
|
27
|
+
* #3303: `@haven_ai/cli/<version>`, sent as `X-Haven-Client` so the backend
|
|
28
|
+
* can tell an outdated CLI what to run. Passed in by `commands.ts`, which
|
|
29
|
+
* owns `CLI_VERSION`, rather than imported here (commands.ts imports this file).
|
|
30
|
+
*/
|
|
31
|
+
clientIdentity?: string;
|
|
26
32
|
}
|
|
27
33
|
/**
|
|
28
34
|
* Minimal JSON client for the Haven backend. Sends the user JWT as a Bearer
|
|
29
35
|
* token when present, and surfaces backend `{ error }` messages as
|
|
30
36
|
* `CliApiError` so commands can print something human.
|
|
31
37
|
*/
|
|
32
|
-
declare function createCliApi({ baseUrl, token, fetchImpl }: CreateCliApiOptions): CliApi;
|
|
38
|
+
declare function createCliApi({ baseUrl, token, fetchImpl, clientIdentity }: CreateCliApiOptions): CliApi;
|
|
33
39
|
|
|
34
40
|
/**
|
|
35
41
|
* The signed-in user session. The token is a *user* JWT (same credential the
|
package/dist/index.js
CHANGED
|
@@ -197,11 +197,12 @@ var CliApiError = class extends Error {
|
|
|
197
197
|
this.body = body;
|
|
198
198
|
}
|
|
199
199
|
};
|
|
200
|
-
function createCliApi({ baseUrl, token, fetchImpl = fetch }) {
|
|
200
|
+
function createCliApi({ baseUrl, token, fetchImpl = fetch, clientIdentity }) {
|
|
201
201
|
const root = baseUrl.replace(/\/+$/, "");
|
|
202
202
|
async function request(method, path, body) {
|
|
203
203
|
const headers = { Accept: "application/json" };
|
|
204
204
|
if (token) headers.Authorization = `Bearer ${token}`;
|
|
205
|
+
if (clientIdentity) headers["X-Haven-Client"] = clientIdentity;
|
|
205
206
|
if (body !== void 0) headers["Content-Type"] = "application/json";
|
|
206
207
|
let res;
|
|
207
208
|
try {
|
|
@@ -230,6 +231,7 @@ function createCliApi({ baseUrl, token, fetchImpl = fetch }) {
|
|
|
230
231
|
async function requestText(path) {
|
|
231
232
|
const headers = { Accept: "text/plain" };
|
|
232
233
|
if (token) headers.Authorization = `Bearer ${token}`;
|
|
234
|
+
if (clientIdentity) headers["X-Haven-Client"] = clientIdentity;
|
|
233
235
|
let res;
|
|
234
236
|
try {
|
|
235
237
|
res = await fetchImpl(`${root}${path}`, { method: "GET", headers });
|
|
@@ -601,7 +603,8 @@ async function runConnector(connectorCommand, spawner, onStderr) {
|
|
|
601
603
|
|
|
602
604
|
// src/commands.ts
|
|
603
605
|
var DEFAULT_API = "https://havenbackend-production-8a00.up.railway.app";
|
|
604
|
-
var CLI_VERSION = "0.0.0-dev.
|
|
606
|
+
var CLI_VERSION = "0.0.0-dev.202609251630.f6bd8a6";
|
|
607
|
+
var CLI_CLIENT_IDENTITY = `@haven_ai/cli/${CLI_VERSION}`;
|
|
605
608
|
function accountAddressOf(s) {
|
|
606
609
|
return s.account_address ?? "";
|
|
607
610
|
}
|
|
@@ -614,7 +617,7 @@ async function run(argv, deps = {}) {
|
|
|
614
617
|
const o = createOutput(json, out, err);
|
|
615
618
|
const d = {
|
|
616
619
|
sessionStore: deps.sessionStore ?? createSessionStore(),
|
|
617
|
-
makeApi: deps.makeApi ?? ((baseUrl, token) => createCliApi({ baseUrl, token })),
|
|
620
|
+
makeApi: deps.makeApi ?? ((baseUrl, token) => createCliApi({ baseUrl, token, clientIdentity: CLI_CLIENT_IDENTITY })),
|
|
618
621
|
promptPassword: deps.promptPassword ?? (() => Promise.reject(new Error("No password input available"))),
|
|
619
622
|
sleep: deps.sleep ?? ((ms) => new Promise((resolve2) => setTimeout(resolve2, ms))),
|
|
620
623
|
spawner: deps.spawner ?? nodeSpawner,
|