managed-deepagents 0.5.0-dev.78 → 0.5.0-dev.80
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 +50 -8
- package/dist/channels/assistant-text.js +1 -1
- package/dist/channels/assistant-text.js.map +1 -1
- package/dist/channels/binding.d.ts.map +1 -1
- package/dist/channels/binding.js +3 -1
- package/dist/channels/binding.js.map +1 -1
- package/dist/channels/index.d.ts +6 -8
- package/dist/channels/index.d.ts.map +1 -1
- package/dist/channels/index.js +5 -5
- package/dist/channels/index.js.map +1 -1
- package/dist/channels/manifest.d.ts +36 -3
- package/dist/channels/manifest.d.ts.map +1 -1
- package/dist/channels/messaging-registry.d.ts +17 -0
- package/dist/channels/messaging-registry.d.ts.map +1 -0
- package/dist/channels/messaging-registry.js +44 -0
- package/dist/channels/messaging-registry.js.map +1 -0
- package/dist/channels/registry.d.ts +4 -3
- package/dist/channels/registry.d.ts.map +1 -1
- package/dist/channels/registry.js +6 -5
- package/dist/channels/registry.js.map +1 -1
- package/dist/channels/schedule-delivery.d.ts +4 -1
- package/dist/channels/schedule-delivery.d.ts.map +1 -1
- package/dist/channels/schedule-delivery.js +4 -2
- package/dist/channels/schedule-delivery.js.map +1 -1
- package/dist/connectors/github/adapter-core.d.ts +15 -0
- package/dist/connectors/github/adapter-core.d.ts.map +1 -0
- package/dist/connectors/github/adapter-core.js +52 -0
- package/dist/connectors/github/adapter-core.js.map +1 -0
- package/dist/{channels → connectors}/github/define.d.ts +28 -58
- package/dist/connectors/github/define.d.ts.map +1 -0
- package/dist/connectors/github/define.js +72 -0
- package/dist/connectors/github/define.js.map +1 -0
- package/dist/{channels → connectors}/github/http.d.ts +4 -4
- package/dist/connectors/github/http.d.ts.map +1 -0
- package/dist/{channels → connectors}/github/http.js +13 -24
- package/dist/connectors/github/http.js.map +1 -0
- package/dist/connectors/github/index.d.ts +59 -16
- package/dist/connectors/github/index.d.ts.map +1 -1
- package/dist/connectors/github/index.js +159 -73
- package/dist/connectors/github/index.js.map +1 -1
- package/dist/connectors/github/match.d.ts +20 -0
- package/dist/connectors/github/match.d.ts.map +1 -0
- package/dist/connectors/github/match.js +41 -0
- package/dist/connectors/github/match.js.map +1 -0
- package/dist/{channels → connectors}/github/normalize.d.ts +1 -1
- package/dist/connectors/github/normalize.d.ts.map +1 -0
- package/dist/{channels → connectors}/github/normalize.js +2 -2
- package/dist/connectors/github/normalize.js.map +1 -0
- package/dist/connectors/github/sandbox.d.ts.map +1 -1
- package/dist/connectors/github/sandbox.js +30 -23
- package/dist/connectors/github/sandbox.js.map +1 -1
- package/dist/connectors/github/source-thread.d.ts.map +1 -0
- package/dist/connectors/github/source-thread.js.map +1 -0
- package/dist/{channels → connectors}/github/transport.d.ts +7 -1
- package/dist/connectors/github/transport.d.ts.map +1 -0
- package/dist/{channels → connectors}/github/transport.js +18 -4
- package/dist/connectors/github/transport.js.map +1 -0
- package/dist/connectors/langsmith/index.d.ts +29 -17
- package/dist/connectors/langsmith/index.d.ts.map +1 -1
- package/dist/connectors/langsmith/index.js +34 -29
- package/dist/connectors/langsmith/index.js.map +1 -1
- package/dist/connectors/langsmith/routes.d.ts +4 -15
- package/dist/connectors/langsmith/routes.d.ts.map +1 -1
- package/dist/connectors/langsmith/routes.js +63 -72
- package/dist/connectors/langsmith/routes.js.map +1 -1
- package/dist/connectors/mcp/index.d.ts +13 -20
- package/dist/connectors/mcp/index.d.ts.map +1 -1
- package/dist/connectors/mcp/index.js +92 -112
- package/dist/connectors/mcp/index.js.map +1 -1
- package/dist/connectors/mcp/load.d.ts.map +1 -1
- package/dist/connectors/mcp/load.js +16 -40
- package/dist/connectors/mcp/load.js.map +1 -1
- package/dist/{channels → connectors}/slack/adapter-core.d.ts +1 -1
- package/dist/connectors/slack/adapter-core.d.ts.map +1 -0
- package/dist/connectors/slack/adapter-core.js.map +1 -0
- package/dist/{channels → connectors}/slack/adapter.d.ts +3 -4
- package/dist/connectors/slack/adapter.d.ts.map +1 -0
- package/dist/{channels → connectors}/slack/adapter.js +1 -1
- package/dist/connectors/slack/adapter.js.map +1 -0
- package/dist/{channels → connectors}/slack/http.d.ts +6 -40
- package/dist/connectors/slack/http.d.ts.map +1 -0
- package/dist/{channels → connectors}/slack/http.js +22 -125
- package/dist/connectors/slack/http.js.map +1 -0
- package/dist/connectors/slack/index.d.ts +108 -0
- package/dist/connectors/slack/index.d.ts.map +1 -0
- package/dist/connectors/slack/index.js +191 -0
- package/dist/connectors/slack/index.js.map +1 -0
- package/dist/{channels → connectors}/slack/normalize.d.ts +5 -5
- package/dist/connectors/slack/normalize.d.ts.map +1 -0
- package/dist/{channels → connectors}/slack/normalize.js +21 -20
- package/dist/connectors/slack/normalize.js.map +1 -0
- package/dist/connectors/slack/source-thread.d.ts.map +1 -0
- package/dist/connectors/slack/source-thread.js.map +1 -0
- package/dist/{channels → connectors}/slack/transport.d.ts +1 -1
- package/dist/connectors/slack/transport.d.ts.map +1 -0
- package/dist/{channels → connectors}/slack/transport.js +4 -3
- package/dist/connectors/slack/transport.js.map +1 -0
- package/dist/connectors/tool-selection.d.ts +31 -0
- package/dist/connectors/tool-selection.d.ts.map +1 -0
- package/dist/connectors/tool-selection.js +54 -0
- package/dist/connectors/tool-selection.js.map +1 -0
- package/dist/connectors/toolserver/catalog.d.ts +134 -0
- package/dist/connectors/toolserver/catalog.d.ts.map +1 -0
- package/dist/connectors/toolserver/catalog.js +74 -0
- package/dist/connectors/toolserver/catalog.js.map +1 -0
- package/dist/connectors/toolserver/index.d.ts +119 -0
- package/dist/connectors/toolserver/index.d.ts.map +1 -0
- package/dist/connectors/toolserver/index.js +150 -0
- package/dist/connectors/toolserver/index.js.map +1 -0
- package/dist/connectors/toolserver/load.d.ts +55 -0
- package/dist/connectors/toolserver/load.d.ts.map +1 -0
- package/dist/connectors/toolserver/load.js +162 -0
- package/dist/connectors/toolserver/load.js.map +1 -0
- package/dist/extension.d.ts +77 -0
- package/dist/extension.d.ts.map +1 -0
- package/dist/extension.js +127 -0
- package/dist/extension.js.map +1 -0
- package/dist/identity/claims.d.ts +18 -0
- package/dist/identity/claims.d.ts.map +1 -0
- package/dist/identity/claims.js +37 -0
- package/dist/identity/claims.js.map +1 -0
- package/dist/identity/connect-inference.d.ts +28 -0
- package/dist/identity/connect-inference.d.ts.map +1 -0
- package/dist/identity/connect-inference.js +39 -0
- package/dist/identity/connect-inference.js.map +1 -0
- package/dist/identity/connect-provider-types.d.ts +23 -6
- package/dist/identity/connect-provider-types.d.ts.map +1 -1
- package/dist/identity/connect-provider-types.js +3 -1
- package/dist/identity/connect-provider-types.js.map +1 -1
- package/dist/identity/connect-provider.d.ts +9 -4
- package/dist/identity/connect-provider.d.ts.map +1 -1
- package/dist/identity/connect-provider.js +19 -9
- package/dist/identity/connect-provider.js.map +1 -1
- package/dist/identity/credential-resolvers.d.ts +33 -0
- package/dist/identity/credential-resolvers.d.ts.map +1 -0
- package/dist/identity/credential-resolvers.js +62 -0
- package/dist/identity/credential-resolvers.js.map +1 -0
- package/dist/identity/github/connect-http.d.ts +3 -3
- package/dist/identity/github/connect-http.d.ts.map +1 -1
- package/dist/identity/github/connect-http.js +21 -13
- package/dist/identity/github/connect-http.js.map +1 -1
- package/dist/identity/github/credentials-store.d.ts +10 -10
- package/dist/identity/github/credentials-store.d.ts.map +1 -1
- package/dist/identity/github/credentials-store.js +40 -43
- package/dist/identity/github/credentials-store.js.map +1 -1
- package/dist/identity/github/credentials.d.ts +16 -13
- package/dist/identity/github/credentials.d.ts.map +1 -1
- package/dist/identity/github/credentials.js +43 -23
- package/dist/identity/github/credentials.js.map +1 -1
- package/dist/identity/github/index.d.ts +2 -3
- package/dist/identity/github/index.d.ts.map +1 -1
- package/dist/identity/github/index.js +1 -2
- package/dist/identity/github/index.js.map +1 -1
- package/dist/identity/github/oauth.d.ts +3 -3
- package/dist/identity/github/oauth.d.ts.map +1 -1
- package/dist/identity/github/oauth.js +10 -9
- package/dist/identity/github/oauth.js.map +1 -1
- package/dist/identity/index.d.ts +35 -29
- package/dist/identity/index.d.ts.map +1 -1
- package/dist/identity/index.js +98 -131
- package/dist/identity/index.js.map +1 -1
- package/dist/identity/loopback.d.ts +27 -2
- package/dist/identity/loopback.d.ts.map +1 -1
- package/dist/identity/loopback.js +61 -8
- package/dist/identity/loopback.js.map +1 -1
- package/dist/identity/options.d.ts +90 -0
- package/dist/identity/options.d.ts.map +1 -0
- package/dist/identity/options.js +171 -0
- package/dist/identity/options.js.map +1 -0
- package/dist/identity/slack/connect-http.d.ts +3 -3
- package/dist/identity/slack/connect-http.d.ts.map +1 -1
- package/dist/identity/slack/connect-http.js +22 -14
- package/dist/identity/slack/connect-http.js.map +1 -1
- package/dist/identity/slack/index.d.ts +1 -2
- package/dist/identity/slack/index.d.ts.map +1 -1
- package/dist/identity/slack/index.js +1 -2
- package/dist/identity/slack/index.js.map +1 -1
- package/dist/identity/slack/links.d.ts +15 -15
- package/dist/identity/slack/links.d.ts.map +1 -1
- package/dist/identity/slack/links.js +50 -53
- package/dist/identity/slack/links.js.map +1 -1
- package/dist/identity/slack/oauth.d.ts +2 -2
- package/dist/identity/slack/oauth.d.ts.map +1 -1
- package/dist/identity/slack/oauth.js +9 -24
- package/dist/identity/slack/oauth.js.map +1 -1
- package/dist/identity/supabase.js +9 -9
- package/dist/identity/supabase.js.map +1 -1
- package/dist/identity/types.d.ts +82 -36
- package/dist/identity/types.d.ts.map +1 -1
- package/dist/index.d.ts +11 -21
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -12
- package/dist/index.js.map +1 -1
- package/dist/ingress/index.d.ts +54 -0
- package/dist/ingress/index.d.ts.map +1 -0
- package/dist/ingress/index.js +128 -0
- package/dist/ingress/index.js.map +1 -0
- package/dist/namespaces.d.ts +76 -0
- package/dist/namespaces.d.ts.map +1 -0
- package/dist/namespaces.js +94 -0
- package/dist/namespaces.js.map +1 -0
- package/dist/runtime/auth.d.ts +18 -14
- package/dist/runtime/auth.d.ts.map +1 -1
- package/dist/runtime/auth.js +88 -68
- package/dist/runtime/auth.js.map +1 -1
- package/dist/runtime/backend.d.ts +1 -1
- package/dist/runtime/backend.d.ts.map +1 -1
- package/dist/runtime/connector.d.ts +66 -23
- package/dist/runtime/connector.d.ts.map +1 -1
- package/dist/runtime/connector.js +63 -27
- package/dist/runtime/connector.js.map +1 -1
- package/dist/runtime/cors.d.ts +2 -3
- package/dist/runtime/cors.d.ts.map +1 -1
- package/dist/runtime/cors.js +2 -7
- package/dist/runtime/cors.js.map +1 -1
- package/dist/runtime/credentials.d.ts.map +1 -1
- package/dist/runtime/credentials.js +39 -14
- package/dist/runtime/credentials.js.map +1 -1
- package/dist/runtime/http.d.ts +47 -0
- package/dist/runtime/http.d.ts.map +1 -0
- package/dist/runtime/http.js +54 -0
- package/dist/runtime/http.js.map +1 -0
- package/dist/runtime/identity-http.d.ts +6 -16
- package/dist/runtime/identity-http.d.ts.map +1 -1
- package/dist/runtime/identity-http.js +71 -54
- package/dist/runtime/identity-http.js.map +1 -1
- package/dist/runtime/identity-runtime.d.ts +18 -17
- package/dist/runtime/identity-runtime.d.ts.map +1 -1
- package/dist/runtime/identity-runtime.js +55 -39
- package/dist/runtime/identity-runtime.js.map +1 -1
- package/dist/runtime/index.d.ts +77 -104
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +36 -35
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/memory/index.d.ts +1 -0
- package/dist/runtime/memory/index.d.ts.map +1 -1
- package/dist/runtime/memory/index.js +1 -0
- package/dist/runtime/memory/index.js.map +1 -1
- package/dist/runtime/memory/lazy-context-backend.d.ts +66 -0
- package/dist/runtime/memory/lazy-context-backend.d.ts.map +1 -0
- package/dist/runtime/memory/lazy-context-backend.js +154 -0
- package/dist/runtime/memory/lazy-context-backend.js.map +1 -0
- package/dist/runtime/memory/user-repo.js +3 -3
- package/dist/runtime/memory/user-repo.js.map +1 -1
- package/dist/runtime/sandbox-manager.d.ts +33 -0
- package/dist/runtime/sandbox-manager.d.ts.map +1 -1
- package/dist/runtime/sandbox-manager.js +173 -9
- package/dist/runtime/sandbox-manager.js.map +1 -1
- package/dist/runtime/sandbox-stream-retry.d.ts +16 -0
- package/dist/runtime/sandbox-stream-retry.d.ts.map +1 -0
- package/dist/runtime/sandbox-stream-retry.js +61 -0
- package/dist/runtime/sandbox-stream-retry.js.map +1 -0
- package/dist/runtime/setup-script.d.ts.map +1 -1
- package/dist/runtime/setup-script.js +4 -2
- package/dist/runtime/setup-script.js.map +1 -1
- package/dist/runtime/validated-token.d.ts +1 -1
- package/dist/runtime/validated-token.d.ts.map +1 -1
- package/dist/runtime/validated-token.js +75 -33
- package/dist/runtime/validated-token.js.map +1 -1
- package/dist/sandbox.d.ts +19 -22
- package/dist/sandbox.d.ts.map +1 -1
- package/dist/sandbox.js +20 -34
- package/dist/sandbox.js.map +1 -1
- package/dist/schedules.js +8 -9
- package/dist/schedules.js.map +1 -1
- package/package.json +18 -28
- package/dist/channels/collect.d.ts +0 -26
- package/dist/channels/collect.d.ts.map +0 -1
- package/dist/channels/collect.js +0 -42
- package/dist/channels/collect.js.map +0 -1
- package/dist/channels/github/adapter-core.d.ts +0 -6
- package/dist/channels/github/adapter-core.d.ts.map +0 -1
- package/dist/channels/github/adapter-core.js +0 -27
- package/dist/channels/github/adapter-core.js.map +0 -1
- package/dist/channels/github/adapter.d.ts +0 -16
- package/dist/channels/github/adapter.d.ts.map +0 -1
- package/dist/channels/github/adapter.js +0 -52
- package/dist/channels/github/adapter.js.map +0 -1
- package/dist/channels/github/define.d.ts.map +0 -1
- package/dist/channels/github/define.js +0 -166
- package/dist/channels/github/define.js.map +0 -1
- package/dist/channels/github/http.d.ts.map +0 -1
- package/dist/channels/github/http.js.map +0 -1
- package/dist/channels/github/index.d.ts +0 -12
- package/dist/channels/github/index.d.ts.map +0 -1
- package/dist/channels/github/index.js +0 -10
- package/dist/channels/github/index.js.map +0 -1
- package/dist/channels/github/normalize.d.ts.map +0 -1
- package/dist/channels/github/normalize.js.map +0 -1
- package/dist/channels/github/source-thread.d.ts.map +0 -1
- package/dist/channels/github/source-thread.js.map +0 -1
- package/dist/channels/github/transport.d.ts.map +0 -1
- package/dist/channels/github/transport.js.map +0 -1
- package/dist/channels/plugin.d.ts +0 -61
- package/dist/channels/plugin.d.ts.map +0 -1
- package/dist/channels/plugin.js +0 -80
- package/dist/channels/plugin.js.map +0 -1
- package/dist/channels/slack/adapter-core.d.ts.map +0 -1
- package/dist/channels/slack/adapter-core.js.map +0 -1
- package/dist/channels/slack/adapter.d.ts.map +0 -1
- package/dist/channels/slack/adapter.js.map +0 -1
- package/dist/channels/slack/define.d.ts +0 -74
- package/dist/channels/slack/define.d.ts.map +0 -1
- package/dist/channels/slack/define.js +0 -160
- package/dist/channels/slack/define.js.map +0 -1
- package/dist/channels/slack/http.d.ts.map +0 -1
- package/dist/channels/slack/http.js.map +0 -1
- package/dist/channels/slack/index.d.ts +0 -18
- package/dist/channels/slack/index.d.ts.map +0 -1
- package/dist/channels/slack/index.js +0 -13
- package/dist/channels/slack/index.js.map +0 -1
- package/dist/channels/slack/normalize.d.ts.map +0 -1
- package/dist/channels/slack/normalize.js.map +0 -1
- package/dist/channels/slack/source-thread.d.ts.map +0 -1
- package/dist/channels/slack/source-thread.js.map +0 -1
- package/dist/channels/slack/transport.d.ts.map +0 -1
- package/dist/channels/slack/transport.js.map +0 -1
- /package/dist/{channels → connectors}/github/source-thread.d.ts +0 -0
- /package/dist/{channels → connectors}/github/source-thread.js +0 -0
- /package/dist/{channels → connectors}/slack/adapter-core.js +0 -0
- /package/dist/{channels → connectors}/slack/source-thread.d.ts +0 -0
- /package/dist/{channels → connectors}/slack/source-thread.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/connectors/toolserver/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EAAE,CAAC,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,cAAc,EACpB,KAAK,EAAE,MAAM,GACZ,0BAA0B,CAU5B;AAED;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAAM,CACvC,qBAAqB,EACrB,0BAA0B,CAMkC,CAAC"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool server connectors — the integrations a workspace manages in LangSmith.
|
|
3
|
+
*
|
|
4
|
+
* A workspace connects Gmail, Slack, Linear, … once in LangSmith; declaring the
|
|
5
|
+
* matching connector is how a Managed Deep Agent gets those tools. The provider's
|
|
6
|
+
* tokens stay in LangSmith's vault: MDA calls LangSmith's tool server gateway,
|
|
7
|
+
* which resolves the credential for the subject and forwards to the tool server.
|
|
8
|
+
* The deployment never sees, stores, or refreshes a provider token.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* // connectors/gmail.ts
|
|
13
|
+
* import { connectors } from "managed-deepagents";
|
|
14
|
+
*
|
|
15
|
+
* export const connector = connectors.gmail({
|
|
16
|
+
* includeTools: ["gmail_read_emails", "gmail_draft_email"],
|
|
17
|
+
* });
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* ## Whose credentials
|
|
21
|
+
*
|
|
22
|
+
* Nothing here. Which workspace the call runs against, which key authenticates
|
|
23
|
+
* it, and whose connection it resolves are facts about the deployment, not
|
|
24
|
+
* choices the agent's source makes — so they come from the environment
|
|
25
|
+
* (`LANGSMITH_API_KEY`, `LANGSMITH_ENDPOINT`, `LANGCHAIN_WORKSPACE_ID`) and the
|
|
26
|
+
* declaration is only ever about which tools the agent gets.
|
|
27
|
+
*
|
|
28
|
+
* The gateway resolves credentials for whoever the call authenticates as, so the
|
|
29
|
+
* subject is the deployment's key rather than the caller of the run: every thread
|
|
30
|
+
* reaches the same connection. A personal key resolves that user's connections,
|
|
31
|
+
* which is what makes `mda dev` work against your own Gmail. A key with no user
|
|
32
|
+
* behind it has no subject yet, and has to borrow an agent's shared connection
|
|
33
|
+
* via `MDA_TOOLSERVER_AGENT_ID` — see the loader for why that is an env var.
|
|
34
|
+
*
|
|
35
|
+
* Per-actor credentials — each caller reaching their own Gmail — are not
|
|
36
|
+
* available through this connector. That needs [credentials](../../identity) with
|
|
37
|
+
* a resolver that can mint a token for `runtime.identity.actor`.
|
|
38
|
+
*/
|
|
39
|
+
import { z } from "zod";
|
|
40
|
+
import { defineExtension } from "../../extension.js";
|
|
41
|
+
import { STANDALONE_TOOL_SERVER_INTEGRATIONS, } from "./catalog.js";
|
|
42
|
+
export { GITHUB_SLUG, SLACK_SLUG, STANDALONE_TOOL_SERVER_INTEGRATIONS, TOOL_SERVER_INTEGRATIONS, } from "./catalog.js";
|
|
43
|
+
/** Tool names, as the tool server publishes them (already provider-prefixed). */
|
|
44
|
+
const toolNames = z
|
|
45
|
+
.array(nonEmpty("tool name"))
|
|
46
|
+
.check((ctx) => {
|
|
47
|
+
const seen = new Set();
|
|
48
|
+
for (const name of ctx.value) {
|
|
49
|
+
if (seen.has(name)) {
|
|
50
|
+
ctx.issues.push({
|
|
51
|
+
code: "custom",
|
|
52
|
+
input: ctx.value,
|
|
53
|
+
message: `contains duplicate tool name "${name}"`,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
seen.add(name);
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
.optional();
|
|
60
|
+
/** The options every tool server integration accepts. */
|
|
61
|
+
const toolServerConnectorFields = {
|
|
62
|
+
includeTools: toolNames,
|
|
63
|
+
excludeTools: toolNames,
|
|
64
|
+
defaultToolTimeout: z
|
|
65
|
+
.number("defaultToolTimeout must be a positive number")
|
|
66
|
+
.positive("defaultToolTimeout must be a positive number")
|
|
67
|
+
.optional(),
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Build the argument schema for one tool server integration.
|
|
71
|
+
*
|
|
72
|
+
* `extra` adds whatever the integration accepts on top of the shared options —
|
|
73
|
+
* `connectors.github`'s sandbox provisioning, say. Every integration is built
|
|
74
|
+
* from here, so the shared options are spelled, defaulted, and validated once
|
|
75
|
+
* rather than restated per integration.
|
|
76
|
+
*
|
|
77
|
+
* Strict, so an option that does not exist is an error rather than a silently
|
|
78
|
+
* ignored key — which matches the Python model's `extra="forbid"`, and is what
|
|
79
|
+
* tells a project that `apiKey` and friends now come from the environment.
|
|
80
|
+
*
|
|
81
|
+
* The result is cast to the caller's argument types. Zod cannot describe a
|
|
82
|
+
* prefaulted object as "accepts undefined, produces defaults" in one type, so
|
|
83
|
+
* the shape and the declared config interface are kept in step by review.
|
|
84
|
+
*/
|
|
85
|
+
export function toolServerConnectorSchema(extra = {}) {
|
|
86
|
+
return z
|
|
87
|
+
.strictObject({ ...toolServerConnectorFields, ...extra })
|
|
88
|
+
.check((ctx) => {
|
|
89
|
+
const { includeTools, excludeTools } = ctx.value;
|
|
90
|
+
const overlap = (includeTools ?? []).filter((name) => (excludeTools ?? []).includes(name));
|
|
91
|
+
if (overlap.length > 0) {
|
|
92
|
+
ctx.issues.push({
|
|
93
|
+
code: "custom",
|
|
94
|
+
input: ctx.value,
|
|
95
|
+
message: `selects tool(s) in both \`includeTools\` and \`excludeTools\`: ${[
|
|
96
|
+
...new Set(overlap),
|
|
97
|
+
]
|
|
98
|
+
.sort()
|
|
99
|
+
.join(", ")}`,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
.prefault({});
|
|
104
|
+
}
|
|
105
|
+
function nonEmpty(field) {
|
|
106
|
+
const message = `${field} must be a non-empty string`;
|
|
107
|
+
return z.string(message).refine((value) => value.trim().length > 0, message);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Build the `tools` hook that loads one integration's tools.
|
|
111
|
+
*
|
|
112
|
+
* Shared so every integration reaches the gateway the same way, whether that is
|
|
113
|
+
* all it does (`connectors.gmail`) or one of the things it does
|
|
114
|
+
* (`connectors.github`, which also provisions the sandbox).
|
|
115
|
+
*
|
|
116
|
+
* The hook runs at agent-graph construction, so the loader is imported lazily —
|
|
117
|
+
* an authoring-only install never pulls in the MCP client.
|
|
118
|
+
*/
|
|
119
|
+
export function toolServerTools(slug, label) {
|
|
120
|
+
return async (_ctx, self) => {
|
|
121
|
+
const { loadToolServerTools } = await import("./load.js");
|
|
122
|
+
return loadToolServerTools(slug, label, self);
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Build the factory for one tool server integration.
|
|
127
|
+
*
|
|
128
|
+
* For the integrations that are only their tools. An integration with more to
|
|
129
|
+
* contribute — `connectors.github` — calls `defineExtension` itself with
|
|
130
|
+
* {@link toolServerConnectorSchema} and {@link toolServerTools}.
|
|
131
|
+
*/
|
|
132
|
+
export function toolServerConnector(slug, label) {
|
|
133
|
+
return defineExtension("connector", {
|
|
134
|
+
kind: slug,
|
|
135
|
+
label,
|
|
136
|
+
args: toolServerConnectorSchema(),
|
|
137
|
+
tools: toolServerTools(slug, label),
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* The `connectors` entries for the integrations that have their own factory.
|
|
142
|
+
*
|
|
143
|
+
* Built from the catalog so a new integration is one entry, not an entry plus a
|
|
144
|
+
* namespace line that can be forgotten.
|
|
145
|
+
*/
|
|
146
|
+
export const toolServerConnectors = Object.fromEntries(STANDALONE_TOOL_SERVER_INTEGRATIONS.map(({ slug, factory }) => [
|
|
147
|
+
factory,
|
|
148
|
+
toolServerConnector(slug, `connectors.${factory}`),
|
|
149
|
+
]));
|
|
150
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/connectors/toolserver/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AA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AAK;QACL,IAAI,EAAE,yBAAyB,EAG5B;QACH,KAAK,EAAE,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC;KACpC,CAAC,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAG7B,MAAM,CAAC,WAAW,CACpB,mCAAmC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAC7D,OAAO;IACP,mBAAmB,CAAC,IAAsB,EAAE,cAAc,OAAO,EAAE,CAAC;CACrE,CAAC,CAC0D,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Load a tool server integration's tools through LangSmith's gateway.
|
|
3
|
+
*
|
|
4
|
+
* The gateway (`POST /v1/toolserver/servers/{slug}/mcp`) authenticates the call,
|
|
5
|
+
* resolves the subject's stored credential for that provider, and forwards the
|
|
6
|
+
* MCP request to the tool server. From the client's side it is an ordinary
|
|
7
|
+
* remote MCP server that happens to need a LangSmith key, so the same
|
|
8
|
+
* `@langchain/mcp-adapters` client `connectors.mcp` uses talks to it.
|
|
9
|
+
*
|
|
10
|
+
* Names are not prefixed with the integration: the tool server already publishes
|
|
11
|
+
* them provider-qualified (`gmail_send_email`, `linear_create_issue`), so a
|
|
12
|
+
* prefix would only produce `gmail__gmail_send_email` and make every
|
|
13
|
+
* `includeTools` entry a guess about MDA's renaming.
|
|
14
|
+
*
|
|
15
|
+
* Everything about *reaching* LangSmith comes from the environment, because it
|
|
16
|
+
* describes the deployment rather than the agent: `LANGSMITH_API_KEY`,
|
|
17
|
+
* `LANGSMITH_ENDPOINT` / `LANGCHAIN_ENDPOINT`, `LANGCHAIN_WORKSPACE_ID`.
|
|
18
|
+
*
|
|
19
|
+
* `MDA_TOOLSERVER_AGENT_ID` is the exception that should not need to exist. The
|
|
20
|
+
* gateway resolves credentials for the user behind the key, and a deployment key
|
|
21
|
+
* that resolves to no user has no subject at all — so until the gateway can
|
|
22
|
+
* recognize a deployment from its own key, such a deployment has to name the
|
|
23
|
+
* LangSmith agent whose shared connection it borrows. It is an env var and not a
|
|
24
|
+
* connector option because it is a fact about where the deployment runs, and
|
|
25
|
+
* because it disappears once the gateway does that itself.
|
|
26
|
+
*/
|
|
27
|
+
import type { ToolServerConnectorConfig, ToolServerSlug } from "./index.js";
|
|
28
|
+
/**
|
|
29
|
+
* Load (and cache) the tools of one declared tool server integration.
|
|
30
|
+
*
|
|
31
|
+
* `connector` carries the gateway options and is what the cache is keyed by: a
|
|
32
|
+
* declaration lives as long as the process, and two of them never share a key.
|
|
33
|
+
*/
|
|
34
|
+
export declare function loadToolServerTools(slug: ToolServerSlug, label: string, connector: ToolServerConnectorConfig & object): Promise<unknown[]>;
|
|
35
|
+
/** Drop a connector's cached tools. Test-only. */
|
|
36
|
+
export declare function clearToolServerToolsCacheForTests(connector: object): void;
|
|
37
|
+
/**
|
|
38
|
+
* Build the integration's gateway URL.
|
|
39
|
+
*
|
|
40
|
+
* The gateway path is appended to the configured API base rather than resolved
|
|
41
|
+
* against its origin, so a LangSmith reachable under a path prefix keeps it. That
|
|
42
|
+
* makes the base the whole prefix — `https://api.smith.langchain.com`, or
|
|
43
|
+
* `https://langsmith.acme.com/api` self-hosted — not a host to graft onto.
|
|
44
|
+
*/
|
|
45
|
+
export declare function gatewayUrl(slug: ToolServerSlug, label: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* Authenticate the call to the gateway.
|
|
48
|
+
*
|
|
49
|
+
* The key is read at load time rather than at declaration time so the same
|
|
50
|
+
* compiled project runs in any workspace, and it is required here rather than
|
|
51
|
+
* defaulted to empty so a missing key fails naming the fix instead of arriving
|
|
52
|
+
* as a 401 from LangSmith.
|
|
53
|
+
*/
|
|
54
|
+
export declare function gatewayHeaders(label: string): Record<string, string>;
|
|
55
|
+
//# sourceMappingURL=load.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../../src/connectors/toolserver/load.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAKH,OAAO,KAAK,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAkB5E;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,cAAc,EACpB,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,yBAAyB,GAAG,MAAM,GAC5C,OAAO,CAAC,OAAO,EAAE,CAAC,CAmBpB;AAED,kDAAkD;AAClD,wBAAgB,iCAAiC,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAEzE;AA+BD;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAoBtE;AAUD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAepE"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Load a tool server integration's tools through LangSmith's gateway.
|
|
3
|
+
*
|
|
4
|
+
* The gateway (`POST /v1/toolserver/servers/{slug}/mcp`) authenticates the call,
|
|
5
|
+
* resolves the subject's stored credential for that provider, and forwards the
|
|
6
|
+
* MCP request to the tool server. From the client's side it is an ordinary
|
|
7
|
+
* remote MCP server that happens to need a LangSmith key, so the same
|
|
8
|
+
* `@langchain/mcp-adapters` client `connectors.mcp` uses talks to it.
|
|
9
|
+
*
|
|
10
|
+
* Names are not prefixed with the integration: the tool server already publishes
|
|
11
|
+
* them provider-qualified (`gmail_send_email`, `linear_create_issue`), so a
|
|
12
|
+
* prefix would only produce `gmail__gmail_send_email` and make every
|
|
13
|
+
* `includeTools` entry a guess about MDA's renaming.
|
|
14
|
+
*
|
|
15
|
+
* Everything about *reaching* LangSmith comes from the environment, because it
|
|
16
|
+
* describes the deployment rather than the agent: `LANGSMITH_API_KEY`,
|
|
17
|
+
* `LANGSMITH_ENDPOINT` / `LANGCHAIN_ENDPOINT`, `LANGCHAIN_WORKSPACE_ID`.
|
|
18
|
+
*
|
|
19
|
+
* `MDA_TOOLSERVER_AGENT_ID` is the exception that should not need to exist. The
|
|
20
|
+
* gateway resolves credentials for the user behind the key, and a deployment key
|
|
21
|
+
* that resolves to no user has no subject at all — so until the gateway can
|
|
22
|
+
* recognize a deployment from its own key, such a deployment has to name the
|
|
23
|
+
* LangSmith agent whose shared connection it borrows. It is an env var and not a
|
|
24
|
+
* connector option because it is a fact about where the deployment runs, and
|
|
25
|
+
* because it disappears once the gateway does that itself.
|
|
26
|
+
*/
|
|
27
|
+
import { MultiServerMCPClient } from "@langchain/mcp-adapters";
|
|
28
|
+
import { selectTools } from "../tool-selection.js";
|
|
29
|
+
/** LangSmith's public API, used when no endpoint is configured. */
|
|
30
|
+
const DEFAULT_API_URL = "https://api.smith.langchain.com";
|
|
31
|
+
/**
|
|
32
|
+
* Tools loaded per declared connector, cached for the life of the process.
|
|
33
|
+
*
|
|
34
|
+
* The compiled entry rebuilds the agent graph on every invocation, but an
|
|
35
|
+
* integration's tool surface is stable for the life of the deployment — so each
|
|
36
|
+
* connector connects and lists once and every later run reuses the result.
|
|
37
|
+
* Keyed by the connector object so two declarations (Gmail and Linear, say)
|
|
38
|
+
* never share an entry, and storing the in-flight promise dedupes concurrent
|
|
39
|
+
* first runs. A rejected load is evicted, so a transient connection error can be
|
|
40
|
+
* retried on the next run while a misconfigured declaration keeps reporting it.
|
|
41
|
+
*/
|
|
42
|
+
const cache = new WeakMap();
|
|
43
|
+
/**
|
|
44
|
+
* Load (and cache) the tools of one declared tool server integration.
|
|
45
|
+
*
|
|
46
|
+
* `connector` carries the gateway options and is what the cache is keyed by: a
|
|
47
|
+
* declaration lives as long as the process, and two of them never share a key.
|
|
48
|
+
*/
|
|
49
|
+
export function loadToolServerTools(slug, label, connector) {
|
|
50
|
+
// An empty allowlist selects no tools, so there is nothing to list. Returning
|
|
51
|
+
// before connecting is what lets a project declare an integration for
|
|
52
|
+
// something other than its tools — `connectors.github` cloning a repository —
|
|
53
|
+
// without the workspace having that integration connected.
|
|
54
|
+
if (connector.includeTools?.length === 0) {
|
|
55
|
+
return Promise.resolve([]);
|
|
56
|
+
}
|
|
57
|
+
const cached = cache.get(connector);
|
|
58
|
+
if (cached) {
|
|
59
|
+
return cached;
|
|
60
|
+
}
|
|
61
|
+
const loading = connectAndLoadTools(slug, label, connector).catch((error) => {
|
|
62
|
+
cache.delete(connector);
|
|
63
|
+
throw error;
|
|
64
|
+
});
|
|
65
|
+
cache.set(connector, loading);
|
|
66
|
+
return loading;
|
|
67
|
+
}
|
|
68
|
+
/** Drop a connector's cached tools. Test-only. */
|
|
69
|
+
export function clearToolServerToolsCacheForTests(connector) {
|
|
70
|
+
cache.delete(connector);
|
|
71
|
+
}
|
|
72
|
+
async function connectAndLoadTools(slug, label, config) {
|
|
73
|
+
const client = new MultiServerMCPClient({
|
|
74
|
+
mcpServers: {
|
|
75
|
+
[slug]: {
|
|
76
|
+
transport: "http",
|
|
77
|
+
url: gatewayUrl(slug, label),
|
|
78
|
+
headers: gatewayHeaders(label),
|
|
79
|
+
// The gateway only answers POST, so there is no SSE endpoint to fall
|
|
80
|
+
// back to; a failure here is a real failure worth surfacing.
|
|
81
|
+
automaticSSEFallback: false,
|
|
82
|
+
...(config.defaultToolTimeout === undefined
|
|
83
|
+
? {}
|
|
84
|
+
: { defaultToolTimeout: config.defaultToolTimeout }),
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
prefixToolNameWithServerName: false,
|
|
88
|
+
throwOnLoadError: true,
|
|
89
|
+
useStandardContentBlocks: true,
|
|
90
|
+
onConnectionError: "throw",
|
|
91
|
+
});
|
|
92
|
+
const tools = await client.getTools(slug);
|
|
93
|
+
return selectTools(label, config, tools);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Build the integration's gateway URL.
|
|
97
|
+
*
|
|
98
|
+
* The gateway path is appended to the configured API base rather than resolved
|
|
99
|
+
* against its origin, so a LangSmith reachable under a path prefix keeps it. That
|
|
100
|
+
* makes the base the whole prefix — `https://api.smith.langchain.com`, or
|
|
101
|
+
* `https://langsmith.acme.com/api` self-hosted — not a host to graft onto.
|
|
102
|
+
*/
|
|
103
|
+
export function gatewayUrl(slug, label) {
|
|
104
|
+
const base = envApiUrl() ?? DEFAULT_API_URL;
|
|
105
|
+
const origin = parseApiBase(base);
|
|
106
|
+
// A base with no host parses in some shapes (`http:/host`) but is not an API
|
|
107
|
+
// to connect to, so it is rejected alongside the ones that fail to parse.
|
|
108
|
+
if (!origin?.host) {
|
|
109
|
+
throw new Error(`${label}(...) could not build a tool server URL from "${base}". Set ` +
|
|
110
|
+
"LANGSMITH_ENDPOINT to your LangSmith API base URL, e.g. " +
|
|
111
|
+
`"${DEFAULT_API_URL}".`);
|
|
112
|
+
}
|
|
113
|
+
const prefix = origin.pathname.replace(/\/+$/, "");
|
|
114
|
+
const url = new URL(`${prefix}/v1/toolserver/servers/${slug}/mcp`, origin);
|
|
115
|
+
const agentId = trimmed(process.env.MDA_TOOLSERVER_AGENT_ID);
|
|
116
|
+
if (agentId) {
|
|
117
|
+
url.searchParams.set("agent_id", agentId);
|
|
118
|
+
}
|
|
119
|
+
return url.toString();
|
|
120
|
+
}
|
|
121
|
+
function parseApiBase(base) {
|
|
122
|
+
try {
|
|
123
|
+
return new URL(withScheme(base));
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Authenticate the call to the gateway.
|
|
131
|
+
*
|
|
132
|
+
* The key is read at load time rather than at declaration time so the same
|
|
133
|
+
* compiled project runs in any workspace, and it is required here rather than
|
|
134
|
+
* defaulted to empty so a missing key fails naming the fix instead of arriving
|
|
135
|
+
* as a 401 from LangSmith.
|
|
136
|
+
*/
|
|
137
|
+
export function gatewayHeaders(label) {
|
|
138
|
+
const apiKey = trimmed(process.env.LANGSMITH_API_KEY);
|
|
139
|
+
if (!apiKey) {
|
|
140
|
+
throw new Error(`${label}(...) needs a LangSmith API key to reach the tool server. Set ` +
|
|
141
|
+
"LANGSMITH_API_KEY in the deployment's environment.");
|
|
142
|
+
}
|
|
143
|
+
const headers = { "x-api-key": apiKey };
|
|
144
|
+
const workspaceId = trimmed(process.env.LANGCHAIN_WORKSPACE_ID);
|
|
145
|
+
if (workspaceId) {
|
|
146
|
+
headers["x-tenant-id"] = workspaceId;
|
|
147
|
+
}
|
|
148
|
+
return headers;
|
|
149
|
+
}
|
|
150
|
+
function envApiUrl() {
|
|
151
|
+
return (trimmed(process.env.LANGSMITH_ENDPOINT) ??
|
|
152
|
+
trimmed(process.env.LANGCHAIN_ENDPOINT));
|
|
153
|
+
}
|
|
154
|
+
/** Accept a bare host, since that is how an endpoint is often configured. */
|
|
155
|
+
function withScheme(base) {
|
|
156
|
+
return /^[a-z][a-z0-9+.-]*:\/\//i.test(base) ? base : `https://${base}`;
|
|
157
|
+
}
|
|
158
|
+
function trimmed(value) {
|
|
159
|
+
const trimmedValue = value?.trim();
|
|
160
|
+
return trimmedValue ? trimmedValue : undefined;
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=load.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load.js","sourceRoot":"","sources":["../../../src/connectors/toolserver/load.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAE/D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGnD,mEAAmE;AACnE,MAAM,eAAe,GAAG,iCAAiC,CAAC;AAE1D;;;;;;;;;;GAUG;AACH,MAAM,KAAK,GAAG,IAAI,OAAO,EAA8B,CAAC;AAExD;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACj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|
+
*
|
|
4
|
+
* `defineExtension(kind, options)` returns the factory an agent project calls —
|
|
5
|
+
* `connectors.slack({ … })`, `connectors.github({ … })`, `sandboxes.langsmith()`.
|
|
6
|
+
* The `kind` narrows which hooks the primitive may implement; argument parsing,
|
|
7
|
+
* branding, and manifest stamping are shared.
|
|
8
|
+
*
|
|
9
|
+
* Every kind declares its input through `args`, which takes a schema from any
|
|
10
|
+
* [Standard Schema](https://standardschema.dev) library — Zod, Valibot,
|
|
11
|
+
* ArkType — or a plain function where a schema does not fit. Validating through
|
|
12
|
+
* that interface keeps the vendor out of this package's dependencies, so a
|
|
13
|
+
* contributor picks whichever library they already use.
|
|
14
|
+
*
|
|
15
|
+
* This module is deliberately absent from the package barrel. Only the
|
|
16
|
+
* first-party namespaces in `namespaces.ts` contribute primitives, so an agent
|
|
17
|
+
* project cannot mount its own adapter, HTTP route, or sandbox backend into the
|
|
18
|
+
* managed runtime. Opening it up to third-party packages is a later step.
|
|
19
|
+
*
|
|
20
|
+
* The `auth`, `credentials`, and `connect` primitives are extended by plain
|
|
21
|
+
* factories rather than through here: they return inert configuration objects
|
|
22
|
+
* with no brand, hooks, or normalization to share. They gain an envelope when
|
|
23
|
+
* this API is exported and their inputs need validating at the boundary.
|
|
24
|
+
*/
|
|
25
|
+
import type { StandardSchemaV1 } from "@standard-schema/spec";
|
|
26
|
+
import type { ChannelTransport } from "./channels/runtime.js";
|
|
27
|
+
import { type Connector, type ConnectorRequirements, type ConnectorToolList, type EventsContext, type HttpContext, type SandboxContext, type ToolContext } from "./runtime/connector.js";
|
|
28
|
+
import { type SandboxOptions, type SandboxDefinition, type SandboxProviderClass } from "./sandbox.js";
|
|
29
|
+
/** The primitives that carry a shared construction envelope. */
|
|
30
|
+
export type ExtensionKind = "connector" | "sandbox";
|
|
31
|
+
/**
|
|
32
|
+
* How author input becomes the arguments a primitive is built from.
|
|
33
|
+
*
|
|
34
|
+
* Either a schema from any [Standard Schema](https://standardschema.dev)
|
|
35
|
+
* library — Zod, Valibot, ArkType, … — or a plain function for the cases a
|
|
36
|
+
* schema cannot express. Both run at module load, so misconfiguration surfaces
|
|
37
|
+
* at build or dev startup rather than mid-run. Defaults and coercions belong
|
|
38
|
+
* here too: whatever this produces is what the primitive carries.
|
|
39
|
+
*/
|
|
40
|
+
export type ExtensionArgs<TInput, TArgs> = StandardSchemaV1<TInput, TArgs> | ((input: TInput) => TArgs);
|
|
41
|
+
/** Shared by every kind: how the factory's input is validated, and its name. */
|
|
42
|
+
interface ExtensionEnvelope<TInput, TArgs> {
|
|
43
|
+
args: ExtensionArgs<TInput, TArgs>;
|
|
44
|
+
/**
|
|
45
|
+
* How the factory is spelled in an agent project, e.g. `"connectors.mcp"`.
|
|
46
|
+
* Prefixes validation errors, which is the only place an author sees it.
|
|
47
|
+
*/
|
|
48
|
+
label: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* A connector contributes tools, HTTP routes, sandbox provisioning, inbound
|
|
52
|
+
* events, and/or a named messaging surface. Hooks receive the built connector,
|
|
53
|
+
* so they can read the parsed arguments spread onto it.
|
|
54
|
+
*/
|
|
55
|
+
export interface ConnectorExtensionOptions<TInput, TArgs extends object, TKind extends string> extends ExtensionEnvelope<TInput, TArgs> {
|
|
56
|
+
/** Diagnostic label (e.g. `"mcp_servers"`). Mounts use the file-stem name. */
|
|
57
|
+
kind: TKind;
|
|
58
|
+
tools?(ctx: ToolContext, self: ConnectorInstance<TArgs, TKind>): ConnectorToolList | Promise<ConnectorToolList>;
|
|
59
|
+
http?(ctx: HttpContext, self: ConnectorInstance<TArgs, TKind>): void | Promise<void>;
|
|
60
|
+
sandbox?(ctx: SandboxContext, self: ConnectorInstance<TArgs, TKind>): void | Promise<void>;
|
|
61
|
+
events?(ctx: EventsContext, self: ConnectorInstance<TArgs, TKind>): Response | Promise<Response>;
|
|
62
|
+
messaging?(env: NodeJS.ProcessEnv, self: ConnectorInstance<TArgs, TKind>): ChannelTransport | undefined;
|
|
63
|
+
requirements?(name: string, self: ConnectorInstance<TArgs, TKind>): ConnectorRequirements;
|
|
64
|
+
}
|
|
65
|
+
/** The connector a `"connector"` extension builds: its brand, kind, and args. */
|
|
66
|
+
export type ConnectorInstance<TArgs extends object, TKind extends string> = Connector & TArgs & {
|
|
67
|
+
readonly kind: TKind;
|
|
68
|
+
};
|
|
69
|
+
/** A sandbox contributes the execution environment the agent's shell runs in. */
|
|
70
|
+
export interface SandboxExtensionOptions<TInput, TProvider extends SandboxProviderClass<any, any>> extends ExtensionEnvelope<TInput, SandboxOptions<TProvider>> {
|
|
71
|
+
/** Backend class MDA constructs with `new Provider({ sandbox, … })`. */
|
|
72
|
+
provider: TProvider;
|
|
73
|
+
}
|
|
74
|
+
export declare function defineExtension<TInput, TArgs extends object, TKind extends string>(kind: "connector", options: ConnectorExtensionOptions<TInput, TArgs, TKind>): (input: TInput) => ConnectorInstance<TArgs, TKind>;
|
|
75
|
+
export declare function defineExtension<TInput, TProvider extends SandboxProviderClass<any, any>>(kind: "sandbox", options: SandboxExtensionOptions<TInput, TProvider>): (input: TInput) => SandboxDefinition<TProvider>;
|
|
76
|
+
export {};
|
|
77
|
+
//# sourceMappingURL=extension.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,WAAW,EACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,oBAA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ible MDA primitives.
|
|
3
|
+
*
|
|
4
|
+
* `defineExtension(kind, options)` returns the factory an agent project calls —
|
|
5
|
+
* `connectors.slack({ … })`, `connectors.github({ … })`, `sandboxes.langsmith()`.
|
|
6
|
+
* The `kind` narrows which hooks the primitive may implement; argument parsing,
|
|
7
|
+
* branding, and manifest stamping are shared.
|
|
8
|
+
*
|
|
9
|
+
* Every kind declares its input through `args`, which takes a schema from any
|
|
10
|
+
* [Standard Schema](https://standardschema.dev) library — Zod, Valibot,
|
|
11
|
+
* ArkType — or a plain function where a schema does not fit. Validating through
|
|
12
|
+
* that interface keeps the vendor out of this package's dependencies, so a
|
|
13
|
+
* contributor picks whichever library they already use.
|
|
14
|
+
*
|
|
15
|
+
* This module is deliberately absent from the package barrel. Only the
|
|
16
|
+
* first-party namespaces in `namespaces.ts` contribute primitives, so an agent
|
|
17
|
+
* project cannot mount its own adapter, HTTP route, or sandbox backend into the
|
|
18
|
+
* managed runtime. Opening it up to third-party packages is a later step.
|
|
19
|
+
*
|
|
20
|
+
* The `auth`, `credentials`, and `connect` primitives are extended by plain
|
|
21
|
+
* factories rather than through here: they return inert configuration objects
|
|
22
|
+
* with no brand, hooks, or normalization to share. They gain an envelope when
|
|
23
|
+
* this API is exported and their inputs need validating at the boundary.
|
|
24
|
+
*/
|
|
25
|
+
import { CONNECTOR_BRAND, } from "./runtime/connector.js";
|
|
26
|
+
import { normalizeSandboxOptions, sandboxProviderKey, } from "./sandbox.js";
|
|
27
|
+
export function defineExtension(kind, options) {
|
|
28
|
+
switch (kind) {
|
|
29
|
+
case "connector":
|
|
30
|
+
return connectorExtension(options);
|
|
31
|
+
case "sandbox":
|
|
32
|
+
return sandboxExtension(options);
|
|
33
|
+
default:
|
|
34
|
+
throw new TypeError(`Unknown extension kind: ${String(kind)}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function connectorExtension(options) {
|
|
38
|
+
const parse = parser(options);
|
|
39
|
+
return (input) => {
|
|
40
|
+
const args = parse(input);
|
|
41
|
+
const self = { kind: options.kind, ...args };
|
|
42
|
+
// Hooks and the brand stay non-enumerable so a connector still spreads and
|
|
43
|
+
// serializes as its plain configuration.
|
|
44
|
+
hide(self, CONNECTOR_BRAND, true);
|
|
45
|
+
if (options.tools) {
|
|
46
|
+
const tools = options.tools;
|
|
47
|
+
hide(self, "tools", (ctx) => tools(ctx, self));
|
|
48
|
+
}
|
|
49
|
+
if (options.http) {
|
|
50
|
+
const http = options.http;
|
|
51
|
+
hide(self, "http", (ctx) => http(ctx, self));
|
|
52
|
+
}
|
|
53
|
+
if (options.sandbox) {
|
|
54
|
+
const sandbox = options.sandbox;
|
|
55
|
+
hide(self, "sandbox", (ctx) => sandbox(ctx, self));
|
|
56
|
+
}
|
|
57
|
+
if (options.events) {
|
|
58
|
+
const events = options.events;
|
|
59
|
+
hide(self, "events", (ctx) => events(ctx, self));
|
|
60
|
+
}
|
|
61
|
+
if (options.messaging) {
|
|
62
|
+
const messaging = options.messaging;
|
|
63
|
+
hide(self, "messaging", (env) => messaging(env, self));
|
|
64
|
+
}
|
|
65
|
+
if (options.requirements) {
|
|
66
|
+
const requirements = options.requirements;
|
|
67
|
+
hide(self, "requirements", (name) => requirements(name, self));
|
|
68
|
+
}
|
|
69
|
+
return self;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function sandboxExtension(options) {
|
|
73
|
+
const parse = parser(options);
|
|
74
|
+
return (input) => {
|
|
75
|
+
if (sandboxProviderKey(options.provider) !== "LangSmithSandbox") {
|
|
76
|
+
throw new TypeError("MDA only supports deepagents' LangSmithSandbox provider");
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
kind: "sandbox",
|
|
80
|
+
provider: options.provider,
|
|
81
|
+
// The managed-key rule is MDA policy, not the provider's, so it runs
|
|
82
|
+
// here rather than in each provider's `args`.
|
|
83
|
+
options: normalizeSandboxOptions(parse(input)),
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Resolve `args` into the function the factory runs on its input.
|
|
89
|
+
*
|
|
90
|
+
* A schema is validated through the Standard Schema interface, so the vendor
|
|
91
|
+
* (Zod, Valibot, …) never has to be a dependency of this package.
|
|
92
|
+
*/
|
|
93
|
+
function parser(options) {
|
|
94
|
+
const { args, label } = options;
|
|
95
|
+
if (typeof args === "function") {
|
|
96
|
+
return args;
|
|
97
|
+
}
|
|
98
|
+
const { validate } = args["~standard"];
|
|
99
|
+
return (input) => {
|
|
100
|
+
const result = validate(input);
|
|
101
|
+
if (result instanceof Promise) {
|
|
102
|
+
throw new TypeError(`${label}(...) needs a schema that validates synchronously, because ` +
|
|
103
|
+
"primitives are declared at module load. Drop the async refinement " +
|
|
104
|
+
"or validate inside a hook instead.");
|
|
105
|
+
}
|
|
106
|
+
if (result.issues) {
|
|
107
|
+
throw new Error(`${label}(...) ${describeIssues(result.issues)}`);
|
|
108
|
+
}
|
|
109
|
+
return result.value;
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/** Render schema issues as `path: message`, in the order the vendor reported. */
|
|
113
|
+
function describeIssues(issues) {
|
|
114
|
+
const lines = issues.map((issue) => {
|
|
115
|
+
const path = (issue.path ?? [])
|
|
116
|
+
.map((segment) => String(typeof segment === "object" ? segment.key : segment))
|
|
117
|
+
.join(".");
|
|
118
|
+
return path.length > 0 ? `${path}: ${issue.message}` : issue.message;
|
|
119
|
+
});
|
|
120
|
+
return lines.length === 1
|
|
121
|
+
? `received invalid configuration — ${lines[0]}.`
|
|
122
|
+
: `received invalid configuration:\n - ${lines.join("\n - ")}`;
|
|
123
|
+
}
|
|
124
|
+
function hide(target, key, value) {
|
|
125
|
+
Object.defineProperty(target, key, { value, enumerable: false });
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=extension.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;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AAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAC5D;aACA,IAAI,CAAC,GAAG,CAAC,CAAC;QACb,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC;IACvE,CAAC,CAAC,CAAC;IACH,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;QACvB,CAAC,CAAC,oCAAoC,KAAK,CAAC,CAAC,CAAC,GAAG;QACjD,CAAC,CAAC,wCAAwC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;AACrE,CAAC;AAED,SAAS,IAAI,CAAC,MAAc,EAAE,GAAoB,EAAE,KAAc;IAChE,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claim-name resolution shared by authoring validation and the runtime token
|
|
3
|
+
* mapper, so both agree on which claim supplies each envelope field.
|
|
4
|
+
*/
|
|
5
|
+
import type { ClaimMapping } from "./types.js";
|
|
6
|
+
/** The claim supplying the caller id, or `undefined` when none is mapped. */
|
|
7
|
+
export declare function userClaimName(mapping: ClaimMapping): string | undefined;
|
|
8
|
+
/** The claim supplying the active organization id, if any. */
|
|
9
|
+
export declare function organizationClaimName(mapping: ClaimMapping): string | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Normalize a `groups` claim value into a list.
|
|
12
|
+
*
|
|
13
|
+
* IdPs are inconsistent here: Auth0 and Okta send an array, Entra sends an array
|
|
14
|
+
* of object ids, and some proxies flatten to a delimited string. Accept all
|
|
15
|
+
* three rather than making authors pre-process the claim.
|
|
16
|
+
*/
|
|
17
|
+
export declare function normalizeGroups(value: unknown): string[];
|
|
18
|
+
//# sourceMappingURL=claims.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claims.d.ts","sourceRoot":"","sources":["../../src/identity/claims.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,6EAA6E;AAC7E,wBAAgB,aAAa,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,GAAG,SAAS,CAEvE;AAED,8DAA8D;AAC9D,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,YAAY,GACpB,MAAM,GAAG,SAAS,CAEpB;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,EAAE,CAaxD"}
|