@kimpton-ai/evalrouter 0.1.0
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/LICENSE +29 -0
- package/README.md +48 -0
- package/dist/boundary.d.ts +2 -0
- package/dist/boundary.js +32 -0
- package/dist/helpers.d.ts +16 -0
- package/dist/helpers.js +73 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.js +41 -0
- package/dist/resources.d.ts +43 -0
- package/dist/resources.js +101 -0
- package/dist/transport.d.ts +73 -0
- package/dist/transport.js +365 -0
- package/dist/types.d.ts +680 -0
- package/dist/types.js +2 -0
- package/package.json +29 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Kimpton EvalRouter SDK License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kimpton. All rights reserved.
|
|
4
|
+
|
|
5
|
+
Permission is granted to download, install, execute, and make internal copies of
|
|
6
|
+
this SDK and its documentation solely to access the EvalRouter service and to
|
|
7
|
+
integrate that access into applications you own or control, subject to your
|
|
8
|
+
applicable EvalRouter service agreement and authorization.
|
|
9
|
+
|
|
10
|
+
This is proprietary software, not an open-source license. Except for the limited
|
|
11
|
+
permission above or as required by applicable law, no permission is granted to
|
|
12
|
+
modify, redistribute, sublicense, sell, or use this software to provide a
|
|
13
|
+
competing service. Preserve this license and all copyright notices in permitted
|
|
14
|
+
copies. All rights not expressly granted are reserved.
|
|
15
|
+
|
|
16
|
+
This license covers only the distributed SDK, CLI, and accompanying
|
|
17
|
+
documentation. It grants no rights to EvalRouter backend or service source,
|
|
18
|
+
benchmarks, datasets, models, credentials, trademarks, or other excluded material.
|
|
19
|
+
Third-party dependencies remain subject to their own licenses.
|
|
20
|
+
|
|
21
|
+
Downloading this software does not create an account, grant service access,
|
|
22
|
+
provide credits, or waive service charges. Access remains subject to separate
|
|
23
|
+
account, workspace, authorization, and billing requirements.
|
|
24
|
+
|
|
25
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
26
|
+
IMPLIED, INCLUDING WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
27
|
+
PURPOSE, AND NONINFRINGEMENT. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
|
|
28
|
+
THE COPYRIGHT HOLDERS SHALL NOT BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER
|
|
29
|
+
LIABILITY ARISING FROM THE SOFTWARE OR ITS USE.
|
package/README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# EvalRouter TypeScript client
|
|
2
|
+
|
|
3
|
+
Client for trusted Node.js 22+ applications, using ESM, distributed under the
|
|
4
|
+
proprietary [Kimpton EvalRouter SDK License](LICENSE). Install with
|
|
5
|
+
`npm install @kimpton-ai/evalrouter@0.1.0`. Discover evaluations and models,
|
|
6
|
+
submit bounded evaluation runs, inspect results, and export reports.
|
|
7
|
+
|
|
8
|
+
Use API keys only in a trusted server process, never a browser bundle. Set
|
|
9
|
+
`EVALROUTER_BASE_URL`, `EVALROUTER_API_KEY` and `EVALROUTER_WORKSPACE_ID` after
|
|
10
|
+
creating and funding an account in the web application. The public API origin is
|
|
11
|
+
`https://api.evalrouter.ai`. Package download does not grant service access.
|
|
12
|
+
While website access is restricted, obtain an invitation from your EvalRouter
|
|
13
|
+
operator before setting up the account and workspace key.
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { Client } from "@kimpton-ai/evalrouter";
|
|
17
|
+
|
|
18
|
+
const client = new Client();
|
|
19
|
+
const available = await client.evals.list();
|
|
20
|
+
// Select an admitted exact reference and compatible model from discovery.
|
|
21
|
+
const run = await client.run({
|
|
22
|
+
model: "YOUR_MANAGED_MODEL",
|
|
23
|
+
eval: "YOUR_EXACT_EVAL_REFERENCE",
|
|
24
|
+
budgetUsd: "1.00",
|
|
25
|
+
idempotencyKey: "my-durable-evaluation-request",
|
|
26
|
+
});
|
|
27
|
+
const result = await client.runs.results(run.id);
|
|
28
|
+
await client.runs.exportToFile(run.id, "result.json", { format: "json" });
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
A budget is a spending cap, not a price guarantee or assurance that an eval fits.
|
|
32
|
+
Managed model routes and checked `connection:<id>` endpoints retain their distinct
|
|
33
|
+
billing bases. Alternatively use `quotes.create`, review the quote, then
|
|
34
|
+
`runs.create(body, durableIdempotencyKey)`. Retry the same authorized request with
|
|
35
|
+
the same idempotency key. Local timeouts do not establish that a submitted run
|
|
36
|
+
failed to commit.
|
|
37
|
+
|
|
38
|
+
The supported resources are `catalog`, `evals`, `connections`, `quotes`,
|
|
39
|
+
`evaluations` and `runs`. `catalog.evals` and `catalog.eval` are discovery aliases.
|
|
40
|
+
The package includes named request/response types, `Client` (`EvalRouter` alias),
|
|
41
|
+
`APIError`, `ClientError`, `RequestTimeout`, `WaitCancelled`, and typed
|
|
42
|
+
request/wait options. `runs.wait` supports local abort/deadlines; `runs.cancel`
|
|
43
|
+
explicitly cancels server work. `runs.exportToFile` handles versioned JSON/CSV/HTML
|
|
44
|
+
exports and refuses overwrites by default. Workspace and API configuration can
|
|
45
|
+
also be passed in `ClientOptions`.
|
|
46
|
+
|
|
47
|
+
The HTTP service enforces account access and workspace permissions. Configure
|
|
48
|
+
the client with an existing workspace API key.
|
package/dist/boundary.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ClientError } from "./transport.js";
|
|
2
|
+
/** Validate supported evaluation inputs before issuing a request. */
|
|
3
|
+
export function validateSubmission(resource, input) {
|
|
4
|
+
const object = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
5
|
+
const allowed = new Set(resource === "quotes"
|
|
6
|
+
? ["selection", "model", "coverage", "max_charge_microusd"]
|
|
7
|
+
: ["model", "eval", "budget_usd", "max_charge_microusd", "provider", "coverage", "name", "metadata", "split"]);
|
|
8
|
+
const fail = () => { throw new ClientError("unsupported_feature", "Choose an admitted eval and a managed model or checked connection."); };
|
|
9
|
+
if (!object(input) || Object.keys(input).some((key) => !allowed.has(key)))
|
|
10
|
+
return fail();
|
|
11
|
+
const model = input.model;
|
|
12
|
+
if (typeof model === "string" && resource === "evaluations") {
|
|
13
|
+
if (!model || /^(checkpoint|agent|artifact):/.test(model))
|
|
14
|
+
return fail();
|
|
15
|
+
}
|
|
16
|
+
else if (object(model)) {
|
|
17
|
+
const keys = model.kind === "managed" ? ["kind", "route_id"] : model.kind === "connection" ? ["kind", "connection_id"] : [];
|
|
18
|
+
if (keys.length === 0 || Object.keys(model).length !== keys.length || keys.some((key) => !(key in model)))
|
|
19
|
+
return fail();
|
|
20
|
+
}
|
|
21
|
+
else
|
|
22
|
+
return fail();
|
|
23
|
+
if (resource === "quotes") {
|
|
24
|
+
const selection = input.selection;
|
|
25
|
+
if (!object(selection))
|
|
26
|
+
return fail();
|
|
27
|
+
const keys = Object.keys(selection);
|
|
28
|
+
if (!(keys.length === 1 && keys[0] === "profile_ids") &&
|
|
29
|
+
!("eval" in selection && keys.every((key) => ["eval", "provider", "split"].includes(key))))
|
|
30
|
+
return fail();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { RunRecord, RunsExportParams } from "./types.js";
|
|
2
|
+
import { Resource, type RequestOptions } from "./transport.js";
|
|
3
|
+
export type WaitOptions = {
|
|
4
|
+
timeoutMs?: number;
|
|
5
|
+
pollIntervalMs?: number;
|
|
6
|
+
signal?: AbortSignal;
|
|
7
|
+
onProgress?: (run: RunRecord) => void | Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
export declare abstract class RunHelpers extends Resource {
|
|
10
|
+
abstract get(runId: string, options?: RequestOptions): Promise<RunRecord>;
|
|
11
|
+
abstract export(runId: string, params?: RunsExportParams, options?: RequestOptions): Promise<Uint8Array>;
|
|
12
|
+
wait(runId: string, options?: WaitOptions): Promise<RunRecord>;
|
|
13
|
+
exportToFile(runId: string, destination: string, params?: RunsExportParams, options?: RequestOptions & {
|
|
14
|
+
overwrite?: boolean;
|
|
15
|
+
}): Promise<string>;
|
|
16
|
+
}
|
package/dist/helpers.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { link, lstat, open, rename, unlink } from "node:fs/promises";
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { ClientError, Resource, checkpoint, pause, positive, } from "./transport.js";
|
|
5
|
+
const terminal = new Set(["completed", "partial", "failed", "cancelled"]);
|
|
6
|
+
const states = new Set([
|
|
7
|
+
...terminal,
|
|
8
|
+
"queued",
|
|
9
|
+
"running",
|
|
10
|
+
"cancelling",
|
|
11
|
+
"finalizing",
|
|
12
|
+
]);
|
|
13
|
+
export class RunHelpers extends Resource {
|
|
14
|
+
async wait(runId, options = {}) {
|
|
15
|
+
const deadline = performance.now() +
|
|
16
|
+
positive(options.timeoutMs ?? 3_600_000, "Wait timeout");
|
|
17
|
+
const interval = positive(options.pollIntervalMs ?? 2000, "Poll interval");
|
|
18
|
+
while (true) {
|
|
19
|
+
const run = await this.get(runId, {
|
|
20
|
+
timeoutMs: checkpoint(deadline, options.signal),
|
|
21
|
+
signal: options.signal,
|
|
22
|
+
});
|
|
23
|
+
checkpoint(deadline, options.signal);
|
|
24
|
+
if (!states.has(run.status))
|
|
25
|
+
throw new ClientError("invalid_response", "API returned an unknown evaluation state.");
|
|
26
|
+
if (options.onProgress)
|
|
27
|
+
await options.onProgress(run);
|
|
28
|
+
checkpoint(deadline, options.signal);
|
|
29
|
+
if (terminal.has(run.status))
|
|
30
|
+
return run;
|
|
31
|
+
await pause(interval, deadline, options.signal);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async exportToFile(runId, destination, params = {}, options = {}) {
|
|
35
|
+
if (!options.overwrite) {
|
|
36
|
+
try {
|
|
37
|
+
await lstat(destination);
|
|
38
|
+
throw new ClientError("destination_exists", "Export destination already exists.");
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
if (e.code !== "ENOENT")
|
|
42
|
+
throw e instanceof ClientError
|
|
43
|
+
? e
|
|
44
|
+
: new ClientError("export_write_failed", "Could not access the export destination.");
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const bytes = await this.export(runId, params, options);
|
|
48
|
+
const temporary = join(dirname(destination), `.kimpton-export-${randomUUID()}`);
|
|
49
|
+
try {
|
|
50
|
+
const file = await open(temporary, "wx", 0o600);
|
|
51
|
+
try {
|
|
52
|
+
await file.writeFile(bytes);
|
|
53
|
+
await file.sync();
|
|
54
|
+
}
|
|
55
|
+
finally {
|
|
56
|
+
await file.close();
|
|
57
|
+
}
|
|
58
|
+
if (options.overwrite)
|
|
59
|
+
await rename(temporary, destination);
|
|
60
|
+
else
|
|
61
|
+
await link(temporary, destination);
|
|
62
|
+
return destination;
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
throw new ClientError(e.code === "EEXIST"
|
|
66
|
+
? "destination_exists"
|
|
67
|
+
: "export_write_failed", "Could not write the export destination.");
|
|
68
|
+
}
|
|
69
|
+
finally {
|
|
70
|
+
await unlink(temporary).catch(() => undefined);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Catalog, Evals, Evaluations, Connections, Quotes, Runs } from "./resources.js";
|
|
2
|
+
import type { RunRecord } from "./types.js";
|
|
3
|
+
import { Transport } from "./transport.js";
|
|
4
|
+
export { APIError, ClientError, RequestTimeout, WaitCancelled, } from "./transport.js";
|
|
5
|
+
export type { ClientOptions, RequestOptions } from "./transport.js";
|
|
6
|
+
export type { WaitOptions } from "./helpers.js";
|
|
7
|
+
export type * from "./types.js";
|
|
8
|
+
export declare class Client extends Transport {
|
|
9
|
+
readonly catalog: Catalog;
|
|
10
|
+
readonly connections: Connections;
|
|
11
|
+
readonly quotes: Quotes;
|
|
12
|
+
readonly runs: Runs;
|
|
13
|
+
readonly evals: Evals;
|
|
14
|
+
readonly evaluations: Evaluations;
|
|
15
|
+
/**
|
|
16
|
+
* The canonical call: route `eval` to whichever provider owns it and run it.
|
|
17
|
+
* `model` is a managed route id or `connection:<uuid>`;
|
|
18
|
+
* `eval` is `eval://provider/name/version` or `name@version`.
|
|
19
|
+
*/
|
|
20
|
+
run(input: {
|
|
21
|
+
model: string;
|
|
22
|
+
eval: string;
|
|
23
|
+
budgetUsd?: number | string;
|
|
24
|
+
maxChargeMicrousd?: string;
|
|
25
|
+
provider?: string;
|
|
26
|
+
coverage?: Record<string, unknown>;
|
|
27
|
+
name?: string;
|
|
28
|
+
metadata?: Record<string, string>;
|
|
29
|
+
idempotencyKey?: string;
|
|
30
|
+
wait?: boolean;
|
|
31
|
+
timeoutMs?: number;
|
|
32
|
+
pollIntervalMs?: number;
|
|
33
|
+
}): Promise<RunRecord>;
|
|
34
|
+
}
|
|
35
|
+
export { Client as EvalRouter };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Catalog, Evals, Evaluations, Connections, Quotes, Runs } from "./resources.js";
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
import { Transport } from "./transport.js";
|
|
4
|
+
export { APIError, ClientError, RequestTimeout, WaitCancelled, } from "./transport.js";
|
|
5
|
+
export class Client extends Transport {
|
|
6
|
+
catalog = new Catalog(this);
|
|
7
|
+
connections = new Connections(this);
|
|
8
|
+
quotes = new Quotes(this);
|
|
9
|
+
runs = new Runs(this);
|
|
10
|
+
evals = new Evals(this);
|
|
11
|
+
evaluations = new Evaluations(this);
|
|
12
|
+
/**
|
|
13
|
+
* The canonical call: route `eval` to whichever provider owns it and run it.
|
|
14
|
+
* `model` is a managed route id or `connection:<uuid>`;
|
|
15
|
+
* `eval` is `eval://provider/name/version` or `name@version`.
|
|
16
|
+
*/
|
|
17
|
+
async run(input) {
|
|
18
|
+
const body = {
|
|
19
|
+
model: input.model,
|
|
20
|
+
eval: input.eval,
|
|
21
|
+
name: input.name ?? "Evaluation",
|
|
22
|
+
metadata: input.metadata ?? {},
|
|
23
|
+
};
|
|
24
|
+
if (input.provider)
|
|
25
|
+
body.provider = input.provider;
|
|
26
|
+
if (input.coverage)
|
|
27
|
+
body.coverage = input.coverage;
|
|
28
|
+
if (input.maxChargeMicrousd !== undefined)
|
|
29
|
+
body.max_charge_microusd = input.maxChargeMicrousd;
|
|
30
|
+
else
|
|
31
|
+
body.budget_usd = String(input.budgetUsd);
|
|
32
|
+
const run = await this.evaluations.create(body, input.idempotencyKey ?? `run-${randomUUID()}`);
|
|
33
|
+
if (input.wait === false)
|
|
34
|
+
return run;
|
|
35
|
+
return this.runs.wait(String(run.id), {
|
|
36
|
+
timeoutMs: input.timeoutMs,
|
|
37
|
+
pollIntervalMs: input.pollIntervalMs,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export { Client as EvalRouter };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type * as types from "./types.js";
|
|
2
|
+
import { Resource, type RequestOptions } from "./transport.js";
|
|
3
|
+
import { RunHelpers } from "./helpers.js";
|
|
4
|
+
export declare class Catalog extends Resource {
|
|
5
|
+
evals(params?: types.CatalogEvalsParams, options?: RequestOptions): Promise<types.Page_EvalRecord_>;
|
|
6
|
+
eval(ref: string, options?: RequestOptions): Promise<types.EvalRecord>;
|
|
7
|
+
benchmarks(params?: types.CatalogBenchmarksParams, options?: RequestOptions): Promise<types.Page_BenchmarkRecord_>;
|
|
8
|
+
benchmark(slug: string, options?: RequestOptions): Promise<types.BenchmarkDetail>;
|
|
9
|
+
models(params?: types.CatalogModelsParams, options?: RequestOptions): Promise<types.Page_ManagedRoute_>;
|
|
10
|
+
execution_options(options?: RequestOptions): Promise<types.ExecutionOptions>;
|
|
11
|
+
environments(params?: types.CatalogEnvironmentsParams, options?: RequestOptions): Promise<types.Page_EnvironmentRecord_>;
|
|
12
|
+
environment(family: string, options?: RequestOptions): Promise<types.EnvironmentFamily>;
|
|
13
|
+
}
|
|
14
|
+
export declare class Connections extends Resource {
|
|
15
|
+
list(params?: types.ConnectionsListParams, options?: RequestOptions): Promise<types.Page_ConnectionRecord_>;
|
|
16
|
+
create(body: types.NewConnection, options?: RequestOptions): Promise<types.ConnectionRecord>;
|
|
17
|
+
check(connection_id: string, options?: RequestOptions): Promise<types.ConnectionRecord>;
|
|
18
|
+
update(connection_id: string, body: types.UpdateConnection, options?: RequestOptions): Promise<types.ConnectionRecord>;
|
|
19
|
+
disable(connection_id: string, options?: RequestOptions): Promise<types.OKResponse>;
|
|
20
|
+
}
|
|
21
|
+
export declare class Quotes extends Resource {
|
|
22
|
+
create(body: types.NewQuote, options?: RequestOptions): Promise<types.QuoteRecord>;
|
|
23
|
+
get(quote_id: string, options?: RequestOptions): Promise<types.QuoteRecord>;
|
|
24
|
+
}
|
|
25
|
+
export declare class Runs extends RunHelpers {
|
|
26
|
+
create(body: types.NewRun, idempotency_key: string, options?: RequestOptions): Promise<types.RunRecord>;
|
|
27
|
+
list(params?: types.RunsListParams, options?: RequestOptions): Promise<types.Page_RunRecord_>;
|
|
28
|
+
get(run_id: string, options?: RequestOptions): Promise<types.RunRecord>;
|
|
29
|
+
receipt(run_id: string, options?: RequestOptions): Promise<types.RunReceipt>;
|
|
30
|
+
executions(run_id: string, params?: types.RunsExecutionsParams, options?: RequestOptions): Promise<types.SandboxExecutionPage>;
|
|
31
|
+
events(run_id: string, params?: types.RunsEventsParams, options?: RequestOptions): Promise<types.EventPage>;
|
|
32
|
+
cancel(run_id: string, options?: RequestOptions): Promise<types.RunRecord>;
|
|
33
|
+
results(run_id: string, params?: types.RunsResultsParams, options?: RequestOptions): Promise<types.ResultRecord>;
|
|
34
|
+
export(run_id: string, params?: types.RunsExportParams, options?: RequestOptions): Promise<Uint8Array>;
|
|
35
|
+
}
|
|
36
|
+
export declare class Evals extends Resource {
|
|
37
|
+
list(params?: types.EvalsListParams, options?: RequestOptions): Promise<types.Page_EvalRecord_>;
|
|
38
|
+
get(ref: string, options?: RequestOptions): Promise<types.EvalRecord>;
|
|
39
|
+
}
|
|
40
|
+
export declare class Evaluations extends Resource {
|
|
41
|
+
create(body: types.NewEvaluation, idempotency_key: string, options?: RequestOptions): Promise<types.RunRecord>;
|
|
42
|
+
get(evaluation_id: string, options?: RequestOptions): Promise<types.RunRecord>;
|
|
43
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Resource, segment } from "./transport.js";
|
|
2
|
+
import { RunHelpers } from "./helpers.js";
|
|
3
|
+
import { validateSubmission } from "./boundary.js";
|
|
4
|
+
export class Catalog extends Resource {
|
|
5
|
+
async evals(params = {}, options) {
|
|
6
|
+
return this.client.request("GET", `/evals`, { retry: true, options, query: params });
|
|
7
|
+
}
|
|
8
|
+
async eval(ref, options) {
|
|
9
|
+
return this.client.request("GET", `/evals/${segment(ref)}`, { retry: true, options });
|
|
10
|
+
}
|
|
11
|
+
async benchmarks(params = {}, options) {
|
|
12
|
+
return this.client.request("GET", `/catalog/benchmarks`, { retry: true, options, query: params });
|
|
13
|
+
}
|
|
14
|
+
async benchmark(slug, options) {
|
|
15
|
+
return this.client.request("GET", `/catalog/benchmarks/${segment(slug)}`, { retry: true, options });
|
|
16
|
+
}
|
|
17
|
+
async models(params = {}, options) {
|
|
18
|
+
return this.client.request("GET", `/catalog/models`, { retry: true, options, query: params });
|
|
19
|
+
}
|
|
20
|
+
async execution_options(options) {
|
|
21
|
+
return this.client.request("GET", `/catalog/execution-options`, { retry: true, options });
|
|
22
|
+
}
|
|
23
|
+
async environments(params = {}, options) {
|
|
24
|
+
return this.client.request("GET", `/catalog/environments`, { retry: true, options, query: params });
|
|
25
|
+
}
|
|
26
|
+
async environment(family, options) {
|
|
27
|
+
return this.client.request("GET", `/catalog/environments/${segment(family)}`, { retry: true, options });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export class Connections extends Resource {
|
|
31
|
+
async list(params = {}, options) {
|
|
32
|
+
return this.client.request("GET", `/connections`, { retry: true, options, query: params });
|
|
33
|
+
}
|
|
34
|
+
async create(body, options) {
|
|
35
|
+
return this.client.request("POST", `/connections`, { retry: false, options, body: body });
|
|
36
|
+
}
|
|
37
|
+
async check(connection_id, options) {
|
|
38
|
+
return this.client.request("POST", `/connections/${segment(connection_id)}/check`, { retry: false, options });
|
|
39
|
+
}
|
|
40
|
+
async update(connection_id, body, options) {
|
|
41
|
+
return this.client.request("PATCH", `/connections/${segment(connection_id)}`, { retry: false, options, body: body });
|
|
42
|
+
}
|
|
43
|
+
async disable(connection_id, options) {
|
|
44
|
+
return this.client.request("DELETE", `/connections/${segment(connection_id)}`, { retry: false, options });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export class Quotes extends Resource {
|
|
48
|
+
async create(body, options) {
|
|
49
|
+
validateSubmission("quotes", body);
|
|
50
|
+
return this.client.request("POST", `/quotes`, { retry: false, options, body: body });
|
|
51
|
+
}
|
|
52
|
+
async get(quote_id, options) {
|
|
53
|
+
return this.client.request("GET", `/quotes/${segment(quote_id)}`, { retry: true, options });
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export class Runs extends RunHelpers {
|
|
57
|
+
async create(body, idempotency_key, options) {
|
|
58
|
+
return this.client.request("POST", `/runs`, { retry: true, options, body: body, idempotency_key: idempotency_key });
|
|
59
|
+
}
|
|
60
|
+
async list(params = {}, options) {
|
|
61
|
+
return this.client.request("GET", `/runs`, { retry: true, options, query: params });
|
|
62
|
+
}
|
|
63
|
+
async get(run_id, options) {
|
|
64
|
+
return this.client.request("GET", `/runs/${segment(run_id)}`, { retry: true, options });
|
|
65
|
+
}
|
|
66
|
+
async receipt(run_id, options) {
|
|
67
|
+
return this.client.request("GET", `/runs/${segment(run_id)}/receipt`, { retry: true, options });
|
|
68
|
+
}
|
|
69
|
+
async executions(run_id, params = {}, options) {
|
|
70
|
+
return this.client.request("GET", `/runs/${segment(run_id)}/executions`, { retry: true, options, query: params });
|
|
71
|
+
}
|
|
72
|
+
async events(run_id, params = {}, options) {
|
|
73
|
+
return this.client.request("GET", `/runs/${segment(run_id)}/events`, { retry: true, options, query: params });
|
|
74
|
+
}
|
|
75
|
+
async cancel(run_id, options) {
|
|
76
|
+
return this.client.request("POST", `/runs/${segment(run_id)}/cancel`, { retry: true, options });
|
|
77
|
+
}
|
|
78
|
+
async results(run_id, params = {}, options) {
|
|
79
|
+
return this.client.request("GET", `/runs/${segment(run_id)}/results`, { retry: true, options, query: params });
|
|
80
|
+
}
|
|
81
|
+
async export(run_id, params = {}, options) {
|
|
82
|
+
return this.client.request("GET", `/runs/${segment(run_id)}/export`, { retry: true, options, query: params, binary: true });
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
export class Evals extends Resource {
|
|
86
|
+
async list(params = {}, options) {
|
|
87
|
+
return this.client.request("GET", `/evals`, { retry: true, options, query: params });
|
|
88
|
+
}
|
|
89
|
+
async get(ref, options) {
|
|
90
|
+
return this.client.request("GET", `/evals/${segment(ref)}`, { retry: true, options });
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
export class Evaluations extends Resource {
|
|
94
|
+
async create(body, idempotency_key, options) {
|
|
95
|
+
validateSubmission("evaluations", body);
|
|
96
|
+
return this.client.request("POST", `/evaluations`, { retry: true, options, body: body, idempotency_key: idempotency_key });
|
|
97
|
+
}
|
|
98
|
+
async get(evaluation_id, options) {
|
|
99
|
+
return this.client.request("GET", `/evaluations/${segment(evaluation_id)}`, { retry: true, options });
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export declare class ClientError extends Error {
|
|
2
|
+
readonly code: string;
|
|
3
|
+
idempotency_key?: string;
|
|
4
|
+
constructor(code: string, message: string);
|
|
5
|
+
toJSON(): {
|
|
6
|
+
idempotency_key?: string | undefined;
|
|
7
|
+
code: string;
|
|
8
|
+
message: string;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export declare class APIError extends ClientError {
|
|
12
|
+
readonly status: number;
|
|
13
|
+
readonly requestId: string | null;
|
|
14
|
+
readonly details: unknown;
|
|
15
|
+
constructor(status: number, code: string, requestId?: string | null, message?: string, details?: unknown);
|
|
16
|
+
toJSON(): {
|
|
17
|
+
status: number;
|
|
18
|
+
request_id: string | null;
|
|
19
|
+
details: unknown;
|
|
20
|
+
idempotency_key?: string | undefined;
|
|
21
|
+
code: string;
|
|
22
|
+
message: string;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export declare class RequestTimeout extends ClientError {
|
|
26
|
+
constructor();
|
|
27
|
+
}
|
|
28
|
+
export declare class WaitCancelled extends ClientError {
|
|
29
|
+
constructor();
|
|
30
|
+
}
|
|
31
|
+
export type RequestOptions = {
|
|
32
|
+
timeoutMs?: number;
|
|
33
|
+
signal?: AbortSignal;
|
|
34
|
+
};
|
|
35
|
+
export type ClientOptions = {
|
|
36
|
+
baseUrl?: string;
|
|
37
|
+
apiKey?: string;
|
|
38
|
+
workspaceId?: string;
|
|
39
|
+
timeoutMs?: number;
|
|
40
|
+
requestTimeoutMs?: number;
|
|
41
|
+
maxRetries?: number;
|
|
42
|
+
maxResponseBytes?: number;
|
|
43
|
+
maxExportBytes?: number;
|
|
44
|
+
allowHttp?: boolean;
|
|
45
|
+
fetch?: typeof globalThis.fetch;
|
|
46
|
+
};
|
|
47
|
+
type Request = {
|
|
48
|
+
body?: unknown;
|
|
49
|
+
query?: object;
|
|
50
|
+
retry: boolean;
|
|
51
|
+
idempotency_key?: string;
|
|
52
|
+
binary?: boolean;
|
|
53
|
+
options?: RequestOptions;
|
|
54
|
+
};
|
|
55
|
+
export declare function positive(value: number, label: string): number;
|
|
56
|
+
export declare function segment(value: string): string;
|
|
57
|
+
export declare function checkpoint(deadline: number, signal?: AbortSignal): number;
|
|
58
|
+
export declare function pause(delay: number, deadline: number, signal?: AbortSignal): Promise<void>;
|
|
59
|
+
export declare class Transport {
|
|
60
|
+
#private;
|
|
61
|
+
readonly timeoutMs: number;
|
|
62
|
+
readonly requestTimeoutMs: number;
|
|
63
|
+
readonly maxRetries: number;
|
|
64
|
+
readonly maxResponseBytes: number;
|
|
65
|
+
readonly maxExportBytes: number;
|
|
66
|
+
constructor(options?: ClientOptions);
|
|
67
|
+
request<T>(method: string, path: string, request: Request): Promise<T>;
|
|
68
|
+
}
|
|
69
|
+
export declare class Resource {
|
|
70
|
+
protected readonly client: Transport;
|
|
71
|
+
constructor(client: Transport);
|
|
72
|
+
}
|
|
73
|
+
export {};
|