@hue-run/sdk 0.12.1 → 0.13.1
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/CLI.md +44 -19
- package/ENVIRONMENTS.md +23 -6
- package/EVALUATIONS.md +19 -1
- package/README.md +29 -13
- package/dist/client.d.ts +8 -0
- package/dist/client.js +23 -2
- package/dist/environment/types.d.ts +8 -1
- package/dist/environment/world.d.ts +14 -1
- package/dist/environment/world.js +61 -4
- package/dist/environment.d.ts +1 -1
- package/dist/environment.js +1 -1
- package/dist/evals/client.d.ts +37 -6
- package/dist/evals/client.js +44 -5
- package/dist/evals/failure.d.ts +17 -0
- package/dist/evals/failure.js +102 -0
- package/dist/evals/runner.js +21 -12
- package/dist/evals/scorer-publication.js +9 -2
- package/dist/evals/scorers.js +3 -1
- package/dist/evals/types.d.ts +58 -0
- package/dist/privacy.d.ts +18 -0
- package/dist/privacy.js +147 -57
- package/dist/safety.d.ts +18 -0
- package/dist/safety.js +76 -23
- package/dist/transport.d.ts +5 -0
- package/dist/transport.js +277 -57
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/evals/client.js
CHANGED
|
@@ -89,6 +89,15 @@ function productRegistryFields(value) {
|
|
|
89
89
|
}
|
|
90
90
|
return result;
|
|
91
91
|
}
|
|
92
|
+
/** Tag names travel as given; anything but a list of strings is a caller error. */
|
|
93
|
+
function tagNames(tags) {
|
|
94
|
+
if (!Array.isArray(tags) || !tags.every((tag) => typeof tag === "string"))
|
|
95
|
+
throw new TypeError("tags must be a list of tag names");
|
|
96
|
+
return tags;
|
|
97
|
+
}
|
|
98
|
+
function withTagNames(input) {
|
|
99
|
+
return input.tags === undefined ? input : { ...input, tags: tagNames(input.tags) };
|
|
100
|
+
}
|
|
92
101
|
const runResponseAliases = [
|
|
93
102
|
["datasetId", "evalSetId"],
|
|
94
103
|
["datasetName", "evalSetName"],
|
|
@@ -388,15 +397,21 @@ export class EvaluationClient {
|
|
|
388
397
|
const query = new URLSearchParams(this.page(options).slice(1));
|
|
389
398
|
if (options.includeArchived !== undefined)
|
|
390
399
|
query.set("includeArchived", String(options.includeArchived));
|
|
400
|
+
for (const tag of tagNames(options.tags ?? []))
|
|
401
|
+
query.append("tag", tag);
|
|
391
402
|
return query.size ? `?${query}` : "";
|
|
392
403
|
}
|
|
393
404
|
/** Reads the current project to confirm the key and origin. */
|
|
394
405
|
checkConnection() {
|
|
395
406
|
return this.request("GET", "/projects/current");
|
|
396
407
|
}
|
|
397
|
-
/** Creates a dataset with an initial draft version. */
|
|
408
|
+
/** Creates a dataset with an initial draft version; `tags` names the tags it starts with. */
|
|
398
409
|
createDataset(input) {
|
|
399
|
-
return this.request("POST", "/datasets", input);
|
|
410
|
+
return this.request("POST", "/datasets", withTagNames(input));
|
|
411
|
+
}
|
|
412
|
+
/** Renames a dataset or replaces its tags by name; the same values again change nothing. */
|
|
413
|
+
updateDataset(id, input) {
|
|
414
|
+
return this.request("PATCH", `/datasets/${uuid(id)}`, withTagNames(input), undefined, undefined, true);
|
|
400
415
|
}
|
|
401
416
|
/** Reads a dataset and its versions. */
|
|
402
417
|
getDataset(id) {
|
|
@@ -430,7 +445,15 @@ export class EvaluationClient {
|
|
|
430
445
|
}
|
|
431
446
|
/** Creates a scorer identity; publish definitions with {@link publishScorerVersion}. */
|
|
432
447
|
createScorer(input) {
|
|
433
|
-
return this.request("POST", "/scorers", input);
|
|
448
|
+
return this.request("POST", "/scorers", withTagNames(input));
|
|
449
|
+
}
|
|
450
|
+
/** Renames a scorer or replaces its tags by name; the same values again change nothing. */
|
|
451
|
+
updateScorer(id, input) {
|
|
452
|
+
return this.request("PATCH", `/scorers/${uuid(id)}`, withTagNames(input), undefined, undefined, true);
|
|
453
|
+
}
|
|
454
|
+
/** Lists the project's tags in the order they were created. */
|
|
455
|
+
listTags() {
|
|
456
|
+
return this.request("GET", "/tags");
|
|
434
457
|
}
|
|
435
458
|
/** Reads a scorer and its published versions. */
|
|
436
459
|
getScorer(id) {
|
|
@@ -452,6 +475,10 @@ export class EvaluationClient {
|
|
|
452
475
|
async createEvalSet(input) {
|
|
453
476
|
return productRegistryFields(await this.createDataset(input));
|
|
454
477
|
}
|
|
478
|
+
/** Renames an eval set or replaces its tags by name. */
|
|
479
|
+
async updateEvalSet(id, input) {
|
|
480
|
+
return productRegistryFields(await this.updateDataset(id, input));
|
|
481
|
+
}
|
|
455
482
|
/** Reads an eval set and its versions. */
|
|
456
483
|
async getEvalSet(id) {
|
|
457
484
|
return productRegistryFields(await this.getDataset(id));
|
|
@@ -484,6 +511,10 @@ export class EvaluationClient {
|
|
|
484
511
|
async createEvaluator(input) {
|
|
485
512
|
return productRegistryFields(await this.createScorer(input));
|
|
486
513
|
}
|
|
514
|
+
/** Renames an evaluator or replaces its tags by name. */
|
|
515
|
+
async updateEvaluator(id, input) {
|
|
516
|
+
return productRegistryFields(await this.updateScorer(id, input));
|
|
517
|
+
}
|
|
487
518
|
/** Reads an evaluator and its published versions. */
|
|
488
519
|
async getEvaluator(id) {
|
|
489
520
|
return productRegistryFields(await this.getScorer(id));
|
|
@@ -502,12 +533,16 @@ export class EvaluationClient {
|
|
|
502
533
|
}
|
|
503
534
|
/** Creates an experiment over a frozen dataset version with pinned scorer versions and a configuration. */
|
|
504
535
|
createExperiment(input) {
|
|
505
|
-
return this.request("POST", "/experiments", input);
|
|
536
|
+
return this.request("POST", "/experiments", withTagNames(input));
|
|
506
537
|
}
|
|
507
538
|
/** Reads an experiment with its evaluation run and execution counts. */
|
|
508
539
|
getExperiment(id) {
|
|
509
540
|
return this.request("GET", `/experiments/${uuid(id)}`);
|
|
510
541
|
}
|
|
542
|
+
/** Renames an experiment or replaces its own tags by name. */
|
|
543
|
+
updateExperiment(id, input) {
|
|
544
|
+
return this.request("PATCH", `/experiments/${uuid(id)}`, withTagNames(input), undefined, undefined, true);
|
|
545
|
+
}
|
|
511
546
|
/** Lists an experiment's cases with their latest executions. */
|
|
512
547
|
listExperimentItems(id, page) {
|
|
513
548
|
return this.request("GET", `/experiments/${uuid(id)}/items${this.page(page)}`);
|
|
@@ -656,12 +691,16 @@ export class EvaluationClient {
|
|
|
656
691
|
}
|
|
657
692
|
/** Creates a run using product request fields on the existing v1 path. */
|
|
658
693
|
async createRun(input) {
|
|
659
|
-
return productRunFields(await this.request("POST", "/experiments", input), "run");
|
|
694
|
+
return productRunFields(await this.request("POST", "/experiments", withTagNames(input)), "run");
|
|
660
695
|
}
|
|
661
696
|
/** Reads a run with its scoring progress. */
|
|
662
697
|
async getRun(id) {
|
|
663
698
|
return productRunFields(await this.getExperiment(id), "run");
|
|
664
699
|
}
|
|
700
|
+
/** Renames a run or replaces its own tags by name; its eval set's tags are not its own. */
|
|
701
|
+
async updateRun(id, input) {
|
|
702
|
+
return this.updateExperiment(id, input);
|
|
703
|
+
}
|
|
665
704
|
/** Lists a run's cases with their latest executions. */
|
|
666
705
|
async listRunItems(id, page) {
|
|
667
706
|
return productRunFields(await this.listExperimentItems(id, page), "run");
|
package/dist/evals/failure.d.ts
CHANGED
|
@@ -10,9 +10,26 @@
|
|
|
10
10
|
* The runner records the type on the execution in place of `TargetError`; Hue classes the first
|
|
11
11
|
* three as infrastructure and the last as configuration, so an error from Hue's own clients is
|
|
12
12
|
* never filed as the agent's. Anything else is the agent's own error.
|
|
13
|
+
*
|
|
14
|
+
* A simulated world the agent reaches through its own client (an MCP client, a REST client, a
|
|
15
|
+
* fetch) answers Hue's gateway refusals with a status and a diagnostic: `503
|
|
16
|
+
* authorization_unavailable` when Hue could not authorize the world token because its database
|
|
17
|
+
* could not answer, `503 gateway_failure` when the gateway failed. The MCP SDK's transport throws
|
|
18
|
+
* these as `StreamableHTTPError` or `SseError` with the status as `code` and no response, so the
|
|
19
|
+
* status is read from there too; the diagnostic is the error's cause (`serviceFailureCause`),
|
|
20
|
+
* recorded beside the type so a run's reader sees what refused it.
|
|
13
21
|
*/
|
|
14
22
|
export type ServiceFailureType = "ServiceRefused" | "ConnectionFailed" | "TimedOut" | "ConfigurationRejected";
|
|
15
23
|
/** The service failure a target's throw shows, by the errors linked from it, in precedence
|
|
16
24
|
* order: a timeout, a failed connection, a retryable refusal, a status Hue's own client was
|
|
17
25
|
* refused with; null for the agent's own error. */
|
|
18
26
|
export declare function serviceFailureType(error: unknown): ServiceFailureType | null;
|
|
27
|
+
/**
|
|
28
|
+
* The service's own word for what failed, when the answer a target's throw carries names one:
|
|
29
|
+
* Hue's gateway diagnostic (`authorization_unavailable`, `gateway_failure`), read from the
|
|
30
|
+
* `x-hue-diagnostic` header or the JSON body's `diagnostic` of any error linked from the throw,
|
|
31
|
+
* nearest first. Undefined when no answer names one, or the name is not a diagnostic's token.
|
|
32
|
+
* Read for a service failure (`serviceFailureType`), where the runner records it as the error's
|
|
33
|
+
* `cause`.
|
|
34
|
+
*/
|
|
35
|
+
export declare function serviceFailureCause(error: unknown): string | undefined;
|
package/dist/evals/failure.js
CHANGED
|
@@ -69,6 +69,17 @@ function names(error) {
|
|
|
69
69
|
}
|
|
70
70
|
return found;
|
|
71
71
|
}
|
|
72
|
+
/** The MCP TypeScript SDK's transport errors, which carry the HTTP status as `code` and no
|
|
73
|
+
* response: a POST the server answered with a failing status (`StreamableHTTPError`) or an SSE
|
|
74
|
+
* stream it refused (`SseError`). Recognized by class name, never imported. */
|
|
75
|
+
const MCP_TRANSPORT_NAMES = new Set(["StreamableHTTPError", "SseError"]);
|
|
76
|
+
/** The status an MCP transport error carries, or undefined for any other error. */
|
|
77
|
+
function transportStatus(error) {
|
|
78
|
+
const { code } = error;
|
|
79
|
+
return typeof code === "number" && names(error).some((name) => MCP_TRANSPORT_NAMES.has(name))
|
|
80
|
+
? code
|
|
81
|
+
: undefined;
|
|
82
|
+
}
|
|
72
83
|
const retryable = (status) => typeof status === "number" &&
|
|
73
84
|
(status === 408 || status === 429 || (status >= 500 && status < 600));
|
|
74
85
|
function timedOut(error) {
|
|
@@ -99,6 +110,9 @@ function disconnected(error) {
|
|
|
99
110
|
function refused(error) {
|
|
100
111
|
if (hueClientError(error))
|
|
101
112
|
return retryable(error.status);
|
|
113
|
+
// An MCP transport error is the exchange itself: the server answered the status it carries.
|
|
114
|
+
if (retryable(transportStatus(error)))
|
|
115
|
+
return true;
|
|
102
116
|
const { status, statusCode, headers, response, url, responseHeaders } = error;
|
|
103
117
|
const exchanged = [headers, response, url, responseHeaders].some((item) => item !== undefined && item !== null);
|
|
104
118
|
// A fetch `Response` carries the status itself.
|
|
@@ -148,3 +162,91 @@ export function serviceFailureType(error) {
|
|
|
148
162
|
return "ConfigurationRejected";
|
|
149
163
|
return null;
|
|
150
164
|
}
|
|
165
|
+
/** The header Hue's gateway names its diagnostic in, beside the JSON body's `diagnostic`. */
|
|
166
|
+
const DIAGNOSTIC_HEADER = "x-hue-diagnostic";
|
|
167
|
+
/** A diagnostic's spelling: a short lower-case token (`authorization_unavailable`). */
|
|
168
|
+
const DIAGNOSTIC = /^[a-z][a-z0-9_]{0,63}$/;
|
|
169
|
+
/** The most of a body or message read for a diagnostic. */
|
|
170
|
+
const MAX_BODY = 8192;
|
|
171
|
+
/** A header's value from a `Headers`, a record of names to values (case-insensitive), or a
|
|
172
|
+
* record of names to arrays, as the HTTP clients spell them; undefined otherwise. */
|
|
173
|
+
function headerValue(headers, name) {
|
|
174
|
+
if (headers === null || typeof headers !== "object")
|
|
175
|
+
return undefined;
|
|
176
|
+
const get = headers.get;
|
|
177
|
+
if (typeof get === "function") {
|
|
178
|
+
const value = get.call(headers, name);
|
|
179
|
+
return typeof value === "string" ? value : undefined;
|
|
180
|
+
}
|
|
181
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
182
|
+
if (key.toLowerCase() !== name)
|
|
183
|
+
continue;
|
|
184
|
+
const first = Array.isArray(value) ? value[0] : value;
|
|
185
|
+
return typeof first === "string" ? first : undefined;
|
|
186
|
+
}
|
|
187
|
+
return undefined;
|
|
188
|
+
}
|
|
189
|
+
/** The `diagnostic` a JSON body names: an object's, at the top or in a JSON-RPC error's `data`,
|
|
190
|
+
* or the object a string carries from its first brace (an MCP transport error's message quotes
|
|
191
|
+
* the body it was answered). */
|
|
192
|
+
function bodyDiagnostic(body) {
|
|
193
|
+
if (typeof body === "string") {
|
|
194
|
+
const start = body.indexOf("{");
|
|
195
|
+
if (start < 0 || body.length - start > MAX_BODY)
|
|
196
|
+
return undefined;
|
|
197
|
+
try {
|
|
198
|
+
return bodyDiagnostic(JSON.parse(body.slice(start)));
|
|
199
|
+
}
|
|
200
|
+
catch {
|
|
201
|
+
return undefined;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (body === null || typeof body !== "object")
|
|
205
|
+
return undefined;
|
|
206
|
+
// Hue's REST refusal names it at the top; its MCP refusal, a JSON-RPC error, in `error.data`.
|
|
207
|
+
const { diagnostic, error } = body;
|
|
208
|
+
if (typeof diagnostic === "string")
|
|
209
|
+
return diagnostic;
|
|
210
|
+
const data = error !== null && typeof error === "object" ? error.data : undefined;
|
|
211
|
+
const named = data !== null && typeof data === "object"
|
|
212
|
+
? data.diagnostic
|
|
213
|
+
: undefined;
|
|
214
|
+
return typeof named === "string" ? named : undefined;
|
|
215
|
+
}
|
|
216
|
+
/** The diagnostic one error carries: the one it names itself (Hue's own clients read the header
|
|
217
|
+
* into `diagnostic`), else the header on its `headers`, `responseHeaders` or `response.headers`,
|
|
218
|
+
* else the body on its `responseBody`, `body` or, for an MCP transport error, its message. */
|
|
219
|
+
function diagnosticOf(error) {
|
|
220
|
+
const { diagnostic, headers, responseHeaders, response, responseBody, body, message } = error;
|
|
221
|
+
const answered = response !== null && typeof response === "object"
|
|
222
|
+
? response.headers
|
|
223
|
+
: undefined;
|
|
224
|
+
return ((typeof diagnostic === "string" ? diagnostic : undefined) ??
|
|
225
|
+
headerValue(headers, DIAGNOSTIC_HEADER) ??
|
|
226
|
+
headerValue(responseHeaders, DIAGNOSTIC_HEADER) ??
|
|
227
|
+
headerValue(answered, DIAGNOSTIC_HEADER) ??
|
|
228
|
+
bodyDiagnostic(responseBody) ??
|
|
229
|
+
bodyDiagnostic(body) ??
|
|
230
|
+
(transportStatus(error) !== undefined ? bodyDiagnostic(message) : undefined));
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* The service's own word for what failed, when the answer a target's throw carries names one:
|
|
234
|
+
* Hue's gateway diagnostic (`authorization_unavailable`, `gateway_failure`), read from the
|
|
235
|
+
* `x-hue-diagnostic` header or the JSON body's `diagnostic` of any error linked from the throw,
|
|
236
|
+
* nearest first. Undefined when no answer names one, or the name is not a diagnostic's token.
|
|
237
|
+
* Read for a service failure (`serviceFailureType`), where the runner records it as the error's
|
|
238
|
+
* `cause`.
|
|
239
|
+
*/
|
|
240
|
+
export function serviceFailureCause(error) {
|
|
241
|
+
for (const item of linked(error)) {
|
|
242
|
+
try {
|
|
243
|
+
const diagnostic = diagnosticOf(item);
|
|
244
|
+
if (diagnostic !== undefined && DIAGNOSTIC.test(diagnostic))
|
|
245
|
+
return diagnostic;
|
|
246
|
+
}
|
|
247
|
+
catch {
|
|
248
|
+
// A property that throws when read names nothing.
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return undefined;
|
|
252
|
+
}
|
package/dist/evals/runner.js
CHANGED
|
@@ -6,7 +6,7 @@ import { ROOT_CONTEXT } from "@opentelemetry/api";
|
|
|
6
6
|
import { HueExportError } from "../transport.js";
|
|
7
7
|
import { HueApiError } from "./client.js";
|
|
8
8
|
import { loadEnvironmentEvidence } from "./environment-evidence.js";
|
|
9
|
-
import { serviceFailureType } from "./failure.js";
|
|
9
|
+
import { serviceFailureCause, serviceFailureType } from "./failure.js";
|
|
10
10
|
import { CheckpointStore } from "./checkpoint.js";
|
|
11
11
|
import { onForcedExit } from "./exit-cleanup.js";
|
|
12
12
|
import { assertSafeFileNames, downloadCaseFiles, downloadCaseInputs, localOutputFiles, verifyCaseFiles, OutputFileError, stageOutputFiles, targetFileRoles, uploadOutputFiles, } from "./files.js";
|
|
@@ -434,17 +434,26 @@ export async function runExperiment(options) {
|
|
|
434
434
|
// A target stopped at its world's deadline is a `TargetTimeout`, told apart from an error the
|
|
435
435
|
// target raised itself: the agent did not finish, rather than finishing wrongly. A service the
|
|
436
436
|
// agent called that refused, dropped the connection or timed out is named apart from the
|
|
437
|
-
// agent's own error (`failure.ts`), so Hue counts it as infrastructure, not as the agent
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
:
|
|
447
|
-
|
|
437
|
+
// agent's own error (`failure.ts`), so Hue counts it as infrastructure, not as the agent, with
|
|
438
|
+
// the service's own word for what failed as the error's `cause` when its answer names one
|
|
439
|
+
// (Hue's gateway diagnostic).
|
|
440
|
+
const errorPayload = (error) => {
|
|
441
|
+
const service = error instanceof OutputTooLargeError || error instanceof TargetTimeoutError
|
|
442
|
+
? null
|
|
443
|
+
: serviceFailureType(error);
|
|
444
|
+
const cause = service ? serviceFailureCause(error) : undefined;
|
|
445
|
+
return {
|
|
446
|
+
type: error instanceof OutputTooLargeError
|
|
447
|
+
? "OutputTooLarge"
|
|
448
|
+
: error instanceof TargetTimeoutError
|
|
449
|
+
? "TargetTimeout"
|
|
450
|
+
: (service ?? "TargetError"),
|
|
451
|
+
...(cause === undefined ? {} : { cause }),
|
|
452
|
+
...(options.persistResultContent && error instanceof Error
|
|
453
|
+
? { message: sanitize(error.message) }
|
|
454
|
+
: {}),
|
|
455
|
+
};
|
|
456
|
+
};
|
|
448
457
|
/** Publish staged files, score with every verified file on disk and save the completion. */
|
|
449
458
|
async function prepare(file, saved, frozenCase, caseDirectory,
|
|
450
459
|
/** The target's output, in memory when result content is not persisted. */
|
|
@@ -5,18 +5,25 @@ const metricName = z
|
|
|
5
5
|
.min(1)
|
|
6
6
|
.max(64)
|
|
7
7
|
.regex(/^[a-zA-Z][a-zA-Z0-9_]*$/);
|
|
8
|
+
const metricDescription = z.string().trim().min(1).max(500).optional();
|
|
8
9
|
const metric = z.discriminatedUnion("type", [
|
|
9
|
-
z.strictObject({
|
|
10
|
-
|
|
10
|
+
z.strictObject({
|
|
11
|
+
name: metricName,
|
|
12
|
+
type: z.literal("boolean"),
|
|
13
|
+
description: metricDescription,
|
|
14
|
+
}),
|
|
15
|
+
z.strictObject({ name: metricName, type: z.literal("text"), description: metricDescription }),
|
|
11
16
|
z.strictObject({
|
|
12
17
|
name: metricName,
|
|
13
18
|
type: z.literal("number"),
|
|
19
|
+
description: metricDescription,
|
|
14
20
|
min: z.number().finite().optional(),
|
|
15
21
|
max: z.number().finite().optional(),
|
|
16
22
|
}),
|
|
17
23
|
z.strictObject({
|
|
18
24
|
name: metricName,
|
|
19
25
|
type: z.literal("category"),
|
|
26
|
+
description: metricDescription,
|
|
20
27
|
categories: z.array(z.string()).min(1),
|
|
21
28
|
}),
|
|
22
29
|
]);
|
package/dist/evals/scorers.js
CHANGED
|
@@ -32,7 +32,9 @@ export function defineLocalScorer(options) {
|
|
|
32
32
|
language: "typescript",
|
|
33
33
|
entrypoint: options.entrypoint,
|
|
34
34
|
sourceDigest: sourceDigest(options.source),
|
|
35
|
-
metrics: options.metrics
|
|
35
|
+
metrics: options.metrics.map((metric) => metric.description === undefined
|
|
36
|
+
? metric
|
|
37
|
+
: { ...metric, description: metric.description.trim() }),
|
|
36
38
|
},
|
|
37
39
|
score: options.score,
|
|
38
40
|
};
|
package/dist/evals/types.d.ts
CHANGED
|
@@ -19,6 +19,8 @@ export interface PageOptions {
|
|
|
19
19
|
export interface RegistryPageOptions extends PageOptions {
|
|
20
20
|
/** Include archived identities so callers can diagnose slug conflicts explicitly. */
|
|
21
21
|
includeArchived?: boolean;
|
|
22
|
+
/** Only identities carrying any of these tag names, matched without case. */
|
|
23
|
+
tags?: string[];
|
|
22
24
|
}
|
|
23
25
|
/** Human-readable identity of a dataset or scorer. */
|
|
24
26
|
export interface Identity {
|
|
@@ -29,12 +31,50 @@ export interface Identity {
|
|
|
29
31
|
/** Optional description. */
|
|
30
32
|
description?: string;
|
|
31
33
|
}
|
|
34
|
+
/** A dataset or scorer to create, with the names of the tags it starts with. */
|
|
35
|
+
export interface TaggedIdentity extends Identity {
|
|
36
|
+
/** Tag names; a name the project has no tag for creates one. */
|
|
37
|
+
tags?: string[];
|
|
38
|
+
}
|
|
39
|
+
/** Identity fields and tags to change on a dataset or scorer; omitted fields stay. */
|
|
40
|
+
export interface IdentityUpdate {
|
|
41
|
+
/** New display name. */
|
|
42
|
+
name?: string;
|
|
43
|
+
/** New description. */
|
|
44
|
+
description?: string;
|
|
45
|
+
/** Every tag name the item should carry; replaces its tags. */
|
|
46
|
+
tags?: string[];
|
|
47
|
+
}
|
|
48
|
+
/** An experiment's (run's) name and tags after an update. */
|
|
49
|
+
export interface UpdatedRun {
|
|
50
|
+
/** Experiment (run) ID. */
|
|
51
|
+
id: string;
|
|
52
|
+
/** Display name. */
|
|
53
|
+
name: string;
|
|
54
|
+
/** The experiment's own tags. */
|
|
55
|
+
tags: Tag[];
|
|
56
|
+
/** Its dataset's (eval set's) tags. */
|
|
57
|
+
evalSetTags: Tag[];
|
|
58
|
+
}
|
|
59
|
+
/** The colors a tag can take. */
|
|
60
|
+
export type TagColor = "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red";
|
|
61
|
+
/** A project's tag: a named, colored label that groups datasets, scorers and experiments. */
|
|
62
|
+
export interface Tag {
|
|
63
|
+
/** Tag ID. */
|
|
64
|
+
id: string;
|
|
65
|
+
/** Name, unique in the project without case. */
|
|
66
|
+
name: string;
|
|
67
|
+
/** Display color. */
|
|
68
|
+
color: TagColor;
|
|
69
|
+
}
|
|
32
70
|
/** A dataset and its versions. */
|
|
33
71
|
export interface Dataset extends Identity {
|
|
34
72
|
/** Dataset ID. */
|
|
35
73
|
id: string;
|
|
36
74
|
/** Archive timestamp on current servers; absent on older compatible responses. */
|
|
37
75
|
archivedAt?: string | null;
|
|
76
|
+
/** The dataset's tags on servers that support tags; absent on older responses. */
|
|
77
|
+
tags?: Tag[];
|
|
38
78
|
/** Versions of this dataset. */
|
|
39
79
|
versions: DatasetVersion[];
|
|
40
80
|
}
|
|
@@ -139,11 +179,15 @@ export type MetricDefinition = {
|
|
|
139
179
|
name: string;
|
|
140
180
|
/** Boolean or free-text metric. */
|
|
141
181
|
type: "boolean" | "text";
|
|
182
|
+
/** What the metric checks, shown with its check in Hue's run view (1–500 characters). */
|
|
183
|
+
description?: string;
|
|
142
184
|
} | {
|
|
143
185
|
/** Metric name. */
|
|
144
186
|
name: string;
|
|
145
187
|
/** Numeric metric. */
|
|
146
188
|
type: "number";
|
|
189
|
+
/** What the metric checks, shown with its check in Hue's run view (1–500 characters). */
|
|
190
|
+
description?: string;
|
|
147
191
|
/** Inclusive lower bound. */
|
|
148
192
|
min?: number;
|
|
149
193
|
/** Inclusive upper bound. */
|
|
@@ -153,6 +197,8 @@ export type MetricDefinition = {
|
|
|
153
197
|
name: string;
|
|
154
198
|
/** Categorical metric. */
|
|
155
199
|
type: "category";
|
|
200
|
+
/** What the metric checks, shown with its check in Hue's run view (1–500 characters). */
|
|
201
|
+
description?: string;
|
|
156
202
|
/** Allowed values. */
|
|
157
203
|
categories: string[];
|
|
158
204
|
};
|
|
@@ -397,6 +443,8 @@ export interface Scorer extends Identity {
|
|
|
397
443
|
id: string;
|
|
398
444
|
/** Archive timestamp on current servers; absent on older compatible responses. */
|
|
399
445
|
archivedAt?: string | null;
|
|
446
|
+
/** The scorer's tags on servers that support tags; absent on older responses. */
|
|
447
|
+
tags?: Tag[];
|
|
400
448
|
/** Published versions, when included in the response. */
|
|
401
449
|
versions?: ScorerVersion[];
|
|
402
450
|
}
|
|
@@ -486,6 +534,10 @@ export interface Experiment {
|
|
|
486
534
|
name: string;
|
|
487
535
|
/** Frozen dataset version under test. */
|
|
488
536
|
datasetVersionId: string;
|
|
537
|
+
/** The experiment's own tags on servers that support tags; absent on older responses. */
|
|
538
|
+
tags?: Tag[];
|
|
539
|
+
/** Its dataset's tags, which tag filters match as well; absent on older responses. */
|
|
540
|
+
evalSetTags?: Tag[];
|
|
489
541
|
/** Configuration handed to the target. */
|
|
490
542
|
config: JsonValue;
|
|
491
543
|
/** Digest of `config`. */
|
|
@@ -546,6 +598,12 @@ export interface TypedError {
|
|
|
546
598
|
* (`agent`, `infrastructure`, `configuration`, `telemetry` or `unsupported`), which Hue reads
|
|
547
599
|
* only for a name it does not know. The SDK's own types need none. */
|
|
548
600
|
class?: "agent" | "infrastructure" | "configuration" | "telemetry" | "unsupported";
|
|
601
|
+
/** For a service failure (`ServiceRefused`, `ConnectionFailed`, `TimedOut`,
|
|
602
|
+
* `ConfigurationRejected`): the service's own word for what failed, when its answer names one,
|
|
603
|
+
* such as Hue's gateway diagnostic (`authorization_unavailable`) from the answer's
|
|
604
|
+
* `x-hue-diagnostic` header or its JSON body's `diagnostic`. A short lower-case token; absent
|
|
605
|
+
* when the answer names none. */
|
|
606
|
+
cause?: string;
|
|
549
607
|
}
|
|
550
608
|
/** Input for {@link EvaluationClient.startExecution}. */
|
|
551
609
|
export interface StartExecution {
|
package/dist/privacy.d.ts
CHANGED
|
@@ -2,8 +2,26 @@ import type { ReadableSpan } from "@opentelemetry/sdk-trace";
|
|
|
2
2
|
import type { ReadableLogRecord } from "@opentelemetry/sdk-logs";
|
|
3
3
|
import { type Resource } from "@opentelemetry/resources";
|
|
4
4
|
import type { HueOptions } from "./types.js";
|
|
5
|
+
import { truncateUtf8 } from "./safety.js";
|
|
6
|
+
export { truncateUtf8 };
|
|
5
7
|
/** Attribute keys (and their dotted children) removed in metadata-only mode. */
|
|
6
8
|
export declare const contentPrefixes: string[];
|
|
9
|
+
export declare function isContentKey(key: string): boolean;
|
|
10
|
+
/** The record attribute listing the keys whose values were cut to fit Hue's 256 KiB value cap:
|
|
11
|
+
* Hue's receiver writes it for the values it cuts, and the SDK writes it for the values it cuts
|
|
12
|
+
* before export, under the same name, so a reader learns of a cut value from one place. */
|
|
13
|
+
export declare const TRUNCATED_KEY = "hue.truncated";
|
|
14
|
+
/** The size of a structured value the marker replaced. */
|
|
15
|
+
export declare const TRUNCATED_BYTES_KEY = "hue.truncated_bytes";
|
|
16
|
+
/** The root span attribute counting this trace's records the SDK could not export at all (a
|
|
17
|
+
* record over the request limit even with every content value shed, or one its queue had no
|
|
18
|
+
* room for): what Hue stores of the trace is incomplete by that many records. */
|
|
19
|
+
export declare const DROPPED_RECORDS_KEY = "hue.sdk.dropped_records";
|
|
20
|
+
/** Hue's receiver's own marker for a structured value it replaced: nothing of the value, its
|
|
21
|
+
* size, and the flag a reader tests. */
|
|
22
|
+
export declare function truncatedMarker(bytes: number): Record<string, unknown>;
|
|
23
|
+
/** `listed` with `keys` added, each once, in order. */
|
|
24
|
+
export declare function withTruncatedKeys(listed: unknown, keys: readonly string[]): string[];
|
|
7
25
|
export type ResourceCache = WeakMap<Resource, Resource>;
|
|
8
26
|
export declare function redactSpan(span: ReadableSpan, options: HueOptions, cache: ResourceCache): ReadableSpan;
|
|
9
27
|
export declare function redactLog(log: ReadableLogRecord, options: HueOptions, cache: ResourceCache): ReadableLogRecord;
|