managed-deepagents 0.6.2-dev.12 → 0.6.2-dev.14
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/dist/agent-auth.d.ts +104 -0
- package/dist/agent-auth.d.ts.map +1 -0
- package/dist/agent-auth.js +224 -0
- package/dist/agent-auth.js.map +1 -0
- package/dist/connectors/mcp/index.d.ts +29 -89
- package/dist/connectors/mcp/index.d.ts.map +1 -1
- package/dist/connectors/mcp/index.js +228 -50
- package/dist/connectors/mcp/index.js.map +1 -1
- package/dist/connectors/mcp/schema.d.ts +12 -0
- package/dist/connectors/mcp/schema.d.ts.map +1 -0
- package/dist/connectors/mcp/schema.js +55 -0
- package/dist/connectors/mcp/schema.js.map +1 -0
- package/dist/connectors/mcp/types.d.ts +62 -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 +9 -18
- package/dist/connectors/tool-selection.d.ts.map +1 -1
- package/dist/connectors/tool-selection.js +32 -58
- package/dist/connectors/tool-selection.js.map +1 -1
- package/dist/credential-gate.d.ts +39 -0
- package/dist/credential-gate.d.ts.map +1 -0
- package/dist/credential-gate.js +209 -0
- package/dist/credential-gate.js.map +1 -0
- package/dist/credentials.d.ts +88 -0
- package/dist/credentials.d.ts.map +1 -0
- package/dist/credentials.js +246 -0
- package/dist/credentials.js.map +1 -0
- 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 +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/runtime/auth.d.ts +9 -4
- package/dist/runtime/auth.d.ts.map +1 -1
- 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 +12 -7
- 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 +7 -7
- 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,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Auth client used by `credentials.get` and the pre-run credential gate.
|
|
3
|
+
*
|
|
4
|
+
* Talks to the shipped Agent Auth APIs (credentials + oauth-authorization-sessions),
|
|
5
|
+
* not the aspirational `credentials/mint` endpoint.
|
|
6
|
+
*/
|
|
7
|
+
export declare const AGENT_AUTH_TIMEOUT_MS = 10000;
|
|
8
|
+
export declare const AGENT_AUTH_PROVIDER_PAGE_SIZE = 100;
|
|
9
|
+
export declare const AGENT_AUTH_MAX_PROVIDER_PAGES = 20;
|
|
10
|
+
export interface AgentAuthHttpConfig {
|
|
11
|
+
apiKey?: string;
|
|
12
|
+
workspaceId?: string;
|
|
13
|
+
}
|
|
14
|
+
/** Query string that addresses one credential by its natural key. */
|
|
15
|
+
export declare function agentAuthCredentialQuery(options: {
|
|
16
|
+
ownerType: string;
|
|
17
|
+
ownerId: string;
|
|
18
|
+
kind: string;
|
|
19
|
+
slug: string;
|
|
20
|
+
}): string;
|
|
21
|
+
export declare function agentAuthHeaders(config: AgentAuthHttpConfig): Record<string, string>;
|
|
22
|
+
/** One Agent Auth HTTP call: no redirects, bounded timeout, JSON body. */
|
|
23
|
+
export declare function requestAgentAuthJson(options: {
|
|
24
|
+
url: string;
|
|
25
|
+
init?: Omit<RequestInit, "headers" | "signal">;
|
|
26
|
+
config: AgentAuthHttpConfig;
|
|
27
|
+
timeoutMs: number;
|
|
28
|
+
fetchImpl: typeof fetch;
|
|
29
|
+
}): Promise<{
|
|
30
|
+
ok: boolean;
|
|
31
|
+
status: number;
|
|
32
|
+
body: Record<string, unknown>;
|
|
33
|
+
}>;
|
|
34
|
+
export interface AgentAuthContext {
|
|
35
|
+
baseUrl: string;
|
|
36
|
+
/** Deployment id, passed to oauth-authorization-sessions as `agent_id`. */
|
|
37
|
+
agentId: string;
|
|
38
|
+
/** Authenticated caller, used as `owner_id` for user credentials. */
|
|
39
|
+
principalId: string;
|
|
40
|
+
apiKey?: string;
|
|
41
|
+
workspaceId?: string;
|
|
42
|
+
}
|
|
43
|
+
/** One credential slug the caller has not granted, with its connect URL. */
|
|
44
|
+
export interface PendingAuthorization {
|
|
45
|
+
slug: string;
|
|
46
|
+
connectUrl: string;
|
|
47
|
+
authId: string;
|
|
48
|
+
}
|
|
49
|
+
export declare class CredentialAuthorizationRequiredError extends Error {
|
|
50
|
+
readonly slugs: readonly string[];
|
|
51
|
+
readonly name = "CredentialAuthorizationRequiredError";
|
|
52
|
+
constructor(slugs: readonly string[]);
|
|
53
|
+
}
|
|
54
|
+
export declare class AgentAuthUnknownProviderError extends Error {
|
|
55
|
+
readonly slug: string;
|
|
56
|
+
readonly name = "AgentAuthUnknownProviderError";
|
|
57
|
+
constructor(slug: string);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Agent Auth could not answer. Callers pass a fixed message: a response body
|
|
61
|
+
* can quote secret material, so it never reaches this error.
|
|
62
|
+
*/
|
|
63
|
+
export declare class CredentialStoreError extends Error {
|
|
64
|
+
readonly status?: number | undefined;
|
|
65
|
+
readonly name = "CredentialStoreError";
|
|
66
|
+
constructor(message: string, status?: number | undefined);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Bound Agent Auth HTTP client. One instance per caller/run; headers, origin,
|
|
70
|
+
* and the request timeout stay on the instance rather than each call site.
|
|
71
|
+
*/
|
|
72
|
+
export declare class AgentAuth {
|
|
73
|
+
#private;
|
|
74
|
+
readonly context: AgentAuthContext;
|
|
75
|
+
constructor(context: AgentAuthContext, fetchImpl?: typeof fetch, timeoutMs?: number);
|
|
76
|
+
/**
|
|
77
|
+
* Read the caller's OAuth access token for a slug without starting a session.
|
|
78
|
+
*
|
|
79
|
+
* Reads never mint, so a caller can be probed repeatedly — on every replay of
|
|
80
|
+
* an interrupted node, for instance — without leaving authorization sessions
|
|
81
|
+
* behind.
|
|
82
|
+
*
|
|
83
|
+
* @returns The access token, or `undefined` when the caller must connect.
|
|
84
|
+
*/
|
|
85
|
+
readUserAccessToken(slug: string): Promise<string | undefined>;
|
|
86
|
+
/**
|
|
87
|
+
* Start an OAuth authorization session for a slug the caller has not granted.
|
|
88
|
+
*
|
|
89
|
+
* @returns The pending session, including the user-facing connect URL.
|
|
90
|
+
*/
|
|
91
|
+
startAuthorizationSession(slug: string): Promise<PendingAuthorization>;
|
|
92
|
+
/** oauth-providers has no slug filter, so the match is made across pages. */
|
|
93
|
+
resolveOAuthProviderId(slug: string): Promise<string>;
|
|
94
|
+
/** The credential key is `credential_id`, never `id`. */
|
|
95
|
+
findCredentialId(options: {
|
|
96
|
+
ownerType: string;
|
|
97
|
+
ownerId: string;
|
|
98
|
+
kind: string;
|
|
99
|
+
slug: string;
|
|
100
|
+
}): Promise<string | undefined>;
|
|
101
|
+
/** @returns The secret, or `undefined` when Agent Auth has no value (404). */
|
|
102
|
+
readSecret(credentialId: string): Promise<string | undefined>;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=agent-auth.d.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AE;QAC9B,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KACd,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAc9B;IAED,8EAA8E;IACxE,UAAU,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAalE;CAqCF"}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Auth client used by `credentials.get` and the pre-run credential gate.
|
|
3
|
+
*
|
|
4
|
+
* Talks to the shipped Agent Auth APIs (credentials + oauth-authorization-sessions),
|
|
5
|
+
* not the aspirational `credentials/mint` endpoint.
|
|
6
|
+
*/
|
|
7
|
+
import { fetchWithTimeout } from "./runtime/http.js";
|
|
8
|
+
export const AGENT_AUTH_TIMEOUT_MS = 10_000;
|
|
9
|
+
export const AGENT_AUTH_PROVIDER_PAGE_SIZE = 100;
|
|
10
|
+
export const AGENT_AUTH_MAX_PROVIDER_PAGES = 20;
|
|
11
|
+
/** Query string that addresses one credential by its natural key. */
|
|
12
|
+
export function agentAuthCredentialQuery(options) {
|
|
13
|
+
return new URLSearchParams({
|
|
14
|
+
owner_type: options.ownerType,
|
|
15
|
+
owner_id: options.ownerId,
|
|
16
|
+
kind: options.kind,
|
|
17
|
+
slug: options.slug,
|
|
18
|
+
}).toString();
|
|
19
|
+
}
|
|
20
|
+
export function agentAuthHeaders(config) {
|
|
21
|
+
const headers = {
|
|
22
|
+
accept: "application/json",
|
|
23
|
+
"content-type": "application/json",
|
|
24
|
+
"x-langsmith-product": "mda",
|
|
25
|
+
};
|
|
26
|
+
const apiKey = config.apiKey?.trim();
|
|
27
|
+
if (apiKey) {
|
|
28
|
+
headers["x-api-key"] = apiKey;
|
|
29
|
+
}
|
|
30
|
+
const workspaceId = config.workspaceId?.trim();
|
|
31
|
+
if (workspaceId) {
|
|
32
|
+
headers["x-tenant-id"] = workspaceId;
|
|
33
|
+
}
|
|
34
|
+
return headers;
|
|
35
|
+
}
|
|
36
|
+
/** One Agent Auth HTTP call: no redirects, bounded timeout, JSON body. */
|
|
37
|
+
export async function requestAgentAuthJson(options) {
|
|
38
|
+
const response = await fetchWithTimeout(options.url, {
|
|
39
|
+
...options.init,
|
|
40
|
+
redirect: "error",
|
|
41
|
+
headers: agentAuthHeaders(options.config),
|
|
42
|
+
}, options.timeoutMs, options.fetchImpl);
|
|
43
|
+
const decoded = await response.json().catch(() => ({}));
|
|
44
|
+
return {
|
|
45
|
+
ok: response.ok,
|
|
46
|
+
status: response.status,
|
|
47
|
+
body: decoded && typeof decoded === "object"
|
|
48
|
+
? decoded
|
|
49
|
+
: {},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export class CredentialAuthorizationRequiredError extends Error {
|
|
53
|
+
slugs;
|
|
54
|
+
name = "CredentialAuthorizationRequiredError";
|
|
55
|
+
constructor(slugs) {
|
|
56
|
+
super(`the caller has not connected: ${slugs.join(", ")}. ` +
|
|
57
|
+
"Declare the credential on a connector so the pre-run gate can request it.");
|
|
58
|
+
this.slugs = slugs;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export class AgentAuthUnknownProviderError extends Error {
|
|
62
|
+
slug;
|
|
63
|
+
name = "AgentAuthUnknownProviderError";
|
|
64
|
+
constructor(slug) {
|
|
65
|
+
super(`Agent Auth has no OAuth provider registered for slug "${slug}". ` +
|
|
66
|
+
"Register the provider or fix the credential slug.");
|
|
67
|
+
this.slug = slug;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Agent Auth could not answer. Callers pass a fixed message: a response body
|
|
72
|
+
* can quote secret material, so it never reaches this error.
|
|
73
|
+
*/
|
|
74
|
+
export class CredentialStoreError extends Error {
|
|
75
|
+
status;
|
|
76
|
+
name = "CredentialStoreError";
|
|
77
|
+
constructor(message, status) {
|
|
78
|
+
super(status === undefined ? message : `${message} (status ${status})`);
|
|
79
|
+
this.status = status;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Bound Agent Auth HTTP client. One instance per caller/run; headers, origin,
|
|
84
|
+
* and the request timeout stay on the instance rather than each call site.
|
|
85
|
+
*/
|
|
86
|
+
export class AgentAuth {
|
|
87
|
+
context;
|
|
88
|
+
#fetchImpl;
|
|
89
|
+
#timeoutMs;
|
|
90
|
+
constructor(context, fetchImpl = fetch, timeoutMs = AGENT_AUTH_TIMEOUT_MS) {
|
|
91
|
+
this.context = context;
|
|
92
|
+
this.#fetchImpl = fetchImpl;
|
|
93
|
+
this.#timeoutMs = timeoutMs;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Read the caller's OAuth access token for a slug without starting a session.
|
|
97
|
+
*
|
|
98
|
+
* Reads never mint, so a caller can be probed repeatedly — on every replay of
|
|
99
|
+
* an interrupted node, for instance — without leaving authorization sessions
|
|
100
|
+
* behind.
|
|
101
|
+
*
|
|
102
|
+
* @returns The access token, or `undefined` when the caller must connect.
|
|
103
|
+
*/
|
|
104
|
+
async readUserAccessToken(slug) {
|
|
105
|
+
const credentialId = await this.findCredentialId({
|
|
106
|
+
ownerType: "user",
|
|
107
|
+
ownerId: this.context.principalId,
|
|
108
|
+
kind: "oauth2",
|
|
109
|
+
slug,
|
|
110
|
+
});
|
|
111
|
+
if (!credentialId)
|
|
112
|
+
return undefined;
|
|
113
|
+
return await this.#fetchAccessToken(credentialId);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Start an OAuth authorization session for a slug the caller has not granted.
|
|
117
|
+
*
|
|
118
|
+
* @returns The pending session, including the user-facing connect URL.
|
|
119
|
+
*/
|
|
120
|
+
async startAuthorizationSession(slug) {
|
|
121
|
+
const providerId = await this.resolveOAuthProviderId(slug);
|
|
122
|
+
const { ok, status, body } = await this.#request("/v1/agent-auth/oauth-authorization-sessions", {
|
|
123
|
+
method: "POST",
|
|
124
|
+
body: JSON.stringify({
|
|
125
|
+
provider_id: providerId,
|
|
126
|
+
principal_id: this.context.principalId,
|
|
127
|
+
agent_id: this.context.agentId,
|
|
128
|
+
}),
|
|
129
|
+
});
|
|
130
|
+
if (!ok) {
|
|
131
|
+
throw new CredentialStoreError("Agent Auth create oauth-authorization-session failed", status);
|
|
132
|
+
}
|
|
133
|
+
const authId = String(body.id ?? "");
|
|
134
|
+
const connectUrl = String(body.verification_url ?? "");
|
|
135
|
+
if (!authId || !connectUrl) {
|
|
136
|
+
throw new CredentialStoreError("Agent Auth oauth-authorization-session missing id or verification_url");
|
|
137
|
+
}
|
|
138
|
+
return { slug, connectUrl, authId };
|
|
139
|
+
}
|
|
140
|
+
/** oauth-providers has no slug filter, so the match is made across pages. */
|
|
141
|
+
async resolveOAuthProviderId(slug) {
|
|
142
|
+
let cursor;
|
|
143
|
+
for (let page = 0; page < AGENT_AUTH_MAX_PROVIDER_PAGES; page += 1) {
|
|
144
|
+
const params = new URLSearchParams({
|
|
145
|
+
page_size: String(AGENT_AUTH_PROVIDER_PAGE_SIZE),
|
|
146
|
+
});
|
|
147
|
+
if (cursor)
|
|
148
|
+
params.set("cursor", cursor);
|
|
149
|
+
const { ok, status, body } = await this.#request(`/v1/agent-auth/oauth-providers?${params.toString()}`, { method: "GET" });
|
|
150
|
+
if (!ok) {
|
|
151
|
+
throw new CredentialStoreError("Agent Auth list oauth-providers failed", status);
|
|
152
|
+
}
|
|
153
|
+
const items = Array.isArray(body.items) ? body.items : [];
|
|
154
|
+
const match = items.find((item) => !!item &&
|
|
155
|
+
typeof item === "object" &&
|
|
156
|
+
String(item.slug) === slug);
|
|
157
|
+
if (match?.id) {
|
|
158
|
+
return String(match.id);
|
|
159
|
+
}
|
|
160
|
+
const next = body.next_cursor;
|
|
161
|
+
if (typeof next !== "string" || !next || next === cursor) {
|
|
162
|
+
throw new AgentAuthUnknownProviderError(slug);
|
|
163
|
+
}
|
|
164
|
+
cursor = next;
|
|
165
|
+
}
|
|
166
|
+
throw new CredentialStoreError("Agent Auth oauth-provider list returned too many pages");
|
|
167
|
+
}
|
|
168
|
+
/** The credential key is `credential_id`, never `id`. */
|
|
169
|
+
async findCredentialId(options) {
|
|
170
|
+
const { ok, status, body } = await this.#request(`/v1/agent-auth/credentials?${agentAuthCredentialQuery(options)}`, { method: "GET" });
|
|
171
|
+
if (!ok) {
|
|
172
|
+
throw new CredentialStoreError("Agent Auth list credentials failed", status);
|
|
173
|
+
}
|
|
174
|
+
const [row] = Array.isArray(body.items) ? body.items : [];
|
|
175
|
+
const id = row?.credential_id;
|
|
176
|
+
return typeof id === "string" ? id : undefined;
|
|
177
|
+
}
|
|
178
|
+
/** @returns The secret, or `undefined` when Agent Auth has no value (404). */
|
|
179
|
+
async readSecret(credentialId) {
|
|
180
|
+
const { ok, status, body } = await this.#request(`/v1/agent-auth/credentials/${encodeURIComponent(credentialId)}/secret`, { method: "GET" });
|
|
181
|
+
if (status === 404) {
|
|
182
|
+
return undefined;
|
|
183
|
+
}
|
|
184
|
+
if (!ok) {
|
|
185
|
+
throw new CredentialStoreError("Agent Auth get secret failed", status);
|
|
186
|
+
}
|
|
187
|
+
const secret = body.secret;
|
|
188
|
+
return typeof secret === "string" && secret.length > 0 ? secret : undefined;
|
|
189
|
+
}
|
|
190
|
+
async #fetchAccessToken(credentialId) {
|
|
191
|
+
const { ok, status, body } = await this.#request(`/v1/agent-auth/credentials/${encodeURIComponent(credentialId)}/oauth2`, { method: "GET" });
|
|
192
|
+
if (isAuthorizationRequired(status, body)) {
|
|
193
|
+
return undefined;
|
|
194
|
+
}
|
|
195
|
+
if (!ok) {
|
|
196
|
+
throw new CredentialStoreError("Agent Auth get oauth2 failed", status);
|
|
197
|
+
}
|
|
198
|
+
const oauth2 = body.oauth2 && typeof body.oauth2 === "object"
|
|
199
|
+
? body.oauth2
|
|
200
|
+
: body;
|
|
201
|
+
const token = oauth2.access_token;
|
|
202
|
+
return typeof token === "string" && token ? token : undefined;
|
|
203
|
+
}
|
|
204
|
+
async #request(path, init = {}) {
|
|
205
|
+
return await requestAgentAuthJson({
|
|
206
|
+
url: `${this.context.baseUrl}${path}`,
|
|
207
|
+
init,
|
|
208
|
+
config: this.context,
|
|
209
|
+
timeoutMs: this.#timeoutMs,
|
|
210
|
+
fetchImpl: this.#fetchImpl,
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
/** Agent Auth answers 409 when a stored grant has lapsed and needs re-auth. */
|
|
215
|
+
function isAuthorizationRequired(status, body) {
|
|
216
|
+
if (status !== 409) {
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
const detail = String(body.detail ?? body.title ?? body.error ?? "").toLowerCase();
|
|
220
|
+
return (body.error === "authorization_required" ||
|
|
221
|
+
detail.includes("authorization is required") ||
|
|
222
|
+
detail.includes("oauth authorization"));
|
|
223
|
+
}
|
|
224
|
+
//# sourceMappingURL=agent-auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-auth.js","sourceRoot":"","sources":["../src/agent-auth.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC;AAC5C,MAAM,CAAC,MAAM,6BAA6B,GAAG,GAAG,CAAC;AACjD,MAAM,CAAC,MAAM,6BAA6B,GAAG,EAAE,CAAC;AAOhD,qEAAqE;AACrE,MAAM,UAAU,wBAAwB,CAAC,OAKxC;IACC,OAAO,IAAI,eAAe,CAAC;QACzB,UAAU,EAAE,OAAO,CAAC,SAAS;QAC7B,QAAQ,EAAE,OAAO,CAAC,OAAO;QACzB,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,IAAI,EAAE,OAAO,CAAC,IAAI;KACnB,CAAC,CAAC,QAAQ,EAAE,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC9B,MA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IAAI,EAAE,CAC9C,CAAC,WAAW,EAAE,CAAC;IAChB,OAAO,CACL,IAAI,CAAC,KAAK,KAAK,wBAAwB;QACvC,MAAM,CAAC,QAAQ,CAAC,2BAA2B,CAAC;QAC5C,MAAM,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CACvC,CAAC;AACJ,CAAC"}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* @example
|
|
19
19
|
* ```ts
|
|
20
20
|
* // connectors/mcp.ts
|
|
21
|
-
* import { connectors } from "managed-deepagents";
|
|
21
|
+
* import { connectors, credentials } from "managed-deepagents";
|
|
22
22
|
*
|
|
23
23
|
* export const connector = connectors.mcp({
|
|
24
24
|
* mcpServers: {
|
|
@@ -26,102 +26,42 @@
|
|
|
26
26
|
* transport: "http",
|
|
27
27
|
* url: "https://docs.example.com/mcp",
|
|
28
28
|
* },
|
|
29
|
+
* notion: {
|
|
30
|
+
* transport: "http",
|
|
31
|
+
* url: "https://mcp.notion.com/mcp",
|
|
32
|
+
* credential: credentials.get("notion", { type: "user" }),
|
|
33
|
+
* },
|
|
29
34
|
* },
|
|
30
35
|
* });
|
|
31
36
|
* ```
|
|
32
37
|
*/
|
|
33
|
-
import type {
|
|
34
|
-
|
|
35
|
-
export
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
/** Shared options for all remote MCP server connections. */
|
|
48
|
-
export interface RemoteMcpServerBaseConfig extends McpToolSelectionConfig {
|
|
49
|
-
/** URL of the remote MCP server endpoint. */
|
|
50
|
-
url: string;
|
|
51
|
-
/** Optional static headers sent when connecting to the MCP server. */
|
|
52
|
-
headers?: Record<string, string>;
|
|
53
|
-
/** Default timeout, in milliseconds, for tools loaded from this server. */
|
|
54
|
-
defaultToolTimeout?: number;
|
|
55
|
-
}
|
|
56
|
-
/** Streamable HTTP MCP server connection. */
|
|
57
|
-
export interface HttpMcpServerConfig extends RemoteMcpServerBaseConfig {
|
|
58
|
-
/** Remote transport. `"http"` selects Streamable HTTP. */
|
|
59
|
-
transport: "http";
|
|
60
|
-
/**
|
|
61
|
-
* Whether the client may fall back to SSE if the server does not support
|
|
62
|
-
* Streamable HTTP. Defaults to the behavior of `@langchain/mcp-adapters`.
|
|
63
|
-
*/
|
|
64
|
-
automaticSSEFallback?: boolean;
|
|
65
|
-
}
|
|
66
|
-
/** Legacy SSE MCP server connection. */
|
|
67
|
-
export interface SseMcpServerConfig extends RemoteMcpServerBaseConfig {
|
|
68
|
-
/** Remote transport. `"sse"` selects legacy SSE. */
|
|
69
|
-
transport: "sse";
|
|
70
|
-
/** Reconnection behavior for SSE MCP servers. */
|
|
71
|
-
reconnect?: {
|
|
72
|
-
enabled: boolean;
|
|
73
|
-
maxAttempts?: number;
|
|
74
|
-
delayMs?: number;
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
/** A remote MCP server connection. Stdio servers are intentionally excluded. */
|
|
78
|
-
export type RemoteMcpServerConfig = HttpMcpServerConfig | SseMcpServerConfig;
|
|
79
|
-
/** Configuration accepted by `connectors.mcp`. */
|
|
80
|
-
export interface McpServersConfig {
|
|
81
|
-
/**
|
|
82
|
-
* MCP servers to connect to. Each key is the logical server name MDA uses
|
|
83
|
-
* for validation, tracing metadata, and tool-name prefixing.
|
|
84
|
-
*/
|
|
85
|
-
mcpServers: Record<string, RemoteMcpServerConfig>;
|
|
86
|
-
/**
|
|
87
|
-
* Whether tool names should be prefixed with the MCP server name (e.g.
|
|
88
|
-
* `docs__search`). Defaults to `true`, which avoids collisions between
|
|
89
|
-
* authored tools and common MCP tool names like `search` or `read`.
|
|
90
|
-
*/
|
|
91
|
-
prefixToolNameWithServerName?: boolean;
|
|
92
|
-
/**
|
|
93
|
-
* Whether tool loading should fail if a tool cannot be loaded. Defaults to
|
|
94
|
-
* `true` — a managed deployment should fail rather than start with a
|
|
95
|
-
* partially loaded tool surface.
|
|
96
|
-
*/
|
|
97
|
-
throwOnLoadError?: boolean;
|
|
98
|
-
/**
|
|
99
|
-
* Whether MCP tool outputs should be converted to LangChain standard content
|
|
100
|
-
* blocks. Defaults to `true` for new managed agents.
|
|
101
|
-
*/
|
|
102
|
-
useStandardContentBlocks?: boolean;
|
|
103
|
-
/**
|
|
104
|
-
* Behavior when an MCP server cannot be connected. Only `"throw"` is
|
|
105
|
-
* supported for the POC — a failed connection fails the deployment.
|
|
106
|
-
*/
|
|
107
|
-
onConnectionError?: "throw";
|
|
108
|
-
}
|
|
38
|
+
import type { CredentialConsumer, LoadedCredentialTools } from "../../credential-gate.js";
|
|
39
|
+
import type { McpServersConfig, McpServersDefinition } from "./types.js";
|
|
40
|
+
export type * from "./types.js";
|
|
41
|
+
/**
|
|
42
|
+
* Load (and cache) the MCP tools for one connector declaration.
|
|
43
|
+
*
|
|
44
|
+
* A failed load is never cached, so a transient connection error on the first
|
|
45
|
+
* run can be retried on the next, but a misconfigured deployment surfaces the
|
|
46
|
+
* error rather than silently starting with no tools.
|
|
47
|
+
*/
|
|
48
|
+
export declare function loadManagedMcpTools(connectors: McpServersDefinition): Promise<unknown[]>;
|
|
49
|
+
/** Clear the process-level MCP tool cache. Test-only. */
|
|
50
|
+
export declare function clearManagedMcpToolsCacheForTests(connectors?: McpServersDefinition): void;
|
|
109
51
|
/**
|
|
110
|
-
* The
|
|
111
|
-
*
|
|
112
|
-
*
|
|
52
|
+
* The credential gate's view of the declared MCP connectors.
|
|
53
|
+
*
|
|
54
|
+
* One consumer per declaration that names a user-owned credential; a
|
|
55
|
+
* declaration that needs no grant never reaches the gate.
|
|
113
56
|
*/
|
|
114
|
-
export
|
|
115
|
-
/** Internal discriminator used by the MDA loader. */
|
|
116
|
-
readonly kind: "mcp_servers";
|
|
117
|
-
}
|
|
57
|
+
export declare function mcpCredentialConsumers(connectors: readonly unknown[] | undefined): CredentialConsumer[];
|
|
118
58
|
/**
|
|
119
|
-
*
|
|
120
|
-
*
|
|
59
|
+
* Load tools for user-credential servers, once the gate has confirmed the
|
|
60
|
+
* caller's grants.
|
|
121
61
|
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
* installs never pull in `@langchain/mcp-adapters`.
|
|
62
|
+
* Not process-cached here: the Authorization header is per caller, so the gate
|
|
63
|
+
* owns both the cache and closing the returned transport.
|
|
125
64
|
*/
|
|
65
|
+
export declare function loadUserCredentialMcpTools(connectors: McpServersDefinition, accessTokens: ReadonlyMap<string, string>): Promise<LoadedCredentialTools>;
|
|
126
66
|
export declare const mcpConnector: (config: McpServersConfig) => McpServersDefinition;
|
|
127
67
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/connectors/mcp/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/connectors/mcp/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAUH,OAAO,KAAK,EACV,kBAAkB,EAClB,qBAAqB,EACtB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,KAAK,EACV,gBAAgB,EAChB,oBAAoB,EAGrB,MAAM,YAAY,CAAC;AAEpB,mBAAmB,YAAY,CAAC;AAkBhC;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,oBAAoB,GAC/B,OAAO,CAAC,OAAO,EAAE,CAAC,CAWpB;AAED,yDAAyD;AACzD,wBAAgB,iCAAiC,CAC/C,UAAU,CAAC,EAAE,oBAAoB,GAChC,IAAI,CAMN;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,SAAS,OAAO,EAAE,GAAG,SAAS,GACzC,kBAAkB,EAAE,CAuBtB;AAoCD;;;;;;GAMG;AACH,wBAAsB,0BAA0B,CAC9C,UAAU,EAAE,oBAAoB,EAChC,YAAY,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GACxC,OAAO,CAAC,qBAAqB,CAAC,CAyBhC;AAsKD,eAAO,MAAM,YAAY,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,oBAMrD,CAAC"}
|