@aexhq/sdk 0.46.4-canary → 0.50.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.
Files changed (337) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +38 -0
  3. package/README.md +23 -31
  4. package/dist/client/aex.d.ts +33 -0
  5. package/dist/client/aex.js +98 -0
  6. package/dist/client/aex.js.map +1 -0
  7. package/dist/client/credentials.d.ts +25 -0
  8. package/dist/client/credentials.js +97 -0
  9. package/dist/client/credentials.js.map +1 -0
  10. package/dist/client/routing.d.ts +7 -0
  11. package/dist/client/routing.js +29 -0
  12. package/dist/client/routing.js.map +1 -0
  13. package/dist/downloads/download.d.ts +25 -0
  14. package/dist/downloads/download.js +53 -0
  15. package/dist/downloads/download.js.map +1 -0
  16. package/dist/generated/errors.d.ts +12 -0
  17. package/dist/generated/errors.js +81 -0
  18. package/dist/generated/errors.js.map +1 -0
  19. package/dist/generated/resources.d.ts +730 -0
  20. package/dist/generated/resources.js +606 -0
  21. package/dist/generated/resources.js.map +1 -0
  22. package/dist/generated/routes.d.ts +42 -0
  23. package/dist/generated/routes.js +2101 -0
  24. package/dist/generated/routes.js.map +1 -0
  25. package/dist/index.d.ts +20 -50
  26. package/dist/index.js +11 -62
  27. package/dist/index.js.map +1 -1
  28. package/dist/observations/stream.d.ts +1 -0
  29. package/dist/observations/stream.js +18 -0
  30. package/dist/observations/stream.js.map +1 -0
  31. package/dist/transport/errors.d.ts +60 -0
  32. package/dist/transport/errors.js +107 -0
  33. package/dist/transport/errors.js.map +1 -0
  34. package/dist/transport/pagination.d.ts +8 -0
  35. package/dist/transport/pagination.js +34 -0
  36. package/dist/transport/pagination.js.map +1 -0
  37. package/dist/transport/retry.d.ts +21 -0
  38. package/dist/transport/retry.js +37 -0
  39. package/dist/transport/retry.js.map +1 -0
  40. package/dist/transport/transport.d.ts +25 -0
  41. package/dist/transport/transport.js +28 -0
  42. package/dist/transport/transport.js.map +1 -0
  43. package/package.json +63 -30
  44. package/dist/_contracts/account-operations.d.ts +0 -101
  45. package/dist/_contracts/account-operations.js +0 -242
  46. package/dist/_contracts/account-types.d.ts +0 -461
  47. package/dist/_contracts/account-types.js +0 -1
  48. package/dist/_contracts/api-key.d.ts +0 -61
  49. package/dist/_contracts/api-key.js +0 -101
  50. package/dist/_contracts/api-routes.d.ts +0 -20
  51. package/dist/_contracts/api-routes.js +0 -109
  52. package/dist/_contracts/archive-limits.d.ts +0 -3
  53. package/dist/_contracts/archive-limits.js +0 -23
  54. package/dist/_contracts/asset-authoring.d.ts +0 -22
  55. package/dist/_contracts/asset-authoring.js +0 -106
  56. package/dist/_contracts/asset-bundle.d.ts +0 -64
  57. package/dist/_contracts/asset-bundle.js +0 -263
  58. package/dist/_contracts/asset-upload-helper.d.ts +0 -31
  59. package/dist/_contracts/asset-upload-helper.js +0 -84
  60. package/dist/_contracts/billing-admission.d.ts +0 -29
  61. package/dist/_contracts/billing-admission.js +0 -28
  62. package/dist/_contracts/bundle-manifest.d.ts +0 -89
  63. package/dist/_contracts/bundle-manifest.js +0 -158
  64. package/dist/_contracts/canonical-sha256.d.ts +0 -8
  65. package/dist/_contracts/canonical-sha256.js +0 -8
  66. package/dist/_contracts/connection-ticket.d.ts +0 -22
  67. package/dist/_contracts/connection-ticket.js +0 -54
  68. package/dist/_contracts/continuation-event.d.ts +0 -31
  69. package/dist/_contracts/continuation-event.js +0 -6
  70. package/dist/_contracts/contract-parse-error.d.ts +0 -12
  71. package/dist/_contracts/contract-parse-error.js +0 -51
  72. package/dist/_contracts/error-codes.d.ts +0 -26
  73. package/dist/_contracts/error-codes.js +0 -116
  74. package/dist/_contracts/error-factory.d.ts +0 -32
  75. package/dist/_contracts/error-factory.js +0 -174
  76. package/dist/_contracts/event-envelope.d.ts +0 -471
  77. package/dist/_contracts/event-envelope.js +0 -501
  78. package/dist/_contracts/event-stream-client.d.ts +0 -122
  79. package/dist/_contracts/event-stream-client.js +0 -445
  80. package/dist/_contracts/event-view.d.ts +0 -44
  81. package/dist/_contracts/event-view.js +0 -69
  82. package/dist/_contracts/failure-class.d.ts +0 -29
  83. package/dist/_contracts/failure-class.js +0 -73
  84. package/dist/_contracts/http.d.ts +0 -135
  85. package/dist/_contracts/http.js +0 -434
  86. package/dist/_contracts/ids.d.ts +0 -66
  87. package/dist/_contracts/ids.js +0 -119
  88. package/dist/_contracts/index.d.ts +0 -42
  89. package/dist/_contracts/index.js +0 -52
  90. package/dist/_contracts/internal.d.ts +0 -55
  91. package/dist/_contracts/internal.js +0 -113
  92. package/dist/_contracts/models.d.ts +0 -30
  93. package/dist/_contracts/models.js +0 -28
  94. package/dist/_contracts/operation-core.d.ts +0 -36
  95. package/dist/_contracts/operation-core.js +0 -70
  96. package/dist/_contracts/operations.d.ts +0 -218
  97. package/dist/_contracts/operations.js +0 -1496
  98. package/dist/_contracts/otlp-projection.d.ts +0 -78
  99. package/dist/_contracts/otlp-projection.js +0 -171
  100. package/dist/_contracts/post-hook.d.ts +0 -31
  101. package/dist/_contracts/post-hook.js +0 -61
  102. package/dist/_contracts/provider-fault.d.ts +0 -34
  103. package/dist/_contracts/provider-fault.js +0 -68
  104. package/dist/_contracts/retry-core.d.ts +0 -29
  105. package/dist/_contracts/retry-core.js +0 -79
  106. package/dist/_contracts/runner-event.d.ts +0 -117
  107. package/dist/_contracts/runner-event.js +0 -172
  108. package/dist/_contracts/runtime-kind.d.ts +0 -60
  109. package/dist/_contracts/runtime-kind.js +0 -70
  110. package/dist/_contracts/runtime-manifest.d.ts +0 -121
  111. package/dist/_contracts/runtime-manifest.js +0 -83
  112. package/dist/_contracts/runtime-security-profile.d.ts +0 -26
  113. package/dist/_contracts/runtime-security-profile.js +0 -73
  114. package/dist/_contracts/runtime-sizes.d.ts +0 -104
  115. package/dist/_contracts/runtime-sizes.js +0 -111
  116. package/dist/_contracts/runtime-types.d.ts +0 -618
  117. package/dist/_contracts/runtime-types.js +0 -58
  118. package/dist/_contracts/schemas/asset-bundle.d.ts +0 -70
  119. package/dist/_contracts/schemas/asset-bundle.js +0 -107
  120. package/dist/_contracts/schemas/asset-ref.d.ts +0 -61
  121. package/dist/_contracts/schemas/asset-ref.js +0 -118
  122. package/dist/_contracts/schemas/bundle-manifest.d.ts +0 -66
  123. package/dist/_contracts/schemas/bundle-manifest.js +0 -77
  124. package/dist/_contracts/schemas/index.d.ts +0 -32
  125. package/dist/_contracts/schemas/index.js +0 -30
  126. package/dist/_contracts/schemas/mcp-server.d.ts +0 -99
  127. package/dist/_contracts/schemas/mcp-server.js +0 -209
  128. package/dist/_contracts/schemas/models.d.ts +0 -29
  129. package/dist/_contracts/schemas/models.js +0 -51
  130. package/dist/_contracts/schemas/numeric.d.ts +0 -18
  131. package/dist/_contracts/schemas/numeric.js +0 -28
  132. package/dist/_contracts/schemas/post-hook.d.ts +0 -45
  133. package/dist/_contracts/schemas/post-hook.js +0 -68
  134. package/dist/_contracts/schemas/response-assets.d.ts +0 -75
  135. package/dist/_contracts/schemas/response-assets.js +0 -81
  136. package/dist/_contracts/schemas/response-billing.d.ts +0 -208
  137. package/dist/_contracts/schemas/response-billing.js +0 -139
  138. package/dist/_contracts/schemas/response-common.d.ts +0 -132
  139. package/dist/_contracts/schemas/response-common.js +0 -162
  140. package/dist/_contracts/schemas/response-identity.d.ts +0 -648
  141. package/dist/_contracts/schemas/response-identity.js +0 -131
  142. package/dist/_contracts/schemas/response-mcp-servers.d.ts +0 -51
  143. package/dist/_contracts/schemas/response-mcp-servers.js +0 -32
  144. package/dist/_contracts/schemas/response-secrets.d.ts +0 -50
  145. package/dist/_contracts/schemas/response-secrets.js +0 -32
  146. package/dist/_contracts/schemas/response-sessions-internal.d.ts +0 -200
  147. package/dist/_contracts/schemas/response-sessions-internal.js +0 -142
  148. package/dist/_contracts/schemas/response-sessions.d.ts +0 -1598
  149. package/dist/_contracts/schemas/response-sessions.js +0 -377
  150. package/dist/_contracts/schemas/response-webhooks.d.ts +0 -76
  151. package/dist/_contracts/schemas/response-webhooks.js +0 -42
  152. package/dist/_contracts/schemas/response-workspace.d.ts +0 -225
  153. package/dist/_contracts/schemas/response-workspace.js +0 -99
  154. package/dist/_contracts/schemas/runtime-kind.d.ts +0 -31
  155. package/dist/_contracts/schemas/runtime-kind.js +0 -29
  156. package/dist/_contracts/schemas/runtime-security-profile.d.ts +0 -28
  157. package/dist/_contracts/schemas/runtime-security-profile.js +0 -26
  158. package/dist/_contracts/schemas/runtime-sizes.d.ts +0 -70
  159. package/dist/_contracts/schemas/runtime-sizes.js +0 -127
  160. package/dist/_contracts/schemas/session-limits.d.ts +0 -34
  161. package/dist/_contracts/schemas/session-limits.js +0 -39
  162. package/dist/_contracts/schemas/session-machine.d.ts +0 -23
  163. package/dist/_contracts/schemas/session-machine.js +0 -24
  164. package/dist/_contracts/schemas/session-request-config.d.ts +0 -58
  165. package/dist/_contracts/schemas/session-request-config.js +0 -134
  166. package/dist/_contracts/schemas/session-webhook.d.ts +0 -11
  167. package/dist/_contracts/schemas/session-webhook.js +0 -38
  168. package/dist/_contracts/schemas/side-effect-audit.d.ts +0 -98
  169. package/dist/_contracts/schemas/side-effect-audit.js +0 -102
  170. package/dist/_contracts/schemas/submission-assets.d.ts +0 -117
  171. package/dist/_contracts/schemas/submission-assets.js +0 -147
  172. package/dist/_contracts/schemas/submission-body.d.ts +0 -251
  173. package/dist/_contracts/schemas/submission-body.js +0 -378
  174. package/dist/_contracts/schemas/submission-environment.d.ts +0 -79
  175. package/dist/_contracts/schemas/submission-environment.js +0 -179
  176. package/dist/_contracts/schemas/submission-request.d.ts +0 -158
  177. package/dist/_contracts/schemas/submission-request.js +0 -49
  178. package/dist/_contracts/schemas/submission-secrets.d.ts +0 -47
  179. package/dist/_contracts/schemas/submission-secrets.js +0 -108
  180. package/dist/_contracts/schemas/wire.d.ts +0 -118
  181. package/dist/_contracts/schemas/wire.js +0 -171
  182. package/dist/_contracts/schemas/workspace-resources.d.ts +0 -50
  183. package/dist/_contracts/schemas/workspace-resources.js +0 -87
  184. package/dist/_contracts/sdk-errors.d.ts +0 -212
  185. package/dist/_contracts/sdk-errors.js +0 -313
  186. package/dist/_contracts/sdk-secrets.d.ts +0 -67
  187. package/dist/_contracts/sdk-secrets.js +0 -427
  188. package/dist/_contracts/session-archive.d.ts +0 -16
  189. package/dist/_contracts/session-archive.js +0 -92
  190. package/dist/_contracts/session-artifacts.d.ts +0 -189
  191. package/dist/_contracts/session-artifacts.js +0 -264
  192. package/dist/_contracts/session-config.d.ts +0 -373
  193. package/dist/_contracts/session-config.js +0 -562
  194. package/dist/_contracts/session-cost-types.d.ts +0 -211
  195. package/dist/_contracts/session-cost-types.js +0 -69
  196. package/dist/_contracts/session-cost.d.ts +0 -8
  197. package/dist/_contracts/session-cost.js +0 -582
  198. package/dist/_contracts/session-custody.d.ts +0 -165
  199. package/dist/_contracts/session-custody.js +0 -345
  200. package/dist/_contracts/session-file-query.d.ts +0 -14
  201. package/dist/_contracts/session-file-query.js +0 -178
  202. package/dist/_contracts/session-record.d.ts +0 -112
  203. package/dist/_contracts/session-record.js +0 -165
  204. package/dist/_contracts/session-retention.d.ts +0 -201
  205. package/dist/_contracts/session-retention.js +0 -450
  206. package/dist/_contracts/side-effect-audit.d.ts +0 -126
  207. package/dist/_contracts/side-effect-audit.js +0 -520
  208. package/dist/_contracts/sse.d.ts +0 -74
  209. package/dist/_contracts/sse.js +0 -227
  210. package/dist/_contracts/stable.d.ts +0 -45
  211. package/dist/_contracts/stable.js +0 -62
  212. package/dist/_contracts/status.d.ts +0 -25
  213. package/dist/_contracts/status.js +0 -57
  214. package/dist/_contracts/submission-limits.d.ts +0 -61
  215. package/dist/_contracts/submission-limits.js +0 -60
  216. package/dist/_contracts/submission.d.ts +0 -547
  217. package/dist/_contracts/submission.js +0 -812
  218. package/dist/_contracts/suggest.d.ts +0 -15
  219. package/dist/_contracts/suggest.js +0 -53
  220. package/dist/_contracts/testing/response-bindings.d.ts +0 -45
  221. package/dist/_contracts/testing/response-bindings.js +0 -256
  222. package/dist/_contracts/testing/wire-conformance-entry.d.ts +0 -10
  223. package/dist/_contracts/testing/wire-conformance-entry.js +0 -8
  224. package/dist/_contracts/testing/wire-conformance.d.ts +0 -169
  225. package/dist/_contracts/testing/wire-conformance.js +0 -276
  226. package/dist/_contracts/turn-trace.d.ts +0 -28
  227. package/dist/_contracts/turn-trace.js +0 -1
  228. package/dist/_contracts/unknown-field-error.d.ts +0 -13
  229. package/dist/_contracts/unknown-field-error.js +0 -21
  230. package/dist/_contracts/value-guards.d.ts +0 -20
  231. package/dist/_contracts/value-guards.js +0 -34
  232. package/dist/_contracts/webhook-verify.d.ts +0 -34
  233. package/dist/_contracts/webhook-verify.js +0 -93
  234. package/dist/_contracts/wire-observer.d.ts +0 -49
  235. package/dist/_contracts/wire-observer.js +0 -34
  236. package/dist/_contracts/workflow-status.d.ts +0 -7
  237. package/dist/_contracts/workflow-status.js +0 -43
  238. package/dist/_contracts/workspace-resources.d.ts +0 -98
  239. package/dist/_contracts/workspace-resources.js +0 -39
  240. package/dist/archive-limits.d.ts +0 -1
  241. package/dist/archive-limits.js +0 -2
  242. package/dist/archive-limits.js.map +0 -1
  243. package/dist/asset-upload.d.ts +0 -47
  244. package/dist/asset-upload.js +0 -269
  245. package/dist/asset-upload.js.map +0 -1
  246. package/dist/bundle.d.ts +0 -9
  247. package/dist/bundle.js +0 -20
  248. package/dist/bundle.js.map +0 -1
  249. package/dist/canonical-zip.d.ts +0 -68
  250. package/dist/canonical-zip.js +0 -355
  251. package/dist/canonical-zip.js.map +0 -1
  252. package/dist/cli.mjs +0 -12048
  253. package/dist/cli.mjs.sha256 +0 -1
  254. package/dist/client-types.d.ts +0 -192
  255. package/dist/client-types.js +0 -2
  256. package/dist/client-types.js.map +0 -1
  257. package/dist/client.d.ts +0 -464
  258. package/dist/client.js +0 -1207
  259. package/dist/client.js.map +0 -1
  260. package/dist/event-projection.d.ts +0 -22
  261. package/dist/event-projection.js +0 -380
  262. package/dist/event-projection.js.map +0 -1
  263. package/dist/fetch-archive.d.ts +0 -16
  264. package/dist/fetch-archive.js +0 -252
  265. package/dist/fetch-archive.js.map +0 -1
  266. package/dist/file.d.ts +0 -96
  267. package/dist/file.js +0 -272
  268. package/dist/file.js.map +0 -1
  269. package/dist/instructions.d.ts +0 -20
  270. package/dist/instructions.js +0 -40
  271. package/dist/instructions.js.map +0 -1
  272. package/dist/legacy-session-provider-fault.d.ts +0 -7
  273. package/dist/legacy-session-provider-fault.js +0 -38
  274. package/dist/legacy-session-provider-fault.js.map +0 -1
  275. package/dist/mcp-server.d.ts +0 -84
  276. package/dist/mcp-server.js +0 -117
  277. package/dist/mcp-server.js.map +0 -1
  278. package/dist/node-fs.d.ts +0 -29
  279. package/dist/node-fs.js +0 -19
  280. package/dist/node-fs.js.map +0 -1
  281. package/dist/node-walk.d.ts +0 -69
  282. package/dist/node-walk.js +0 -151
  283. package/dist/node-walk.js.map +0 -1
  284. package/dist/path-basename.d.ts +0 -5
  285. package/dist/path-basename.js +0 -9
  286. package/dist/path-basename.js.map +0 -1
  287. package/dist/retry.d.ts +0 -70
  288. package/dist/retry.js +0 -155
  289. package/dist/retry.js.map +0 -1
  290. package/dist/secret.d.ts +0 -65
  291. package/dist/secret.js +0 -110
  292. package/dist/secret.js.map +0 -1
  293. package/dist/session-validate.d.ts +0 -100
  294. package/dist/session-validate.js +0 -303
  295. package/dist/session-validate.js.map +0 -1
  296. package/dist/skill.d.ts +0 -99
  297. package/dist/skill.js +0 -169
  298. package/dist/skill.js.map +0 -1
  299. package/dist/submission-wire.d.ts +0 -13
  300. package/dist/submission-wire.js +0 -69
  301. package/dist/submission-wire.js.map +0 -1
  302. package/dist/tool.d.ts +0 -41
  303. package/dist/tool.js +0 -76
  304. package/dist/tool.js.map +0 -1
  305. package/dist/version.d.ts +0 -9
  306. package/dist/version.js +0 -10
  307. package/dist/version.js.map +0 -1
  308. package/docs/authentication.md +0 -125
  309. package/docs/billing.md +0 -164
  310. package/docs/cleanup.md +0 -27
  311. package/docs/concepts/agent-tools.md +0 -47
  312. package/docs/concepts/composition.md +0 -60
  313. package/docs/concepts/providers-and-runtimes.md +0 -121
  314. package/docs/concepts/sessions.md +0 -51
  315. package/docs/concepts/subagents.md +0 -35
  316. package/docs/credentials.md +0 -116
  317. package/docs/defaults.md +0 -51
  318. package/docs/errors.md +0 -258
  319. package/docs/events.md +0 -143
  320. package/docs/files.md +0 -130
  321. package/docs/limits-and-quotas.md +0 -114
  322. package/docs/limits.md +0 -51
  323. package/docs/mcp.md +0 -47
  324. package/docs/networking.md +0 -114
  325. package/docs/provider-runtime-capabilities.md +0 -32
  326. package/docs/public-surface.json +0 -73
  327. package/docs/quickstart.md +0 -135
  328. package/docs/release.md +0 -44
  329. package/docs/retries.md +0 -108
  330. package/docs/secrets.md +0 -141
  331. package/docs/session-config.md +0 -51
  332. package/docs/session-record.md +0 -58
  333. package/docs/skills.md +0 -65
  334. package/docs/telemetry.md +0 -66
  335. package/docs/testing.md +0 -35
  336. package/docs/vision-skills.md +0 -94
  337. package/docs/webhooks.md +0 -143
@@ -1,227 +0,0 @@
1
- /**
2
- * Tiny SSE (text/event-stream) parser used by the SDK / CLI to consume
3
- * the dashboard's `/api/sessions/:id/events/stream` endpoint without
4
- * pulling in a DOM `EventSource` dependency. Node's `fetch` returns a
5
- * web `ReadableStream<Uint8Array>` body; this parser turns that into
6
- * an async iterable of `SseFrame`s.
7
- *
8
- * The wire grammar follows the WHATWG HTML spec § Server-sent events:
9
- *
10
- * - Lines are separated by `\n`, `\r`, or `\r\n`.
11
- * - A `:` prefix marks a comment — ignored.
12
- * - `field: value` (or `field:value`, with no space) — leading space
13
- * after the colon is stripped.
14
- * - Recognised fields: `event`, `data`, `id`, `retry`.
15
- * - Multiple `data:` lines join with `\n`.
16
- * - A blank line dispatches the current frame and resets the buffer.
17
- * - `event:` defaults to `"message"` when absent.
18
- *
19
- * The parser is deliberately a free function so it can be unit-tested
20
- * against synthesized chunk boundaries (one byte at a time, mid-frame,
21
- * across UTF-8 multi-byte sequences) without spinning up a real
22
- * connection.
23
- */
24
- /**
25
- * Stateful parser: feed in chunks (in any size), pull out completed
26
- * frames. Designed for `for await` consumption — see `iterateSse`.
27
- */
28
- export class SseParser {
29
- #buffer = "";
30
- #decoder = new TextDecoder("utf-8");
31
- #eventType = "";
32
- #dataLines = [];
33
- #lastEventId;
34
- #retry;
35
- /**
36
- * Push a chunk of raw bytes through the parser. Returns any frames
37
- * that completed during this chunk. Chunks may contain zero, one,
38
- * or many frame boundaries — the parser handles partial trailing
39
- * data internally.
40
- */
41
- pushBytes(chunk) {
42
- return this.pushText(this.#decoder.decode(chunk, { stream: true }));
43
- }
44
- /**
45
- * Push a text chunk directly. Used by the parser tests so they can
46
- * exercise byte-boundary edge cases without manufacturing a
47
- * `TextDecoder` round-trip.
48
- */
49
- pushText(text) {
50
- this.#buffer += text;
51
- const frames = [];
52
- let idx;
53
- // SSE accepts \n, \r\n, or \r as the line terminator. Normalize by
54
- // splitting on any of them — but only split on a complete line
55
- // (we leave trailing partial bytes in the buffer).
56
- while ((idx = findLineBreak(this.#buffer)) !== -1) {
57
- const line = this.#buffer.slice(0, idx);
58
- // A trailing CR may be the first half of a CRLF split across chunks.
59
- // A blank trailing CR can dispatch immediately without splitting data.
60
- if (this.#buffer[idx] === "\r" && idx === this.#buffer.length - 1 && line.length > 0)
61
- break;
62
- const skip = this.#buffer[idx] === "\r" && this.#buffer[idx + 1] === "\n" ? 2 : 1;
63
- this.#buffer = this.#buffer.slice(idx + skip);
64
- const frame = this.#consumeLine(line);
65
- if (frame)
66
- frames.push(frame);
67
- }
68
- return frames;
69
- }
70
- /**
71
- * Indicate end-of-stream. Returns any final frame that the dispatcher
72
- * was holding when the stream closed mid-frame (no trailing blank
73
- * line). The dispatcher pattern is: blank line dispatches; if the
74
- * remote closes after a partial frame, that frame is dropped per the
75
- * spec.
76
- */
77
- flush() {
78
- // No-op for now — partial frames are discarded per spec. Kept as
79
- // an extension point in case callers want a "soft flush" later.
80
- }
81
- #consumeLine(line) {
82
- if (line.length === 0) {
83
- // Blank line → dispatch the current frame.
84
- return this.#dispatch();
85
- }
86
- if (line.startsWith(":")) {
87
- // Comment — ignored.
88
- return null;
89
- }
90
- const colonIdx = line.indexOf(":");
91
- let field;
92
- let value;
93
- if (colonIdx === -1) {
94
- field = line;
95
- value = "";
96
- }
97
- else {
98
- field = line.slice(0, colonIdx);
99
- value = line.slice(colonIdx + 1);
100
- if (value.startsWith(" "))
101
- value = value.slice(1);
102
- }
103
- switch (field) {
104
- case "event":
105
- this.#eventType = value;
106
- break;
107
- case "data":
108
- this.#dataLines.push(value);
109
- break;
110
- case "id":
111
- // Per spec: empty id sets last id to empty string; ids
112
- // containing U+0000 are ignored. We adopt the simple
113
- // policy and just store the verbatim value.
114
- if (!value.includes("\0")) {
115
- this.#lastEventId = value;
116
- }
117
- break;
118
- case "retry": {
119
- const parsed = Number.parseInt(value, 10);
120
- if (Number.isFinite(parsed) && parsed >= 0)
121
- this.#retry = parsed;
122
- break;
123
- }
124
- default:
125
- // Unknown field — ignored per spec.
126
- break;
127
- }
128
- return null;
129
- }
130
- #dispatch() {
131
- if (this.#dataLines.length === 0 && this.#eventType === "") {
132
- // Nothing to dispatch — a blank line on its own resets nothing.
133
- return null;
134
- }
135
- const data = this.#dataLines.join("\n");
136
- const event = this.#eventType === "" ? "message" : this.#eventType;
137
- const frame = {
138
- event,
139
- data,
140
- ...(this.#lastEventId !== undefined ? { id: this.#lastEventId } : {}),
141
- ...(this.#retry !== undefined ? { retry: this.#retry } : {})
142
- };
143
- // Reset per-frame state. `lastEventId` and `retry` PERSIST across
144
- // frames per spec — they are connection-level, not frame-level.
145
- this.#eventType = "";
146
- this.#dataLines = [];
147
- this.#retry = undefined;
148
- return frame;
149
- }
150
- /**
151
- * Current "last event id" — the cursor the SSE spec instructs the
152
- * client to replay on automatic reconnection. Callers use this to
153
- * resume after a disconnect.
154
- */
155
- get lastEventId() {
156
- return this.#lastEventId;
157
- }
158
- }
159
- /**
160
- * Convert a web `ReadableStream<Uint8Array>` (the body of a fetch
161
- * Response) into an async iterable of SSE frames. The stream is
162
- * consumed exactly once; the caller is responsible for cancelling
163
- * the underlying reader on abort.
164
- *
165
- * The reader is raced against the abort signal so a long-blocked
166
- * server (no chunks for many seconds) still releases the loop
167
- * promptly when the consumer aborts.
168
- */
169
- export async function* iterateSse(body, signal) {
170
- const reader = body.getReader();
171
- const parser = new SseParser();
172
- const ABORT_SENTINEL = Symbol("aborted");
173
- try {
174
- while (true) {
175
- if (signal?.aborted)
176
- return;
177
- const readPromise = reader.read();
178
- let result;
179
- if (signal) {
180
- result = await Promise.race([
181
- readPromise,
182
- new Promise((resolve) => {
183
- const onAbort = () => resolve(ABORT_SENTINEL);
184
- if (signal.aborted) {
185
- resolve(ABORT_SENTINEL);
186
- return;
187
- }
188
- signal.addEventListener("abort", onAbort, { once: true });
189
- })
190
- ]);
191
- }
192
- else {
193
- result = await readPromise;
194
- }
195
- if (result === ABORT_SENTINEL)
196
- return;
197
- if (result.done) {
198
- parser.flush();
199
- return;
200
- }
201
- const value = result.value;
202
- if (!value)
203
- continue;
204
- const frames = parser.pushBytes(value);
205
- for (const frame of frames) {
206
- yield frame;
207
- }
208
- }
209
- }
210
- finally {
211
- try {
212
- await reader.cancel();
213
- }
214
- catch {
215
- // Cancel can throw if the stream is already closed — ignore.
216
- }
217
- }
218
- }
219
- function findLineBreak(buffer) {
220
- // Returns the index of the first \n or \r in `buffer`, or -1.
221
- for (let i = 0; i < buffer.length; i++) {
222
- const code = buffer.charCodeAt(i);
223
- if (code === 0x0a || code === 0x0d)
224
- return i;
225
- }
226
- return -1;
227
- }
@@ -1,45 +0,0 @@
1
- /**
2
- * Canonical hosted aex API plane URL. Used as the default `baseUrl`
3
- * for the SDK `Aex` client and the host-side CLI `--aex-url`
4
- * flag.
5
- *
6
- * Pinned to `api.aex.dev` on purpose: the dashboard at
7
- * `aex.dev` is the human UX surface, while `api.aex.dev`
8
- * owns the runtime/API plane (session submission, provider proxy, MCP
9
- * proxy, runner callbacks). Both the apex `aex.dev` and `www.` host
10
- * may issue redirects, and HTTP clients strip the `Authorization`
11
- * header on cross-origin redirects (WHATWG Fetch §5.5) — hitting them
12
- * would make authenticated calls land as 401s. Always go direct to
13
- * the API plane.
14
- *
15
- * A single canonical default is not a "footnote mode" — it is the
16
- * canonical product. Self-hosted deployments override via the
17
- * explicit `baseUrl` / `--aex-url` parameter. The value lives in
18
- * source (no env-var override) so the agent reading the SDK call site
19
- * can see exactly where the call goes.
20
- *
21
- * Kept in source with no env-var override so callers and agents can see the
22
- * exact default API plane.
23
- */
24
- export declare const AEX_DEFAULT_BASE_URL = "https://api.aex.dev";
25
- /**
26
- * Canonical hosted dev API plane URL. Used when a self-describing dev API key is
27
- * passed with no explicit `baseUrl`.
28
- */
29
- export declare const AEX_DEV_BASE_URL = "https://dev-api.aex.dev";
30
- /**
31
- * Plane → API base URL. When the SDK constructor is given no explicit `baseUrl`
32
- * it DERIVES the target from the API key's embedded plane (see
33
- * {@link import("./api-key.js").parseApiKey}) rather than blindly defaulting to
34
- * prod — so a dev key routes to `dev-api.aex.dev` and a prd key routes to
35
- * `api.aex.dev`.
36
- *
37
- * The plane-mismatch guard still fires when a key is pointed at the wrong
38
- * canonical host (for example, a dev key with `baseUrl=https://api.aex.dev`).
39
- */
40
- export declare const PLANE_BASE_URLS: {
41
- readonly dev: "https://dev-api.aex.dev";
42
- readonly prd: "https://api.aex.dev";
43
- };
44
- export declare function stableStringify(value: unknown): string;
45
- export declare function sha256(value: unknown): string;
@@ -1,62 +0,0 @@
1
- import { createHash } from "node:crypto";
2
- /**
3
- * Canonical hosted aex API plane URL. Used as the default `baseUrl`
4
- * for the SDK `Aex` client and the host-side CLI `--aex-url`
5
- * flag.
6
- *
7
- * Pinned to `api.aex.dev` on purpose: the dashboard at
8
- * `aex.dev` is the human UX surface, while `api.aex.dev`
9
- * owns the runtime/API plane (session submission, provider proxy, MCP
10
- * proxy, runner callbacks). Both the apex `aex.dev` and `www.` host
11
- * may issue redirects, and HTTP clients strip the `Authorization`
12
- * header on cross-origin redirects (WHATWG Fetch §5.5) — hitting them
13
- * would make authenticated calls land as 401s. Always go direct to
14
- * the API plane.
15
- *
16
- * A single canonical default is not a "footnote mode" — it is the
17
- * canonical product. Self-hosted deployments override via the
18
- * explicit `baseUrl` / `--aex-url` parameter. The value lives in
19
- * source (no env-var override) so the agent reading the SDK call site
20
- * can see exactly where the call goes.
21
- *
22
- * Kept in source with no env-var override so callers and agents can see the
23
- * exact default API plane.
24
- */
25
- export const AEX_DEFAULT_BASE_URL = "https://api.aex.dev";
26
- /**
27
- * Canonical hosted dev API plane URL. Used when a self-describing dev API key is
28
- * passed with no explicit `baseUrl`.
29
- */
30
- export const AEX_DEV_BASE_URL = "https://dev-api.aex.dev";
31
- /**
32
- * Plane → API base URL. When the SDK constructor is given no explicit `baseUrl`
33
- * it DERIVES the target from the API key's embedded plane (see
34
- * {@link import("./api-key.js").parseApiKey}) rather than blindly defaulting to
35
- * prod — so a dev key routes to `dev-api.aex.dev` and a prd key routes to
36
- * `api.aex.dev`.
37
- *
38
- * The plane-mismatch guard still fires when a key is pointed at the wrong
39
- * canonical host (for example, a dev key with `baseUrl=https://api.aex.dev`).
40
- */
41
- export const PLANE_BASE_URLS = {
42
- dev: AEX_DEV_BASE_URL,
43
- prd: AEX_DEFAULT_BASE_URL
44
- };
45
- export function stableStringify(value) {
46
- return JSON.stringify(sortValue(value));
47
- }
48
- export function sha256(value) {
49
- return createHash("sha256").update(typeof value === "string" ? value : stableStringify(value)).digest("hex");
50
- }
51
- function sortValue(value) {
52
- if (Array.isArray(value)) {
53
- return value.map(sortValue);
54
- }
55
- if (value && typeof value === "object") {
56
- return Object.fromEntries(Object.entries(value)
57
- .filter(([, item]) => item !== undefined)
58
- .sort(([a], [b]) => a.localeCompare(b))
59
- .map(([key, item]) => [key, sortValue(item)]));
60
- }
61
- return value;
62
- }
@@ -1,25 +0,0 @@
1
- /**
2
- * The RESUMABLE / in-flight lifecycle half of a session's status. A session
3
- * whose status is one of these is either transitioning, parked and resumable,
4
- * or being removed. A prior run's verdict is not projected into this field;
5
- * read `lastRun.outcome` or the terminal RUN event instead. In particular,
6
- * `error` means the most recent run failed while the thread remains resumable.
7
- */
8
- export declare const SESSION_LIFECYCLE_STATUSES: readonly ["creating", "running", "idle", "suspending", "suspended", "awaiting_approval", "error", "cancelling", "deleting", "deleted", "expired"];
9
- export type SessionLifecycleStatus = typeof SESSION_LIFECYCLE_STATUSES[number];
10
- /**
11
- * Terminal RUN outcomes. These describe a completed run, not the lifecycle
12
- * status of its resumable session thread.
13
- */
14
- export declare const SESSION_TERMINAL_OUTCOMES: readonly ["succeeded", "failed", "timed_out", "cancelled", "interrupted"];
15
- export type SessionTerminalOutcome = typeof SESSION_TERMINAL_OUTCOMES[number];
16
- /**
17
- * The full closed set of session lifecycle statuses. Run outcomes deliberately
18
- * remain separate so a resumable session never reports `succeeded`/`failed`.
19
- */
20
- export declare const SESSION_STATUSES: readonly ["creating", "running", "idle", "suspending", "suspended", "awaiting_approval", "error", "cancelling", "deleting", "deleted", "expired"];
21
- export type SessionStatus = SessionLifecycleStatus;
22
- /** True when a session thread has been deleted or expired. */
23
- export declare function isTerminalSessionStatus(status: SessionStatus): boolean;
24
- export declare const CLEANUP_STATUSES: readonly ["not_started", "pending", "running", "succeeded", "failed_retryable", "failed_terminal", "skipped"];
25
- export type CleanupStatus = typeof CLEANUP_STATUSES[number];
@@ -1,57 +0,0 @@
1
- /**
2
- * The RESUMABLE / in-flight lifecycle half of a session's status. A session
3
- * whose status is one of these is either transitioning, parked and resumable,
4
- * or being removed. A prior run's verdict is not projected into this field;
5
- * read `lastRun.outcome` or the terminal RUN event instead. In particular,
6
- * `error` means the most recent run failed while the thread remains resumable.
7
- */
8
- export const SESSION_LIFECYCLE_STATUSES = [
9
- "creating",
10
- "running",
11
- "idle",
12
- "suspending",
13
- "suspended",
14
- "awaiting_approval",
15
- "error",
16
- "cancelling",
17
- "deleting",
18
- "deleted",
19
- "expired"
20
- ];
21
- /**
22
- * Terminal RUN outcomes. These describe a completed run, not the lifecycle
23
- * status of its resumable session thread.
24
- */
25
- export const SESSION_TERMINAL_OUTCOMES = [
26
- "succeeded",
27
- "failed",
28
- "timed_out",
29
- "cancelled",
30
- "interrupted"
31
- ];
32
- /**
33
- * The full closed set of session lifecycle statuses. Run outcomes deliberately
34
- * remain separate so a resumable session never reports `succeeded`/`failed`.
35
- */
36
- export const SESSION_STATUSES = SESSION_LIFECYCLE_STATUSES;
37
- /**
38
- * Only removal makes a session thread terminal. Run outcomes are intentionally
39
- * not session statuses.
40
- */
41
- const SESSION_TERMINAL_STATUSES = new Set([
42
- "deleted",
43
- "expired"
44
- ]);
45
- /** True when a session thread has been deleted or expired. */
46
- export function isTerminalSessionStatus(status) {
47
- return SESSION_TERMINAL_STATUSES.has(status);
48
- }
49
- export const CLEANUP_STATUSES = [
50
- "not_started",
51
- "pending",
52
- "running",
53
- "succeeded",
54
- "failed_retryable",
55
- "failed_terminal",
56
- "skipped"
57
- ];
@@ -1,61 +0,0 @@
1
- /**
2
- * Bounds and patterns the submission schemas enforce.
3
- *
4
- * A leaf module with no imports. It exists so `schemas/submission-environment.ts`
5
- * can read these without importing `submission.ts`, which imports the schema
6
- * back — a cycle that would leave the constants `undefined` at the moment the
7
- * schemas are constructed at module load.
8
- *
9
- * `submission.ts` re-exports every public name from here, so the published
10
- * surface is unchanged.
11
- */
12
- /**
13
- * Reserved prefix for aex-set runtime env vars (`AEX_CLI`,
14
- * `AEX_RUNTIME_JSON`, …). Customer `environment.envVars` keys carrying this
15
- * prefix are rejected at submission parse time so platform-set values
16
- * cannot be silently overwritten.
17
- */
18
- export declare const AEX_RESERVED_ENV_PREFIX = "AEX_";
19
- /**
20
- * Maximum number of `environment.envVars` entries accepted per
21
- * submission. Picked to be generous for real customer config bags
22
- * (the broll case ships a handful — `BROLL_STORE`, `BROLL_OUTPUTS`,
23
- * `BROLL_MODE`, …) while still bounding the size of every RUNTIME
24
- * file we mount into the container.
25
- */
26
- export declare const ENV_VARS_MAX_ENTRIES = 64;
27
- /** Maximum byte length of a single `environment.envVars` value. */
28
- export declare const ENV_VARS_MAX_VALUE_BYTES = 4096;
29
- /** Maximum total byte length of all `environment.envVars` keys+values combined. */
30
- export declare const ENV_VARS_MAX_TOTAL_BYTES = 65536;
31
- /**
32
- * POSIX-shell-portable env var key: starts with `A-Z` or `_`, body is
33
- * `A-Z`, `0-9`, `_`. We deliberately reject lowercase to keep
34
- * `RUNTIME.env` readable and consistent with platform conventions; if
35
- * a customer has lowercase keys today, they uppercase them at the
36
- * call site.
37
- */
38
- export declare const ENV_VAR_KEY_PATTERN: RegExp;
39
- /**
40
- * Package-manager ecosystems accepted by the public submission schema.
41
- * The customer encodes the target manager as a `name` prefix
42
- * `"<eco>:<pkg>"` (e.g. "pip:pandas", "npm:express", "apt:ffmpeg"); an
43
- * UNPREFIXED name defaults to `apt`. After parsing, `PlatformPackage.name`
44
- * is the bare package and `PlatformPackage.ecosystem` is the resolved
45
- * manager.
46
- */
47
- export declare const PLATFORM_PACKAGE_ECOSYSTEMS: readonly ["apt", "npm", "pip"];
48
- export type PlatformPackageEcosystem = (typeof PLATFORM_PACKAGE_ECOSYSTEMS)[number];
49
- /** POSIX-style env var name a `secretEnv` entry binds to (e.g. `SERPER_API_KEY`). */
50
- export declare const SECRET_ENV_NAME_PATTERN: RegExp;
51
- /**
52
- * Workspace secret handle a `secretEnv` ref points at (and the name
53
- * `secret.upload` persists to).
54
- */
55
- export declare const SECRET_HANDLE_PATTERN: RegExp;
56
- /**
57
- * Namespace reserved for platform-set values inside the secrets channel. A
58
- * caller-supplied key carrying it is rejected with its own message rather than
59
- * the generic unknown-field one, so the reason is legible.
60
- */
61
- export declare const PLATFORM_INTERNAL_SECRET_PREFIX = "__aex_";
@@ -1,60 +0,0 @@
1
- /**
2
- * Bounds and patterns the submission schemas enforce.
3
- *
4
- * A leaf module with no imports. It exists so `schemas/submission-environment.ts`
5
- * can read these without importing `submission.ts`, which imports the schema
6
- * back — a cycle that would leave the constants `undefined` at the moment the
7
- * schemas are constructed at module load.
8
- *
9
- * `submission.ts` re-exports every public name from here, so the published
10
- * surface is unchanged.
11
- */
12
- /**
13
- * Reserved prefix for aex-set runtime env vars (`AEX_CLI`,
14
- * `AEX_RUNTIME_JSON`, …). Customer `environment.envVars` keys carrying this
15
- * prefix are rejected at submission parse time so platform-set values
16
- * cannot be silently overwritten.
17
- */
18
- export const AEX_RESERVED_ENV_PREFIX = "AEX_";
19
- /**
20
- * Maximum number of `environment.envVars` entries accepted per
21
- * submission. Picked to be generous for real customer config bags
22
- * (the broll case ships a handful — `BROLL_STORE`, `BROLL_OUTPUTS`,
23
- * `BROLL_MODE`, …) while still bounding the size of every RUNTIME
24
- * file we mount into the container.
25
- */
26
- export const ENV_VARS_MAX_ENTRIES = 64;
27
- /** Maximum byte length of a single `environment.envVars` value. */
28
- export const ENV_VARS_MAX_VALUE_BYTES = 4096;
29
- /** Maximum total byte length of all `environment.envVars` keys+values combined. */
30
- export const ENV_VARS_MAX_TOTAL_BYTES = 65536;
31
- /**
32
- * POSIX-shell-portable env var key: starts with `A-Z` or `_`, body is
33
- * `A-Z`, `0-9`, `_`. We deliberately reject lowercase to keep
34
- * `RUNTIME.env` readable and consistent with platform conventions; if
35
- * a customer has lowercase keys today, they uppercase them at the
36
- * call site.
37
- */
38
- export const ENV_VAR_KEY_PATTERN = /^[A-Z_][A-Z0-9_]*$/;
39
- /**
40
- * Package-manager ecosystems accepted by the public submission schema.
41
- * The customer encodes the target manager as a `name` prefix
42
- * `"<eco>:<pkg>"` (e.g. "pip:pandas", "npm:express", "apt:ffmpeg"); an
43
- * UNPREFIXED name defaults to `apt`. After parsing, `PlatformPackage.name`
44
- * is the bare package and `PlatformPackage.ecosystem` is the resolved
45
- * manager.
46
- */
47
- export const PLATFORM_PACKAGE_ECOSYSTEMS = ["apt", "npm", "pip"];
48
- /** POSIX-style env var name a `secretEnv` entry binds to (e.g. `SERPER_API_KEY`). */
49
- export const SECRET_ENV_NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_]{0,127}$/;
50
- /**
51
- * Workspace secret handle a `secretEnv` ref points at (and the name
52
- * `secret.upload` persists to).
53
- */
54
- export const SECRET_HANDLE_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
55
- /**
56
- * Namespace reserved for platform-set values inside the secrets channel. A
57
- * caller-supplied key carrying it is rejected with its own message rather than
58
- * the generic unknown-field one, so the reason is legible.
59
- */
60
- export const PLATFORM_INTERNAL_SECRET_PREFIX = "__aex_";