@nylorun/runtime 0.26.0-beta → 0.28.0-beta

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 (379) hide show
  1. package/CHANGELOG.md +171 -0
  2. package/README.md +18 -14
  3. package/dist/adapters/execution/restate.d.ts +15 -18
  4. package/dist/adapters/execution/restate.js +31 -27
  5. package/dist/adapters/replication/pgoutput.d.ts +1 -1
  6. package/dist/adapters/replication/pgoutput.js +3 -2
  7. package/dist/adapters/sandbox/local.js +8 -5
  8. package/dist/adapters/sandbox/virtual.js +2 -2
  9. package/dist/adapters/streams/s2.d.ts +1 -1
  10. package/dist/adapters/streams/s2.js +18 -14
  11. package/dist/api/a2a/card.d.ts +4 -3
  12. package/dist/api/a2a/card.js +4 -4
  13. package/dist/api/a2a/endpoint.js +3 -4
  14. package/dist/api/a2a/protocol.js +4 -0
  15. package/dist/api/a2a/routes.d.ts +2 -6
  16. package/dist/api/a2a/routes.js +30 -25
  17. package/dist/api/ag-ui/endpoint.js +2 -3
  18. package/dist/api/ag-ui/routes.js +8 -11
  19. package/dist/api/components.d.ts +6789 -3405
  20. package/dist/api/components.js +43 -30
  21. package/dist/api/gate/keys.js +7 -4
  22. package/dist/api/gate/routes.d.ts +6 -2
  23. package/dist/api/gate/routes.js +15 -11
  24. package/dist/api/http/app.js +9 -4
  25. package/dist/api/http/body.d.ts +17 -3
  26. package/dist/api/http/body.js +35 -7
  27. package/dist/api/http/respond.js +6 -2
  28. package/dist/api/http/routes/access.js +5 -4
  29. package/dist/api/http/routes/agent-manifests.d.ts +10 -0
  30. package/dist/api/http/routes/agent-manifests.js +135 -0
  31. package/dist/api/http/routes/agents.d.ts +11 -0
  32. package/dist/api/http/routes/agents.js +418 -0
  33. package/dist/api/http/routes/artifacts.js +21 -9
  34. package/dist/api/http/routes/coverage.d.ts +4 -4
  35. package/dist/api/http/routes/coverage.js +13 -7
  36. package/dist/api/http/routes/files.d.ts +2 -1
  37. package/dist/api/http/routes/files.js +31 -5
  38. package/dist/api/http/routes/mcp.js +3 -3
  39. package/dist/api/http/routes/me.d.ts +1 -1
  40. package/dist/api/http/routes/me.js +1 -2
  41. package/dist/api/http/routes/memories.d.ts +9 -0
  42. package/dist/api/http/routes/memories.js +152 -0
  43. package/dist/api/http/routes/reads.d.ts +10 -111
  44. package/dist/api/http/routes/reads.js +51 -29
  45. package/dist/api/http/routes/sessions.js +26 -54
  46. package/dist/api/http/routes/tenant.d.ts +2 -2
  47. package/dist/api/http/routes/tenant.js +77 -24
  48. package/dist/api/http/routes/triggers.d.ts +10 -0
  49. package/dist/api/http/routes/triggers.js +180 -0
  50. package/dist/api/inbound-files.d.ts +3 -9
  51. package/dist/api/inbound-files.js +18 -24
  52. package/dist/api/openapi.js +73 -47
  53. package/dist/artifacts/disk.d.ts +10 -14
  54. package/dist/artifacts/disk.js +99 -95
  55. package/dist/artifacts/files.d.ts +13 -4
  56. package/dist/artifacts/files.js +27 -9
  57. package/dist/artifacts/folder-upload.d.ts +75 -0
  58. package/dist/artifacts/folder-upload.js +263 -0
  59. package/dist/artifacts/folders.d.ts +14 -8
  60. package/dist/artifacts/folders.js +19 -11
  61. package/dist/artifacts/links.js +7 -6
  62. package/dist/artifacts/parts.d.ts +9 -14
  63. package/dist/artifacts/parts.js +11 -9
  64. package/dist/artifacts/pipe.d.ts +15 -0
  65. package/dist/artifacts/pipe.js +71 -0
  66. package/dist/artifacts/quota.d.ts +36 -0
  67. package/dist/artifacts/quota.js +44 -0
  68. package/dist/artifacts/service.d.ts +25 -1
  69. package/dist/artifacts/service.js +72 -27
  70. package/dist/blob/fs.js +2 -1
  71. package/dist/blob/s3.d.ts +6 -2
  72. package/dist/blob/s3.js +9 -7
  73. package/dist/blob/types.d.ts +1 -1
  74. package/dist/blob/types.js +1 -1
  75. package/dist/core/flow-host.d.ts +0 -1
  76. package/dist/core/limits.d.ts +11 -35
  77. package/dist/core/limits.js +5 -73
  78. package/dist/core/sandbox-routes.js +0 -1
  79. package/dist/core/turn-manifest.d.ts +1 -2
  80. package/dist/core/turn-manifest.js +4 -28
  81. package/dist/execution/memory.d.ts +8 -5
  82. package/dist/execution/memory.js +8 -6
  83. package/dist/execution/types.d.ts +1 -6
  84. package/dist/execution/types.js +0 -5
  85. package/dist/gates/contract.d.ts +3 -2
  86. package/dist/gates/contract.js +1 -1
  87. package/dist/gates/egress-credentials.js +5 -4
  88. package/dist/gates/egress.d.ts +13 -13
  89. package/dist/gates/egress.js +19 -21
  90. package/dist/gates/fixture-model.js +13 -2
  91. package/dist/gates/handler.d.ts +1 -3
  92. package/dist/gates/handler.js +4 -3
  93. package/dist/gates/http-client.d.ts +4 -3
  94. package/dist/gates/http-client.js +5 -7
  95. package/dist/gates/http-tool.d.ts +24 -4
  96. package/dist/gates/http-tool.js +41 -13
  97. package/dist/gates/in-process.d.ts +2 -1
  98. package/dist/gates/in-process.js +17 -9
  99. package/dist/gates/inflight.d.ts +2 -2
  100. package/dist/gates/inflight.js +3 -2
  101. package/dist/gates/journal.js +5 -7
  102. package/dist/gates/mcp-handler.d.ts +4 -3
  103. package/dist/gates/mcp-handler.js +15 -5
  104. package/dist/gates/meter.js +6 -5
  105. package/dist/gates/model-gate.d.ts +11 -2
  106. package/dist/gates/policy.d.ts +34 -6
  107. package/dist/gates/policy.js +66 -18
  108. package/dist/gates/provider-gate.d.ts +22 -0
  109. package/dist/gates/provider-gate.js +30 -0
  110. package/dist/gates/tool-calls.d.ts +1 -3
  111. package/dist/gates/tool-calls.js +2 -3
  112. package/dist/gates/tool-client.d.ts +1 -1
  113. package/dist/gates/tool-client.js +5 -6
  114. package/dist/gates/tool-contract.d.ts +8 -5
  115. package/dist/gates/tool-contract.js +1 -1
  116. package/dist/gates/tool-gate.d.ts +18 -7
  117. package/dist/gates/tool-gate.js +49 -7
  118. package/dist/harness/calls.d.ts +27 -25
  119. package/dist/harness/calls.js +40 -46
  120. package/dist/harness/executors.d.ts +10 -3
  121. package/dist/harness/executors.js +53 -23
  122. package/dist/harness/main.js +2 -2
  123. package/dist/harness/pod.d.ts +2 -2
  124. package/dist/harness/pod.js +7 -6
  125. package/dist/harness/run-tokens.d.ts +4 -1
  126. package/dist/harness/run-tokens.js +6 -2
  127. package/dist/harness/service.d.ts +17 -14
  128. package/dist/harness/service.js +21 -35
  129. package/dist/harness/setup.d.ts +0 -2
  130. package/dist/harness/setup.js +21 -15
  131. package/dist/harness/ws-client.d.ts +2 -2
  132. package/dist/harness/ws-client.js +7 -5
  133. package/dist/harness/ws-port.d.ts +3 -4
  134. package/dist/harness/ws-port.js +3 -4
  135. package/dist/harness-api/artifacts.d.ts +20 -0
  136. package/dist/harness-api/artifacts.js +478 -0
  137. package/dist/harness-api/in-process.d.ts +2 -2
  138. package/dist/harness-api/in-process.js +18 -16
  139. package/dist/harness-api/record.d.ts +10 -9
  140. package/dist/harness-api/record.js +113 -157
  141. package/dist/harness-api/renew.d.ts +1 -1
  142. package/dist/harness-api/renew.js +2 -2
  143. package/dist/harness-api/server.d.ts +1 -16
  144. package/dist/harness-api/server.js +86 -73
  145. package/dist/harness-api/start.d.ts +27 -5
  146. package/dist/harness-api/start.js +102 -19
  147. package/dist/harness-api/tool-journal.d.ts +15 -10
  148. package/dist/harness-api/tool-journal.js +26 -24
  149. package/dist/harness-api/workspace.d.ts +0 -4
  150. package/dist/harness-api/workspace.js +4 -47
  151. package/dist/harness-api/ws-server.js +10 -10
  152. package/dist/host/create-host.js +2 -3
  153. package/dist/host/execution.js +2 -3
  154. package/dist/host/gates.d.ts +2 -9
  155. package/dist/host/gates.js +15 -12
  156. package/dist/host/http.d.ts +2 -4
  157. package/dist/host/http.js +5 -29
  158. package/dist/host/main.js +10 -3
  159. package/dist/host/operate.js +12 -3
  160. package/dist/host/stack-config.d.ts +11 -0
  161. package/dist/host/stack-config.js +21 -1
  162. package/dist/index.d.ts +0 -1
  163. package/dist/index.js +0 -1
  164. package/dist/infra/index.js +2 -1
  165. package/dist/infra/readiness.d.ts +0 -2
  166. package/dist/infra/readiness.js +4 -3
  167. package/dist/keys/client.d.ts +1 -0
  168. package/dist/keys/client.js +2 -3
  169. package/dist/keys/contract.d.ts +0 -2
  170. package/dist/keys/contract.js +0 -2
  171. package/dist/keys/egress-ca.d.ts +0 -2
  172. package/dist/keys/egress-ca.js +2 -3
  173. package/dist/keys/keys.d.ts +15 -4
  174. package/dist/keys/keys.js +22 -1
  175. package/dist/keys/webhooks.d.ts +25 -0
  176. package/dist/keys/webhooks.js +62 -0
  177. package/dist/keys/x509.d.ts +8 -4
  178. package/dist/keys/x509.js +14 -5
  179. package/dist/management-openapi.json +3043 -1954
  180. package/dist/mcp/connect.d.ts +35 -26
  181. package/dist/mcp/connect.js +112 -141
  182. package/dist/mcp/pool.d.ts +27 -22
  183. package/dist/mcp/pool.js +34 -48
  184. package/dist/mcp/preview.d.ts +12 -5
  185. package/dist/mcp/preview.js +43 -26
  186. package/dist/mcp/snapshot.d.ts +35 -86
  187. package/dist/mcp/snapshot.js +93 -135
  188. package/dist/memory/service.d.ts +97 -0
  189. package/dist/memory/service.js +335 -0
  190. package/dist/memory/tool.d.ts +36 -0
  191. package/dist/memory/tool.js +84 -0
  192. package/dist/model/auth-store.js +5 -3
  193. package/dist/model/capabilities.d.ts +1 -1
  194. package/dist/model/catalog.d.ts +9 -36
  195. package/dist/model/catalog.js +6 -33
  196. package/dist/model/descriptor.d.ts +51 -0
  197. package/dist/model/descriptor.js +83 -0
  198. package/dist/model/models.d.ts +0 -3
  199. package/dist/model/models.js +3 -5
  200. package/dist/model/native-blocks.js +1 -1
  201. package/dist/model/pi-model.d.ts +16 -5
  202. package/dist/model/pi-model.js +86 -105
  203. package/dist/openapi.json +13653 -9986
  204. package/dist/reads/cursor.js +3 -1
  205. package/dist/reads/types.d.ts +3 -3
  206. package/dist/record/agent.d.ts +27 -0
  207. package/dist/record/agent.js +46 -0
  208. package/dist/record/append.d.ts +34 -2
  209. package/dist/record/append.js +50 -1
  210. package/dist/record/index.d.ts +2 -2
  211. package/dist/record/index.js +2 -2
  212. package/dist/redact.d.ts +1 -1
  213. package/dist/redact.js +3 -2
  214. package/dist/sandbox/egress-token.d.ts +3 -3
  215. package/dist/sandbox/egress-token.js +3 -3
  216. package/dist/sandbox/join.js +8 -7
  217. package/dist/sandbox/manager.d.ts +41 -41
  218. package/dist/sandbox/manager.js +112 -44
  219. package/dist/sandbox/placement.d.ts +2 -2
  220. package/dist/sandbox/placement.js +7 -10
  221. package/dist/sandbox/pods/client.d.ts +1 -10
  222. package/dist/sandbox/pods/client.js +8 -4
  223. package/dist/sandbox/pods/lifecycle.d.ts +25 -17
  224. package/dist/sandbox/pods/lifecycle.js +51 -29
  225. package/dist/sandbox/pods/network-gate.d.ts +4 -5
  226. package/dist/sandbox/pods/network-gate.js +7 -7
  227. package/dist/sandbox/pods/reconcile.js +14 -3
  228. package/dist/sandbox/pods/spec.js +8 -5
  229. package/dist/sandbox/policy.d.ts +7 -1
  230. package/dist/sandbox/policy.js +10 -3
  231. package/dist/sandbox/resolve.d.ts +11 -6
  232. package/dist/sandbox/resolve.js +19 -9
  233. package/dist/sandbox/setup.d.ts +6 -2
  234. package/dist/sandbox/setup.js +47 -14
  235. package/dist/sandbox/share.d.ts +5 -14
  236. package/dist/sandbox/share.js +5 -34
  237. package/dist/sandbox/skills.d.ts +7 -13
  238. package/dist/sandbox/skills.js +16 -31
  239. package/dist/sandbox/tenant-config.d.ts +2 -2
  240. package/dist/sandbox/tenant-config.js +4 -3
  241. package/dist/sandbox/tools.d.ts +7 -1
  242. package/dist/sandbox/tools.js +26 -26
  243. package/dist/sandbox/types.d.ts +10 -3
  244. package/dist/sandbox/types.js +9 -0
  245. package/dist/store/postgres/connect.d.ts +6 -5
  246. package/dist/store/postgres/connect.js +14 -11
  247. package/dist/store/postgres/control.js +13 -13
  248. package/dist/store/postgres/drizzle/0028_artifact_write_keys.sql +2 -0
  249. package/dist/store/postgres/drizzle/0029_protocol_15.sql +11 -0
  250. package/dist/store/postgres/drizzle/0030_protocol_15_runtime_block.sql +11 -0
  251. package/dist/store/postgres/drizzle/0031_protocol_15_mcp_snapshot.sql +8 -0
  252. package/dist/store/postgres/drizzle/0032_agents.sql +54 -0
  253. package/dist/store/postgres/drizzle/0033_agent_versions.sql +7 -0
  254. package/dist/store/postgres/drizzle/0034_protocol_17_session_queue.sql +13 -0
  255. package/dist/store/postgres/drizzle/0035_t4_triggers.sql +41 -0
  256. package/dist/store/postgres/drizzle/0036_t5_memories.sql +30 -0
  257. package/dist/store/postgres/drizzle/meta/_journal.json +63 -0
  258. package/dist/store/postgres/reads.js +17 -82
  259. package/dist/store/postgres/record-writer.d.ts +4 -4
  260. package/dist/store/postgres/record-writer.js +9 -9
  261. package/dist/store/postgres/schema.d.ts +1382 -151
  262. package/dist/store/postgres/schema.js +191 -37
  263. package/dist/store/postgres/store.js +384 -105
  264. package/dist/store/postgres/tenant.js +1 -2
  265. package/dist/store/types.d.ts +172 -57
  266. package/dist/store/types.js +0 -1
  267. package/dist/streams/relay/core.d.ts +3 -3
  268. package/dist/streams/relay/core.js +9 -10
  269. package/dist/tenant/advance.js +41 -39
  270. package/dist/tenant/agent-manifests.d.ts +72 -0
  271. package/dist/tenant/agent-manifests.js +359 -0
  272. package/dist/tenant/agent-versions.d.ts +126 -0
  273. package/dist/tenant/agent-versions.js +389 -0
  274. package/dist/tenant/agents.d.ts +230 -0
  275. package/dist/tenant/{environments.js → agents.js} +493 -328
  276. package/dist/tenant/auth.d.ts +1 -1
  277. package/dist/tenant/auth.js +3 -3
  278. package/dist/tenant/commands.d.ts +63 -2
  279. package/dist/tenant/commands.js +240 -90
  280. package/dist/tenant/context.d.ts +57 -33
  281. package/dist/tenant/context.js +6 -2
  282. package/dist/tenant/definition-files.d.ts +25 -4
  283. package/dist/tenant/definition-files.js +85 -47
  284. package/dist/tenant/effects.js +15 -51
  285. package/dist/tenant/ephemeral.js +2 -1
  286. package/dist/tenant/history.d.ts +1 -1
  287. package/dist/tenant/history.js +1 -1
  288. package/dist/tenant/host-token.d.ts +3 -3
  289. package/dist/tenant/host-token.js +11 -10
  290. package/dist/tenant/http.d.ts +5 -8
  291. package/dist/tenant/http.js +9 -0
  292. package/dist/tenant/identity-file.d.ts +29 -6
  293. package/dist/tenant/identity-file.js +45 -15
  294. package/dist/tenant/issuers.d.ts +5 -5
  295. package/dist/tenant/issuers.js +34 -26
  296. package/dist/tenant/jwt.d.ts +8 -2
  297. package/dist/tenant/jwt.js +10 -2
  298. package/dist/tenant/limits.d.ts +87 -0
  299. package/dist/tenant/limits.js +172 -0
  300. package/dist/tenant/memories.d.ts +38 -0
  301. package/dist/tenant/memories.js +119 -0
  302. package/dist/tenant/module.d.ts +4 -1
  303. package/dist/tenant/module.js +9 -8
  304. package/dist/tenant/outbound.d.ts +11 -14
  305. package/dist/tenant/outbound.js +10 -15
  306. package/dist/tenant/reset.js +2 -2
  307. package/dist/tenant/run-grants.d.ts +6 -0
  308. package/dist/tenant/run-grants.js +7 -2
  309. package/dist/tenant/run-token.d.ts +0 -4
  310. package/dist/tenant/run-token.js +6 -11
  311. package/dist/tenant/runtime-limits.d.ts +24 -0
  312. package/dist/tenant/runtime-limits.js +27 -0
  313. package/dist/tenant/runtime.d.ts +1 -1
  314. package/dist/tenant/runtime.js +38 -43
  315. package/dist/tenant/session-streams.js +7 -6
  316. package/dist/tenant/session.d.ts +1 -1
  317. package/dist/tenant/session.js +1 -1
  318. package/dist/tenant/sessions.d.ts +28 -45
  319. package/dist/tenant/sessions.js +89 -209
  320. package/dist/tenant/signing-keys.d.ts +1 -1
  321. package/dist/tenant/signing-keys.js +5 -6
  322. package/dist/tenant/status.js +10 -10
  323. package/dist/tenant/streams.js +18 -20
  324. package/dist/tenant/sweep.d.ts +1 -21
  325. package/dist/tenant/sweep.js +51 -51
  326. package/dist/tenant/transcript.d.ts +70 -23
  327. package/dist/tenant/transcript.js +28 -22
  328. package/dist/tenant/triggers.d.ts +143 -0
  329. package/dist/tenant/triggers.js +715 -0
  330. package/dist/tenant/turn-timing.d.ts +11 -1
  331. package/dist/tenant/turn-timing.js +3 -1
  332. package/dist/tenant/types.d.ts +9 -14
  333. package/dist/tenant/worker.d.ts +4 -10
  334. package/dist/tenant/worker.js +10 -14
  335. package/dist/traces/ids.js +5 -1
  336. package/dist/traces/map.d.ts +10 -7
  337. package/dist/traces/map.js +16 -12
  338. package/dist/traces/otlp.d.ts +3 -3
  339. package/dist/traces/otlp.js +5 -3
  340. package/dist/traces/projector.d.ts +9 -4
  341. package/dist/traces/projector.js +13 -7
  342. package/dist/traces/read.js +6 -1
  343. package/dist/tuning.d.ts +390 -0
  344. package/dist/tuning.js +677 -0
  345. package/dist/vault/headers.js +4 -2
  346. package/dist/vault/service.d.ts +13 -8
  347. package/dist/vault/service.js +61 -17
  348. package/dist/version.d.ts +1 -1
  349. package/dist/version.js +1 -1
  350. package/package.json +13 -12
  351. package/dist/api/http/routes/environment-manifests.d.ts +0 -9
  352. package/dist/api/http/routes/environment-manifests.js +0 -118
  353. package/dist/api/http/routes/environments.d.ts +0 -11
  354. package/dist/api/http/routes/environments.js +0 -332
  355. package/dist/artifacts/export.d.ts +0 -8
  356. package/dist/artifacts/export.js +0 -204
  357. package/dist/artifacts/media-types.d.ts +0 -30
  358. package/dist/artifacts/media-types.js +0 -137
  359. package/dist/artifacts/workspace.d.ts +0 -60
  360. package/dist/artifacts/workspace.js +0 -45
  361. package/dist/media.d.ts +0 -10
  362. package/dist/media.js +0 -58
  363. package/dist/record/environment.d.ts +0 -25
  364. package/dist/record/environment.js +0 -44
  365. package/dist/sandbox/runtime-tools.d.ts +0 -9
  366. package/dist/sandbox/runtime-tools.js +0 -16
  367. package/dist/sandbox/session-sandbox.d.ts +0 -16
  368. package/dist/sandbox/session-sandbox.js +0 -77
  369. package/dist/tenant/artifact-tool.d.ts +0 -13
  370. package/dist/tenant/artifact-tool.js +0 -243
  371. package/dist/tenant/environment-manifests.d.ts +0 -57
  372. package/dist/tenant/environment-manifests.js +0 -200
  373. package/dist/tenant/environments.d.ts +0 -174
  374. package/dist/tenant/skill-tool.d.ts +0 -20
  375. package/dist/tenant/skill-tool.js +0 -67
  376. package/dist/tenant/tool-results.d.ts +0 -57
  377. package/dist/tenant/tool-results.js +0 -298
  378. package/dist/tenant/tool-search.d.ts +0 -39
  379. package/dist/tenant/tool-search.js +0 -103
@@ -1,137 +0,0 @@
1
- import { DEFAULT_CONTENT_TYPE } from "../blob/index.js";
2
- const MEDIA_TYPE = /^[a-z0-9][a-z0-9!#$&^_.+-]{0,126}\/[a-z0-9][a-z0-9!#$&^_.+-]{0,126}$/;
3
- const BY_EXTENSION = {
4
- png: "image/png",
5
- jpg: "image/jpeg",
6
- jpeg: "image/jpeg",
7
- gif: "image/gif",
8
- webp: "image/webp",
9
- svg: "image/svg+xml",
10
- pdf: "application/pdf",
11
- doc: "application/msword",
12
- docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
13
- xls: "application/vnd.ms-excel",
14
- xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
15
- ppt: "application/vnd.ms-powerpoint",
16
- pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
17
- txt: "text/plain",
18
- md: "text/markdown",
19
- csv: "text/csv",
20
- html: "text/html",
21
- htm: "text/html",
22
- css: "text/css",
23
- js: "text/javascript",
24
- mjs: "text/javascript",
25
- ts: "text/x-typescript",
26
- py: "text/x-python",
27
- sh: "text/x-sh",
28
- json: "application/json",
29
- xml: "application/xml",
30
- yaml: "application/yaml",
31
- yml: "application/yaml",
32
- zip: "application/zip",
33
- tar: "application/x-tar",
34
- gz: "application/gzip",
35
- mp3: "audio/mpeg",
36
- wav: "audio/wav",
37
- mp4: "video/mp4",
38
- };
39
- /** Images the model reads as images. */
40
- export const MODEL_IMAGE_TYPES = Object.freeze([
41
- "image/png",
42
- "image/jpeg",
43
- "image/webp",
44
- "image/gif",
45
- ]);
46
- /** The largest image or text file a model call carries inline. */
47
- export const MODEL_FILE_MAX_BYTES = 8 * 1024 * 1024;
48
- /** The type part of a `Content-Type` value, lowercased, without parameters. */
49
- export function essence(contentType) {
50
- return contentType.split(";")[0].trim().toLowerCase();
51
- }
52
- /** A declared `Content-Type` as stored, or undefined when it is not a media type. */
53
- export function normalizeContentType(value) {
54
- if (value === undefined)
55
- return undefined;
56
- const trimmed = value.trim();
57
- if (trimmed === "" || trimmed.length > 255)
58
- return undefined;
59
- return MEDIA_TYPE.test(essence(trimmed)) ? trimmed : undefined;
60
- }
61
- /** The media type a file name implies, or `application/octet-stream`. */
62
- export function contentTypeFor(name) {
63
- const dot = name.lastIndexOf(".");
64
- if (dot < 0)
65
- return DEFAULT_CONTENT_TYPE;
66
- return BY_EXTENSION[name.slice(dot + 1).toLowerCase()] ?? DEFAULT_CONTENT_TYPE;
67
- }
68
- export function isModelImage(contentType) {
69
- return MODEL_IMAGE_TYPES.includes(essence(contentType));
70
- }
71
- /** Files the model reads as text: `text/*`, JSON, XML, YAML and their `+json`/`+xml` kin. */
72
- export function isText(contentType) {
73
- const type = essence(contentType);
74
- return (type.startsWith("text/") ||
75
- type === "application/json" ||
76
- type === "application/xml" ||
77
- type === "application/yaml" ||
78
- type === "application/x-yaml" ||
79
- type === "application/javascript" ||
80
- type.endsWith("+json") ||
81
- type.endsWith("+xml"));
82
- }
83
- /** The usual extension of a media type, for a name the Runtime gives a file; undefined if none. */
84
- export function extensionFor(contentType) {
85
- const type = essence(contentType);
86
- return Object.keys(BY_EXTENSION).find((extension) => BY_EXTENSION[extension] === type);
87
- }
88
- /** Word, Excel and PowerPoint documents, old and Open XML. */
89
- function isOffice(type) {
90
- return (type === "application/msword" ||
91
- type === "application/vnd.ms-excel" ||
92
- type === "application/vnd.ms-powerpoint" ||
93
- type.startsWith("application/vnd.openxmlformats-officedocument."));
94
- }
95
- /** The model input a file of `contentType` is, or undefined for a type no model reads. */
96
- export function modelInputOf(contentType) {
97
- const type = essence(contentType);
98
- if (isText(type))
99
- return "text";
100
- if (type.startsWith("image/"))
101
- return "image";
102
- if (type === "application/pdf")
103
- return "pdf";
104
- if (isOffice(type))
105
- return "office";
106
- if (type.startsWith("audio/"))
107
- return "audio";
108
- if (type.startsWith("video/"))
109
- return "video";
110
- return undefined;
111
- }
112
- const LABELS = {
113
- text: "text files",
114
- image: "images",
115
- pdf: "PDFs",
116
- office: "Office documents",
117
- audio: "audio",
118
- video: "video",
119
- };
120
- /** An input, in a sentence: "PDFs", "Office documents"; "files of this type" for none. */
121
- export function inputLabel(input) {
122
- return input === undefined ? "files of this type" : LABELS[input];
123
- }
124
- /**
125
- * Why a model that reads `inputs` cannot read a file of `contentType`, or undefined when it can.
126
- * An image must also be PNG, JPEG, GIF or WebP.
127
- */
128
- export function unreadableReason(contentType, inputs) {
129
- const input = modelInputOf(contentType);
130
- if (input === undefined)
131
- return `no model reads ${essence(contentType)} files`;
132
- if (!inputs.includes(input))
133
- return `this model does not read ${LABELS[input]}`;
134
- if (input === "image" && !isModelImage(contentType))
135
- return "the model reads PNG, JPEG, GIF and WebP images only";
136
- return undefined;
137
- }
@@ -1,60 +0,0 @@
1
- /**
2
- * The `WorkspaceReader` seam (F8.2): how core reads a session's sandbox workspace at turn end, to
3
- * export its outputs as a folder artifact. Two calls, a listing and one file's bytes, both the
4
- * claim of whoever holds the workspace: the Runtime stores what it is given without observing it.
5
- *
6
- * One implementation, `sandboxWorkspaceReader`, over the workspace feature (F6.2,
7
- * `harness-api/workspace.ts`): the in-process `SandboxManager`, or the harness that serves the
8
- * Tenant's workspaces (`workspace.read`). F6.2 reimplements it over the Harness API's `workspace.read`, and F7.2's pod
9
- * sandboxes are read through the same seam, so the export never knows which kind of sandbox it
10
- * reads.
11
- */
12
- import type { AgentManifest } from "@nylorun/core/define";
13
- import { type SandboxManager } from "../sandbox/manager.js";
14
- /** What the reader needs of a workspace: a `SandboxManager`, or the workspace feature. */
15
- export type WorkspaceFiles = Pick<SandboxManager, "listFiles" | "readBytes">;
16
- /** Whose workspace to read: the session whose turn ended, resolved to the workspace it uses. */
17
- export interface WorkspaceSession {
18
- /** The session whose turn ended. */
19
- readonly sessionId: string;
20
- /** The turn that ended. */
21
- readonly turnId: string | null;
22
- /** The session that owns the workspace (one hop through `sandboxOwnerId`). */
23
- readonly ownerId: string;
24
- /** The sandbox resource the workspace belongs to, when the owner is attached to one. */
25
- readonly environmentId?: string;
26
- /** The session's pinned manifest: its `runtime` block carries the sandbox's spec. */
27
- readonly manifest: AgentManifest;
28
- }
29
- /** One regular file under the listed directory. */
30
- export interface WorkspaceEntry {
31
- /** Relative to the directory listed, `/`-separated, never `.` or `..` segments. */
32
- readonly path: string;
33
- readonly size: number;
34
- }
35
- export interface WorkspaceListing {
36
- /** The files in path order, symbolic links left out. */
37
- readonly entries: readonly WorkspaceEntry[];
38
- /** More than `maxEntries` files: `entries` holds `maxEntries + 1` of them. */
39
- readonly truncated: boolean;
40
- }
41
- export interface WorkspaceReader {
42
- /**
43
- * The regular files under `dir` (absolute, e.g. `/workspace/outputs`), recursively. Undefined
44
- * when the session has no sandbox, its sandbox was never created, or `dir` is not a directory.
45
- */
46
- list(session: WorkspaceSession, dir: string, options: {
47
- readonly maxEntries: number;
48
- readonly signal: AbortSignal;
49
- }): Promise<WorkspaceListing | undefined>;
50
- /**
51
- * One file's bytes (absolute path), or undefined when it is gone. A file larger than
52
- * `maxBytes` throws `SandboxFileTooLargeError`; a sandbox that fails throws.
53
- */
54
- readBytes(session: WorkspaceSession, path: string, options: {
55
- readonly maxBytes: number;
56
- readonly signal: AbortSignal;
57
- }): Promise<Uint8Array | undefined>;
58
- }
59
- /** The reader over the workspaces, in each sandbox's queue of tool calls. */
60
- export declare function sandboxWorkspaceReader(sandbox: WorkspaceFiles): WorkspaceReader;
@@ -1,45 +0,0 @@
1
- import { sandboxToolSpec } from "../sandbox/manager.js";
2
- import { SandboxFileTooLargeError } from "../sandbox/types.js";
3
- /** The reader over the workspaces, in each sandbox's queue of tool calls. */
4
- export function sandboxWorkspaceReader(sandbox) {
5
- const target = (session) => {
6
- const spec = sandboxToolSpec(session.manifest, "read");
7
- if (!spec)
8
- return undefined;
9
- return {
10
- spec,
11
- ref: {
12
- id: session.ownerId,
13
- activeTurnId: session.turnId,
14
- manifest: session.manifest,
15
- ...(session.environmentId === undefined ? {} : { environmentId: session.environmentId }),
16
- },
17
- };
18
- };
19
- return {
20
- async list(session, dir, options) {
21
- const found = target(session);
22
- if (!found)
23
- return undefined;
24
- const listed = await sandbox.listFiles(found.ref, found.spec, dir, options.maxEntries, options.signal);
25
- if (listed.kind === "missing")
26
- return undefined;
27
- if (listed.kind === "failed")
28
- throw new Error(listed.message);
29
- return listed.listing;
30
- },
31
- async readBytes(session, path, options) {
32
- const found = target(session);
33
- if (!found)
34
- return undefined;
35
- const read = await sandbox.readBytes(found.ref, found.spec, path, options.maxBytes, options.signal);
36
- if (read.kind === "read")
37
- return read.bytes;
38
- if (read.kind === "missing")
39
- return undefined;
40
- if (read.code === "artifact.too_large")
41
- throw new SandboxFileTooLargeError(path, options.maxBytes + 1, options.maxBytes);
42
- throw new Error(read.message);
43
- },
44
- };
45
- }
package/dist/media.d.ts DELETED
@@ -1,10 +0,0 @@
1
- /**
2
- * Image checks for code that handles image bytes itself (a service behind an HTTP tool):
3
- * the supported types, the size cap and a signature check. Storing images is the job of file
4
- * artifacts (`artifacts/`, protocol 6), which replaced `MediaStore`.
5
- */
6
- export declare const IMAGE_MEDIA_TYPES: readonly string[];
7
- export declare const MAX_IMAGE_BYTES: number;
8
- export declare function decodeImageBase64(mediaType: string, base64: string): Uint8Array;
9
- /** Verify the asserted media type and lightweight file signature for a supported image. */
10
- export declare function validateImageBytes(mediaType: string, bytes: Uint8Array): void;
package/dist/media.js DELETED
@@ -1,58 +0,0 @@
1
- /**
2
- * Image checks for code that handles image bytes itself (a service behind an HTTP tool):
3
- * the supported types, the size cap and a signature check. Storing images is the job of file
4
- * artifacts (`artifacts/`, protocol 6), which replaced `MediaStore`.
5
- */
6
- export const IMAGE_MEDIA_TYPES = Object.freeze([
7
- "image/jpeg",
8
- "image/png",
9
- "image/webp",
10
- ]);
11
- export const MAX_IMAGE_BYTES = 8 * 1024 * 1024;
12
- export function decodeImageBase64(mediaType, base64) {
13
- if (!IMAGE_MEDIA_TYPES.includes(mediaType))
14
- throw new Error("Only JPEG, PNG, and WebP images are supported.");
15
- if (typeof base64 !== "string" || base64 === "")
16
- throw new Error("Image data is required.");
17
- if (base64.length % 4 !== 0 || !/^[A-Za-z0-9+/]*={0,2}$/u.test(base64))
18
- throw new Error("Image data must be canonical base64.");
19
- const decoded = atob(base64);
20
- const bytes = Uint8Array.from(decoded, (character) => character.charCodeAt(0));
21
- if (btoa(decoded) !== base64)
22
- throw new Error("Image data must be canonical base64.");
23
- validateImageBytes(mediaType, bytes);
24
- return bytes;
25
- }
26
- /** Verify the asserted media type and lightweight file signature for a supported image. */
27
- export function validateImageBytes(mediaType, bytes) {
28
- if (!IMAGE_MEDIA_TYPES.includes(mediaType))
29
- throw new Error("Only JPEG, PNG, and WebP images are supported.");
30
- if (bytes.byteLength === 0 || bytes.byteLength > MAX_IMAGE_BYTES)
31
- throw new Error("Images must be no larger than 8 MiB.");
32
- const signature = mediaType === "image/jpeg"
33
- ? bytes.byteLength >= 3 &&
34
- bytes[0] === 0xff &&
35
- bytes[1] === 0xd8 &&
36
- bytes[2] === 0xff
37
- : mediaType === "image/png"
38
- ? bytes.byteLength >= 8 &&
39
- bytes[0] === 0x89 &&
40
- bytes[1] === 0x50 &&
41
- bytes[2] === 0x4e &&
42
- bytes[3] === 0x47 &&
43
- bytes[4] === 0x0d &&
44
- bytes[5] === 0x0a &&
45
- bytes[6] === 0x1a &&
46
- bytes[7] === 0x0a
47
- : bytes.byteLength >= 12 &&
48
- bytes[0] === 0x52 &&
49
- bytes[1] === 0x49 &&
50
- bytes[2] === 0x46 &&
51
- bytes[3] === 0x46 &&
52
- bytes[8] === 0x57 &&
53
- bytes[9] === 0x45 &&
54
- bytes[10] === 0x42 &&
55
- bytes[11] === 0x50;
56
- if (!signature)
57
- throw new Error(`Image bytes do not match ${mediaType}.`);
58
- }
@@ -1,25 +0,0 @@
1
- import { type EnvironmentEvent, type EnvironmentEventPayload, type EnvironmentEventType } from "@nylorun/core/contracts";
2
- /** The Environment stream's two statements, in the caller's transaction. */
3
- export interface EnvironmentRecordWriter {
4
- /** The seq the Environment's next event takes: one past its last, or 0. */
5
- nextSeq(environmentId: string): Promise<number>;
6
- insert(row: {
7
- environmentId: string;
8
- seq: number;
9
- type: string;
10
- body: EnvironmentEvent;
11
- }): Promise<void>;
12
- }
13
- export interface EnvironmentAppendInput<T extends EnvironmentEventType> {
14
- tenantId: string;
15
- environmentId: string;
16
- time: Date;
17
- type: T;
18
- payload: EnvironmentEventPayload<T>;
19
- }
20
- /** Builds the event and checks it against the Environment event catalog. */
21
- export declare function buildEnvironmentEvent<T extends EnvironmentEventType>(input: EnvironmentAppendInput<T> & {
22
- seq: number;
23
- }): EnvironmentEvent;
24
- /** Appends one event to the Environment's stream through `writer`. */
25
- export declare function appendEnvironmentEvent<T extends EnvironmentEventType>(writer: EnvironmentRecordWriter, input: EnvironmentAppendInput<T>): Promise<EnvironmentEvent>;
@@ -1,44 +0,0 @@
1
- /**
2
- * A environment's lifecycle stream (blueprint D39, F7.1): `environment.created`, `environment.attached`,
3
- * `environment.detached` and `environment.deleted` (and the rest of `ENVIRONMENT_EVENT_TYPES`, egress-gate's
4
- * `environment.egress` for every connection among them, D67), on the `nylorun.environment-event/1` envelope, numbered
5
- * from 0 per environment id in `nylorun_streams.environment_events`. The record module is its only
6
- * writer, as for session events; the store runs the two statements through
7
- * `EnvironmentRecordWriter` in the caller's transaction, under the environment row's lock (or, for a
8
- * environment being created, its new row).
9
- *
10
- * The stream lives in the record only: it is not published to the stream relay, so no S2
11
- * stream follows it yet. Clients read it with `GET /v1/environmentes/{id}/events`.
12
- */
13
- import { randomUUID } from "node:crypto";
14
- import { z } from "zod";
15
- import { ENVIRONMENT_EVENT_PAYLOADS, ENVIRONMENT_EVENT_SCHEMA, EnvironmentEventSchema, } from "@nylorun/core/contracts";
16
- import { InvalidEventError } from "./envelope.js";
17
- /** Builds the event and checks it against the Environment event catalog. */
18
- export function buildEnvironmentEvent(input) {
19
- const payload = ENVIRONMENT_EVENT_PAYLOADS[input.type];
20
- const checkedPayload = payload.safeParse(input.payload);
21
- if (!checkedPayload.success)
22
- throw new InvalidEventError(input.type, z.prettifyError(checkedPayload.error));
23
- const event = JSON.parse(JSON.stringify({
24
- schema: ENVIRONMENT_EVENT_SCHEMA,
25
- eventId: randomUUID(),
26
- tenantId: input.tenantId,
27
- environmentId: input.environmentId,
28
- seq: input.seq,
29
- time: input.time.toISOString(),
30
- type: input.type,
31
- payload: input.payload,
32
- }));
33
- const checked = EnvironmentEventSchema.safeParse(event);
34
- if (!checked.success)
35
- throw new InvalidEventError(input.type, z.prettifyError(checked.error));
36
- return event;
37
- }
38
- /** Appends one event to the Environment's stream through `writer`. */
39
- export async function appendEnvironmentEvent(writer, input) {
40
- const seq = await writer.nextSeq(input.environmentId);
41
- const event = buildEnvironmentEvent({ ...input, seq });
42
- await writer.insert({ environmentId: input.environmentId, seq, type: input.type, body: event });
43
- return event;
44
- }
@@ -1,9 +0,0 @@
1
- import { type AgentManifest, type SandboxManifest } from "@nylorun/core/define";
2
- /**
3
- * The session's sandbox spec when `toolName` is one of the sandbox tools the Runtime pinned on
4
- * `manifest` (its `runtime` block); undefined for any other tool. A tool's name alone says whose
5
- * it is: an author tool may not take a Runtime tool's name.
6
- */
7
- export declare function sandboxToolSpec(manifest: AgentManifest | undefined, toolName: string | undefined): SandboxManifest | undefined;
8
- /** True when `toolName` is a tool the Runtime pinned on `manifest` (its `runtime.tools`). */
9
- export declare function isPinnedRuntimeTool(manifest: AgentManifest | undefined, toolName: string | undefined): boolean;
@@ -1,16 +0,0 @@
1
- import { isSandboxToolName, runtimeToolOf, } from "@nylorun/core/define";
2
- /**
3
- * The session's sandbox spec when `toolName` is one of the sandbox tools the Runtime pinned on
4
- * `manifest` (its `runtime` block); undefined for any other tool. A tool's name alone says whose
5
- * it is: an author tool may not take a Runtime tool's name.
6
- */
7
- export function sandboxToolSpec(manifest, toolName) {
8
- if (!toolName || !isSandboxToolName(toolName))
9
- return undefined;
10
- const sandbox = manifest?.runtime?.sandbox;
11
- return sandbox !== undefined && runtimeToolOf(manifest, toolName) !== undefined ? sandbox : undefined;
12
- }
13
- /** True when `toolName` is a tool the Runtime pinned on `manifest` (its `runtime.tools`). */
14
- export function isPinnedRuntimeTool(manifest, toolName) {
15
- return runtimeToolOf(manifest, toolName) !== undefined;
16
- }
@@ -1,16 +0,0 @@
1
- import { type AgentManifest, type SandboxManifest } from "@nylorun/core/define";
2
- export type SandboxedManifest = {
3
- readonly ok: true;
4
- readonly manifest: AgentManifest;
5
- readonly manifestHash: string;
6
- } | {
7
- readonly ok: false;
8
- readonly message: string;
9
- };
10
- /** The agent's pinned manifest with the session's sandbox, or why it cannot take one. */
11
- export declare function withSandbox(manifest: AgentManifest, spec: SandboxManifest): SandboxedManifest;
12
- /**
13
- * The pinned manifest of an agent session without a sandbox: `read_artifact` for each agent of
14
- * the tree (R2b C11, protocol 12), and the skill tools for each with skills.
15
- */
16
- export declare function withRuntimeTools(manifest: AgentManifest): SandboxedManifest;
@@ -1,77 +0,0 @@
1
- /**
2
- * Gives a session the sandbox chosen when it was opened, and the Runtime tools its agents need.
3
- * An agent session's pinned manifest is its definition with a `runtime` block
4
- * (`runtimeManifestFor`) on each agent of the tree:
5
- *
6
- * - with a sandbox, the six sandbox tools, their instructions and the resolved spec, and
7
- * `save_artifact`, so files the agent makes reach the user (F8.1). The agents it uses as tools
8
- * get the same spec, so the tree shares one sandbox. The sandbox's instructions name the
9
- * agent's skills' folders (`/skills/<name>@<hash>/`);
10
- * - with or without a sandbox, `read_artifact` (R2b C11, protocol 12): the Runtime stores a result
11
- * of an MCP or HTTP tool too large to show as an artifact, and the model reads it in pages; a
12
- * file of an earlier turn is a reference line the model reads again with it;
13
- * - with skills, `load_skill`, `read_skill_resource` and the skill catalog.
14
- *
15
- * `tool_search` and `tool_call` are not pinned: they are session tools, given per run when the
16
- * session defers some MCP tools (R2b C10). An author tool may not take any of these names (the
17
- * manifest schema refuses it), so a tool's name alone says whose it is. The definition in the
18
- * registry never changes.
19
- */
20
- import { AgentManifestSchema } from "@nylorun/core/contracts";
21
- import { hashManifest, runtimeManifestFor, } from "@nylorun/core/define";
22
- function isAgentManifest(value) {
23
- return (typeof value === "object" &&
24
- value !== null &&
25
- value.kind !== "workflow" &&
26
- typeof value.id === "string");
27
- }
28
- /** `manifest` with its `runtime` block, and each agent it uses as a tool with its own. */
29
- function pinRuntime(manifest, spec) {
30
- let changed = false;
31
- const tools = manifest.tools?.map((tool) => {
32
- // Agents used as tools share the session's sandbox; flow agents used as tools run in linked
33
- // sessions that inherit it.
34
- if (tool.agent === undefined || !isAgentManifest(tool.agent))
35
- return tool;
36
- const agent = pinRuntime(tool.agent, spec);
37
- if (agent === tool.agent)
38
- return tool;
39
- changed = true;
40
- return { ...tool, agent };
41
- });
42
- const runtime = runtimeManifestFor(manifest, {
43
- ...(spec === undefined ? {} : { sandbox: spec }),
44
- save: spec !== undefined,
45
- read: true,
46
- });
47
- if (runtime === undefined && !changed)
48
- return manifest;
49
- return {
50
- ...manifest,
51
- ...(changed ? { tools } : {}),
52
- ...(runtime === undefined ? {} : { runtime }),
53
- };
54
- }
55
- /** `pinned` checked as a manifest, with its hash. */
56
- function checked(original, pinned) {
57
- const parsed = AgentManifestSchema.safeParse(pinned);
58
- if (!parsed.success) {
59
- const issues = parsed.error.issues.map((issue) => issue.message);
60
- return {
61
- ok: false,
62
- message: `'${original.id}' cannot take the Runtime's tools: ${[...new Set(issues)].join("; ")}`,
63
- };
64
- }
65
- return { ok: true, manifest: pinned, manifestHash: hashManifest(pinned) };
66
- }
67
- /** The agent's pinned manifest with the session's sandbox, or why it cannot take one. */
68
- export function withSandbox(manifest, spec) {
69
- return checked(manifest, pinRuntime(manifest, spec));
70
- }
71
- /**
72
- * The pinned manifest of an agent session without a sandbox: `read_artifact` for each agent of
73
- * the tree (R2b C11, protocol 12), and the skill tools for each with skills.
74
- */
75
- export function withRuntimeTools(manifest) {
76
- return checked(manifest, pinRuntime(manifest, undefined));
77
- }
@@ -1,13 +0,0 @@
1
- import type { SandboxToolOutcome } from "@nylorun/core/contracts";
2
- import { type ToolResultFile } from "@nylorun/core/define";
3
- import type { HostEffect } from "@nylorun/harness/run";
4
- import { type TenantContext } from "./context.js";
5
- export { isReadArtifactCall, isSaveArtifactCall } from "../harness/calls.js";
6
- export declare function callSaveArtifact(ctx: TenantContext, request: HostEffect, signal: AbortSignal): Promise<SandboxToolOutcome>;
7
- /** What `read_artifact` returns: a page of a text artifact, or a file the model reads. */
8
- interface ReadOutcome {
9
- readonly kind: "completed";
10
- readonly output: Record<string, unknown>;
11
- readonly files?: readonly ToolResultFile[];
12
- }
13
- export declare function callReadArtifact(ctx: TenantContext, request: HostEffect, signal: AbortSignal): Promise<ReadOutcome | SandboxToolOutcome>;