@aexhq/sdk 0.46.5-canary → 0.51.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 (346) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +38 -0
  3. package/README.md +54 -29
  4. package/dist/client/aex.d.ts +33 -0
  5. package/dist/client/aex.js +108 -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 +18 -0
  14. package/dist/downloads/download.js +67 -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 +82 -0
  18. package/dist/generated/errors.js.map +1 -0
  19. package/dist/generated/models.d.ts +1392 -0
  20. package/dist/generated/models.js +62 -0
  21. package/dist/generated/models.js.map +1 -0
  22. package/dist/generated/resources.d.ts +710 -0
  23. package/dist/generated/resources.js +582 -0
  24. package/dist/generated/resources.js.map +1 -0
  25. package/dist/generated/routes.d.ts +44 -0
  26. package/dist/generated/routes.js +1905 -0
  27. package/dist/generated/routes.js.map +1 -0
  28. package/dist/index.d.ts +21 -50
  29. package/dist/index.js +14 -62
  30. package/dist/index.js.map +1 -1
  31. package/dist/node/session-file-limits.d.ts +4 -0
  32. package/dist/node/session-file-limits.js +7 -0
  33. package/dist/node/session-file-limits.js.map +1 -0
  34. package/dist/node/session-files.d.ts +80 -0
  35. package/dist/node/session-files.js +254 -0
  36. package/dist/node/session-files.js.map +1 -0
  37. package/dist/observations/stream.d.ts +1 -0
  38. package/dist/observations/stream.js +18 -0
  39. package/dist/observations/stream.js.map +1 -0
  40. package/dist/transport/errors.d.ts +60 -0
  41. package/dist/transport/errors.js +107 -0
  42. package/dist/transport/errors.js.map +1 -0
  43. package/dist/transport/pagination.d.ts +8 -0
  44. package/dist/transport/pagination.js +34 -0
  45. package/dist/transport/pagination.js.map +1 -0
  46. package/dist/transport/retry.d.ts +21 -0
  47. package/dist/transport/retry.js +37 -0
  48. package/dist/transport/retry.js.map +1 -0
  49. package/dist/transport/transport.d.ts +25 -0
  50. package/dist/transport/transport.js +33 -0
  51. package/dist/transport/transport.js.map +1 -0
  52. package/package.json +67 -30
  53. package/dist/_contracts/account-operations.d.ts +0 -101
  54. package/dist/_contracts/account-operations.js +0 -242
  55. package/dist/_contracts/account-types.d.ts +0 -461
  56. package/dist/_contracts/account-types.js +0 -1
  57. package/dist/_contracts/api-key.d.ts +0 -61
  58. package/dist/_contracts/api-key.js +0 -101
  59. package/dist/_contracts/api-routes.d.ts +0 -20
  60. package/dist/_contracts/api-routes.js +0 -109
  61. package/dist/_contracts/archive-limits.d.ts +0 -3
  62. package/dist/_contracts/archive-limits.js +0 -23
  63. package/dist/_contracts/asset-authoring.d.ts +0 -22
  64. package/dist/_contracts/asset-authoring.js +0 -106
  65. package/dist/_contracts/asset-bundle.d.ts +0 -64
  66. package/dist/_contracts/asset-bundle.js +0 -263
  67. package/dist/_contracts/asset-upload-helper.d.ts +0 -31
  68. package/dist/_contracts/asset-upload-helper.js +0 -84
  69. package/dist/_contracts/billing-admission.d.ts +0 -29
  70. package/dist/_contracts/billing-admission.js +0 -28
  71. package/dist/_contracts/bundle-manifest.d.ts +0 -89
  72. package/dist/_contracts/bundle-manifest.js +0 -158
  73. package/dist/_contracts/canonical-sha256.d.ts +0 -8
  74. package/dist/_contracts/canonical-sha256.js +0 -8
  75. package/dist/_contracts/connection-ticket.d.ts +0 -22
  76. package/dist/_contracts/connection-ticket.js +0 -54
  77. package/dist/_contracts/continuation-event.d.ts +0 -31
  78. package/dist/_contracts/continuation-event.js +0 -6
  79. package/dist/_contracts/contract-parse-error.d.ts +0 -12
  80. package/dist/_contracts/contract-parse-error.js +0 -51
  81. package/dist/_contracts/error-codes.d.ts +0 -26
  82. package/dist/_contracts/error-codes.js +0 -116
  83. package/dist/_contracts/error-factory.d.ts +0 -32
  84. package/dist/_contracts/error-factory.js +0 -174
  85. package/dist/_contracts/event-envelope.d.ts +0 -471
  86. package/dist/_contracts/event-envelope.js +0 -501
  87. package/dist/_contracts/event-stream-client.d.ts +0 -122
  88. package/dist/_contracts/event-stream-client.js +0 -445
  89. package/dist/_contracts/event-view.d.ts +0 -44
  90. package/dist/_contracts/event-view.js +0 -69
  91. package/dist/_contracts/failure-class.d.ts +0 -29
  92. package/dist/_contracts/failure-class.js +0 -73
  93. package/dist/_contracts/http.d.ts +0 -135
  94. package/dist/_contracts/http.js +0 -434
  95. package/dist/_contracts/ids.d.ts +0 -66
  96. package/dist/_contracts/ids.js +0 -119
  97. package/dist/_contracts/index.d.ts +0 -42
  98. package/dist/_contracts/index.js +0 -52
  99. package/dist/_contracts/internal.d.ts +0 -55
  100. package/dist/_contracts/internal.js +0 -113
  101. package/dist/_contracts/models.d.ts +0 -30
  102. package/dist/_contracts/models.js +0 -28
  103. package/dist/_contracts/operation-core.d.ts +0 -36
  104. package/dist/_contracts/operation-core.js +0 -70
  105. package/dist/_contracts/operations.d.ts +0 -218
  106. package/dist/_contracts/operations.js +0 -1496
  107. package/dist/_contracts/otlp-projection.d.ts +0 -78
  108. package/dist/_contracts/otlp-projection.js +0 -171
  109. package/dist/_contracts/post-hook.d.ts +0 -31
  110. package/dist/_contracts/post-hook.js +0 -61
  111. package/dist/_contracts/provider-fault.d.ts +0 -34
  112. package/dist/_contracts/provider-fault.js +0 -68
  113. package/dist/_contracts/retry-core.d.ts +0 -29
  114. package/dist/_contracts/retry-core.js +0 -79
  115. package/dist/_contracts/runner-event.d.ts +0 -117
  116. package/dist/_contracts/runner-event.js +0 -172
  117. package/dist/_contracts/runtime-kind.d.ts +0 -60
  118. package/dist/_contracts/runtime-kind.js +0 -70
  119. package/dist/_contracts/runtime-manifest.d.ts +0 -121
  120. package/dist/_contracts/runtime-manifest.js +0 -83
  121. package/dist/_contracts/runtime-security-profile.d.ts +0 -26
  122. package/dist/_contracts/runtime-security-profile.js +0 -73
  123. package/dist/_contracts/runtime-sizes.d.ts +0 -104
  124. package/dist/_contracts/runtime-sizes.js +0 -111
  125. package/dist/_contracts/runtime-types.d.ts +0 -618
  126. package/dist/_contracts/runtime-types.js +0 -58
  127. package/dist/_contracts/schemas/asset-bundle.d.ts +0 -70
  128. package/dist/_contracts/schemas/asset-bundle.js +0 -107
  129. package/dist/_contracts/schemas/asset-ref.d.ts +0 -61
  130. package/dist/_contracts/schemas/asset-ref.js +0 -118
  131. package/dist/_contracts/schemas/bundle-manifest.d.ts +0 -66
  132. package/dist/_contracts/schemas/bundle-manifest.js +0 -77
  133. package/dist/_contracts/schemas/index.d.ts +0 -32
  134. package/dist/_contracts/schemas/index.js +0 -30
  135. package/dist/_contracts/schemas/mcp-server.d.ts +0 -99
  136. package/dist/_contracts/schemas/mcp-server.js +0 -209
  137. package/dist/_contracts/schemas/models.d.ts +0 -29
  138. package/dist/_contracts/schemas/models.js +0 -51
  139. package/dist/_contracts/schemas/numeric.d.ts +0 -18
  140. package/dist/_contracts/schemas/numeric.js +0 -28
  141. package/dist/_contracts/schemas/post-hook.d.ts +0 -45
  142. package/dist/_contracts/schemas/post-hook.js +0 -68
  143. package/dist/_contracts/schemas/response-assets.d.ts +0 -75
  144. package/dist/_contracts/schemas/response-assets.js +0 -81
  145. package/dist/_contracts/schemas/response-billing.d.ts +0 -208
  146. package/dist/_contracts/schemas/response-billing.js +0 -139
  147. package/dist/_contracts/schemas/response-common.d.ts +0 -132
  148. package/dist/_contracts/schemas/response-common.js +0 -162
  149. package/dist/_contracts/schemas/response-identity.d.ts +0 -648
  150. package/dist/_contracts/schemas/response-identity.js +0 -131
  151. package/dist/_contracts/schemas/response-mcp-servers.d.ts +0 -51
  152. package/dist/_contracts/schemas/response-mcp-servers.js +0 -32
  153. package/dist/_contracts/schemas/response-secrets.d.ts +0 -50
  154. package/dist/_contracts/schemas/response-secrets.js +0 -32
  155. package/dist/_contracts/schemas/response-sessions-internal.d.ts +0 -200
  156. package/dist/_contracts/schemas/response-sessions-internal.js +0 -142
  157. package/dist/_contracts/schemas/response-sessions.d.ts +0 -1598
  158. package/dist/_contracts/schemas/response-sessions.js +0 -377
  159. package/dist/_contracts/schemas/response-webhooks.d.ts +0 -76
  160. package/dist/_contracts/schemas/response-webhooks.js +0 -42
  161. package/dist/_contracts/schemas/response-workspace.d.ts +0 -225
  162. package/dist/_contracts/schemas/response-workspace.js +0 -99
  163. package/dist/_contracts/schemas/runtime-kind.d.ts +0 -31
  164. package/dist/_contracts/schemas/runtime-kind.js +0 -29
  165. package/dist/_contracts/schemas/runtime-security-profile.d.ts +0 -28
  166. package/dist/_contracts/schemas/runtime-security-profile.js +0 -26
  167. package/dist/_contracts/schemas/runtime-sizes.d.ts +0 -70
  168. package/dist/_contracts/schemas/runtime-sizes.js +0 -127
  169. package/dist/_contracts/schemas/session-limits.d.ts +0 -34
  170. package/dist/_contracts/schemas/session-limits.js +0 -39
  171. package/dist/_contracts/schemas/session-machine.d.ts +0 -23
  172. package/dist/_contracts/schemas/session-machine.js +0 -24
  173. package/dist/_contracts/schemas/session-request-config.d.ts +0 -58
  174. package/dist/_contracts/schemas/session-request-config.js +0 -134
  175. package/dist/_contracts/schemas/session-webhook.d.ts +0 -11
  176. package/dist/_contracts/schemas/session-webhook.js +0 -38
  177. package/dist/_contracts/schemas/side-effect-audit.d.ts +0 -98
  178. package/dist/_contracts/schemas/side-effect-audit.js +0 -102
  179. package/dist/_contracts/schemas/submission-assets.d.ts +0 -117
  180. package/dist/_contracts/schemas/submission-assets.js +0 -147
  181. package/dist/_contracts/schemas/submission-body.d.ts +0 -251
  182. package/dist/_contracts/schemas/submission-body.js +0 -378
  183. package/dist/_contracts/schemas/submission-environment.d.ts +0 -79
  184. package/dist/_contracts/schemas/submission-environment.js +0 -179
  185. package/dist/_contracts/schemas/submission-request.d.ts +0 -158
  186. package/dist/_contracts/schemas/submission-request.js +0 -49
  187. package/dist/_contracts/schemas/submission-secrets.d.ts +0 -47
  188. package/dist/_contracts/schemas/submission-secrets.js +0 -108
  189. package/dist/_contracts/schemas/wire.d.ts +0 -118
  190. package/dist/_contracts/schemas/wire.js +0 -171
  191. package/dist/_contracts/schemas/workspace-resources.d.ts +0 -50
  192. package/dist/_contracts/schemas/workspace-resources.js +0 -87
  193. package/dist/_contracts/sdk-errors.d.ts +0 -212
  194. package/dist/_contracts/sdk-errors.js +0 -313
  195. package/dist/_contracts/sdk-secrets.d.ts +0 -67
  196. package/dist/_contracts/sdk-secrets.js +0 -427
  197. package/dist/_contracts/session-archive.d.ts +0 -16
  198. package/dist/_contracts/session-archive.js +0 -92
  199. package/dist/_contracts/session-artifacts.d.ts +0 -189
  200. package/dist/_contracts/session-artifacts.js +0 -264
  201. package/dist/_contracts/session-config.d.ts +0 -373
  202. package/dist/_contracts/session-config.js +0 -562
  203. package/dist/_contracts/session-cost-types.d.ts +0 -211
  204. package/dist/_contracts/session-cost-types.js +0 -69
  205. package/dist/_contracts/session-cost.d.ts +0 -8
  206. package/dist/_contracts/session-cost.js +0 -582
  207. package/dist/_contracts/session-custody.d.ts +0 -165
  208. package/dist/_contracts/session-custody.js +0 -345
  209. package/dist/_contracts/session-file-query.d.ts +0 -14
  210. package/dist/_contracts/session-file-query.js +0 -178
  211. package/dist/_contracts/session-record.d.ts +0 -112
  212. package/dist/_contracts/session-record.js +0 -165
  213. package/dist/_contracts/session-retention.d.ts +0 -201
  214. package/dist/_contracts/session-retention.js +0 -450
  215. package/dist/_contracts/side-effect-audit.d.ts +0 -126
  216. package/dist/_contracts/side-effect-audit.js +0 -520
  217. package/dist/_contracts/sse.d.ts +0 -74
  218. package/dist/_contracts/sse.js +0 -227
  219. package/dist/_contracts/stable.d.ts +0 -45
  220. package/dist/_contracts/stable.js +0 -62
  221. package/dist/_contracts/status.d.ts +0 -25
  222. package/dist/_contracts/status.js +0 -57
  223. package/dist/_contracts/submission-limits.d.ts +0 -61
  224. package/dist/_contracts/submission-limits.js +0 -60
  225. package/dist/_contracts/submission.d.ts +0 -547
  226. package/dist/_contracts/submission.js +0 -812
  227. package/dist/_contracts/suggest.d.ts +0 -15
  228. package/dist/_contracts/suggest.js +0 -53
  229. package/dist/_contracts/testing/response-bindings.d.ts +0 -45
  230. package/dist/_contracts/testing/response-bindings.js +0 -256
  231. package/dist/_contracts/testing/wire-conformance-entry.d.ts +0 -10
  232. package/dist/_contracts/testing/wire-conformance-entry.js +0 -8
  233. package/dist/_contracts/testing/wire-conformance.d.ts +0 -169
  234. package/dist/_contracts/testing/wire-conformance.js +0 -276
  235. package/dist/_contracts/turn-trace.d.ts +0 -28
  236. package/dist/_contracts/turn-trace.js +0 -1
  237. package/dist/_contracts/unknown-field-error.d.ts +0 -13
  238. package/dist/_contracts/unknown-field-error.js +0 -21
  239. package/dist/_contracts/value-guards.d.ts +0 -20
  240. package/dist/_contracts/value-guards.js +0 -34
  241. package/dist/_contracts/webhook-verify.d.ts +0 -34
  242. package/dist/_contracts/webhook-verify.js +0 -93
  243. package/dist/_contracts/wire-observer.d.ts +0 -49
  244. package/dist/_contracts/wire-observer.js +0 -34
  245. package/dist/_contracts/workflow-status.d.ts +0 -7
  246. package/dist/_contracts/workflow-status.js +0 -43
  247. package/dist/_contracts/workspace-resources.d.ts +0 -98
  248. package/dist/_contracts/workspace-resources.js +0 -39
  249. package/dist/archive-limits.d.ts +0 -1
  250. package/dist/archive-limits.js +0 -2
  251. package/dist/archive-limits.js.map +0 -1
  252. package/dist/asset-upload.d.ts +0 -47
  253. package/dist/asset-upload.js +0 -269
  254. package/dist/asset-upload.js.map +0 -1
  255. package/dist/bundle.d.ts +0 -9
  256. package/dist/bundle.js +0 -20
  257. package/dist/bundle.js.map +0 -1
  258. package/dist/canonical-zip.d.ts +0 -68
  259. package/dist/canonical-zip.js +0 -355
  260. package/dist/canonical-zip.js.map +0 -1
  261. package/dist/cli.mjs +0 -12048
  262. package/dist/cli.mjs.sha256 +0 -1
  263. package/dist/client-types.d.ts +0 -192
  264. package/dist/client-types.js +0 -2
  265. package/dist/client-types.js.map +0 -1
  266. package/dist/client.d.ts +0 -464
  267. package/dist/client.js +0 -1207
  268. package/dist/client.js.map +0 -1
  269. package/dist/event-projection.d.ts +0 -22
  270. package/dist/event-projection.js +0 -380
  271. package/dist/event-projection.js.map +0 -1
  272. package/dist/fetch-archive.d.ts +0 -16
  273. package/dist/fetch-archive.js +0 -252
  274. package/dist/fetch-archive.js.map +0 -1
  275. package/dist/file.d.ts +0 -96
  276. package/dist/file.js +0 -272
  277. package/dist/file.js.map +0 -1
  278. package/dist/instructions.d.ts +0 -20
  279. package/dist/instructions.js +0 -40
  280. package/dist/instructions.js.map +0 -1
  281. package/dist/legacy-session-provider-fault.d.ts +0 -7
  282. package/dist/legacy-session-provider-fault.js +0 -38
  283. package/dist/legacy-session-provider-fault.js.map +0 -1
  284. package/dist/mcp-server.d.ts +0 -84
  285. package/dist/mcp-server.js +0 -117
  286. package/dist/mcp-server.js.map +0 -1
  287. package/dist/node-fs.d.ts +0 -29
  288. package/dist/node-fs.js +0 -19
  289. package/dist/node-fs.js.map +0 -1
  290. package/dist/node-walk.d.ts +0 -69
  291. package/dist/node-walk.js +0 -151
  292. package/dist/node-walk.js.map +0 -1
  293. package/dist/path-basename.d.ts +0 -5
  294. package/dist/path-basename.js +0 -9
  295. package/dist/path-basename.js.map +0 -1
  296. package/dist/retry.d.ts +0 -70
  297. package/dist/retry.js +0 -155
  298. package/dist/retry.js.map +0 -1
  299. package/dist/secret.d.ts +0 -65
  300. package/dist/secret.js +0 -110
  301. package/dist/secret.js.map +0 -1
  302. package/dist/session-validate.d.ts +0 -100
  303. package/dist/session-validate.js +0 -303
  304. package/dist/session-validate.js.map +0 -1
  305. package/dist/skill.d.ts +0 -99
  306. package/dist/skill.js +0 -169
  307. package/dist/skill.js.map +0 -1
  308. package/dist/submission-wire.d.ts +0 -13
  309. package/dist/submission-wire.js +0 -69
  310. package/dist/submission-wire.js.map +0 -1
  311. package/dist/tool.d.ts +0 -41
  312. package/dist/tool.js +0 -76
  313. package/dist/tool.js.map +0 -1
  314. package/dist/version.d.ts +0 -9
  315. package/dist/version.js +0 -10
  316. package/dist/version.js.map +0 -1
  317. package/docs/authentication.md +0 -125
  318. package/docs/billing.md +0 -164
  319. package/docs/cleanup.md +0 -27
  320. package/docs/concepts/agent-tools.md +0 -47
  321. package/docs/concepts/composition.md +0 -60
  322. package/docs/concepts/providers-and-runtimes.md +0 -121
  323. package/docs/concepts/sessions.md +0 -51
  324. package/docs/concepts/subagents.md +0 -35
  325. package/docs/credentials.md +0 -116
  326. package/docs/defaults.md +0 -51
  327. package/docs/errors.md +0 -258
  328. package/docs/events.md +0 -143
  329. package/docs/files.md +0 -130
  330. package/docs/limits-and-quotas.md +0 -114
  331. package/docs/limits.md +0 -51
  332. package/docs/mcp.md +0 -47
  333. package/docs/networking.md +0 -114
  334. package/docs/provider-runtime-capabilities.md +0 -32
  335. package/docs/public-surface.json +0 -73
  336. package/docs/quickstart.md +0 -135
  337. package/docs/release.md +0 -44
  338. package/docs/retries.md +0 -108
  339. package/docs/secrets.md +0 -141
  340. package/docs/session-config.md +0 -51
  341. package/docs/session-record.md +0 -58
  342. package/docs/skills.md +0 -65
  343. package/docs/telemetry.md +0 -66
  344. package/docs/testing.md +0 -35
  345. package/docs/vision-skills.md +0 -94
  346. package/docs/webhooks.md +0 -143
@@ -1,78 +0,0 @@
1
- import type { AexEvent } from "./event-envelope.js";
2
- /** Signals exposed by the session telemetry pull API. */
3
- export type OtlpSignal = "traces" | "logs";
4
- /** OTLP/HTTP JSON AnyValue. The projection emits only public scalar values. */
5
- export type OtlpAnyValue = {
6
- readonly stringValue: string;
7
- } | {
8
- readonly boolValue: boolean;
9
- } | {
10
- readonly intValue: string;
11
- } | {
12
- readonly doubleValue: number;
13
- };
14
- export interface OtlpKeyValue {
15
- readonly key: string;
16
- readonly value: OtlpAnyValue;
17
- }
18
- export interface OtlpResource {
19
- readonly attributes: readonly OtlpKeyValue[];
20
- }
21
- export interface OtlpInstrumentationScope {
22
- readonly name: string;
23
- readonly version?: string;
24
- }
25
- export interface OtlpTraceSpan {
26
- readonly traceId: string;
27
- readonly spanId: string;
28
- readonly parentSpanId?: string;
29
- readonly name: string;
30
- readonly kind: 1;
31
- readonly startTimeUnixNano: string;
32
- readonly endTimeUnixNano: string;
33
- readonly attributes: readonly OtlpKeyValue[];
34
- readonly status: {
35
- readonly code: 1 | 2;
36
- };
37
- }
38
- export interface OtlpScopeSpans {
39
- readonly scope: OtlpInstrumentationScope;
40
- readonly spans: readonly OtlpTraceSpan[];
41
- }
42
- export interface OtlpResourceSpans {
43
- readonly resource: OtlpResource;
44
- readonly scopeSpans: readonly OtlpScopeSpans[];
45
- }
46
- /** Standards-pure OTLP ExportTraceServiceRequest JSON body. */
47
- export interface OtlpExportTraceServiceRequest {
48
- readonly resourceSpans: readonly OtlpResourceSpans[];
49
- }
50
- export interface OtlpLogRecord {
51
- readonly timeUnixNano: string;
52
- readonly observedTimeUnixNano: string;
53
- readonly severityNumber: 9 | 13 | 17;
54
- readonly severityText: "INFO" | "WARN" | "ERROR";
55
- readonly body: OtlpAnyValue;
56
- readonly attributes: readonly OtlpKeyValue[];
57
- readonly traceId?: string;
58
- readonly spanId?: string;
59
- }
60
- export interface OtlpScopeLogs {
61
- readonly scope: OtlpInstrumentationScope;
62
- readonly logRecords: readonly OtlpLogRecord[];
63
- }
64
- export interface OtlpResourceLogs {
65
- readonly resource: OtlpResource;
66
- readonly scopeLogs: readonly OtlpScopeLogs[];
67
- }
68
- /** Standards-pure OTLP ExportLogsServiceRequest JSON body. */
69
- export interface OtlpExportLogsServiceRequest {
70
- readonly resourceLogs: readonly OtlpResourceLogs[];
71
- }
72
- export type OtlpExportRequest = OtlpExportTraceServiceRequest | OtlpExportLogsServiceRequest;
73
- export interface ToOtlpOptions<Signal extends OtlpSignal = OtlpSignal> {
74
- readonly signal: Signal;
75
- }
76
- export declare function toOTLP(events: readonly AexEvent[], options: ToOtlpOptions<"traces">): OtlpExportTraceServiceRequest;
77
- export declare function toOTLP(events: readonly AexEvent[], options: ToOtlpOptions<"logs">): OtlpExportLogsServiceRequest;
78
- export declare function toOTLP(events: readonly AexEvent[], options: ToOtlpOptions): OtlpExportRequest;
@@ -1,171 +0,0 @@
1
- import { redactString } from "./sdk-secrets.js";
2
- const TRACE_ID = /^[0-9a-f]{32}$/;
3
- const SPAN_ID = /^[0-9a-f]{16}$/;
4
- const SCOPE = Object.freeze({ name: "@aexhq/contracts", version: "1" });
5
- /**
6
- * Project public event envelopes into a standards-pure OTLP/HTTP JSON body.
7
- *
8
- * This function accepts only the public event contract. It never accepts or
9
- * imports private journal rows. Projection is allow-list based: arbitrary
10
- * event data is ignored, and text that is intentionally public is passed
11
- * through the canonical public redactor before it becomes telemetry.
12
- */
13
- export function toOTLP(events, options) {
14
- if (options.signal === "traces")
15
- return projectTraces(events);
16
- if (options.signal === "logs")
17
- return projectLogs(events);
18
- throw new TypeError(`unsupported OTLP signal: ${String(options.signal)}`);
19
- }
20
- function projectTraces(events) {
21
- const spans = events.flatMap((event) => {
22
- if (!validTraceIdentity(event))
23
- return [];
24
- const start = unixNano(event.time);
25
- return [{
26
- traceId: event.traceId,
27
- spanId: event.spanId,
28
- ...(validSpanId(event.parentSpanId) ? { parentSpanId: event.parentSpanId } : {}),
29
- name: publicSpanName(event),
30
- kind: 1,
31
- startTimeUnixNano: start,
32
- endTimeUnixNano: (BigInt(start) + 1n).toString(),
33
- attributes: publicAttributes(event, "traces"),
34
- status: { code: event.type === "RUN_ERROR" ? 2 : 1 }
35
- }];
36
- });
37
- return {
38
- resourceSpans: spans.length === 0 ? [] : [{
39
- resource: publicResource(),
40
- scopeSpans: [{ scope: SCOPE, spans }]
41
- }]
42
- };
43
- }
44
- function projectLogs(events) {
45
- const logRecords = events
46
- .filter((event) => event.channel === "log" || event.type === "LOG")
47
- .map((event) => {
48
- const time = unixNano(event.time);
49
- const severity = severityOf(event.level);
50
- const message = typeof event.message === "string"
51
- ? event.message
52
- : typeof event.data["message"] === "string"
53
- ? event.data["message"]
54
- : event.type;
55
- return {
56
- timeUnixNano: time,
57
- observedTimeUnixNano: time,
58
- ...severity,
59
- body: { stringValue: redactString(message) },
60
- attributes: publicAttributes(event, "logs"),
61
- ...(validTraceId(event.traceId) ? { traceId: event.traceId } : {}),
62
- ...(validSpanId(event.spanId) ? { spanId: event.spanId } : {})
63
- };
64
- });
65
- return {
66
- resourceLogs: logRecords.length === 0 ? [] : [{
67
- resource: publicResource(),
68
- scopeLogs: [{ scope: SCOPE, logRecords }]
69
- }]
70
- };
71
- }
72
- function publicResource() {
73
- return {
74
- attributes: [
75
- attribute("service.name", "aex"),
76
- attribute("aex.visibility", "external")
77
- ]
78
- };
79
- }
80
- function publicAttributes(event, signal) {
81
- const attributes = [
82
- attribute("aex.visibility", "external"),
83
- attribute("aex.session.id", event.subject),
84
- attribute("aex.run.id", event.runId)
85
- ];
86
- const turnSeq = publicNumber(event.data["turnSeq"])
87
- ?? publicNestedNumber(event.data["value"], "turnSeq");
88
- if (turnSeq !== undefined)
89
- attributes.push(attribute("aex.turn.seq", turnSeq));
90
- const callId = publicString(event.data["callId"])
91
- ?? publicNestedString(event.data["fields"], "callId")
92
- ?? publicNestedString(event.data["value"], "callId");
93
- if (callId !== undefined)
94
- attributes.push(attribute("aex.call.id", callId));
95
- const failureClass = publicString(event.data["failureClass"]);
96
- if (failureClass !== undefined)
97
- attributes.push(attribute("aex.failure.class_public", failureClass));
98
- if (signal === "logs") {
99
- const ioStream = publicIoStream(event.data["stream"])
100
- ?? publicNestedIoStream(event.data["fields"], "stream")
101
- ?? publicNestedIoStream(event.data["value"], "stream");
102
- if (ioStream !== undefined)
103
- attributes.push(attribute("log.iostream", ioStream));
104
- }
105
- const exitCode = publicSafeInteger(event.data["exitCode"])
106
- ?? publicNestedSafeInteger(event.data["fields"], "exitCode")
107
- ?? publicNestedSafeInteger(event.data["value"], "exitCode");
108
- if (exitCode !== undefined)
109
- attributes.push(attribute("aex.tool.exit_code", exitCode));
110
- return attributes;
111
- }
112
- function publicSpanName(event) {
113
- const customName = event.type === "CUSTOM" ? publicString(event.data["name"]) : undefined;
114
- return redactString(customName ?? event.type);
115
- }
116
- function attribute(key, value) {
117
- if (typeof value === "string")
118
- return { key, value: { stringValue: redactString(value) } };
119
- if (typeof value === "boolean")
120
- return { key, value: { boolValue: value } };
121
- return Number.isSafeInteger(value)
122
- ? { key, value: { intValue: String(value) } }
123
- : { key, value: { doubleValue: value } };
124
- }
125
- function severityOf(level) {
126
- if (level === "error")
127
- return { severityNumber: 17, severityText: "ERROR" };
128
- if (level === "warn")
129
- return { severityNumber: 13, severityText: "WARN" };
130
- return { severityNumber: 9, severityText: "INFO" };
131
- }
132
- function unixNano(value) {
133
- const milliseconds = Date.parse(value);
134
- return (BigInt(Number.isFinite(milliseconds) ? Math.max(0, Math.trunc(milliseconds)) : 0) * 1000000n).toString();
135
- }
136
- function validTraceIdentity(event) {
137
- return validTraceId(event.traceId) && validSpanId(event.spanId);
138
- }
139
- function validTraceId(value) {
140
- return typeof value === "string" && TRACE_ID.test(value) && !/^0+$/.test(value);
141
- }
142
- function validSpanId(value) {
143
- return typeof value === "string" && SPAN_ID.test(value) && !/^0+$/.test(value);
144
- }
145
- function publicString(value) {
146
- return typeof value === "string" && value.length > 0 ? redactString(value) : undefined;
147
- }
148
- function publicNumber(value) {
149
- return typeof value === "number" && Number.isFinite(value) ? value : undefined;
150
- }
151
- function publicSafeInteger(value) {
152
- return typeof value === "number" && Number.isSafeInteger(value) ? value : undefined;
153
- }
154
- function publicIoStream(value) {
155
- return value === "stdout" || value === "stderr" ? value : undefined;
156
- }
157
- function publicNestedString(value, key) {
158
- return isPlainRecord(value) ? publicString(value[key]) : undefined;
159
- }
160
- function publicNestedNumber(value, key) {
161
- return isPlainRecord(value) ? publicNumber(value[key]) : undefined;
162
- }
163
- function publicNestedSafeInteger(value, key) {
164
- return isPlainRecord(value) ? publicSafeInteger(value[key]) : undefined;
165
- }
166
- function publicNestedIoStream(value, key) {
167
- return isPlainRecord(value) ? publicIoStream(value[key]) : undefined;
168
- }
169
- function isPlainRecord(value) {
170
- return value !== null && typeof value === "object" && !Array.isArray(value);
171
- }
@@ -1,31 +0,0 @@
1
- /** Default post-agent-run hook timeout (5 minutes). */
2
- export declare const DEFAULT_POST_HOOK_TIMEOUT_MS: number;
3
- /** Default number of repair turns after a failing hook. */
4
- export declare const DEFAULT_POST_HOOK_MAX_TURNS = 10;
5
- /**
6
- * Private post-agent-run verifier input. The public SDK does not
7
- * accepts this field; platform-internal paths may still normalize old wire
8
- * records to {@link PlatformPostHook}.
9
- *
10
- * The runtime statement of this shape is `postHookSchema()` in
11
- * `./schemas/post-hook.ts`; its keys are the accepted field list.
12
- */
13
- export interface PlatformPostHookInput {
14
- readonly command: string;
15
- readonly timeout?: string;
16
- readonly maxTurns?: number;
17
- readonly maxChars?: number | null;
18
- }
19
- /** Parsed post-agent-run verifier carried through dispatch to the runner. */
20
- export interface PlatformPostHook {
21
- readonly command: string;
22
- readonly timeoutMs: number;
23
- readonly maxTurns: number;
24
- readonly maxChars: number | null;
25
- }
26
- /**
27
- * Parse the private `postHook` option. An omitted hook, null hook, or hook with
28
- * an empty/whitespace-only command is treated as omitted so callers can pre-fill
29
- * configs without enabling the verifier accidentally.
30
- */
31
- export declare function parsePostHook(input: unknown, path?: string): PlatformPostHook | undefined;
@@ -1,61 +0,0 @@
1
- import { parseDurationToMs } from "./runtime-sizes.js";
2
- import { withContractParseError } from "./contract-parse-error.js";
3
- import { postHookGateSchema, postHookSchema } from "./schemas/post-hook.js";
4
- import { parseWire } from "./schemas/wire.js";
5
- /** Default post-agent-run hook timeout (5 minutes). */
6
- export const DEFAULT_POST_HOOK_TIMEOUT_MS = 5 * 60 * 1000;
7
- /** Default number of repair turns after a failing hook. */
8
- export const DEFAULT_POST_HOOK_MAX_TURNS = 10;
9
- /**
10
- * Parse the private `postHook` option. An omitted hook, null hook, or hook with
11
- * an empty/whitespace-only command is treated as omitted so callers can pre-fill
12
- * configs without enabling the verifier accidentally.
13
- */
14
- export function parsePostHook(input, path = "postHook") {
15
- return withContractParseError("parsePostHook", () => {
16
- if (input === undefined || input === null) {
17
- return undefined;
18
- }
19
- // Two passes, deliberately. The gate settles shape, the allow-list and the
20
- // command; only if the command is non-blank do the sibling rules run. A
21
- // single pass would reject `{ command: "", timeout: <junk> }`, which is
22
- // exactly the pre-filled config the blank-command rule exists to allow.
23
- if (parseWire(postHookGateSchema(path), input).command.trim().length === 0) {
24
- return undefined;
25
- }
26
- return normalizePostHook(parseWire(postHookSchema(path), input), path);
27
- });
28
- }
29
- /**
30
- * Apply the hook's defaults and turn its wire duration into milliseconds.
31
- *
32
- * Separate from the schema because both halves are transforms — per D4 a schema
33
- * that transformed could not be converted on the output side — and because the
34
- * duration parse belongs to {@link parseDurationToMs}, which brands its own
35
- * failures.
36
- *
37
- * The blank-command collapse is repeated here so this function is correct on its
38
- * own; the caller has already applied it via the gate schema, which is what
39
- * keeps a blank command from ever reaching the sibling field rules.
40
- */
41
- function normalizePostHook(hook, path) {
42
- if (hook.command.trim().length === 0) {
43
- return undefined;
44
- }
45
- return {
46
- command: hook.command,
47
- timeoutMs: postHookTimeoutMs(hook.timeout, `${path}.timeout`),
48
- maxTurns: hook.maxTurns ?? DEFAULT_POST_HOOK_MAX_TURNS,
49
- maxChars: hook.maxChars ?? null
50
- };
51
- }
52
- function postHookTimeoutMs(timeout, path) {
53
- if (timeout === undefined) {
54
- return DEFAULT_POST_HOOK_TIMEOUT_MS;
55
- }
56
- const ms = parseDurationToMs(timeout);
57
- if (ms <= 0) {
58
- throw new Error(`${path} must be greater than 0ms; got ${ms}ms`);
59
- }
60
- return ms;
61
- }
@@ -1,34 +0,0 @@
1
- /** Canonical, redaction-safe terminal fault reported by an upstream provider. */
2
- export declare const PROVIDER_FAULT_KINDS: readonly ["rate_limit", "overloaded", "quota_exceeded", "unavailable", "provider_error"];
3
- export type KnownProviderFaultKind = (typeof PROVIDER_FAULT_KINDS)[number];
4
- declare const UNKNOWN_PROVIDER_FAULT_KIND: unique symbol;
5
- /**
6
- * A syntactically valid future provider-fault kind accepted from the wire.
7
- * Producers must use a known kind; only the canonical parser creates this type.
8
- */
9
- export type UnknownProviderFaultKind = string & {
10
- readonly [UNKNOWN_PROVIDER_FAULT_KIND]: "UnknownProviderFaultKind";
11
- };
12
- export type ProviderFaultKind = KnownProviderFaultKind | UnknownProviderFaultKind;
13
- export interface ProviderFault {
14
- /** Upstream provider id, for example `anthropic`, when reported. */
15
- readonly provider?: string;
16
- /** Exact machine-readable fault class. Unknown future tokens are non-throttling. */
17
- readonly kind: ProviderFaultKind;
18
- /** Upstream HTTP status, when reported. */
19
- readonly status?: number;
20
- /** Retry delay in milliseconds, when reported. */
21
- readonly retryAfterMs?: number;
22
- /** Short, already-redacted diagnostic message. */
23
- readonly message?: string;
24
- }
25
- export declare function isKnownProviderFaultKind(kind: string): kind is KnownProviderFaultKind;
26
- /**
27
- * Strictly parse the canonical provider-fault wire object.
28
- *
29
- * This parser intentionally rejects aliases, coercions, unknown fields, and
30
- * malformed present values. A valid future `kind` token is preserved for
31
- * forward compatibility, but callers must not infer throttle semantics from it.
32
- */
33
- export declare function parseProviderFault(value: unknown): ProviderFault;
34
- export {};
@@ -1,68 +0,0 @@
1
- /** Canonical, redaction-safe terminal fault reported by an upstream provider. */
2
- import { rethrowContractParseError } from "./contract-parse-error.js";
3
- import { isRecord } from "./value-guards.js";
4
- export const PROVIDER_FAULT_KINDS = [
5
- "rate_limit",
6
- "overloaded",
7
- "quota_exceeded",
8
- "unavailable",
9
- "provider_error"
10
- ];
11
- const PROVIDER_FAULT_KIND_SET = new Set(PROVIDER_FAULT_KINDS);
12
- const PROVIDER_FAULT_KEYS = new Set(["provider", "kind", "status", "retryAfterMs", "message"]);
13
- const KIND_TOKEN = /^[a-z][a-z0-9_.:-]{0,63}$/;
14
- const PROVIDER_TOKEN = /^[A-Za-z0-9][A-Za-z0-9_.:-]{0,127}$/;
15
- const MAX_MESSAGE_LENGTH = 512;
16
- export function isKnownProviderFaultKind(kind) {
17
- return PROVIDER_FAULT_KIND_SET.has(kind);
18
- }
19
- /**
20
- * Strictly parse the canonical provider-fault wire object.
21
- *
22
- * This parser intentionally rejects aliases, coercions, unknown fields, and
23
- * malformed present values. A valid future `kind` token is preserved for
24
- * forward compatibility, but callers must not infer throttle semantics from it.
25
- */
26
- export function parseProviderFault(value) {
27
- try {
28
- return parseProviderFaultValue(value);
29
- }
30
- catch (error) {
31
- rethrowContractParseError(error, "parseProviderFault");
32
- }
33
- }
34
- function parseProviderFaultValue(value) {
35
- if (!isRecord(value))
36
- throw new TypeError("providerFault must be an object");
37
- for (const key of Object.keys(value)) {
38
- if (!PROVIDER_FAULT_KEYS.has(key)) {
39
- throw new TypeError("providerFault contains an unknown field");
40
- }
41
- }
42
- if (!Object.hasOwn(value, "kind") || typeof value.kind !== "string" || !KIND_TOKEN.test(value.kind)) {
43
- throw new TypeError("providerFault.kind must be a canonical token");
44
- }
45
- if (Object.hasOwn(value, "provider") && (typeof value.provider !== "string" || !PROVIDER_TOKEN.test(value.provider))) {
46
- throw new TypeError("providerFault.provider must be a canonical provider token");
47
- }
48
- if (Object.hasOwn(value, "status") && (!Number.isInteger(value.status) || value.status < 100 || value.status > 599)) {
49
- throw new TypeError("providerFault.status must be an HTTP status integer");
50
- }
51
- if (Object.hasOwn(value, "retryAfterMs") && (!Number.isSafeInteger(value.retryAfterMs) || value.retryAfterMs < 0)) {
52
- throw new TypeError("providerFault.retryAfterMs must be a non-negative safe integer");
53
- }
54
- if (Object.hasOwn(value, "message") && (typeof value.message !== "string" || value.message.length === 0 ||
55
- value.message.length > MAX_MESSAGE_LENGTH || /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/.test(value.message))) {
56
- throw new TypeError(`providerFault.message must be 1-${MAX_MESSAGE_LENGTH} printable characters`);
57
- }
58
- const kind = isKnownProviderFaultKind(value.kind)
59
- ? value.kind
60
- : value.kind;
61
- return {
62
- kind,
63
- ...(Object.hasOwn(value, "provider") ? { provider: value.provider } : {}),
64
- ...(Object.hasOwn(value, "status") ? { status: value.status } : {}),
65
- ...(Object.hasOwn(value, "retryAfterMs") ? { retryAfterMs: value.retryAfterMs } : {}),
66
- ...(Object.hasOwn(value, "message") ? { message: value.message } : {})
67
- };
68
- }
@@ -1,29 +0,0 @@
1
- /**
2
- * Public-safe retry primitives shared by public packages through the
3
- * `@aexhq/contracts/internal` subpath. Keep this module free of hosted
4
- * implementation details and do not export it from the public contracts root.
5
- */
6
- export declare const RETRYABLE_HTTP_STATUS: readonly number[];
7
- export declare const RATE_LIMIT_HTTP_STATUS: readonly number[];
8
- export interface RetryBackoffConfig {
9
- readonly initialDelayMs: number;
10
- readonly maxDelayMs: number;
11
- }
12
- export type RetryRandom = () => number;
13
- export declare function isRetryableHttpStatus(status: number): boolean;
14
- export declare function isRateLimitHttpStatus(status: number): boolean;
15
- /**
16
- * Parse an HTTP `Retry-After` header into milliseconds. RFC 7231 permits either
17
- * a non-negative integer number of seconds or an HTTP-date.
18
- */
19
- export declare function tryParseRetryAfterMs(headerValue: string | null | undefined, now?: number): number | undefined;
20
- /** @deprecated Use {@link tryParseRetryAfterMs}; this compatibility wrapper is identical. */
21
- export declare function parseRetryAfterMs(headerValue: string | null | undefined, now?: number): number | undefined;
22
- /**
23
- * Full-jitter exponential backoff: the nominal wait doubles per failed attempt
24
- * and the actual delay is sampled uniformly in `[0, nominal]`.
25
- */
26
- export declare function computeRetryBackoffDelayMs(config: RetryBackoffConfig, attemptNumber: number, random: RetryRandom): number;
27
- /** Combine a server `Retry-After` floor with the jittered backoff delay. */
28
- export declare function computeRetryDelayMs(config: RetryBackoffConfig, attemptNumber: number, random: RetryRandom, retryAfterMs: number | undefined): number;
29
- export declare function abortableSleep(ms: number, signal?: AbortSignal): Promise<void>;
@@ -1,79 +0,0 @@
1
- /**
2
- * Public-safe retry primitives shared by public packages through the
3
- * `@aexhq/contracts/internal` subpath. Keep this module free of hosted
4
- * implementation details and do not export it from the public contracts root.
5
- */
6
- export const RETRYABLE_HTTP_STATUS = [429, 500, 502, 503, 504, 529];
7
- export const RATE_LIMIT_HTTP_STATUS = [429, 503, 529];
8
- const RETRYABLE_HTTP_STATUS_SET = new Set(RETRYABLE_HTTP_STATUS);
9
- const RATE_LIMIT_HTTP_STATUS_SET = new Set(RATE_LIMIT_HTTP_STATUS);
10
- export function isRetryableHttpStatus(status) {
11
- return RETRYABLE_HTTP_STATUS_SET.has(status);
12
- }
13
- export function isRateLimitHttpStatus(status) {
14
- return RATE_LIMIT_HTTP_STATUS_SET.has(status);
15
- }
16
- /**
17
- * Parse an HTTP `Retry-After` header into milliseconds. RFC 7231 permits either
18
- * a non-negative integer number of seconds or an HTTP-date.
19
- */
20
- export function tryParseRetryAfterMs(headerValue, now = Date.now()) {
21
- if (headerValue === null || headerValue === undefined)
22
- return undefined;
23
- const trimmed = headerValue.trim();
24
- if (trimmed.length === 0)
25
- return undefined;
26
- if (/^\d+$/.test(trimmed)) {
27
- return Number(trimmed) * 1000;
28
- }
29
- const dateMs = Date.parse(trimmed);
30
- if (!Number.isNaN(dateMs)) {
31
- return Math.max(0, dateMs - now);
32
- }
33
- return undefined;
34
- }
35
- /** @deprecated Use {@link tryParseRetryAfterMs}; this compatibility wrapper is identical. */
36
- export function parseRetryAfterMs(headerValue, now = Date.now()) {
37
- return tryParseRetryAfterMs(headerValue, now);
38
- }
39
- /**
40
- * Full-jitter exponential backoff: the nominal wait doubles per failed attempt
41
- * and the actual delay is sampled uniformly in `[0, nominal]`.
42
- */
43
- export function computeRetryBackoffDelayMs(config, attemptNumber, random) {
44
- const exponent = Math.max(0, attemptNumber - 1);
45
- const nominal = Math.min(config.maxDelayMs, config.initialDelayMs * 2 ** exponent);
46
- return Math.round(random() * nominal);
47
- }
48
- /** Combine a server `Retry-After` floor with the jittered backoff delay. */
49
- export function computeRetryDelayMs(config, attemptNumber, random, retryAfterMs) {
50
- const backoff = computeRetryBackoffDelayMs(config, attemptNumber, random);
51
- return retryAfterMs === undefined ? backoff : Math.max(retryAfterMs, backoff);
52
- }
53
- export function abortableSleep(ms, signal) {
54
- return new Promise((resolve, reject) => {
55
- if (signal?.aborted) {
56
- reject(abortReason(signal));
57
- return;
58
- }
59
- const timer = setTimeout(() => {
60
- signal?.removeEventListener("abort", onAbort);
61
- resolve();
62
- }, ms);
63
- const onAbort = () => {
64
- clearTimeout(timer);
65
- reject(signal ? abortReason(signal) : makeAbortError());
66
- };
67
- signal?.addEventListener("abort", onAbort, { once: true });
68
- });
69
- }
70
- function abortReason(signal) {
71
- return signal.reason instanceof Error ? signal.reason : makeAbortError();
72
- }
73
- function makeAbortError() {
74
- if (typeof DOMException !== "undefined")
75
- return new DOMException("Aborted", "AbortError");
76
- const err = new Error("Aborted");
77
- err.name = "AbortError";
78
- return err;
79
- }
@@ -1,117 +0,0 @@
1
- /**
2
- * Unified runner event schema. The managed runtime feeds one shape into
3
- * the hosted aex event pipeline:
4
- *
5
- * - The per-session managed runtime POSTs batches of NDJSON events to
6
- * `/sessions/{id}/runner/events`; the runtime adapter translates each
7
- * event into one or more `RunnerEvent`s.
8
- *
9
- * The downstream subscribers (dashboard, SDK `streamEvents`, observable
10
- * spans) never see runtime-specific wire shapes — they only see
11
- * `RunnerEvent`s.
12
- *
13
- * This is the public event contract consumed by SDK and CLI clients.
14
- */
15
- import { type JsonValue } from "./value-guards.js";
16
- /**
17
- * Schema version. Bump when the shape of `RunnerEvent`, its kind set,
18
- * or the batch envelope changes. Subscribers gate on this so a future
19
- * v2 wire shape can land behind a feature flag.
20
- */
21
- export declare const RUNNER_EVENT_VERSION: 1;
22
- /**
23
- * The set of event kinds emitted into the unified stream. Adapters
24
- * fold runtime-specific events into one of these — anything that
25
- * doesn't fit is mapped to `notification` so the data is captured
26
- * even when no UI handler exists yet.
27
- *
28
- * - `runtime_started` — the managed runtime announced "ready" or
29
- * accepted the first turn.
30
- * - `assistant_text` — model text delta.
31
- * - `tool_request` — model emitted a tool_use / function call.
32
- * - `tool_response` — tool result delivered back to the model.
33
- * - `skill_loaded` — a skill was loaded from a provider ref or
34
- * a workspace folder mount.
35
- * - `file_uploaded` — a file became available to the agent
36
- * (Files API id OR workspace path).
37
- * - `notification` — runtime/extension notification; catch-all
38
- * for diagnostic data.
39
- * - `stream_error` — stream-level error (non-fatal). Subscribers
40
- * may surface this as a UI warning; the session
41
- * continues unless `runtime_terminal` follows.
42
- * - `runtime_terminal` — the session reached a terminal state. The
43
- * adapter MUST emit exactly one of these per
44
- * run; subscribers gate on it for end-of-stream.
45
- */
46
- export declare const RUNNER_EVENT_KINDS: readonly ["runtime_started", "assistant_text", "tool_request", "tool_response", "skill_loaded", "file_uploaded", "notification", "stream_error", "runtime_terminal"];
47
- export type RunnerEventKind = (typeof RUNNER_EVENT_KINDS)[number];
48
- /**
49
- * One event in the unified stream. `seq` is monotonically increasing
50
- * within a single run (the adapter is responsible for assigning seqs
51
- * — no two events with the same `seq` for the same `sessionId`); `tMs` is
52
- * a millisecond-resolution timestamp that is also monotonically
53
- * non-decreasing within a single run (an event's `tMs` is never less
54
- * than the previous event's `tMs`). `data` carries the runtime- and
55
- * kind-specific payload, JSON-typed so the batch round-trips through
56
- * the database column without ad-hoc serialization.
57
- */
58
- export interface RunnerEvent {
59
- readonly seq: number;
60
- readonly tMs: number;
61
- /** Optional per-source ordering counter carried through to AexEvent. */
62
- readonly sourceSeq?: number;
63
- /** Optional producer wall-clock time in milliseconds. */
64
- readonly emittedAt?: number;
65
- readonly kind: RunnerEventKind;
66
- readonly data: Readonly<Record<string, JsonValue>>;
67
- }
68
- /**
69
- * Batch envelope. The runner ships one or more events per POST so the
70
- * inbox writes them atomically. `events` MUST be sorted by `seq`
71
- * ascending; api.aex.dev rejects malformed batches before touching
72
- * Postgres.
73
- */
74
- export interface RunnerEventBatch {
75
- readonly v: typeof RUNNER_EVENT_VERSION;
76
- readonly sessionId: string;
77
- readonly events: readonly RunnerEvent[];
78
- }
79
- /**
80
- * Maximum number of events per batch. Bounds the size of the body
81
- * api.aex.dev accepts and the size of the downstream Postgres / metadata-store
82
- * write. Larger streams are split into multiple batches; the runner is
83
- * responsible for chunking.
84
- */
85
- export declare const RUNNER_EVENT_BATCH_MAX_EVENTS: 256;
86
- /**
87
- * Validation outcome for an inbound batch. The `ok` branch returns
88
- * the parsed batch with frozen events; the `error` branch returns the
89
- * code + a short human message suitable for an HTTP 400 body. Codes
90
- * are stable strings — the dashboard / SDK may branch on them.
91
- */
92
- export type RunnerEventBatchValidation = {
93
- readonly ok: true;
94
- readonly batch: RunnerEventBatch;
95
- } | {
96
- readonly ok: false;
97
- readonly code: RunnerEventBatchValidationCode;
98
- readonly message: string;
99
- };
100
- export declare const RUNNER_EVENT_BATCH_VALIDATION_CODES: readonly ["invalid_envelope", "version_mismatch", "missing_session_id", "empty_batch", "batch_too_large", "invalid_event", "seq_not_monotonic", "t_ms_not_monotonic"];
101
- export type RunnerEventBatchValidationCode = (typeof RUNNER_EVENT_BATCH_VALIDATION_CODES)[number];
102
- /**
103
- * Parse + validate an inbound runner event batch (untrusted input).
104
- * Used at the api.aex.dev ingress so adapters never have to
105
- * re-check the wire shape, and used by tests to assert the contract.
106
- *
107
- * Successful validation guarantees:
108
- * - top-level envelope matches {@link RunnerEventBatch}
109
- * - `v === RUNNER_EVENT_VERSION`
110
- * - `sessionId` is a non-empty string
111
- * - `events` is a non-empty array of at most
112
- * {@link RUNNER_EVENT_BATCH_MAX_EVENTS} entries
113
- * - each event is a {@link RunnerEvent} with a known `kind`
114
- * - `seq` is strictly increasing across the batch
115
- * - `tMs` is non-decreasing across the batch
116
- */
117
- export declare function validateRunnerEventBatch(input: unknown): RunnerEventBatchValidation;