@aexhq/sdk 0.54.0 → 0.55.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/README.md +16 -123
- package/dist/errors.d.ts +33 -0
- package/dist/errors.js +69 -0
- package/dist/index.d.ts +16 -23
- package/dist/index.js +18 -16
- package/dist/json.d.ts +4 -0
- package/dist/json.js +46 -0
- package/dist/session.d.ts +74 -0
- package/dist/session.js +255 -0
- package/dist/transport.d.ts +22 -0
- package/dist/transport.js +196 -0
- package/package.json +16 -64
- package/LICENSE +0 -201
- package/NOTICE +0 -38
- package/dist/client/aex.d.ts +0 -38
- package/dist/client/aex.js +0 -149
- package/dist/client/aex.js.map +0 -1
- package/dist/client/credentials.d.ts +0 -25
- package/dist/client/credentials.js +0 -97
- package/dist/client/credentials.js.map +0 -1
- package/dist/client/routing.d.ts +0 -7
- package/dist/client/routing.js +0 -26
- package/dist/client/routing.js.map +0 -1
- package/dist/downloads/download.d.ts +0 -18
- package/dist/downloads/download.js +0 -67
- package/dist/downloads/download.js.map +0 -1
- package/dist/files/workspace-files.d.ts +0 -55
- package/dist/files/workspace-files.js +0 -150
- package/dist/files/workspace-files.js.map +0 -1
- package/dist/generated/errors.d.ts +0 -12
- package/dist/generated/errors.js +0 -66
- package/dist/generated/errors.js.map +0 -1
- package/dist/generated/models.d.ts +0 -853
- package/dist/generated/models.js +0 -62
- package/dist/generated/models.js.map +0 -1
- package/dist/generated/resources.d.ts +0 -265
- package/dist/generated/resources.js +0 -207
- package/dist/generated/resources.js.map +0 -1
- package/dist/generated/routes.d.ts +0 -44
- package/dist/generated/routes.js +0 -510
- package/dist/generated/routes.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/observations/stream.d.ts +0 -1
- package/dist/observations/stream.js +0 -18
- package/dist/observations/stream.js.map +0 -1
- package/dist/transport/errors.d.ts +0 -60
- package/dist/transport/errors.js +0 -107
- package/dist/transport/errors.js.map +0 -1
- package/dist/transport/pagination.d.ts +0 -8
- package/dist/transport/pagination.js +0 -34
- package/dist/transport/pagination.js.map +0 -1
- package/dist/transport/retry.d.ts +0 -21
- package/dist/transport/retry.js +0 -37
- package/dist/transport/retry.js.map +0 -1
- package/dist/transport/transport.d.ts +0 -33
- package/dist/transport/transport.js +0 -111
- package/dist/transport/transport.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,131 +1,24 @@
|
|
|
1
1
|
# @aexhq/sdk
|
|
2
2
|
|
|
3
|
-
The zero-dependency TypeScript SDK for the session-centered AEX public API.
|
|
4
|
-
|
|
5
|
-
```bash
|
|
6
|
-
npm install @aexhq/sdk
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
## Quickstart
|
|
10
|
-
|
|
11
3
|
```ts
|
|
12
|
-
import { Aex
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
4
|
+
import { Aex } from "@aexhq/sdk";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
|
|
7
|
+
const aex = new Aex({ apiKey: "aex_sk_..." });
|
|
8
|
+
const session = await aex.sessions.create({
|
|
9
|
+
model: {
|
|
10
|
+
provider: "anthropic",
|
|
11
|
+
name: "claude-sonnet-5",
|
|
12
|
+
apiKey: "sk-ant-...",
|
|
20
13
|
},
|
|
21
|
-
idempotencyKey: crypto.randomUUID(),
|
|
22
14
|
});
|
|
23
15
|
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (frame.kind === "committed" && frame.message?.role === "assistant") {
|
|
29
|
-
return frame.message;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
throw new Error("message stream ended before the assistant committed");
|
|
33
|
-
})();
|
|
34
|
-
|
|
35
|
-
await aex.sessions.sessionMessageSend({
|
|
36
|
-
sessionId: session.id,
|
|
37
|
-
body: { text: "Inspect the tests and summarize the failures." },
|
|
38
|
-
idempotencyKey: crypto.randomUUID(),
|
|
39
|
-
});
|
|
40
|
-
console.log(await committed);
|
|
41
|
-
|
|
42
|
-
await aex.sessions.sessionTerminate({
|
|
43
|
-
sessionId: session.id,
|
|
44
|
-
body: {},
|
|
45
|
-
operationId: newId("operation"),
|
|
46
|
-
});
|
|
16
|
+
const result = await session.output(
|
|
17
|
+
z.object({ answer: z.string() }),
|
|
18
|
+
"Answer the question.",
|
|
19
|
+
);
|
|
47
20
|
```
|
|
48
21
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
Anthropic, DeepSeek, xAI, Meta, Moonshot AI, and Alibaba.
|
|
53
|
-
|
|
54
|
-
## Client surface
|
|
55
|
-
|
|
56
|
-
Regional session and file calls use a workspace `apiKey`. Central bootstrap,
|
|
57
|
-
API-key, and billing calls use a GitHub `dashboardSession`. A client may hold
|
|
58
|
-
both; the SDK sends each credential only to its owning API plane.
|
|
59
|
-
|
|
60
|
-
```ts
|
|
61
|
-
const aex = new Aex({
|
|
62
|
-
apiKey: process.env.AEX_WORKSPACE_API_KEY!,
|
|
63
|
-
dashboardSession: process.env.AEX_DASHBOARD_SESSION!,
|
|
64
|
-
});
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
Generated namespaces are `apiKeys`, `auth`, `billing`, `bootstrap`, `registry`,
|
|
68
|
-
`sessions`, and `uploads`. `aex.workspaceFiles` adds verified convenience
|
|
69
|
-
helpers for the latest-only file API. `ROUTES` and `aex.execute(...)` expose the
|
|
70
|
-
same generated contract without a second handwritten route table.
|
|
71
|
-
|
|
72
|
-
## Sessions and sandboxes
|
|
73
|
-
|
|
74
|
-
A session is the only public execution resource. It owns committed messages,
|
|
75
|
-
one active root message, durable tool effects, native subagents, frozen file
|
|
76
|
-
mounts, sandbox state, and telemetry. There is no public run resource.
|
|
77
|
-
|
|
78
|
-
The default sandbox starts preparing in the background when session creation
|
|
79
|
-
commits, then suspends when no tool call is waiting. A sandbox tool call waits
|
|
80
|
-
for the exact generation to become ready and resumes it when required. Set
|
|
81
|
-
`sandbox.enabled` to `false` to allocate no sandbox; sandbox-only tools then
|
|
82
|
-
return a structured error the model can handle.
|
|
83
|
-
|
|
84
|
-
Cancel stops active work and returns the session to idle. Terminate destroys
|
|
85
|
-
sandbox compute while retaining messages and telemetry. Delete irreversibly
|
|
86
|
-
removes session-owned content; independent workspace files remain.
|
|
87
|
-
|
|
88
|
-
## Files, tools, and MCP
|
|
89
|
-
|
|
90
|
-
`aex.workspaceFiles` provides `put`, `upload`, `get`, `list`, `download`, and
|
|
91
|
-
`delete`. Each logical name has only one current value. Inputs may be inline
|
|
92
|
-
text or bytes, an HTTPS URL, or a direct multipart upload. Session creation
|
|
93
|
-
freezes selected names and mount paths, so later overwrites do not change an
|
|
94
|
-
existing session.
|
|
95
|
-
|
|
96
|
-
Messages are text-only. Upload arbitrary images, PDFs, video, archives, or
|
|
97
|
-
source and tell the model which path under `/workspace` to inspect.
|
|
98
|
-
|
|
99
|
-
The built-in tool surface is Bash, file read/edit/write, MCP,
|
|
100
|
-
`storage.persist`, and native create/wait/stop subagent tools. Configure remote
|
|
101
|
-
Streamable HTTP or sandbox-process MCP per session. Large tool results keep a
|
|
102
|
-
bounded preview and the full bytes at a sandbox path; `storage.persist`
|
|
103
|
-
publishes a chosen sandbox file as the latest workspace value. Native
|
|
104
|
-
subagents are bounded to 12 child identities per session lifetime and depth 3.
|
|
105
|
-
|
|
106
|
-
`sessionMessageSend` accepts optional native JSON Schema output through
|
|
107
|
-
`responseFormat`. Strict structured output is admitted only for a qualified
|
|
108
|
-
provider/model capability; AEX does not present prompt emulation as strict.
|
|
109
|
-
|
|
110
|
-
## Streaming, telemetry, and billing
|
|
111
|
-
|
|
112
|
-
`sessionMessagesStream` emits bounded preview, gap, committed, reconcile, and
|
|
113
|
-
heartbeat frames. Committed messages preserve provider-neutral text, tool-call,
|
|
114
|
-
and tool-result parts.
|
|
115
|
-
|
|
116
|
-
Session telemetry is available as a live stream, retained replay, and verified
|
|
117
|
-
compressed download. Billing resources expose prepaid balance, saved-card
|
|
118
|
-
display metadata, hosted card setup and top-up, immutable transactions, and
|
|
119
|
-
usage. Billing methods require `dashboardSession`; session and file methods
|
|
120
|
-
require `apiKey`.
|
|
121
|
-
|
|
122
|
-
See the [AEX documentation](https://aex.dev/docs) for complete examples.
|
|
123
|
-
|
|
124
|
-
## Status
|
|
125
|
-
|
|
126
|
-
AEX is in active prelaunch development. Expect breaking changes and do not rely
|
|
127
|
-
on the hosted service for production workloads yet.
|
|
128
|
-
|
|
129
|
-
## License
|
|
130
|
-
|
|
131
|
-
Apache License 2.0. See [LICENSE](LICENSE) and [NOTICE](NOTICE).
|
|
22
|
+
`send()` returns text. `output()` returns a normal typed Promise and uses `https://api.aex.dev` by
|
|
23
|
+
default. Zod schemas must be representable as JSON Schema; process-local custom refinements and
|
|
24
|
+
transforms fail before any model work is admitted.
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ApiError, ApiErrorCode, OutputValidationIssue } from "@aexhq/contracts/session";
|
|
2
|
+
export interface AexErrorOptions {
|
|
3
|
+
code?: ApiErrorCode | undefined;
|
|
4
|
+
status?: number | undefined;
|
|
5
|
+
param?: string | undefined;
|
|
6
|
+
requestId?: string | undefined;
|
|
7
|
+
cause?: unknown;
|
|
8
|
+
}
|
|
9
|
+
export declare class AexError extends Error {
|
|
10
|
+
readonly code: ApiErrorCode | undefined;
|
|
11
|
+
readonly status: number | undefined;
|
|
12
|
+
readonly param: string | undefined;
|
|
13
|
+
readonly requestId: string | undefined;
|
|
14
|
+
constructor(message: string, options?: AexErrorOptions);
|
|
15
|
+
}
|
|
16
|
+
export declare class OutputSchemaError extends AexError {
|
|
17
|
+
constructor(message: string, options?: AexErrorOptions);
|
|
18
|
+
}
|
|
19
|
+
export declare class OutputRefusalError extends AexError {
|
|
20
|
+
constructor(message: string, options?: AexErrorOptions);
|
|
21
|
+
}
|
|
22
|
+
export declare class OutputValidationError extends AexError {
|
|
23
|
+
readonly issues: readonly OutputValidationIssue[];
|
|
24
|
+
constructor(message: string, issues?: readonly OutputValidationIssue[], options?: AexErrorOptions);
|
|
25
|
+
}
|
|
26
|
+
export declare class SessionError extends AexError {
|
|
27
|
+
constructor(message: string, options?: AexErrorOptions);
|
|
28
|
+
}
|
|
29
|
+
export declare class AbortError extends AexError {
|
|
30
|
+
constructor(message?: string, options?: AexErrorOptions);
|
|
31
|
+
}
|
|
32
|
+
export declare function errorFromApi(error: ApiError, status?: number, issues?: readonly OutputValidationIssue[]): AexError;
|
|
33
|
+
export declare function abortError(cause?: unknown): AbortError;
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export class AexError extends Error {
|
|
2
|
+
code;
|
|
3
|
+
status;
|
|
4
|
+
param;
|
|
5
|
+
requestId;
|
|
6
|
+
constructor(message, options = {}) {
|
|
7
|
+
super(message, options.cause === undefined ? undefined : { cause: options.cause });
|
|
8
|
+
this.name = "AexError";
|
|
9
|
+
this.code = options.code;
|
|
10
|
+
this.status = options.status;
|
|
11
|
+
this.param = options.param;
|
|
12
|
+
this.requestId = options.requestId;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export class OutputSchemaError extends AexError {
|
|
16
|
+
constructor(message, options = {}) {
|
|
17
|
+
super(message, { ...options, code: "output_schema_error" });
|
|
18
|
+
this.name = "OutputSchemaError";
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export class OutputRefusalError extends AexError {
|
|
22
|
+
constructor(message, options = {}) {
|
|
23
|
+
super(message, { ...options, code: "output_refused" });
|
|
24
|
+
this.name = "OutputRefusalError";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export class OutputValidationError extends AexError {
|
|
28
|
+
issues;
|
|
29
|
+
constructor(message, issues = [], options = {}) {
|
|
30
|
+
super(message, { ...options, code: "output_validation_error" });
|
|
31
|
+
this.name = "OutputValidationError";
|
|
32
|
+
this.issues = issues;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export class SessionError extends AexError {
|
|
36
|
+
constructor(message, options = {}) {
|
|
37
|
+
super(message, options);
|
|
38
|
+
this.name = "SessionError";
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export class AbortError extends AexError {
|
|
42
|
+
constructor(message = "The operation was cancelled", options = {}) {
|
|
43
|
+
super(message, { ...options, code: "cancelled" });
|
|
44
|
+
this.name = "AbortError";
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export function errorFromApi(error, status, issues = []) {
|
|
48
|
+
const options = {
|
|
49
|
+
code: error.code,
|
|
50
|
+
status,
|
|
51
|
+
param: error.param,
|
|
52
|
+
requestId: error.request_id,
|
|
53
|
+
};
|
|
54
|
+
switch (error.code) {
|
|
55
|
+
case "output_schema_error":
|
|
56
|
+
return new OutputSchemaError(error.message, options);
|
|
57
|
+
case "output_refused":
|
|
58
|
+
return new OutputRefusalError(error.message, options);
|
|
59
|
+
case "output_validation_error":
|
|
60
|
+
return new OutputValidationError(error.message, issues, options);
|
|
61
|
+
case "cancelled":
|
|
62
|
+
return new AbortError(error.message, options);
|
|
63
|
+
default:
|
|
64
|
+
return new SessionError(error.message, options);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export function abortError(cause) {
|
|
68
|
+
return new AbortError("The operation was cancelled", { cause });
|
|
69
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,23 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export {
|
|
4
|
-
export type {
|
|
5
|
-
export {
|
|
6
|
-
export type {
|
|
7
|
-
export {
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export { parseNdjsonFrames } from "./observations/stream.js";
|
|
18
|
-
export { ERROR_METADATA } from "./generated/errors.js";
|
|
19
|
-
export type { ErrorClass } from "./generated/errors.js";
|
|
20
|
-
export { ROUTES } from "./generated/routes.js";
|
|
21
|
-
export type { RouteDescriptor, RouteId } from "./generated/routes.js";
|
|
22
|
-
export * from "./generated/models.js";
|
|
23
|
-
export type { ExecuteOptions, ResourceExecutor } from "./generated/resources.js";
|
|
1
|
+
import { Sessions } from "./session.js";
|
|
2
|
+
import type { Fetch } from "./transport.js";
|
|
3
|
+
export { AbortError, AexError, OutputRefusalError, OutputSchemaError, OutputValidationError, SessionError, } from "./errors.js";
|
|
4
|
+
export type { AexErrorOptions } from "./errors.js";
|
|
5
|
+
export { Session, Sessions, } from "./session.js";
|
|
6
|
+
export type { CreateSessionOptions, ListSessionsOptions, ModelSummary, ModelOptions, OutputOptions, RequestOptions, SessionInput, SessionList, SessionSummary, } from "./session.js";
|
|
7
|
+
export type { EventOptions } from "./transport.js";
|
|
8
|
+
export interface AexOptions {
|
|
9
|
+
apiKey: string;
|
|
10
|
+
baseUrl?: string;
|
|
11
|
+
fetch?: Fetch;
|
|
12
|
+
}
|
|
13
|
+
export declare class Aex {
|
|
14
|
+
readonly sessions: Sessions;
|
|
15
|
+
constructor(options: AexOptions);
|
|
16
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { Sessions } from "./session.js";
|
|
2
|
+
import { Transport } from "./transport.js";
|
|
3
|
+
export { AbortError, AexError, OutputRefusalError, OutputSchemaError, OutputValidationError, SessionError, } from "./errors.js";
|
|
4
|
+
export { Session, Sessions, } from "./session.js";
|
|
5
|
+
const DEFAULT_API_URL = "https://api.aex.dev";
|
|
6
|
+
export class Aex {
|
|
7
|
+
sessions;
|
|
8
|
+
constructor(options) {
|
|
9
|
+
if (options.apiKey.trim() === "")
|
|
10
|
+
throw new TypeError("AEX apiKey cannot be empty");
|
|
11
|
+
const fetchImplementation = options.fetch ?? globalThis.fetch?.bind(globalThis);
|
|
12
|
+
if (fetchImplementation === undefined) {
|
|
13
|
+
throw new TypeError("This runtime does not provide fetch; pass a fetch implementation to Aex");
|
|
14
|
+
}
|
|
15
|
+
const transport = new Transport(options.apiKey, options.baseUrl ?? DEFAULT_API_URL, fetchImplementation);
|
|
16
|
+
this.sessions = new Sessions(transport);
|
|
17
|
+
}
|
|
18
|
+
}
|
package/dist/json.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** RFC 8785 canonical JSON. Object keys sort by UTF-16 code units, as required by JCS. */
|
|
2
|
+
export declare function canonicalize(value: unknown): string;
|
|
3
|
+
export declare function jcsSha256(value: unknown): Promise<string>;
|
|
4
|
+
export declare function randomIdempotencyKey(): string;
|
package/dist/json.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { OutputSchemaError, SessionError } from "./errors.js";
|
|
2
|
+
/** RFC 8785 canonical JSON. Object keys sort by UTF-16 code units, as required by JCS. */
|
|
3
|
+
export function canonicalize(value) {
|
|
4
|
+
const visit = (current) => {
|
|
5
|
+
if (Array.isArray(current))
|
|
6
|
+
return current.map(visit);
|
|
7
|
+
if (current !== null && typeof current === "object") {
|
|
8
|
+
const object = current;
|
|
9
|
+
return Object.fromEntries(Object.keys(object)
|
|
10
|
+
.filter((key) => object[key] !== undefined)
|
|
11
|
+
.sort()
|
|
12
|
+
.map((key) => [key, visit(object[key])]));
|
|
13
|
+
}
|
|
14
|
+
if (typeof current === "number" && !Number.isFinite(current)) {
|
|
15
|
+
throw new OutputSchemaError("The output schema contains a non-finite number");
|
|
16
|
+
}
|
|
17
|
+
return current;
|
|
18
|
+
};
|
|
19
|
+
const encoded = JSON.stringify(visit(value));
|
|
20
|
+
if (encoded === undefined) {
|
|
21
|
+
throw new OutputSchemaError("The output schema is not JSON-serialisable");
|
|
22
|
+
}
|
|
23
|
+
return encoded;
|
|
24
|
+
}
|
|
25
|
+
export async function jcsSha256(value) {
|
|
26
|
+
const subtle = globalThis.crypto?.subtle;
|
|
27
|
+
if (subtle === undefined) {
|
|
28
|
+
throw new OutputSchemaError("This runtime does not provide Web Crypto SHA-256 support");
|
|
29
|
+
}
|
|
30
|
+
const bytes = new TextEncoder().encode(canonicalize(value));
|
|
31
|
+
const digest = await subtle.digest("SHA-256", bytes);
|
|
32
|
+
return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
33
|
+
}
|
|
34
|
+
export function randomIdempotencyKey() {
|
|
35
|
+
const crypto = globalThis.crypto;
|
|
36
|
+
if (crypto === undefined) {
|
|
37
|
+
throw new SessionError("This runtime does not provide secure random values");
|
|
38
|
+
}
|
|
39
|
+
if (typeof crypto.randomUUID === "function")
|
|
40
|
+
return crypto.randomUUID();
|
|
41
|
+
const bytes = crypto.getRandomValues(new Uint8Array(16));
|
|
42
|
+
bytes[6] = ((bytes[6] ?? 0) & 0x0f) | 0x40;
|
|
43
|
+
bytes[8] = ((bytes[8] ?? 0) & 0x3f) | 0x80;
|
|
44
|
+
const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0"));
|
|
45
|
+
return `${hex.slice(0, 4).join("")}-${hex.slice(4, 6).join("")}-${hex.slice(6, 8).join("")}-${hex.slice(8, 10).join("")}-${hex.slice(10).join("")}`;
|
|
46
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { Event, Provider, Session as SessionData, SessionState } from "@aexhq/contracts/session";
|
|
2
|
+
import * as z from "zod";
|
|
3
|
+
import type { EventOptions } from "./transport.js";
|
|
4
|
+
import { Transport } from "./transport.js";
|
|
5
|
+
export type SessionInput = string;
|
|
6
|
+
export interface ModelOptions {
|
|
7
|
+
provider: Provider;
|
|
8
|
+
name: string;
|
|
9
|
+
apiKey: string;
|
|
10
|
+
baseUrl?: string;
|
|
11
|
+
maxOutputTokens?: number;
|
|
12
|
+
temperature?: number;
|
|
13
|
+
reasoningEffort?: "low" | "medium" | "high";
|
|
14
|
+
}
|
|
15
|
+
export interface CreateSessionOptions {
|
|
16
|
+
model: ModelOptions;
|
|
17
|
+
systemPrompt?: string;
|
|
18
|
+
metadata?: Record<string, string>;
|
|
19
|
+
}
|
|
20
|
+
export interface RequestOptions {
|
|
21
|
+
signal?: AbortSignal;
|
|
22
|
+
idempotencyKey?: string;
|
|
23
|
+
metadata?: Record<string, string>;
|
|
24
|
+
}
|
|
25
|
+
export interface OutputOptions extends RequestOptions {
|
|
26
|
+
}
|
|
27
|
+
export interface ListSessionsOptions {
|
|
28
|
+
limit?: number;
|
|
29
|
+
cursor?: string;
|
|
30
|
+
state?: SessionState;
|
|
31
|
+
signal?: AbortSignal;
|
|
32
|
+
}
|
|
33
|
+
export interface SessionList {
|
|
34
|
+
data: Session[];
|
|
35
|
+
hasMore: boolean;
|
|
36
|
+
nextCursor?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface ModelSummary {
|
|
39
|
+
provider: Provider;
|
|
40
|
+
name: string;
|
|
41
|
+
baseUrl?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface SessionSummary {
|
|
44
|
+
id: string;
|
|
45
|
+
state: SessionState;
|
|
46
|
+
model: ModelSummary;
|
|
47
|
+
createdAt: string;
|
|
48
|
+
updatedAt: string;
|
|
49
|
+
metadata: Readonly<Record<string, string | undefined>>;
|
|
50
|
+
}
|
|
51
|
+
export declare class Sessions {
|
|
52
|
+
#private;
|
|
53
|
+
constructor(transport: Transport);
|
|
54
|
+
create(options: CreateSessionOptions, request?: RequestOptions): Promise<Session>;
|
|
55
|
+
get(id: string, options?: Pick<RequestOptions, "signal">): Promise<Session>;
|
|
56
|
+
list(options?: ListSessionsOptions): Promise<SessionList>;
|
|
57
|
+
}
|
|
58
|
+
export declare class Session implements SessionSummary {
|
|
59
|
+
#private;
|
|
60
|
+
constructor(transport: Transport, data: SessionData);
|
|
61
|
+
get id(): string;
|
|
62
|
+
get state(): SessionState;
|
|
63
|
+
get model(): ModelSummary;
|
|
64
|
+
get createdAt(): string;
|
|
65
|
+
get updatedAt(): string;
|
|
66
|
+
get metadata(): Readonly<Record<string, string | undefined>>;
|
|
67
|
+
refresh(options?: Pick<RequestOptions, "signal">): Promise<this>;
|
|
68
|
+
send(input: SessionInput, options?: RequestOptions): Promise<string>;
|
|
69
|
+
output<Schema extends z.ZodType>(schema: Schema, input?: SessionInput, options?: OutputOptions): Promise<z.output<Schema>>;
|
|
70
|
+
events(options?: EventOptions): AsyncGenerator<Event>;
|
|
71
|
+
cancel(options?: Pick<RequestOptions, "signal">): Promise<this>;
|
|
72
|
+
delete(options?: Pick<RequestOptions, "signal">): Promise<void>;
|
|
73
|
+
private markIdle;
|
|
74
|
+
}
|