@answerlayer/cli 0.3.2 → 0.3.4
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 +5 -8
- package/package.json +1 -1
- package/skills/answerlayer/SKILL.md +8 -9
- package/src/cli.js +4 -4
- package/src/client.js +1 -1
- package/src/config.js +4 -4
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
|
|
67
|
-
|
|
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
|
|
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
|
@@ -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
|
|
113
|
-
|
|
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
|
|
123
|
-
|
|
124
|
-
|
|
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 --
|
|
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`
|
|
133
|
-
|
|
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 --
|
|
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);
|
|
@@ -1275,8 +1275,8 @@ async function handleOptimization(client, command, positionals, parsed, io) {
|
|
|
1275
1275
|
budget: {
|
|
1276
1276
|
max_iterations: numberFlag(parsed.flags.maxIterations, 3),
|
|
1277
1277
|
max_proposals: numberFlag(parsed.flags.maxProposals, 10),
|
|
1278
|
-
max_input_tokens: numberFlag(parsed.flags.maxInputTokens
|
|
1279
|
-
max_output_tokens: numberFlag(parsed.flags.maxOutputTokens
|
|
1278
|
+
max_input_tokens: numberFlag(parsed.flags.maxInputTokens),
|
|
1279
|
+
max_output_tokens: numberFlag(parsed.flags.maxOutputTokens),
|
|
1280
1280
|
max_sql_queries: numberFlag(parsed.flags.maxSqlQueries, 500),
|
|
1281
1281
|
max_duration_seconds: numberFlag(parsed.flags.maxDuration, 7200),
|
|
1282
1282
|
max_agent_turns: parseBoundedInteger(
|
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.
|
|
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
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
export const DEFAULT_BASE_URL =
|
|
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");
|