@nylorun/runtime 0.24.0-beta → 0.26.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 (171) hide show
  1. package/CHANGELOG.md +143 -0
  2. package/README.md +18 -4
  3. package/dist/api/a2a/card.d.ts +11 -1
  4. package/dist/api/a2a/card.js +26 -2
  5. package/dist/api/a2a/endpoint.js +4 -2
  6. package/dist/api/a2a/protocol.d.ts +25 -2
  7. package/dist/api/a2a/protocol.js +20 -3
  8. package/dist/api/a2a/routes.d.ts +4 -1
  9. package/dist/api/a2a/routes.js +65 -7
  10. package/dist/api/ag-ui/endpoint.js +5 -2
  11. package/dist/api/ag-ui/history.d.ts +6 -1
  12. package/dist/api/ag-ui/history.js +35 -2
  13. package/dist/api/ag-ui/routes.js +53 -11
  14. package/dist/api/components.d.ts +1165 -678
  15. package/dist/api/components.js +16 -1
  16. package/dist/api/gate/keys.d.ts +2 -1
  17. package/dist/api/gate/keys.js +7 -0
  18. package/dist/api/gate/routes.js +13 -0
  19. package/dist/api/http/app.d.ts +2 -2
  20. package/dist/api/http/app.js +15 -4
  21. package/dist/api/http/body.d.ts +3 -3
  22. package/dist/api/http/body.js +7 -7
  23. package/dist/api/http/define.d.ts +1 -1
  24. package/dist/api/http/respond.js +1 -1
  25. package/dist/api/http/routes/environment-manifests.d.ts +9 -0
  26. package/dist/api/http/routes/environment-manifests.js +118 -0
  27. package/dist/api/http/routes/environments.js +61 -12
  28. package/dist/api/http/routes/reads.d.ts +52 -3
  29. package/dist/api/http/routes/sessions.js +14 -4
  30. package/dist/api/http/routes/tenant.js +35 -7
  31. package/dist/api/inbound-files.d.ts +65 -0
  32. package/dist/api/inbound-files.js +115 -0
  33. package/dist/api/openapi.js +18 -3
  34. package/dist/artifacts/disk.js +20 -14
  35. package/dist/artifacts/media-types.d.ts +15 -0
  36. package/dist/artifacts/media-types.js +56 -4
  37. package/dist/artifacts/parts.d.ts +12 -3
  38. package/dist/artifacts/parts.js +15 -4
  39. package/dist/artifacts/workspace.d.ts +4 -4
  40. package/dist/artifacts/workspace.js +6 -18
  41. package/dist/core/flow-host.d.ts +1 -1
  42. package/dist/core/flow-host.js +2 -2
  43. package/dist/core/sandbox-routes.js +2 -2
  44. package/dist/core/turn-manifest.d.ts +3 -2
  45. package/dist/core/turn-manifest.js +29 -5
  46. package/dist/gates/egress-credentials.js +1 -1
  47. package/dist/gates/egress.d.ts +13 -19
  48. package/dist/gates/egress.js +32 -29
  49. package/dist/gates/http-tool.d.ts +3 -4
  50. package/dist/gates/http-tool.js +23 -19
  51. package/dist/gates/journal.js +0 -1
  52. package/dist/gates/mcp-handler.js +2 -3
  53. package/dist/gates/policy.js +1 -3
  54. package/dist/gates/tool-contract.d.ts +1 -1
  55. package/dist/harness/calls.d.ts +2 -2
  56. package/dist/harness/calls.js +9 -12
  57. package/dist/harness/main.js +7 -1
  58. package/dist/harness/pod.d.ts +6 -1
  59. package/dist/harness/pod.js +5 -0
  60. package/dist/harness/service.js +5 -5
  61. package/dist/harness/setup.d.ts +2 -0
  62. package/dist/harness/setup.js +25 -1
  63. package/dist/harness-api/record.d.ts +1 -1
  64. package/dist/harness-api/record.js +13 -13
  65. package/dist/harness-api/server.d.ts +27 -4
  66. package/dist/harness-api/server.js +41 -8
  67. package/dist/harness-api/tool-journal.d.ts +17 -8
  68. package/dist/harness-api/tool-journal.js +41 -11
  69. package/dist/harness-api/workspace.d.ts +7 -5
  70. package/dist/harness-api/workspace.js +25 -19
  71. package/dist/host/gates.js +2 -2
  72. package/dist/host/stack-config.js +1 -1
  73. package/dist/keys/contract.d.ts +1 -1
  74. package/dist/keys/contract.js +1 -1
  75. package/dist/keys/keys.d.ts +9 -2
  76. package/dist/keys/keys.js +4 -1
  77. package/dist/management-openapi.json +366 -61
  78. package/dist/mcp/connect.d.ts +1 -2
  79. package/dist/mcp/connect.js +1 -4
  80. package/dist/mcp/pool.d.ts +1 -4
  81. package/dist/mcp/pool.js +13 -27
  82. package/dist/mcp/preview.d.ts +1 -1
  83. package/dist/mcp/preview.js +1 -2
  84. package/dist/mcp/snapshot.d.ts +11 -13
  85. package/dist/mcp/snapshot.js +27 -38
  86. package/dist/model/capabilities.d.ts +26 -0
  87. package/dist/model/capabilities.js +44 -0
  88. package/dist/model/catalog.d.ts +34 -3
  89. package/dist/model/catalog.js +38 -2
  90. package/dist/model/models.d.ts +2 -0
  91. package/dist/model/models.js +1 -1
  92. package/dist/model/native-blocks.d.ts +35 -0
  93. package/dist/model/native-blocks.js +170 -0
  94. package/dist/model/pi-model.js +106 -94
  95. package/dist/openapi.json +9554 -5076
  96. package/dist/record/environment.js +1 -1
  97. package/dist/sandbox/join.js +4 -0
  98. package/dist/sandbox/manager.d.ts +32 -14
  99. package/dist/sandbox/manager.js +132 -93
  100. package/dist/sandbox/placement.d.ts +1 -1
  101. package/dist/sandbox/placement.js +2 -2
  102. package/dist/sandbox/pods/client.d.ts +3 -1
  103. package/dist/sandbox/pods/lifecycle.d.ts +8 -0
  104. package/dist/sandbox/pods/lifecycle.js +15 -0
  105. package/dist/sandbox/pods/spec.js +2 -1
  106. package/dist/sandbox/resolve.d.ts +5 -3
  107. package/dist/sandbox/resolve.js +9 -2
  108. package/dist/sandbox/runtime-tools.d.ts +9 -0
  109. package/dist/sandbox/runtime-tools.js +16 -0
  110. package/dist/sandbox/session-sandbox.d.ts +4 -6
  111. package/dist/sandbox/session-sandbox.js +47 -94
  112. package/dist/sandbox/setup.d.ts +4 -1
  113. package/dist/sandbox/setup.js +46 -9
  114. package/dist/sandbox/share.d.ts +12 -7
  115. package/dist/sandbox/share.js +27 -25
  116. package/dist/sandbox/skills.d.ts +8 -6
  117. package/dist/sandbox/skills.js +24 -23
  118. package/dist/store/postgres/drizzle/0024_flat_manifest.sql +7 -0
  119. package/dist/store/postgres/drizzle/0025_environment_manifests.sql +14 -0
  120. package/dist/store/postgres/drizzle/0026_environment_forks.sql +1 -0
  121. package/dist/store/postgres/drizzle/0027_environment_image_digest.sql +1 -0
  122. package/dist/store/postgres/drizzle/meta/_journal.json +28 -0
  123. package/dist/store/postgres/migrate.js +1 -1
  124. package/dist/store/postgres/reads.js +8 -2
  125. package/dist/store/postgres/schema.d.ts +217 -0
  126. package/dist/store/postgres/schema.js +36 -2
  127. package/dist/store/postgres/store.js +79 -4
  128. package/dist/store/types.d.ts +68 -14
  129. package/dist/tenant/advance.js +3 -0
  130. package/dist/tenant/artifact-tool.d.ts +1 -1
  131. package/dist/tenant/artifact-tool.js +43 -22
  132. package/dist/tenant/commands.js +24 -4
  133. package/dist/tenant/context.d.ts +10 -4
  134. package/dist/tenant/effects.js +7 -9
  135. package/dist/tenant/environment-manifests.d.ts +57 -0
  136. package/dist/tenant/environment-manifests.js +200 -0
  137. package/dist/tenant/environments.d.ts +54 -47
  138. package/dist/tenant/environments.js +309 -85
  139. package/dist/tenant/ephemeral.d.ts +1 -1
  140. package/dist/tenant/host-token.js +1 -1
  141. package/dist/tenant/identity-file.d.ts +1 -1
  142. package/dist/tenant/identity-file.js +1 -1
  143. package/dist/tenant/model-setting.d.ts +14 -0
  144. package/dist/tenant/model-setting.js +51 -0
  145. package/dist/tenant/outbound.d.ts +6 -5
  146. package/dist/tenant/outbound.js +8 -6
  147. package/dist/tenant/sessions.d.ts +5 -1
  148. package/dist/tenant/sessions.js +45 -12
  149. package/dist/tenant/skill-tool.d.ts +3 -3
  150. package/dist/tenant/skill-tool.js +6 -11
  151. package/dist/tenant/sweep.js +1 -1
  152. package/dist/tenant/tool-results.js +1 -1
  153. package/dist/tenant/tool-search.d.ts +7 -11
  154. package/dist/tenant/tool-search.js +8 -5
  155. package/dist/tenant/transcript.d.ts +51 -32
  156. package/dist/tenant/transcript.js +2 -1
  157. package/dist/tenant/types.d.ts +2 -2
  158. package/dist/traces/ids.d.ts +0 -1
  159. package/dist/traces/ids.js +0 -4
  160. package/dist/traces/map.d.ts +2 -2
  161. package/dist/traces/map.js +1 -29
  162. package/dist/vault/coverage.js +11 -13
  163. package/dist/vault/host-model.d.ts +4 -1
  164. package/dist/vault/host-model.js +10 -2
  165. package/dist/vault/service.d.ts +49 -4
  166. package/dist/vault/service.js +153 -6
  167. package/dist/version.d.ts +1 -1
  168. package/dist/version.js +1 -1
  169. package/package.json +3 -3
  170. package/dist/sandbox/capability.d.ts +0 -3
  171. package/dist/sandbox/capability.js +0 -10
@@ -1,43 +1,8 @@
1
- /**
2
- * Environments (D55, D56, protocol 11): `PUT`, `GET` and `DELETE /v1/environments/{id}`, the
3
- * list by label, stop, reset and the lifecycle stream; sessions naming one with `environment`,
4
- * and the checks every turn start makes on it.
5
- *
6
- * - **No scope.** The Runtime decides nothing about who uses an Environment: the app maps its
7
- * people and agents to ids. It stores the id, kind, recipe, labels and the optional owner
8
- * guard; the session body names the Environment (`Session.environmentId`), and deleting a
9
- * session (a sessions reset) only detaches it.
10
- * - **One sandbox, one vault.** Kind `virtual` (a just-bash workspace in the harness container,
11
- * keyed by the Environment id and created on the first tool call), `pod` (an agent-sandbox pod
12
- * on the Tenant's cluster, Host feature `sandbox-pods`, created at once) or `none` (no compute).
13
- * Each has one vault (`vault/service.ts`), created and deleted with it in one transaction.
14
- * - **A recipe that changes.** `PUT` on an existing id compares the fields sent: `kind` and
15
- * `storage` are fixed (`409`), labels replace, and any other change writes the recipe and bumps
16
- * `version`. A pod runs `applied`: image and resources reach it when it is next asked to run
17
- * from stopped (`wantRunning`), so nothing swaps them mid-turn; so does `harness`, which picks
18
- * what the pod runs (R4.4). Network and lifecycle apply at once. A virtual or `none`
19
- * Environment applies every change at once.
20
- * - **Access.** An application key reaches every Environment, and so does an application key
21
- * acting for a subject (`Nylorun-Subject`), which needs `environments:write` to change one. A
22
- * token caller reaches only the ids its grants match, and changes them only with
23
- * `environments:write`; any other id is the 404 of a missing one.
24
- * - **The owner guard.** When `ownerUserId` is set, only that owner's sessions may name the
25
- * Environment, checked when a session opens and at every turn start (`403
26
- * environment_owner_mismatch`; the opaque 404 to a caller acting for a person).
27
- * - **Serial turns.** One turn at a time per Environment with a sandbox: a session whose
28
- * Environment another session's turn holds is refused (`409 environment_busy`).
29
- * - **Lifecycle.** `POST .../stop` suspends a pod (the volume is kept; the next turn starts it),
30
- * `POST .../reset` gives it a new pod on a new volume. A lost pod refuses turns
31
- * (`environment_lost`) until a reset. `lifecycle.deleteAfter` deletes an Environment unused
32
- * for that long (the Tenant sweep, `sweepUnusedEnvironments`). Deleting a pod Environment keeps
33
- * its row (`desired: deleted`, invisible here) until its Sandbox is gone; its vault goes at once.
34
- * - **Lifecycle events** go to the Environment's own stream in the record (`Tx.environmentEvent`,
35
- * `record/environment.ts`); the session's log records `environment.attached` too.
36
- */
37
- import { type EnvironmentView, type PutEnvironmentRequest } from "@nylorun/core/contracts";
38
- import type { Environment, Tx } from "../store/types.js";
1
+ import { type EnvironmentRecipe, type EnvironmentView, type ForkEnvironmentRequest, type ForkEnvironmentResponse, type PutEnvironmentRequest, type PutEnvironmentSecretRequest } from "@nylorun/core/contracts";
2
+ import type { Environment, EnvironmentEventsQuery, Tx } from "../store/types.js";
39
3
  import type { SandboxRouteDeps } from "../core/sandbox-routes.js";
40
4
  import { type AuthScope, type Session, type TenantContext } from "./context.js";
5
+ import type { SealedSecretCopies } from "../vault/service.js";
41
6
  /** The Environment grants that limit `scope`, or undefined when it reaches every Environment. */
42
7
  export declare function environmentGrantsOf(scope: AuthScope): readonly string[] | undefined;
43
8
  /** Who the vault's audit rows name for a request: the subject, else the application. */
@@ -48,13 +13,54 @@ export declare function assertReaches(scope: AuthScope, id: string): void;
48
13
  export declare function liveEnvironment(t: Tx, id: string, options?: {
49
14
  lock?: boolean;
50
15
  }): Promise<Environment | undefined>;
16
+ /**
17
+ * Why input files cannot be used: each that is not a version of a Tenant-wide artifact (a
18
+ * session's artifacts go with the session). Pins nothing else: the version is the one named.
19
+ */
20
+ export declare function fileErrors(t: Tx, files: EnvironmentRecipe["files"]): Promise<string[]>;
51
21
  /**
52
22
  * `PUT /v1/environments/{id}`: creates the Environment and its vault (within the Tenant's limit
53
- * on their number), or finds the one with this id, so "get or create" is one call. On an
54
- * existing one, `kind` and `storage` must match, labels replace, the owner guard is set or
55
- * cleared, and a recipe change bumps `version`. Every `PUT` counts as the Environment's use.
23
+ * on their number) from an environment manifest's version or from the inline fields, or finds
24
+ * the one with this id, so "get or create" is one call. An existing one never changes what it
25
+ * runs (D63): its labels and owner guard may change, fields that match are accepted, and any
26
+ * other difference is `409 environment_immutable`. Every `PUT` counts as the Environment's use.
27
+ */
28
+ export declare function putEnvironment(ctx: TenantContext, id: string, body: PutEnvironmentRequest, scope: AuthScope, options?: {
29
+ fork?: Fork;
30
+ }): Promise<EnvironmentView>;
31
+ /**
32
+ * The secret write `raw` asks of Environment `id` (D64). When what it runs declares secret
33
+ * slots, the name must be one (`409 secret_not_in_manifest`), and the body is `{ value }` (or
34
+ * `{ headers }` for a `headers` slot) with the binding from the slot; a full typed body is
35
+ * accepted only when its binding is the slot's. Without slots, today's typed body.
36
+ */
37
+ export declare function secretRequestFor(ctx: TenantContext, id: string, name: string, raw: unknown): Promise<PutEnvironmentSecretRequest>;
38
+ /** What a create does for a fork (`POST .../fork`); `copied` is filled in by the create. */
39
+ interface Fork {
40
+ source: string;
41
+ setup: boolean;
42
+ /**
43
+ * The source's secrets sealed by keys for the new vault `vaultId` (F4.2), before the create's
44
+ * transaction, which inserts them; absent with `secrets: none`.
45
+ */
46
+ sealed?: {
47
+ vaultId: string;
48
+ copies: SealedSecretCopies;
49
+ };
50
+ copied?: {
51
+ copied: string[];
52
+ dropped: string[];
53
+ };
54
+ }
55
+ /**
56
+ * `POST /v1/environments/{id}/fork` (Q15): how an Environment gets a new manifest version. A new
57
+ * Environment `body.id` is made from the manifest version (default the source's manifest at its
58
+ * latest), its disk started from a version of the source's (`latest` takes a snapshot first,
59
+ * refused during a turn), and its secrets copied inside the Runtime. A fork onto other setup
60
+ * runs that setup on the copied disk before its first turn (Q17). The source keeps what it runs,
61
+ * its disk and its sessions. With `dryRun`, the plan only.
56
62
  */
57
- export declare function putEnvironment(ctx: TenantContext, id: string, body: PutEnvironmentRequest, scope: AuthScope): Promise<EnvironmentView>;
63
+ export declare function forkEnvironment(ctx: TenantContext, sourceId: string, body: ForkEnvironmentRequest, scope: AuthScope): Promise<ForkEnvironmentResponse>;
58
64
  /** `GET /v1/environments/{id}`. */
59
65
  export declare function getEnvironment(ctx: TenantContext, id: string, scope: AuthScope): Promise<EnvironmentView>;
60
66
  /** `GET /v1/environments?label=k=v`: every Environment with all the labels, that the caller reaches. */
@@ -113,7 +119,7 @@ export declare function newVolume(ctx: TenantContext, t: Tx, environment: Enviro
113
119
  /** How long a pending seed holds the disk before another process may take it over. */
114
120
  export declare const SEED_LEASE_MS: number;
115
121
  /** `GET /v1/environments/{id}/events`: the Environment's lifecycle stream. */
116
- export declare function environmentEventsOf(ctx: TenantContext, id: string, scope: AuthScope, fromSeq: number | undefined): Promise<{
122
+ export declare function environmentEventsOf(ctx: TenantContext, id: string, scope: AuthScope, query?: EnvironmentEventsQuery): Promise<{
117
123
  events: {
118
124
  schema: "nylorun.environment-event/1";
119
125
  eventId: string;
@@ -121,7 +127,7 @@ export declare function environmentEventsOf(ctx: TenantContext, id: string, scop
121
127
  environmentId: string;
122
128
  seq: number;
123
129
  time: string;
124
- type: "environment.attached" | "environment.created" | "environment.deleted" | "environment.detached" | "environment.egress" | "environment.failed" | "environment.lost" | "environment.relaunched" | "environment.reset" | "environment.running" | "environment.suspended";
130
+ type: "environment.attached" | "environment.created" | "environment.deleted" | "environment.detached" | "environment.egress" | "environment.failed" | "environment.forked" | "environment.lost" | "environment.relaunched" | "environment.reset" | "environment.running" | "environment.suspended";
125
131
  payload: Record<string, unknown>;
126
132
  }[];
127
133
  }>;
@@ -140,9 +146,9 @@ export declare function recordAttachment(t: Tx, sessionId: string, environmentId
140
146
  /**
141
147
  * Checks a turn start on a session that names an Environment, in the command's transaction
142
148
  * after the session row lock: the Environment still exists, a token caller's grants reach it,
143
- * its owner guard admits the session's owner, and, with a sandbox, no other session's turn
144
- * holds it. Holds the Environment row's lock until the transaction ends, so two turn starts on
145
- * one Environment are decided one after the other.
149
+ * its owner guard admits the session's owner, and no disk copy holds it. Other sessions' turns
150
+ * do not stop it (D66). Holds the Environment row's lock until the transaction ends, so a turn
151
+ * start and disk work on one Environment are decided one after the other.
146
152
  *
147
153
  * A pod Environment must also be usable: not lost (`environment_lost`), on a Runtime with
148
154
  * sandbox pods (`environment_unavailable`). A stopped or failed pod is asked to run again, with
@@ -165,3 +171,4 @@ export declare function touchEnvironment(ctx: TenantContext, id: string): Promis
165
171
  export declare function rearmPodTimers(ctx: TenantContext): Promise<void>;
166
172
  /** Session lookups for the sandbox route handlers (`core/sandbox-routes.ts`). */
167
173
  export declare function sandboxRouteDeps(ctx: TenantContext): SandboxRouteDeps;
174
+ export {};