@aexhq/sdk 0.85.0 → 0.86.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 +25 -22
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -8,14 +8,14 @@ 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.86.0 @aexhq/agentloop-pi@7.3.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
|
|
15
15
|
run `node order.mjs`:
|
|
16
16
|
|
|
17
17
|
```js
|
|
18
|
-
import { Aex,
|
|
18
|
+
import { Aex, tool } from "@aexhq/sdk";
|
|
19
19
|
import { pi } from "@aexhq/agentloop-pi";
|
|
20
20
|
import { z } from "zod";
|
|
21
21
|
|
|
@@ -27,22 +27,22 @@ const lookupOrder = tool({
|
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
const aex = new Aex({ apiKey: process.env.AEX_API_KEY });
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
console.log("Session:", session.id);
|
|
40
|
-
} finally {
|
|
41
|
-
await session.end();
|
|
30
|
+
aex.sessions.create({
|
|
31
|
+
model: { provider: "openai", name: "gpt-4.1-mini", apiKey: process.env.OPENAI_API_KEY },
|
|
32
|
+
agentloop: pi(),
|
|
33
|
+
tools: [lookupOrder()],
|
|
34
|
+
}).then(async session => {
|
|
35
|
+
const after = session.state.lastSequence;
|
|
36
|
+
await session.send("Look up order A-1001. Has it shipped?");
|
|
37
|
+
for await (const event of session.events(after)) {
|
|
38
|
+
if (event.type === "turn_failed") throw new Error(JSON.stringify(event.data));
|
|
42
39
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
40
|
+
console.log(JSON.stringify(await session.transcript(), null, 2));
|
|
41
|
+
console.log("Session:", session.id);
|
|
42
|
+
}).catch(error => {
|
|
43
|
+
console.error(error);
|
|
44
|
+
process.exitCode = 1;
|
|
45
|
+
});
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
The transcript includes an order lookup and the agent's answer. The lookup function runs in your
|
|
@@ -60,13 +60,16 @@ The SDK uses Brain's session API and extension helpers. You can import `tool`, `
|
|
|
60
60
|
- [Managed environments](https://github.com/aexhq/aex/blob/main/docs/environments.md): hosted tools and workspaces.
|
|
61
61
|
- [Attachments](https://github.com/aexhq/aex/blob/main/docs/attachments.md): upload images and PDFs.
|
|
62
62
|
|
|
63
|
-
Use `ctx.finish(value)` to complete a tool.
|
|
64
|
-
|
|
63
|
+
Use `ctx.finish(value)` to complete a tool. The shared tool connection suspends after five
|
|
64
|
+
idle seconds and reconnects before the same live client starts more work. Configure
|
|
65
|
+
`connectionIdleTimeoutMs` on `new Aex(...)`; use `0` when other callers or future autonomous
|
|
66
|
+
events must reach these tools. History reads do not reconnect, and event subscriptions remain
|
|
67
|
+
caller-owned. Explicit `aex.close()` permanently disposes of the client while keeping stored sessions.
|
|
65
68
|
|
|
66
69
|
## Structured output
|
|
67
70
|
|
|
68
|
-
Ask for a typed application answer on one send.
|
|
69
|
-
|
|
71
|
+
Ask for a typed application answer on one send. Inside the callback, pass a Zod schema
|
|
72
|
+
alongside the message:
|
|
70
73
|
|
|
71
74
|
```ts
|
|
72
75
|
const answer = await session.send("Return the order status", {
|
|
@@ -119,7 +122,7 @@ correction. It supports JSON Schema, not arbitrary local Zod refinements or tran
|
|
|
119
122
|
Brain SDK 0.34 removes typed sends and the corresponding types and errors. Aex SDK 0.84
|
|
120
123
|
owns them. Existing Aex `send(..., { output })` calls keep the same syntax and behavior.
|
|
121
124
|
Import `StructuredSendOptions` and `StructuredOutputError` from `@aexhq/sdk`.
|
|
122
|
-
Use Pi
|
|
125
|
+
Use Pi 7.3.0, Codex 7.2.5 and extension packages pinned to Brain 0.36.0 with this SDK.
|
|
123
126
|
Mixing exact Brain dependency versions creates different TypeScript extension brands.
|
|
124
127
|
|
|
125
128
|
An existing standalone Brain handle can use Aex's policy without changing servers:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aexhq/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.86.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.36.0",
|
|
32
32
|
"zod": "4.4.3",
|
|
33
|
-
"@aexhq/env-http": "0.3.
|
|
33
|
+
"@aexhq/env-http": "0.3.1"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"gen": "node ../../tools/sdk-contracts.mjs",
|