@aexhq/sdk 0.40.16 → 0.41.1

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 (130) hide show
  1. package/README.md +25 -25
  2. package/dist/_contracts/api-key.d.ts +6 -4
  3. package/dist/_contracts/api-key.js +20 -7
  4. package/dist/_contracts/connection-ticket.d.ts +5 -5
  5. package/dist/_contracts/connection-ticket.js +7 -7
  6. package/dist/_contracts/error-codes.d.ts +1 -1
  7. package/dist/_contracts/error-codes.js +4 -4
  8. package/dist/_contracts/error-factory.js +1 -1
  9. package/dist/_contracts/event-envelope.d.ts +41 -41
  10. package/dist/_contracts/event-envelope.js +49 -49
  11. package/dist/_contracts/event-stream-client.d.ts +9 -9
  12. package/dist/_contracts/event-stream-client.js +5 -5
  13. package/dist/_contracts/event-view.d.ts +6 -6
  14. package/dist/_contracts/event-view.js +12 -12
  15. package/dist/_contracts/http.js +1 -1
  16. package/dist/_contracts/index.d.ts +10 -10
  17. package/dist/_contracts/index.js +9 -9
  18. package/dist/_contracts/models.d.ts +17 -17
  19. package/dist/_contracts/models.js +14 -14
  20. package/dist/_contracts/operations.d.ts +79 -82
  21. package/dist/_contracts/operations.js +233 -243
  22. package/dist/_contracts/provider-support.d.ts +2 -2
  23. package/dist/_contracts/runner-event.d.ts +8 -8
  24. package/dist/_contracts/runner-event.js +9 -9
  25. package/dist/_contracts/runtime-manifest.d.ts +12 -12
  26. package/dist/_contracts/runtime-manifest.js +1 -1
  27. package/dist/_contracts/runtime-sizes.d.ts +12 -12
  28. package/dist/_contracts/runtime-sizes.js +18 -18
  29. package/dist/_contracts/runtime-types.d.ts +117 -117
  30. package/dist/_contracts/runtime-types.js +2 -2
  31. package/dist/_contracts/sdk-errors.d.ts +3 -3
  32. package/dist/_contracts/sdk-errors.js +4 -4
  33. package/dist/_contracts/sdk-secrets.js +10 -10
  34. package/dist/_contracts/session-artifacts.d.ts +151 -0
  35. package/dist/_contracts/session-artifacts.js +234 -0
  36. package/dist/_contracts/{run-config.d.ts → session-config.d.ts} +29 -29
  37. package/dist/_contracts/{run-config.js → session-config.js} +37 -37
  38. package/dist/_contracts/session-cost.d.ts +140 -0
  39. package/dist/_contracts/{run-cost.js → session-cost.js} +94 -94
  40. package/dist/_contracts/{run-custody.d.ts → session-custody.d.ts} +16 -16
  41. package/dist/_contracts/{run-custody.js → session-custody.js} +42 -42
  42. package/dist/_contracts/session-record.d.ts +112 -0
  43. package/dist/_contracts/{run-record.js → session-record.js} +23 -23
  44. package/dist/_contracts/session-retention.d.ts +209 -0
  45. package/dist/_contracts/{run-retention.js → session-retention.js} +116 -116
  46. package/dist/_contracts/{run-unit.d.ts → session-unit.d.ts} +38 -38
  47. package/dist/_contracts/{run-unit.js → session-unit.js} +33 -33
  48. package/dist/_contracts/side-effect-audit.d.ts +14 -14
  49. package/dist/_contracts/side-effect-audit.js +38 -38
  50. package/dist/_contracts/sse.d.ts +1 -1
  51. package/dist/_contracts/sse.js +0 -0
  52. package/dist/_contracts/stable.d.ts +1 -1
  53. package/dist/_contracts/stable.js +1 -1
  54. package/dist/_contracts/status.d.ts +18 -18
  55. package/dist/_contracts/status.js +19 -19
  56. package/dist/_contracts/submission.d.ts +101 -99
  57. package/dist/_contracts/submission.js +96 -96
  58. package/dist/_contracts/{run-trace.d.ts → turn-trace.d.ts} +1 -1
  59. package/dist/_contracts/webhook-verify.d.ts +1 -1
  60. package/dist/_contracts/webhook-verify.js +1 -1
  61. package/dist/agents-md.d.ts +4 -4
  62. package/dist/agents-md.js +5 -5
  63. package/dist/agents-md.js.map +1 -1
  64. package/dist/bundle.d.ts +1 -1
  65. package/dist/bundle.js +1 -1
  66. package/dist/bundle.js.map +1 -1
  67. package/dist/cli.mjs +578 -621
  68. package/dist/cli.mjs.sha256 +1 -1
  69. package/dist/client.d.ts +141 -155
  70. package/dist/client.js +236 -245
  71. package/dist/client.js.map +1 -1
  72. package/dist/fetch-archive.js +3 -3
  73. package/dist/file.d.ts +7 -7
  74. package/dist/file.js +8 -8
  75. package/dist/file.js.map +1 -1
  76. package/dist/index.d.ts +10 -10
  77. package/dist/index.js +8 -8
  78. package/dist/index.js.map +1 -1
  79. package/dist/mcp-server.d.ts +1 -1
  80. package/dist/retry.d.ts +1 -1
  81. package/dist/secret.d.ts +6 -6
  82. package/dist/secret.js +6 -6
  83. package/dist/secret.js.map +1 -1
  84. package/dist/skill.d.ts +2 -2
  85. package/dist/skill.js +3 -3
  86. package/dist/skill.js.map +1 -1
  87. package/dist/tool.js +2 -2
  88. package/dist/tool.js.map +1 -1
  89. package/dist/version.d.ts +1 -1
  90. package/dist/version.js +1 -1
  91. package/dist/version.js.map +1 -1
  92. package/docs/authentication.md +11 -11
  93. package/docs/billing.md +3 -3
  94. package/docs/cleanup.md +5 -5
  95. package/docs/concepts/agent-tools.md +5 -5
  96. package/docs/concepts/composition.md +3 -3
  97. package/docs/concepts/providers-and-runtimes.md +3 -3
  98. package/docs/concepts/{runs.md → sessions.md} +8 -8
  99. package/docs/concepts/subagents.md +16 -16
  100. package/docs/credentials.md +7 -7
  101. package/docs/defaults.md +14 -14
  102. package/docs/errors.md +10 -10
  103. package/docs/events.md +26 -26
  104. package/docs/files.md +267 -0
  105. package/docs/limits-and-quotas.md +35 -35
  106. package/docs/limits.md +6 -6
  107. package/docs/mcp.md +3 -3
  108. package/docs/networking.md +24 -24
  109. package/docs/provider-runtime-capabilities.md +1 -1
  110. package/docs/public-surface.json +6 -6
  111. package/docs/quickstart.md +13 -13
  112. package/docs/release.md +5 -5
  113. package/docs/retries.md +3 -3
  114. package/docs/secrets.md +16 -16
  115. package/docs/session-config.md +58 -0
  116. package/docs/{run-record.md → session-record.md} +16 -16
  117. package/docs/skills.md +9 -9
  118. package/docs/vision-skills.md +7 -7
  119. package/docs/webhooks.md +11 -11
  120. package/examples/feature-tour.ts +17 -17
  121. package/examples/spike-settle-latency.ts +11 -11
  122. package/package.json +1 -1
  123. package/dist/_contracts/run-artifacts.d.ts +0 -49
  124. package/dist/_contracts/run-artifacts.js +0 -102
  125. package/dist/_contracts/run-cost.d.ts +0 -140
  126. package/dist/_contracts/run-record.d.ts +0 -116
  127. package/dist/_contracts/run-retention.d.ts +0 -209
  128. package/docs/outputs.md +0 -267
  129. package/docs/run-config.md +0 -58
  130. /package/dist/_contracts/{run-trace.js → turn-trace.js} +0 -0
@@ -2,7 +2,7 @@
2
2
  "brand": "aex",
3
3
  "productName": "Agent Executor",
4
4
  "oneLine": "aex is an agent execution platform for launching autonomous agents from a simple TypeScript SDK and CLI.",
5
- "description": "Open durable agent sessions, send turns, stream events, capture outputs, and compose agents with skills, files, MCP, secrets, networking controls, and subagents across the managed runtime.",
5
+ "description": "Open durable agent sessions, send turns, stream events, capture files, and compose agents with skills, files, MCP, secrets, networking controls, and subagents across the managed runtime.",
6
6
  "alpha": {
7
7
  "label": "Alpha testing",
8
8
  "description": "Access is limited to invited testers while we harden the hosted runtime, dashboard, and SDK workflows."
@@ -26,7 +26,7 @@
26
26
  "console.log(result.status, result.text);"
27
27
  ],
28
28
  "cliLines": [
29
- "aex run \\",
29
+ "aex start \\",
30
30
  " --api-key \"$AEX_API_KEY\" \\",
31
31
  " --anthropic-api-key \"$ANTHROPIC_API_KEY\" \\",
32
32
  " --model claude-haiku-4-5 \\",
@@ -49,13 +49,13 @@
49
49
  "slug": "agent-runtime",
50
50
  "href": "/docs/features/#agent-runtime",
51
51
  "title": "Agent runtime",
52
- "description": "Managed autonomous runs with filesystem read/edit, grep/glob/head/tail, open web fetch/search, background commands, code execution, git, and subagents."
52
+ "description": "Managed autonomous sessions with filesystem read/edit, grep/glob/head/tail, open web fetch/search, background commands, code execution, git, and subagents."
53
53
  },
54
54
  {
55
55
  "slug": "durable-infrastructure",
56
56
  "href": "/docs/features/#durable-infrastructure",
57
57
  "title": "Durable infrastructure",
58
- "description": "Run records, status, wait/cancel/delete, idempotency, typed events, output capture, downloads, timeouts, and runtime sizes."
58
+ "description": "SessionRecord records, status, wait/cancel/delete, idempotency, typed events, file capture, downloads, timeouts, and runtime sizes."
59
59
  },
60
60
  {
61
61
  "slug": "agent-composition",
@@ -67,7 +67,7 @@
67
67
  "slug": "subagents",
68
68
  "href": "/docs/features/#subagents",
69
69
  "title": "Subagents",
70
- "description": "Typed parent/child lineage for async child runs, output handoff, and bounded agent delegation."
70
+ "description": "Typed parent/child lineage for async child sessions, file handoff, and bounded agent delegation."
71
71
  },
72
72
  {
73
73
  "slug": "models-and-providers",
@@ -79,7 +79,7 @@
79
79
  "slug": "typed-control-surface",
80
80
  "href": "/docs/features/#typed-control-surface",
81
81
  "title": "Typed control surface",
82
- "description": "Strongly typed SDK inputs, CLI parity, BYOK provider keys, workspace secrets, redaction, and output modes."
82
+ "description": "Strongly typed SDK inputs, CLI parity, BYOK provider keys, workspace secrets, redaction, assistant text modes, and file capture policy."
83
83
  }
84
84
  ]
85
85
  }
@@ -16,8 +16,8 @@ This installs the TypeScript SDK exports and the bundled `aex` CLI.
16
16
 
17
17
  aex is currently in **invite-only beta**: workspaces and API keys are issued
18
18
  by the aex team — contact <support@aex.dev> for beta access. Once you have
19
- access, create a quickstart SDK token with `runs:read`, `runs:write`,
20
- `outputs:read`, and `billing:read` in the dashboard at <https://aex.dev>. The
19
+ access, create a quickstart SDK token with `sessions:read`, `sessions:write`,
20
+ `files:read`, and `billing:read` in the dashboard at <https://aex.dev>. The
21
21
  examples also need your BYOK provider key for the model you choose. For the
22
22
  Claude examples below:
23
23
 
@@ -45,11 +45,11 @@ const first = await session.send("Write a short report and save it as a file.").
45
45
  console.log(first.status, first.costUsd, first.text);
46
46
  ```
47
47
 
48
- `send().done()` (and `run()`) **await settle by default**, so the result always
48
+ `send().done()` (and `start()`) **await settle by default**, so the result always
49
49
  carries a terminal `status` (`succeeded` / `failed` / `timed_out` / `cancelled`
50
50
  — never a bare `idle`) plus `costUsd` and `usage`. Pass `await: 'park'` to
51
51
  return early at the render-complete park event when you don't need cost/usage.
52
- `costUsd` is aex runtime/storage spend and **excludes** your BYOK provider
52
+ `costUsd` is aex starttime/storage spend and **excludes** your BYOK provider
53
53
  charges — price those from `usage` token counts against your provider's rates.
54
54
 
55
55
  The session parks as `idle` between turns and automatically moves to
@@ -62,17 +62,17 @@ await resumed.send("Now run the validation command and summarize the result.").d
62
62
 
63
63
  ## 4. One-shot convenience
64
64
 
65
- `run()` opens a session, sends `message` as one turn, and returns the collected
66
- result. Its `runId` is the session id.
65
+ `start()` opens a session, sends `message` as one turn, and returns the collected
66
+ result. Its `sessionId` is the session id.
67
67
 
68
68
  ```ts
69
- const result = await aex.run({
69
+ const result = await aex.start({
70
70
  model: Models.CLAUDE_HAIKU_4_5,
71
71
  apiKeys: { anthropic: process.env.ANTHROPIC_API_KEY! },
72
72
  message: "Write a short report and save it as a file."
73
73
  });
74
74
 
75
- console.log(result.runId, result.status, result.text);
75
+ console.log(result.sessionId, result.status, result.text);
76
76
  ```
77
77
 
78
78
  ## 5. Session control: stream, wait, download
@@ -101,7 +101,7 @@ console.log(messages.at(-1)?.text);
101
101
  const record = await session.wait();
102
102
  console.log(record.status);
103
103
 
104
- // Download the whole session record (metadata, events, outputs) as a zip.
104
+ // Download the whole session record (metadata, events, files) as a zip.
105
105
  await session.download({ to: "./session.zip" });
106
106
  ```
107
107
 
@@ -109,7 +109,7 @@ The same run from the bundled CLI (`npx aex` on a local install; or
109
109
  `npm i -g @aexhq/sdk` for a bare `aex`):
110
110
 
111
111
  ```bash
112
- npx aex run \
112
+ npx aex start \
113
113
  --api-key "$AEX_API_KEY" \
114
114
  --anthropic-api-key "$ANTHROPIC_API_KEY" \
115
115
  --model claude-haiku-4-5 \
@@ -120,7 +120,7 @@ npx aex run \
120
120
  ## Add capabilities
121
121
 
122
122
  - Add files, skills, AGENTS.md, MCP servers, packages, and networking controls with [Composition](concepts/composition.md).
123
- - Delegate bounded sub-tasks to child runs with [Subagents](concepts/subagents.md).
124
- - Get notified when a run finishes with [Webhooks](webhooks.md).
125
- - Narrow output capture or download individual files with [Outputs](outputs.md).
123
+ - Delegate bounded sub-tasks to child sessions with [Subagents](concepts/subagents.md).
124
+ - Get notified when a session finishes with [Webhooks](webhooks.md).
125
+ - Narrow file capture or download individual files with [Files](files.md).
126
126
  - Check supported providers and models in the [provider/runtime capability matrix](provider-runtime-capabilities.md).
package/docs/release.md CHANGED
@@ -21,7 +21,7 @@ bun run docs:build
21
21
  bun run pack:sdk
22
22
  ```
23
23
 
24
- `bun run pack:sdk` builds the SDK, runs a Bun pack dry-run, and runs the public
24
+ `bun run pack:sdk` builds the SDK, sessions a Bun pack dry-run, and sessions the public
25
25
  boundary gate. Offline user tests install the packed SDK into a clean Bun
26
26
  project and exercise the SDK and CLI from that install tree.
27
27
 
@@ -30,15 +30,15 @@ project and exercise the SDK and CLI from that install tree.
30
30
  The manual `.github/workflows/release.yml` workflow:
31
31
 
32
32
  - Installs with `bun ci`.
33
- - Runs lint, unit/security, offline user tests, docs build, and `pack:sdk`.
33
+ - Sessions lint, unit/security, offline user tests, docs build, and `pack:sdk`.
34
34
  - Refuses to publish if `@aexhq/sdk@<package version>` already exists.
35
35
  - Packs `packages/sdk` with `bun pm pack`.
36
- - Runs the publish job in the `npm-release` GitHub Environment and requires its
36
+ - Sessions the publish job in the `npm-release` GitHub Environment and requires its
37
37
  `NPM_TOKEN` secret.
38
38
  - Publishes the tarball with npm provenance to the selected dist-tag (`canary`
39
39
  by default).
40
40
  - Waits for npm visibility.
41
- - Runs live user tests against the exact published version.
41
+ - Sessions live user tests against the exact published version.
42
42
 
43
43
  Publish canary first for release validation. Promote the same immutable version
44
44
  only after the downstream platform release gate is green.
@@ -64,7 +64,7 @@ CLI version that supports OIDC trusted publishing.
64
64
 
65
65
  The manual `.github/workflows/promote.yml` workflow assigns an npm dist-tag to
66
66
  an already-published `@aexhq/sdk` version, usually `latest` after canary and
67
- platform validation. It also runs in `npm-release`, requires `NPM_TOKEN`, and
67
+ platform validation. It also sessions in `npm-release`, requires `NPM_TOKEN`, and
68
68
  does not rebuild or republish the package.
69
69
 
70
70
  ## What ships in the tarball
package/docs/retries.md CHANGED
@@ -50,7 +50,7 @@ Turn it off entirely with `retry: false`, or make a single attempt with
50
50
  ## Idempotent by construction
51
51
 
52
52
  Retries — whether the built-in transport retry or your own re-invocation of
53
- `run(...)` — never double-bill. The one-shot `run(...)` and `sessions.run(...)`
53
+ `run(...)` — never double-bill. The one-shot `run(...)` and `sessions.start(...)`
54
54
  derive the turn's idempotency key from the session-create key, so re-invoking
55
55
  either with the same `idempotencyKey` de-duplicates **both** the session create
56
56
  and the billable turn server-side:
@@ -58,7 +58,7 @@ and the billable turn server-side:
58
58
  ```ts
59
59
  // A retried call with the same idempotencyKey resolves to the same run,
60
60
  // not a second billable one.
61
- const result = await aex.run({
61
+ const result = await aex.start({
62
62
  model: "claude-haiku-4-5",
63
63
  message: "Write a short report and save it as a file.",
64
64
  apiKeys: { anthropic: process.env.ANTHROPIC_API_KEY! },
@@ -106,7 +106,7 @@ working, and it carries structured, non-leaky detail:
106
106
  import { isRateLimited } from "@aexhq/sdk";
107
107
 
108
108
  try {
109
- await aex.run({ /* … */ });
109
+ await aex.start({ /* … */ });
110
110
  } catch (err) {
111
111
  if (isRateLimited(err)) {
112
112
  err.status; // 429 | 503 | 529
package/docs/secrets.md CHANGED
@@ -4,14 +4,14 @@ title: Secrets
4
4
 
5
5
  # Secrets
6
6
 
7
- aex supports BYOK provider keys, per-run credentials, and reusable workspace
7
+ aex supports BYOK provider keys, per-session credentials, and reusable workspace
8
8
  secrets. Secret values are excluded from the idempotency fingerprint and do not
9
- belong in run config.
9
+ belong in session config.
10
10
 
11
11
  Runnable examples need both `AEX_API_KEY` for aex and the matching BYOK
12
12
  provider key, such as `ANTHROPIC_API_KEY` for Claude.
13
13
 
14
- ## Use A Provider Key For One Run
14
+ ## Use A Provider Key For One SessionRecord
15
15
 
16
16
  ### TypeScript
17
17
 
@@ -20,7 +20,7 @@ import { Aex, Models } from "@aexhq/sdk";
20
20
 
21
21
  const aex = new Aex({ apiKey: process.env.AEX_API_KEY! });
22
22
 
23
- await aex.run({
23
+ await aex.start({
24
24
  model: Models.CLAUDE_HAIKU_4_5,
25
25
  message: "Write a short report and save it as a file.",
26
26
  apiKeys: { anthropic: process.env.ANTHROPIC_API_KEY! }
@@ -30,7 +30,7 @@ await aex.run({
30
30
  ### CLI
31
31
 
32
32
  ```bash
33
- aex run \
33
+ aex start \
34
34
  --api-key "$AEX_API_KEY" \
35
35
  --anthropic-api-key "$ANTHROPIC_API_KEY" \
36
36
  --model claude-haiku-4-5 \
@@ -40,7 +40,7 @@ aex run \
40
40
  ## Upload An Env Secret
41
41
 
42
42
  Use `Secret.value(...).upload(...)` when you start with an ephemeral value and
43
- want to persist it as a named workspace secret for later runs.
43
+ want to persist it as a named workspace secret for later sessions.
44
44
 
45
45
  ```ts
46
46
  import { Aex, Models, Providers, Secret } from "@aexhq/sdk";
@@ -51,7 +51,7 @@ const githubToken = await Secret.value(process.env.GITHUB_TOKEN!).upload(aex, {
51
51
  name: "github-token"
52
52
  });
53
53
 
54
- await aex.run({
54
+ await aex.start({
55
55
  provider: Providers.ANTHROPIC,
56
56
  model: Models.CLAUDE_HAIKU_4_5,
57
57
  message: "Inspect the repository issues.",
@@ -86,7 +86,7 @@ const secrets = await aex.secrets.list();
86
86
  const metadata = await aex.secrets.get("serper-api-key");
87
87
  ```
88
88
 
89
- ## Inject A Workspace Secret Into A Run
89
+ ## Inject A Workspace Secret Into A SessionRecord
90
90
 
91
91
  Reference workspace secrets with `Secret.ref(name)`. The value resolves
92
92
  server-side and is injected as the named environment variable.
@@ -94,7 +94,7 @@ server-side and is injected as the named environment variable.
94
94
  ```ts
95
95
  import { Models, Providers, Secret } from "@aexhq/sdk";
96
96
 
97
- await aex.run({
97
+ await aex.start({
98
98
  provider: Providers.ANTHROPIC,
99
99
  model: Models.CLAUDE_HAIKU_4_5,
100
100
  message: "Use SERPER_API_KEY for web search.",
@@ -111,19 +111,19 @@ await aex.run({
111
111
  await aex.secrets.delete("serper-api-key");
112
112
  ```
113
113
 
114
- The CLI supports per-run provider and MCP credentials. Workspace secret
114
+ The CLI supports per-session provider and MCP credentials. Workspace secret
115
115
  administration is exposed through the SDK.
116
116
 
117
- ## Redaction Scope And Output Files
117
+ ## Redaction Scope And Session Files
118
118
 
119
- Registered secret values are redacted from the run's **event stream** (both tool
119
+ Registered secret values are redacted from the session's **event stream** (both tool
120
120
  output and model-authored surfaces) — a value you inject via `environment.secrets`
121
121
  is masked regardless of its shape. Two surfaces are intentionally *not* scrubbed:
122
122
 
123
- - **Captured output files** (`outputs().download()` / `read()` / the `aex download`
124
- zip) are returned **verbatim**. They are your run's own artifacts, so the platform
123
+ - **Captured session files** (`files().download()` / `read()` / the `aex download`
124
+ zip) are returned **verbatim**. They are your session's own artifacts, so the platform
125
125
  does not rewrite their bytes — if the agent writes a secret into a deliverable file,
126
- that file contains it. Treat downloaded outputs as unredacted.
127
- - An **unregistered** secret (a credential the run produces itself and never declared
126
+ that file contains it. Treat downloaded files as unredacted.
127
+ - An **unregistered** secret (a credential the session produces itself and never declared
128
128
  via `environment.secrets`) can only be masked heuristically by shape; register the
129
129
  values you care about so they are masked by value.
@@ -0,0 +1,58 @@
1
+ ---
2
+ title: SessionRecord configuration
3
+ ---
4
+
5
+ # SessionRecord configuration
6
+
7
+ A session config is the credential-free subset of the session options (`openSession` / `run`) that you can keep in code or load from a JSON file. It is not a platform object, saved definition, DSL, trigger, or persistent agent profile. aex only stores the immutable session record created when the session lands.
8
+
9
+ Allowed fields:
10
+
11
+ - `model` - required.
12
+ - `system` - optional system message.
13
+ - `mcpServers` - array of `McpServerRef`; headers are split into the vaulted secrets channel server-side.
14
+ - `environment` - `{ networking?, packages?, variables? }`. Networking is open by default; set `networking.mode` to `limited` only when you want an allowlist. `variables` are merged into the in-container `RUNTIME.env` / `RUNTIME.json` mounts. (SessionRecord secrets go in `environment.secrets`, which carries live `Secret` instances and is not part of a shareable config.)
15
+ - `runtime` - optional managed-runtime preset. Prefer `Sizes` in TypeScript.
16
+ - `metadata` - non-secret structured metadata.
17
+ - `overrides` - `{ idleTtl?, timeout?, maxSpendUsd?, maxTurns? }`. `timeout` is an optional session deadline (e.g. `"30m"`, `"2h"`); `maxSpendUsd` stops the session once its spend would exceed the cap; `maxTurns` caps the agent's iteration count for the turn (a positive integer — omit to accept the platform default of 20, clamped to the ceiling). See [Limits & quotas](limits-and-quotas.md).
18
+
19
+ `message` (the one-shot `run` input), `agentsMd`, `files`, `fileCapture`, `tools`, `skills`, `includeBuiltinTools`, and `outputMode` are `openSession` / `run` options, not reusable session-config fields. They carry the turn input, mounted bytes, capture behavior, or agent tool / assistant-text controls that belong on a concrete call. Skill bundles are `skills` entries built with `Skill.fromDir(...)`, `Skill.fromUrl(...)`, or the other `Skill.from*` factories, so they too are SDK-code options rather than config fields. Subagents are session-internal (the in-run `subagent` tool — see [Subagents](concepts/subagents.md)); there is no `parentSessionId` option. The wire contract carries a per-session `limits` object (the exported `SessionLimits` type: `maxConcurrentChildSessions`, `maxSubagentDepth`, `maxSpendUsd`, `maxTurns`), and the session surface exposes its spend and iteration dials via `overrides.maxSpendUsd` and `overrides.maxTurns`; the subagent depth/breadth dials are not settable per-session today and take the platform defaults.
20
+
21
+ Secrets never live in session config. Pass provider keys through the top-level
22
+ `apiKeys` map and runtime secrets through `environment.secrets` in the SDK, or
23
+ the equivalent host-mode flags (`--anthropic-api-key`, `--mcp-auth`) in the CLI.
24
+ See [Secrets](secrets.md) for secret lifecycles and [Credentials](credentials.md)
25
+ for credential handling.
26
+
27
+ ## Reuse in code
28
+
29
+ Use an ordinary function when you want reusable typed parameters. aex does not store or execute this function; it only receives the parameters you pass.
30
+
31
+ ```ts
32
+ import { Models } from "@aexhq/sdk";
33
+
34
+ function summarise(topic: string) {
35
+ return {
36
+ model: Models.CLAUDE_HAIKU_4_5,
37
+ system: "You are a concise automation agent.",
38
+ message: `Write a short answer about ${topic}.`
39
+ };
40
+ }
41
+
42
+ await aex.start({
43
+ ...summarise("agent-first SDK design"),
44
+ apiKeys: { anthropic: apiKey }
45
+ });
46
+ ```
47
+
48
+ ## CLI
49
+
50
+ The `aex start` host subcommand accepts the same session config either as a JSON file:
51
+
52
+ ```bash
53
+ aex start --config ./main.json \
54
+ --api-key "$AEX_API_KEY" \
55
+ --anthropic-api-key "$ANTHROPIC_API_KEY"
56
+ ```
57
+
58
+ ...or as explicit flags (`--model`, `--system`, `--prompt`, `--mcp`, `--mcp-auth`, `--runtime-size`, `--session-timeout`, `--metadata`). The two modes are mutually exclusive. Composition inputs attach with repeatable flags that map onto the SDK's `Skill`/`Tool`/`AgentsMd`/`File` factories: `--skill @bundle` (workspace skill), `--tool @tool.js` (custom tool module), `--agents-md @AGENTS.md`, and `--file @path` (mount a file into `/workspace`).
@@ -1,14 +1,14 @@
1
1
  ---
2
- title: Run record
2
+ title: Session record
3
3
  ---
4
4
 
5
- # Run record
5
+ # Session record
6
6
 
7
- The run record is the durable product primitive for one session. It is the public-safe bundle of status metadata, the non-secret submission snapshot when available, typed events, captured outputs, and manifest entries for custody and cost telemetry.
7
+ The session record is the durable product primitive for one session. It is the public-safe bundle of status metadata, the non-secret submission snapshot when available, typed events, captured files, and manifest entries for custody and cost telemetry.
8
8
 
9
9
  ## Listing sessions
10
10
 
11
- `aex.sessions.list(query?)` enumerates the sessions in this workspace, most-recent first, one page at a time. The workspace is derived server-side from the API key, so this only ever returns your own sessions. It is the workspace-wide discovery entry point: combine it with `aex.sessions.outputs(id).list()` / `.read(...)` (see [Outputs](outputs.md)) to reach any session's deliverables.
11
+ `aex.sessions.list(query?)` enumerates the sessions in this workspace, most-recent first, one page at a time. The workspace is derived server-side from the API key, so this only ever returns your own sessions. It is the workspace-wide discovery entry point: combine it with `aex.sessions.files(id).list()` / `.read(...)` (see [Files](files.md)) to reach any session's deliverables.
12
12
 
13
13
  ```ts
14
14
  let cursor: string | undefined;
@@ -23,33 +23,33 @@ do {
23
23
 
24
24
  `query` fields are all optional: `status` (single session status, e.g. `"idle"`), `since` (ISO-8601 lower bound on `createdAt`), `limit` (defaults to 25, clamped to `[1, 100]`), and `cursor` (the opaque keyset cursor from a prior page's `nextCursor` — absent on the last page). Each page row is a public-safe `SessionSummary` (`id`, `status`, `createdAt`, `updatedAt`, and `costUsd` once settled); it deliberately omits the submission snapshot (model / system / env). Use `aex.sessions.get(id)` for status / timing / cost on one session, or `session.unit()` on a handle for the full self-contained record including the parsed submission.
25
25
 
26
- ## Downloading a run record
26
+ ## Downloading a session record
27
27
 
28
28
  `session.download()` and `aex download <session-id>` return a zip with this layout:
29
29
 
30
30
  ```text
31
31
  manifest.json
32
- metadata/run.json
32
+ metadata/session.json
33
33
  metadata/submission.json # when a public-safe submission snapshot is returned by the read API
34
34
  metadata/cost.json # when public cost telemetry is returned by the read API
35
35
  events/events.jsonl
36
- outputs/<captured deliverable files>
36
+ files/<captured deliverable files>
37
37
  ```
38
38
 
39
- `manifest.json` is versioned as `RunRecordManifestV1`:
39
+ `manifest.json` is versioned as `SessionRecordManifestV1`:
40
40
 
41
41
  | Field | Meaning |
42
42
  | --- | --- |
43
- | `schemaVersion` | `aex.run-record.manifest.v1`. |
44
- | `runRecordSchemaVersion` | `aex.run-record.v1`. |
45
- | `runId` | The run the archive was assembled for. |
46
- | `namespaces[]` | The documented top-level namespaces: `metadata`, `events`, `outputs`. |
43
+ | `schemaVersion` | `aex.session-record.manifest.v1`. |
44
+ | `sessionRecordSchemaVersion` | `aex.session-record.v1`. |
45
+ | `sessionId` | The session the archive was assembled for. |
46
+ | `namespaces[]` | The documented top-level namespaces: `metadata`, `events`, `files`. |
47
47
  | `files[]` | Inventory of expected and present files with `namespace`, `path`, `role`, and `status`. |
48
- | `outputs[]` | Compatibility alias for present captured output artifacts. |
48
+ | `sessionFiles[]` | Session file metadata for entries present under the `files/` namespace. |
49
49
  | `errors[]` | Per-artifact byte fetch failures during archive assembly. |
50
50
 
51
- Current v1 downloads always include `metadata/run.json` and `events/events.jsonl`. `events/events.jsonl` contains typed event-channel records only; internal diagnostics and full internal streams are not mixed into that file.
51
+ Current v1 downloads always include `metadata/session.json` and `events/events.jsonl`. `events/events.jsonl` contains typed event-channel records only; internal diagnostics and full internal streams are not mixed into that file.
52
52
 
53
- `metadata/submission.json` is present only when the run read shape includes a public-safe submission snapshot. `metadata/cost.json` is present only when the run read shape includes public `costTelemetry`; otherwise cost stays `pending`. `metadata/custody.json` remains `pending` until the custody manifest writer and public read surface land. `events/manifest.json` remains `unavailable` in this client-side slice because there is no public coordinator-manifest download route.
53
+ `metadata/submission.json` is present only when the session read shape includes a public-safe submission snapshot. `metadata/cost.json` is present only when the session read shape includes public `costTelemetry`; otherwise cost stays `pending`. `metadata/custody.json` remains `pending` until the custody manifest writer and public read surface land. `events/manifest.json` remains `unavailable` in this client-side slice because there is no public coordinator-manifest download route.
54
54
 
55
- The record boundary is public-safe. It must not contain provider API keys, runner bearers, workspace tokens, signed URLs, raw provider response bodies, object-store keys, Vault ids, raw query strings, secret-shaped values, or internal diagnostic files. Credentials are supplied per run and vaulted separately for the run lifetime.
55
+ The record boundary is public-safe. It must not contain provider API keys, runner bearers, workspace tokens, signed URLs, raw provider response bodies, object-store keys, Vault ids, raw query strings, secret-shaped values, or internal diagnostic files. Credentials are supplied per session and vaulted separately for the session lifetime.
package/docs/skills.md CHANGED
@@ -7,7 +7,7 @@ title: Skills
7
7
  A skill is a bundle of instructional or executable content (`SKILL.md` plus any
8
8
  supporting files) that the agent can pull into context on demand. Skills are a
9
9
  **first-class concept, separate from tools**: you pass them on the session's own
10
- `skills` input (not `tools`), and the run gets a single `skills` meta-tool the
10
+ `skills` input (not `tools`), and the session gets a single `skills` meta-tool the
11
11
  model uses to list and load them.
12
12
 
13
13
  Build a skill with the `Skill.from*` factories. Each reads a bundle, lifts the
@@ -34,7 +34,7 @@ import { Aex, Models, Skill } from "@aexhq/sdk";
34
34
 
35
35
  const aex = new Aex({ apiKey });
36
36
 
37
- await aex.run({
37
+ await aex.start({
38
38
  model: Models.CLAUDE_HAIKU_4_5,
39
39
  message,
40
40
  skills: [await Skill.fromDir("./skills/rules", { name: "rules" })],
@@ -48,17 +48,17 @@ A skill is bound to the workspace **by name**. `skill.upload(client)` UPSERTS th
48
48
  workspace skill under its name; a re-upload under the same name changes what
49
49
  every future run referencing that name sees. The wire ref is name-only —
50
50
  `{ kind:"skill", name }` — with no `assetId` and no hash, so the idempotency hash
51
- of two runs that reference the same skill name is identical even if the skill's
51
+ of two sessions that reference the same skill name is identical even if the skill's
52
52
  bytes changed between them.
53
53
 
54
54
  Passing a **draft** `Skill` in `skills:` auto-upserts it on submit (the same
55
55
  ergonomic as a draft `Tool` / `File`). To upsert explicitly and reuse the name
56
- across many runs:
56
+ across many sessions:
57
57
 
58
58
  ```ts
59
59
  const rules = await Skill.fromDir("./skills/rules", { name: "rules" });
60
60
  await rules.upload(aex); // stage bytes + PUT /skills/rules
61
- await aex.run({ model, message, skills: [rules], apiKeys });
61
+ await aex.start({ model, message, skills: [rules], apiKeys });
62
62
  ```
63
63
 
64
64
  `upload()` is idempotent on an instance (it caches the resolved name, so reuse
@@ -82,7 +82,7 @@ concurrency and run concurrently with each other.
82
82
 
83
83
  ## The `skills` meta-tool
84
84
 
85
- When a run references at least one skill, the platform injects a single `skills`
85
+ When a session references at least one skill, the platform injects a single `skills`
86
86
  meta-tool:
87
87
 
88
88
  - `skills({ action: "list" })` returns each skill's `name` + `description`
@@ -92,9 +92,9 @@ meta-tool:
92
92
 
93
93
  A skill's supporting files are staged to disk under `/workspace/skills/<name>/`
94
94
  from the first turn, so `load` pulls the instructions while `read_file` / `bash`
95
- read the rest. The run resolves each referenced name to the workspace skill's
96
- current bytes at submit time and snapshots them into durable run asset storage
97
- (`runs/<runId>/assets/<hash>`); run-scoped copies are removed by run deletion or
95
+ read the rest. The session resolves each referenced name to the workspace skill's
96
+ current bytes at submit time and snapshots them into durable session asset storage
97
+ (`sessions/<sessionId>/assets/<hash>`); session-scoped copies are removed by session deletion or
98
98
  retention cleanup.
99
99
 
100
100
  ## Workspace skill admin
@@ -5,22 +5,22 @@ title: Call a vision API from a skill
5
5
  # Call a vision API from a skill
6
6
 
7
7
  aex has no built-in vision tool. The agent's `provider` / `model` selects the
8
- reasoning model for the run; if a skill needs image understanding mid-run, ship a
8
+ reasoning model for the session; if a skill needs image understanding mid-session, ship a
9
9
  skill that calls the vision provider with normal HTTP and pass that provider key
10
10
  as a runtime secret.
11
11
 
12
- The runnable example lives at [`examples/vision-skill/`](../../../examples/vision-skill).
12
+ The sessionnable example lives at [`examples/vision-skill/`](../../../examples/vision-skill).
13
13
  It captions a frame with ByteDance Doubao Seed Vision (Ark) and returns a
14
14
  per-noun "does the frame depict X?" verdict.
15
15
 
16
- ## Submit the run
16
+ ## Submit the session
17
17
 
18
18
  ```ts
19
19
  import { Aex, Models, Secret, Skill } from "@aexhq/sdk";
20
20
 
21
21
  const aex = new Aex({ apiKey: process.env.AEX_API_KEY! });
22
22
 
23
- const result = await aex.run({
23
+ const result = await aex.start({
24
24
  model: Models.CLAUDE_HAIKU_4_5,
25
25
  message: "Read skills/frame-vision-gate/SKILL.md, then caption and verify the frame.",
26
26
  skills: [await Skill.fromDir("./vision-skill", { name: "frame-vision-gate" })],
@@ -36,16 +36,16 @@ const result = await aex.run({
36
36
  apiKeys: { anthropic: process.env.ANTHROPIC_API_KEY! }
37
37
  });
38
38
 
39
- console.log(result.runId, result.text);
39
+ console.log(result.sessionId, result.text);
40
40
  ```
41
41
 
42
42
  `Skill.fromDir("./vision-skill", ...)` is resolved relative to the process
43
- CWD. Run the script from the directory that contains `vision-skill/` (in this
43
+ CWD. SessionRecord the script from the directory that contains `vision-skill/` (in this
44
44
  repo, `examples/`).
45
45
 
46
46
  ## Call the provider from the skill
47
47
 
48
- Inside the run, the skill reads `DOUBAO_API_KEY` and makes an
48
+ Inside the session, the skill reads `DOUBAO_API_KEY` and makes an
49
49
  OpenAI-compatible chat-completions request with Python's standard HTTP client.
50
50
  The image is base64-inlined as a data URL in the request body:
51
51
 
package/docs/webhooks.md CHANGED
@@ -4,9 +4,9 @@ title: Webhooks
4
4
 
5
5
  # Webhooks
6
6
 
7
- aex can notify your endpoint when a run finishes. Webhooks are **per-run**: you
7
+ aex can notify your endpoint when a session finishes. Webhooks are **per-session**: you
8
8
  pass a callback URL with the submission, and the platform delivers exactly one
9
- `run.finished` event to it when the run reaches its terminal state.
9
+ `session.finished` event to it when the session reaches its terminal state.
10
10
 
11
11
  ## Register a callback
12
12
 
@@ -23,7 +23,7 @@ const session = await aex.openSession({
23
23
  ```
24
24
 
25
25
  ```bash
26
- aex run \
26
+ aex start \
27
27
  --api-key "$AEX_API_KEY" \
28
28
  --anthropic-api-key "$ANTHROPIC_API_KEY" \
29
29
  --model claude-haiku-4-5 \
@@ -37,9 +37,9 @@ idempotency key but a different callback URL never conflicts.
37
37
 
38
38
  ## What gets delivered
39
39
 
40
- One POST carrying the terminal `run.finished` event, sent at the
41
- settle-consistent barrier — when you receive it, the run record is already
42
- terminal and its outputs are complete and readable. The body is built once at
40
+ One POST carrying the terminal `session.finished` event, sent at the
41
+ settle-consistent barrier — when you receive it, the session record is already
42
+ terminal and its files are complete and readable. The body is built once at
43
43
  settle, frozen, and re-sent byte-identical on every retry or manual redelivery:
44
44
 
45
45
  ```json
@@ -47,11 +47,11 @@ settle, frozen, and re-sent byte-identical on every retry or manual redelivery:
47
47
  "specversion": "1.0",
48
48
  "id": "<delivery id — matches the webhook-id header>",
49
49
  "source": "aex",
50
- "type": "run.finished",
51
- "subject": "<the run id>",
50
+ "type": "session.finished",
51
+ "subject": "<the session id>",
52
52
  "time": "2026-07-02T12:34:56.000Z",
53
53
  "data": {
54
- "runId": "<the run id>",
54
+ "sessionId": "<the session id>",
55
55
  "status": "succeeded",
56
56
  "terminalAt": "2026-07-02T12:34:56.000Z",
57
57
  "reason": null,
@@ -108,7 +108,7 @@ is compromised, contact <support@aex.dev>.
108
108
 
109
109
  ## Delivery ledger and redelivery
110
110
 
111
- Each run keeps a delivery ledger — attempts, last status code, and last error:
111
+ Each session keeps a delivery ledger — attempts, last status code, and last error:
112
112
 
113
113
  ```ts
114
114
  const deliveries = await session.webhooks().list();
@@ -121,7 +121,7 @@ aex deliveries <session-id> --api-key "$AEX_API_KEY"
121
121
 
122
122
  Redelivery re-sends the frozen payload with the **same** `webhook-id`, so a
123
123
  consumer that dedupes on `webhook-id` handles retries, redeliveries, and
124
- at-least-once delivery uniformly. An empty ledger means the run carried no
124
+ at-least-once delivery uniformly. An empty ledger means the session carried no
125
125
  `webhook` or has not reached a terminal state yet.
126
126
 
127
127
  For the terminal-event mechanics behind delivery timing, see