@answerlayer/cli 0.1.11 → 0.1.13
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 +32 -1
- package/package.json +1 -1
- package/skills/answerlayer/SKILL.md +22 -41
- package/src/cli.js +4 -1
- package/src/local.js +198 -2
package/README.md
CHANGED
|
@@ -97,7 +97,37 @@ This installs to `~/.codex/skills/answerlayer` by default. Use `--path` for a
|
|
|
97
97
|
different skill directory; an existing skill is never replaced unless you pass
|
|
98
98
|
`--force`.
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
The recommended path is one command:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
answerlayer local quickstart
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Quickstart asks for confirmation before it changes local state, then initializes
|
|
107
|
+
and starts the supported public-image runtime, authenticates the CLI, installs
|
|
108
|
+
the deterministic demo, and verifies the provider-free demo query. If no model
|
|
109
|
+
provider is configured, it stops with a safe handoff:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
answerlayer local provider set anthropic
|
|
113
|
+
answerlayer local quickstart
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
The provider command must be run privately in the user's own terminal. The
|
|
117
|
+
resumed quickstart verifies the provider and runs one real model-backed inquiry
|
|
118
|
+
against the demo. Successful inquiry details are retained in the local runtime
|
|
119
|
+
state, so repeating quickstart reuses the verified session instead of creating
|
|
120
|
+
duplicate demo resources or inquiry sessions.
|
|
121
|
+
|
|
122
|
+
For agent automation after the user has explicitly approved starting
|
|
123
|
+
containers, use `answerlayer local quickstart --yes --json`. Progress is written
|
|
124
|
+
to stderr; stdout is one stable, credential-free JSON object containing the CLI
|
|
125
|
+
version, image digest, runtime directory, demo and provider status, local URL,
|
|
126
|
+
inquiry result, and next actions. `--yes` must not be used to bypass user
|
|
127
|
+
approval.
|
|
128
|
+
|
|
129
|
+
The underlying lifecycle commands remain available when manual control is
|
|
130
|
+
needed:
|
|
101
131
|
|
|
102
132
|
```bash
|
|
103
133
|
answerlayer local init
|
|
@@ -210,6 +240,7 @@ answerlayer health
|
|
|
210
240
|
answerlayer openapi --output openapi.json
|
|
211
241
|
answerlayer local init
|
|
212
242
|
answerlayer local start
|
|
243
|
+
answerlayer local quickstart --yes --json
|
|
213
244
|
answerlayer local demo --json
|
|
214
245
|
answerlayer local provider status --json
|
|
215
246
|
answerlayer local status
|
package/package.json
CHANGED
|
@@ -30,24 +30,16 @@ already available in the Codex skills directory.
|
|
|
30
30
|
npm install -g @answerlayer/cli
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
2.
|
|
33
|
+
2. Explain that quickstart may pull an image, start Docker containers, create a
|
|
34
|
+
persistent local volume, and install synthetic demo data. Get explicit user
|
|
35
|
+
confirmation, then run:
|
|
34
36
|
|
|
35
37
|
```bash
|
|
36
|
-
answerlayer local
|
|
38
|
+
answerlayer local quickstart --yes --json
|
|
37
39
|
```
|
|
38
40
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
in the platform application-data directory. It does not require Git, a
|
|
42
|
-
source checkout, registry credentials, or a model-provider key.
|
|
43
|
-
|
|
44
|
-
3. After confirmation, start and configure the stack:
|
|
45
|
-
|
|
46
|
-
```bash
|
|
47
|
-
answerlayer local start
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
This starts Postgres, runs migrations, waits for readiness, creates the local
|
|
41
|
+
Never pass `--yes` before the user approves. This checks Docker, pulls and
|
|
42
|
+
pins the supported public image, starts Postgres, runs migrations, creates the local
|
|
51
43
|
identity and scoped key, verifies it, and configures the CLI. It also seeds a
|
|
52
44
|
versioned synthetic retail demo in a separate database, registers a
|
|
53
45
|
dedicated read-only connection, creates starter semantic resources and a
|
|
@@ -55,48 +47,37 @@ already available in the Codex skills directory.
|
|
|
55
47
|
credentials rather than printing them. Use `answerlayer local status` and
|
|
56
48
|
`answerlayer local logs` to inspect progress. `local stop` preserves data;
|
|
57
49
|
`local reset --force` is the explicit destructive reset. Use `--no-demo`
|
|
58
|
-
only when the user explicitly wants an empty instance.
|
|
59
|
-
|
|
60
|
-
4. Inspect the machine-readable demo handoff:
|
|
61
|
-
|
|
62
|
-
```bash
|
|
63
|
-
answerlayer local demo --json
|
|
64
|
-
```
|
|
50
|
+
only when the user explicitly wants an empty instance. Progress appears on
|
|
51
|
+
stderr; parse the single credential-free JSON object on stdout.
|
|
65
52
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
```bash
|
|
71
|
-
answerlayer saved-queries execute <saved-query-id> --format table
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
5. When the user wants natural-language inquiry, hand provider setup back to
|
|
75
|
-
them. Ask them to run this command privately in their own terminal:
|
|
53
|
+
3. If the JSON status is `provider-required`, report that the provider-free demo
|
|
54
|
+
succeeded and hand provider setup back to the user. Ask them to run this
|
|
55
|
+
privately in their own terminal:
|
|
76
56
|
|
|
77
57
|
```bash
|
|
78
58
|
answerlayer local provider set anthropic
|
|
79
59
|
```
|
|
80
60
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
the application container, and verifies the provider. For automation, the
|
|
85
|
-
user may place the key in a mode-0600 file and pass its path with
|
|
86
|
-
`--from-file`; do not read or print that file. After the user confirms the
|
|
87
|
-
command completed, inspect only secret-free status:
|
|
61
|
+
Never ask the user to paste the key into chat, never pass it as an argument,
|
|
62
|
+
and do not read a credential file. After the user confirms setup completed,
|
|
63
|
+
resume the same idempotent workflow without another state-change approval:
|
|
88
64
|
|
|
89
65
|
```bash
|
|
90
|
-
answerlayer local
|
|
66
|
+
answerlayer local quickstart --yes --json
|
|
91
67
|
```
|
|
92
68
|
|
|
93
|
-
|
|
69
|
+
A `complete` status proves a real model-backed inquiry ran against the demo.
|
|
70
|
+
Report the local URL, verified question/result, and suggested next actions.
|
|
71
|
+
Repeating quickstart reuses the completed inquiry rather than creating a
|
|
72
|
+
duplicate session.
|
|
73
|
+
|
|
74
|
+
4. Before connecting real data, require a dedicated database account that is
|
|
94
75
|
restricted to approved schemas and `SELECT` only. Show the proposed
|
|
95
76
|
connection host, database, and username, then get confirmation before
|
|
96
77
|
running `connections create` or any query. Put the password only in a local,
|
|
97
78
|
permission-restricted JSON file; never print it or commit it.
|
|
98
79
|
|
|
99
|
-
|
|
80
|
+
5. Start with a small approved schema and read-only inspection. Confirm before
|
|
100
81
|
creating connections, generating semantic objects, or executing queries.
|
|
101
82
|
|
|
102
83
|
This workflow is for Docker Compose development only. Do not run
|
package/src/cli.js
CHANGED
|
@@ -1440,6 +1440,8 @@ function normalizeFlagName(rawName) {
|
|
|
1440
1440
|
"--no-semantic-layer": "noSemanticLayer",
|
|
1441
1441
|
"--no-demo": "noDemo",
|
|
1442
1442
|
"--from-file": "fromFile",
|
|
1443
|
+
"--yes": "yes",
|
|
1444
|
+
"-y": "yes",
|
|
1443
1445
|
"--options": "options",
|
|
1444
1446
|
"--status": "status",
|
|
1445
1447
|
"--summary": "summary",
|
|
@@ -1478,7 +1480,7 @@ function normalizeFlagName(rawName) {
|
|
|
1478
1480
|
}
|
|
1479
1481
|
|
|
1480
1482
|
function isBooleanFlag(rawName) {
|
|
1481
|
-
return ["--json", "--help", "-h", "--include", "-i", "--raw", "--admin", "--force", "--follow", "--active", "--inactive", "--include-inactive", "--include-semantic-snapshot", "--use-semantic-layer", "--no-semantic-layer", "--no-demo"].includes(rawName);
|
|
1483
|
+
return ["--json", "--help", "-h", "--include", "-i", "--raw", "--admin", "--force", "--follow", "--active", "--inactive", "--include-inactive", "--include-semantic-snapshot", "--use-semantic-layer", "--no-semantic-layer", "--no-demo", "--yes", "-y"].includes(rawName);
|
|
1482
1484
|
}
|
|
1483
1485
|
|
|
1484
1486
|
function setFlag(flags, name, value) {
|
|
@@ -1619,6 +1621,7 @@ Usage:
|
|
|
1619
1621
|
answerlayer local start [--no-demo]
|
|
1620
1622
|
answerlayer local status|logs|stop
|
|
1621
1623
|
answerlayer local demo [--json]
|
|
1624
|
+
answerlayer local quickstart [--yes] [--json]
|
|
1622
1625
|
answerlayer local provider set|rotate anthropic [--from-file <mode-0600-path>]
|
|
1623
1626
|
answerlayer local provider status|verify [anthropic] [--json]
|
|
1624
1627
|
answerlayer local provider remove anthropic --force
|
package/src/local.js
CHANGED
|
@@ -4,10 +4,11 @@ import net from "node:net";
|
|
|
4
4
|
import os from "node:os";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { spawnSync } from "node:child_process";
|
|
7
|
+
import { createInterface } from "node:readline/promises";
|
|
7
8
|
import { AnswerLayerClient } from "./client.js";
|
|
8
9
|
import { defaultConfigPath, readConfig, writeConfig } from "./config.js";
|
|
9
10
|
|
|
10
|
-
export const DEFAULT_LOCAL_IMAGE = "public.ecr.aws/s8d9x7y7/answerlayer:1.
|
|
11
|
+
export const DEFAULT_LOCAL_IMAGE = "public.ecr.aws/s8d9x7y7/answerlayer:1.20.3";
|
|
11
12
|
const DEFAULT_PORT = 8000;
|
|
12
13
|
const MINIMUM_FREE_BYTES = 2 * 1024 * 1024 * 1024;
|
|
13
14
|
const PROVIDER_VALIDATION_TIMEOUT_MS = 15_000;
|
|
@@ -21,12 +22,14 @@ const LOCAL_DEMO_QUESTIONS = [
|
|
|
21
22
|
"Which region generated the most completed revenue?",
|
|
22
23
|
"How did completed revenue change from January to March?",
|
|
23
24
|
];
|
|
25
|
+
const LOCAL_QUICKSTART_QUESTION = LOCAL_DEMO_QUESTIONS[0];
|
|
24
26
|
const LOCAL_PROVIDERS = {
|
|
25
27
|
anthropic: {
|
|
26
28
|
label: "Anthropic",
|
|
27
29
|
environmentName: "ANSWERLAYER_ANTHROPIC_API_KEY",
|
|
28
30
|
},
|
|
29
31
|
};
|
|
32
|
+
const CLI_VERSION = JSON.parse(fs.readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
|
|
30
33
|
|
|
31
34
|
export async function handleLocal(command, parsed, io) {
|
|
32
35
|
if (command === "init") return localInit(parsed, io);
|
|
@@ -36,9 +39,10 @@ export async function handleLocal(command, parsed, io) {
|
|
|
36
39
|
if (command === "stop") return localStop(parsed, io);
|
|
37
40
|
if (command === "demo") return localDemo(parsed, io);
|
|
38
41
|
if (command === "provider") return localProvider(parsed, io);
|
|
42
|
+
if (command === "quickstart") return localQuickstart(parsed, io);
|
|
39
43
|
if (command === "upgrade") return localUpgrade(parsed, io);
|
|
40
44
|
if (command === "reset") return localReset(parsed, io);
|
|
41
|
-
throw new Error("Expected `answerlayer local init|start|status|logs|stop|demo|provider|upgrade|reset`");
|
|
45
|
+
throw new Error("Expected `answerlayer local init|start|status|logs|stop|demo|provider|quickstart|upgrade|reset`");
|
|
42
46
|
}
|
|
43
47
|
|
|
44
48
|
export async function localUp(parsed, io) {
|
|
@@ -90,6 +94,70 @@ async function localStart(parsed, io) {
|
|
|
90
94
|
write(io.stdout, "Demo: skipped (--no-demo)\n");
|
|
91
95
|
write(io.stdout, "Install it later with: answerlayer local demo\n");
|
|
92
96
|
}
|
|
97
|
+
return { runtime: { ...runtime, state }, baseUrl, configPath, demo };
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async function localQuickstart(parsed, io) {
|
|
101
|
+
if (!(await confirmQuickstart(parsed, io))) {
|
|
102
|
+
throw new Error("Quickstart cancelled before making local runtime changes.");
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const progressIo = { ...io, stdout: io.stderr };
|
|
106
|
+
const started = await localStart({
|
|
107
|
+
...parsed,
|
|
108
|
+
flags: { ...parsed.flags, noDemo: false },
|
|
109
|
+
}, progressIo);
|
|
110
|
+
const { runtime, baseUrl, demo } = started;
|
|
111
|
+
const provider = resolveLocalProvider("anthropic");
|
|
112
|
+
const configured = Boolean(readEnvironment(runtime.envPath)[provider.environmentName]);
|
|
113
|
+
let providerStatus;
|
|
114
|
+
|
|
115
|
+
if (!configured) {
|
|
116
|
+
providerStatus = providerResult(provider, false, "ready", { verified: false, errorCode: "not-configured" });
|
|
117
|
+
const result = quickstartResult(runtime, demo, providerStatus, {
|
|
118
|
+
status: "not-run",
|
|
119
|
+
question: LOCAL_QUICKSTART_QUESTION,
|
|
120
|
+
});
|
|
121
|
+
persistQuickstart(runtime, { status: "provider-required", question: LOCAL_QUICKSTART_QUESTION });
|
|
122
|
+
printQuickstart(result, parsed, io);
|
|
123
|
+
return result;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const verification = validateProvider(runtime, io.runCommand || runCommand, provider);
|
|
127
|
+
providerStatus = providerResult(provider, true, "ready", verification);
|
|
128
|
+
if (!verification.verified) {
|
|
129
|
+
const result = quickstartResult(runtime, demo, providerStatus, {
|
|
130
|
+
status: "not-run",
|
|
131
|
+
question: LOCAL_QUICKSTART_QUESTION,
|
|
132
|
+
});
|
|
133
|
+
persistQuickstart(runtime, {
|
|
134
|
+
status: "provider-verification-failed",
|
|
135
|
+
question: LOCAL_QUICKSTART_QUESTION,
|
|
136
|
+
errorCode: verification.errorCode,
|
|
137
|
+
});
|
|
138
|
+
printQuickstart(result, parsed, io);
|
|
139
|
+
return result;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
let inquiry = runtime.state.quickstart?.status === "complete"
|
|
143
|
+
&& runtime.state.quickstart.question === LOCAL_QUICKSTART_QUESTION
|
|
144
|
+
&& runtime.state.quickstart.connectionId === demo.connectionId
|
|
145
|
+
? runtime.state.quickstart.inquiry
|
|
146
|
+
: null;
|
|
147
|
+
if (!inquiry) {
|
|
148
|
+
inquiry = await runQuickstartInquiry(baseUrl, demo.connectionId, io);
|
|
149
|
+
persistQuickstart(runtime, {
|
|
150
|
+
status: "complete",
|
|
151
|
+
question: LOCAL_QUICKSTART_QUESTION,
|
|
152
|
+
connectionId: demo.connectionId,
|
|
153
|
+
inquiry,
|
|
154
|
+
completedAt: new Date().toISOString(),
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const result = quickstartResult(runtime, demo, providerStatus, inquiry);
|
|
159
|
+
printQuickstart(result, parsed, io);
|
|
160
|
+
return result;
|
|
93
161
|
}
|
|
94
162
|
|
|
95
163
|
async function localDemo(parsed, io) {
|
|
@@ -232,6 +300,7 @@ async function localStatus(parsed, io) {
|
|
|
232
300
|
resolvedImage: runtime.state.resolvedImage,
|
|
233
301
|
runtimeDirectory: runtime.directory,
|
|
234
302
|
demo: runtime.state.demo || { status: "not-installed", version: LOCAL_DEMO_VERSION },
|
|
303
|
+
quickstart: runtime.state.quickstart || { status: "not-started", question: LOCAL_QUICKSTART_QUESTION },
|
|
235
304
|
providers: localProviderConfiguration(runtime),
|
|
236
305
|
services: status.services,
|
|
237
306
|
};
|
|
@@ -245,6 +314,7 @@ async function localStatus(parsed, io) {
|
|
|
245
314
|
write(io.stdout, `Image: ${result.resolvedImage}\n`);
|
|
246
315
|
write(io.stdout, `Runtime config: ${result.runtimeDirectory}\n`);
|
|
247
316
|
write(io.stdout, `Demo: ${result.demo.status} (${result.demo.version})\n`);
|
|
317
|
+
write(io.stdout, `Quickstart: ${result.quickstart.status}\n`);
|
|
248
318
|
write(io.stdout, `Model provider: ${result.providers.anthropic.configured ? "anthropic (configured)" : "not configured"}\n`);
|
|
249
319
|
}
|
|
250
320
|
|
|
@@ -283,6 +353,7 @@ async function localReset(parsed, io) {
|
|
|
283
353
|
writeState(runtime.statePath, {
|
|
284
354
|
...runtime.state,
|
|
285
355
|
demo: { status: "not-installed", version: LOCAL_DEMO_VERSION },
|
|
356
|
+
quickstart: { status: "not-started", question: LOCAL_QUICKSTART_QUESTION },
|
|
286
357
|
lastStatus: "stopped",
|
|
287
358
|
resetAt: new Date().toISOString(),
|
|
288
359
|
});
|
|
@@ -324,6 +395,7 @@ async function ensureInitialized(parsed, io) {
|
|
|
324
395
|
resolvedImage,
|
|
325
396
|
port,
|
|
326
397
|
...(existingState?.demo ? { demo: existingState.demo } : {}),
|
|
398
|
+
...(existingState?.quickstart ? { quickstart: existingState.quickstart } : {}),
|
|
327
399
|
...runtimeResourceNames(runtime.directory),
|
|
328
400
|
createdAt: existingState?.createdAt || new Date().toISOString(),
|
|
329
401
|
updatedAt: new Date().toISOString(),
|
|
@@ -716,6 +788,130 @@ function providerResult(provider, configured, runtimeStatus, verification) {
|
|
|
716
788
|
};
|
|
717
789
|
}
|
|
718
790
|
|
|
791
|
+
async function confirmQuickstart(parsed, io) {
|
|
792
|
+
if (parsed.flags.yes) return true;
|
|
793
|
+
const prompt = "Quickstart may pull an image, start local containers, and create persistent demo data. Continue? [y/N] ";
|
|
794
|
+
if (io.confirm) return Boolean(await io.confirm(prompt));
|
|
795
|
+
if (!io.stdin?.isTTY) {
|
|
796
|
+
throw new Error("Quickstart requires confirmation before starting containers. Rerun interactively or use --yes only after the user approves.");
|
|
797
|
+
}
|
|
798
|
+
const terminal = createInterface({ input: io.stdin, output: io.stderr });
|
|
799
|
+
try {
|
|
800
|
+
const answer = await terminal.question(prompt);
|
|
801
|
+
return /^(?:y|yes)$/i.test(answer.trim());
|
|
802
|
+
} finally {
|
|
803
|
+
terminal.close();
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
async function runQuickstartInquiry(baseUrl, connectionId, io) {
|
|
808
|
+
const config = readConfig(io.env);
|
|
809
|
+
if (config.baseUrl !== baseUrl || !config.apiKey) {
|
|
810
|
+
throw new Error("Local CLI credentials are unavailable. Run `answerlayer local start` and retry quickstart.");
|
|
811
|
+
}
|
|
812
|
+
const client = new AnswerLayerClient({
|
|
813
|
+
baseUrl,
|
|
814
|
+
apiKey: config.apiKey,
|
|
815
|
+
fetchImpl: io.fetch || globalThis.fetch,
|
|
816
|
+
});
|
|
817
|
+
const catalog = await client.request("GET", "/api/v1/inquiry/models");
|
|
818
|
+
const model = catalog?.default_model;
|
|
819
|
+
if (!model) throw new Error("The local runtime did not return a default inquiry model.");
|
|
820
|
+
const session = await client.request("POST", "/api/v1/inquiry/sessions", {
|
|
821
|
+
body: { connection_id: connectionId, model, use_semantic_layer: true },
|
|
822
|
+
});
|
|
823
|
+
if (!session?.session_id) throw new Error("Quickstart inquiry did not return a session ID.");
|
|
824
|
+
const turn = await client.request(
|
|
825
|
+
"POST",
|
|
826
|
+
`/api/v1/inquiry/sessions/${encodeURIComponent(session.session_id)}/sync`,
|
|
827
|
+
{ body: { user_input: LOCAL_QUICKSTART_QUESTION } },
|
|
828
|
+
);
|
|
829
|
+
if (!String(turn?.final_response || "").trim()) {
|
|
830
|
+
throw new Error("Quickstart inquiry completed without a model response. Check `answerlayer local logs answerlayer` and retry.");
|
|
831
|
+
}
|
|
832
|
+
return {
|
|
833
|
+
status: "verified",
|
|
834
|
+
sessionId: String(session.session_id),
|
|
835
|
+
turnId: turn.turn_id ? String(turn.turn_id) : null,
|
|
836
|
+
model,
|
|
837
|
+
question: LOCAL_QUICKSTART_QUESTION,
|
|
838
|
+
answer: String(turn.final_response),
|
|
839
|
+
sqlQueries: Array.isArray(turn.sql_queries) ? turn.sql_queries.map(String) : [],
|
|
840
|
+
};
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
function persistQuickstart(runtime, quickstart) {
|
|
844
|
+
const state = {
|
|
845
|
+
...runtime.state,
|
|
846
|
+
quickstart,
|
|
847
|
+
updatedAt: new Date().toISOString(),
|
|
848
|
+
};
|
|
849
|
+
writeState(runtime.statePath, state);
|
|
850
|
+
runtime.state = state;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
function quickstartResult(runtime, demo, provider, inquiry) {
|
|
854
|
+
const status = provider.status === "unconfigured"
|
|
855
|
+
? "provider-required"
|
|
856
|
+
: provider.status !== "verified"
|
|
857
|
+
? "provider-verification-failed"
|
|
858
|
+
: inquiry.status === "verified"
|
|
859
|
+
? "complete"
|
|
860
|
+
: "inquiry-not-run";
|
|
861
|
+
return {
|
|
862
|
+
schemaVersion: 1,
|
|
863
|
+
status,
|
|
864
|
+
cliVersion: CLI_VERSION,
|
|
865
|
+
runtime: {
|
|
866
|
+
status: "ready",
|
|
867
|
+
url: `http://127.0.0.1:${runtime.state.port}`,
|
|
868
|
+
image: runtime.state.requestedImage,
|
|
869
|
+
resolvedImage: runtime.state.resolvedImage,
|
|
870
|
+
directory: runtime.directory,
|
|
871
|
+
},
|
|
872
|
+
demo: {
|
|
873
|
+
status: demo.status,
|
|
874
|
+
version: demo.version,
|
|
875
|
+
connectionId: demo.connectionId,
|
|
876
|
+
savedQueryId: demo.savedQueryId,
|
|
877
|
+
validation: demo.validation,
|
|
878
|
+
},
|
|
879
|
+
provider,
|
|
880
|
+
inquiry,
|
|
881
|
+
nextActions: status === "provider-required"
|
|
882
|
+
? ["answerlayer local provider set anthropic", "answerlayer local quickstart"]
|
|
883
|
+
: status === "provider-verification-failed"
|
|
884
|
+
? ["answerlayer local provider set anthropic", "answerlayer local quickstart"]
|
|
885
|
+
: LOCAL_DEMO_QUESTIONS.slice(1).map(question => `answerlayer inquiry ask --connection ${demo.connectionId} "${question}"`),
|
|
886
|
+
};
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
function printQuickstart(result, parsed, io) {
|
|
890
|
+
if (parsed.flags.json) {
|
|
891
|
+
write(io.stdout, `${JSON.stringify(result, null, 2)}\n`);
|
|
892
|
+
return;
|
|
893
|
+
}
|
|
894
|
+
write(io.stdout, `AnswerLayer quickstart: ${result.status}\n`);
|
|
895
|
+
write(io.stdout, `URL: ${result.runtime.url}\n`);
|
|
896
|
+
write(io.stdout, `Demo: ${result.demo.status} (${result.demo.version})\n`);
|
|
897
|
+
if (result.status === "provider-required") {
|
|
898
|
+
write(io.stdout, "A model provider is required for natural-language inquiry.\n");
|
|
899
|
+
write(io.stdout, "Enter the credential privately in your terminal: answerlayer local provider set anthropic\n");
|
|
900
|
+
write(io.stdout, "Then resume with: answerlayer local quickstart\n");
|
|
901
|
+
return;
|
|
902
|
+
}
|
|
903
|
+
if (result.status === "provider-verification-failed") {
|
|
904
|
+
write(io.stdout, `Provider verification failed: ${result.provider.errorCode}\n`);
|
|
905
|
+
write(io.stdout, "Repair it privately with: answerlayer local provider set anthropic\n");
|
|
906
|
+
return;
|
|
907
|
+
}
|
|
908
|
+
write(io.stdout, `Model inquiry verified with ${result.inquiry.model}.\n`);
|
|
909
|
+
write(io.stdout, `Question: ${result.inquiry.question}\n`);
|
|
910
|
+
write(io.stdout, `Answer: ${result.inquiry.answer}\n`);
|
|
911
|
+
write(io.stdout, `Session: ${result.inquiry.sessionId}\n`);
|
|
912
|
+
write(io.stdout, `Next: ${result.nextActions[0]}\n`);
|
|
913
|
+
}
|
|
914
|
+
|
|
719
915
|
function readState(statePath) {
|
|
720
916
|
if (!fs.existsSync(statePath)) return null;
|
|
721
917
|
try {
|