@aexhq/sdk 0.69.0 → 0.71.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Aex contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -10,14 +10,39 @@ console.log(await aex.account.get());
10
10
  ```
11
11
 
12
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.
13
+ extension builders are Brain's implementations. SDK 0.71 uses Brain 0.20 and official
14
+ extension packages 5.x. Rebuild custom Wasm Components against Brain 0.20's WIT; older
15
+ Components and session configurations are not migrated automatically. See https://aex.dev/docs
16
+ for a complete session example.
15
17
 
16
18
  Place uploaded Wasm Agentloops and Tools in `brainEnv` for hosted execution. `hostEnv`
17
19
  executes application functions in your process. Native hosted Components receive no server
18
20
  secrets, filesystem or network grants. Customer-selected HTTP Environments are not enabled
19
- on the initial deployment. Supply your model key per session.
21
+ on the initial deployment. Hosted `brainEnv` configuration must be empty; resource access
22
+ is configured by each Environment, not declared through extension `needs`. Prepare dependencies
23
+ for `hostEnv` Tools in your application before registering them. Supply your model key per session.
20
24
 
21
25
  `account.get()` and `account.usage()` accept a workload API key. `keys` management requires
22
26
  an authenticated account session and is normally performed in the dashboard. API keys do
23
27
  not grant authority to create more credentials. New key secrets are returned once.
28
+
29
+ ## Account management
30
+
31
+ Use an account session obtained through browser login for account management. Workload
32
+ API keys remain scoped to runtime operations and read-only account/usage access.
33
+
34
+ ```ts
35
+ const account = new Aex({ accountToken: process.env.AEX_ACCOUNT_TOKEN! });
36
+ await account.keys.list();
37
+ const issued = await account.keys.create({ name: "My app" });
38
+ await account.keys.update(issued.key.id, { name: "Renamed app" });
39
+ await account.keys.delete(issued.key.id);
40
+ await account.account.get(); // includes billing status and limits
41
+ await account.account.usage();
42
+ await account.account.logout();
43
+ ```
44
+
45
+ `account.account.authorizeLogin({code_challenge, redirect_uri})` and
46
+ `Aex.exchangeLogin({code, code_verifier, redirect_uri})` expose the shared HTTP login
47
+ contract for clients. The `@aexhq/cli` package handles opening the browser, PKCE,
48
+ loopback callback and local credential storage.
@@ -78,3 +78,36 @@ export interface IssuedKey {
78
78
  export interface KeyInput {
79
79
  name: string;
80
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
+ }
package/dist/index.d.ts CHANGED
@@ -1,16 +1,25 @@
1
1
  export * from "@aexhq/brain";
2
2
  export type * from "./generated.js";
3
3
  import { Brain, type BrainOptions } from "@aexhq/brain";
4
- import type { Account, Usage, ApiKey, IssuedKey, KeyInput } from "./generated.js";
5
- export type AexOptions = Omit<BrainOptions, "token" | "baseUrl"> & {
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
7
  };
8
+ export type AexOptions = AexConnection & ({
9
+ apiKey: string;
10
+ accountToken?: never;
11
+ } | {
12
+ accountToken: string;
13
+ apiKey?: never;
14
+ });
9
15
  export declare class Aex extends Brain {
10
- constructor({ apiKey, ...options }: AexOptions);
16
+ constructor({ apiKey, accountToken, ...options }: AexOptions);
17
+ static exchangeLogin(input: LoginExchange, options?: AexConnection): Promise<AccountSession>;
11
18
  readonly account: {
12
19
  get: () => Promise<Account>;
13
20
  usage: () => Promise<Usage>;
21
+ logout: () => Promise<void>;
22
+ authorizeLogin: (input: LoginGrantInput) => Promise<LoginGrant>;
14
23
  };
15
24
  /** Key management requires an account session; workload API keys cannot create credentials. */
16
25
  readonly keys: {
package/dist/index.js CHANGED
@@ -1,14 +1,19 @@
1
1
  export * from "@aexhq/brain";
2
2
  import { Brain } from "@aexhq/brain";
3
3
  export class Aex extends Brain {
4
- constructor({ apiKey, ...options }) {
5
- if (!apiKey)
6
- throw new TypeError("apiKey is required");
7
- super({ baseUrl: "https://api.aex.dev", ...options, token: apiKey });
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 });
8
+ }
9
+ static exchangeLogin(input, options = {}) {
10
+ return new Brain({ baseUrl: "https://api.aex.dev", ...options }).request("POST", "/v1/auth/exchange", input);
8
11
  }
9
12
  account = {
10
13
  get: () => this.request("GET", "/v1/account"),
11
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),
12
17
  };
13
18
  /** Key management requires an account session; workload API keys cannot create credentials. */
14
19
  keys = {
package/package.json CHANGED
@@ -1,16 +1,35 @@
1
1
  {
2
2
  "name": "@aexhq/sdk",
3
- "version": "0.69.0",
3
+ "version": "0.71.0",
4
4
  "description": "Aex accounts and hosted sessions using the Brain SDK",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "sideEffects": false,
8
- "engines": { "node": ">=22" },
9
- "repository": { "type": "git", "url": "git+https://github.com/aexhq/aex.git", "directory": "packages/sdk" },
10
- "exports": { ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" } },
11
- "files": ["dist", "README.md"],
12
- "publishConfig": { "access": "public", "tag": "next" },
13
- "dependencies": { "@aexhq/brain": "0.19.0" },
8
+ "engines": {
9
+ "node": ">=22"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/aexhq/aex.git",
14
+ "directory": "packages/sdk"
15
+ },
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "import": "./dist/index.js"
20
+ }
21
+ },
22
+ "files": [
23
+ "dist",
24
+ "README.md"
25
+ ],
26
+ "publishConfig": {
27
+ "access": "public",
28
+ "tag": "next"
29
+ },
30
+ "dependencies": {
31
+ "@aexhq/brain": "0.20.0"
32
+ },
14
33
  "scripts": {
15
34
  "gen": "node ../../tools/sdk-contracts.mjs",
16
35
  "build": "tsc -p tsconfig.json",