@answerlayer/cli 0.3.0 → 0.3.2
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 +80 -0
- package/package.json +3 -3
- package/skills/answerlayer/SKILL.md +31 -1
- package/src/cli.js +257 -2
package/README.md
CHANGED
|
@@ -83,6 +83,86 @@ export ANSWERLAYER_BASE_URL=https://answerlayer.your-company.com # optional ove
|
|
|
83
83
|
|
|
84
84
|
The CLI sends API keys using the `X-API-Key` header.
|
|
85
85
|
|
|
86
|
+
## Configure inquiry response policies
|
|
87
|
+
|
|
88
|
+
Response policies control answer presentation and uncertainty handling without
|
|
89
|
+
changing data access, semantic definitions, or citation integrity. Policies are
|
|
90
|
+
versioned: creating or revising a policy produces a draft, and inquiries use an
|
|
91
|
+
immutable revision once it is selected. API keys need `inquiry_policy:read` to
|
|
92
|
+
inspect policies and `inquiry_policy:write` to manage them.
|
|
93
|
+
|
|
94
|
+
Create and preview a policy before activating its first revision:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
answerlayer inquiry-policies preview \
|
|
98
|
+
--output-format table_first \
|
|
99
|
+
--precision-mode significant_figures --precision-value 4 \
|
|
100
|
+
--require-identifiers --require-numeric-support \
|
|
101
|
+
--insufficient-data ask_for_clarification \
|
|
102
|
+
--proxy-behavior require_confirmation \
|
|
103
|
+
--guidance "Lead with the decision-relevant result." --json
|
|
104
|
+
|
|
105
|
+
answerlayer inquiry-policies create \
|
|
106
|
+
--name "Board answers" \
|
|
107
|
+
--description "Concise, board-ready answers" \
|
|
108
|
+
--output-format table_first \
|
|
109
|
+
--precision-mode significant_figures --precision-value 4 \
|
|
110
|
+
--require-identifiers --require-numeric-support \
|
|
111
|
+
--insufficient-data ask_for_clarification \
|
|
112
|
+
--proxy-behavior require_confirmation \
|
|
113
|
+
--guidance "Lead with the decision-relevant result." --json
|
|
114
|
+
|
|
115
|
+
answerlayer inquiry-policies activate "Board answers" 1 --json
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Policy options accept these values:
|
|
119
|
+
|
|
120
|
+
- `--output-format`: `concise`, `narrative`, or `table_first`.
|
|
121
|
+
- `--precision-mode`: `preserve_source`, `minimum_decimal_places` (value
|
|
122
|
+
`0-10`), or `significant_figures` (value `1-15`). `preserve_source` does not
|
|
123
|
+
accept `--precision-value`.
|
|
124
|
+
- Evidence switches: `--require-identifiers` / `--no-require-identifiers` and
|
|
125
|
+
`--require-numeric-support` / `--no-require-numeric-support`.
|
|
126
|
+
- `--insufficient-data`: `explain_and_stop`, `ask_for_clarification`, or
|
|
127
|
+
`conditional_proxy`.
|
|
128
|
+
- `--proxy-behavior`: `forbid_unconfirmed`, `require_confirmation`, or
|
|
129
|
+
`allow_with_prominent_qualification`.
|
|
130
|
+
- `--guidance`: optional administrator instructions for tone, structure,
|
|
131
|
+
terminology, and caveats. Platform safety and data-authority rules retain
|
|
132
|
+
higher precedence.
|
|
133
|
+
|
|
134
|
+
Create a new immutable draft revision, then activate it explicitly:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
answerlayer inquiry-policies revise "Board answers" \
|
|
138
|
+
--output-format concise \
|
|
139
|
+
--precision-mode preserve_source \
|
|
140
|
+
--guidance "State the result before supporting detail." --json
|
|
141
|
+
answerlayer inquiry-policies activate "Board answers" 2 --json
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Set the active policy as the organization default or override it for one
|
|
145
|
+
connection. Resolution precedence is explicit policy, connection default,
|
|
146
|
+
organization default, then the built-in platform policy:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
answerlayer inquiry-policies set-default organization "Board answers" --json
|
|
150
|
+
answerlayer inquiry-policies set-default connection <connection-id> "Board answers" --json
|
|
151
|
+
answerlayer inquiry-policies effective --connection <connection-id> --json
|
|
152
|
+
answerlayer inquiry-policies clear-default connection <connection-id>
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Omit `--policy` to use those defaults, or pin a policy and exact revision for a
|
|
156
|
+
new inquiry or evaluation run. Existing sessions and runs remain pinned even if
|
|
157
|
+
a different revision is activated later:
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
answerlayer inquiry create-session --connection <connection-id> \
|
|
161
|
+
--policy "Board answers" --policy-version 2 --json
|
|
162
|
+
answerlayer evals runs create --suite <suite-id> \
|
|
163
|
+
--policy "Board answers" --policy-version 2 --json
|
|
164
|
+
```
|
|
165
|
+
|
|
86
166
|
## Operate API pipelines
|
|
87
167
|
|
|
88
168
|
API pipeline authoring and lifecycle operations are CLI-first. The AnswerLayer
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@answerlayer/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Open-source command line client for the AnswerLayer API.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
-
"answerlayer": "
|
|
8
|
-
"al": "
|
|
7
|
+
"answerlayer": "bin/answerlayer.js",
|
|
8
|
+
"al": "bin/answerlayer.js"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"bin",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: answerlayer
|
|
3
|
-
description: Query databases and operate customer-owned API pipelines with AnswerLayer. Use when the user wants to set up or configure AnswerLayer, connect to their data, ask analytical or business questions about a database, run SQL, or manage AnswerLayer API pipelines, connections, saved queries, the semantic layer, or dashboards.
|
|
3
|
+
description: Query databases and operate customer-owned API pipelines with AnswerLayer. Use when the user wants to set up or configure AnswerLayer, connect to their data, ask analytical or business questions about a database, run SQL, or manage AnswerLayer response policies, API pipelines, connections, saved queries, the semantic layer, or dashboards.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# AnswerLayer
|
|
@@ -167,6 +167,34 @@ AL query run <connection-id> --file ./report.sql --format csv
|
|
|
167
167
|
AL query validate <connection-id> --sql "select * from orders"
|
|
168
168
|
```
|
|
169
169
|
|
|
170
|
+
### Manage inquiry response policies
|
|
171
|
+
|
|
172
|
+
Use `AL inquiry-policies list|get|effective --json` to inspect policies and the
|
|
173
|
+
default resolved for a connection. Policy mutations require the user's
|
|
174
|
+
confirmation. Preview configuration before creating or revising it:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
AL inquiry-policies preview \
|
|
178
|
+
--output-format table_first \
|
|
179
|
+
--precision-mode significant_figures --precision-value 4 \
|
|
180
|
+
--require-identifiers --require-numeric-support \
|
|
181
|
+
--insufficient-data ask_for_clarification \
|
|
182
|
+
--proxy-behavior require_confirmation \
|
|
183
|
+
--guidance "Lead with the result." --json
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
After confirmation, use `create --name <name>` or `revise <policy>`, then
|
|
187
|
+
activate the returned revision explicitly with
|
|
188
|
+
`activate <policy> <revision-id-or-version>`. Set defaults with
|
|
189
|
+
`set-default organization <policy>` or
|
|
190
|
+
`set-default connection <connection-id> <policy>`.
|
|
191
|
+
|
|
192
|
+
New inquiries and eval runs inherit connection, organization, then platform
|
|
193
|
+
defaults. Use `--policy <id-or-name> --policy-version <number-or-revision-id>`
|
|
194
|
+
to pin an exact revision. Existing sessions and runs remain pinned when a later
|
|
195
|
+
revision is activated. Run `AL --help` for all allowed configuration values and
|
|
196
|
+
precision ranges.
|
|
197
|
+
|
|
170
198
|
### Other resources
|
|
171
199
|
|
|
172
200
|
These follow `AL <group> <command>`. Run `AL <group> --help` (or `AL --help`)
|
|
@@ -179,6 +207,8 @@ to see exact flags before using one:
|
|
|
179
207
|
- `generation` — generate semantic components, optionally grounded by an eval suite's authoring cases; holdout and adversarial cases are rejected
|
|
180
208
|
- `dashboards`, `tiles` — build and read dashboards
|
|
181
209
|
- `documents` — upload business-context docs and link them to connections
|
|
210
|
+
- `inquiry-policies` — preview, create, revise, activate, archive, and assign
|
|
211
|
+
versioned answer-formatting and uncertainty-handling policies
|
|
182
212
|
- `connections` — create / test / inspect schema
|
|
183
213
|
- `pipelines` — create, inspect, update, validate, connection-test, probe,
|
|
184
214
|
promote, run with explicit dataset scope and idempotency, retry from durable
|
package/src/cli.js
CHANGED
|
@@ -55,6 +55,7 @@ export async function main(argv, io) {
|
|
|
55
55
|
if (group === "query-results" || group === "results") return handleQueryResults(client, command, positionals, parsed, 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
|
+
if (group === "inquiry-policies" || group === "policies") return handleInquiryPolicies(client, command, positionals, parsed, io);
|
|
58
59
|
if (group === "inquiry") return handleInquiry(client, command, positionals, parsed, io);
|
|
59
60
|
if (group === "evals" || group === "evaluations") return handleEvals(client, command, positionals, parsed, io);
|
|
60
61
|
if (group === "optimize" || group === "optimization" || group === "semantic-optimization") {
|
|
@@ -794,8 +795,13 @@ async function handleInquiry(client, command, positionals, parsed, io) {
|
|
|
794
795
|
let sessionId = firstValue(parsed.flags.session);
|
|
795
796
|
if (!sessionId) {
|
|
796
797
|
if (!connectionId) throw usage("inquiry ask requires --connection when --session is not provided");
|
|
798
|
+
const policy = await resolvePolicySelection(client, parsed.flags);
|
|
797
799
|
const session = await client.request("POST", "/api/v1/inquiry/sessions", {
|
|
798
|
-
body: {
|
|
800
|
+
body: {
|
|
801
|
+
connection_id: connectionId,
|
|
802
|
+
model: firstValue(parsed.flags.model),
|
|
803
|
+
...policy,
|
|
804
|
+
},
|
|
799
805
|
});
|
|
800
806
|
sessionId = session.session_id;
|
|
801
807
|
}
|
|
@@ -833,10 +839,12 @@ async function handleInquiry(client, command, positionals, parsed, io) {
|
|
|
833
839
|
}
|
|
834
840
|
|
|
835
841
|
if (command === "create-session") {
|
|
842
|
+
const policy = await resolvePolicySelection(client, parsed.flags);
|
|
836
843
|
return requestAndPrint(client, "POST", "/api/v1/inquiry/sessions", parsed, io, {
|
|
837
844
|
body: await readData(parsed.flags, io, {
|
|
838
845
|
connection_id: firstValue(parsed.flags.connection),
|
|
839
846
|
model: firstValue(parsed.flags.model),
|
|
847
|
+
...policy,
|
|
840
848
|
}),
|
|
841
849
|
});
|
|
842
850
|
}
|
|
@@ -870,6 +878,198 @@ async function handleInquiry(client, command, positionals, parsed, io) {
|
|
|
870
878
|
throw usage(`Unknown inquiry command: ${command}`);
|
|
871
879
|
}
|
|
872
880
|
|
|
881
|
+
async function handleInquiryPolicies(client, command, positionals, parsed, io) {
|
|
882
|
+
const base = "/api/v1/inquiry-policies";
|
|
883
|
+
if (command === "list" || !command) {
|
|
884
|
+
return requestAndPrint(client, "GET", base, parsed, io, {
|
|
885
|
+
query: { include_archived: parsed.flags.includeArchived || undefined },
|
|
886
|
+
table: [
|
|
887
|
+
{ key: "id", label: "ID" },
|
|
888
|
+
{ key: "name", label: "Name" },
|
|
889
|
+
{ key: "status", label: "Status" },
|
|
890
|
+
{ key: "active_version", label: "Version" },
|
|
891
|
+
{ key: "active_content_sha256", label: "Content hash" },
|
|
892
|
+
],
|
|
893
|
+
});
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
if (["create", "preview"].includes(command)) {
|
|
897
|
+
const payload = await readData(parsed.flags, io, policyContentPayload(parsed.flags, {
|
|
898
|
+
includeMetadata: command === "create",
|
|
899
|
+
}));
|
|
900
|
+
if (command === "create") {
|
|
901
|
+
requirePayloadValue(payload, "name", "inquiry-policies create requires --name");
|
|
902
|
+
}
|
|
903
|
+
return requestAndPrint(client, "POST", command === "preview" ? `${base}/preview` : base, parsed, io, {
|
|
904
|
+
body: payload,
|
|
905
|
+
});
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
if (command === "effective") {
|
|
909
|
+
const connectionId = firstValue(parsed.flags.connection) || positionals[0];
|
|
910
|
+
if (!connectionId) throw usage("inquiry-policies effective requires --connection");
|
|
911
|
+
return requestAndPrint(client, "GET", `${base}/defaults/effective`, parsed, io, {
|
|
912
|
+
query: { connection_id: connectionId },
|
|
913
|
+
});
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
if (command === "set-default") {
|
|
917
|
+
const scope = positionals[0];
|
|
918
|
+
const policyRef = positionals[scope === "connection" ? 2 : 1] || firstValue(parsed.flags.policy);
|
|
919
|
+
if (!policyRef) throw usage("inquiry-policies set-default requires a policy id or name");
|
|
920
|
+
const { policy_id } = await resolvePolicySelection(client, { policy: policyRef });
|
|
921
|
+
if (scope === "organization" || scope === "org") {
|
|
922
|
+
return requestAndPrint(client, "PUT", `${base}/defaults/organization`, parsed, io, {
|
|
923
|
+
body: { policy_id },
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
if (scope === "connection") {
|
|
927
|
+
const connectionId = positionals[1] || firstValue(parsed.flags.connection);
|
|
928
|
+
if (!connectionId) throw usage("connection default requires a connection id");
|
|
929
|
+
return requestAndPrint(client, "PUT", `${base}/defaults/connections/${encodeURIComponent(connectionId)}`, parsed, io, {
|
|
930
|
+
body: { policy_id },
|
|
931
|
+
});
|
|
932
|
+
}
|
|
933
|
+
throw usage("Expected inquiry-policies set-default organization|connection");
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
if (command === "clear-default") {
|
|
937
|
+
const scope = positionals[0];
|
|
938
|
+
if (scope === "organization" || scope === "org") {
|
|
939
|
+
return requestAndPrint(client, "DELETE", `${base}/defaults/organization`, parsed, io);
|
|
940
|
+
}
|
|
941
|
+
if (scope === "connection") {
|
|
942
|
+
const connectionId = positionals[1] || firstValue(parsed.flags.connection);
|
|
943
|
+
if (!connectionId) throw usage("connection default requires a connection id");
|
|
944
|
+
return requestAndPrint(client, "DELETE", `${base}/defaults/connections/${encodeURIComponent(connectionId)}`, parsed, io);
|
|
945
|
+
}
|
|
946
|
+
throw usage("Expected inquiry-policies clear-default organization|connection");
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
const policyRef = positionals[0] || firstValue(parsed.flags.policy);
|
|
950
|
+
if (!policyRef) throw usage(`inquiry-policies ${command} requires a policy id or name`);
|
|
951
|
+
const { policy_id: policyId } = await resolvePolicySelection(client, { policy: policyRef });
|
|
952
|
+
if (command === "get") {
|
|
953
|
+
return requestAndPrint(client, "GET", `${base}/${encodeURIComponent(policyId)}`, parsed, io);
|
|
954
|
+
}
|
|
955
|
+
if (command === "revise") {
|
|
956
|
+
return requestAndPrint(client, "POST", `${base}/${encodeURIComponent(policyId)}/revisions`, parsed, io, {
|
|
957
|
+
body: await readData(parsed.flags, io, {
|
|
958
|
+
...policyContentPayload(parsed.flags),
|
|
959
|
+
base_revision_id: firstValue(parsed.flags.baseRevision),
|
|
960
|
+
}),
|
|
961
|
+
});
|
|
962
|
+
}
|
|
963
|
+
if (command === "activate") {
|
|
964
|
+
const revisionRef = positionals[1] || firstValue(parsed.flags.policyVersion);
|
|
965
|
+
if (!revisionRef) throw usage("inquiry-policies activate requires a revision id or version");
|
|
966
|
+
const { policy_revision_id: revisionId } = await resolvePolicySelection(client, {
|
|
967
|
+
policy: policyId,
|
|
968
|
+
policyVersion: revisionRef,
|
|
969
|
+
});
|
|
970
|
+
return requestAndPrint(client, "POST", `${base}/${encodeURIComponent(policyId)}/revisions/${encodeURIComponent(revisionId)}/activate`, parsed, io);
|
|
971
|
+
}
|
|
972
|
+
if (command === "archive" || command === "delete") {
|
|
973
|
+
return requestAndPrint(client, "POST", `${base}/${encodeURIComponent(policyId)}/archive`, parsed, io);
|
|
974
|
+
}
|
|
975
|
+
throw usage(`Unknown inquiry-policies command: ${command}`);
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
function policyContentPayload(flags, { includeMetadata = false } = {}) {
|
|
979
|
+
if (flags.requireIdentifiers && flags.noRequireIdentifiers) {
|
|
980
|
+
throw usage("Use only one of --require-identifiers or --no-require-identifiers");
|
|
981
|
+
}
|
|
982
|
+
if (flags.requireNumericSupport && flags.noRequireNumericSupport) {
|
|
983
|
+
throw usage("Use only one of --require-numeric-support or --no-require-numeric-support");
|
|
984
|
+
}
|
|
985
|
+
const evidence = dropUndefined({
|
|
986
|
+
require_identifiers: flags.requireIdentifiers
|
|
987
|
+
? true
|
|
988
|
+
: (flags.noRequireIdentifiers ? false : undefined),
|
|
989
|
+
require_numeric_support: flags.requireNumericSupport
|
|
990
|
+
? true
|
|
991
|
+
: (flags.noRequireNumericSupport ? false : undefined),
|
|
992
|
+
});
|
|
993
|
+
const outputFormat = enumFlag(flags.outputFormat, "output-format", [
|
|
994
|
+
"concise", "narrative", "table_first",
|
|
995
|
+
]);
|
|
996
|
+
const insufficientDataBehavior = enumFlag(flags.insufficientData, "insufficient-data", [
|
|
997
|
+
"explain_and_stop", "ask_for_clarification", "conditional_proxy",
|
|
998
|
+
]);
|
|
999
|
+
const proxyBehavior = enumFlag(flags.proxyBehavior, "proxy-behavior", [
|
|
1000
|
+
"forbid_unconfirmed", "require_confirmation", "allow_with_prominent_qualification",
|
|
1001
|
+
]);
|
|
1002
|
+
const config = dropUndefined({
|
|
1003
|
+
output_format: outputFormat,
|
|
1004
|
+
numeric_precision: policyNumericPrecision(flags),
|
|
1005
|
+
insufficient_data_behavior: insufficientDataBehavior,
|
|
1006
|
+
proxy_behavior: proxyBehavior,
|
|
1007
|
+
evidence: Object.keys(evidence).length ? evidence : undefined,
|
|
1008
|
+
});
|
|
1009
|
+
return dropUndefined({
|
|
1010
|
+
...(includeMetadata ? {
|
|
1011
|
+
name: firstValue(flags.name),
|
|
1012
|
+
description: firstValue(flags.description),
|
|
1013
|
+
} : {}),
|
|
1014
|
+
config: Object.keys(config).length ? config : undefined,
|
|
1015
|
+
administrator_guidance: firstValue(flags.guidance),
|
|
1016
|
+
});
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
function policyNumericPrecision(flags) {
|
|
1020
|
+
const mode = enumFlag(flags.precisionMode, "precision-mode", [
|
|
1021
|
+
"preserve_source", "minimum_decimal_places", "significant_figures",
|
|
1022
|
+
]);
|
|
1023
|
+
const rawValue = firstValue(flags.precisionValue);
|
|
1024
|
+
if (!mode) {
|
|
1025
|
+
if (rawValue !== undefined) throw usage("--precision-value requires --precision-mode");
|
|
1026
|
+
return undefined;
|
|
1027
|
+
}
|
|
1028
|
+
if (mode === "preserve_source") {
|
|
1029
|
+
if (rawValue !== undefined) throw usage("--precision-mode preserve_source does not accept --precision-value");
|
|
1030
|
+
return { mode };
|
|
1031
|
+
}
|
|
1032
|
+
if (rawValue === undefined || rawValue === "") {
|
|
1033
|
+
throw usage(`--precision-mode ${mode} requires --precision-value`);
|
|
1034
|
+
}
|
|
1035
|
+
const [minimum, maximum] = mode === "minimum_decimal_places" ? [0, 10] : [1, 15];
|
|
1036
|
+
return {
|
|
1037
|
+
mode,
|
|
1038
|
+
value: parseBoundedInteger(rawValue, "precision-value", minimum, maximum),
|
|
1039
|
+
};
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
async function resolvePolicySelection(client, flags) {
|
|
1043
|
+
const reference = firstValue(flags.policy);
|
|
1044
|
+
const versionReference = firstValue(flags.policyVersion);
|
|
1045
|
+
if (!reference) {
|
|
1046
|
+
if (versionReference) throw usage("--policy-version requires --policy");
|
|
1047
|
+
return {};
|
|
1048
|
+
}
|
|
1049
|
+
let policyId = reference;
|
|
1050
|
+
if (!isUuid(reference)) {
|
|
1051
|
+
const policies = await client.request("GET", "/api/v1/inquiry-policies");
|
|
1052
|
+
const matches = policies.filter((policy) => policy.name.toLowerCase() === reference.toLowerCase());
|
|
1053
|
+
if (matches.length !== 1) {
|
|
1054
|
+
throw usage(matches.length ? `Policy name is ambiguous: ${reference}` : `Policy not found: ${reference}`);
|
|
1055
|
+
}
|
|
1056
|
+
policyId = matches[0].id;
|
|
1057
|
+
}
|
|
1058
|
+
if (!versionReference) return { policy_id: policyId };
|
|
1059
|
+
if (isUuid(versionReference)) {
|
|
1060
|
+
return { policy_id: policyId, policy_revision_id: versionReference };
|
|
1061
|
+
}
|
|
1062
|
+
const version = parsePositiveInteger(versionReference, "policy-version");
|
|
1063
|
+
const policy = await client.request("GET", `/api/v1/inquiry-policies/${encodeURIComponent(policyId)}`);
|
|
1064
|
+
const revision = policy.revisions.find((item) => item.version === version);
|
|
1065
|
+
if (!revision) throw usage(`Policy ${reference} has no version ${version}`);
|
|
1066
|
+
return { policy_id: policyId, policy_revision_id: revision.id };
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
function isUuid(value) {
|
|
1070
|
+
return /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value);
|
|
1071
|
+
}
|
|
1072
|
+
|
|
873
1073
|
async function handleEvals(client, resource, positionals, parsed, io) {
|
|
874
1074
|
const [command, ...rest] = positionals;
|
|
875
1075
|
const base = "/api/v1/evals";
|
|
@@ -964,6 +1164,7 @@ async function handleEvals(client, resource, positionals, parsed, io) {
|
|
|
964
1164
|
case_ids: optionalCsvOrRepeated(parsed.flags.case),
|
|
965
1165
|
categories: optionalDistinctRepeated(parsed.flags.category),
|
|
966
1166
|
case_concurrency: firstValue(parsed.flags.concurrency),
|
|
1167
|
+
...await resolvePolicySelection(client, parsed.flags),
|
|
967
1168
|
});
|
|
968
1169
|
requirePayloadValue(payload, "suite_id", "evals runs create requires a suite id or --suite");
|
|
969
1170
|
normalizeEvalCaseConcurrency(payload);
|
|
@@ -981,6 +1182,7 @@ async function handleEvals(client, resource, positionals, parsed, io) {
|
|
|
981
1182
|
model: firstValue(parsed.flags.model),
|
|
982
1183
|
use_semantic_layer: semanticLayerMode(parsed.flags),
|
|
983
1184
|
case_concurrency: firstValue(parsed.flags.concurrency),
|
|
1185
|
+
...await resolvePolicySelection(client, parsed.flags),
|
|
984
1186
|
});
|
|
985
1187
|
requireEvalBatchSuites(payload.suite_ids);
|
|
986
1188
|
normalizeEvalCaseConcurrency(payload);
|
|
@@ -2026,6 +2228,19 @@ function normalizeFlagName(rawName) {
|
|
|
2026
2228
|
"--h": "h",
|
|
2027
2229
|
"--prompt": "prompt",
|
|
2028
2230
|
"--model": "model",
|
|
2231
|
+
"--policy": "policy",
|
|
2232
|
+
"--policy-version": "policyVersion",
|
|
2233
|
+
"--base-revision": "baseRevision",
|
|
2234
|
+
"--guidance": "guidance",
|
|
2235
|
+
"--output-format": "outputFormat",
|
|
2236
|
+
"--precision-mode": "precisionMode",
|
|
2237
|
+
"--precision-value": "precisionValue",
|
|
2238
|
+
"--insufficient-data": "insufficientData",
|
|
2239
|
+
"--proxy-behavior": "proxyBehavior",
|
|
2240
|
+
"--require-identifiers": "requireIdentifiers",
|
|
2241
|
+
"--no-require-identifiers": "noRequireIdentifiers",
|
|
2242
|
+
"--require-numeric-support": "requireNumericSupport",
|
|
2243
|
+
"--no-require-numeric-support": "noRequireNumericSupport",
|
|
2029
2244
|
"--mode": "mode",
|
|
2030
2245
|
"--reason": "reason",
|
|
2031
2246
|
"--component": "component",
|
|
@@ -2098,7 +2313,7 @@ function normalizeFlagName(rawName) {
|
|
|
2098
2313
|
}
|
|
2099
2314
|
|
|
2100
2315
|
function isBooleanFlag(rawName) {
|
|
2101
|
-
return ["--json", "--help", "-h", "--include", "-i", "--raw", "--admin", "--force", "--follow", "--active", "--inactive", "--include-inactive", "--include-semantic-snapshot", "--include-archived", "--clear-description", "--use-semantic-layer", "--no-semantic-layer", "--no-demo", "--yes", "-y", "--wait", "--armed", "--paused"].includes(rawName);
|
|
2316
|
+
return ["--json", "--help", "-h", "--include", "-i", "--raw", "--admin", "--force", "--follow", "--active", "--inactive", "--include-inactive", "--include-semantic-snapshot", "--include-archived", "--clear-description", "--use-semantic-layer", "--no-semantic-layer", "--require-identifiers", "--no-require-identifiers", "--require-numeric-support", "--no-require-numeric-support", "--no-demo", "--yes", "-y", "--wait", "--armed", "--paused"].includes(rawName);
|
|
2102
2317
|
}
|
|
2103
2318
|
|
|
2104
2319
|
function setFlag(flags, name, value) {
|
|
@@ -2161,6 +2376,23 @@ function parseBoundedInteger(value, name, minimum, maximum) {
|
|
|
2161
2376
|
return parsed;
|
|
2162
2377
|
}
|
|
2163
2378
|
|
|
2379
|
+
function parsePositiveInteger(value, name) {
|
|
2380
|
+
const parsed = Number(value);
|
|
2381
|
+
if (!Number.isSafeInteger(parsed) || parsed < 1) {
|
|
2382
|
+
throw usage(`--${name} must be a positive integer or revision UUID`);
|
|
2383
|
+
}
|
|
2384
|
+
return parsed;
|
|
2385
|
+
}
|
|
2386
|
+
|
|
2387
|
+
function enumFlag(value, name, allowed) {
|
|
2388
|
+
const selected = firstValue(value);
|
|
2389
|
+
if (selected === undefined || selected === "") return undefined;
|
|
2390
|
+
if (!allowed.includes(selected)) {
|
|
2391
|
+
throw usage(`--${name} must be one of: ${allowed.join(", ")}`);
|
|
2392
|
+
}
|
|
2393
|
+
return selected;
|
|
2394
|
+
}
|
|
2395
|
+
|
|
2164
2396
|
function requiredBoundedFlag(value, name, minimum, maximum) {
|
|
2165
2397
|
const first = firstValue(value);
|
|
2166
2398
|
if (first === undefined || first === "") {
|
|
@@ -2299,6 +2531,27 @@ Data products:
|
|
|
2299
2531
|
answerlayer saved-queries list|get|create|update|delete|approve|unapprove|execute
|
|
2300
2532
|
answerlayer semantic <entities|relationships|measures|metrics|dimensions|filters> list|get|create|update|delete|delete-all|generate
|
|
2301
2533
|
answerlayer inquiry models|ask|sessions|create-session|session|update-session|delete-session|turn
|
|
2534
|
+
answerlayer inquiry-policies list [--include-archived]
|
|
2535
|
+
answerlayer inquiry-policies get <policy-id-or-name>
|
|
2536
|
+
answerlayer inquiry-policies create --name <name> [policy options]
|
|
2537
|
+
answerlayer inquiry-policies revise <policy-id-or-name> [policy options]
|
|
2538
|
+
answerlayer inquiry-policies preview [policy options]
|
|
2539
|
+
answerlayer inquiry-policies activate <policy-id-or-name> <revision-id-or-version>
|
|
2540
|
+
answerlayer inquiry-policies archive <policy-id-or-name>
|
|
2541
|
+
answerlayer inquiry-policies effective --connection <connection-id>
|
|
2542
|
+
answerlayer inquiry-policies set-default organization <policy-id-or-name>
|
|
2543
|
+
answerlayer inquiry-policies set-default connection <connection-id> <policy-id-or-name>
|
|
2544
|
+
answerlayer inquiry-policies clear-default organization
|
|
2545
|
+
answerlayer inquiry-policies clear-default connection <connection-id>
|
|
2546
|
+
Policy options:
|
|
2547
|
+
--description <text> --guidance <text>
|
|
2548
|
+
--output-format <concise|narrative|table_first>
|
|
2549
|
+
--precision-mode <preserve_source|minimum_decimal_places|significant_figures>
|
|
2550
|
+
--precision-value <0-10 decimal places|1-15 significant figures>
|
|
2551
|
+
--require-identifiers|--no-require-identifiers
|
|
2552
|
+
--require-numeric-support|--no-require-numeric-support
|
|
2553
|
+
--insufficient-data <explain_and_stop|ask_for_clarification|conditional_proxy>
|
|
2554
|
+
--proxy-behavior <forbid_unconfirmed|require_confirmation|allow_with_prominent_qualification>
|
|
2302
2555
|
answerlayer evals suites list|create|get|update|delete
|
|
2303
2556
|
answerlayer evals cases create|update|delete
|
|
2304
2557
|
answerlayer evals runs list|create|create-batch|get|update|cancel|compare|analyze
|
|
@@ -2310,6 +2563,8 @@ Data products:
|
|
|
2310
2563
|
--category <name> (repeat; category and case selectors are unioned),
|
|
2311
2564
|
--concurrency <1-8> (default 3; 1 is serial), and
|
|
2312
2565
|
--use-semantic-layer or --no-semantic-layer
|
|
2566
|
+
inquiry and eval run creation accept --policy <id-or-name> and
|
|
2567
|
+
--policy-version <number-or-revision-id>
|
|
2313
2568
|
create-batch accepts 2 to 20 suite ids as positionals or repeatable
|
|
2314
2569
|
--suite values, plus shared --label, --model, --concurrency <1-8>,
|
|
2315
2570
|
and --use-semantic-layer or --no-semantic-layer
|