@aexhq/sdk 0.73.0 → 0.75.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
@@ -10,11 +10,24 @@ 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. SDK 0.73 uses Brain SDK 0.22 and Pi/Codex/Tools
14
- 5.1. Brain 0.22 retains the existing Wasm interface. Components and session configurations are
15
- not migrated automatically. See https://aex.dev/docs
13
+ extension builders are Brain's implementations. SDK 0.75 uses Brain SDK 0.24 and Pi/Codex/Tools
14
+ 6.1. Images and PDFs use HTTPS URLs; Aex owns attachment publication and expiry. Deploy the matching
15
+ runtime and extensions together. Retained sessions require a compatibility check before upgrading.
16
+ See https://aex.dev/docs
16
17
  for a complete session example.
17
18
 
19
+ Put client use, including session creation, inside `try/finally` and `await aex.close()` in
20
+ `finally`. The client retains one shared host connection until close, even if creation fails.
21
+ Close releases client I/O and local handlers while retaining stored sessions. Use
22
+ `session.interrupt()` to stop the current turn, `session.end()` to finish the conversation,
23
+ and `session.delete()` to remove an ended or failed session. `interrupt()` replaces SDK
24
+ `cancel()`; the HTTP route is unchanged. See the [session example](../../examples/session.mjs).
25
+
26
+ Tool schemas describe accepted inputs. Defaulted arguments are optional; Zod applies defaults
27
+ and transforms before the handler. Ordinary objects strip extra properties and strict objects
28
+ reject them. Pi dispatches in parallel; coordinate shared resources in their owning Tool or
29
+ Environment. The official loops explain unanswered calls after interruption without replaying them.
30
+
18
31
  Host Tools return ordinary successful output or a Brain `Outcome` directly. Structured errors retain
19
32
  code, message, retryable and details. The top-level statuses `ok`, `error`, `timeout`, `cancelled`
20
33
  and `unknown` declare outcomes; malformed envelopes fail validation, and only successful values
@@ -43,7 +56,8 @@ not grant authority to create more credentials. New key secrets are returned onc
43
56
  Pass `output: { type: z.object({ name: z.string() }), maxRetries: 2 }` in the second
44
57
  argument to `session.send`. The SDK prompts for JSON, validates with Zod locally,
45
58
  and returns the inferred parsed value. Two additional correction turns are allowed
46
- by default; set zero to disable retries. Ordinary sends keep returning session state.
59
+ by default; set zero to disable retries. Ordinary sends keep returning session state;
60
+ `idle` alone does not mean the turn succeeded. No terminal Tool is needed for structured output.
47
61
 
48
62
  See the [executable example](https://github.com/aexhq/aex/blob/main/examples/structured-output.mjs)
49
63
  and [full contract](https://aex.dev/brain/docs/guides/structured-output).
@@ -73,3 +87,5 @@ await account.account.logout();
73
87
  `Aex.exchangeLogin({code, code_verifier, redirect_uri})` expose the shared HTTP login
74
88
  contract for clients. The `@aexhq/cli` package handles opening the browser, PKCE,
75
89
  loopback callback and local credential storage.
90
+
91
+ Image and PDF uploads use the [attachment API](../../docs/attachments.md). `models(provider?)` exposes only the configured hosted model choices, with models.dev metadata when known.
@@ -1,3 +1,4 @@
1
+ import type { Media } from "@aexhq/brain";
1
2
  /**
2
3
  * This interface was referenced by `AexContracts`'s JSON-Schema
3
4
  * via the `definition` "Billing".
@@ -5,6 +6,15 @@
5
6
  export type Billing = "preview_customer_model_keys";
6
7
  export interface AexContracts {
7
8
  }
9
+ /**
10
+ * This interface was referenced by `AexContracts`'s JSON-Schema
11
+ * via the `definition` "Attachment".
12
+ */
13
+ export interface Attachment {
14
+ expires_at: number;
15
+ id: string;
16
+ media: Media;
17
+ }
8
18
  /**
9
19
  * This interface was referenced by `AexContracts`'s JSON-Schema
10
20
  * via the `definition` "Limits".
@@ -36,6 +46,8 @@ export interface Limits {
36
46
  */
37
47
  export interface Usage {
38
48
  active_turns: number;
49
+ attachment_bytes: number;
50
+ attachments: number;
39
51
  measured_at?: number | null;
40
52
  retained_bytes: number;
41
53
  sessions: number;
package/dist/generated.js CHANGED
@@ -1,2 +1 @@
1
- /* Generated from aex-server schemas. */
2
1
  export {};
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
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, LoginGrantInput, LoginGrant, LoginExchange, AccountSession } from "./generated.js";
4
+ import type { Attachment, Account, Usage, ApiKey, IssuedKey, KeyInput, LoginGrantInput, LoginGrant, LoginExchange, AccountSession } from "./generated.js";
5
5
  export type AexConnection = Omit<BrainOptions, "token" | "baseUrl"> & {
6
6
  baseUrl?: string;
7
7
  };
@@ -15,6 +15,15 @@ export type AexOptions = AexConnection & ({
15
15
  export declare class Aex extends Brain {
16
16
  constructor({ apiKey, accountToken, ...options }: AexOptions);
17
17
  static exchangeLogin(input: LoginExchange, options?: AexConnection): Promise<AccountSession>;
18
+ readonly attachments: {
19
+ upload: (sessionId: string, bytes: Uint8Array, options: {
20
+ contentType: string;
21
+ expiresAt?: number;
22
+ idempotencyKey: string;
23
+ signal?: AbortSignal;
24
+ }) => Promise<Attachment>;
25
+ delete: (sessionId: string, id: string) => Promise<void>;
26
+ };
18
27
  readonly account: {
19
28
  get: () => Promise<Account>;
20
29
  usage: () => Promise<Usage>;
package/dist/index.js CHANGED
@@ -9,6 +9,14 @@ export class Aex extends Brain {
9
9
  static exchangeLogin(input, options = {}) {
10
10
  return new Brain({ baseUrl: "https://api.aex.dev", ...options }).request("POST", "/v1/auth/exchange", input);
11
11
  }
12
+ attachments = {
13
+ upload: (sessionId, bytes, options) => {
14
+ if (options.expiresAt !== undefined && (!Number.isSafeInteger(options.expiresAt) || options.expiresAt <= 0))
15
+ throw new TypeError("expiresAt must be positive Unix seconds");
16
+ return this.request("POST", `/v1/sessions/${encodeURIComponent(sessionId)}/attachments`, bytes, options.idempotencyKey, options.contentType, options.signal, options.expiresAt === undefined ? undefined : { "x-aex-expires-at": String(options.expiresAt) });
17
+ },
18
+ delete: (sessionId, id) => this.request("DELETE", `/v1/sessions/${encodeURIComponent(sessionId)}/attachments/${encodeURIComponent(id)}`),
19
+ };
12
20
  account = {
13
21
  get: () => this.request("GET", "/v1/account"),
14
22
  usage: () => this.request("GET", "/v1/usage"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aexhq/sdk",
3
- "version": "0.73.0",
3
+ "version": "0.75.0",
4
4
  "description": "Aex accounts and hosted sessions using the Brain SDK",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -28,7 +28,7 @@
28
28
  "tag": "next"
29
29
  },
30
30
  "dependencies": {
31
- "@aexhq/brain": "0.22.0"
31
+ "@aexhq/brain": "0.24.0"
32
32
  },
33
33
  "scripts": {
34
34
  "gen": "node ../../tools/sdk-contracts.mjs",