@aexhq/sdk 0.68.0 → 0.70.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 CHANGED
@@ -1,35 +1,44 @@
1
- # @aexhq/sdk
1
+ # Aex SDK
2
2
 
3
- The hosted Aex client uses the neutral Brain composition API with the `https://api.aex.dev` base
4
- URL and an Aex API key.
3
+ Install `@aexhq/sdk`. Create an API key at https://aex.dev/dashboard.
5
4
 
6
5
  ```ts
7
- import { Aex, brainEnv } from "@aexhq/sdk";
8
- import { awsMicroVm } from "@aexhq/env-aws-microvm";
9
- import { pi } from "@aexhq/agentloop-pi";
10
- import { bash, read } from "@aexhq/tools";
6
+ import { Aex, agentloop, brainEnv, component, hostEnv, tool } from "@aexhq/sdk";
11
7
 
12
8
  const aex = new Aex({ apiKey: process.env.AEX_API_KEY! });
13
- const workspace = awsMicroVm({ name: "sandbox", url: process.env.ENVIRONMENT_URL, token: process.env.ENVIRONMENT_TOKEN, region: "eu-west-2" });
14
- const session = await aex.sessions.create({
15
- model: {
16
- provider: "vercel-ai-gateway",
17
- name: "openai/gpt-5-mini",
18
- apiKey: process.env.VERCEL_AI_GATEWAY_API_KEY!,
19
- },
20
- agentloop: pi({ env: brainEnv({ name: "brain" }) }),
21
- tools: [read({ env: workspace }), bash({ env: workspace })],
22
- });
23
-
24
- await session.send("Inspect the workspace.");
25
- for await (const event of session.events()) console.log(event);
9
+ console.log(await aex.account.get());
26
10
  ```
27
11
 
28
- Aex supplies hosted authentication and policy. Brain admission, Tool placement, Environment
29
- operations, operation keys, and event cursors are handled by the shared Brain SDK.
12
+ `Aex` extends the pinned Brain client. Its sessions, registration, Events, Components and
13
+ extension builders are Brain's implementations. Existing Brain extension packages work with
14
+ the same contracts. See https://aex.dev/docs for a complete session example.
30
15
 
31
- This example requires a separately deployed AWS Environment driver. Supply its URL and bearer
32
- credential as `ENVIRONMENT_URL` and `ENVIRONMENT_TOKEN`; the SDK keeps the credential out of the
33
- Environment configuration and Tool implementation descriptors. See the
34
- [Environment package](https://github.com/aexhq/extensions/tree/main/packages/env-aws-microvm)
35
- for its supported runtime and deployment boundary.
16
+ Place uploaded Wasm Agentloops and Tools in `brainEnv` for hosted execution. `hostEnv`
17
+ executes application functions in your process. Native hosted Components receive no server
18
+ secrets, filesystem or network grants. Customer-selected HTTP Environments are not enabled
19
+ on the initial deployment. Supply your model key per session.
20
+
21
+ `account.get()` and `account.usage()` accept a workload API key. `keys` management requires
22
+ an authenticated account session and is normally performed in the dashboard. API keys do
23
+ not grant authority to create more credentials. New key secrets are returned once.
24
+
25
+ ## Account management
26
+
27
+ Use an account session obtained through browser login for account management. Workload
28
+ API keys remain scoped to runtime operations and read-only account/usage access.
29
+
30
+ ```ts
31
+ const account = new Aex({ accountToken: process.env.AEX_ACCOUNT_TOKEN! });
32
+ await account.keys.list();
33
+ const issued = await account.keys.create({ name: "My app" });
34
+ await account.keys.update(issued.key.id, { name: "Renamed app" });
35
+ await account.keys.delete(issued.key.id);
36
+ await account.account.get(); // includes billing status and limits
37
+ await account.account.usage();
38
+ await account.account.logout();
39
+ ```
40
+
41
+ `account.account.authorizeLogin({code_challenge, redirect_uri})` and
42
+ `Aex.exchangeLogin({code, code_verifier, redirect_uri})` expose the shared HTTP login
43
+ contract for clients. The `@aexhq/cli` package handles opening the browser, PKCE,
44
+ loopback callback and local credential storage.
@@ -0,0 +1,113 @@
1
+ /**
2
+ * This interface was referenced by `AexContracts`'s JSON-Schema
3
+ * via the `definition` "Billing".
4
+ */
5
+ export type Billing = "preview_customer_model_keys";
6
+ export interface AexContracts {
7
+ }
8
+ /**
9
+ * This interface was referenced by `AexContracts`'s JSON-Schema
10
+ * via the `definition` "Limits".
11
+ */
12
+ export interface Limits {
13
+ accounts: number;
14
+ active_turns_per_account: number;
15
+ artifact_bytes_per_account: number;
16
+ artifacts_per_account: number;
17
+ claims_per_account: number;
18
+ hosts_per_account: number;
19
+ keys_per_account: number;
20
+ minimum_free_disk_bytes: number;
21
+ request_bytes: number;
22
+ requests: number;
23
+ requests_per_account: number;
24
+ response_bytes: number;
25
+ retained_bytes_per_account: number;
26
+ retention_secs: number;
27
+ sessions_per_account: number;
28
+ streams_per_account: number;
29
+ turn_reserve_bytes: number;
30
+ upstream_timeout_secs: number;
31
+ usage_max_age_secs: number;
32
+ }
33
+ /**
34
+ * This interface was referenced by `AexContracts`'s JSON-Schema
35
+ * via the `definition` "Usage".
36
+ */
37
+ export interface Usage {
38
+ active_turns: number;
39
+ measured_at?: number | null;
40
+ retained_bytes: number;
41
+ sessions: number;
42
+ }
43
+ /**
44
+ * This interface was referenced by `AexContracts`'s JSON-Schema
45
+ * via the `definition` "Account".
46
+ */
47
+ export interface Account {
48
+ billing: Billing;
49
+ created: number;
50
+ email?: string | null;
51
+ id: string;
52
+ limits: Limits;
53
+ usage: Usage;
54
+ }
55
+ /**
56
+ * This interface was referenced by `AexContracts`'s JSON-Schema
57
+ * via the `definition` "ApiKey".
58
+ */
59
+ export interface ApiKey {
60
+ active: boolean;
61
+ created: number;
62
+ id: string;
63
+ name: string;
64
+ prefix: string;
65
+ }
66
+ /**
67
+ * This interface was referenced by `AexContracts`'s JSON-Schema
68
+ * via the `definition` "IssuedKey".
69
+ */
70
+ export interface IssuedKey {
71
+ key: ApiKey;
72
+ token: string;
73
+ }
74
+ /**
75
+ * This interface was referenced by `AexContracts`'s JSON-Schema
76
+ * via the `definition` "KeyInput".
77
+ */
78
+ export interface KeyInput {
79
+ name: string;
80
+ }
81
+ /**
82
+ * This interface was referenced by `AexContracts`'s JSON-Schema
83
+ * via the `definition` "LoginGrantInput".
84
+ */
85
+ export interface LoginGrantInput {
86
+ code_challenge: string;
87
+ redirect_uri: string;
88
+ }
89
+ /**
90
+ * This interface was referenced by `AexContracts`'s JSON-Schema
91
+ * via the `definition` "LoginGrant".
92
+ */
93
+ export interface LoginGrant {
94
+ code: string;
95
+ expires: number;
96
+ }
97
+ /**
98
+ * This interface was referenced by `AexContracts`'s JSON-Schema
99
+ * via the `definition` "LoginExchange".
100
+ */
101
+ export interface LoginExchange {
102
+ code: string;
103
+ code_verifier: string;
104
+ redirect_uri: string;
105
+ }
106
+ /**
107
+ * This interface was referenced by `AexContracts`'s JSON-Schema
108
+ * via the `definition` "AccountSession".
109
+ */
110
+ export interface AccountSession {
111
+ expires: number;
112
+ token: string;
113
+ }
@@ -0,0 +1,2 @@
1
+ /* Generated from aex-server schemas. */
2
+ export {};
package/dist/index.d.ts CHANGED
@@ -1,13 +1,31 @@
1
+ export * from "@aexhq/brain";
2
+ export type * from "./generated.js";
1
3
  import { Brain, type BrainOptions } from "@aexhq/brain";
2
- export { BrainError as AexError } from "@aexhq/brain";
3
- export { agentloop, brainEnv, component, environment, hostEnv, tool } from "@aexhq/brain";
4
- export type { PlacedAgentloop, BrainEnvOptions, Component, CreateSessionOptions, CustomProviderModel, Environment, KnownProviderId, KnownProviderModel, ModelContentBlock, ModelMessage, ModelResponse, ModelSelection, ModelStopReason, ModelUsage, OperationOptions, Outcome, Schema, SchemaInput, SchemaOutput, SessionEvent, SessionState, SessionStreamEvent, SessionTool, PlacedTool, ToolDefinition, VercelAiGatewayModel, } from "@aexhq/brain";
5
- export interface AexOptions {
6
- apiKey: string;
4
+ import type { Account, Usage, ApiKey, IssuedKey, KeyInput, LoginGrantInput, LoginGrant, LoginExchange, AccountSession } from "./generated.js";
5
+ export type AexConnection = Omit<BrainOptions, "token" | "baseUrl"> & {
7
6
  baseUrl?: string;
8
- fetch?: BrainOptions["fetch"];
9
- timeoutMs?: number;
10
- }
7
+ };
8
+ export type AexOptions = AexConnection & ({
9
+ apiKey: string;
10
+ accountToken?: never;
11
+ } | {
12
+ accountToken: string;
13
+ apiKey?: never;
14
+ });
11
15
  export declare class Aex extends Brain {
12
- constructor(options: AexOptions);
16
+ constructor({ apiKey, accountToken, ...options }: AexOptions);
17
+ static exchangeLogin(input: LoginExchange, options?: AexConnection): Promise<AccountSession>;
18
+ readonly account: {
19
+ get: () => Promise<Account>;
20
+ usage: () => Promise<Usage>;
21
+ logout: () => Promise<void>;
22
+ authorizeLogin: (input: LoginGrantInput) => Promise<LoginGrant>;
23
+ };
24
+ /** Key management requires an account session; workload API keys cannot create credentials. */
25
+ readonly keys: {
26
+ list: () => Promise<ApiKey[]>;
27
+ create: (input: KeyInput) => Promise<IssuedKey>;
28
+ update: (id: string, input: KeyInput) => Promise<ApiKey>;
29
+ delete: (id: string) => Promise<void>;
30
+ };
13
31
  }
package/dist/index.js CHANGED
@@ -1,16 +1,25 @@
1
+ export * from "@aexhq/brain";
1
2
  import { Brain } from "@aexhq/brain";
2
- export { BrainError as AexError } from "@aexhq/brain";
3
- export { agentloop, brainEnv, component, environment, hostEnv, tool } from "@aexhq/brain";
4
- const DEFAULT_API_URL = "https://api.aex.dev";
5
3
  export class Aex extends Brain {
6
- constructor(options) {
7
- if (options.apiKey.trim() === "")
8
- throw new TypeError("Aex apiKey cannot be empty");
9
- super({
10
- baseUrl: options.baseUrl ?? DEFAULT_API_URL,
11
- token: options.apiKey,
12
- ...(options.fetch === undefined ? {} : { fetch: options.fetch }),
13
- ...(options.timeoutMs === undefined ? {} : { timeoutMs: options.timeoutMs }),
14
- });
4
+ constructor({ apiKey, accountToken, ...options }) {
5
+ if (!(apiKey || accountToken) || (apiKey && accountToken))
6
+ throw new TypeError("one apiKey or accountToken is required");
7
+ super({ baseUrl: "https://api.aex.dev", ...options, token: apiKey ?? accountToken });
15
8
  }
9
+ static exchangeLogin(input, options = {}) {
10
+ return new Brain({ baseUrl: "https://api.aex.dev", ...options }).request("POST", "/v1/auth/exchange", input);
11
+ }
12
+ account = {
13
+ get: () => this.request("GET", "/v1/account"),
14
+ usage: () => this.request("GET", "/v1/usage"),
15
+ logout: () => this.request("DELETE", "/v1/account/session"),
16
+ authorizeLogin: (input) => this.request("POST", "/v1/auth/grants", input),
17
+ };
18
+ /** Key management requires an account session; workload API keys cannot create credentials. */
19
+ keys = {
20
+ list: () => this.request("GET", "/v1/keys"),
21
+ create: (input) => this.request("POST", "/v1/keys", input),
22
+ update: (id, input) => this.request("PATCH", `/v1/keys/${encodeURIComponent(id)}`, input),
23
+ delete: (id) => this.request("DELETE", `/v1/keys/${encodeURIComponent(id)}`),
24
+ };
16
25
  }
package/package.json CHANGED
@@ -1,42 +1,39 @@
1
1
  {
2
2
  "name": "@aexhq/sdk",
3
- "version": "0.68.0",
4
- "description": "TypeScript SDK for Aex sessions",
5
- "license": "Apache-2.0",
6
- "homepage": "https://aex.dev",
3
+ "version": "0.70.0",
4
+ "description": "Aex accounts and hosted sessions using the Brain SDK",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "sideEffects": false,
8
+ "engines": {
9
+ "node": ">=22"
10
+ },
7
11
  "repository": {
8
12
  "type": "git",
9
13
  "url": "git+https://github.com/aexhq/aex.git",
10
14
  "directory": "packages/sdk"
11
15
  },
12
- "type": "module",
13
- "engines": {
14
- "node": ">=22.0.0"
15
- },
16
- "publishConfig": {
17
- "access": "public",
18
- "provenance": false,
19
- "tag": "next"
20
- },
21
16
  "exports": {
22
17
  ".": {
23
18
  "types": "./dist/index.d.ts",
24
19
  "import": "./dist/index.js"
25
- },
26
- "./package.json": "./package.json"
20
+ }
27
21
  },
28
22
  "files": [
29
23
  "dist",
30
24
  "README.md"
31
25
  ],
32
- "scripts": {
33
- "build": "tsc -p tsconfig.json",
34
- "test": "tsc -p tsconfig.json && node --test"
26
+ "publishConfig": {
27
+ "access": "public",
28
+ "tag": "next"
35
29
  },
36
30
  "dependencies": {
37
- "@aexhq/brain": "0.18.0"
31
+ "@aexhq/brain": "0.19.0"
38
32
  },
39
- "devDependencies": {
40
- "typescript": "5.9.3"
33
+ "scripts": {
34
+ "gen": "node ../../tools/sdk-contracts.mjs",
35
+ "build": "tsc -p tsconfig.json",
36
+ "test": "npm run build && node --test test/*.test.mjs",
37
+ "prepack": "npm run build"
41
38
  }
42
39
  }