@answerlayer/cli 0.3.1 → 0.3.3

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/README.md CHANGED
@@ -60,15 +60,12 @@ initialize the CLI. `init` verifies the key before it writes the config file, so
60
60
  an invalid or expired key never overwrites a working local setup:
61
61
 
62
62
  ```bash
63
- answerlayer init --api-key al_live_...
63
+ answerlayer init --base-url https://answerlayer.your-company.com --api-key al_live_...
64
64
  ```
65
65
 
66
- The CLI talks to the hosted SaaS at `https://app.answerlayer.io` by default. For a
67
- BYOC or self-hosted install, point it at your own URL:
68
-
69
- ```bash
70
- answerlayer init --api-key al_live_... --base-url https://answerlayer.your-company.com
71
- ```
66
+ The CLI has no hosted network default. Pass the URL for your local, BYOC, or
67
+ self-hosted install explicitly; after initialization it is saved in the local
68
+ configuration file.
72
69
 
73
70
  The first API key is currently created in the AnswerLayer app under **Settings →
74
71
  API Keys**. A browser/device login flow is planned; until then, the CLI will tell
@@ -78,7 +75,7 @@ You can also skip the config file and use environment variables:
78
75
 
79
76
  ```bash
80
77
  export ANSWERLAYER_API_KEY=al_live_...
81
- export ANSWERLAYER_BASE_URL=https://answerlayer.your-company.com # optional override
78
+ export ANSWERLAYER_BASE_URL=https://answerlayer.your-company.com
82
79
  ```
83
80
 
84
81
  The CLI sends API keys using the `X-API-Key` header.
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@answerlayer/cli",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "Open-source command line client for the AnswerLayer API.",
5
5
  "type": "module",
6
6
  "bin": {
7
- "answerlayer": "./bin/answerlayer.js",
8
- "al": "./bin/answerlayer.js"
7
+ "answerlayer": "bin/answerlayer.js",
8
+ "al": "bin/answerlayer.js"
9
9
  },
10
10
  "files": [
11
11
  "bin",
@@ -109,8 +109,8 @@ Use whichever it prints as `AL` below. They all run identical code.
109
109
 
110
110
  ## 2. Ensure it's configured
111
111
 
112
- The CLI needs a base URL (defaults to `https://app.answerlayer.io`) and an API
113
- key sent as `X-API-Key`. Check whether credentials already exist:
112
+ The CLI needs the base URL for the user's AnswerLayer install and an API key
113
+ sent as `X-API-Key`. Check whether credentials already exist:
114
114
 
115
115
  ```bash
116
116
  AL auth me --json
@@ -119,18 +119,17 @@ AL auth me --json
119
119
  - If it returns the caller's identity, you're configured — continue to step 3.
120
120
  - If it errors with a missing-key/auth error, set credentials up:
121
121
 
122
- 1. Ask the user for their **API key**. Also ask for their **host** only if
123
- they're on a BYOC / self-hosted install; otherwise the default
124
- `https://app.answerlayer.io` is correct.
125
- 2. Configure (omit `--base-url` to accept the default):
122
+ 1. Ask the user for their **API key** and the **base URL** of their local,
123
+ BYOC, or self-hosted install.
124
+ 2. Configure:
126
125
 
127
126
  ```bash
128
- AL init --api-key <KEY> [--base-url https://answerlayer.their-host.com]
127
+ AL init --base-url https://answerlayer.their-host.com --api-key <KEY>
129
128
  ```
130
129
 
131
130
  This verifies the key before writing `~/.answerlayer/config.json` (mode
132
- 0600). Alternatively the user can export `ANSWERLAYER_API_KEY` (and
133
- optionally `ANSWERLAYER_BASE_URL`).
131
+ 0600). Alternatively the user can export `ANSWERLAYER_API_KEY` and
132
+ `ANSWERLAYER_BASE_URL`.
134
133
  3. Re-run `AL auth me --json` to confirm.
135
134
 
136
135
  **Never print, echo, or log the API key.** Pass it straight to `init`. Tell
package/src/cli.js CHANGED
@@ -83,8 +83,8 @@ function configure(parsed, io) {
83
83
  const baseUrl = firstValue(parsed.flags.baseUrl) || existing.baseUrl || DEFAULT_BASE_URL;
84
84
  const apiKey = firstValue(parsed.flags.apiKey) || existing.apiKey;
85
85
 
86
- if (!apiKey) {
87
- throw usage("configure requires --api-key (--base-url defaults to https://app.answerlayer.io)");
86
+ if (!baseUrl || !apiKey) {
87
+ throw usage("configure requires --base-url and --api-key");
88
88
  }
89
89
 
90
90
  const configPath = writeConfig({ ...existing, baseUrl, apiKey }, io.env);
package/src/client.js CHANGED
@@ -10,7 +10,7 @@ export class AnswerLayerApiError extends Error {
10
10
  export class AnswerLayerClient {
11
11
  constructor({ baseUrl, apiKey, fetchImpl = globalThis.fetch }) {
12
12
  if (!baseUrl) {
13
- throw new Error("Missing API base URL. Run `answerlayer configure --base-url <url> --api-key <key>` or set ANSWERLAYER_BASE_URL.");
13
+ throw new Error("Missing API base URL. Pass `--base-url <url>`, run `answerlayer configure --base-url <url> --api-key <key>`, or set ANSWERLAYER_BASE_URL.");
14
14
  }
15
15
 
16
16
  if (!fetchImpl) {
package/src/config.js CHANGED
@@ -2,10 +2,10 @@ import fs from "node:fs";
2
2
  import os from "node:os";
3
3
  import path from "node:path";
4
4
 
5
- // Default to the hosted AnswerLayer SaaS. Override with --base-url, the
6
- // ANSWERLAYER_BASE_URL env var, or `answerlayer configure` for BYOC /
7
- // self-hosted installs.
8
- export const DEFAULT_BASE_URL = "https://app.answerlayer.io";
5
+ // There is no network default. Every local, BYOC, or self-hosted install has
6
+ // its own endpoint, supplied through --base-url, ANSWERLAYER_BASE_URL, or the
7
+ // saved configuration.
8
+ export const DEFAULT_BASE_URL = null;
9
9
 
10
10
  export function defaultConfigPath(env = process.env) {
11
11
  return env.ANSWERLAYER_CONFIG || path.join(os.homedir(), ".answerlayer", "config.json");