@nylorun/runtime 0.23.0-beta → 0.24.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 (252) hide show
  1. package/CHANGELOG.md +148 -0
  2. package/README.md +79 -28
  3. package/dist/adapters/execution/restate.js +1 -1
  4. package/dist/adapters/replication/pgoutput.d.ts +2 -0
  5. package/dist/adapters/replication/pgoutput.js +6 -3
  6. package/dist/adapters/sandbox/local.d.ts +9 -1
  7. package/dist/adapters/sandbox/local.js +16 -4
  8. package/dist/adapters/sandbox/virtual.js +4 -1
  9. package/dist/api/a2a/endpoint.js +5 -1
  10. package/dist/api/a2a/routes.d.ts +2 -0
  11. package/dist/api/a2a/routes.js +2 -2
  12. package/dist/api/a2a/tasks.js +2 -1
  13. package/dist/api/ag-ui/endpoint.js +4 -2
  14. package/dist/api/ag-ui/history.js +4 -1
  15. package/dist/api/ag-ui/routes.d.ts +4 -1
  16. package/dist/api/ag-ui/routes.js +11 -10
  17. package/dist/api/ag-ui/translate.js +3 -2
  18. package/dist/api/components.d.ts +4953 -1204
  19. package/dist/api/components.js +25 -16
  20. package/dist/api/gate/keys.js +7 -1
  21. package/dist/api/gate/routes.d.ts +6 -0
  22. package/dist/api/gate/routes.js +39 -3
  23. package/dist/api/http/app.js +4 -4
  24. package/dist/api/http/define.d.ts +6 -0
  25. package/dist/api/http/define.js +13 -1
  26. package/dist/api/http/respond.js +1 -1
  27. package/dist/api/http/routes/artifacts.js +35 -8
  28. package/dist/api/http/routes/coverage.d.ts +9 -0
  29. package/dist/api/http/routes/coverage.js +34 -0
  30. package/dist/api/http/routes/environments.d.ts +11 -0
  31. package/dist/api/http/routes/environments.js +283 -0
  32. package/dist/api/http/routes/mcp.d.ts +1 -1
  33. package/dist/api/http/routes/mcp.js +2 -2
  34. package/dist/api/http/routes/me.js +1 -1
  35. package/dist/api/http/routes/reads.d.ts +45 -9
  36. package/dist/api/http/routes/reads.js +54 -5
  37. package/dist/api/http/routes/sessions.js +11 -6
  38. package/dist/api/http/routes/tenant.js +32 -10
  39. package/dist/api/openapi.js +31 -26
  40. package/dist/artifacts/disk.d.ts +59 -0
  41. package/dist/artifacts/disk.js +563 -0
  42. package/dist/artifacts/export.d.ts +1 -1
  43. package/dist/artifacts/export.js +2 -3
  44. package/dist/artifacts/folders.d.ts +6 -3
  45. package/dist/artifacts/folders.js +17 -12
  46. package/dist/artifacts/service.d.ts +2 -1
  47. package/dist/artifacts/service.js +6 -1
  48. package/dist/artifacts/workspace.d.ts +1 -1
  49. package/dist/artifacts/workspace.js +1 -1
  50. package/dist/core/flow-host.d.ts +2 -3
  51. package/dist/core/flow-host.js +3 -0
  52. package/dist/core/provider.d.ts +3 -2
  53. package/dist/core/provider.js +5 -37
  54. package/dist/core/sandbox-routes.d.ts +2 -21
  55. package/dist/core/sandbox-routes.js +10 -43
  56. package/dist/execution/types.d.ts +1 -1
  57. package/dist/gates/contract.d.ts +3 -24
  58. package/dist/gates/contract.js +1 -36
  59. package/dist/gates/egress-credentials.d.ts +9 -0
  60. package/dist/gates/egress-credentials.js +11 -4
  61. package/dist/gates/egress.d.ts +28 -1
  62. package/dist/gates/egress.js +115 -10
  63. package/dist/gates/fixture-model.d.ts +28 -0
  64. package/dist/gates/fixture-model.js +92 -0
  65. package/dist/gates/handler.js +4 -4
  66. package/dist/gates/http-tool.d.ts +6 -2
  67. package/dist/gates/http-tool.js +3 -5
  68. package/dist/gates/in-process.d.ts +5 -0
  69. package/dist/gates/in-process.js +12 -1
  70. package/dist/gates/journal.d.ts +30 -0
  71. package/dist/gates/journal.js +52 -0
  72. package/dist/gates/mcp-handler.d.ts +4 -0
  73. package/dist/gates/mcp-handler.js +5 -1
  74. package/dist/gates/meter.d.ts +10 -2
  75. package/dist/gates/meter.js +20 -5
  76. package/dist/gates/policy.d.ts +49 -0
  77. package/dist/gates/policy.js +134 -0
  78. package/dist/gates/tenant-vaults.d.ts +7 -7
  79. package/dist/gates/tenant-vaults.js +5 -5
  80. package/dist/gates/tool-calls.d.ts +10 -5
  81. package/dist/gates/tool-calls.js +28 -10
  82. package/dist/gates/tool-client.d.ts +8 -0
  83. package/dist/gates/tool-client.js +27 -11
  84. package/dist/gates/tool-contract.d.ts +10 -68
  85. package/dist/gates/tool-contract.js +1 -85
  86. package/dist/gates/tool-gate.d.ts +1 -1
  87. package/dist/harness/calls.d.ts +12 -5
  88. package/dist/harness/calls.js +21 -12
  89. package/dist/harness/executors.js +12 -9
  90. package/dist/harness/main.js +18 -5
  91. package/dist/harness/pod.d.ts +34 -0
  92. package/dist/harness/pod.js +41 -0
  93. package/dist/harness/service.d.ts +0 -1
  94. package/dist/harness/service.js +13 -5
  95. package/dist/harness/setup.d.ts +27 -0
  96. package/dist/harness/setup.js +150 -0
  97. package/dist/harness/ws-client.js +3 -2
  98. package/dist/harness/ws-port.d.ts +1 -5
  99. package/dist/harness/ws-port.js +1 -5
  100. package/dist/harness-api/in-process.js +3 -3
  101. package/dist/harness-api/record.d.ts +15 -1
  102. package/dist/harness-api/record.js +174 -44
  103. package/dist/harness-api/redact.d.ts +3 -0
  104. package/dist/harness-api/redact.js +45 -0
  105. package/dist/harness-api/server.d.ts +8 -0
  106. package/dist/harness-api/server.js +93 -13
  107. package/dist/harness-api/start.d.ts +10 -3
  108. package/dist/harness-api/start.js +40 -10
  109. package/dist/harness-api/tool-journal.d.ts +96 -0
  110. package/dist/harness-api/tool-journal.js +102 -0
  111. package/dist/harness-api/tool-status.d.ts +13 -0
  112. package/dist/harness-api/tool-status.js +26 -0
  113. package/dist/harness-api/workspace.d.ts +6 -3
  114. package/dist/harness-api/workspace.js +27 -11
  115. package/dist/harness-api/ws-server.d.ts +11 -3
  116. package/dist/harness-api/ws-server.js +94 -15
  117. package/dist/host/gates.d.ts +2 -1
  118. package/dist/host/gates.js +10 -2
  119. package/dist/host/main.js +54 -5
  120. package/dist/host/operate.js +67 -5
  121. package/dist/host/stack-config.d.ts +64 -0
  122. package/dist/host/stack-config.js +61 -1
  123. package/dist/keys/client.js +4 -1
  124. package/dist/keys/keys.d.ts +5 -5
  125. package/dist/keys/keys.js +5 -7
  126. package/dist/management-openapi.json +999 -2211
  127. package/dist/mcp/connect.d.ts +25 -20
  128. package/dist/mcp/connect.js +29 -30
  129. package/dist/mcp/pool.d.ts +2 -2
  130. package/dist/mcp/pool.js +1 -1
  131. package/dist/mcp/preview.d.ts +3 -3
  132. package/dist/mcp/preview.js +10 -20
  133. package/dist/mcp/snapshot.d.ts +5 -11
  134. package/dist/mcp/snapshot.js +6 -7
  135. package/dist/model/pi-model.js +8 -0
  136. package/dist/openapi.json +6955 -2526
  137. package/dist/reads/types.d.ts +16 -3
  138. package/dist/record/append.d.ts +3 -1
  139. package/dist/record/append.js +1 -0
  140. package/dist/record/envelope.d.ts +5 -1
  141. package/dist/record/envelope.js +7 -3
  142. package/dist/record/environment.d.ts +25 -0
  143. package/dist/record/environment.js +44 -0
  144. package/dist/record/index.d.ts +1 -1
  145. package/dist/record/index.js +1 -1
  146. package/dist/sandbox/disk-fs.d.ts +95 -0
  147. package/dist/sandbox/disk-fs.js +206 -0
  148. package/dist/sandbox/join.d.ts +17 -18
  149. package/dist/sandbox/join.js +42 -15
  150. package/dist/sandbox/manager.d.ts +16 -8
  151. package/dist/sandbox/manager.js +33 -17
  152. package/dist/sandbox/placement.d.ts +13 -12
  153. package/dist/sandbox/placement.js +29 -12
  154. package/dist/sandbox/pods/client.d.ts +6 -1
  155. package/dist/sandbox/pods/lifecycle.d.ts +28 -27
  156. package/dist/sandbox/pods/lifecycle.js +14 -26
  157. package/dist/sandbox/pods/reconcile.js +18 -12
  158. package/dist/sandbox/pods/spec.d.ts +15 -13
  159. package/dist/sandbox/pods/spec.js +16 -20
  160. package/dist/sandbox/records.d.ts +2 -2
  161. package/dist/sandbox/records.js +3 -3
  162. package/dist/sandbox/resolve.d.ts +35 -27
  163. package/dist/sandbox/resolve.js +66 -41
  164. package/dist/sandbox/session-sandbox.js +1 -1
  165. package/dist/sandbox/setup.d.ts +61 -0
  166. package/dist/sandbox/setup.js +123 -0
  167. package/dist/sandbox/share.d.ts +11 -21
  168. package/dist/sandbox/share.js +12 -41
  169. package/dist/sandbox/tenant-config.d.ts +12 -14
  170. package/dist/sandbox/tenant-config.js +12 -17
  171. package/dist/sandbox/types.d.ts +6 -0
  172. package/dist/store/postgres/drizzle/0020_environments.sql +63 -0
  173. package/dist/store/postgres/drizzle/0021_disk_versions.sql +7 -0
  174. package/dist/store/postgres/drizzle/0022_model_usage_timing.sql +5 -0
  175. package/dist/store/postgres/drizzle/0023_artifact_pages.sql +1 -0
  176. package/dist/store/postgres/drizzle/meta/_journal.json +28 -0
  177. package/dist/store/postgres/reads.js +117 -17
  178. package/dist/store/postgres/record-writer.d.ts +4 -4
  179. package/dist/store/postgres/record-writer.js +9 -9
  180. package/dist/store/postgres/record.d.ts +7 -0
  181. package/dist/store/postgres/record.js +23 -2
  182. package/dist/store/postgres/schema.d.ts +934 -761
  183. package/dist/store/postgres/schema.js +102 -73
  184. package/dist/store/postgres/store.js +119 -66
  185. package/dist/store/types.d.ts +109 -48
  186. package/dist/tenant/advance.d.ts +7 -6
  187. package/dist/tenant/advance.js +115 -42
  188. package/dist/tenant/artifact-tool.js +3 -4
  189. package/dist/tenant/commands.d.ts +15 -2
  190. package/dist/tenant/commands.js +93 -12
  191. package/dist/tenant/context.d.ts +48 -22
  192. package/dist/tenant/context.js +4 -15
  193. package/dist/tenant/effects.d.ts +1 -1
  194. package/dist/tenant/effects.js +37 -20
  195. package/dist/tenant/environments.d.ts +167 -0
  196. package/dist/tenant/environments.js +823 -0
  197. package/dist/tenant/harness-tokens.d.ts +21 -0
  198. package/dist/tenant/harness-tokens.js +61 -0
  199. package/dist/tenant/host-token.d.ts +1 -1
  200. package/dist/tenant/host-token.js +2 -4
  201. package/dist/tenant/identity-file.d.ts +4 -4
  202. package/dist/tenant/identity-file.js +17 -8
  203. package/dist/tenant/issuers.js +3 -3
  204. package/dist/tenant/principals.js +1 -1
  205. package/dist/tenant/reset.js +3 -3
  206. package/dist/tenant/runtime.d.ts +6 -1
  207. package/dist/tenant/runtime.js +7 -1
  208. package/dist/tenant/session.d.ts +3 -3
  209. package/dist/tenant/session.js +0 -14
  210. package/dist/tenant/sessions.d.ts +13 -13
  211. package/dist/tenant/sessions.js +61 -138
  212. package/dist/tenant/signing-keys.d.ts +5 -1
  213. package/dist/tenant/status.js +3 -3
  214. package/dist/tenant/sweep.js +12 -6
  215. package/dist/tenant/transcript.d.ts +210 -20
  216. package/dist/tenant/transcript.js +62 -11
  217. package/dist/tenant/turn-timing.d.ts +43 -0
  218. package/dist/tenant/turn-timing.js +39 -0
  219. package/dist/tenant/types.d.ts +2 -0
  220. package/dist/traces/ids.d.ts +42 -0
  221. package/dist/traces/ids.js +85 -0
  222. package/dist/traces/key.d.ts +6 -0
  223. package/dist/traces/key.js +37 -0
  224. package/dist/traces/map.d.ts +113 -0
  225. package/dist/traces/map.js +317 -0
  226. package/dist/traces/options.d.ts +7 -0
  227. package/dist/traces/options.js +1 -0
  228. package/dist/traces/otlp.d.ts +42 -0
  229. package/dist/traces/otlp.js +84 -0
  230. package/dist/traces/projector.d.ts +58 -0
  231. package/dist/traces/projector.js +200 -0
  232. package/dist/traces/read.d.ts +23 -0
  233. package/dist/traces/read.js +16 -0
  234. package/dist/vault/coverage.d.ts +26 -0
  235. package/dist/vault/coverage.js +64 -0
  236. package/dist/vault/error.d.ts +11 -1
  237. package/dist/vault/error.js +5 -1
  238. package/dist/vault/service.d.ts +47 -48
  239. package/dist/vault/service.js +321 -382
  240. package/dist/vault/sources.d.ts +5 -16
  241. package/dist/vault/sources.js +6 -8
  242. package/dist/version.d.ts +1 -1
  243. package/dist/version.js +2 -2
  244. package/package.json +13 -13
  245. package/dist/api/http/routes/sandboxes.d.ts +0 -9
  246. package/dist/api/http/routes/sandboxes.js +0 -153
  247. package/dist/api/http/routes/vaults.d.ts +0 -10
  248. package/dist/api/http/routes/vaults.js +0 -139
  249. package/dist/record/sandbox.d.ts +0 -25
  250. package/dist/record/sandbox.js +0 -43
  251. package/dist/tenant/sandboxes.d.ts +0 -123
  252. package/dist/tenant/sandboxes.js +0 -566
@@ -1,3 +1,49 @@
1
+ /**
2
+ * Stack configuration for the Runtime process, parsed from an environment
3
+ * snapshot and argv. Pure: `host/main.ts` passes the process environment and
4
+ * arguments; nothing here reads ambient state.
5
+ *
6
+ * `--service core,loop` names the Runtime services the process runs (blueprint
7
+ * §19, D12): one image runs every service, and a container may pack several.
8
+ * Without the flag a process runs core and loop. `--role api|worker|all` is
9
+ * the deprecated name of the same choice (core, loop, or both). `gates` (the
10
+ * Model Gate) never shares a process with core or loop: it holds the
11
+ * credentials they must not. Only a process that runs core or loop parses the
12
+ * API listener (`NYLORUN_LISTEN_*`); only one that runs gates parses its
13
+ * listener (`NYLORUN_GATES_LISTEN_*`), and only one that runs loop parses
14
+ * where to reach the gate (`NYLORUN_GATES_URL`). Both read
15
+ * `NYLORUN_GATES_TOKEN`. In a container, loop requires the gate: the loop
16
+ * process must never hold a model credential. `egress` (egress-gate, F7.2) joins gates and keys
17
+ * in the gateway and parses its listener (`NYLORUN_EGRESS_LISTEN_*`, default `0.0.0.0:4200`).
18
+ * The credential resolver is gone (protocol 10): its `NYLORUN_RESOLVER_*` variables are ignored,
19
+ * and the Host logs `resolver_removed` when one is set.
20
+ *
21
+ * `harness` (F6.2) runs alone: it holds the harness credential and nothing else. It connects to
22
+ * core's Harness API listener (`NYLORUN_HARNESS_URL`, `NYLORUN_HARNESS_TOKEN`), calls models and
23
+ * remote MCP servers through the gates service (`NYLORUN_GATES_URL`, with run tokens only), and
24
+ * keeps its workspaces under `NYLORUN_HARNESS_ROOT`. It refuses to start with a database, the
25
+ * gates' or keys' credential, or Restate settings. A process running core starts the Harness API
26
+ * listener when `NYLORUN_HARNESS=remote` (`NYLORUN_HARNESS_LISTEN_*`, `NYLORUN_HARNESS_TOKEN`).
27
+ *
28
+ * Two listen modes:
29
+ * - **local** (no `NYLORUN_LISTEN_*` / `NYLORUN_ALLOWED_HOSTS`): the Host binds
30
+ * what `host.json` names, loopback only unless `allowNonLoopback`.
31
+ * - **container**: the Host binds `NYLORUN_LISTEN_HOST:NYLORUN_LISTEN_PORT`
32
+ * (default `0.0.0.0:4000`) and accepts only the `Host` headers in
33
+ * `NYLORUN_ALLOWED_HOSTS`, plus the loopback forms of the listen port for
34
+ * probes from inside the container.
35
+ *
36
+ * The Postgres, Restate and S2 endpoints are parsed and validated here;
37
+ * `infra/*` builds the clients from them. So is the Object store (`NYLORUN_OBJECT_STORE_*`),
38
+ * which every service may read; `host/main.ts` builds the `BlobStore` from it. So is who the Host's Tenant is when its database
39
+ * holds none yet (`NYLORUN_TENANT_ID`, `NYLORUN_TENANT_NAME`). So are traces (R7.2), for a
40
+ * process running core: where they go (`OTEL_EXPORTER_OTLP_ENDPOINT`, or
41
+ * `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT`, with `OTEL_EXPORTER_OTLP_HEADERS`), what they say of
42
+ * their source (`OTEL_SERVICE_NAME`, `OTEL_RESOURCE_ATTRIBUTES`) and which content they carry
43
+ * (`NYLORUN_TRACE_CONTENT`, or all of it with `OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true`).
44
+ */
45
+ import { type TraceResource } from "../traces/otlp.js";
46
+ import { type TraceContentKind } from "../traces/map.js";
1
47
  import { type BlockedAddress } from "../sandbox/pods/network-gate.js";
2
48
  /** A Runtime service this release has. */
3
49
  export type RuntimeService = "core" | "loop" | "gates" | "keys" | "egress" | "harness";
@@ -197,6 +243,24 @@ export interface StackConfig {
197
243
  * (the `fs` adapter, `TenantPaths.blobs`).
198
244
  */
199
245
  objectStore?: ObjectStoreConfig;
246
+ /**
247
+ * Present when the process runs core and an `OTEL_*` or `NYLORUN_TRACE_CONTENT` variable is set:
248
+ * how spans are made, for the trace projector and the trace route (R7.2, R7.5). `export` is
249
+ * present only with an endpoint (Q5): without one there is no replication slot and no cost.
250
+ */
251
+ traces?: TraceConfig;
252
+ }
253
+ /** Traces (R7.2), from the standard `OTEL_*` variables and `NYLORUN_TRACE_CONTENT`. */
254
+ export interface TraceConfig {
255
+ /** `OTEL_SERVICE_NAME` (default `nylorun`) and `OTEL_RESOURCE_ATTRIBUTES`. */
256
+ resource: TraceResource;
257
+ /** The content kinds spans carry: none by default. */
258
+ content: TraceContentKind[];
259
+ /** Where the projector posts: the traces URL and `OTEL_EXPORTER_OTLP_HEADERS`. */
260
+ export?: {
261
+ url: string;
262
+ headers: Record<string, string>;
263
+ };
200
264
  }
201
265
  /** Where the Object store is and the credential for it (`NYLORUN_OBJECT_STORE_*`). */
202
266
  export interface ObjectStoreConfig {
@@ -36,8 +36,14 @@
36
36
  * The Postgres, Restate and S2 endpoints are parsed and validated here;
37
37
  * `infra/*` builds the clients from them. So is the Object store (`NYLORUN_OBJECT_STORE_*`),
38
38
  * which every service may read; `host/main.ts` builds the `BlobStore` from it. So is who the Host's Tenant is when its database
39
- * holds none yet (`NYLORUN_TENANT_ID`, `NYLORUN_TENANT_NAME`).
39
+ * holds none yet (`NYLORUN_TENANT_ID`, `NYLORUN_TENANT_NAME`). So are traces (R7.2), for a
40
+ * process running core: where they go (`OTEL_EXPORTER_OTLP_ENDPOINT`, or
41
+ * `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT`, with `OTEL_EXPORTER_OTLP_HEADERS`), what they say of
42
+ * their source (`OTEL_SERVICE_NAME`, `OTEL_RESOURCE_ATTRIBUTES`) and which content they carry
43
+ * (`NYLORUN_TRACE_CONTENT`, or all of it with `OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true`).
40
44
  */
45
+ import { DEFAULT_SERVICE_NAME } from "../traces/otlp.js";
46
+ import { TRACE_CONTENT_KINDS } from "../traces/map.js";
41
47
  import { isTenantId } from "@nylorun/core/compatibility";
42
48
  import { blockedAddresses } from "../sandbox/pods/network-gate.js";
43
49
  export const RUNTIME_SERVICES = ["core", "loop", "gates", "keys", "egress", "harness"];
@@ -316,6 +322,7 @@ export function parseStackConfig(env, argv) {
316
322
  const delivery = parseDelivery(env);
317
323
  const tenant = servesApi ? parseTenant(env) : undefined;
318
324
  const objectStore = parseObjectStore(env);
325
+ const traces = services.has("core") ? parseTraces(env) : undefined;
319
326
  const removedResolverVariables = Object.keys(env)
320
327
  .filter((name) => name.startsWith(REMOVED_RESOLVER_PREFIX) && read(env, name) !== undefined)
321
328
  .sort();
@@ -337,8 +344,61 @@ export function parseStackConfig(env, argv) {
337
344
  ...(delivery ? { delivery } : {}),
338
345
  ...(tenant ? { tenant } : {}),
339
346
  ...(objectStore ? { objectStore } : {}),
347
+ ...(traces ? { traces } : {}),
340
348
  };
341
349
  }
350
+ /**
351
+ * `StackConfig.traces` (R7.2). The OTLP endpoint is the collector's base URL, to which
352
+ * `/v1/traces` is added; `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` is the full URL and wins. Headers
353
+ * and resource attributes are `key=value` lists separated by commas, values percent-encoded (the
354
+ * OTel SDK environment specification).
355
+ */
356
+ function parseTraces(env) {
357
+ const traces = parseUrl(env, "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT", ["http:", "https:"]);
358
+ const base = parseUrl(env, "OTEL_EXPORTER_OTLP_ENDPOINT", ["http:", "https:"]);
359
+ const url = traces ?? (base === undefined ? undefined : `${base.replace(/\/+$/, "")}/v1/traces`);
360
+ const resource = keyValues(env, "OTEL_RESOURCE_ATTRIBUTES");
361
+ const all = read(env, "OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT")?.toLowerCase() === "true";
362
+ const content = new Set(all ? TRACE_CONTENT_KINDS : []);
363
+ for (const kind of (read(env, "NYLORUN_TRACE_CONTENT") ?? "").split(",").map((part) => part.trim())) {
364
+ if (kind === "")
365
+ continue;
366
+ if (!TRACE_CONTENT_KINDS.includes(kind))
367
+ throw new StackConfigError(`NYLORUN_TRACE_CONTENT lists ${TRACE_CONTENT_KINDS.join(", ")}, not ${kind}`);
368
+ content.add(kind);
369
+ }
370
+ const serviceName = read(env, "OTEL_SERVICE_NAME") ?? resource["service.name"];
371
+ // Nothing set: the defaults (`service.name` nylorun, no content, no export).
372
+ if (url === undefined && serviceName === undefined && Object.keys(resource).length === 0 && content.size === 0)
373
+ return undefined;
374
+ return {
375
+ resource: {
376
+ serviceName: serviceName ?? DEFAULT_SERVICE_NAME,
377
+ attributes: resource,
378
+ },
379
+ content: TRACE_CONTENT_KINDS.filter((kind) => content.has(kind)),
380
+ ...(url ? { export: { url, headers: keyValues(env, "OTEL_EXPORTER_OTLP_HEADERS") } } : {}),
381
+ };
382
+ }
383
+ /** A `key=value,key=value` variable, values percent-decoded; a malformed one is refused. */
384
+ function keyValues(env, name) {
385
+ const out = {};
386
+ for (const pair of (read(env, name) ?? "").split(",")) {
387
+ if (pair.trim() === "")
388
+ continue;
389
+ const at = pair.indexOf("=");
390
+ const key = at < 0 ? "" : pair.slice(0, at).trim();
391
+ if (key === "")
392
+ throw new StackConfigError(`${name} must be key=value pairs separated by commas`);
393
+ try {
394
+ out[key] = decodeURIComponent(pair.slice(at + 1).trim());
395
+ }
396
+ catch {
397
+ throw new StackConfigError(`${name} has a value that is not percent-encoded: ${key}`);
398
+ }
399
+ }
400
+ return out;
401
+ }
342
402
  /** S3 bucket names: 3 to 63 lowercase letters, digits, dots and hyphens. */
343
403
  const BUCKET = /^[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]$/;
344
404
  /** `StackConfig.objectStore` from `NYLORUN_OBJECT_STORE_*`, or `undefined` without an endpoint. */
@@ -51,7 +51,10 @@ export function httpKeys(options) {
51
51
  return resolve(answer.result);
52
52
  const error = answer.error;
53
53
  reject(error.kind === "vault"
54
- ? new VaultError(error.status, error.message)
54
+ ? new VaultError(error.status, error.message, {
55
+ ...(error.code === undefined ? {} : { code: error.code }),
56
+ ...(error.details === undefined ? {} : { details: error.details }),
57
+ })
55
58
  : new HttpError(error.status, error.message, {
56
59
  ...(error.code === undefined ? {} : { code: error.code }),
57
60
  ...(error.details === undefined ? {} : { details: error.details }),
@@ -1,4 +1,4 @@
1
- import type { CreateCredentialRequest, CredentialInfo, HostModelView, McpPreview, McpPreviewRequest, PutHostModelRequest, RotateCredentialRequest, SelectHostModelRequest, SigningKeyView } from "@nylorun/core/contracts";
1
+ import type { EnvironmentSecretView, HostModelView, McpPreview, McpPreviewRequest, PutEnvironmentSecretRequest, PutHostModelRequest, SelectHostModelRequest, SigningKeyView } from "@nylorun/core/contracts";
2
2
  import type { SessionStore } from "../store/types.js";
3
3
  import type { OutboundPolicy } from "../tenant/outbound.js";
4
4
  import { type SigningKeys } from "../tenant/signing-keys.js";
@@ -14,8 +14,8 @@ export interface Signed {
14
14
  readonly keyId: string;
15
15
  }
16
16
  export interface Keys {
17
- createCredential(vaultId: string, body: CreateCredentialRequest): Promise<CredentialInfo>;
18
- rotateCredential(vaultId: string, id: string, body: RotateCredentialRequest): Promise<CredentialInfo>;
17
+ /** `PUT /v1/environments/{id}/secrets/{name}` (`VaultService.putEnvironmentSecret`). */
18
+ putEnvironmentSecret(environmentId: string, name: string, body: PutEnvironmentSecretRequest, actor: string): Promise<EnvironmentSecretView>;
19
19
  putHostModel(body: PutHostModelRequest): Promise<HostModelView>;
20
20
  selectHostModel(body: SelectHostModelRequest): Promise<HostModelView>;
21
21
  /** Signs with the current key, creating the Tenant's keys if it has none. */
@@ -28,7 +28,7 @@ export interface Keys {
28
28
  /** Creates the current and standby keys when the Tenant has none. */
29
29
  ensureSigningKeys(): Promise<void>;
30
30
  /**
31
- * Lists a remote MCP server's tools with the installation vault's credential for its URL
31
+ * Lists a remote MCP server's tools with the Environment's credential for its URL
32
32
  * (R2b C12, `mcp/preview.ts`); never calls a tool.
33
33
  */
34
34
  previewMcp(body: McpPreviewRequest): Promise<McpPreview>;
@@ -41,7 +41,7 @@ export interface Keys {
41
41
  signEgressLeaf(host: string, publicKey: string): Promise<string>;
42
42
  }
43
43
  /** The operations, by the name the HTTP route carries. */
44
- export declare const KEYS_OPERATIONS: readonly ["createCredential", "rotateCredential", "putHostModel", "selectHostModel", "sign", "rotateSigningKeys", "ensureSigningKeys", "previewMcp", "egressCa", "signEgressLeaf"];
44
+ export declare const KEYS_OPERATIONS: readonly ["putEnvironmentSecret", "putHostModel", "selectHostModel", "sign", "rotateSigningKeys", "ensureSigningKeys", "previewMcp", "egressCa", "signEgressLeaf"];
45
45
  export type KeysOperation = (typeof KEYS_OPERATIONS)[number];
46
46
  export interface InProcessKeysOptions {
47
47
  readonly store: SessionStore;
package/dist/keys/keys.js CHANGED
@@ -1,12 +1,12 @@
1
1
  /**
2
2
  * The keys seam (blueprint §14, F4.2): everything that needs the vault key. Vault writes that
3
- * touch a secret (creating and rotating a credential, setting and selecting the host model;
3
+ * touch a secret (writing an Environment's secret, setting and selecting the host model;
4
4
  * rotation and selection decrypt the old secret first) and all token signing (capability
5
5
  * links, run and host tokens, signing-key rotation) run here, whole, so the process that calls them never
6
6
  * holds the key or a private signing key.
7
7
  *
8
- * A tool preview (R2b C12, `previewMcp`) runs here too: it sends an installation vault's
9
- * credential to the server it lists, so the process that reads the plaintext makes the request.
8
+ * A tool preview (R2b C12, `previewMcp`) runs here too: it sends an Environment's credential to
9
+ * the server it lists, so the process that reads the plaintext makes the request.
10
10
  *
11
11
  * Two implementations: `inProcessKeys` (embedding, the ephemeral Runtime, tests, and the gates
12
12
  * service itself, which serves the HTTP routes with it), and `httpKeys` (`client.ts`), the
@@ -18,8 +18,7 @@ import { previewMcpServer } from "../mcp/preview.js";
18
18
  import { signingKeyView } from "../tenant/signing-keys.js";
19
19
  /** The operations, by the name the HTTP route carries. */
20
20
  export const KEYS_OPERATIONS = [
21
- "createCredential",
22
- "rotateCredential",
21
+ "putEnvironmentSecret",
23
22
  "putHostModel",
24
23
  "selectHostModel",
25
24
  "sign",
@@ -33,8 +32,7 @@ export function inProcessKeys(options) {
33
32
  const { store, vault, signingKeys, kek } = options;
34
33
  const egress = new EgressAuthority(store, kek);
35
34
  return {
36
- createCredential: (vaultId, body) => vault.createCredential(vaultId, body),
37
- rotateCredential: (vaultId, id, body) => vault.rotateCredential(vaultId, id, body),
35
+ putEnvironmentSecret: (environmentId, name, body, actor) => vault.putEnvironmentSecret(environmentId, name, body, actor),
38
36
  putHostModel: (body) => vault.putHostModel(body),
39
37
  selectHostModel: (body) => vault.selectHostModel(body),
40
38
  async sign(request) {