@aexhq/sdk 0.40.6 → 0.40.8

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.
Files changed (53) hide show
  1. package/README.md +159 -159
  2. package/dist/_contracts/asset-upload-helper.d.ts +38 -0
  3. package/dist/_contracts/asset-upload-helper.js +111 -0
  4. package/dist/_contracts/internal.d.ts +5 -9
  5. package/dist/_contracts/internal.js +5 -79
  6. package/dist/_contracts/operations.d.ts +9 -2
  7. package/dist/_contracts/operations.js +141 -16
  8. package/dist/_contracts/retry-core.d.ts +27 -0
  9. package/dist/_contracts/retry-core.js +75 -0
  10. package/dist/_contracts/runtime-types.d.ts +6 -0
  11. package/dist/_contracts/stable.d.ts +10 -5
  12. package/dist/_contracts/stable.js +10 -5
  13. package/dist/asset-upload.d.ts +2 -1
  14. package/dist/asset-upload.js +28 -61
  15. package/dist/asset-upload.js.map +1 -1
  16. package/dist/cli.mjs +297 -80
  17. package/dist/cli.mjs.sha256 +1 -1
  18. package/dist/client.d.ts +5 -0
  19. package/dist/client.js +8 -13
  20. package/dist/client.js.map +1 -1
  21. package/dist/retry.js +13 -41
  22. package/dist/retry.js.map +1 -1
  23. package/dist/version.d.ts +1 -1
  24. package/dist/version.js +1 -1
  25. package/docs/authentication.md +125 -125
  26. package/docs/billing.md +118 -118
  27. package/docs/concepts/agent-tools.md +66 -66
  28. package/docs/concepts/composition.md +37 -37
  29. package/docs/concepts/providers-and-runtimes.md +54 -54
  30. package/docs/concepts/runs.md +49 -49
  31. package/docs/concepts/subagents.md +88 -88
  32. package/docs/credentials.md +125 -125
  33. package/docs/defaults.md +64 -64
  34. package/docs/errors.md +196 -196
  35. package/docs/events.md +243 -243
  36. package/docs/limits-and-quotas.md +144 -144
  37. package/docs/limits.md +50 -50
  38. package/docs/mcp.md +44 -44
  39. package/docs/networking.md +163 -163
  40. package/docs/outputs.md +267 -267
  41. package/docs/public-surface.json +77 -77
  42. package/docs/quickstart.md +119 -119
  43. package/docs/release.md +38 -38
  44. package/docs/retries.md +129 -129
  45. package/docs/run-config.md +58 -58
  46. package/docs/run-record.md +55 -55
  47. package/docs/secrets.md +125 -125
  48. package/docs/testing.md +35 -35
  49. package/docs/vision-skills.md +91 -91
  50. package/docs/webhooks.md +127 -127
  51. package/examples/feature-tour.ts +282 -282
  52. package/examples/spike-settle-latency.ts +125 -125
  53. package/package.json +1 -1
@@ -1,125 +1,125 @@
1
- ---
2
- title: Credentials
3
- ---
4
-
5
- # Credentials
6
-
7
- aex uses explicit, per-session credentials:
8
-
9
- - `AEX_API_KEY` authenticates the SDK or CLI to aex.
10
- - `apiKeys` carries BYOK provider keys for the model provider.
11
- - `McpServer.remote(..., { headers })` carries MCP auth when a remote MCP server needs it.
12
- - `environment.secrets` carries runtime secrets for your own code.
13
-
14
- Secrets never belong in reusable run config, files, prompts, or examples.
15
-
16
- ## The client credential
17
-
18
- Pass your aex API key directly to the constructor — `new Aex(apiKey)` — or as
19
- the `apiKey` option:
20
-
21
- ```ts
22
- import { Aex } from "@aexhq/sdk";
23
-
24
- const aex = new Aex(process.env.AEX_API_KEY!); // preferred shorthand
25
- // equivalently:
26
- // const aex = new Aex({ apiKey: process.env.AEX_API_KEY! });
27
- ```
28
-
29
- See [Authentication](authentication.md) for how keys are scoped, rotated, and
30
- issued during the beta.
31
-
32
- ## Provider keys
33
-
34
- A session selects one upstream provider and must carry a BYOK key for it. Include
35
- additional provider keys only when subagents may use those providers.
36
-
37
- ```ts
38
- const result = await aex.run({
39
- model: Models.CLAUDE_HAIKU_4_5,
40
- message: "Write a short report and save it as a file.",
41
- apiKeys: {
42
- anthropic: process.env.ANTHROPIC_API_KEY!
43
- }
44
- });
45
- ```
46
-
47
- Provider keys are used by the managed runtime for model calls. They are not saved
48
- as client defaults.
49
-
50
- ## Runtime secrets
51
-
52
- Use `environment.secrets` for credentials your code needs at runtime. The value
53
- can be ephemeral with `Secret.value(...)` or a workspace secret reference with
54
- `Secret.ref(...)`.
55
-
56
- ```ts
57
- import { Aex, Models, Secret } from "@aexhq/sdk";
58
-
59
- const aex = new Aex({ apiKey: process.env.AEX_API_KEY! });
60
-
61
- await aex.run({
62
- model: Models.CLAUDE_HAIKU_4_5,
63
- message: "Call https://api.example.com/v1/status with INTERNAL_API_TOKEN and summarize it.",
64
- environment: {
65
- secrets: {
66
- INTERNAL_API_TOKEN: Secret.value(process.env.INTERNAL_API_TOKEN!)
67
- },
68
- networking: {
69
- mode: "limited",
70
- allowedHosts: ["api.example.com"]
71
- }
72
- },
73
- apiKeys: { anthropic: process.env.ANTHROPIC_API_KEY! }
74
- });
75
- ```
76
-
77
- Inside the run, use normal HTTP code for the service:
78
-
79
- ```bash
80
- curl -sS \
81
- -H "Authorization: Bearer $INTERNAL_API_TOKEN" \
82
- https://api.example.com/v1/status
83
- ```
84
-
85
- ## Workspace secrets
86
-
87
- > **Availability note:** workspace-secret `Secret.ref(...)` injection requires
88
- > the next platform deploy — on the current hosted plane the referenced
89
- > variable can resolve empty inside the run. Per-run `Secret.value(...)`
90
- > secrets are unaffected.
91
-
92
- Store reusable values once, then reference them by name:
93
-
94
- ```ts
95
- await aex.secrets.set({
96
- name: "internal-api-token",
97
- value: process.env.INTERNAL_API_TOKEN!
98
- });
99
-
100
- await aex.run({
101
- model: Models.CLAUDE_HAIKU_4_5,
102
- message: "Use INTERNAL_API_TOKEN for the status request.",
103
- environment: {
104
- secrets: {
105
- INTERNAL_API_TOKEN: Secret.ref("internal-api-token")
106
- }
107
- },
108
- apiKeys: { anthropic: process.env.ANTHROPIC_API_KEY! }
109
- });
110
- ```
111
-
112
- Secret reads return metadata only; they never return the stored value.
113
-
114
- ## Networking
115
-
116
- Networking is open by default within the platform's managed egress ceiling. Use
117
- `environment.networking.mode: "limited"` with `allowedHosts` when you want a
118
- run's own code to reach only named hosts. See [Networking](networking.md) for
119
- the two-layer enforcement model.
120
-
121
- ## Explicit call-site rule
122
-
123
- There is no `defaultSecrets` and no client-held secret state. Each
124
- `openSession(...)` or `run(...)` call should show the provider keys, MCP auth, and
125
- runtime secrets needed for that call.
1
+ ---
2
+ title: Credentials
3
+ ---
4
+
5
+ # Credentials
6
+
7
+ aex uses explicit, per-session credentials:
8
+
9
+ - `AEX_API_KEY` authenticates the SDK or CLI to aex.
10
+ - `apiKeys` carries BYOK provider keys for the model provider.
11
+ - `McpServer.remote(..., { headers })` carries MCP auth when a remote MCP server needs it.
12
+ - `environment.secrets` carries runtime secrets for your own code.
13
+
14
+ Secrets never belong in reusable run config, files, prompts, or examples.
15
+
16
+ ## The client credential
17
+
18
+ Pass your aex API key directly to the constructor — `new Aex(apiKey)` — or as
19
+ the `apiKey` option:
20
+
21
+ ```ts
22
+ import { Aex } from "@aexhq/sdk";
23
+
24
+ const aex = new Aex(process.env.AEX_API_KEY!); // preferred shorthand
25
+ // equivalently:
26
+ // const aex = new Aex({ apiKey: process.env.AEX_API_KEY! });
27
+ ```
28
+
29
+ See [Authentication](authentication.md) for how keys are scoped, rotated, and
30
+ issued during the beta.
31
+
32
+ ## Provider keys
33
+
34
+ A session selects one upstream provider and must carry a BYOK key for it. Include
35
+ additional provider keys only when subagents may use those providers.
36
+
37
+ ```ts
38
+ const result = await aex.run({
39
+ model: Models.CLAUDE_HAIKU_4_5,
40
+ message: "Write a short report and save it as a file.",
41
+ apiKeys: {
42
+ anthropic: process.env.ANTHROPIC_API_KEY!
43
+ }
44
+ });
45
+ ```
46
+
47
+ Provider keys are used by the managed runtime for model calls. They are not saved
48
+ as client defaults.
49
+
50
+ ## Runtime secrets
51
+
52
+ Use `environment.secrets` for credentials your code needs at runtime. The value
53
+ can be ephemeral with `Secret.value(...)` or a workspace secret reference with
54
+ `Secret.ref(...)`.
55
+
56
+ ```ts
57
+ import { Aex, Models, Secret } from "@aexhq/sdk";
58
+
59
+ const aex = new Aex({ apiKey: process.env.AEX_API_KEY! });
60
+
61
+ await aex.run({
62
+ model: Models.CLAUDE_HAIKU_4_5,
63
+ message: "Call https://api.example.com/v1/status with INTERNAL_API_TOKEN and summarize it.",
64
+ environment: {
65
+ secrets: {
66
+ INTERNAL_API_TOKEN: Secret.value(process.env.INTERNAL_API_TOKEN!)
67
+ },
68
+ networking: {
69
+ mode: "limited",
70
+ allowedHosts: ["api.example.com"]
71
+ }
72
+ },
73
+ apiKeys: { anthropic: process.env.ANTHROPIC_API_KEY! }
74
+ });
75
+ ```
76
+
77
+ Inside the run, use normal HTTP code for the service:
78
+
79
+ ```bash
80
+ curl -sS \
81
+ -H "Authorization: Bearer $INTERNAL_API_TOKEN" \
82
+ https://api.example.com/v1/status
83
+ ```
84
+
85
+ ## Workspace secrets
86
+
87
+ > **Availability note:** workspace-secret `Secret.ref(...)` injection requires
88
+ > the next platform deploy — on the current hosted plane the referenced
89
+ > variable can resolve empty inside the run. Per-run `Secret.value(...)`
90
+ > secrets are unaffected.
91
+
92
+ Store reusable values once, then reference them by name:
93
+
94
+ ```ts
95
+ await aex.secrets.set({
96
+ name: "internal-api-token",
97
+ value: process.env.INTERNAL_API_TOKEN!
98
+ });
99
+
100
+ await aex.run({
101
+ model: Models.CLAUDE_HAIKU_4_5,
102
+ message: "Use INTERNAL_API_TOKEN for the status request.",
103
+ environment: {
104
+ secrets: {
105
+ INTERNAL_API_TOKEN: Secret.ref("internal-api-token")
106
+ }
107
+ },
108
+ apiKeys: { anthropic: process.env.ANTHROPIC_API_KEY! }
109
+ });
110
+ ```
111
+
112
+ Secret reads return metadata only; they never return the stored value.
113
+
114
+ ## Networking
115
+
116
+ Networking is open by default within the platform's managed egress ceiling. Use
117
+ `environment.networking.mode: "limited"` with `allowedHosts` when you want a
118
+ run's own code to reach only named hosts. See [Networking](networking.md) for
119
+ the two-layer enforcement model.
120
+
121
+ ## Explicit call-site rule
122
+
123
+ There is no `defaultSecrets` and no client-held secret state. Each
124
+ `openSession(...)` or `run(...)` call should show the provider keys, MCP auth, and
125
+ runtime secrets needed for that call.
package/docs/defaults.md CHANGED
@@ -1,64 +1,64 @@
1
- ---
2
- title: Defaults
3
- ---
4
-
5
- # Defaults
6
-
7
- These are the values aex applies when you **omit** the corresponding option on a
8
- run. Every value is mirrored from a single source-of-truth constant in the
9
- platform's limits module; this page is hand-maintained against those constants.
10
- If a value here ever disagrees with the constant, the constant wins.
11
-
12
- Each value below is named by its source-of-truth constant. The runtime-size
13
- presets are defined in the public
14
- [`packages/contracts/src/runtime-sizes.ts`](https://github.com/aexhq/aex/blob/main/packages/contracts/src/runtime-sizes.ts).
15
- For the hard ceilings and who can raise them, see
16
- [Limits & quotas](limits-and-quotas.md). For policy boundaries, see
17
- [Limits](limits.md).
18
-
19
- ## Run
20
-
21
- | Option | Default | How to override | Source |
22
- | --- | --- | --- | --- |
23
- | `timeout` (run deadline) | 8 hours (also the ceiling) | Per-session via `overrides.timeout` (e.g. `"30m"`, `"2h"`). Values outside the run-timeout floor (1 minute) / ceiling (8 hours) are rejected with `RunConfigValidationError` before submission. | `RUN_DEFAULT_TIMEOUT_MS` |
24
- | `runtime` (machine size) | `shared-0.25x-1gb` — 0.25 vCPU, 1 GB | Per-session via `runtime` (use `Sizes.*` in TypeScript). | `RUN_DEFAULT_RUNTIME_SIZE` |
25
- | `overrides.maxSpendUsd` (per-session spend cap) | None — no spend cap (the session is still bounded by its `timeout` and any workspace-level cap) | Per-session via `overrides.maxSpendUsd` (a positive USD amount); the session is stopped once its spend would exceed the cap. | — |
26
- | `overrides.maxTurns` (agent iterations per run) | 20 (ceiling 200) | Per-session via `overrides.maxTurns` (a positive integer, clamped to the ceiling). | `RUN_DEFAULT_MAX_TURNS` |
27
-
28
- ## Tools
29
-
30
- | Option | Default | How to override | Source |
31
- | --- | --- | --- | --- |
32
- | Per-call exec timeout | 30 minutes | Per-call via the tool call's `timeoutMs`. | `RUN_DEFAULT_EXEC_TIMEOUT_MS` |
33
- | `web_fetch` returned body | 500 KB (UTF-8) | Per-call via the tool's `max_bytes` argument. | `REQUEST_WEB_FETCH_DEFAULT_MAX_BYTES` |
34
-
35
- ## MCP
36
-
37
- | Option | Default | How to override | Source |
38
- | --- | --- | --- | --- |
39
- | MCP connect timeout (register + initialize + discover) | 30 seconds | Per-port via `connectTimeoutMs`. | `RUN_DEFAULT_MCP_CONNECT_TIMEOUT_MS` |
40
- | MCP `tools/call` timeout | 30 minutes | Per-port via `callTimeoutMs`. | `RUN_DEFAULT_MCP_CALL_TIMEOUT_MS` |
41
-
42
- ## Links (signed URLs and tickets)
43
-
44
- | Option | Default | How to override | Source |
45
- | --- | --- | --- | --- |
46
- | Output link / signed-URL TTL | 300 seconds (5 minutes) at the storage layer; `session.outputs().link(...)` defaults to `"1h"` | Per-call via `expiresSeconds` (storage) or `expiresIn` on `session.outputs().link` / `session.outputs().fetch`. | `REQUEST_PRESIGN_URL_DEFAULT_TTL_SECONDS` |
47
- | Event-stream connection ticket TTL | 60 seconds | Per-mint via the `ttlMs` argument. | `REQUEST_TICKET_DEFAULT_TTL_MS` |
48
-
49
- ## Subagents
50
-
51
- | Option | Default | How to override | Source |
52
- | --- | --- | --- | --- |
53
- | Concurrent child runs per lineage root | 1000 (live, non-terminal child runs) | Platform default (subagents run in-process; no public per-run override). Hard ceiling 4096. | `RUN_DEFAULT_MAX_CONCURRENT_CHILD_RUNS` |
54
- | Max subagent depth | 5 | Platform default (subagents run in-process; no public per-run override). | `RUN_MAX_PUBLIC_SUBAGENT_DEPTH` |
55
-
56
- ## Workspace
57
-
58
- | Option | Default | How to override | Source |
59
- | --- | --- | --- | --- |
60
- | Run submit rate (per minute) | 120 (`0` = disabled); past it `POST /runs` fails with `429 workspace_submit_rate_exceeded` | Per-plane via env `AEX_WORKSPACE_SUBMIT_RATE_PER_MIN`; per-workspace via support. | — |
61
- | Max concurrent runs | Plan-based: 5 live root runs (free), 50 (Pro), 200 (Team); hard ceiling 200 | Per-plan (upgrade) or per-workspace override via support, clamped to the ceiling. | `PLANS[planKey].maxConcurrentRuns` |
62
- | Monthly spend cap | $250 per UTC calendar month (`0` = unlimited) | Per-workspace override via support. | `WORKSPACE_DEFAULT_SPEND_CAP_USD` |
63
- | Per-workspace mutation rate limits (per minute) | run cancel 30, run delete 30, signed link 120, API key create 10, API key delete 30 | Per-plane via the matching `AEX_RATE_LIMIT_<ACTION>_PER_MINUTE` env var. | `WORKSPACE_RATE_LIMIT_DEFAULTS` |
64
- | Workspace storage cap | 500 GB (decimal) | Per-plane via env `AEX_WORKSPACE_STORAGE_CAP_BYTES`; admin workspaces are uncapped (not a customer entitlement). | `WORKSPACE_DEFAULT_STORAGE_CAP_BYTES` |
1
+ ---
2
+ title: Defaults
3
+ ---
4
+
5
+ # Defaults
6
+
7
+ These are the values aex applies when you **omit** the corresponding option on a
8
+ run. Every value is mirrored from a single source-of-truth constant in the
9
+ platform's limits module; this page is hand-maintained against those constants.
10
+ If a value here ever disagrees with the constant, the constant wins.
11
+
12
+ Each value below is named by its source-of-truth constant. The runtime-size
13
+ presets are defined in the public
14
+ [`packages/contracts/src/runtime-sizes.ts`](https://github.com/aexhq/aex/blob/main/packages/contracts/src/runtime-sizes.ts).
15
+ For the hard ceilings and who can raise them, see
16
+ [Limits & quotas](limits-and-quotas.md). For policy boundaries, see
17
+ [Limits](limits.md).
18
+
19
+ ## Run
20
+
21
+ | Option | Default | How to override | Source |
22
+ | --- | --- | --- | --- |
23
+ | `timeout` (run deadline) | 8 hours (also the ceiling) | Per-session via `overrides.timeout` (e.g. `"30m"`, `"2h"`). Values outside the run-timeout floor (1 minute) / ceiling (8 hours) are rejected with `RunConfigValidationError` before submission. | `RUN_DEFAULT_TIMEOUT_MS` |
24
+ | `runtime` (machine size) | `shared-0.25x-1gb` — 0.25 vCPU, 1 GB | Per-session via `runtime` (use `Sizes.*` in TypeScript). | `RUN_DEFAULT_RUNTIME_SIZE` |
25
+ | `overrides.maxSpendUsd` (per-session spend cap) | None — no spend cap (the session is still bounded by its `timeout` and any workspace-level cap) | Per-session via `overrides.maxSpendUsd` (a positive USD amount); the session is stopped once its spend would exceed the cap. | — |
26
+ | `overrides.maxTurns` (agent iterations per run) | 20 (ceiling 200) | Per-session via `overrides.maxTurns` (a positive integer, clamped to the ceiling). | `RUN_DEFAULT_MAX_TURNS` |
27
+
28
+ ## Tools
29
+
30
+ | Option | Default | How to override | Source |
31
+ | --- | --- | --- | --- |
32
+ | Per-call exec timeout | 30 minutes | Per-call via the tool call's `timeoutMs`. | `RUN_DEFAULT_EXEC_TIMEOUT_MS` |
33
+ | `web_fetch` returned body | 500 KB (UTF-8) | Per-call via the tool's `max_bytes` argument. | `REQUEST_WEB_FETCH_DEFAULT_MAX_BYTES` |
34
+
35
+ ## MCP
36
+
37
+ | Option | Default | How to override | Source |
38
+ | --- | --- | --- | --- |
39
+ | MCP connect timeout (register + initialize + discover) | 30 seconds | Per-port via `connectTimeoutMs`. | `RUN_DEFAULT_MCP_CONNECT_TIMEOUT_MS` |
40
+ | MCP `tools/call` timeout | 30 minutes | Per-port via `callTimeoutMs`. | `RUN_DEFAULT_MCP_CALL_TIMEOUT_MS` |
41
+
42
+ ## Links (signed URLs and tickets)
43
+
44
+ | Option | Default | How to override | Source |
45
+ | --- | --- | --- | --- |
46
+ | Output link / signed-URL TTL | 300 seconds (5 minutes) at the storage layer; `session.outputs().link(...)` defaults to `"1h"` | Per-call via `expiresSeconds` (storage) or `expiresIn` on `session.outputs().link` / `session.outputs().fetch`. | `REQUEST_PRESIGN_URL_DEFAULT_TTL_SECONDS` |
47
+ | Event-stream connection ticket TTL | 60 seconds | Per-mint via the `ttlMs` argument. | `REQUEST_TICKET_DEFAULT_TTL_MS` |
48
+
49
+ ## Subagents
50
+
51
+ | Option | Default | How to override | Source |
52
+ | --- | --- | --- | --- |
53
+ | Concurrent child runs per lineage root | 1000 (live, non-terminal child runs) | Platform default (subagents run in-process; no public per-run override). Hard ceiling 4096. | `RUN_DEFAULT_MAX_CONCURRENT_CHILD_RUNS` |
54
+ | Max subagent depth | 5 | Platform default (subagents run in-process; no public per-run override). | `RUN_MAX_PUBLIC_SUBAGENT_DEPTH` |
55
+
56
+ ## Workspace
57
+
58
+ | Option | Default | How to override | Source |
59
+ | --- | --- | --- | --- |
60
+ | Run submit rate (per minute) | 120 (`0` = disabled); past it `POST /runs` fails with `429 workspace_submit_rate_exceeded` | Per-plane via env `AEX_WORKSPACE_SUBMIT_RATE_PER_MIN`; per-workspace via support. | — |
61
+ | Max concurrent runs | Plan-based: 5 live root runs (free), 50 (Pro), 200 (Team); hard ceiling 200 | Per-plan (upgrade) or per-workspace override via support, clamped to the ceiling. | `PLANS[planKey].maxConcurrentRuns` |
62
+ | Monthly spend cap | $250 per UTC calendar month (`0` = unlimited) | Per-workspace override via support. | `WORKSPACE_DEFAULT_SPEND_CAP_USD` |
63
+ | Per-workspace mutation rate limits (per minute) | run cancel 30, run delete 30, signed link 120, API key create 10, API key delete 30 | Per-plane via the matching `AEX_RATE_LIMIT_<ACTION>_PER_MINUTE` env var. | `WORKSPACE_RATE_LIMIT_DEFAULTS` |
64
+ | Workspace storage cap | 500 GB (decimal) | Per-plane via env `AEX_WORKSPACE_STORAGE_CAP_BYTES`; admin workspaces are uncapped (not a customer entitlement). | `WORKSPACE_DEFAULT_STORAGE_CAP_BYTES` |