@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,172 +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 { isJsonRecord, isRecord, isStringLiteral } 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 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 const RUNNER_EVENT_KINDS = [
47
- "runtime_started",
48
- "assistant_text",
49
- "tool_request",
50
- "tool_response",
51
- "skill_loaded",
52
- "file_uploaded",
53
- "notification",
54
- "stream_error",
55
- "runtime_terminal"
56
- ];
57
- /**
58
- * Maximum number of events per batch. Bounds the size of the body
59
- * api.aex.dev accepts and the size of the downstream Postgres / metadata-store
60
- * write. Larger streams are split into multiple batches; the runner is
61
- * responsible for chunking.
62
- */
63
- export const RUNNER_EVENT_BATCH_MAX_EVENTS = 256;
64
- export const RUNNER_EVENT_BATCH_VALIDATION_CODES = [
65
- "invalid_envelope",
66
- "version_mismatch",
67
- "missing_session_id",
68
- "empty_batch",
69
- "batch_too_large",
70
- "invalid_event",
71
- "seq_not_monotonic",
72
- "t_ms_not_monotonic"
73
- ];
74
- /**
75
- * Parse + validate an inbound runner event batch (untrusted input).
76
- * Used at the api.aex.dev ingress so adapters never have to
77
- * re-check the wire shape, and used by tests to assert the contract.
78
- *
79
- * Successful validation guarantees:
80
- * - top-level envelope matches {@link RunnerEventBatch}
81
- * - `v === RUNNER_EVENT_VERSION`
82
- * - `sessionId` is a non-empty string
83
- * - `events` is a non-empty array of at most
84
- * {@link RUNNER_EVENT_BATCH_MAX_EVENTS} entries
85
- * - each event is a {@link RunnerEvent} with a known `kind`
86
- * - `seq` is strictly increasing across the batch
87
- * - `tMs` is non-decreasing across the batch
88
- */
89
- export function validateRunnerEventBatch(input) {
90
- if (!isRecord(input)) {
91
- return invalid("invalid_envelope", "batch must be a JSON object");
92
- }
93
- if (input.v !== RUNNER_EVENT_VERSION) {
94
- return invalid("version_mismatch", `batch.v must equal ${RUNNER_EVENT_VERSION} (got ${JSON.stringify(input.v)})`);
95
- }
96
- if (typeof input.sessionId !== "string" || input.sessionId.length === 0) {
97
- return invalid("missing_session_id", "batch.sessionId must be a non-empty string");
98
- }
99
- if (!Array.isArray(input.events) || input.events.length === 0) {
100
- return invalid("empty_batch", "batch.events must be a non-empty array");
101
- }
102
- if (input.events.length > RUNNER_EVENT_BATCH_MAX_EVENTS) {
103
- return invalid("batch_too_large", `batch.events has ${input.events.length} entries; max is ${RUNNER_EVENT_BATCH_MAX_EVENTS}`);
104
- }
105
- let lastSeq = Number.NEGATIVE_INFINITY;
106
- let lastTMs = Number.NEGATIVE_INFINITY;
107
- const events = [];
108
- for (let i = 0; i < input.events.length; i++) {
109
- const evt = input.events[i];
110
- if (!isRecord(evt)) {
111
- return invalid("invalid_event", `events[${i}] must be a JSON object`);
112
- }
113
- if (typeof evt.seq !== "number" ||
114
- !Number.isFinite(evt.seq) ||
115
- !Number.isInteger(evt.seq) ||
116
- evt.seq < 0) {
117
- return invalid("invalid_event", `events[${i}].seq must be a non-negative integer`);
118
- }
119
- if (typeof evt.tMs !== "number" ||
120
- !Number.isFinite(evt.tMs) ||
121
- !Number.isInteger(evt.tMs) ||
122
- evt.tMs < 0) {
123
- return invalid("invalid_event", `events[${i}].tMs must be a non-negative integer`);
124
- }
125
- if (!isStringLiteral(evt.kind, RUNNER_EVENT_KINDS)) {
126
- return invalid("invalid_event", `events[${i}].kind must be one of: ${RUNNER_EVENT_KINDS.join(", ")} (got ${JSON.stringify(evt.kind)})`);
127
- }
128
- if (evt.sourceSeq !== undefined &&
129
- (typeof evt.sourceSeq !== "number" ||
130
- !Number.isFinite(evt.sourceSeq) ||
131
- !Number.isInteger(evt.sourceSeq) ||
132
- evt.sourceSeq < 0)) {
133
- return invalid("invalid_event", `events[${i}].sourceSeq must be a non-negative integer when present`);
134
- }
135
- if (evt.emittedAt !== undefined &&
136
- (typeof evt.emittedAt !== "number" ||
137
- !Number.isFinite(evt.emittedAt) ||
138
- !Number.isInteger(evt.emittedAt) ||
139
- evt.emittedAt < 0)) {
140
- return invalid("invalid_event", `events[${i}].emittedAt must be a non-negative integer when present`);
141
- }
142
- if (!isRecord(evt.data)) {
143
- return invalid("invalid_event", `events[${i}].data must be a JSON object`);
144
- }
145
- if (!isJsonRecord(evt.data)) {
146
- return invalid("invalid_event", `events[${i}].data must be JSON-serializable`);
147
- }
148
- if (evt.seq <= lastSeq) {
149
- return invalid("seq_not_monotonic", `events[${i}].seq=${evt.seq} must be strictly greater than the previous seq=${lastSeq}`);
150
- }
151
- if (evt.tMs < lastTMs) {
152
- return invalid("t_ms_not_monotonic", `events[${i}].tMs=${evt.tMs} must be >= the previous tMs=${lastTMs}`);
153
- }
154
- lastSeq = evt.seq;
155
- lastTMs = evt.tMs;
156
- events.push({
157
- seq: evt.seq,
158
- tMs: evt.tMs,
159
- ...(evt.sourceSeq !== undefined ? { sourceSeq: evt.sourceSeq } : {}),
160
- ...(evt.emittedAt !== undefined ? { emittedAt: evt.emittedAt } : {}),
161
- kind: evt.kind,
162
- data: Object.freeze({ ...evt.data })
163
- });
164
- }
165
- return {
166
- ok: true,
167
- batch: { v: RUNNER_EVENT_VERSION, sessionId: input.sessionId, events: Object.freeze(events) }
168
- };
169
- }
170
- function invalid(code, message) {
171
- return { ok: false, code, message };
172
- }
@@ -1,60 +0,0 @@
1
- /**
2
- * Managed execution-runtime selector ("which backend runs the session").
3
- *
4
- * Distinct from {@link import("./runtime-sizes.js").RuntimeSize} ("how big the
5
- * box is"). A session picks BOTH: a `runtimeKind` (this file) and a
6
- * `runtimeSize`. The kind selects the execution backend; the size selects the
7
- * vCPU/memory preset within it.
8
- *
9
- * Three product runtimes, selected per session (feature addition, not a
10
- * migration — see `references/microvm-migration-2026-07-15/00`§0):
11
- * - `container` — today's co-located Fargate (on-demand). Explicit opt-in.
12
- * - `spot_container` — the same behavior on Fargate Spot: cheaper and
13
- * interruption tolerant through durable recovery. This is
14
- * {@link DEFAULT_RUNTIME_KIND}.
15
- * - `lambda` — event-driven Lambda + on-demand MicroVM sandbox;
16
- * idle → $0, fast resume, ≤32 GB workspace.
17
- *
18
- * The wire shape of a submission is identical across all three, but the runtimes
19
- * are NOT yet capability-equivalent: `lambda` has a 900 s per-invocation ceiling, a
20
- * 32 GiB / 8 h sandbox, and no tool execution until the MicroVM hands channel ships.
21
- * `spot_container` executes side-effecting tools at-least-once because a Spot
22
- * reclaim replays the interrupted step. Pricing differs per runtime.
23
- */
24
- import { RUNTIME_KINDS } from "./schemas/runtime-kind.js";
25
- /** The accepted execution-runtime values (the wire/CLI tokens). */
26
- export { RUNTIME_KINDS };
27
- /** One of the closed {@link RUNTIME_KINDS} tokens. */
28
- export type RuntimeKind = (typeof RUNTIME_KINDS)[number];
29
- /**
30
- * Default when `runtimeKind` is omitted: `spot_container` (Fargate Spot).
31
- *
32
- * Chosen because it is the cheapest kind that can execute every tool today. The
33
- * `lambda` path can finish an LLM turn but cannot execute a tool call, so it is
34
- * an explicit opt-in rather than the default. Kept byte-equal to the hosted
35
- * declaration in `packages/contract-core/src/runtime-kind.ts`, which carries the
36
- * revert condition.
37
- */
38
- export declare const DEFAULT_RUNTIME_KIND: RuntimeKind;
39
- /**
40
- * Symbol-style accessors for TS callers: `RuntimeKinds.SPOT_CONTAINER` resolves
41
- * to the wire token `"spot_container"`. Re-exported by the SDK as
42
- * `RuntimeKinds`. Prefer these over raw strings so an invalid token is a compile
43
- * error, not a runtime 400.
44
- */
45
- export declare const RuntimeKinds: {
46
- /** Today's co-located Fargate, on-demand capacity. Explicit opt-in. */
47
- readonly CONTAINER: "container";
48
- /**
49
- * Fargate Spot — same behavior, cheaper capacity, interruption tolerant.
50
- * This is {@link DEFAULT_RUNTIME_KIND}: what an omitted `runtime.kind` resolves to.
51
- */
52
- readonly SPOT_CONTAINER: "spot_container";
53
- /** Event-driven Lambda + on-demand MicroVM sandbox; idle → $0. Explicit opt-in. */
54
- readonly LAMBDA: "lambda";
55
- };
56
- /**
57
- * Validate the wire `runtimeKind` field. `undefined` (omitted) is allowed and
58
- * consumers apply {@link DEFAULT_RUNTIME_KIND}.
59
- */
60
- export declare function parseRuntimeKind(input: unknown): RuntimeKind | undefined;
@@ -1,70 +0,0 @@
1
- /**
2
- * Managed execution-runtime selector ("which backend runs the session").
3
- *
4
- * Distinct from {@link import("./runtime-sizes.js").RuntimeSize} ("how big the
5
- * box is"). A session picks BOTH: a `runtimeKind` (this file) and a
6
- * `runtimeSize`. The kind selects the execution backend; the size selects the
7
- * vCPU/memory preset within it.
8
- *
9
- * Three product runtimes, selected per session (feature addition, not a
10
- * migration — see `references/microvm-migration-2026-07-15/00`§0):
11
- * - `container` — today's co-located Fargate (on-demand). Explicit opt-in.
12
- * - `spot_container` — the same behavior on Fargate Spot: cheaper and
13
- * interruption tolerant through durable recovery. This is
14
- * {@link DEFAULT_RUNTIME_KIND}.
15
- * - `lambda` — event-driven Lambda + on-demand MicroVM sandbox;
16
- * idle → $0, fast resume, ≤32 GB workspace.
17
- *
18
- * The wire shape of a submission is identical across all three, but the runtimes
19
- * are NOT yet capability-equivalent: `lambda` has a 900 s per-invocation ceiling, a
20
- * 32 GiB / 8 h sandbox, and no tool execution until the MicroVM hands channel ships.
21
- * `spot_container` executes side-effecting tools at-least-once because a Spot
22
- * reclaim replays the interrupted step. Pricing differs per runtime.
23
- */
24
- import { rethrowContractParseError } from "./contract-parse-error.js";
25
- import { RUNTIME_KINDS, RuntimeKindSchema } from "./schemas/runtime-kind.js";
26
- import { parseWire } from "./schemas/wire.js";
27
- /** The accepted execution-runtime values (the wire/CLI tokens). */
28
- export { RUNTIME_KINDS };
29
- /**
30
- * Default when `runtimeKind` is omitted: `spot_container` (Fargate Spot).
31
- *
32
- * Chosen because it is the cheapest kind that can execute every tool today. The
33
- * `lambda` path can finish an LLM turn but cannot execute a tool call, so it is
34
- * an explicit opt-in rather than the default. Kept byte-equal to the hosted
35
- * declaration in `packages/contract-core/src/runtime-kind.ts`, which carries the
36
- * revert condition.
37
- */
38
- export const DEFAULT_RUNTIME_KIND = "spot_container";
39
- /**
40
- * Symbol-style accessors for TS callers: `RuntimeKinds.SPOT_CONTAINER` resolves
41
- * to the wire token `"spot_container"`. Re-exported by the SDK as
42
- * `RuntimeKinds`. Prefer these over raw strings so an invalid token is a compile
43
- * error, not a runtime 400.
44
- */
45
- export const RuntimeKinds = {
46
- /** Today's co-located Fargate, on-demand capacity. Explicit opt-in. */
47
- CONTAINER: "container",
48
- /**
49
- * Fargate Spot — same behavior, cheaper capacity, interruption tolerant.
50
- * This is {@link DEFAULT_RUNTIME_KIND}: what an omitted `runtime.kind` resolves to.
51
- */
52
- SPOT_CONTAINER: "spot_container",
53
- /** Event-driven Lambda + on-demand MicroVM sandbox; idle → $0. Explicit opt-in. */
54
- LAMBDA: "lambda"
55
- };
56
- /**
57
- * Validate the wire `runtimeKind` field. `undefined` (omitted) is allowed and
58
- * consumers apply {@link DEFAULT_RUNTIME_KIND}.
59
- */
60
- export function parseRuntimeKind(input) {
61
- try {
62
- if (input === undefined) {
63
- return undefined;
64
- }
65
- return parseWire(RuntimeKindSchema, input);
66
- }
67
- catch (error) {
68
- rethrowContractParseError(error, "parseRuntimeKind");
69
- }
70
- }
@@ -1,121 +0,0 @@
1
- import type { ProviderName } from "./submission.js";
2
- /**
3
- * Runtime manifest: the per-session description of where
4
- * aex places things inside the agent container, plus the merged
5
- * env-var bag delivered via `RUNTIME.env` / `RUNTIME.json`.
6
- *
7
- * A manifest is computed from the validated submission via
8
- * {@link buildRuntimeManifest}, so caller code (anyone rendering catalog
9
- * markdown pre-submission, or resolving aex's in-container path strings)
10
- * doesn't have to guess.
11
- *
12
- * It is NOT on the session wire. `Session.runtimeManifest` was declared and
13
- * `publicSessionFromItem` has never emitted one, so every read of it returned
14
- * `undefined`; the field is gone rather than left as a promise nothing keeps.
15
- * Build the manifest from the submission instead.
16
- *
17
- * The managed runtime materialises the actual `RUNTIME.env` / `RUNTIME.json`
18
- * files in-container from the same envVars inputs, so the
19
- * SDK-side view and the in-container view describe the same layout.
20
- *
21
- * Manifest values are derived, never persisted separately — the source
22
- * of truth for the customer half remains `submission.environment.envVars`
23
- * on the session row; the aex half is constant for a given SDK version.
24
- */
25
- /**
26
- * The in-container paths the agent and skill code reference at
27
- * runtime. All fields are absolute, all reflect Anthropic Managed
28
- * Agents' session-mount rebase rule (every `mount_path` lands under
29
- * `/mnt/session/uploads/` regardless of the leading slash).
30
- *
31
- * `skillsRoot` is the location of Skills API-registered bundles, which
32
- * the runtime auto-discovers under `/workspace/skills/<name>/` —
33
- * empirically a separate root from the session-resource mounts, NOT
34
- * under `/mnt/session/uploads/`.
35
- */
36
- export interface RuntimeManifest {
37
- readonly provider: ProviderName | string;
38
- /** Where skill bundles auto-discover in the managed runner. */
39
- readonly skillsRoot: string;
40
- /** Parent dir of File mounts: `<filesRoot>/<f_id>/<rel-path>`. */
41
- readonly filesRoot: string;
42
- /** Parent dir of non-SKILL.md asset mounts: `<assetsRoot>/<skl_id>/<rel-path>`. */
43
- readonly assetsRoot: string;
44
- /** Absolute path of the in-container aex runtime bridge (invoke via `bun`). */
45
- readonly aexCli: string;
46
- /** Absolute path of the in-container aex runtime index. */
47
- readonly indexJson: string;
48
- /** Absolute path of the always-mounted aex runtime contract README. */
49
- readonly readme: string;
50
- /** Absolute path of the machine-readable manifest mirror. */
51
- readonly runtimeJson: string;
52
- /** Absolute path of the POSIX-shell-sourceable runtime env file. */
53
- readonly runtimeEnv: string;
54
- /**
55
- * Merged env-var bag: aex-set runtime keys (with reserved
56
- * `AEX_` prefix) plus customer-supplied `environment.envVars`.
57
- * Both `RUNTIME.env` and `RUNTIME.json` are rendered from this
58
- * exact map; `__KEY__` substitution in agent-facing markdown
59
- * resolves against this exact map.
60
- */
61
- readonly envVars: Readonly<Record<string, string>>;
62
- /**
63
- * The resolved in-container mount DIRECTORY of each submitted `File`, so the
64
- * caller can learn where a handed file landed. `mountPath` is the validated
65
- * directory the archive unzipped into (the SDK default is `/workspace`); a
66
- * single file lands at `<mountPath>/<realFilename>`, a folder lands its entries
67
- * under `<mountPath>/`. Empty when the session carried no files.
68
- */
69
- readonly mountedFiles: readonly MountedFileManifest[];
70
- }
71
- /** One submitted `File`'s resolved mount directory (surfaced on the Session record). */
72
- export interface MountedFileManifest {
73
- /** The file's storage slug (`FileRef.name`). */
74
- readonly name: string;
75
- /** Absolute container directory the file unzipped into (defaults to `/workspace`). */
76
- readonly mountPath: string;
77
- }
78
- /**
79
- * Managed-runner container paths. Kept here so the BFF, hosted API, and
80
- * in-container bridge render identical values; runtime bootstrap constants are
81
- * validated against these by a regression test
82
- * (`packages/contracts/test/runtime-manifest.test.ts`).
83
- */
84
- declare const RUNTIME_PATHS: Readonly<{
85
- readonly skillsRoot: "/workspace/skills";
86
- readonly filesRoot: "/mnt/session/uploads/aex/files";
87
- readonly assetsRoot: "/mnt/session/uploads/aex/assets";
88
- readonly aexCli: "/mnt/session/uploads/aex/aex";
89
- readonly indexJson: "/mnt/session/uploads/aex/index.json";
90
- readonly readme: "/mnt/session/uploads/aex/SKILLS.md";
91
- readonly runtimeJson: "/mnt/session/uploads/aex/RUNTIME.json";
92
- readonly runtimeEnv: "/mnt/session/uploads/aex/RUNTIME.env";
93
- }>;
94
- export declare function runtimePaths(): typeof RUNTIME_PATHS;
95
- export interface BuildRuntimeManifestInput {
96
- readonly provider: ProviderName | string;
97
- /**
98
- * Customer-supplied `environment.envVars` from the validated
99
- * submission. Keys with the reserved `AEX_` prefix are
100
- * filtered out defensively — the strict submission parser already
101
- * rejects them, but defence-in-depth means a malformed snapshot
102
- * (or a future bypass) can't poison the manifest.
103
- */
104
- readonly customerEnvVars?: Readonly<Record<string, string>> | undefined;
105
- /**
106
- * The validated submission's `files` refs. Each resolves to one
107
- * {@link MountedFileManifest} entry surfacing the resolved mount directory
108
- * (the SDK default is `/workspace`). Absent / non-array ⇒ no mounted files.
109
- */
110
- readonly files?: readonly {
111
- readonly name?: unknown;
112
- readonly mountPath?: unknown;
113
- }[] | undefined;
114
- }
115
- /**
116
- * Build the runtime manifest for a single submission. Pure function:
117
- * same input → same output → safe to call from the BFF response path
118
- * and from the hosted bootstrap path with identical results.
119
- */
120
- export declare function buildRuntimeManifest(input: BuildRuntimeManifestInput): RuntimeManifest;
121
- export {};
@@ -1,83 +0,0 @@
1
- /**
2
- * Managed-runner container paths. Kept here so the BFF, hosted API, and
3
- * in-container bridge render identical values; runtime bootstrap constants are
4
- * validated against these by a regression test
5
- * (`packages/contracts/test/runtime-manifest.test.ts`).
6
- */
7
- const RUNTIME_PATHS = Object.freeze({
8
- skillsRoot: "/workspace/skills",
9
- filesRoot: "/mnt/session/uploads/aex/files",
10
- assetsRoot: "/mnt/session/uploads/aex/assets",
11
- aexCli: "/mnt/session/uploads/aex/aex",
12
- indexJson: "/mnt/session/uploads/aex/index.json",
13
- readme: "/mnt/session/uploads/aex/SKILLS.md",
14
- runtimeJson: "/mnt/session/uploads/aex/RUNTIME.json",
15
- runtimeEnv: "/mnt/session/uploads/aex/RUNTIME.env"
16
- });
17
- export function runtimePaths() {
18
- return RUNTIME_PATHS;
19
- }
20
- /**
21
- * Reserved env-var prefix for aex-set runtime keys. Mirrors the
22
- * constant in `submission.ts`; duplicated here so this module is
23
- * self-contained and can be tree-shaken by SDK consumers that don't
24
- * need the submission parser.
25
- */
26
- const AEX_PREFIX = "AEX_";
27
- /**
28
- * Default mount DIRECTORY for a `File` with no explicit `mountPath`. Mirrors
29
- * `DEFAULT_FILE_MOUNT_PATH` in `session-config.ts`; duplicated here so this module
30
- * stays self-contained (tree-shakeable) — the same reason {@link AEX_PREFIX}
31
- * is inlined rather than imported from the submission parser.
32
- */
33
- const DEFAULT_FILE_MOUNT_PATH = "/workspace";
34
- /**
35
- * Build the runtime manifest for a single submission. Pure function:
36
- * same input → same output → safe to call from the BFF response path
37
- * and from the hosted bootstrap path with identical results.
38
- */
39
- export function buildRuntimeManifest(input) {
40
- const paths = runtimePaths();
41
- const aexEnvVars = {
42
- AEX_PROVIDER: input.provider,
43
- AEX_CLI: paths.aexCli,
44
- AEX_SKILLS_ROOT: paths.skillsRoot,
45
- AEX_FILES_ROOT: paths.filesRoot,
46
- AEX_ASSETS_ROOT: paths.assetsRoot,
47
- AEX_INDEX_JSON: paths.indexJson,
48
- AEX_README: paths.readme,
49
- AEX_RUNTIME_JSON: paths.runtimeJson,
50
- AEX_RUNTIME_ENV: paths.runtimeEnv
51
- };
52
- const customerEnvVars = {};
53
- for (const [key, value] of Object.entries(input.customerEnvVars ?? {})) {
54
- if (key.startsWith(AEX_PREFIX)) {
55
- // Defensive filter; the strict parser rejects this at submit
56
- // time. If a stored snapshot somehow carries a reserved key
57
- // we drop it rather than letting it shadow our value.
58
- continue;
59
- }
60
- customerEnvVars[key] = value;
61
- }
62
- const envVars = Object.freeze({ ...aexEnvVars, ...customerEnvVars });
63
- const mountedFiles = [];
64
- for (const f of Array.isArray(input.files) ? input.files : []) {
65
- if (typeof f.name !== "string" || f.name.length === 0)
66
- continue;
67
- const mountPath = typeof f.mountPath === "string" && f.mountPath.length > 0 ? f.mountPath : DEFAULT_FILE_MOUNT_PATH;
68
- mountedFiles.push(Object.freeze({ name: f.name, mountPath }));
69
- }
70
- return Object.freeze({
71
- provider: input.provider,
72
- skillsRoot: paths.skillsRoot,
73
- filesRoot: paths.filesRoot,
74
- assetsRoot: paths.assetsRoot,
75
- aexCli: paths.aexCli,
76
- indexJson: paths.indexJson,
77
- readme: paths.readme,
78
- runtimeJson: paths.runtimeJson,
79
- runtimeEnv: paths.runtimeEnv,
80
- envVars,
81
- mountedFiles: Object.freeze(mountedFiles)
82
- });
83
- }
@@ -1,26 +0,0 @@
1
- import { RUNTIME_SECURITY_PROFILES } from "./schemas/runtime-security-profile.js";
2
- export { RUNTIME_SECURITY_PROFILES };
3
- export type RuntimeSecurityProfileName = (typeof RUNTIME_SECURITY_PROFILES)[number];
4
- export interface RuntimeSecurityProfile {
5
- readonly name: RuntimeSecurityProfileName;
6
- readonly defaultNetworkingMode: "limited" | "open";
7
- readonly allowOpenNetworking: boolean;
8
- readonly allowRuntimePackages: boolean;
9
- readonly allowCustomerEnvVars: boolean;
10
- readonly allowMcpServers: boolean;
11
- }
12
- export interface RuntimeSecurityProfileEvaluationInput {
13
- readonly networkingMode?: "limited" | "open";
14
- readonly packageCount?: number;
15
- readonly customerEnvVarCount?: number;
16
- readonly mcpServerCount?: number;
17
- }
18
- export interface RuntimeSecurityProfileViolation {
19
- readonly field: string;
20
- readonly reason: string;
21
- }
22
- export declare const RUNTIME_SECURITY_PROFILE_CONFIG: Readonly<Record<RuntimeSecurityProfileName, RuntimeSecurityProfile>>;
23
- export declare function parseRuntimeSecurityProfile(input: unknown): RuntimeSecurityProfileName | undefined;
24
- export declare function resolveRuntimeSecurityProfile(input: RuntimeSecurityProfileName | undefined): RuntimeSecurityProfile;
25
- export declare function serializeRuntimeSecurityProfile(profile: RuntimeSecurityProfileName): string;
26
- export declare function evaluateRuntimeSecurityProfile(profileName: RuntimeSecurityProfileName | undefined, input: RuntimeSecurityProfileEvaluationInput): readonly RuntimeSecurityProfileViolation[];
@@ -1,73 +0,0 @@
1
- import { withContractParseError } from "./contract-parse-error.js";
2
- import { RUNTIME_SECURITY_PROFILES, RuntimeSecurityProfileSchema } from "./schemas/runtime-security-profile.js";
3
- import { parseWire } from "./schemas/wire.js";
4
- export { RUNTIME_SECURITY_PROFILES };
5
- export const RUNTIME_SECURITY_PROFILE_CONFIG = Object.freeze({
6
- strict: Object.freeze({
7
- name: "strict",
8
- defaultNetworkingMode: "limited",
9
- allowOpenNetworking: false,
10
- allowRuntimePackages: false,
11
- allowCustomerEnvVars: true,
12
- allowMcpServers: true
13
- }),
14
- standard: Object.freeze({
15
- name: "standard",
16
- defaultNetworkingMode: "open",
17
- allowOpenNetworking: true,
18
- allowRuntimePackages: true,
19
- allowCustomerEnvVars: true,
20
- allowMcpServers: true
21
- }),
22
- developer: Object.freeze({
23
- name: "developer",
24
- defaultNetworkingMode: "open",
25
- allowOpenNetworking: true,
26
- allowRuntimePackages: true,
27
- allowCustomerEnvVars: true,
28
- allowMcpServers: true
29
- })
30
- });
31
- export function parseRuntimeSecurityProfile(input) {
32
- return withContractParseError("parseRuntimeSecurityProfile", () => {
33
- if (input === undefined || input === null)
34
- return undefined;
35
- return parseWire(RuntimeSecurityProfileSchema, input);
36
- });
37
- }
38
- export function resolveRuntimeSecurityProfile(input) {
39
- return RUNTIME_SECURITY_PROFILE_CONFIG[input ?? "standard"];
40
- }
41
- export function serializeRuntimeSecurityProfile(profile) {
42
- parseRuntimeSecurityProfile(profile);
43
- return profile;
44
- }
45
- export function evaluateRuntimeSecurityProfile(profileName, input) {
46
- const profile = resolveRuntimeSecurityProfile(profileName);
47
- const violations = [];
48
- if (input.networkingMode === "open" && !profile.allowOpenNetworking) {
49
- violations.push({
50
- field: "environment.networking.mode",
51
- reason: `${profile.name} requires limited networking`
52
- });
53
- }
54
- if ((input.packageCount ?? 0) > 0 && !profile.allowRuntimePackages) {
55
- violations.push({
56
- field: "environment.packages",
57
- reason: `${profile.name} does not allow runtime package installs`
58
- });
59
- }
60
- if ((input.customerEnvVarCount ?? 0) > 0 && !profile.allowCustomerEnvVars) {
61
- violations.push({
62
- field: "environment.envVars",
63
- reason: `${profile.name} does not allow customer runtime env vars`
64
- });
65
- }
66
- if ((input.mcpServerCount ?? 0) > 0 && !profile.allowMcpServers) {
67
- violations.push({
68
- field: "submission.mcpServers",
69
- reason: `${profile.name} does not allow MCP servers`
70
- });
71
- }
72
- return Object.freeze(violations);
73
- }