@aexhq/sdk 0.40.5 → 0.40.6

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 (77) hide show
  1. package/README.md +159 -159
  2. package/dist/_contracts/api-key.js +0 -1
  3. package/dist/_contracts/bundle-manifest.js +0 -1
  4. package/dist/_contracts/connection-ticket.js +0 -1
  5. package/dist/_contracts/error-codes.js +0 -1
  6. package/dist/_contracts/error-factory.js +0 -1
  7. package/dist/_contracts/event-envelope.js +0 -1
  8. package/dist/_contracts/event-stream-client.js +0 -1
  9. package/dist/_contracts/event-view.js +0 -1
  10. package/dist/_contracts/http.js +0 -1
  11. package/dist/_contracts/index.js +0 -1
  12. package/dist/_contracts/internal.d.ts +36 -0
  13. package/dist/_contracts/internal.js +155 -6
  14. package/dist/_contracts/models.js +0 -1
  15. package/dist/_contracts/operations.js +1 -2
  16. package/dist/_contracts/post-hook.js +0 -1
  17. package/dist/_contracts/provider-support.js +0 -1
  18. package/dist/_contracts/run-artifacts.js +0 -1
  19. package/dist/_contracts/run-config.js +0 -1
  20. package/dist/_contracts/run-cost.js +0 -1
  21. package/dist/_contracts/run-custody.js +0 -1
  22. package/dist/_contracts/run-record.js +0 -1
  23. package/dist/_contracts/run-retention.js +0 -1
  24. package/dist/_contracts/run-trace.js +0 -1
  25. package/dist/_contracts/run-unit.js +0 -1
  26. package/dist/_contracts/runner-event.js +0 -1
  27. package/dist/_contracts/runtime-manifest.js +0 -1
  28. package/dist/_contracts/runtime-security-profile.js +0 -1
  29. package/dist/_contracts/runtime-sizes.js +0 -1
  30. package/dist/_contracts/runtime-types.js +0 -1
  31. package/dist/_contracts/sdk-errors.js +0 -1
  32. package/dist/_contracts/sdk-secrets.js +0 -1
  33. package/dist/_contracts/side-effect-audit.js +0 -1
  34. package/dist/_contracts/sse.js +0 -0
  35. package/dist/_contracts/stable.js +0 -1
  36. package/dist/_contracts/status.js +0 -1
  37. package/dist/_contracts/submission.js +0 -1
  38. package/dist/_contracts/suggest.js +0 -1
  39. package/dist/_contracts/webhook-verify.js +0 -1
  40. package/dist/asset-upload.d.ts +3 -43
  41. package/dist/asset-upload.js +1 -109
  42. package/dist/asset-upload.js.map +1 -1
  43. package/dist/cli.mjs +354 -781
  44. package/dist/cli.mjs.sha256 +1 -1
  45. package/dist/fetch-archive.js +76 -16
  46. package/dist/fetch-archive.js.map +1 -1
  47. package/dist/version.d.ts +1 -1
  48. package/dist/version.js +1 -1
  49. package/docs/authentication.md +125 -125
  50. package/docs/billing.md +118 -118
  51. package/docs/concepts/agent-tools.md +66 -66
  52. package/docs/concepts/composition.md +37 -37
  53. package/docs/concepts/providers-and-runtimes.md +54 -54
  54. package/docs/concepts/runs.md +49 -49
  55. package/docs/concepts/subagents.md +88 -88
  56. package/docs/credentials.md +125 -125
  57. package/docs/defaults.md +64 -64
  58. package/docs/errors.md +196 -196
  59. package/docs/events.md +243 -243
  60. package/docs/limits-and-quotas.md +144 -144
  61. package/docs/limits.md +50 -50
  62. package/docs/mcp.md +44 -44
  63. package/docs/networking.md +163 -163
  64. package/docs/outputs.md +267 -267
  65. package/docs/public-surface.json +77 -77
  66. package/docs/quickstart.md +119 -119
  67. package/docs/release.md +38 -38
  68. package/docs/retries.md +129 -129
  69. package/docs/run-config.md +58 -58
  70. package/docs/run-record.md +55 -55
  71. package/docs/secrets.md +125 -130
  72. package/docs/testing.md +35 -35
  73. package/docs/vision-skills.md +91 -91
  74. package/docs/webhooks.md +127 -131
  75. package/examples/feature-tour.ts +282 -282
  76. package/examples/spike-settle-latency.ts +125 -125
  77. package/package.json +1 -1
package/docs/webhooks.md CHANGED
@@ -1,132 +1,128 @@
1
- ---
2
- title: Webhooks
3
- ---
4
-
5
- # Webhooks
6
-
7
- aex can notify your endpoint when a run finishes. Webhooks are **per-run**: you
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.
10
-
11
- > **Availability note:** terminal webhook delivery for session-based runs
12
- > requires the next platform deploy — on the current hosted plane a session
13
- > run's webhook may not fire. This note will be removed once the deploy lands.
14
-
1
+ ---
2
+ title: Webhooks
3
+ ---
4
+
5
+ # Webhooks
6
+
7
+ aex can notify your endpoint when a run finishes. Webhooks are **per-run**: you
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.
10
+
15
11
  ## Register a callback
16
-
17
- ```ts
18
- import { Aex, Models } from "@aexhq/sdk";
19
-
20
- const aex = new Aex(process.env.AEX_API_KEY!);
21
-
22
- const session = await aex.openSession({
23
- model: Models.CLAUDE_HAIKU_4_5,
24
- webhook: { url: "https://hooks.example.com/aex" },
25
- apiKeys: { anthropic: process.env.ANTHROPIC_API_KEY! }
26
- });
27
- ```
28
-
29
- ```bash
30
- aex run \
31
- --api-key "$AEX_API_KEY" \
32
- --anthropic-api-key "$ANTHROPIC_API_KEY" \
33
- --model claude-haiku-4-5 \
34
- --prompt "Write the report." \
35
- --webhook https://hooks.example.com/aex
36
- ```
37
-
38
- The URL must be `https`. The callback URL is an operational concern, not part
39
- of the submission fingerprint: retrying the same submission with the same
40
- idempotency key but a different callback URL never conflicts.
41
-
42
- ## What gets delivered
43
-
44
- One POST carrying the terminal `run.finished` event, sent at the
45
- settle-consistent barrier — when you receive it, the run record is already
46
- terminal and its outputs are complete and readable. The body is built once at
47
- settle, frozen, and re-sent byte-identical on every retry or manual redelivery:
48
-
49
- ```json
50
- {
51
- "specversion": "1.0",
52
- "id": "<delivery id — matches the webhook-id header>",
53
- "source": "aex",
54
- "type": "run.finished",
55
- "subject": "<the run id>",
56
- "time": "2026-07-02T12:34:56.000Z",
57
- "data": {
58
- "runId": "<the run id>",
59
- "status": "succeeded",
60
- "terminalAt": "2026-07-02T12:34:56.000Z",
61
- "reason": null,
62
- "failureClass": null,
63
- "costTelemetry": { "billedCostUsd": 0.42 }
64
- }
65
- }
66
- ```
67
-
68
- `reason` / `failureClass` carry the failure detail on non-success terminals;
69
- `costTelemetry` is present when the billed cost is known.
70
-
71
- ## Verify deliveries
72
-
73
- Deliveries are signed [Standard Webhooks](https://www.standardwebhooks.com/)
74
- style: HMAC-SHA256 over `` `${webhook-id}.${webhook-timestamp}.${rawBody}` ``,
75
- sent in three headers — `webhook-id` (stable across retries; your dedupe key),
76
- `webhook-timestamp` (unix seconds), and `webhook-signature` (a space-delimited
77
- list of `v1,<base64>` entries).
78
-
79
- The signing key is a per-workspace secret. Reveal it (it is created on first
80
- use) with either surface:
81
-
82
- ```bash
83
- aex webhooks secret --api-key "$AEX_API_KEY" # prints whsec_...
84
- ```
85
-
86
- ```ts
87
- const { whsec } = await aex.webhookSigningSecret();
88
- ```
89
-
90
- Verify inbound requests with the exported `verifyAexWebhook` — pure Web Crypto,
91
- identical under Bun and Node, and interoperable with the `standardwebhooks`
92
- reference library:
93
-
94
- ```ts
95
- import { verifyAexWebhook } from "@aexhq/sdk";
96
-
97
- // In your HTTP handler — use the EXACT raw body bytes, never re-serialize.
98
- const ok = await verifyAexWebhook({
99
- rawBody,
100
- headers: request.headers,
101
- secret: process.env.AEX_WEBHOOK_SECRET! // the whsec_... value
102
- });
103
- if (!ok) return new Response("bad signature", { status: 401 });
104
- ```
105
-
106
- `verifyAexWebhook` rejects stale timestamps (default tolerance 300 seconds) and
107
- compares signatures constant-time. It accepts every `v1` entry in the signature
108
- list, so it is already rotation-ready — but **server-side rotation of the
109
- signing secret is not available yet**: `aex webhooks secret` reveals or creates
110
- the one workspace secret and there is no rotate endpoint today. If your secret
111
- is compromised, contact <support@aex.dev>.
112
-
113
- ## Delivery ledger and redelivery
114
-
115
- Each run keeps a delivery ledger — attempts, last status code, and last error:
116
-
117
- ```ts
118
- const deliveries = await session.webhooks().list();
119
- await session.webhooks().redeliver(deliveries[0]!.id);
120
- ```
121
-
122
- ```bash
123
- aex deliveries <session-id> --api-key "$AEX_API_KEY"
124
- ```
125
-
126
- Redelivery re-sends the frozen payload with the **same** `webhook-id`, so a
127
- consumer that dedupes on `webhook-id` handles retries, redeliveries, and
128
- at-least-once delivery uniformly. An empty ledger means the run carried no
129
- `webhook` or has not reached a terminal state yet.
130
-
131
- For the terminal-event mechanics behind delivery timing, see
132
- [Events](events.md).
12
+
13
+ ```ts
14
+ import { Aex, Models } from "@aexhq/sdk";
15
+
16
+ const aex = new Aex(process.env.AEX_API_KEY!);
17
+
18
+ const session = await aex.openSession({
19
+ model: Models.CLAUDE_HAIKU_4_5,
20
+ webhook: { url: "https://hooks.example.com/aex" },
21
+ apiKeys: { anthropic: process.env.ANTHROPIC_API_KEY! }
22
+ });
23
+ ```
24
+
25
+ ```bash
26
+ aex run \
27
+ --api-key "$AEX_API_KEY" \
28
+ --anthropic-api-key "$ANTHROPIC_API_KEY" \
29
+ --model claude-haiku-4-5 \
30
+ --prompt "Write the report." \
31
+ --webhook https://hooks.example.com/aex
32
+ ```
33
+
34
+ The URL must be `https`. The callback URL is an operational concern, not part
35
+ of the submission fingerprint: retrying the same submission with the same
36
+ idempotency key but a different callback URL never conflicts.
37
+
38
+ ## What gets delivered
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
43
+ settle, frozen, and re-sent byte-identical on every retry or manual redelivery:
44
+
45
+ ```json
46
+ {
47
+ "specversion": "1.0",
48
+ "id": "<delivery id — matches the webhook-id header>",
49
+ "source": "aex",
50
+ "type": "run.finished",
51
+ "subject": "<the run id>",
52
+ "time": "2026-07-02T12:34:56.000Z",
53
+ "data": {
54
+ "runId": "<the run id>",
55
+ "status": "succeeded",
56
+ "terminalAt": "2026-07-02T12:34:56.000Z",
57
+ "reason": null,
58
+ "failureClass": null,
59
+ "costTelemetry": { "billedCostUsd": 0.42 }
60
+ }
61
+ }
62
+ ```
63
+
64
+ `reason` / `failureClass` carry the failure detail on non-success terminals;
65
+ `costTelemetry` is present when the billed cost is known.
66
+
67
+ ## Verify deliveries
68
+
69
+ Deliveries are signed [Standard Webhooks](https://www.standardwebhooks.com/)
70
+ style: HMAC-SHA256 over `` `${webhook-id}.${webhook-timestamp}.${rawBody}` ``,
71
+ sent in three headers — `webhook-id` (stable across retries; your dedupe key),
72
+ `webhook-timestamp` (unix seconds), and `webhook-signature` (a space-delimited
73
+ list of `v1,<base64>` entries).
74
+
75
+ The signing key is a per-workspace secret. Reveal it (it is created on first
76
+ use) with either surface:
77
+
78
+ ```bash
79
+ aex webhooks secret --api-key "$AEX_API_KEY" # prints whsec_...
80
+ ```
81
+
82
+ ```ts
83
+ const { whsec } = await aex.webhookSigningSecret();
84
+ ```
85
+
86
+ Verify inbound requests with the exported `verifyAexWebhook` — pure Web Crypto,
87
+ identical under Bun and Node, and interoperable with the `standardwebhooks`
88
+ reference library:
89
+
90
+ ```ts
91
+ import { verifyAexWebhook } from "@aexhq/sdk";
92
+
93
+ // In your HTTP handler — use the EXACT raw body bytes, never re-serialize.
94
+ const ok = await verifyAexWebhook({
95
+ rawBody,
96
+ headers: request.headers,
97
+ secret: process.env.AEX_WEBHOOK_SECRET! // the whsec_... value
98
+ });
99
+ if (!ok) return new Response("bad signature", { status: 401 });
100
+ ```
101
+
102
+ `verifyAexWebhook` rejects stale timestamps (default tolerance 300 seconds) and
103
+ compares signatures constant-time. It accepts every `v1` entry in the signature
104
+ list, so it is already rotation-ready — but **server-side rotation of the
105
+ signing secret is not available yet**: `aex webhooks secret` reveals or creates
106
+ the one workspace secret and there is no rotate endpoint today. If your secret
107
+ is compromised, contact <support@aex.dev>.
108
+
109
+ ## Delivery ledger and redelivery
110
+
111
+ Each run keeps a delivery ledger — attempts, last status code, and last error:
112
+
113
+ ```ts
114
+ const deliveries = await session.webhooks().list();
115
+ await session.webhooks().redeliver(deliveries[0]!.id);
116
+ ```
117
+
118
+ ```bash
119
+ aex deliveries <session-id> --api-key "$AEX_API_KEY"
120
+ ```
121
+
122
+ Redelivery re-sends the frozen payload with the **same** `webhook-id`, so a
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
125
+ `webhook` or has not reached a terminal state yet.
126
+
127
+ For the terminal-event mechanics behind delivery timing, see
128
+ [Events](events.md).