@answerlayer/cli 0.1.3 → 0.1.5

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
@@ -130,7 +130,8 @@ Useful scopes:
130
130
  - `saved_query:read`, `saved_query:execute`, and `saved_query:write` for saved-query workflows
131
131
  - `semantic:read`, `semantic:write`, and `semantic:generate` for semantic-layer workflows
132
132
  - `dashboard:read`, `dashboard:write`, `tile:read`, and `tile:write` for dashboard workflows
133
- - `inquiry:execute` for natural-language inquiry
133
+ - `inquiry:read` to inspect inquiry sessions and evaluation suites/runs
134
+ - `inquiry:execute` for natural-language inquiry and to manage/run evaluations
134
135
 
135
136
  ## Commands
136
137
 
@@ -158,6 +159,15 @@ answerlayer semantic metrics generate --connection <connection-id> --prompt "Saa
158
159
 
159
160
  answerlayer inquiry ask --connection <connection-id> "What changed in revenue this month?"
160
161
  answerlayer inquiry ask --session <session-id> "Break that down by region"
162
+ answerlayer inquiry models
163
+ answerlayer inquiry ask --connection <connection-id> --model claude-opus-4-6 "Investigate unusual revenue changes"
164
+
165
+ answerlayer evals suites create --name "Revenue checks" --connection <connection-id>
166
+ answerlayer evals cases create <suite-id> --title "Monthly revenue" --question "What was revenue last month?" --expected-sql "select sum(amount) from orders where ..."
167
+ answerlayer evals runs create <suite-id> --label "Before prompt change"
168
+ answerlayer evals runs create <suite-id> --case <case-id> --case <case-id> --label "Focused smoke run"
169
+ answerlayer evals runs create <suite-id> --model claude-opus-4-6 --label "Model comparison"
170
+ answerlayer evals runs compare <run-id> --baseline <baseline-run-id>
161
171
 
162
172
  answerlayer dashboards create --title "Executive overview" --visibility org
163
173
  answerlayer tiles create --title "Revenue" --source-type saved_query --source <saved-query-id>
@@ -182,7 +192,7 @@ answerlayer branding update --data-file ./branding.json
182
192
  ## Command groups
183
193
 
184
194
  - Core: `api-keys`, `connections`, `metadata`, `query`, `query-results`
185
- - Data products: `saved-queries`, `semantic`, `inquiry`, `generation`, `tiles`, `dashboards`
195
+ - Data products: `saved-queries`, `semantic`, `inquiry`, `evals`, `generation`, `tiles`, `dashboards`
186
196
  - Supporting resources: `documents`, `branding`, `uploads`, `chains`, `users`, `org`, `roles`, `billing`, `stats`
187
197
 
188
198
  ## Development
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@answerlayer/cli",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Open-source command line client for the AnswerLayer API.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -147,6 +147,7 @@ to see exact flags before using one:
147
147
  - `saved-queries` — list / get / create / execute reusable queries
148
148
  - `semantic` — entities, relationships, measures, metrics, dimensions, filters
149
149
  (most need `--connection <id>`)
150
+ - `evals` — create evaluation suites and cases, run them, and compare runs
150
151
  - `dashboards`, `tiles` — build and read dashboards
151
152
  - `documents` — upload business-context docs and link them to connections
152
153
  - `connections` — create / test / inspect schema
package/src/cli.js CHANGED
@@ -56,6 +56,7 @@ export async function main(argv, io) {
56
56
  if (group === "saved-queries" || group === "saved") return handleSavedQueries(client, command, positionals, parsed, io);
57
57
  if (group === "semantic") return handleSemantic(client, command, positionals, parsed, io);
58
58
  if (group === "inquiry") return handleInquiry(client, command, positionals, parsed, io);
59
+ if (group === "evals" || group === "evaluations") return handleEvals(client, command, positionals, parsed, io);
59
60
  if (group === "generation") return handleGeneration(client, command, positionals, parsed, io);
60
61
  if (group === "tiles") return handleTiles(client, command, positionals, parsed, io);
61
62
  if (group === "dashboards") return handleDashboards(client, command, positionals, parsed, io);
@@ -488,6 +489,20 @@ async function handleSemantic(client, command, positionals, parsed, io) {
488
489
  }
489
490
 
490
491
  async function handleInquiry(client, command, positionals, parsed, io) {
492
+ if (command === "models") {
493
+ return requestAndPrint(client, "GET", "/api/v1/inquiry/models", parsed, io, {
494
+ tableDataKey: "models",
495
+ tablePrefix: (data) => `Default model: ${data.default_model}\n\n`,
496
+ table: [
497
+ { key: "id", label: "ID" },
498
+ { key: "label", label: "Model" },
499
+ { key: "family", label: "Provider" },
500
+ { key: "transport", label: "Transport" },
501
+ { key: "description", label: "Description" },
502
+ ],
503
+ });
504
+ }
505
+
491
506
  if (command === "ask") {
492
507
  const question = firstValue(parsed.flags.question) || positionals.join(" ");
493
508
  const connectionId = firstValue(parsed.flags.connection);
@@ -572,6 +587,120 @@ async function handleInquiry(client, command, positionals, parsed, io) {
572
587
  throw usage(`Unknown inquiry command: ${command}`);
573
588
  }
574
589
 
590
+ async function handleEvals(client, resource, positionals, parsed, io) {
591
+ const [command, ...rest] = positionals;
592
+ const base = "/api/v1/evals";
593
+
594
+ if (resource === "suites" || resource === "suite") {
595
+ if (command === "list" || !command) {
596
+ return requestAndPrint(client, "GET", `${base}/suites`, parsed, io, {
597
+ query: {
598
+ connection_id: firstValue(parsed.flags.connection),
599
+ include_inactive: parsed.flags.includeInactive || undefined,
600
+ },
601
+ table: [
602
+ { key: "id", label: "ID" },
603
+ { key: "name", label: "Name" },
604
+ { key: "connection_id", label: "Connection" },
605
+ { key: "version", label: "Version" },
606
+ { key: "case_count", label: "Cases" },
607
+ { key: "is_active", label: "Active" },
608
+ ],
609
+ });
610
+ }
611
+
612
+ if (command === "create") {
613
+ const payload = await readData(parsed.flags, io, {
614
+ name: firstValue(parsed.flags.name),
615
+ connection_id: firstValue(parsed.flags.connection),
616
+ description: firstValue(parsed.flags.description),
617
+ });
618
+ requirePayloadValue(payload, "name", "evals suites create requires --name");
619
+ requirePayloadValue(payload, "connection_id", "evals suites create requires --connection");
620
+ return requestAndPrint(client, "POST", `${base}/suites`, parsed, io, { body: payload });
621
+ }
622
+
623
+ const suiteId = requirePositional(rest, 0, "eval suite id");
624
+ if (command === "get") return requestAndPrint(client, "GET", `${base}/suites/${encodeURIComponent(suiteId)}`, parsed, io);
625
+ if (command === "update") {
626
+ return requestAndPrint(client, "PATCH", `${base}/suites/${encodeURIComponent(suiteId)}`, parsed, io, {
627
+ body: await readData(parsed.flags, io, {
628
+ name: firstValue(parsed.flags.name),
629
+ description: firstValue(parsed.flags.description),
630
+ is_active: activeFlag(parsed.flags),
631
+ }),
632
+ });
633
+ }
634
+ if (command === "delete") return requestAndPrint(client, "DELETE", `${base}/suites/${encodeURIComponent(suiteId)}`, parsed, io);
635
+ throw usage(`Unknown evals suites command: ${command}`);
636
+ }
637
+
638
+ if (resource === "cases" || resource === "case") {
639
+ if (command === "create") {
640
+ const suiteId = firstValue(parsed.flags.suite) || requirePositional(rest, 0, "eval suite id");
641
+ return requestAndPrint(client, "POST", `${base}/suites/${encodeURIComponent(suiteId)}/cases`, parsed, io, {
642
+ body: await readData(parsed.flags, io, evalCasePayload(parsed.flags)),
643
+ });
644
+ }
645
+
646
+ const caseId = requirePositional(rest, 0, "eval case id");
647
+ if (command === "update") {
648
+ return requestAndPrint(client, "PATCH", `${base}/cases/${encodeURIComponent(caseId)}`, parsed, io, {
649
+ body: await readData(parsed.flags, io, { ...evalCasePayload(parsed.flags), is_active: activeFlag(parsed.flags) }),
650
+ });
651
+ }
652
+ if (command === "delete") return requestAndPrint(client, "DELETE", `${base}/cases/${encodeURIComponent(caseId)}`, parsed, io);
653
+ throw usage(`Unknown evals cases command: ${command}`);
654
+ }
655
+
656
+ if (resource === "runs" || resource === "run") {
657
+ if (command === "list" || !command) {
658
+ return requestAndPrint(client, "GET", `${base}/runs`, parsed, io, {
659
+ query: {
660
+ suite_id: firstValue(parsed.flags.suite),
661
+ limit: firstValue(parsed.flags.limit),
662
+ offset: firstValue(parsed.flags.offset),
663
+ },
664
+ table: [
665
+ { key: "id", label: "ID" },
666
+ { key: "suite_id", label: "Suite" },
667
+ { key: "label", label: "Label" },
668
+ { key: "status", label: "Status" },
669
+ { key: "suite_version", label: "Version" },
670
+ ],
671
+ });
672
+ }
673
+
674
+ if (command === "create") {
675
+ const payload = await readData(parsed.flags, io, {
676
+ suite_id: firstValue(parsed.flags.suite) || rest[0],
677
+ label: firstValue(parsed.flags.label),
678
+ model: firstValue(parsed.flags.model),
679
+ baseline_run_id: firstValue(parsed.flags.baseline),
680
+ case_ids: optionalCsvOrRepeated(parsed.flags.case),
681
+ });
682
+ requirePayloadValue(payload, "suite_id", "evals runs create requires a suite id or --suite");
683
+ return requestAndPrint(client, "POST", `${base}/runs`, parsed, io, { body: payload });
684
+ }
685
+
686
+ const runId = requirePositional(rest, 0, "eval run id");
687
+ if (command === "get") {
688
+ return requestAndPrint(client, "GET", `${base}/runs/${encodeURIComponent(runId)}`, parsed, io, {
689
+ query: { include_semantic_snapshot: parsed.flags.includeSemanticSnapshot || undefined },
690
+ });
691
+ }
692
+ if (command === "cancel") return requestAndPrint(client, "POST", `${base}/runs/${encodeURIComponent(runId)}/cancel`, parsed, io);
693
+ if (command === "compare") {
694
+ return requestAndPrint(client, "GET", `${base}/runs/${encodeURIComponent(runId)}/compare`, parsed, io, {
695
+ query: { baseline_run_id: firstValue(parsed.flags.baseline) },
696
+ });
697
+ }
698
+ throw usage(`Unknown evals runs command: ${command}`);
699
+ }
700
+
701
+ throw usage(`Expected evals resource: suites, cases, or runs`);
702
+ }
703
+
575
704
  async function handleGeneration(client, command, positionals, parsed, io) {
576
705
  const base = "/api/v1/semantic/jobs";
577
706
  if (command === "start" || command === "create") {
@@ -997,6 +1126,29 @@ function queryPayload(flags, sql) {
997
1126
  };
998
1127
  }
999
1128
 
1129
+ function evalCasePayload(flags) {
1130
+ return {
1131
+ title: firstValue(flags.title),
1132
+ question: firstValue(flags.question),
1133
+ expected_answer: firstValue(flags.expectedAnswer),
1134
+ expected_sql: firstValue(flags.expectedSql) || firstValue(flags.sql),
1135
+ expected_values: parseJsonFlag(firstValue(flags.expectedValues), "expected-values"),
1136
+ required_tools: optionalCsvOrRepeated(flags.requiredTool),
1137
+ forbidden_tools: optionalCsvOrRepeated(flags.forbiddenTool),
1138
+ tags: optionalCsvOrRepeated(flags.tag),
1139
+ evaluator_config: parseJsonFlag(firstValue(flags.evaluatorConfig), "evaluator-config"),
1140
+ numeric_tolerance: parseNumber(firstValue(flags.numericTolerance), "numeric-tolerance"),
1141
+ pass_threshold: parseNumber(firstValue(flags.passThreshold), "pass-threshold"),
1142
+ };
1143
+ }
1144
+
1145
+ function activeFlag(flags) {
1146
+ if (flags.active && flags.inactive) throw usage("Use only one of --active or --inactive");
1147
+ if (flags.active) return true;
1148
+ if (flags.inactive) return false;
1149
+ return undefined;
1150
+ }
1151
+
1000
1152
  async function semanticPayload(resource, flags, positionals, io) {
1001
1153
  const common = {
1002
1154
  name: firstValue(flags.name) || positionals.join(" ") || undefined,
@@ -1122,6 +1274,7 @@ async function requestAndPrint(client, method, pathName, parsed, io, options = {
1122
1274
  if (!parsed.flags.json && options.table) {
1123
1275
  const rows = options.tableDataKey ? result.data[options.tableDataKey] : result.data;
1124
1276
  if (Array.isArray(rows)) {
1277
+ if (options.tablePrefix) write(io.stdout, options.tablePrefix(result.data));
1125
1278
  write(io.stdout, formatList(rows, options.table));
1126
1279
  return;
1127
1280
  }
@@ -1244,6 +1397,26 @@ function normalizeFlagName(rawName) {
1244
1397
  "--summary": "summary",
1245
1398
  "--session": "session",
1246
1399
  "--question": "question",
1400
+ "--suite": "suite",
1401
+ "--suite-id": "suite",
1402
+ "--label": "label",
1403
+ "--baseline": "baseline",
1404
+ "--baseline-run": "baseline",
1405
+ "--case": "case",
1406
+ "--case-id": "case",
1407
+ "--expected-answer": "expectedAnswer",
1408
+ "--expected-sql": "expectedSql",
1409
+ "--expected-values": "expectedValues",
1410
+ "--required-tool": "requiredTool",
1411
+ "--forbidden-tool": "forbiddenTool",
1412
+ "--tag": "tag",
1413
+ "--evaluator-config": "evaluatorConfig",
1414
+ "--numeric-tolerance": "numericTolerance",
1415
+ "--pass-threshold": "passThreshold",
1416
+ "--active": "active",
1417
+ "--inactive": "inactive",
1418
+ "--include-inactive": "includeInactive",
1419
+ "--include-semantic-snapshot": "includeSemanticSnapshot",
1247
1420
  "--turn": "turn",
1248
1421
  "--from": "from",
1249
1422
  "--to": "to",
@@ -1257,7 +1430,7 @@ function normalizeFlagName(rawName) {
1257
1430
  }
1258
1431
 
1259
1432
  function isBooleanFlag(rawName) {
1260
- return ["--json", "--help", "-h", "--include", "-i", "--raw", "--admin", "--force"].includes(rawName);
1433
+ return ["--json", "--help", "-h", "--include", "-i", "--raw", "--admin", "--force", "--active", "--inactive", "--include-inactive", "--include-semantic-snapshot"].includes(rawName);
1261
1434
  }
1262
1435
 
1263
1436
  function setFlag(flags, name, value) {
@@ -1282,6 +1455,13 @@ function parseInteger(value, fallback) {
1282
1455
  return parsed;
1283
1456
  }
1284
1457
 
1458
+ function parseNumber(value, name) {
1459
+ if (value === undefined || value === null || value === "") return undefined;
1460
+ const parsed = Number(value);
1461
+ if (!Number.isFinite(parsed)) throw usage(`Expected a number for --${name}, received ${value}`);
1462
+ return parsed;
1463
+ }
1464
+
1285
1465
  function requirePositional(positionals, index, label) {
1286
1466
  const value = positionals[index];
1287
1467
  if (!value) throw usage(`Missing ${label}`);
@@ -1301,6 +1481,10 @@ function csvOrRepeated(value) {
1301
1481
  return values.flatMap((item) => String(item).split(",").map((part) => part.trim()).filter(Boolean));
1302
1482
  }
1303
1483
 
1484
+ function optionalCsvOrRepeated(value) {
1485
+ return value === undefined ? undefined : csvOrRepeated(value);
1486
+ }
1487
+
1304
1488
  function firstValue(value) {
1305
1489
  return Array.isArray(value) ? value[0] : value;
1306
1490
  }
@@ -1360,7 +1544,11 @@ Core:
1360
1544
  Data products:
1361
1545
  answerlayer saved-queries list|get|create|update|delete|approve|unapprove|execute
1362
1546
  answerlayer semantic <entities|relationships|measures|metrics|dimensions|filters> list|get|create|update|delete|delete-all|generate
1363
- answerlayer inquiry ask|sessions|create-session|session|update-session|delete-session|turn
1547
+ answerlayer inquiry models|ask|sessions|create-session|session|update-session|delete-session|turn
1548
+ answerlayer evals suites list|create|get|update|delete
1549
+ answerlayer evals cases create|update|delete
1550
+ answerlayer evals runs list|create|get|cancel|compare
1551
+ create accepts --case <case-id> (repeat or comma-separate to select cases)
1364
1552
  answerlayer generation start|list|get|status|stream|cancel|questions|guidance|delete
1365
1553
  answerlayer tiles list|get|create|update|data|delete
1366
1554
  answerlayer dashboards list|get|create|update|delete|duplicate|manifest|attach-tile|move-tile|detach-tile|assignments|assign|unassign|tile-data