@haven_ai/cli 0.4.0-alpha.0 → 0.5.0-alpha.1

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.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
@@ -138,6 +138,7 @@ function helpText() {
138
138
  " budget show <agentId> --hashes Its delegation hashes \u2014 the second",
139
139
  " argument `budget revoke` takes, printed nowhere else",
140
140
  " activity list [--safe <id|address>] [--agent <id>] [--direction in|out] [--limit <n>] [--offset <n>]",
141
+ " Wallet-scoped history; --agent narrows it (--json rows carry scope, timestampSource)",
141
142
  " activity export [filters] Emit CSV to stdout (--format csv, default)",
142
143
  " activity export --format sie [--from <ISO>] [--to <ISO>] [--company <name>]",
143
144
  " Bookkeeping-ready SIE 4I (Fortnox/Visma/Bokio)",
@@ -196,11 +197,12 @@ var CliApiError = class extends Error {
196
197
  this.body = body;
197
198
  }
198
199
  };
199
- function createCliApi({ baseUrl, token, fetchImpl = fetch }) {
200
+ function createCliApi({ baseUrl, token, fetchImpl = fetch, clientIdentity }) {
200
201
  const root = baseUrl.replace(/\/+$/, "");
201
202
  async function request(method, path, body) {
202
203
  const headers = { Accept: "application/json" };
203
204
  if (token) headers.Authorization = `Bearer ${token}`;
205
+ if (clientIdentity) headers["X-Haven-Client"] = clientIdentity;
204
206
  if (body !== void 0) headers["Content-Type"] = "application/json";
205
207
  let res;
206
208
  try {
@@ -229,6 +231,7 @@ function createCliApi({ baseUrl, token, fetchImpl = fetch }) {
229
231
  async function requestText(path) {
230
232
  const headers = { Accept: "text/plain" };
231
233
  if (token) headers.Authorization = `Bearer ${token}`;
234
+ if (clientIdentity) headers["X-Haven-Client"] = clientIdentity;
232
235
  let res;
233
236
  try {
234
237
  res = await fetchImpl(`${root}${path}`, { method: "GET", headers });
@@ -600,7 +603,8 @@ async function runConnector(connectorCommand, spawner, onStderr) {
600
603
 
601
604
  // src/commands.ts
602
605
  var DEFAULT_API = "https://havenbackend-production-8a00.up.railway.app";
603
- var CLI_VERSION = "0.4.0-alpha.0";
606
+ var CLI_VERSION = "0.5.0-alpha.1";
607
+ var CLI_CLIENT_IDENTITY = `@haven_ai/cli/${CLI_VERSION}`;
604
608
  function accountAddressOf(s) {
605
609
  return s.account_address ?? "";
606
610
  }
@@ -613,7 +617,7 @@ async function run(argv, deps = {}) {
613
617
  const o = createOutput(json, out, err);
614
618
  const d = {
615
619
  sessionStore: deps.sessionStore ?? createSessionStore(),
616
- makeApi: deps.makeApi ?? ((baseUrl, token) => createCliApi({ baseUrl, token })),
620
+ makeApi: deps.makeApi ?? ((baseUrl, token) => createCliApi({ baseUrl, token, clientIdentity: CLI_CLIENT_IDENTITY })),
617
621
  promptPassword: deps.promptPassword ?? (() => Promise.reject(new Error("No password input available"))),
618
622
  sleep: deps.sleep ?? ((ms) => new Promise((resolve2) => setTimeout(resolve2, ms))),
619
623
  spawner: deps.spawner ?? nodeSpawner,