@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.
- package/CHANGELOG.md +90 -0
- package/README.md +22 -13
- package/dist/adapters/streams/s2.js +5 -11
- package/dist/api/components.d.ts +326 -205
- package/dist/api/components.js +3 -3
- package/dist/api/http/app.js +2 -0
- package/dist/api/http/define.d.ts +3 -2
- package/dist/api/http/define.js +10 -11
- package/dist/api/http/routes/mcp.d.ts +9 -0
- package/dist/api/http/routes/mcp.js +32 -0
- package/dist/api/http/routes/vaults.d.ts +1 -9
- package/dist/api/http/routes/vaults.js +3 -103
- package/dist/api/openapi.js +37 -6
- package/dist/artifacts/media-types.d.ts +2 -0
- package/dist/artifacts/media-types.js +5 -0
- package/dist/execution/types.d.ts +1 -1
- package/dist/gates/http-tool.d.ts +7 -0
- package/dist/gates/http-tool.js +34 -3
- package/dist/gates/mcp-handler.d.ts +4 -1
- package/dist/gates/mcp-handler.js +64 -8
- package/dist/gates/tenant-vaults.d.ts +9 -15
- package/dist/gates/tenant-vaults.js +9 -17
- package/dist/gates/tool-client.js +36 -17
- package/dist/gates/tool-contract.d.ts +19 -3
- package/dist/gates/tool-contract.js +9 -3
- package/dist/gates/tool-gate.d.ts +2 -2
- package/dist/harness/calls.d.ts +2 -0
- package/dist/harness/calls.js +13 -3
- package/dist/harness-api/record.d.ts +7 -6
- package/dist/harness-api/record.js +99 -17
- package/dist/harness-api/server.js +35 -27
- package/dist/harness-api/start.js +2 -1
- package/dist/host/app.d.ts +3 -0
- package/dist/host/app.js +33 -4
- package/dist/host/config-for.d.ts +0 -2
- package/dist/host/config-for.js +0 -1
- package/dist/host/create-host.d.ts +6 -0
- package/dist/host/create-host.js +1 -0
- package/dist/host/gates.js +0 -1
- package/dist/host/main.js +24 -7
- package/dist/host/stack-config.d.ts +5 -8
- package/dist/host/stack-config.js +9 -20
- package/dist/index.d.ts +0 -1
- package/dist/infra/index.d.ts +2 -1
- package/dist/infra/index.js +0 -1
- package/dist/infra/readiness.d.ts +6 -6
- package/dist/infra/readiness.js +2 -5
- package/dist/keys/client.js +1 -9
- package/dist/keys/keys.d.ts +11 -13
- package/dist/keys/keys.js +5 -7
- package/dist/management-openapi.json +671 -378
- package/dist/mcp/connect.d.ts +159 -13
- package/dist/mcp/connect.js +538 -55
- package/dist/mcp/pool.d.ts +11 -2
- package/dist/mcp/pool.js +74 -27
- package/dist/mcp/preview.d.ts +35 -0
- package/dist/mcp/preview.js +215 -0
- package/dist/mcp/snapshot.d.ts +79 -5
- package/dist/mcp/snapshot.js +145 -27
- package/dist/model/catalog.d.ts +14 -0
- package/dist/model/catalog.js +14 -1
- package/dist/model/pi-model.js +36 -2
- package/dist/openapi.json +644 -266
- package/dist/redact.d.ts +19 -1
- package/dist/redact.js +42 -13
- package/dist/sandbox/session-sandbox.d.ts +7 -0
- package/dist/sandbox/session-sandbox.js +89 -28
- package/dist/store/postgres/connect.d.ts +10 -0
- package/dist/store/postgres/connect.js +30 -3
- package/dist/store/postgres/control.d.ts +14 -0
- package/dist/store/postgres/control.js +187 -0
- package/dist/store/postgres/drizzle/0015_control_signals.sql +11 -0
- package/dist/store/postgres/drizzle/0016_mcp_oauth_removed.sql +5 -0
- package/dist/store/postgres/drizzle/meta/_journal.json +14 -0
- package/dist/store/postgres/schema.d.ts +122 -261
- package/dist/store/postgres/schema.js +22 -36
- package/dist/store/postgres/store.js +16 -18
- package/dist/store/postgres/tenant.d.ts +14 -0
- package/dist/store/postgres/tenant.js +22 -2
- package/dist/store/types.d.ts +42 -8
- package/dist/streams/types.d.ts +6 -29
- package/dist/streams/types.js +5 -4
- package/dist/tenant/artifact-tool.d.ts +9 -1
- package/dist/tenant/artifact-tool.js +113 -9
- package/dist/tenant/auth.d.ts +16 -6
- package/dist/tenant/auth.js +41 -17
- package/dist/tenant/commands.js +10 -6
- package/dist/tenant/context.d.ts +9 -6
- package/dist/tenant/control.d.ts +26 -0
- package/dist/tenant/control.js +35 -0
- package/dist/tenant/effects.d.ts +2 -2
- package/dist/tenant/effects.js +20 -5
- package/dist/tenant/ephemeral.d.ts +0 -6
- package/dist/tenant/ephemeral.js +1 -1
- package/dist/tenant/http.d.ts +4 -2
- package/dist/tenant/http.js +4 -2
- package/dist/tenant/identity-file.d.ts +16 -12
- package/dist/tenant/identity-file.js +41 -29
- package/dist/tenant/issuers.d.ts +4 -3
- package/dist/tenant/issuers.js +22 -16
- package/dist/tenant/outbound.d.ts +14 -5
- package/dist/tenant/outbound.js +21 -9
- package/dist/tenant/reset.d.ts +2 -2
- package/dist/tenant/reset.js +8 -2
- package/dist/tenant/resource-server.d.ts +56 -0
- package/dist/tenant/resource-server.js +62 -0
- package/dist/tenant/runtime.d.ts +1 -1
- package/dist/tenant/runtime.js +16 -15
- package/dist/tenant/scheduler.d.ts +1 -1
- package/dist/tenant/scheduler.js +1 -1
- package/dist/tenant/sessions.js +20 -3
- package/dist/tenant/store-pg.js +9 -0
- package/dist/tenant/streams.d.ts +16 -22
- package/dist/tenant/streams.js +7 -87
- package/dist/tenant/sweep.js +9 -1
- package/dist/tenant/tool-results.d.ts +57 -0
- package/dist/tenant/tool-results.js +298 -0
- package/dist/tenant/tool-search.d.ts +43 -0
- package/dist/tenant/tool-search.js +100 -0
- package/dist/tenant/transcript.d.ts +108 -0
- package/dist/tenant/transcript.js +13 -0
- package/dist/tenant/types.d.ts +0 -14
- package/dist/vault/crypto.d.ts +0 -7
- package/dist/vault/crypto.js +0 -16
- package/dist/vault/headers.d.ts +17 -0
- package/dist/vault/headers.js +61 -0
- package/dist/vault/service.d.ts +11 -68
- package/dist/vault/service.js +83 -438
- package/dist/vault/sources.d.ts +20 -48
- package/dist/vault/sources.js +25 -189
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
- package/dist/streams/control.d.ts +0 -13
- package/dist/streams/control.js +0 -25
- package/dist/vault/oauth.d.ts +0 -55
- package/dist/vault/oauth.js +0 -186
package/dist/mcp/connect.d.ts
CHANGED
|
@@ -2,7 +2,9 @@ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
|
2
2
|
import type { McpServerManifest } from "@nylorun/core/define";
|
|
3
3
|
import { type OutboundPolicy } from "../tenant/outbound.js";
|
|
4
4
|
import type { AuthorizeResult } from "../vault/service.js";
|
|
5
|
-
import { type McpDiagnostic, type McpToolRecord } from "./snapshot.js";
|
|
5
|
+
import { type McpDiagnostic, type McpRenamedTool, type McpToolRecord } from "./snapshot.js";
|
|
6
|
+
/** How much of a failed answer's body the model sees. */
|
|
7
|
+
export declare const MCP_ERROR_BODY_CHARS = 2000;
|
|
6
8
|
/** Options of one MCP request. */
|
|
7
9
|
export interface McpRequestOptions {
|
|
8
10
|
readonly signal?: AbortSignal;
|
|
@@ -22,9 +24,19 @@ export interface McpToolPage {
|
|
|
22
24
|
readonly description?: string;
|
|
23
25
|
readonly inputSchema?: unknown;
|
|
24
26
|
readonly outputSchema?: unknown;
|
|
27
|
+
readonly annotations?: Readonly<Record<string, unknown>>;
|
|
25
28
|
}[];
|
|
26
29
|
readonly nextCursor?: string;
|
|
27
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* A `tools/call` answer: the raw `CallToolResult`, with each credential value sent for the call
|
|
33
|
+
* that it echoes replaced by `[redacted]` (R2b C8).
|
|
34
|
+
*/
|
|
35
|
+
export interface McpCallAnswer {
|
|
36
|
+
readonly result: Record<string, unknown>;
|
|
37
|
+
/** How many values were replaced; absent when none. */
|
|
38
|
+
readonly redacted?: number;
|
|
39
|
+
}
|
|
28
40
|
/**
|
|
29
41
|
* What the pool needs of an MCP client: the SDK `Client` over a transport of this process
|
|
30
42
|
* (`sdkClient`), or a client of the gates service that holds the real connection
|
|
@@ -34,18 +46,127 @@ export interface McpClient {
|
|
|
34
46
|
listTools(params?: {
|
|
35
47
|
cursor?: string;
|
|
36
48
|
}, options?: McpRequestOptions): Promise<McpToolPage>;
|
|
37
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* One `tools/call`; `callMcpTool` reads its answer. A call that failed at the transport or
|
|
51
|
+
* the server rejects with `McpCallFailed`; any other rejection leaves its fate unknown.
|
|
52
|
+
*/
|
|
38
53
|
callTool(params: {
|
|
39
54
|
name: string;
|
|
40
55
|
arguments: Record<string, unknown>;
|
|
41
|
-
}, options?: McpCallOptions): Promise<
|
|
56
|
+
}, options?: McpCallOptions): Promise<McpCallAnswer>;
|
|
42
57
|
}
|
|
43
58
|
export interface LiveConnection {
|
|
44
59
|
readonly client: McpClient;
|
|
60
|
+
/** The server's instructions from `initialize`, cut (`serverInstructions`); absent when none. */
|
|
61
|
+
readonly instructions?: string;
|
|
62
|
+
/**
|
|
63
|
+
* The server's `serverInfo` from `initialize` (name, version, title), without a credential
|
|
64
|
+
* value sent; absent from a connection the gates service holds.
|
|
65
|
+
*/
|
|
66
|
+
readonly serverInfo?: Readonly<Record<string, unknown>>;
|
|
45
67
|
close(): Promise<void>;
|
|
46
68
|
}
|
|
47
|
-
/**
|
|
48
|
-
export
|
|
69
|
+
/** What a failed tool call says to the model (`callMcpTool`). */
|
|
70
|
+
export type McpToolFailure = {
|
|
71
|
+
readonly kind: "failed";
|
|
72
|
+
readonly code: string;
|
|
73
|
+
readonly message: string;
|
|
74
|
+
/** True when calling again may work (R2b C7). */
|
|
75
|
+
readonly retryable?: boolean;
|
|
76
|
+
/** With `credential_rejected`: the server, and the scope of the vault whose credential was sent. */
|
|
77
|
+
readonly server?: string;
|
|
78
|
+
readonly vault?: "installation" | "user";
|
|
79
|
+
/** How many credential values the message had in it, replaced (R2b C8). */
|
|
80
|
+
readonly redacted?: number;
|
|
81
|
+
};
|
|
82
|
+
/** What a tool call came to (`callMcpTool`). */
|
|
83
|
+
export type McpToolOutcome = {
|
|
84
|
+
readonly kind: "completed";
|
|
85
|
+
readonly output: unknown;
|
|
86
|
+
readonly redacted?: number;
|
|
87
|
+
} | McpToolFailure;
|
|
88
|
+
/**
|
|
89
|
+
* How a tool call failed at the transport or the server (R2b C7), as the gate answers it:
|
|
90
|
+
* - `mcp.unreachable`: never sent (address policy, DNS, refused connection, TLS, a connection
|
|
91
|
+
* that could not be opened). Calling again may work.
|
|
92
|
+
* - `credential_rejected`: the server answered `401` (C1).
|
|
93
|
+
* - `mcp.forbidden`: the server answered `403`.
|
|
94
|
+
* - `mcp.error`: the server answered a JSON-RPC error; the message has its code.
|
|
95
|
+
* - `mcp.status`: the server answered another HTTP error status, without a JSON-RPC error.
|
|
96
|
+
* - `mcp.lost`: sent, and the answer was lost, so the tool may have run. The model sees it only
|
|
97
|
+
* for a tool the server marks read-only or idempotent (Q15); any other call is `uncertain`.
|
|
98
|
+
* - `mcp.too-large`: the answer passed `MCP_RESULT_MAX_BYTES` (R2b C11), as an HTTP tool's
|
|
99
|
+
* answer is `http.too-large`. The tool ran; its answer was not kept.
|
|
100
|
+
*/
|
|
101
|
+
export type McpFailureCode = "mcp.unreachable" | "credential_rejected" | "mcp.forbidden" | "mcp.error" | "mcp.status" | "mcp.lost" | "mcp.too-large";
|
|
102
|
+
/**
|
|
103
|
+
* The largest `tools/call` answer the gate holds (R2b C11): 8 MiB, an HTTP tool's cap. Core
|
|
104
|
+
* stores what does not fit a tool result as an artifact (`tenant/tool-results.ts`).
|
|
105
|
+
*/
|
|
106
|
+
export declare const MCP_RESULT_MAX_BYTES: number;
|
|
107
|
+
export interface McpCallFailure {
|
|
108
|
+
readonly code: McpFailureCode;
|
|
109
|
+
readonly message: string;
|
|
110
|
+
/** The request reached the server, so it may have acted on it. */
|
|
111
|
+
readonly sent: boolean;
|
|
112
|
+
readonly retryable: boolean;
|
|
113
|
+
/** With `credential_rejected`: the server, and the scope of the vault whose credential was sent. */
|
|
114
|
+
readonly server?: string;
|
|
115
|
+
readonly vault?: "installation" | "user";
|
|
116
|
+
/** How many credential values the message had in it, replaced (R2b C8). */
|
|
117
|
+
readonly redacted?: number;
|
|
118
|
+
}
|
|
119
|
+
/** A tool call that failed with a code the model can act on (R2b C7). */
|
|
120
|
+
export declare class McpCallFailed extends Error {
|
|
121
|
+
readonly failure: McpCallFailure;
|
|
122
|
+
constructor(failure: McpCallFailure);
|
|
123
|
+
get code(): McpFailureCode;
|
|
124
|
+
/** The failure the gate answered, as the class the loop's own call would have thrown. */
|
|
125
|
+
static from(failure: McpCallFailure): McpCallFailed;
|
|
126
|
+
/** The failed tool outcome the model sees. */
|
|
127
|
+
outcome(): McpToolFailure;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* A request the server answered `401` (R2b C1): it rejected the vault's credential, or wanted one
|
|
131
|
+
* and got none. Never retried, since nothing the gate holds changes between tries (Q4). A tool
|
|
132
|
+
* call that meets it fails with `credential_rejected` for the model to see; at discovery it is the
|
|
133
|
+
* server's `failed` diagnostic.
|
|
134
|
+
*/
|
|
135
|
+
export declare class CredentialRejected extends McpCallFailed {
|
|
136
|
+
readonly server: string;
|
|
137
|
+
/** The scope of the vault whose credential was sent; absent when none was. */
|
|
138
|
+
readonly vault?: "installation" | "user" | undefined;
|
|
139
|
+
/**
|
|
140
|
+
* The answer's `WWW-Authenticate`, which may name the server's protected-resource metadata
|
|
141
|
+
* (RFC 9728 `resource_metadata`): a tool preview reads it (R2b C12). Never shown to the model.
|
|
142
|
+
*/
|
|
143
|
+
readonly challenge?: string | undefined;
|
|
144
|
+
constructor(server: string,
|
|
145
|
+
/** The scope of the vault whose credential was sent; absent when none was. */
|
|
146
|
+
vault?: "installation" | "user" | undefined,
|
|
147
|
+
/**
|
|
148
|
+
* The answer's `WWW-Authenticate`, which may name the server's protected-resource metadata
|
|
149
|
+
* (RFC 9728 `resource_metadata`): a tool preview reads it (R2b C12). Never shown to the model.
|
|
150
|
+
*/
|
|
151
|
+
challenge?: string | undefined);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* A request its connection can no longer make, refused before it reached a tool: the server
|
|
155
|
+
* answered `404` to the connection's `Mcp-Session-Id` (the session is gone, MCP 2025-06-18
|
|
156
|
+
* "Session Management"), or the credential's `via` now sends the server's requests elsewhere.
|
|
157
|
+
* Whoever holds the connection drops it, opens it again and sends the call once more (R2b C7).
|
|
158
|
+
* When that fails too, it is `mcp.unreachable`: nothing ran.
|
|
159
|
+
*/
|
|
160
|
+
export declare class McpConnectionStale extends McpCallFailed {
|
|
161
|
+
constructor(server: string, reason: string);
|
|
162
|
+
}
|
|
163
|
+
/** A tool call that never reached its server: its connection could not be opened. */
|
|
164
|
+
export declare function unreachable(server: string, error: unknown): McpCallFailed;
|
|
165
|
+
/**
|
|
166
|
+
* An SDK `Client` as an `McpClient`. Its answers and failures carry no credential value sent
|
|
167
|
+
* with them (R2b C8), and a failed call is an `McpCallFailed` (C7).
|
|
168
|
+
*/
|
|
169
|
+
export declare function sdkClient(client: Client, serverName: string): McpClient;
|
|
49
170
|
export declare function openMcpServer(input: {
|
|
50
171
|
server: McpServerManifest;
|
|
51
172
|
authorize: (url: string) => Promise<AuthorizeResult>;
|
|
@@ -55,22 +176,47 @@ export declare function openMcpServer(input: {
|
|
|
55
176
|
* Host that refuses private addresses refuses them here too. Default: no limits.
|
|
56
177
|
*/
|
|
57
178
|
policy?: OutboundPolicy;
|
|
179
|
+
/** Ends `initialize` (a tool preview's timeout, R2b C12). */
|
|
180
|
+
signal?: AbortSignal;
|
|
58
181
|
}): Promise<LiveConnection>;
|
|
182
|
+
/**
|
|
183
|
+
* What a server's `initialize` said to do with its tools, for the note on its deferred tools
|
|
184
|
+
* (R2b C10): cut to `SERVER_INSTRUCTIONS_MAX_CHARS`, without a credential value sent (C8).
|
|
185
|
+
*/
|
|
186
|
+
export declare function serverInstructions(text: unknown, secrets: readonly string[]): string | undefined;
|
|
187
|
+
/**
|
|
188
|
+
* Lists a server's tools under the names the model knows them by (R2b C6): `server__tool` where
|
|
189
|
+
* that is a name every provider accepts, else `normalizeToolName`'s, listed in `renamed`. A name
|
|
190
|
+
* taken by a declared tool or an earlier server's tool omits the tool; a renamed tool that
|
|
191
|
+
* collides gets the hash suffix first.
|
|
192
|
+
*/
|
|
59
193
|
export declare function listMcpTools(client: McpClient, input: {
|
|
60
194
|
capabilityId: string;
|
|
61
195
|
serverName: string;
|
|
62
196
|
taken: Set<string>;
|
|
63
197
|
signal?: AbortSignal;
|
|
198
|
+
/**
|
|
199
|
+
* The server's declaration: a tool its `tools` settings disable is left out before it takes
|
|
200
|
+
* a name (R2b C9), and a key that names no listed tool is in `unknownTools`.
|
|
201
|
+
*/
|
|
202
|
+
server?: McpServerManifest;
|
|
64
203
|
}): Promise<{
|
|
65
204
|
tools: McpToolRecord[];
|
|
66
205
|
omitted: string[];
|
|
206
|
+
renamed: McpRenamedTool[];
|
|
207
|
+
disabled: number;
|
|
208
|
+
unknownTools: string[];
|
|
67
209
|
}>;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
210
|
+
/**
|
|
211
|
+
* One tool call and what it came to. Rejects with `McpConnectionStale` when the connection must
|
|
212
|
+
* be opened again (the caller retries once), and with any error that leaves the call's fate
|
|
213
|
+
* unknown.
|
|
214
|
+
*/
|
|
215
|
+
export declare function callMcpTool(client: McpClient, serverToolName: string, args: unknown, options?: McpCallOptions & {
|
|
216
|
+
/**
|
|
217
|
+
* The tool is read-only or idempotent (`McpToolRecord.annotations`): a call whose answer was
|
|
218
|
+
* lost after it was sent is `mcp.lost` to the model. Otherwise it is left uncertain (Q15).
|
|
219
|
+
*/
|
|
220
|
+
readonly retrySafe?: boolean;
|
|
221
|
+
}): Promise<McpToolOutcome>;
|
|
76
222
|
export declare function diagnosticFromError(capabilityId: string, serverName: string, error: unknown): McpDiagnostic;
|