@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,520 +0,0 @@
1
- import { createForbiddenFieldNamePredicate, isPlatformContentDigest, privateResourceHandlePattern, PUBLIC_SAFE_SECRET_PATTERNS, scanPublicSafePayload, underscoredHighEntropyPattern } from "./sdk-secrets.js";
2
- import { SideEffectAuditDeletionMetadataSchema, SideEffectAuditMetadataSchema } from "./schemas/side-effect-audit.js";
3
- import { parseWire } from "./schemas/wire.js";
4
- export const SIDE_EFFECT_AUDIT_SCHEMA_VERSION = 1;
5
- export const SIDE_EFFECT_AUDIT_REDACTION_SCANNER_VERSION = 1;
6
- export const SIDE_EFFECT_AUDIT_KIND = "aex.side_effect_audit.v1";
7
- export const SIDE_EFFECT_AUDIT_ACTIONS = [
8
- "session.submit.accepted",
9
- "session.submit.rejected",
10
- "session.cancel.requested",
11
- "session.delete.requested",
12
- "session.delete.completed",
13
- "session.delete.failed",
14
- "session.download.requested",
15
- "session.file.downloaded",
16
- "session.log.downloaded",
17
- "session.event.downloaded",
18
- "workspace.asset.uploaded",
19
- "workspace.asset.deleted",
20
- "proxy.endpoint.called",
21
- "mcp.credential.accessed",
22
- "mcp.proxy.called",
23
- "provider.proxy.called",
24
- "custody.manifest.written",
25
- "custody.transition.recorded",
26
- "runtime.cleanup.completed",
27
- "runtime.cleanup.failed",
28
- "terminal_redrive.attempted",
29
- "terminal_redrive.completed",
30
- "api_key.created",
31
- "api_key.deleted",
32
- "api_key.used"
33
- ];
34
- export const SIDE_EFFECT_AUDIT_ACTOR_PRINCIPAL_TYPES = [
35
- "user",
36
- "api_key",
37
- "system",
38
- "runtime"
39
- ];
40
- export const SIDE_EFFECT_AUDIT_SOURCE_PLANES = [
41
- "dashboard",
42
- "api",
43
- "runtime",
44
- "system"
45
- ];
46
- export const SIDE_EFFECT_AUDIT_AUTHENTICATION_KINDS = [
47
- "dashboard_auth",
48
- "api_key",
49
- "runner_token",
50
- "system"
51
- ];
52
- export const SIDE_EFFECT_AUDIT_TARGET_TYPES = [
53
- "workspace",
54
- "session",
55
- "proxy_endpoint",
56
- "mcp_credential",
57
- "mcp_proxy",
58
- "provider_proxy",
59
- "file_archive",
60
- "session_file",
61
- "session_log",
62
- "session_event_stream",
63
- "workspace_asset",
64
- "custody_manifest",
65
- "custody_transition",
66
- "cleanup",
67
- "deletion",
68
- "terminal_redrive",
69
- "api_key"
70
- ];
71
- export const SIDE_EFFECT_AUDIT_OUTCOMES = [
72
- "accepted",
73
- "rejected",
74
- "succeeded",
75
- "failed",
76
- "denied",
77
- "canceled",
78
- "pending"
79
- ];
80
- export const SIDE_EFFECT_AUDIT_COUNT_NAMES = [
81
- "requestBytes",
82
- "responseBytes",
83
- "durationMs",
84
- "attemptCount",
85
- "retryCount",
86
- "fileCount",
87
- "logCount",
88
- "eventCount",
89
- "assetCount",
90
- "proxyCallCount",
91
- "mcpCallCount",
92
- "providerProxyCallCount",
93
- "secretClassCount",
94
- "resourceClassCount",
95
- "deletedObjectCount",
96
- "retainedObjectCount",
97
- "failedObjectCount",
98
- "quotaRequestedUnits",
99
- "quotaRemainingUnits",
100
- "reservationCount"
101
- ];
102
- export const SIDE_EFFECT_AUDIT_TIMESTAMP_NAMES = [
103
- "startedAt",
104
- "finishedAt",
105
- "observedAt",
106
- "decidedAt",
107
- "deletedAt",
108
- "terminalAt",
109
- "expiresAt"
110
- ];
111
- export const SIDE_EFFECT_AUDIT_METADATA_EXCLUDED_VALUE_CLASSES = [
112
- "headers",
113
- "bodies",
114
- "raw_urls",
115
- "raw_paths",
116
- "query_strings",
117
- "provider_response_bodies",
118
- "signed_urls",
119
- "object_store_keys",
120
- "vault_ids",
121
- "resource_handles",
122
- "bearer_hashes",
123
- "secret_values",
124
- "customer_or_agent_identity",
125
- "private_pricing_or_provider_deployment"
126
- ];
127
- export class SideEffectAuditRedactionError extends Error {
128
- code = "side_effect_audit_not_public_safe";
129
- findings;
130
- constructor(findings) {
131
- super(`side-effect audit payload contains non-public data at ${formatFindingPaths(findings)}`);
132
- this.name = "SideEffectAuditRedactionError";
133
- this.findings = Object.freeze([...findings]);
134
- }
135
- }
136
- export function buildSideEffectAuditEvent(input) {
137
- const action = normalizeAction(input.action);
138
- const event = Object.freeze({
139
- schemaVersion: SIDE_EFFECT_AUDIT_SCHEMA_VERSION,
140
- kind: SIDE_EFFECT_AUDIT_KIND,
141
- ...(input.auditId ? { auditId: assertSafeIdentifier(input.auditId, "auditId") } : {}),
142
- workspaceId: assertSafeIdentifier(input.workspaceId, "workspaceId"),
143
- ...(input.sessionId ? { sessionId: assertSafeIdentifier(input.sessionId, "sessionId") } : {}),
144
- action,
145
- outcome: normalizeOutcome(input.outcome),
146
- observedAt: assertTimestamp(input.observedAt, "observedAt"),
147
- actor: normalizeActor(input.actor),
148
- target: normalizeTarget(input.target),
149
- ...(input.correlation ? { correlation: normalizeCorrelation(input.correlation) } : {}),
150
- metadata: redactSideEffectAuditMetadata(input.metadata ?? {}, action)
151
- });
152
- assertPublicSafeSideEffectAuditPayload(event);
153
- return event;
154
- }
155
- export function buildSessionDeletionRequestedAuditEvent(input) {
156
- return buildSessionScopedAuditEvent(input, {
157
- action: "session.delete.requested",
158
- outcome: "accepted",
159
- targetType: "deletion"
160
- });
161
- }
162
- export function buildSessionDeletionCompletedAuditEvent(input) {
163
- return buildSessionScopedAuditEvent(input, {
164
- action: "session.delete.completed",
165
- outcome: "succeeded",
166
- targetType: "deletion"
167
- });
168
- }
169
- export function buildSessionDeletionFailedAuditEvent(input) {
170
- return buildSessionScopedAuditEvent(input, {
171
- action: "session.delete.failed",
172
- outcome: "failed",
173
- targetType: "deletion"
174
- });
175
- }
176
- export function buildSessionDownloadRequestedAuditEvent(input) {
177
- return buildSessionScopedAuditEvent(input, {
178
- action: "session.download.requested",
179
- outcome: "accepted",
180
- targetType: "file_archive"
181
- });
182
- }
183
- export function buildCustodyManifestWrittenAuditEvent(input) {
184
- return buildSessionScopedAuditEvent(input, {
185
- action: "custody.manifest.written",
186
- outcome: "succeeded",
187
- targetType: "custody_manifest"
188
- });
189
- }
190
- export function redactSideEffectAuditMetadata(input, action) {
191
- assertPublicSafeSideEffectAuditPayload(input);
192
- assertSupportedMetadata(input, action);
193
- const metadata = Object.freeze({
194
- ...(input.status ? { status: normalizeStatusMetadata(input.status) } : {}),
195
- ...(input.counts ? { counts: normalizeCounts(input.counts) } : {}),
196
- ...(input.timestamps ? { timestamps: normalizeTimestamps(input.timestamps) } : {}),
197
- ...(input.dimensions && !isDeletionAction(action)
198
- ? { dimensions: normalizeDimensions(input.dimensions) }
199
- : {}),
200
- redaction: Object.freeze({
201
- policy: "metadata_only",
202
- scannerVersion: SIDE_EFFECT_AUDIT_REDACTION_SCANNER_VERSION,
203
- excludes: Object.freeze([...SIDE_EFFECT_AUDIT_METADATA_EXCLUDED_VALUE_CLASSES])
204
- })
205
- });
206
- assertPublicSafeSideEffectAuditPayload(metadata);
207
- return metadata;
208
- }
209
- export function scanSideEffectAuditPayloadForSensitiveValues(input) {
210
- return scanPublicSafePayload(input, {
211
- patterns: auditStringPatterns,
212
- isForbiddenFieldName: isForbiddenAuditFieldName,
213
- isPatternExempt: ({ reason, path, match }) => reason === "high_entropy_token" &&
214
- path === "$.target.id" &&
215
- isPlatformContentDigest(match)
216
- });
217
- }
218
- export function assertPublicSafeSideEffectAuditPayload(input) {
219
- const findings = scanSideEffectAuditPayloadForSensitiveValues(input);
220
- if (findings.length > 0) {
221
- throw new SideEffectAuditRedactionError(findings);
222
- }
223
- }
224
- function normalizeActor(input) {
225
- if (!input || typeof input !== "object") {
226
- throw new Error("side-effect audit actor must be an object");
227
- }
228
- return Object.freeze({
229
- principal: normalizePrincipal(input.principal),
230
- sourcePlane: normalizeSourcePlane(input.sourcePlane),
231
- ...(input.authenticatedBy ? { authenticatedBy: normalizeAuthentication(input.authenticatedBy) } : {})
232
- });
233
- }
234
- function normalizePrincipal(input) {
235
- if (!input || typeof input !== "object") {
236
- throw new Error("side-effect audit actor principal must be an object");
237
- }
238
- const type = normalizePrincipalType(input.type);
239
- const ref = input.ref ? assertSafePrincipalRef(input.ref, "actor.principal.ref") : undefined;
240
- return Object.freeze({
241
- type,
242
- ...(ref ? { ref } : {})
243
- });
244
- }
245
- function normalizeTarget(input) {
246
- if (!input || typeof input !== "object") {
247
- throw new Error("side-effect audit target must be an object");
248
- }
249
- return Object.freeze({
250
- type: normalizeTargetType(input.type),
251
- ...(input.id ? { id: assertSafeIdentifier(input.id, "target.id") } : {}),
252
- ...(input.name ? { name: assertSafeMetadataString(input.name, "target.name") } : {})
253
- });
254
- }
255
- function normalizeCorrelation(input) {
256
- return Object.freeze({
257
- ...(input.requestId ? { requestId: assertSafeIdentifier(input.requestId, "correlation.requestId") } : {}),
258
- ...(input.operationId
259
- ? { operationId: assertSafeIdentifier(input.operationId, "correlation.operationId") }
260
- : {}),
261
- ...(input.eventId ? { eventId: assertSafeIdentifier(input.eventId, "correlation.eventId") } : {}),
262
- ...(input.parentAuditId
263
- ? { parentAuditId: assertSafeIdentifier(input.parentAuditId, "correlation.parentAuditId") }
264
- : {}),
265
- ...(input.sourceAuditId
266
- ? { sourceAuditId: assertSafeIdentifier(input.sourceAuditId, "correlation.sourceAuditId") }
267
- : {}),
268
- ...(input.idempotencyKeyRef
269
- ? {
270
- idempotencyKeyRef: assertSafeIdentifier(input.idempotencyKeyRef, "correlation.idempotencyKeyRef")
271
- }
272
- : {})
273
- });
274
- }
275
- /**
276
- * Drop the absent fields of an already-validated `metadata.status`.
277
- *
278
- * Shape, supported keys, and the `statusCode` range are settled by
279
- * `SideEffectAuditStatusMetadataSchema` before this runs. What remains is
280
- * the public-safety scan, which no schema can perform because it raises
281
- * {@link SideEffectAuditRedactionError} rather than a parse failure, and the
282
- * empty-string drop — a falsy value carries no signal and is omitted rather
283
- * than recorded.
284
- */
285
- function normalizeStatusMetadata(input) {
286
- return Object.freeze({
287
- ...(input.status ? { status: assertSafeMetadataString(input.status, "metadata.status.status") } : {}),
288
- ...(input.statusCode !== undefined ? { statusCode: input.statusCode } : {}),
289
- ...(input.errorClass
290
- ? { errorClass: assertSafeMetadataString(input.errorClass, "metadata.status.errorClass") }
291
- : {}),
292
- ...(input.denialReason
293
- ? { denialReason: assertSafeMetadataString(input.denialReason, "metadata.status.denialReason") }
294
- : {}),
295
- ...(input.followUpRequired !== undefined ? { followUpRequired: input.followUpRequired } : {})
296
- });
297
- }
298
- function normalizeCounts(input) {
299
- const out = {};
300
- for (const [key, value] of Object.entries(input)) {
301
- if (!isStringIn(key, SIDE_EFFECT_AUDIT_COUNT_NAMES)) {
302
- throw new Error(`side-effect audit metadata.counts.${key} is not supported`);
303
- }
304
- if (value !== undefined) {
305
- out[key] = nonNegativeFinite(value, `metadata.counts.${key}`);
306
- }
307
- }
308
- return Object.freeze(out);
309
- }
310
- function normalizeTimestamps(input) {
311
- const out = {};
312
- for (const [key, value] of Object.entries(input)) {
313
- if (!isStringIn(key, SIDE_EFFECT_AUDIT_TIMESTAMP_NAMES)) {
314
- throw new Error(`side-effect audit metadata.timestamps.${key} is not supported`);
315
- }
316
- if (value !== undefined) {
317
- out[key] = assertTimestamp(value, `metadata.timestamps.${key}`);
318
- }
319
- }
320
- return Object.freeze(out);
321
- }
322
- /**
323
- * Drop the absent fields of an already-validated `metadata.dimensions`.
324
- *
325
- * Sibling of {@link normalizeStatusMetadata}: supported keys and the closed
326
- * `namespace` / `method` value sets are settled by
327
- * `SideEffectAuditDimensionsMetadataSchema`, leaving only the scan and the
328
- * empty-value drop.
329
- */
330
- function normalizeDimensions(input) {
331
- return Object.freeze({
332
- ...(input.provider ? { provider: assertSafeMetadataString(input.provider, "metadata.dimensions.provider") } : {}),
333
- ...(input.namespace ? { namespace: input.namespace } : {}),
334
- ...(input.method ? { method: input.method } : {}),
335
- ...(input.surface ? { surface: assertSafeMetadataString(input.surface, "metadata.dimensions.surface") } : {})
336
- });
337
- }
338
- /**
339
- * Reject an envelope a caller may not send, choosing the schema by action.
340
- *
341
- * The two schemas differ only in whether `dimensions` is a declared container,
342
- * so a deletion audit reports it with the same "not supported" wording an
343
- * invented key gets. Nested containers are validated in the same pass; the
344
- * shallowest complaint is the one reported, which is the order the hand-written
345
- * ladder produced.
346
- */
347
- function assertSupportedMetadata(input, action) {
348
- parseWire(isDeletionAction(action)
349
- ? SideEffectAuditDeletionMetadataSchema
350
- : SideEffectAuditMetadataSchema, input);
351
- }
352
- function buildSessionScopedAuditEvent(input, spec) {
353
- return buildSideEffectAuditEvent({
354
- workspaceId: input.workspaceId,
355
- sessionId: input.sessionId,
356
- action: spec.action,
357
- outcome: spec.outcome,
358
- observedAt: input.observedAt,
359
- actor: input.actor,
360
- target: { type: spec.targetType, id: input.sessionId },
361
- ...(input.correlation ? { correlation: input.correlation } : {}),
362
- ...(input.metadata ? { metadata: input.metadata } : {})
363
- });
364
- }
365
- function normalizeAction(input) {
366
- if (!isStringIn(input, SIDE_EFFECT_AUDIT_ACTIONS)) {
367
- throw new Error(`side-effect audit action ${String(input)} is not supported`);
368
- }
369
- return input;
370
- }
371
- function normalizeOutcome(input) {
372
- if (!isStringIn(input, SIDE_EFFECT_AUDIT_OUTCOMES)) {
373
- throw new Error(`side-effect audit outcome ${String(input)} is not supported`);
374
- }
375
- return input;
376
- }
377
- function normalizePrincipalType(input) {
378
- if (!isStringIn(input, SIDE_EFFECT_AUDIT_ACTOR_PRINCIPAL_TYPES)) {
379
- throw new Error(`side-effect audit principal type ${String(input)} is not supported`);
380
- }
381
- return input;
382
- }
383
- function normalizeSourcePlane(input) {
384
- if (!isStringIn(input, SIDE_EFFECT_AUDIT_SOURCE_PLANES)) {
385
- throw new Error(`side-effect audit source plane ${String(input)} is not supported`);
386
- }
387
- return input;
388
- }
389
- function normalizeAuthentication(input) {
390
- if (!isStringIn(input, SIDE_EFFECT_AUDIT_AUTHENTICATION_KINDS)) {
391
- throw new Error(`side-effect audit authentication kind ${String(input)} is not supported`);
392
- }
393
- return input;
394
- }
395
- function normalizeTargetType(input) {
396
- if (!isStringIn(input, SIDE_EFFECT_AUDIT_TARGET_TYPES)) {
397
- throw new Error(`side-effect audit target type ${String(input)} is not supported`);
398
- }
399
- return input;
400
- }
401
- function isDeletionAction(action) {
402
- return action === "session.delete.requested" || action === "session.delete.completed" || action === "session.delete.failed";
403
- }
404
- const auditStringPatterns = Object.freeze([
405
- ...PUBLIC_SAFE_SECRET_PATTERNS,
406
- underscoredHighEntropyPattern(),
407
- privateResourceHandlePattern([
408
- "machine",
409
- "agent",
410
- "resource",
411
- "handle",
412
- "token_hash",
413
- "bearer_hash"
414
- ]),
415
- Object.freeze({ reason: "raw_url", regex: /\bhttps?:\/\/\S+/i }),
416
- Object.freeze({
417
- reason: "raw_path",
418
- regex: /(^|[\s"'`])\/[A-Za-z0-9._~!$&'()*+,;=:@%-]+(?:[/?#][^\s"'`]*)?/
419
- })
420
- ]);
421
- const isForbiddenAuditFieldName = createForbiddenFieldNamePredicate([
422
- "authorization",
423
- "header",
424
- "headers",
425
- "requestHeader",
426
- "requestHeaders",
427
- "responseHeader",
428
- "responseHeaders",
429
- "body",
430
- "requestBody",
431
- "responseBody",
432
- "rawBody",
433
- "prompt",
434
- "url",
435
- "rawUrl",
436
- "href",
437
- "query",
438
- "queryString",
439
- "path",
440
- "rawPath",
441
- "signedUrl",
442
- "objectStoreKey",
443
- "objectKey",
444
- "vaultId",
445
- "providerResponseBody",
446
- "providerAccountId",
447
- "providerDeployment",
448
- "rateCard",
449
- "rateCardVersion",
450
- "margin",
451
- "discount",
452
- "calculator",
453
- "reconciliation",
454
- "resourceHandle",
455
- "privateResourceHandle",
456
- "bearerHash",
457
- "tokenHash",
458
- "apiKey",
459
- "apiKeys",
460
- "secretValue",
461
- "providerSessionId",
462
- "agentId",
463
- "customerId",
464
- "endUserId",
465
- "identity",
466
- "email"
467
- ]);
468
- function assertSafeIdentifier(value, field) {
469
- assertNonEmptyString(value, field);
470
- if (!/^[A-Za-z0-9._:-]+$/.test(value)) {
471
- throw new Error(`side-effect audit ${field} must be an opaque identifier without path separators`);
472
- }
473
- if (field === "target.id" && isPlatformContentDigest(value)) {
474
- return value;
475
- }
476
- assertPublicSafeSideEffectAuditPayload(value);
477
- return value;
478
- }
479
- function assertSafePrincipalRef(value, field) {
480
- assertNonEmptyString(value, field);
481
- if (!/^[A-Za-z0-9._:-]+$/.test(value)) {
482
- throw new Error(`side-effect audit ${field} must be an opaque identifier without path separators`);
483
- }
484
- const ref = value;
485
- if (/^(?:agent|session|customer|end[_-]?user|provider[_-]?session)[_.:-]/i.test(ref)) {
486
- throw new Error(`side-effect audit ${field} must not introduce agent, session, or customer identity`);
487
- }
488
- assertPublicSafeSideEffectAuditPayload(ref);
489
- return ref;
490
- }
491
- function assertSafeMetadataString(value, field) {
492
- assertNonEmptyString(value, field);
493
- assertPublicSafeSideEffectAuditPayload(value);
494
- return value;
495
- }
496
- function assertNonEmptyString(value, field) {
497
- if (typeof value !== "string" || value.trim().length === 0) {
498
- throw new Error(`side-effect audit ${field} must be a non-empty string`);
499
- }
500
- }
501
- function assertTimestamp(value, field) {
502
- assertSafeMetadataString(value, field);
503
- const ms = Date.parse(value);
504
- if (!Number.isFinite(ms)) {
505
- throw new Error(`side-effect audit ${field} must be an ISO timestamp string`);
506
- }
507
- return value;
508
- }
509
- function nonNegativeFinite(value, field) {
510
- if (!Number.isFinite(value) || value < 0) {
511
- throw new Error(`side-effect audit ${field} must be a non-negative finite number`);
512
- }
513
- return value;
514
- }
515
- function formatFindingPaths(findings) {
516
- return findings.map((finding) => `${finding.path} (${finding.reason})`).join(", ");
517
- }
518
- function isStringIn(value, allowed) {
519
- return typeof value === "string" && allowed.includes(value);
520
- }
@@ -1,74 +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
- export interface SseFrame {
25
- readonly id?: string;
26
- readonly event: string;
27
- readonly data: string;
28
- readonly retry?: number;
29
- }
30
- /**
31
- * Stateful parser: feed in chunks (in any size), pull out completed
32
- * frames. Designed for `for await` consumption — see `iterateSse`.
33
- */
34
- export declare class SseParser {
35
- #private;
36
- /**
37
- * Push a chunk of raw bytes through the parser. Returns any frames
38
- * that completed during this chunk. Chunks may contain zero, one,
39
- * or many frame boundaries — the parser handles partial trailing
40
- * data internally.
41
- */
42
- pushBytes(chunk: Uint8Array): readonly SseFrame[];
43
- /**
44
- * Push a text chunk directly. Used by the parser tests so they can
45
- * exercise byte-boundary edge cases without manufacturing a
46
- * `TextDecoder` round-trip.
47
- */
48
- pushText(text: string): readonly SseFrame[];
49
- /**
50
- * Indicate end-of-stream. Returns any final frame that the dispatcher
51
- * was holding when the stream closed mid-frame (no trailing blank
52
- * line). The dispatcher pattern is: blank line dispatches; if the
53
- * remote closes after a partial frame, that frame is dropped per the
54
- * spec.
55
- */
56
- flush(): void;
57
- /**
58
- * Current "last event id" — the cursor the SSE spec instructs the
59
- * client to replay on automatic reconnection. Callers use this to
60
- * resume after a disconnect.
61
- */
62
- get lastEventId(): string | undefined;
63
- }
64
- /**
65
- * Convert a web `ReadableStream<Uint8Array>` (the body of a fetch
66
- * Response) into an async iterable of SSE frames. The stream is
67
- * consumed exactly once; the caller is responsible for cancelling
68
- * the underlying reader on abort.
69
- *
70
- * The reader is raced against the abort signal so a long-blocked
71
- * server (no chunks for many seconds) still releases the loop
72
- * promptly when the consumer aborts.
73
- */
74
- export declare function iterateSse(body: ReadableStream<Uint8Array>, signal?: AbortSignal): AsyncIterable<SseFrame>;