@aexhq/sdk 0.86.0 → 0.88.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 +8 -3
- package/dist/index.d.ts +6 -2
- package/dist/index.js +17 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ tools, send messages, and read saved conversations without operating a Brain ser
|
|
|
8
8
|
Create a key in the [dashboard](https://aex.dev/dashboard). With Node.js 22 or newer, install:
|
|
9
9
|
|
|
10
10
|
```sh
|
|
11
|
-
npm install @aexhq/sdk@0.
|
|
11
|
+
npm install @aexhq/sdk@0.88.0 @aexhq/agentloop-pi@9.0.0 zod@4.4.3
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
Set `AEX_API_KEY` and `OPENAI_API_KEY` in your server environment. Save as `order.mjs` and
|
|
@@ -52,10 +52,11 @@ explains setup and where other tools run.
|
|
|
52
52
|
## Sessions and tools
|
|
53
53
|
|
|
54
54
|
The SDK uses Brain's session API and extension helpers. You can import `tool`, `agentloop`,
|
|
55
|
-
`brainEnv`, `hostEnv`, `component` and `environment` from `@aexhq/sdk`.
|
|
55
|
+
`brainEnv`, `hostEnv`, `component`, `program` and `environment` from `@aexhq/sdk`.
|
|
56
56
|
|
|
57
57
|
- [Sessions](https://aex.dev/brain/docs/concepts/sessions): send, submit, stream, reconnect and stop.
|
|
58
58
|
- [Tools](https://aex.dev/brain/docs/guides/write-a-tool): application functions and packaged tools.
|
|
59
|
+
- [Custom Agentloops](https://aex.dev/brain/docs/reference/agentloop-contract): one scoped `ctx`, KV state and automatic completion on successful return. Rebuild custom loops with Brain SDK 0.38.0 and use matching Pi/Codex 9.0.0 for new sessions.
|
|
59
60
|
- [Structured output](#structured-output): validated JSON answers.
|
|
60
61
|
- [Managed environments](https://github.com/aexhq/aex/blob/main/docs/environments.md): hosted tools and workspaces.
|
|
61
62
|
- [Attachments](https://github.com/aexhq/aex/blob/main/docs/attachments.md): upload images and PDFs.
|
|
@@ -122,7 +123,7 @@ correction. It supports JSON Schema, not arbitrary local Zod refinements or tran
|
|
|
122
123
|
Brain SDK 0.34 removes typed sends and the corresponding types and errors. Aex SDK 0.84
|
|
123
124
|
owns them. Existing Aex `send(..., { output })` calls keep the same syntax and behavior.
|
|
124
125
|
Import `StructuredSendOptions` and `StructuredOutputError` from `@aexhq/sdk`.
|
|
125
|
-
Use Pi
|
|
126
|
+
Use Pi 9.0.0, Codex 9.0.0 and extension packages pinned to Brain 0.38.0 with this SDK.
|
|
126
127
|
Mixing exact Brain dependency versions creates different TypeScript extension brands.
|
|
127
128
|
|
|
128
129
|
An existing standalone Brain handle can use Aex's policy without changing servers:
|
|
@@ -168,3 +169,7 @@ request and read its committed outcome later. Desktop apps can use
|
|
|
168
169
|
without receiving an account credential.
|
|
169
170
|
|
|
170
171
|
Choose [clientBrowser](https://aex.dev/docs/client-browser) for the user's connected tab, or [Application](https://aex.dev/docs/application) for a deployed backend. Both use `aex.sessions.create()` and ordinary Tool declarations.
|
|
172
|
+
|
|
173
|
+
The SDK prepares hosted code during session setup. To do that earlier and reuse it across
|
|
174
|
+
sessions, call `const loop = await aex.prepare(pi())` during startup, then use `agentloop: loop`.
|
|
175
|
+
See [Environment preparation](https://github.com/aexhq/aex/blob/main/docs/environments.md#prepare-hosted-code).
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { AexSessionHandle } from "./session.js";
|
|
|
4
4
|
export { StructuredOutputError } from "./structured-output.js";
|
|
5
5
|
export type { StructuredSendOptions } from "./structured-output.js";
|
|
6
6
|
import { application } from "@aexhq/env-http";
|
|
7
|
-
import { Brain, type BrainOptions, type CreateSessionOptions, type OperationOptions, type ModelSelection } from "@aexhq/brain";
|
|
7
|
+
import { Brain, type PlacedAgentloop, type PlacedTool, type BrainOptions, type CreateSessionOptions, type OperationOptions, type ModelSelection } from "@aexhq/brain";
|
|
8
8
|
import { AexSessionHandle } from "./session.js";
|
|
9
9
|
import type { ClientAccess, EnvironmentCatalog, TokenUsage } from "./generated.js";
|
|
10
10
|
import type { Attachment, Account, Usage, ApiKey, IssuedKey, KeyInput, LoginGrantInput, LoginGrant, LoginExchange, AccountSession, Wallet, BillingSettings, LedgerPage, Topup, TopupInput, Refund, RefundInput, SyncPayment } from "./generated.js";
|
|
@@ -34,11 +34,12 @@ export declare class Aex {
|
|
|
34
34
|
private readonly clientAccess?;
|
|
35
35
|
constructor({ apiKey, accountToken, clientAccess, maxCostMicroUsd, ...options }: AexOptions);
|
|
36
36
|
private composition;
|
|
37
|
+
private preparedComposition;
|
|
37
38
|
get baseUrl(): string;
|
|
38
39
|
readonly sessions: Readonly<{
|
|
39
40
|
create: (options: AexSessionOptions, operation?: OperationOptions) => Promise<AexSessionHandle>;
|
|
40
41
|
get: (sessionId: string, options?: {
|
|
41
|
-
tools?: readonly
|
|
42
|
+
tools?: readonly PlacedTool[];
|
|
42
43
|
} | undefined) => Promise<AexSessionHandle>;
|
|
43
44
|
list: () => ReturnType<Brain["sessions"]["list"]>;
|
|
44
45
|
}>;
|
|
@@ -48,6 +49,9 @@ export declare class Aex {
|
|
|
48
49
|
models(...args: Parameters<Brain["models"]>): ReturnType<Brain["models"]>;
|
|
49
50
|
stream(...args: Parameters<Brain["stream"]>): ReturnType<Brain["stream"]>;
|
|
50
51
|
streamPath(...args: Parameters<Brain["streamPath"]>): ReturnType<Brain["streamPath"]>;
|
|
52
|
+
prepare<T extends PlacedAgentloop | PlacedTool>(extension: T): Promise<T>;
|
|
53
|
+
prepareEnvironment(...args: Parameters<Brain["prepareEnvironment"]>): ReturnType<Brain["prepareEnvironment"]>;
|
|
54
|
+
admitProgram(...args: Parameters<Brain["admitProgram"]>): ReturnType<Brain["admitProgram"]>;
|
|
51
55
|
admit(...args: Parameters<Brain["admit"]>): ReturnType<Brain["admit"]>;
|
|
52
56
|
admitAgentloop(...args: Parameters<Brain["admitAgentloop"]>): ReturnType<Brain["admitAgentloop"]>;
|
|
53
57
|
admitTool(...args: Parameters<Brain["admitTool"]>): ReturnType<Brain["admitTool"]>;
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ export { AexSessionHandle } from "./session.js";
|
|
|
3
3
|
export { StructuredOutputError } from "./structured-output.js";
|
|
4
4
|
import { application } from "@aexhq/env-http";
|
|
5
5
|
import { composeApplication } from "./application.js";
|
|
6
|
-
import { Brain } from "@aexhq/brain";
|
|
6
|
+
import { Brain, inspectAgentloop, inspectTool, inspectEnvironment } from "@aexhq/brain";
|
|
7
7
|
import { AexSessionHandle } from "./session.js";
|
|
8
8
|
function nonnegativeInteger(value, name) {
|
|
9
9
|
if (!Number.isSafeInteger(value) || value < 0)
|
|
@@ -43,9 +43,20 @@ export class Aex {
|
|
|
43
43
|
throw new TypeError("server-side sessions require a model apiKey");
|
|
44
44
|
return composeApplication({ ...options, model: { ...model, apiKey: model.apiKey } }, this.baseUrl);
|
|
45
45
|
}
|
|
46
|
+
async preparedComposition(options) {
|
|
47
|
+
const composition = this.composition(options);
|
|
48
|
+
const agentloop = inspectEnvironment(inspectAgentloop(composition.agentloop).environment).driver.driver === "brain"
|
|
49
|
+
? await this.client.prepare(composition.agentloop) : composition.agentloop;
|
|
50
|
+
const tools = [];
|
|
51
|
+
for (const tool of composition.tools ?? []) {
|
|
52
|
+
tools.push(inspectEnvironment(inspectTool(tool).environment).driver.driver === "brain"
|
|
53
|
+
? await this.client.prepare(tool) : tool);
|
|
54
|
+
}
|
|
55
|
+
return { ...composition, agentloop, tools };
|
|
56
|
+
}
|
|
46
57
|
get baseUrl() { return this.client.baseUrl; }
|
|
47
58
|
sessions = Object.freeze({
|
|
48
|
-
create: async (options, operation) => new AexSessionHandle(await this.client.sessions.create(this.
|
|
59
|
+
create: async (options, operation) => new AexSessionHandle(await this.client.sessions.create(await this.preparedComposition(options), operation)),
|
|
49
60
|
get: async (...args) => new AexSessionHandle(await this.client.sessions.get(...args)),
|
|
50
61
|
list: () => this.client.sessions.list(),
|
|
51
62
|
});
|
|
@@ -55,6 +66,9 @@ export class Aex {
|
|
|
55
66
|
models(...args) { return this.client.models(...args); }
|
|
56
67
|
stream(...args) { return this.client.stream(...args); }
|
|
57
68
|
streamPath(...args) { return this.client.streamPath(...args); }
|
|
69
|
+
prepare(extension) { return this.client.prepare(extension); }
|
|
70
|
+
prepareEnvironment(...args) { return this.client.prepareEnvironment(...args); }
|
|
71
|
+
admitProgram(...args) { return this.client.admitProgram(...args); }
|
|
58
72
|
admit(...args) { return this.client.admit(...args); }
|
|
59
73
|
admitAgentloop(...args) { return this.client.admitAgentloop(...args); }
|
|
60
74
|
admitTool(...args) { return this.client.admitTool(...args); }
|
|
@@ -121,7 +135,7 @@ export class Aex {
|
|
|
121
135
|
grant: async ({ session, origin, expiresAt = Math.floor(Date.now() / 1000) + 3600 }) => {
|
|
122
136
|
if (this.clientAccess)
|
|
123
137
|
throw new TypeError("client grants require a backend API key");
|
|
124
|
-
const prepared = await this.client.sessions.prepare(this.
|
|
138
|
+
const prepared = await this.client.sessions.prepare(await this.preparedComposition(session), "authorized-client");
|
|
125
139
|
return this.request("POST", "/v1/clients", { origin, expires_at: expiresAt, session: prepared });
|
|
126
140
|
},
|
|
127
141
|
revoke: (id) => this.request("DELETE", `/v1/clients/${encodeURIComponent(id)}`),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aexhq/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.88.0",
|
|
4
4
|
"description": "Aex accounts and hosted sessions using the Brain SDK",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"tag": "next"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@aexhq/brain": "0.
|
|
31
|
+
"@aexhq/brain": "0.38.0",
|
|
32
32
|
"zod": "4.4.3",
|
|
33
|
-
"@aexhq/env-http": "0.3.
|
|
33
|
+
"@aexhq/env-http": "0.3.3"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"gen": "node ../../tools/sdk-contracts.mjs",
|