@nylorun/runtime 0.19.1-beta → 0.21.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 (137) hide show
  1. package/CHANGELOG.md +90 -0
  2. package/README.md +22 -13
  3. package/dist/adapters/streams/s2.js +5 -11
  4. package/dist/api/components.d.ts +326 -205
  5. package/dist/api/components.js +3 -3
  6. package/dist/api/http/app.js +2 -0
  7. package/dist/api/http/define.d.ts +3 -2
  8. package/dist/api/http/define.js +10 -11
  9. package/dist/api/http/routes/mcp.d.ts +9 -0
  10. package/dist/api/http/routes/mcp.js +32 -0
  11. package/dist/api/http/routes/vaults.d.ts +1 -9
  12. package/dist/api/http/routes/vaults.js +3 -103
  13. package/dist/api/openapi.js +37 -6
  14. package/dist/artifacts/media-types.d.ts +2 -0
  15. package/dist/artifacts/media-types.js +5 -0
  16. package/dist/execution/types.d.ts +1 -1
  17. package/dist/gates/http-tool.d.ts +7 -0
  18. package/dist/gates/http-tool.js +34 -3
  19. package/dist/gates/mcp-handler.d.ts +4 -1
  20. package/dist/gates/mcp-handler.js +64 -8
  21. package/dist/gates/tenant-vaults.d.ts +9 -15
  22. package/dist/gates/tenant-vaults.js +9 -17
  23. package/dist/gates/tool-client.js +36 -17
  24. package/dist/gates/tool-contract.d.ts +19 -3
  25. package/dist/gates/tool-contract.js +9 -3
  26. package/dist/gates/tool-gate.d.ts +2 -2
  27. package/dist/harness/calls.d.ts +2 -0
  28. package/dist/harness/calls.js +13 -3
  29. package/dist/harness-api/record.d.ts +7 -6
  30. package/dist/harness-api/record.js +99 -17
  31. package/dist/harness-api/server.js +35 -27
  32. package/dist/harness-api/start.js +2 -1
  33. package/dist/host/app.d.ts +3 -0
  34. package/dist/host/app.js +33 -4
  35. package/dist/host/config-for.d.ts +0 -2
  36. package/dist/host/config-for.js +0 -1
  37. package/dist/host/create-host.d.ts +6 -0
  38. package/dist/host/create-host.js +1 -0
  39. package/dist/host/gates.js +0 -1
  40. package/dist/host/main.js +24 -7
  41. package/dist/host/stack-config.d.ts +5 -8
  42. package/dist/host/stack-config.js +9 -20
  43. package/dist/index.d.ts +0 -1
  44. package/dist/infra/index.d.ts +2 -1
  45. package/dist/infra/index.js +0 -1
  46. package/dist/infra/readiness.d.ts +6 -6
  47. package/dist/infra/readiness.js +2 -5
  48. package/dist/keys/client.js +1 -9
  49. package/dist/keys/keys.d.ts +11 -13
  50. package/dist/keys/keys.js +5 -7
  51. package/dist/management-openapi.json +671 -378
  52. package/dist/mcp/connect.d.ts +159 -13
  53. package/dist/mcp/connect.js +538 -55
  54. package/dist/mcp/pool.d.ts +11 -2
  55. package/dist/mcp/pool.js +74 -27
  56. package/dist/mcp/preview.d.ts +35 -0
  57. package/dist/mcp/preview.js +215 -0
  58. package/dist/mcp/snapshot.d.ts +79 -5
  59. package/dist/mcp/snapshot.js +145 -27
  60. package/dist/model/catalog.d.ts +14 -0
  61. package/dist/model/catalog.js +14 -1
  62. package/dist/model/pi-model.js +36 -2
  63. package/dist/openapi.json +644 -266
  64. package/dist/redact.d.ts +19 -1
  65. package/dist/redact.js +42 -13
  66. package/dist/sandbox/session-sandbox.d.ts +7 -0
  67. package/dist/sandbox/session-sandbox.js +89 -28
  68. package/dist/store/postgres/connect.d.ts +10 -0
  69. package/dist/store/postgres/connect.js +30 -3
  70. package/dist/store/postgres/control.d.ts +14 -0
  71. package/dist/store/postgres/control.js +187 -0
  72. package/dist/store/postgres/drizzle/0015_control_signals.sql +11 -0
  73. package/dist/store/postgres/drizzle/0016_mcp_oauth_removed.sql +5 -0
  74. package/dist/store/postgres/drizzle/meta/_journal.json +14 -0
  75. package/dist/store/postgres/schema.d.ts +122 -261
  76. package/dist/store/postgres/schema.js +22 -36
  77. package/dist/store/postgres/store.js +16 -18
  78. package/dist/store/postgres/tenant.d.ts +14 -0
  79. package/dist/store/postgres/tenant.js +22 -2
  80. package/dist/store/types.d.ts +42 -8
  81. package/dist/streams/types.d.ts +6 -29
  82. package/dist/streams/types.js +5 -4
  83. package/dist/tenant/artifact-tool.d.ts +9 -1
  84. package/dist/tenant/artifact-tool.js +113 -9
  85. package/dist/tenant/auth.d.ts +16 -6
  86. package/dist/tenant/auth.js +41 -17
  87. package/dist/tenant/commands.js +10 -6
  88. package/dist/tenant/context.d.ts +9 -6
  89. package/dist/tenant/control.d.ts +26 -0
  90. package/dist/tenant/control.js +35 -0
  91. package/dist/tenant/effects.d.ts +2 -2
  92. package/dist/tenant/effects.js +20 -5
  93. package/dist/tenant/ephemeral.d.ts +0 -6
  94. package/dist/tenant/ephemeral.js +1 -1
  95. package/dist/tenant/http.d.ts +4 -2
  96. package/dist/tenant/http.js +4 -2
  97. package/dist/tenant/identity-file.d.ts +16 -12
  98. package/dist/tenant/identity-file.js +41 -29
  99. package/dist/tenant/issuers.d.ts +4 -3
  100. package/dist/tenant/issuers.js +22 -16
  101. package/dist/tenant/outbound.d.ts +14 -5
  102. package/dist/tenant/outbound.js +21 -9
  103. package/dist/tenant/reset.d.ts +2 -2
  104. package/dist/tenant/reset.js +8 -2
  105. package/dist/tenant/resource-server.d.ts +56 -0
  106. package/dist/tenant/resource-server.js +62 -0
  107. package/dist/tenant/runtime.d.ts +1 -1
  108. package/dist/tenant/runtime.js +16 -15
  109. package/dist/tenant/scheduler.d.ts +1 -1
  110. package/dist/tenant/scheduler.js +1 -1
  111. package/dist/tenant/sessions.js +20 -3
  112. package/dist/tenant/store-pg.js +9 -0
  113. package/dist/tenant/streams.d.ts +16 -22
  114. package/dist/tenant/streams.js +7 -87
  115. package/dist/tenant/sweep.js +9 -1
  116. package/dist/tenant/tool-results.d.ts +57 -0
  117. package/dist/tenant/tool-results.js +298 -0
  118. package/dist/tenant/tool-search.d.ts +43 -0
  119. package/dist/tenant/tool-search.js +100 -0
  120. package/dist/tenant/transcript.d.ts +108 -0
  121. package/dist/tenant/transcript.js +13 -0
  122. package/dist/tenant/types.d.ts +0 -14
  123. package/dist/vault/crypto.d.ts +0 -7
  124. package/dist/vault/crypto.js +0 -16
  125. package/dist/vault/headers.d.ts +17 -0
  126. package/dist/vault/headers.js +61 -0
  127. package/dist/vault/service.d.ts +11 -68
  128. package/dist/vault/service.js +83 -438
  129. package/dist/vault/sources.d.ts +20 -48
  130. package/dist/vault/sources.js +25 -189
  131. package/dist/version.d.ts +1 -1
  132. package/dist/version.js +1 -1
  133. package/package.json +3 -3
  134. package/dist/streams/control.d.ts +0 -13
  135. package/dist/streams/control.js +0 -25
  136. package/dist/vault/oauth.d.ts +0 -55
  137. package/dist/vault/oauth.js +0 -186
@@ -1,20 +1,21 @@
1
1
  /**
2
2
  * Aggregate readiness of the Host's infrastructure (architecture §13, §14.3):
3
- * the Runtime's `/ready` covers Postgres, Restate and S2. s2-lite's image has
4
- * no health check of its own, so this is the only place its health shows.
3
+ * the Runtime's `/ready` covers Postgres and Restate. S2 is left out (D48): it only
4
+ * serves API listeners (history, SSE, AG-UI, A2A), so an outage degrades those reads
5
+ * and never makes the Runtime unready. Its health shows in the Tenant's status
6
+ * (`GET /v1/tenant`, `streams.reachable`).
5
7
  *
6
8
  * Every probe runs on each call, in parallel, bounded by one timeout. A probe
7
9
  * that throws or outlives the timeout marks its check `false`. Only check
8
10
  * names and booleans are reported; the errors stay in the report for logs.
9
11
  */
10
12
  import type { DurableExecution } from "../execution/types.js";
11
- import type { DurableStreams } from "../streams/types.js";
12
13
  import { type PostgresClient } from "./database.js";
13
14
  /** Resolves when the dependency answers; rejects otherwise. Must honour `signal`. */
14
15
  export type Probe = (signal: AbortSignal) => Promise<void>;
15
16
  export interface ReadinessReport {
16
17
  ok: boolean;
17
- /** One entry per configured dependency, e.g. `{ postgres, restate, s2 }`. */
18
+ /** One entry per configured dependency, e.g. `{ postgres, restate }`. */
18
19
  checks: Record<string, boolean>;
19
20
  /** Why each failing check failed. Not for unauthenticated responses. */
20
21
  errors: Record<string, string>;
@@ -25,9 +26,8 @@ export declare const READINESS_TIMEOUT_MS = 2000;
25
26
  export declare function createReadiness(probes: Readonly<Record<string, Probe>>, options?: {
26
27
  timeoutMs?: number;
27
28
  }): Readiness;
28
- /** The standard checks for whichever infrastructure the Host was built with. */
29
+ /** The standard checks for whichever infrastructure the Host was built with. Never S2 (D48). */
29
30
  export declare function infraProbes(infra: {
30
31
  database?: PostgresClient;
31
32
  execution?: DurableExecution;
32
- streams?: DurableStreams;
33
33
  }): Record<string, Probe>;
@@ -1,6 +1,5 @@
1
1
  import { probeDatabase } from "./database.js";
2
2
  import { probeExecution } from "./execution.js";
3
- import { probeStreams } from "./streams.js";
4
3
  /** Default bound on one readiness pass. Compose probes `/ready` every 2 s with a 5 s timeout. */
5
4
  export const READINESS_TIMEOUT_MS = 2000;
6
5
  export function createReadiness(probes, options = {}) {
@@ -18,16 +17,14 @@ export function createReadiness(probes, options = {}) {
18
17
  return { ok: Object.values(checks).every(Boolean), checks, errors };
19
18
  };
20
19
  }
21
- /** The standard checks for whichever infrastructure the Host was built with. */
20
+ /** The standard checks for whichever infrastructure the Host was built with. Never S2 (D48). */
22
21
  export function infraProbes(infra) {
23
22
  const probes = {};
24
- const { database, execution, streams } = infra;
23
+ const { database, execution } = infra;
25
24
  if (database)
26
25
  probes.postgres = (signal) => probeDatabase(database, signal);
27
26
  if (execution)
28
27
  probes.restate = (signal) => probeExecution(execution, signal);
29
- if (streams)
30
- probes.s2 = (signal) => probeStreams(streams, signal);
31
28
  return probes;
32
29
  }
33
30
  /** Runs one probe under a timeout; returns its failure message, or undefined when ready. */
@@ -12,18 +12,10 @@ import { KEYS_PATH } from "./contract.js";
12
12
  import { KEYS_OPERATIONS } from "./keys.js";
13
13
  /** Signing and vault writes are short; anything slower is a gateway in trouble. */
14
14
  const KEYS_TIMEOUT_MS = 30_000;
15
- /**
16
- * MCP OAuth connect calls the authorization server several times (discovery, registration, the
17
- * code exchange), each bounded by `guardedFetch`'s 30 s: these wait longer.
18
- */
19
- const SLOW_OPERATIONS = {
20
- startOAuth: 120_000,
21
- finishOAuth: 60_000,
22
- };
23
15
  export function httpKeys(options) {
24
16
  const where = new URL(options.url).origin;
25
17
  function call(operation, args) {
26
- const timeoutMs = Math.max(options.timeoutMs ?? KEYS_TIMEOUT_MS, SLOW_OPERATIONS[operation] ?? 0);
18
+ const timeoutMs = options.timeoutMs ?? KEYS_TIMEOUT_MS;
27
19
  const url = new URL(`${KEYS_PATH}/${operation}`, options.url);
28
20
  const send = url.protocol === "https:" ? httpsRequest : httpRequest;
29
21
  const payload = Buffer.from(JSON.stringify({ args }), "utf8");
@@ -1,7 +1,8 @@
1
- import type { CreateCredentialRequest, CredentialInfo, HostModelView, PutHostModelRequest, RotateCredentialRequest, SelectHostModelRequest, SigningKeyView } from "@nylorun/core/contracts";
1
+ import type { CreateCredentialRequest, CredentialInfo, HostModelView, McpPreview, McpPreviewRequest, PutHostModelRequest, RotateCredentialRequest, SelectHostModelRequest, SigningKeyView } from "@nylorun/core/contracts";
2
2
  import type { SessionStore } from "../store/types.js";
3
+ import type { OutboundPolicy } from "../tenant/outbound.js";
3
4
  import { type SigningKeys } from "../tenant/signing-keys.js";
4
- import type { FinishOAuthInput, StartOAuthInput, VaultService } from "../vault/service.js";
5
+ import type { VaultService } from "../vault/service.js";
5
6
  /** One JWT to sign: its `typ` and every claim, `iss`, `aud`, `sub`, `iat`, `exp` and `jti` included. */
6
7
  export interface SignRequest {
7
8
  readonly typ: string;
@@ -26,19 +27,14 @@ export interface Keys {
26
27
  }): Promise<SigningKeyView[]>;
27
28
  /** Creates the current and standby keys when the Tenant has none. */
28
29
  ensureSigningKeys(): Promise<void>;
29
- /** Starts an MCP OAuth connect into an installation vault (`VaultService.startOAuth`). */
30
- startOAuth(input: StartOAuthInput): Promise<{
31
- authorizeUrl: string;
32
- expiresAt: string;
33
- }>;
34
- /** Finishes one from its callback (`VaultService.finishOAuth`). */
35
- finishOAuth(input: FinishOAuthInput): Promise<{
36
- vaultId: string;
37
- credentialId: string;
38
- }>;
30
+ /**
31
+ * Lists a remote MCP server's tools with the installation vault's credential for its URL
32
+ * (R2b C12, `mcp/preview.ts`); never calls a tool.
33
+ */
34
+ previewMcp(body: McpPreviewRequest): Promise<McpPreview>;
39
35
  }
40
36
  /** The operations, by the name the HTTP route carries. */
41
- export declare const KEYS_OPERATIONS: readonly ["createCredential", "rotateCredential", "putHostModel", "selectHostModel", "sign", "rotateSigningKeys", "ensureSigningKeys", "startOAuth", "finishOAuth"];
37
+ export declare const KEYS_OPERATIONS: readonly ["createCredential", "rotateCredential", "putHostModel", "selectHostModel", "sign", "rotateSigningKeys", "ensureSigningKeys", "previewMcp"];
42
38
  export type KeysOperation = (typeof KEYS_OPERATIONS)[number];
43
39
  export interface InProcessKeysOptions {
44
40
  readonly store: SessionStore;
@@ -47,5 +43,7 @@ export interface InProcessKeysOptions {
47
43
  readonly signingKeys: SigningKeys;
48
44
  /** The vault key. */
49
45
  readonly kek: () => Buffer;
46
+ /** How a tool preview reaches the server (`TenantConfig.delivery`). Default: no limits. */
47
+ readonly policy?: OutboundPolicy;
50
48
  }
51
49
  export declare function inProcessKeys(options: InProcessKeysOptions): Keys;
package/dist/keys/keys.js CHANGED
@@ -5,15 +5,15 @@
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
- * MCP OAuth connect (F9-D14) runs here too: discovery, registration, the code exchange and the
9
- * credential it seals, so the plaintext tokens, the PKCE verifier and any client secret never
10
- * reach the runtime container; core only routes the start and the callback.
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.
11
10
  *
12
11
  * Two implementations: `inProcessKeys` (embedding, the ephemeral Runtime, tests, and the gates
13
12
  * service itself, which serves the HTTP routes with it), and `httpKeys` (`client.ts`), the
14
13
  * runtime container's client of the `keys` service in the gateway.
15
14
  */
16
15
  import { SignJWT } from "jose";
16
+ import { previewMcpServer } from "../mcp/preview.js";
17
17
  import { signingKeyView } from "../tenant/signing-keys.js";
18
18
  /** The operations, by the name the HTTP route carries. */
19
19
  export const KEYS_OPERATIONS = [
@@ -24,8 +24,7 @@ export const KEYS_OPERATIONS = [
24
24
  "sign",
25
25
  "rotateSigningKeys",
26
26
  "ensureSigningKeys",
27
- "startOAuth",
28
- "finishOAuth",
27
+ "previewMcp",
29
28
  ];
30
29
  export function inProcessKeys(options) {
31
30
  const { store, vault, signingKeys, kek } = options;
@@ -34,8 +33,6 @@ export function inProcessKeys(options) {
34
33
  rotateCredential: (vaultId, id, body) => vault.rotateCredential(vaultId, id, body),
35
34
  putHostModel: (body) => vault.putHostModel(body),
36
35
  selectHostModel: (body) => vault.selectHostModel(body),
37
- startOAuth: (input) => vault.startOAuth(input),
38
- finishOAuth: (input) => vault.finishOAuth(input),
39
36
  async sign(request) {
40
37
  const key = kek();
41
38
  const row = await store.tx((t) => signingKeys.ensure(t, key));
@@ -54,5 +51,6 @@ export function inProcessKeys(options) {
54
51
  const key = kek();
55
52
  await store.tx((t) => signingKeys.ensure(t, key));
56
53
  },
54
+ previewMcp: (body) => previewMcpServer(body, { vault, policy: options.policy ?? {} }),
57
55
  };
58
56
  }