@nylorun/runtime 0.14.0-beta → 0.15.1-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 +115 -0
- package/README.md +82 -40
- package/dist/adapters/execution/restate.js +2 -2
- package/dist/adapters/replication/pgoutput.d.ts +5 -0
- package/dist/adapters/replication/pgoutput.js +4 -3
- package/dist/admin-openapi.json +185 -686
- package/dist/api/components.d.ts +308 -68
- package/dist/api/components.js +4 -5
- package/dist/api/gate/keys.d.ts +14 -0
- package/dist/api/gate/keys.js +59 -0
- package/dist/api/gate/routes.d.ts +34 -0
- package/dist/api/gate/routes.js +235 -0
- package/dist/api/http/define.js +0 -8
- package/dist/api/http/routes/access.js +25 -18
- package/dist/api/http/routes/tenant.d.ts +2 -1
- package/dist/api/http/routes/tenant.js +77 -5
- package/dist/api/http/routes/vaults.js +2 -2
- package/dist/api/openapi.js +6 -7
- package/dist/gates/contract.d.ts +51 -0
- package/dist/gates/contract.js +37 -0
- package/dist/gates/handler.d.ts +21 -0
- package/dist/gates/handler.js +55 -0
- package/dist/gates/http-client.d.ts +12 -0
- package/dist/gates/http-client.js +160 -0
- package/dist/gates/in-process.d.ts +32 -0
- package/dist/gates/in-process.js +42 -0
- package/dist/gates/inflight.d.ts +39 -0
- package/dist/gates/inflight.js +70 -0
- package/dist/gates/mcp-handler.d.ts +35 -0
- package/dist/gates/mcp-handler.js +142 -0
- package/dist/gates/meter.d.ts +24 -0
- package/dist/gates/meter.js +165 -0
- package/dist/gates/model-gate.d.ts +45 -0
- package/dist/gates/model-gate.js +1 -0
- package/dist/gates/tenant-vaults.d.ts +64 -0
- package/dist/gates/tenant-vaults.js +94 -0
- package/dist/gates/tool-calls.d.ts +51 -0
- package/dist/gates/tool-calls.js +64 -0
- package/dist/gates/tool-client.d.ts +12 -0
- package/dist/gates/tool-client.js +201 -0
- package/dist/gates/tool-contract.d.ts +116 -0
- package/dist/gates/tool-contract.js +64 -0
- package/dist/gates/tool-gate.d.ts +45 -0
- package/dist/gates/tool-gate.js +10 -0
- package/dist/host/admin-api.d.ts +7 -6
- package/dist/host/admin-api.js +9 -113
- package/dist/host/app.d.ts +1 -1
- package/dist/host/app.js +20 -24
- package/dist/host/config-for.d.ts +1 -1
- package/dist/host/config-for.js +2 -2
- package/dist/host/create-host.d.ts +5 -5
- package/dist/host/create-host.js +5 -15
- package/dist/host/execution.d.ts +20 -18
- package/dist/host/execution.js +2 -2
- package/dist/host/gates.d.ts +58 -0
- package/dist/host/gates.js +127 -0
- package/dist/host/http.d.ts +6 -1
- package/dist/host/http.js +17 -0
- package/dist/host/index.d.ts +1 -1
- package/dist/host/main.js +151 -71
- package/dist/host/stack-config.d.ts +71 -19
- package/dist/host/stack-config.js +192 -18
- package/dist/infra/database.d.ts +2 -2
- package/dist/infra/execution.d.ts +5 -5
- package/dist/infra/execution.js +8 -6
- package/dist/infra/index.d.ts +1 -1
- package/dist/infra/workers.d.ts +17 -17
- package/dist/infra/workers.js +9 -9
- package/dist/keys/client.d.ts +9 -0
- package/dist/keys/client.js +70 -0
- package/dist/keys/contract.d.ts +24 -0
- package/dist/keys/contract.js +12 -0
- package/dist/keys/keys.d.ts +41 -0
- package/dist/keys/keys.js +50 -0
- package/dist/mcp/connect.d.ts +43 -3
- package/dist/mcp/connect.js +12 -5
- package/dist/mcp/pool.d.ts +21 -3
- package/dist/mcp/pool.js +15 -2
- package/dist/openapi.json +888 -695
- package/dist/record/append.d.ts +51 -0
- package/dist/record/append.js +20 -0
- package/dist/{store/event.js → record/envelope.js} +1 -1
- package/dist/record/index.d.ts +11 -0
- package/dist/record/index.js +11 -0
- package/dist/store/postgres/connect.d.ts +15 -12
- package/dist/store/postgres/connect.js +24 -12
- package/dist/store/postgres/db.d.ts +16 -0
- package/dist/store/postgres/db.js +28 -0
- package/dist/store/postgres/drizzle/0000_foundation.sql +22 -0
- package/dist/store/postgres/drizzle/0001_baseline.sql +255 -0
- package/dist/store/postgres/drizzle/0002_stream_relay.sql +4 -0
- package/dist/store/postgres/drizzle/0003_tool_crossings.sql +9 -0
- package/dist/store/postgres/drizzle/meta/_journal.json +34 -0
- package/dist/store/postgres/migrate.d.ts +68 -0
- package/dist/store/postgres/migrate.js +183 -0
- package/dist/store/postgres/record-writer.d.ts +4 -0
- package/dist/store/postgres/record-writer.js +34 -0
- package/dist/store/postgres/record.d.ts +2 -8
- package/dist/store/postgres/record.js +50 -54
- package/dist/store/postgres/schema.d.ts +3096 -0
- package/dist/store/postgres/schema.js +363 -0
- package/dist/store/postgres/store.d.ts +2 -4
- package/dist/store/postgres/store.js +481 -567
- package/dist/store/postgres/tenant.d.ts +56 -0
- package/dist/store/postgres/tenant.js +154 -0
- package/dist/store/types.d.ts +43 -87
- package/dist/store/types.js +0 -1
- package/dist/streams/control.d.ts +1 -1
- package/dist/streams/control.js +6 -2
- package/dist/streams/relay/types.d.ts +2 -1
- package/dist/streams/relay/types.js +2 -1
- package/dist/streams/types.d.ts +5 -0
- package/dist/tenant/advance.d.ts +7 -2
- package/dist/tenant/advance.js +95 -16
- package/dist/tenant/cause.d.ts +25 -0
- package/dist/tenant/cause.js +45 -0
- package/dist/tenant/commands.js +4 -2
- package/dist/tenant/context.d.ts +26 -3
- package/dist/tenant/delivery-token.js +17 -18
- package/dist/tenant/delivery.d.ts +1 -1
- package/dist/tenant/delivery.js +18 -13
- package/dist/tenant/effects.d.ts +15 -1
- package/dist/tenant/effects.js +93 -17
- package/dist/tenant/ephemeral.d.ts +16 -7
- package/dist/tenant/ephemeral.js +45 -111
- package/dist/tenant/history.d.ts +64 -0
- package/dist/tenant/history.js +120 -0
- package/dist/tenant/model-setting.d.ts +2 -2
- package/dist/tenant/module.d.ts +14 -28
- package/dist/tenant/module.js +131 -271
- package/dist/tenant/paths.d.ts +11 -16
- package/dist/tenant/paths.js +24 -68
- package/dist/tenant/pool.d.ts +1 -1
- package/dist/tenant/pool.js +1 -1
- package/dist/tenant/principals.d.ts +23 -11
- package/dist/tenant/principals.js +61 -49
- package/dist/tenant/runtime.d.ts +19 -1
- package/dist/tenant/runtime.js +40 -26
- package/dist/tenant/scheduler.d.ts +4 -2
- package/dist/tenant/scheduler.js +4 -4
- package/dist/tenant/session-streams.d.ts +2 -0
- package/dist/tenant/session-streams.js +8 -3
- package/dist/tenant/status.d.ts +3 -0
- package/dist/tenant/status.js +1 -1
- package/dist/tenant/store-pg.d.ts +9 -6
- package/dist/tenant/store-pg.js +60 -125
- package/dist/tenant/streams.d.ts +9 -25
- package/dist/tenant/streams.js +7 -22
- package/dist/tenant/tokens.js +16 -14
- package/dist/tenant/types.d.ts +41 -92
- package/dist/tenant/types.js +4 -15
- package/dist/tenant/worker.js +4 -4
- package/dist/vault/host-model.d.ts +31 -0
- package/dist/vault/host-model.js +57 -0
- package/dist/vault/service.d.ts +26 -15
- package/dist/vault/service.js +70 -109
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +9 -5
- package/dist/store/memory.d.ts +0 -69
- package/dist/store/memory.js +0 -810
- package/dist/store/postgres/migrations/001_initial.d.ts +0 -27
- package/dist/store/postgres/migrations/001_initial.js +0 -196
- package/dist/store/postgres/migrations/002_session_owner.d.ts +0 -6
- package/dist/store/postgres/migrations/002_session_owner.js +0 -13
- package/dist/store/postgres/migrations/003_subject_tokens.d.ts +0 -8
- package/dist/store/postgres/migrations/003_subject_tokens.js +0 -42
- package/dist/store/postgres/migrations/004_publishable_keys.d.ts +0 -6
- package/dist/store/postgres/migrations/004_publishable_keys.js +0 -18
- package/dist/store/postgres/migrations/005_action_endpoints.d.ts +0 -6
- package/dist/store/postgres/migrations/005_action_endpoints.js +0 -32
- package/dist/store/postgres/migrations/006_drop_executors.d.ts +0 -11
- package/dist/store/postgres/migrations/006_drop_executors.js +0 -32
- package/dist/store/postgres/migrations/007_event_time.d.ts +0 -7
- package/dist/store/postgres/migrations/007_event_time.js +0 -14
- package/dist/store/postgres/migrations/008_durable_streams.d.ts +0 -13
- package/dist/store/postgres/migrations/008_durable_streams.js +0 -35
- package/dist/store/postgres/migrations/index.d.ts +0 -53
- package/dist/store/postgres/migrations/index.js +0 -96
- package/dist/store/postgres/migrations/shared/index.d.ts +0 -31
- package/dist/store/postgres/migrations/shared/index.js +0 -92
- package/dist/store/postgres/names.d.ts +0 -11
- package/dist/store/postgres/names.js +0 -42
- package/dist/store/postgres/tenants.d.ts +0 -90
- package/dist/store/postgres/tenants.js +0 -228
- package/dist/streams/relay/memory.d.ts +0 -69
- package/dist/streams/relay/memory.js +0 -176
- package/dist/tenant/envelope.d.ts +0 -7
- package/dist/tenant/envelope.js +0 -22
- package/dist/tenant/quarantine-error.d.ts +0 -6
- package/dist/tenant/quarantine-error.js +0 -9
- package/dist/tenant/quarantine.d.ts +0 -27
- package/dist/tenant/quarantine.js +0 -72
- package/dist/tenant/store-memory.d.ts +0 -16
- package/dist/tenant/store-memory.js +0 -111
- /package/dist/{store → record}/cursor.d.ts +0 -0
- /package/dist/{store → record}/cursor.js +0 -0
- /package/dist/{store/event.d.ts → record/envelope.d.ts} +0 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
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;
|
|
4
|
+
* rotation and selection decrypt the old secret first) and all token signing (subject and
|
|
5
|
+
* delivery tokens, signing-key rotation) run here, whole, so the process that calls them never
|
|
6
|
+
* holds the key or a private signing key.
|
|
7
|
+
*
|
|
8
|
+
* Two implementations: `inProcessKeys` (embedding, the ephemeral Runtime, tests, and the gates
|
|
9
|
+
* service itself, which serves the HTTP routes with it), and `httpKeys` (`client.ts`), the
|
|
10
|
+
* runtime container's client of the `keys` service in the gateway.
|
|
11
|
+
*/
|
|
12
|
+
import { SignJWT } from "jose";
|
|
13
|
+
import { signingKeyView } from "../tenant/signing-keys.js";
|
|
14
|
+
/** The operations, by the name the HTTP route carries. */
|
|
15
|
+
export const KEYS_OPERATIONS = [
|
|
16
|
+
"createCredential",
|
|
17
|
+
"rotateCredential",
|
|
18
|
+
"putHostModel",
|
|
19
|
+
"selectHostModel",
|
|
20
|
+
"sign",
|
|
21
|
+
"rotateSigningKeys",
|
|
22
|
+
"ensureSigningKeys",
|
|
23
|
+
];
|
|
24
|
+
export function inProcessKeys(options) {
|
|
25
|
+
const { store, vault, signingKeys, kek } = options;
|
|
26
|
+
return {
|
|
27
|
+
createCredential: (vaultId, body) => vault.createCredential(vaultId, body),
|
|
28
|
+
rotateCredential: (vaultId, id, body) => vault.rotateCredential(vaultId, id, body),
|
|
29
|
+
putHostModel: (body) => vault.putHostModel(body),
|
|
30
|
+
selectHostModel: (body) => vault.selectHostModel(body),
|
|
31
|
+
async sign(request) {
|
|
32
|
+
const key = kek();
|
|
33
|
+
const row = await store.tx((t) => signingKeys.ensure(t, key));
|
|
34
|
+
const signer = await signingKeys.privateKey(row, key);
|
|
35
|
+
const token = await new SignJWT({ ...request.claims })
|
|
36
|
+
.setProtectedHeader({ alg: "ES256", typ: request.typ, kid: signer.id })
|
|
37
|
+
.sign(signer.key);
|
|
38
|
+
return { token, keyId: signer.id };
|
|
39
|
+
},
|
|
40
|
+
async rotateSigningKeys(request) {
|
|
41
|
+
const key = kek();
|
|
42
|
+
const rows = await store.tx((t) => signingKeys.rotate(t, key, request.maxTtlSeconds, request.force));
|
|
43
|
+
return rows.map(signingKeyView);
|
|
44
|
+
},
|
|
45
|
+
async ensureSigningKeys() {
|
|
46
|
+
const key = kek();
|
|
47
|
+
await store.tx((t) => signingKeys.ensure(t, key));
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}
|
package/dist/mcp/connect.d.ts
CHANGED
|
@@ -2,10 +2,49 @@ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
|
2
2
|
import type { McpServerManifest } from "@nylorun/core/define";
|
|
3
3
|
import type { AuthorizeResult } from "../vault/service.js";
|
|
4
4
|
import { type McpDiagnostic, type McpToolRecord } from "./snapshot.js";
|
|
5
|
+
/** Options of one MCP request. */
|
|
6
|
+
export interface McpRequestOptions {
|
|
7
|
+
readonly signal?: AbortSignal;
|
|
8
|
+
}
|
|
9
|
+
/** Options of one tool call. */
|
|
10
|
+
export interface McpCallOptions extends McpRequestOptions {
|
|
11
|
+
/**
|
|
12
|
+
* The call's effect id. A gate runs a keyed call once and keeps its outcome, so a re-send
|
|
13
|
+
* after a takeover joins it (F4.1). An in-process connection ignores it.
|
|
14
|
+
*/
|
|
15
|
+
readonly key?: string;
|
|
16
|
+
}
|
|
17
|
+
/** A page of `tools/list`, as the MCP SDK returns it. */
|
|
18
|
+
export interface McpToolPage {
|
|
19
|
+
readonly tools: readonly {
|
|
20
|
+
readonly name: string;
|
|
21
|
+
readonly description?: string;
|
|
22
|
+
readonly inputSchema?: unknown;
|
|
23
|
+
readonly outputSchema?: unknown;
|
|
24
|
+
}[];
|
|
25
|
+
readonly nextCursor?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* What the pool needs of an MCP client: the SDK `Client` over a transport of this process
|
|
29
|
+
* (`sdkClient`), or a client of the gates service that holds the real connection
|
|
30
|
+
* (`gates/tool-client.ts`).
|
|
31
|
+
*/
|
|
32
|
+
export interface McpClient {
|
|
33
|
+
listTools(params?: {
|
|
34
|
+
cursor?: string;
|
|
35
|
+
}, options?: McpRequestOptions): Promise<McpToolPage>;
|
|
36
|
+
/** The raw `CallToolResult`; `callMcpTool` reads it. */
|
|
37
|
+
callTool(params: {
|
|
38
|
+
name: string;
|
|
39
|
+
arguments: Record<string, unknown>;
|
|
40
|
+
}, options?: McpCallOptions): Promise<Record<string, unknown>>;
|
|
41
|
+
}
|
|
5
42
|
export interface LiveConnection {
|
|
6
|
-
readonly client:
|
|
43
|
+
readonly client: McpClient;
|
|
7
44
|
close(): Promise<void>;
|
|
8
45
|
}
|
|
46
|
+
/** An SDK `Client` as an `McpClient`. */
|
|
47
|
+
export declare function sdkClient(client: Client): McpClient;
|
|
9
48
|
export declare function openMcpServer(input: {
|
|
10
49
|
server: McpServerManifest;
|
|
11
50
|
authorize?: (url: string) => Promise<AuthorizeResult>;
|
|
@@ -13,15 +52,16 @@ export declare function openMcpServer(input: {
|
|
|
13
52
|
pluginData: string;
|
|
14
53
|
childEnv?: Readonly<Record<string, string>>;
|
|
15
54
|
}): Promise<LiveConnection>;
|
|
16
|
-
export declare function listMcpTools(client:
|
|
55
|
+
export declare function listMcpTools(client: McpClient, input: {
|
|
17
56
|
capabilityId: string;
|
|
18
57
|
serverName: string;
|
|
19
58
|
taken: Set<string>;
|
|
59
|
+
signal?: AbortSignal;
|
|
20
60
|
}): Promise<{
|
|
21
61
|
tools: McpToolRecord[];
|
|
22
62
|
omitted: string[];
|
|
23
63
|
}>;
|
|
24
|
-
export declare function callMcpTool(client:
|
|
64
|
+
export declare function callMcpTool(client: McpClient, serverToolName: string, args: unknown, options?: McpCallOptions): Promise<{
|
|
25
65
|
kind: "completed";
|
|
26
66
|
output: unknown;
|
|
27
67
|
} | {
|
package/dist/mcp/connect.js
CHANGED
|
@@ -5,6 +5,13 @@ import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/
|
|
|
5
5
|
import { schemaFromJSON } from "@nylorun/core/define";
|
|
6
6
|
import { modelToolName, } from "./snapshot.js";
|
|
7
7
|
import { prepareStdioLaunch } from "./stdio.js";
|
|
8
|
+
/** An SDK `Client` as an `McpClient`. */
|
|
9
|
+
export function sdkClient(client) {
|
|
10
|
+
return {
|
|
11
|
+
listTools: (params, options) => client.listTools(params, options?.signal ? { signal: options.signal } : undefined),
|
|
12
|
+
callTool: (params, options) => client.callTool(params, undefined, options?.signal ? { signal: options.signal } : undefined),
|
|
13
|
+
};
|
|
14
|
+
}
|
|
8
15
|
export async function openMcpServer(input) {
|
|
9
16
|
if (input.server.type === "stdio") {
|
|
10
17
|
const launch = prepareStdioLaunch(input.server, {
|
|
@@ -23,7 +30,7 @@ export async function openMcpServer(input) {
|
|
|
23
30
|
transport.stderr?.on("data", () => { });
|
|
24
31
|
const client = createClient();
|
|
25
32
|
await client.connect(transport);
|
|
26
|
-
return { client, close: () => client.close() };
|
|
33
|
+
return { client: sdkClient(client), close: () => client.close() };
|
|
27
34
|
}
|
|
28
35
|
const authorize = input.authorize;
|
|
29
36
|
if (!authorize)
|
|
@@ -42,14 +49,14 @@ export async function openMcpServer(input) {
|
|
|
42
49
|
: new StreamableHTTPClientTransport(url, { fetch: fetchImpl });
|
|
43
50
|
const client = createClient();
|
|
44
51
|
await client.connect(transport);
|
|
45
|
-
return { client, close: () => client.close() };
|
|
52
|
+
return { client: sdkClient(client), close: () => client.close() };
|
|
46
53
|
}
|
|
47
54
|
export async function listMcpTools(client, input) {
|
|
48
55
|
const tools = [];
|
|
49
56
|
const omitted = [];
|
|
50
57
|
let cursor;
|
|
51
58
|
for (let page = 0; page < 100; page += 1) {
|
|
52
|
-
const listed = await client.listTools(cursor ? { cursor } : undefined);
|
|
59
|
+
const listed = await client.listTools(cursor ? { cursor } : undefined, input.signal ? { signal: input.signal } : undefined);
|
|
53
60
|
for (const tool of listed.tools) {
|
|
54
61
|
if (typeof tool.name !== "string" || tool.name.length === 0)
|
|
55
62
|
continue;
|
|
@@ -81,13 +88,13 @@ export async function listMcpTools(client, input) {
|
|
|
81
88
|
}
|
|
82
89
|
return { tools, omitted };
|
|
83
90
|
}
|
|
84
|
-
export async function callMcpTool(client, serverToolName, args) {
|
|
91
|
+
export async function callMcpTool(client, serverToolName, args, options = {}) {
|
|
85
92
|
const result = await client.callTool({
|
|
86
93
|
name: serverToolName,
|
|
87
94
|
arguments: args && typeof args === "object" && !Array.isArray(args)
|
|
88
95
|
? args
|
|
89
96
|
: {},
|
|
90
|
-
});
|
|
97
|
+
}, options);
|
|
91
98
|
if ("isError" in result && result.isError) {
|
|
92
99
|
return {
|
|
93
100
|
kind: "failed",
|
package/dist/mcp/pool.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AgentManifest, McpServerManifest } from "@nylorun/core/define";
|
|
2
2
|
import type { AuthorizeResult } from "../vault/service.js";
|
|
3
|
-
import { callMcpTool, openMcpServer } from "./connect.js";
|
|
3
|
+
import { callMcpTool, openMcpServer, type LiveConnection } from "./connect.js";
|
|
4
4
|
import { type McpDiagnostic, type McpSnapshot, type McpToolRecord } from "./snapshot.js";
|
|
5
5
|
/** A connection unused this long is closed by the sweep; the next call opens it again. */
|
|
6
6
|
export declare const DEFAULT_MCP_IDLE_MS: number;
|
|
@@ -25,6 +25,13 @@ export declare class McpPool {
|
|
|
25
25
|
readonly now?: () => number;
|
|
26
26
|
/** Tests replace how a declared server is opened. */
|
|
27
27
|
readonly open?: typeof openMcpServer;
|
|
28
|
+
/**
|
|
29
|
+
* Opens a remote (`streamable-http` or `sse`) server somewhere else: the gates service
|
|
30
|
+
* holds the connection and its credential, and the loop never sees either (F4.1).
|
|
31
|
+
* Absent: remote servers are opened in this process, with `authorize`. Stdio servers
|
|
32
|
+
* always run here.
|
|
33
|
+
*/
|
|
34
|
+
readonly openRemote?: (server: McpServerRef) => Promise<LiveConnection>;
|
|
28
35
|
});
|
|
29
36
|
discover(input: {
|
|
30
37
|
sessionId: string;
|
|
@@ -52,6 +59,9 @@ export declare class McpPool {
|
|
|
52
59
|
args: unknown;
|
|
53
60
|
manifest: AgentManifest;
|
|
54
61
|
pluginRoots: Readonly<Record<string, string>>;
|
|
62
|
+
/** The effect id: a gate runs the call once under it (F4.1). */
|
|
63
|
+
effectId?: string;
|
|
64
|
+
signal?: AbortSignal;
|
|
55
65
|
}): Promise<Awaited<ReturnType<typeof callMcpTool>>>;
|
|
56
66
|
/**
|
|
57
67
|
* Closes connections unused for the idle timeout (the Tenant sweep). A session that calls
|
|
@@ -64,7 +74,15 @@ export declare class McpPool {
|
|
|
64
74
|
private liveKey;
|
|
65
75
|
private connectDeclared;
|
|
66
76
|
}
|
|
67
|
-
|
|
77
|
+
/** One declared MCP server of a session: what a gate needs to find it in the pinned manifest. */
|
|
78
|
+
export interface McpServerRef {
|
|
79
|
+
readonly sessionId: string;
|
|
80
|
+
/** The agent used as a tool that declares the server; absent for the session's root agent. */
|
|
81
|
+
readonly agentId?: string;
|
|
82
|
+
readonly capabilityId: string;
|
|
83
|
+
readonly serverName: string;
|
|
84
|
+
}
|
|
85
|
+
export interface DeclaredServer {
|
|
68
86
|
/** Absent for the session's root agent. */
|
|
69
87
|
readonly agentId?: string;
|
|
70
88
|
/** The manifest of the agent that declares the server. */
|
|
@@ -74,4 +92,4 @@ interface DeclaredServer {
|
|
|
74
92
|
}
|
|
75
93
|
/** Servers of the root agent, then of each agent it uses as a tool. */
|
|
76
94
|
export declare function serversOf(manifest: AgentManifest): DeclaredServer[];
|
|
77
|
-
export
|
|
95
|
+
export declare function findServer(manifest: AgentManifest, agentId: string | undefined, capabilityId: string, serverName: string): DeclaredServer | undefined;
|
package/dist/mcp/pool.js
CHANGED
|
@@ -37,6 +37,7 @@ export class McpPool {
|
|
|
37
37
|
capabilityId: declared.capabilityId,
|
|
38
38
|
serverName: declared.server.name,
|
|
39
39
|
taken: taken.get(declared.agentId),
|
|
40
|
+
...(input.signal ? { signal: input.signal } : {}),
|
|
40
41
|
});
|
|
41
42
|
tools.push(...listed.tools.map((tool) => owned(declared, tool)));
|
|
42
43
|
diagnostics.push({
|
|
@@ -118,7 +119,10 @@ export class McpPool {
|
|
|
118
119
|
}
|
|
119
120
|
live.active += 1;
|
|
120
121
|
try {
|
|
121
|
-
return await callMcpTool(live.connection.client, input.serverToolName, input.args
|
|
122
|
+
return await callMcpTool(live.connection.client, input.serverToolName, input.args, {
|
|
123
|
+
...(input.effectId === undefined ? {} : { key: input.effectId }),
|
|
124
|
+
...(input.signal ? { signal: input.signal } : {}),
|
|
125
|
+
});
|
|
122
126
|
}
|
|
123
127
|
finally {
|
|
124
128
|
live.active -= 1;
|
|
@@ -169,6 +173,15 @@ export class McpPool {
|
|
|
169
173
|
}
|
|
170
174
|
async connectDeclared(input, declared) {
|
|
171
175
|
try {
|
|
176
|
+
if (declared.server.type !== "stdio" && this.options.openRemote) {
|
|
177
|
+
const connection = await this.options.openRemote({
|
|
178
|
+
sessionId: input.sessionId,
|
|
179
|
+
...ownerOf(declared),
|
|
180
|
+
capabilityId: declared.capabilityId,
|
|
181
|
+
serverName: declared.server.name,
|
|
182
|
+
});
|
|
183
|
+
return { ok: true, connection };
|
|
184
|
+
}
|
|
172
185
|
const connection = await this.open({
|
|
173
186
|
server: declared.server,
|
|
174
187
|
pluginRoot: input.pluginRoots[pluginKey(declared)],
|
|
@@ -209,7 +222,7 @@ export function serversOf(manifest) {
|
|
|
209
222
|
add(child.manifest, child.manifest.id);
|
|
210
223
|
return servers;
|
|
211
224
|
}
|
|
212
|
-
function findServer(manifest, agentId, capabilityId, serverName) {
|
|
225
|
+
export function findServer(manifest, agentId, capabilityId, serverName) {
|
|
213
226
|
return serversOf(manifest).find((item) => item.agentId === agentId &&
|
|
214
227
|
item.capabilityId === capabilityId &&
|
|
215
228
|
item.server.name === serverName);
|