managed-deepagents 0.6.2-dev.5 → 0.6.2-dev.51
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/README.md +25 -9
- package/dist/agent-auth.d.ts +129 -0
- package/dist/agent-auth.d.ts.map +1 -0
- package/dist/agent-auth.js +393 -0
- package/dist/agent-auth.js.map +1 -0
- package/dist/channels/manifest.d.ts +4 -0
- package/dist/channels/manifest.d.ts.map +1 -1
- package/dist/channels/schedule-delivery.d.ts +2 -0
- package/dist/channels/schedule-delivery.d.ts.map +1 -1
- package/dist/channels/schedule-delivery.js +40 -4
- package/dist/channels/schedule-delivery.js.map +1 -1
- package/dist/channels/trigger/client.d.ts +1 -0
- package/dist/channels/trigger/client.d.ts.map +1 -1
- package/dist/channels/trigger/client.js +19 -8
- package/dist/channels/trigger/client.js.map +1 -1
- package/dist/channels/trigger/http.js +1 -1
- package/dist/channels/trigger/http.js.map +1 -1
- package/dist/channels/trigger/types.d.ts +1 -1
- package/dist/channels/trigger/types.d.ts.map +1 -1
- package/dist/connections.d.ts +74 -0
- package/dist/connections.d.ts.map +1 -0
- package/dist/connections.js +280 -0
- package/dist/connections.js.map +1 -0
- package/dist/connectors/mcp/index.d.ts +36 -95
- package/dist/connectors/mcp/index.d.ts.map +1 -1
- package/dist/connectors/mcp/index.js +266 -57
- package/dist/connectors/mcp/index.js.map +1 -1
- package/dist/connectors/mcp/schema.d.ts +17 -0
- package/dist/connectors/mcp/schema.d.ts.map +1 -0
- package/dist/connectors/mcp/schema.js +122 -0
- package/dist/connectors/mcp/schema.js.map +1 -0
- package/dist/connectors/mcp/types.d.ts +81 -0
- package/dist/connectors/mcp/types.d.ts.map +1 -0
- package/dist/connectors/mcp/types.js +2 -0
- package/dist/connectors/mcp/types.js.map +1 -0
- package/dist/connectors/tool-selection.d.ts +10 -19
- package/dist/connectors/tool-selection.d.ts.map +1 -1
- package/dist/connectors/tool-selection.js +33 -59
- package/dist/connectors/tool-selection.js.map +1 -1
- package/dist/credential-gate.d.ts +40 -0
- package/dist/credential-gate.d.ts.map +1 -0
- package/dist/credential-gate.js +227 -0
- package/dist/credential-gate.js.map +1 -0
- package/dist/extension.d.ts +3 -3
- package/dist/extension.js +2 -2
- package/dist/identity/index.d.ts +1 -1
- package/dist/identity/index.d.ts.map +1 -1
- package/dist/identity/index.js.map +1 -1
- package/dist/identity/types.d.ts +79 -5
- package/dist/identity/types.d.ts.map +1 -1
- package/dist/index.d.ts +9 -34
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -6
- package/dist/index.js.map +1 -1
- package/dist/namespaces.d.ts +12 -29
- package/dist/namespaces.d.ts.map +1 -1
- package/dist/namespaces.js +26 -9
- package/dist/namespaces.js.map +1 -1
- package/dist/runtime/auth.d.ts +31 -4
- package/dist/runtime/auth.d.ts.map +1 -1
- package/dist/runtime/auth.js +58 -3
- package/dist/runtime/auth.js.map +1 -1
- package/dist/runtime/http.d.ts +1 -1
- package/dist/runtime/http.d.ts.map +1 -1
- package/dist/runtime/http.js.map +1 -1
- package/dist/runtime/identity-runtime.d.ts +65 -5
- package/dist/runtime/identity-runtime.d.ts.map +1 -1
- package/dist/runtime/identity-runtime.js +148 -0
- package/dist/runtime/identity-runtime.js.map +1 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +13 -8
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/managed-middleware.d.ts +2 -2
- package/dist/runtime/managed-middleware.js +6 -6
- package/dist/runtime/managed-tools.d.ts +19 -15
- package/dist/runtime/managed-tools.d.ts.map +1 -1
- package/dist/runtime/managed-tools.js +14 -13
- package/dist/runtime/managed-tools.js.map +1 -1
- package/dist/runtime/types.d.ts +2 -2
- package/package.json +8 -8
- package/dist/connectors/mcp/load.d.ts +0 -12
- package/dist/connectors/mcp/load.d.ts.map +0 -1
- package/dist/connectors/mcp/load.js +0 -122
- package/dist/connectors/mcp/load.js.map +0 -1
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { appendToolSelectionOverlapIssue, optionalToolNameListSchema, } from "../tool-selection.js";
|
|
3
|
+
import { isConnectionReference, } from "../../connections.js";
|
|
4
|
+
/** Stdio servers are out of scope; the message points at the alternatives. */
|
|
5
|
+
const STDIO_REJECTION = "uses a stdio transport, which is not supported. Managed Deep Agents " +
|
|
6
|
+
"support remote MCP servers over HTTP/SSE only; expose the server over HTTP " +
|
|
7
|
+
"or write a normal authored tool instead.";
|
|
8
|
+
const CREDENTIAL_FIELD_REJECTION = 'the "credential" field was removed; use connection: connections.get(slug, owner) instead';
|
|
9
|
+
/** @internal */
|
|
10
|
+
export const MCP_SERVERS_KEY_DEPRECATION = "mcpServers is deprecated; use servers instead. It will be removed in 0.8.0.";
|
|
11
|
+
const SERVERS_MAP_ERROR = "must be an object mapping server names to remote MCP server configs";
|
|
12
|
+
const SERVERS_KEY_CONFLICT = 'use either "servers" or "mcpServers", not both';
|
|
13
|
+
function emitMcpServersKeyDeprecation() {
|
|
14
|
+
if (typeof process !== "undefined" &&
|
|
15
|
+
typeof process.emitWarning === "function") {
|
|
16
|
+
process.emitWarning(MCP_SERVERS_KEY_DEPRECATION, {
|
|
17
|
+
type: "DeprecationWarning",
|
|
18
|
+
code: "MDA_MCP_SERVERS",
|
|
19
|
+
});
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
console.warn(MCP_SERVERS_KEY_DEPRECATION);
|
|
23
|
+
}
|
|
24
|
+
/** Raw MCP tool names, before the managed `{server}__` prefix is applied. */
|
|
25
|
+
const remoteMcpServer = z
|
|
26
|
+
.looseObject({
|
|
27
|
+
/**
|
|
28
|
+
* Present only to reject it: a `command` is how a stdio server is defined,
|
|
29
|
+
* which we don't support.
|
|
30
|
+
*/
|
|
31
|
+
command: z.never({ error: STDIO_REJECTION }).optional(),
|
|
32
|
+
transport: z.enum(["http", "sse"], {
|
|
33
|
+
error: (issue) => issue.input === "stdio"
|
|
34
|
+
? STDIO_REJECTION
|
|
35
|
+
: 'must declare a remote transport ("http" or "sse")',
|
|
36
|
+
}),
|
|
37
|
+
url: z
|
|
38
|
+
.string("must be a non-empty URL")
|
|
39
|
+
.refine((url) => url.trim().length > 0, "must be a non-empty URL"),
|
|
40
|
+
headers: z.record(z.string(), z.string()).optional(),
|
|
41
|
+
defaultToolTimeout: z
|
|
42
|
+
.number("defaultToolTimeout must be a positive number")
|
|
43
|
+
.positive("defaultToolTimeout must be a positive number")
|
|
44
|
+
.optional(),
|
|
45
|
+
includeTools: optionalToolNameListSchema,
|
|
46
|
+
excludeTools: optionalToolNameListSchema,
|
|
47
|
+
credential: z.never({ error: CREDENTIAL_FIELD_REJECTION }).optional(),
|
|
48
|
+
connection: z
|
|
49
|
+
.custom(isConnectionReference, "must be a connections.get(slug, owner) reference")
|
|
50
|
+
.optional(),
|
|
51
|
+
})
|
|
52
|
+
.check(appendToolSelectionOverlapIssue);
|
|
53
|
+
const serverMap = z
|
|
54
|
+
.record(z.string(), remoteMcpServer, {
|
|
55
|
+
error: SERVERS_MAP_ERROR,
|
|
56
|
+
})
|
|
57
|
+
.refine((servers) => Object.keys(servers).length > 0, "requires at least one entry");
|
|
58
|
+
/**
|
|
59
|
+
* The MCP connector's arguments.
|
|
60
|
+
*
|
|
61
|
+
* Shape, types, and tool-name lists are the schema's job; the rules that need
|
|
62
|
+
* more than one field — a stdio server, a tool selected and deselected at once
|
|
63
|
+
* — are checks with hand-written messages. Server configs stay loose because
|
|
64
|
+
* `@langchain/mcp-adapters` accepts more per-transport options than MDA models.
|
|
65
|
+
*
|
|
66
|
+
* `mcpServers` is accepted as a deprecated alias of `servers` and is rewritten
|
|
67
|
+
* to `servers` so the stored definition has one key.
|
|
68
|
+
*/
|
|
69
|
+
export const mcpServersConfig = z
|
|
70
|
+
.object({
|
|
71
|
+
servers: serverMap.optional(),
|
|
72
|
+
mcpServers: serverMap.optional(),
|
|
73
|
+
prefixToolNameWithServerName: z.boolean().optional(),
|
|
74
|
+
throwOnLoadError: z.boolean().optional(),
|
|
75
|
+
useStandardContentBlocks: z.boolean().optional(),
|
|
76
|
+
onConnectionError: z.literal("throw").optional(),
|
|
77
|
+
})
|
|
78
|
+
.check((ctx) => {
|
|
79
|
+
const { servers, mcpServers } = ctx.value;
|
|
80
|
+
if (servers !== undefined && mcpServers !== undefined) {
|
|
81
|
+
ctx.issues.push({
|
|
82
|
+
code: "custom",
|
|
83
|
+
input: ctx.value,
|
|
84
|
+
message: SERVERS_KEY_CONFLICT,
|
|
85
|
+
path: ["mcpServers"],
|
|
86
|
+
});
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (servers === undefined && mcpServers === undefined) {
|
|
90
|
+
ctx.issues.push({
|
|
91
|
+
code: "custom",
|
|
92
|
+
input: ctx.value,
|
|
93
|
+
message: SERVERS_MAP_ERROR,
|
|
94
|
+
path: ["servers"],
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
})
|
|
98
|
+
.transform((value) => {
|
|
99
|
+
const servers = value.servers ?? value.mcpServers;
|
|
100
|
+
if (servers === undefined) {
|
|
101
|
+
// The `.check` above reports this; keep the transform total.
|
|
102
|
+
return { servers: {} };
|
|
103
|
+
}
|
|
104
|
+
if (value.mcpServers !== undefined && value.servers === undefined) {
|
|
105
|
+
emitMcpServersKeyDeprecation();
|
|
106
|
+
}
|
|
107
|
+
const args = { servers };
|
|
108
|
+
if (value.prefixToolNameWithServerName !== undefined) {
|
|
109
|
+
args.prefixToolNameWithServerName = value.prefixToolNameWithServerName;
|
|
110
|
+
}
|
|
111
|
+
if (value.throwOnLoadError !== undefined) {
|
|
112
|
+
args.throwOnLoadError = value.throwOnLoadError;
|
|
113
|
+
}
|
|
114
|
+
if (value.useStandardContentBlocks !== undefined) {
|
|
115
|
+
args.useStandardContentBlocks = value.useStandardContentBlocks;
|
|
116
|
+
}
|
|
117
|
+
if (value.onConnectionError !== undefined) {
|
|
118
|
+
args.onConnectionError = value.onConnectionError;
|
|
119
|
+
}
|
|
120
|
+
return args;
|
|
121
|
+
});
|
|
122
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/connectors/mcp/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,+BAA+B,EAC/B,0BAA0B,GAC3B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,qBAAqB,GAEtB,MAAM,sBAAsB,CAAC;AAE9B,8EAA8E;AAC9E,MAAM,eAAe,GACnB,sEAAsE;IACtE,6EAA6E;IAC7E,0CAA0C,CAAC;AAE7C,MAAM,0BAA0B,GAC9B,0FAA0F,CAAC;AAE7F,gBAAgB;AAChB,MAAM,CAAC,MAAM,2BAA2B,GACtC,6EAA6E,CAAC;AAEhF,MAAM,iBAAiB,GACrB,qEAAqE,CAAC;AAExE,MAAM,oBAAoB,GAAG,gDAAgD,CAAC;AAE9E,SAAS,4BAA4B;IACnC,IACE,OAAO,OAAO,KAAK,WAAW;QAC9B,OAAO,OAAO,CAAC,WAAW,KAAK,UAAU,EACzC,CAAC;QACD,OAAO,CAAC,WAAW,CAAC,2BAA2B,EAAE;YAC/C,IAAI,EAAE,oBAAoB;YAC1B,IAAI,EAAE,iBAAiB;SACxB,CAAC,CAAC;QACH,OAAO;IACT,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;AAC5C,CAAC;AAED,6EAA6E;AAC7E,MAAM,eAAe,GAAG,CAAC;KACtB,WAAW,CAAC;IACX;;;OAGG;IACH,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,eAAe,EAAE,CAAC,CAAC,QAAQ,EAAE;IACvD,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE;QACjC,KAAK,EAAE,CAAC,KAAK,EAAE,E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AAO,KAAK,SAAS,EAAE,CAAC;QAClE,4BAA4B,EAAE,CAAC;IACjC,CAAC;IACD,MAAM,IAAI,GAAmB,EAAE,OAAO,EAAE,CAAC;IACzC,IAAI,KAAK,CAAC,4BAA4B,KAAK,SAAS,EAAE,CAAC;QACrD,IAAI,CAAC,4BAA4B,GAAG,KAAK,CAAC,4BAA4B,CAAC;IACzE,CAAC;IACD,IAAI,KAAK,CAAC,gBAAgB,KAAK,SAAS,EAAE,CAAC;QACzC,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC,gBAAgB,CAAC;IACjD,CAAC;IACD,IAAI,KAAK,CAAC,wBAAwB,KAAK,SAAS,EAAE,CAAC;QACjD,IAAI,CAAC,wBAAwB,GAAG,KAAK,CAAC,wBAAwB,CAAC;IACjE,CAAC;IACD,IAAI,KAAK,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;QAC1C,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC,iBAAiB,CAAC;IACnD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { ClientConfig, StreamableHTTPConnection } from "@langchain/mcp-adapters";
|
|
2
|
+
import type { Connector } from "../../runtime/connector.js";
|
|
3
|
+
import type { ConnectionReference } from "../../connections.js";
|
|
4
|
+
/** Per-server MCP tool selection. Names are raw, unprefixed MCP tool names. */
|
|
5
|
+
export interface McpToolSelectionConfig {
|
|
6
|
+
/**
|
|
7
|
+
* Raw MCP tool names to expose from this server. Names are matched before any
|
|
8
|
+
* managed `{server}__` prefix is applied.
|
|
9
|
+
*/
|
|
10
|
+
includeTools?: string[];
|
|
11
|
+
/**
|
|
12
|
+
* Raw MCP tool names to hide from this server. Names are matched before any
|
|
13
|
+
* managed `{server}__` prefix is applied.
|
|
14
|
+
*/
|
|
15
|
+
excludeTools?: string[];
|
|
16
|
+
}
|
|
17
|
+
/** A connection reference resolved through Agent Auth at run time. */
|
|
18
|
+
export type McpServerConnection = ConnectionReference;
|
|
19
|
+
/** Adapter connection fields MDA forwards, excluding stdio/auth the runtime owns. */
|
|
20
|
+
type AdapterRemoteConnection = Omit<StreamableHTTPConnection, "transport" | "type" | "authProvider">;
|
|
21
|
+
/** Shared remote server options plus MDA-only tool selection and connection mode. */
|
|
22
|
+
export type RemoteMcpServerBaseConfig = AdapterRemoteConnection & McpToolSelectionConfig & {
|
|
23
|
+
/**
|
|
24
|
+
* Bearer connection for this server, declared with `connections.get(...)`.
|
|
25
|
+
* An agent owner is a workspace-shared secret read once at load; a user
|
|
26
|
+
* owner is the caller's grant, loaded per caller after the gate.
|
|
27
|
+
*/
|
|
28
|
+
connection?: McpServerConnection;
|
|
29
|
+
};
|
|
30
|
+
/** Streamable HTTP MCP server connection. */
|
|
31
|
+
export type HttpMcpServerConfig = RemoteMcpServerBaseConfig & {
|
|
32
|
+
/** Remote transport. `"http"` selects Streamable HTTP. */
|
|
33
|
+
transport: "http";
|
|
34
|
+
};
|
|
35
|
+
/** Legacy SSE MCP server connection. */
|
|
36
|
+
export type SseMcpServerConfig = RemoteMcpServerBaseConfig & {
|
|
37
|
+
/** Remote transport. `"sse"` selects legacy SSE. */
|
|
38
|
+
transport: "sse";
|
|
39
|
+
};
|
|
40
|
+
/** A remote MCP server connection. Stdio servers are intentionally excluded. */
|
|
41
|
+
export type RemoteMcpServerConfig = HttpMcpServerConfig | SseMcpServerConfig;
|
|
42
|
+
/** {@link MultiServerMCPClient} options MDA exposes on `defineMCP`. */
|
|
43
|
+
type McpClientOptions = Pick<ClientConfig, "prefixToolNameWithServerName" | "throwOnLoadError" | "useStandardContentBlocks" | "onConnectionError">;
|
|
44
|
+
/** Named remote MCP servers. Each key is the logical server name. */
|
|
45
|
+
export type McpServerMap = Record<string, RemoteMcpServerConfig>;
|
|
46
|
+
/**
|
|
47
|
+
* Configuration accepted by `defineMCP`.
|
|
48
|
+
*
|
|
49
|
+
* Prefer `servers`. `mcpServers` is a deprecated alias and will be removed in
|
|
50
|
+
* 0.8.0.
|
|
51
|
+
*/
|
|
52
|
+
export type McpServersConfig = McpClientOptions & ({
|
|
53
|
+
/**
|
|
54
|
+
* MCP servers to connect to. Each key is the logical server name MDA
|
|
55
|
+
* uses for validation, tracing metadata, and tool-name prefixing.
|
|
56
|
+
*/
|
|
57
|
+
servers: McpServerMap;
|
|
58
|
+
mcpServers?: never;
|
|
59
|
+
} | {
|
|
60
|
+
/**
|
|
61
|
+
* @deprecated Use {@link McpServersConfig} `servers` instead.
|
|
62
|
+
* `mcpServers` will be removed in 0.8.0.
|
|
63
|
+
*/
|
|
64
|
+
mcpServers: McpServerMap;
|
|
65
|
+
servers?: never;
|
|
66
|
+
});
|
|
67
|
+
/** Parsed `defineMCP` arguments stored on the connector. Always `servers`. */
|
|
68
|
+
export interface McpServersArgs extends McpClientOptions {
|
|
69
|
+
servers: McpServerMap;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The connector exported from a `connectors/` module for MCP. It is a branded
|
|
73
|
+
* managed {@link Connector} whose `tools` hook loads the declared MCP tools at
|
|
74
|
+
* runtime, plus the raw config the loader reads.
|
|
75
|
+
*/
|
|
76
|
+
export interface McpServersDefinition extends McpServersArgs, Connector {
|
|
77
|
+
/** Internal discriminator used by the MDA loader. */
|
|
78
|
+
readonly kind: "mcp_servers";
|
|
79
|
+
}
|
|
80
|
+
export {};
|
|
81
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/connectors/mcp/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,wBAAwB,EACzB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAEhE,+EAA+E;AAC/E,MAAM,WAA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C;AAEJ,8EAA8E;AAC9E,MAAM,WAAW,cAAe,SAAQ,gBAAgB;IACtD,OAAO,EAAE,YAAY,CAAC;CACvB;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAqB,SAAQ,cAAc,EAAE,SAAS;IACrE,qDAAqD;IACrD,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;CAC9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/connectors/mcp/types.ts"],"names":[],"mappings":""}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Tool-name selection, shared by the connectors that load their tools from a
|
|
3
3
|
* remote MCP server.
|
|
4
4
|
*
|
|
5
|
-
* `
|
|
5
|
+
* `defineMCP` selects by raw tool name across arbitrary servers. A name in
|
|
6
6
|
* `includeTools`/`excludeTools` that no loaded tool answers to is an error
|
|
7
7
|
* naming what *was* available, so a typo fails the deployment instead of
|
|
8
8
|
* silently dropping a tool the agent was meant to have.
|
|
@@ -20,27 +20,18 @@ export interface ToolSelection<TTool extends string = string> {
|
|
|
20
20
|
/** Tool names to hide. Applied after {@link ToolSelection.includeTools}. */
|
|
21
21
|
excludeTools?: TTool[];
|
|
22
22
|
}
|
|
23
|
-
/**
|
|
24
|
-
* Shared authoring options for connectors that load remote tools.
|
|
25
|
-
*/
|
|
26
|
-
export interface ToolSelectionConnectorConfig<TTool extends string = string> extends ToolSelection<TTool> {
|
|
27
|
-
/** Timeout for each tool call (milliseconds on the TypeScript runtime). */
|
|
28
|
-
defaultToolTimeout?: number;
|
|
29
|
-
}
|
|
30
23
|
/** Tool names: non-empty, no duplicates within one list. */
|
|
31
|
-
export declare const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
defaultToolTimeout: z.ZodOptional<z.ZodNumber>;
|
|
35
|
-
};
|
|
36
|
-
/** Shared include/exclude overlap check for connector arg schemas. */
|
|
37
|
-
export declare function checkToolSelectionOverlap(ctx: {
|
|
24
|
+
export declare const optionalToolNameListSchema: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
25
|
+
export declare function appendToolSelectionOverlapIssue(ctx: {
|
|
26
|
+
value: unknown;
|
|
38
27
|
issues: {
|
|
39
|
-
push(issue:
|
|
28
|
+
push: (issue: {
|
|
29
|
+
code: "custom";
|
|
30
|
+
input: unknown;
|
|
31
|
+
message: string;
|
|
32
|
+
}) => void;
|
|
40
33
|
};
|
|
41
|
-
|
|
42
|
-
}, value: ToolSelection): void;
|
|
43
|
-
export declare function toolSelectionConnectorSchema<TArgs, TInput>(extra?: z.ZodRawShape): z.ZodType<TArgs, TInput>;
|
|
34
|
+
}): void;
|
|
44
35
|
/** Read the name a selection matches a loaded tool by. */
|
|
45
36
|
export type ToolNameReader = (tool: unknown) => string | undefined;
|
|
46
37
|
/** Read a loaded tool's own `name`. The default for connectors that don't rename. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-selection.d.ts","sourceRoot":"","sources":["../../src/connectors/tool-selection.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;GAKG;AACH,MAAM,WAAW,aAAa,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM;IAC1D,6DAA6D;IAC7D,YAAY,CAAC,EAAE,KAAK,EAAE,CAAC;IACvB,4EAA4E;IAC5E,YAAY,CAAC,EAAE,KAAK,EAAE,CAAC;CACxB;AAED
|
|
1
|
+
{"version":3,"file":"tool-selection.d.ts","sourceRoot":"","sources":["../../src/connectors/tool-selection.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;GAKG;AACH,MAAM,WAAW,aAAa,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM;IAC1D,6DAA6D;IAC7D,YAAY,CAAC,EAAE,KAAK,EAAE,CAAC;IACvB,4EAA4E;IAC5E,YAAY,CAAC,EAAE,KAAK,EAAE,CAAC;CACxB;AAED,4DAA4D;AAC5D,eAAO,MAAM,0BAA0B,wCAsB1B,CAAC;AAmBd,wBAAgB,+BAA+B,CAAC,GAAG,EAAE;IACnD,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE;QACN,IAAI,EAAE,CAAC,KAAK,EAAE;YAAE,IAAI,EAAE,QAAQ,CAAC;YAAC,KAAK,EAAE,OAAO,CAAC;YAAC,OAAO,EAAE,MAAM,CAAA;SAAE,KAAK,IAAI,CAAC;KAC5E,CAAC;CACH,GAAG,IAAI,CAWP;AAED,0DAA0D;AAC1D,MAAM,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,OAAO,KAAK,MAAM,GAAG,SAAS,CAAC;AAEnE,qFAAqF;AACrF,eAAO,MAAM,QAAQ,EAAE,cAGtB,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,aAAa,EACxB,KAAK,EAAE,SAAS,OAAO,EAAE,EACzB,QAAQ,GAAE,cAAyB,GAClC,OAAO,EAAE,CAwBX"}
|
|
@@ -2,79 +2,53 @@
|
|
|
2
2
|
* Tool-name selection, shared by the connectors that load their tools from a
|
|
3
3
|
* remote MCP server.
|
|
4
4
|
*
|
|
5
|
-
* `
|
|
5
|
+
* `defineMCP` selects by raw tool name across arbitrary servers. A name in
|
|
6
6
|
* `includeTools`/`excludeTools` that no loaded tool answers to is an error
|
|
7
7
|
* naming what *was* available, so a typo fails the deployment instead of
|
|
8
8
|
* silently dropping a tool the agent was meant to have.
|
|
9
9
|
*/
|
|
10
10
|
import { z } from "zod";
|
|
11
|
-
function nonEmpty(field) {
|
|
12
|
-
const message = `${field} must be a non-empty string`;
|
|
13
|
-
return z.string(message).refine((value) => value.trim().length > 0, message);
|
|
14
|
-
}
|
|
15
11
|
/** Tool names: non-empty, no duplicates within one list. */
|
|
16
|
-
export const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
seen.add(name);
|
|
30
|
-
}
|
|
31
|
-
})
|
|
32
|
-
.optional(),
|
|
33
|
-
excludeTools: z
|
|
34
|
-
.array(nonEmpty("tool name"))
|
|
35
|
-
.check((ctx) => {
|
|
36
|
-
const seen = new Set();
|
|
37
|
-
for (const name of ctx.value) {
|
|
38
|
-
if (seen.has(name)) {
|
|
39
|
-
ctx.issues.push({
|
|
40
|
-
code: "custom",
|
|
41
|
-
input: ctx.value,
|
|
42
|
-
message: `contains duplicate tool name "${name}"`,
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
seen.add(name);
|
|
12
|
+
export const optionalToolNameListSchema = z
|
|
13
|
+
.array(z
|
|
14
|
+
.string("tool name must be a non-empty string")
|
|
15
|
+
.refine((name) => name.trim().length > 0, "tool name must be a non-empty string"))
|
|
16
|
+
.check((ctx) => {
|
|
17
|
+
const seen = new Set();
|
|
18
|
+
for (const name of ctx.value) {
|
|
19
|
+
if (seen.has(name)) {
|
|
20
|
+
ctx.issues.push({
|
|
21
|
+
code: "custom",
|
|
22
|
+
input: ctx.value,
|
|
23
|
+
message: `contains duplicate tool name "${name}"`,
|
|
24
|
+
});
|
|
46
25
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
};
|
|
54
|
-
/** Shared include/exclude overlap check for connector arg schemas. */
|
|
55
|
-
export function checkToolSelectionOverlap(ctx, value) {
|
|
56
|
-
const { includeTools, excludeTools } = value;
|
|
26
|
+
seen.add(name);
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
.optional();
|
|
30
|
+
function toolSelectionOverlapMessage(selection) {
|
|
31
|
+
const { includeTools, excludeTools } = selection;
|
|
57
32
|
const overlap = (includeTools ?? []).filter((name) => (excludeTools ?? []).includes(name));
|
|
58
|
-
if (overlap.length
|
|
33
|
+
if (overlap.length === 0) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
return `selects tool(s) in both \`includeTools\` and \`excludeTools\`: ${[
|
|
37
|
+
...new Set(overlap),
|
|
38
|
+
]
|
|
39
|
+
.sort()
|
|
40
|
+
.join(", ")}`;
|
|
41
|
+
}
|
|
42
|
+
export function appendToolSelectionOverlapIssue(ctx) {
|
|
43
|
+
const message = toolSelectionOverlapMessage(ctx.value);
|
|
44
|
+
if (message) {
|
|
59
45
|
ctx.issues.push({
|
|
60
46
|
code: "custom",
|
|
61
47
|
input: ctx.value,
|
|
62
|
-
message
|
|
63
|
-
...new Set(overlap),
|
|
64
|
-
]
|
|
65
|
-
.sort()
|
|
66
|
-
.join(", ")}`,
|
|
48
|
+
message,
|
|
67
49
|
});
|
|
68
50
|
}
|
|
69
51
|
}
|
|
70
|
-
export function toolSelectionConnectorSchema(extra = {}) {
|
|
71
|
-
return z
|
|
72
|
-
.strictObject({ ...toolSelectionConnectorFields, ...extra })
|
|
73
|
-
.check((ctx) => {
|
|
74
|
-
checkToolSelectionOverlap(ctx, ctx.value);
|
|
75
|
-
})
|
|
76
|
-
.prefault({});
|
|
77
|
-
}
|
|
78
52
|
/** Read a loaded tool's own `name`. The default for connectors that don't rename. */
|
|
79
53
|
export const toolName = (tool) => {
|
|
80
54
|
const name = tool.name;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-selection.js","sourceRoot":"","sources":["../../src/connectors/tool-selection.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"tool-selection.js","sourceRoot":"","sources":["../../src/connectors/tool-selection.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAex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run gate for declarations that need a user-owned connection.
|
|
3
|
+
*
|
|
4
|
+
* Before the first model turn the gate reads the caller's OAuth grants and
|
|
5
|
+
* opaque secrets from Agent Auth. Missing grants raise one LangGraph interrupt;
|
|
6
|
+
* OAuth slugs include connect URLs, opaque slugs request password-style input.
|
|
7
|
+
* The tools a grant unlocks are loaded on first use and cached per caller.
|
|
8
|
+
*/
|
|
9
|
+
import { createMiddleware } from "langchain";
|
|
10
|
+
import { type ConnectionReference } from "./connections.js";
|
|
11
|
+
export declare const CREDENTIAL_GATE_MIDDLEWARE_NAME = "mda-credential-gate";
|
|
12
|
+
export interface PendingCredential {
|
|
13
|
+
slug: string;
|
|
14
|
+
kind: "oauth2" | "secret";
|
|
15
|
+
connect_url?: string;
|
|
16
|
+
auth_id?: string;
|
|
17
|
+
}
|
|
18
|
+
/** Interrupt payload when the caller has not granted one or more connections. */
|
|
19
|
+
export interface CredentialAuthorizationRequiredInterrupt {
|
|
20
|
+
type: "credential_authorization_required";
|
|
21
|
+
message: string;
|
|
22
|
+
credentials: PendingCredential[];
|
|
23
|
+
}
|
|
24
|
+
/** Tools a declaration contributes for one caller, plus their transport. */
|
|
25
|
+
export interface LoadedCredentialTools {
|
|
26
|
+
tools: unknown[];
|
|
27
|
+
close: () => Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
/** A declaration whose tools are unlocked by user-owned connections. */
|
|
30
|
+
export interface CredentialConsumer {
|
|
31
|
+
/** The declaration itself, used to key the per-caller tool cache. */
|
|
32
|
+
declaration: object;
|
|
33
|
+
/** User-owned connection references the declaration needs. */
|
|
34
|
+
credentials: readonly ConnectionReference[];
|
|
35
|
+
load: (accessTokens: ReadonlyMap<string, string>) => Promise<LoadedCredentialTools>;
|
|
36
|
+
}
|
|
37
|
+
export declare function createCredentialGateMiddleware(consumers: readonly CredentialConsumer[]): ReturnType<typeof createMiddleware> | undefined;
|
|
38
|
+
/** Drop every cached caller entry and close its transports. Test-only. */
|
|
39
|
+
export declare function clearCredentialToolCacheForTests(): Promise<void>;
|
|
40
|
+
//# sourceMappingURL=credential-gate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential-gate.d.ts","sourceRoot":"","sources":["../src/credential-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAS7C,OAAO,EAGL,KAAK,mBAAmB,EACzB,MAAM,kBAAkB,CAAC;AAY1B,eAAO,MAAM,+BAA+B,wBAAwB,CAAC;AAUrE,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,iFAAiF;AACjF,MAAM,WAAW,wCAAwC;IACvD,IAAI,EAAE,mCAAmC,CAAC;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,iBAAiB,EAAE,CAAC;CAClC;AAED,4EAA4E;AAC5E,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,OAAO,EAAE,CAAC;IACjB,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B;AAED,wEAAwE;AACxE,MAAM,WAAW,kBAAkB;IACjC,qEAAqE;IACrE,WAAW,EAAE,MAAM,CAAC;IACpB,8DAA8D;IAC9D,WAAW,EAAE,SAAS,mBAAmB,EAAE,CAAC;IAC5C,IAAI,EAAE,CACJ,YAAY,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,KACtC,OAAO,CAAC,qBAAqB,CAAC,CAAC;CACrC;AA6CD,wBAAgB,8BAA8B,CAC5C,SAAS,EAAE,SAAS,kBAAkB,EAAE,GACvC,UAAU,CAAC,OAAO,gBAAgB,CAAC,GAAG,SAAS,CAuCjD;AAgND,0EAA0E;AAC1E,wBAAsB,gCAAgC,IAAI,OAAO,CAAC,IAAI,CAAC,CAStE"}
|