@nylorun/runtime 0.20.0-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 (95) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/README.md +15 -10
  3. package/dist/api/components.d.ts +155 -36
  4. package/dist/api/components.js +3 -3
  5. package/dist/api/http/app.js +2 -0
  6. package/dist/api/http/routes/mcp.d.ts +9 -0
  7. package/dist/api/http/routes/mcp.js +32 -0
  8. package/dist/api/http/routes/vaults.d.ts +1 -9
  9. package/dist/api/http/routes/vaults.js +3 -103
  10. package/dist/api/openapi.js +6 -3
  11. package/dist/artifacts/media-types.d.ts +2 -0
  12. package/dist/artifacts/media-types.js +5 -0
  13. package/dist/gates/http-tool.d.ts +7 -0
  14. package/dist/gates/http-tool.js +34 -3
  15. package/dist/gates/mcp-handler.d.ts +4 -1
  16. package/dist/gates/mcp-handler.js +64 -8
  17. package/dist/gates/tenant-vaults.d.ts +9 -15
  18. package/dist/gates/tenant-vaults.js +9 -17
  19. package/dist/gates/tool-client.js +36 -17
  20. package/dist/gates/tool-contract.d.ts +19 -3
  21. package/dist/gates/tool-contract.js +9 -3
  22. package/dist/gates/tool-gate.d.ts +2 -2
  23. package/dist/harness/calls.d.ts +2 -0
  24. package/dist/harness/calls.js +13 -3
  25. package/dist/harness-api/record.d.ts +7 -6
  26. package/dist/harness-api/record.js +99 -17
  27. package/dist/harness-api/server.js +35 -27
  28. package/dist/harness-api/start.js +2 -1
  29. package/dist/host/config-for.d.ts +0 -2
  30. package/dist/host/config-for.js +0 -1
  31. package/dist/host/gates.js +0 -1
  32. package/dist/host/main.js +13 -3
  33. package/dist/host/stack-config.d.ts +5 -8
  34. package/dist/host/stack-config.js +8 -19
  35. package/dist/index.d.ts +0 -1
  36. package/dist/keys/client.js +1 -9
  37. package/dist/keys/keys.d.ts +11 -13
  38. package/dist/keys/keys.js +5 -7
  39. package/dist/management-openapi.json +315 -345
  40. package/dist/mcp/connect.d.ts +159 -13
  41. package/dist/mcp/connect.js +538 -55
  42. package/dist/mcp/pool.d.ts +11 -2
  43. package/dist/mcp/pool.js +74 -27
  44. package/dist/mcp/preview.d.ts +35 -0
  45. package/dist/mcp/preview.js +215 -0
  46. package/dist/mcp/snapshot.d.ts +79 -5
  47. package/dist/mcp/snapshot.js +145 -27
  48. package/dist/model/catalog.d.ts +14 -0
  49. package/dist/model/catalog.js +14 -1
  50. package/dist/model/pi-model.js +36 -2
  51. package/dist/openapi.json +362 -123
  52. package/dist/redact.d.ts +19 -1
  53. package/dist/redact.js +42 -13
  54. package/dist/sandbox/session-sandbox.d.ts +7 -0
  55. package/dist/sandbox/session-sandbox.js +89 -28
  56. package/dist/store/postgres/drizzle/0016_mcp_oauth_removed.sql +5 -0
  57. package/dist/store/postgres/drizzle/meta/_journal.json +7 -0
  58. package/dist/store/postgres/schema.d.ts +2 -261
  59. package/dist/store/postgres/schema.js +2 -36
  60. package/dist/store/postgres/store.js +1 -18
  61. package/dist/store/postgres/tenant.d.ts +14 -0
  62. package/dist/store/postgres/tenant.js +22 -2
  63. package/dist/store/types.d.ts +2 -8
  64. package/dist/tenant/artifact-tool.d.ts +9 -1
  65. package/dist/tenant/artifact-tool.js +113 -9
  66. package/dist/tenant/context.d.ts +5 -6
  67. package/dist/tenant/effects.d.ts +2 -2
  68. package/dist/tenant/effects.js +20 -5
  69. package/dist/tenant/ephemeral.d.ts +0 -6
  70. package/dist/tenant/ephemeral.js +0 -1
  71. package/dist/tenant/outbound.d.ts +14 -5
  72. package/dist/tenant/outbound.js +21 -9
  73. package/dist/tenant/runtime.js +9 -14
  74. package/dist/tenant/sessions.js +20 -3
  75. package/dist/tenant/store-pg.js +9 -0
  76. package/dist/tenant/tool-results.d.ts +57 -0
  77. package/dist/tenant/tool-results.js +298 -0
  78. package/dist/tenant/tool-search.d.ts +43 -0
  79. package/dist/tenant/tool-search.js +100 -0
  80. package/dist/tenant/transcript.d.ts +108 -0
  81. package/dist/tenant/transcript.js +13 -0
  82. package/dist/tenant/types.d.ts +0 -14
  83. package/dist/vault/crypto.d.ts +0 -7
  84. package/dist/vault/crypto.js +0 -16
  85. package/dist/vault/headers.d.ts +17 -0
  86. package/dist/vault/headers.js +61 -0
  87. package/dist/vault/service.d.ts +11 -68
  88. package/dist/vault/service.js +83 -438
  89. package/dist/vault/sources.d.ts +20 -48
  90. package/dist/vault/sources.js +25 -189
  91. package/dist/version.d.ts +1 -1
  92. package/dist/version.js +1 -1
  93. package/package.json +3 -3
  94. package/dist/vault/oauth.d.ts +0 -55
  95. package/dist/vault/oauth.js +0 -186
@@ -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
  }