managed-deepagents 0.0.3-dev.32 → 0.0.3-dev.34
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/connectors.d.ts +2 -7
- package/dist/connectors.d.ts.map +1 -1
- package/dist/connectors.js +1 -18
- package/dist/connectors.js.map +1 -1
- package/dist/index.d.ts +0 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/runtime/index.d.ts +0 -13
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +12 -39
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/types.d.ts +7 -23
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/types.d.ts +0 -9
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -12
- package/dist/connectors/langsmith.d.ts +0 -133
- package/dist/connectors/langsmith.d.ts.map +0 -1
- package/dist/connectors/langsmith.js +0 -262
- package/dist/connectors/langsmith.js.map +0 -1
- package/dist/identity.d.ts +0 -273
- package/dist/identity.d.ts.map +0 -1
- package/dist/identity.js +0 -358
- package/dist/identity.js.map +0 -1
- package/dist/runtime/auth.d.ts +0 -54
- package/dist/runtime/auth.d.ts.map +0 -1
- package/dist/runtime/auth.js +0 -191
- package/dist/runtime/auth.js.map +0 -1
- package/dist/runtime/connector.d.ts +0 -138
- package/dist/runtime/connector.d.ts.map +0 -1
- package/dist/runtime/connector.js +0 -82
- package/dist/runtime/connector.js.map +0 -1
- package/dist/runtime/credentials.d.ts +0 -60
- package/dist/runtime/credentials.d.ts.map +0 -1
- package/dist/runtime/credentials.js +0 -189
- package/dist/runtime/credentials.js.map +0 -1
- package/dist/runtime/identity-http.d.ts +0 -27
- package/dist/runtime/identity-http.d.ts.map +0 -1
- package/dist/runtime/identity-http.js +0 -150
- package/dist/runtime/identity-http.js.map +0 -1
- package/dist/runtime/identity-runtime.d.ts +0 -54
- package/dist/runtime/identity-runtime.d.ts.map +0 -1
- package/dist/runtime/identity-runtime.js +0 -151
- package/dist/runtime/identity-runtime.js.map +0 -1
- package/dist/runtime/langsmith-connector.d.ts +0 -113
- package/dist/runtime/langsmith-connector.d.ts.map +0 -1
- package/dist/runtime/langsmith-connector.js +0 -410
- package/dist/runtime/langsmith-connector.js.map +0 -1
- package/dist/runtime/managed-middleware.d.ts +0 -25
- package/dist/runtime/managed-middleware.d.ts.map +0 -1
- package/dist/runtime/managed-middleware.js +0 -76
- package/dist/runtime/managed-middleware.js.map +0 -1
- package/dist/runtime/managed-tools.d.ts +0 -61
- package/dist/runtime/managed-tools.d.ts.map +0 -1
- package/dist/runtime/managed-tools.js +0 -102
- package/dist/runtime/managed-tools.js.map +0 -1
- package/dist/runtime/validated-token.d.ts +0 -25
- package/dist/runtime/validated-token.d.ts.map +0 -1
- package/dist/runtime/validated-token.js +0 -260
- package/dist/runtime/validated-token.js.map +0 -1
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The managed connector protocol.
|
|
3
|
-
*
|
|
4
|
-
* A connector is any object carrying {@link CONNECTOR_BRAND} that knows how to
|
|
5
|
-
* contribute to a managed Deep Agent. MCP is one built-in implementation
|
|
6
|
-
* (contributes tools); the LangSmith connector is another (mounts HTTP routes).
|
|
7
|
-
* Third parties implement the same interface with their own `kind` — nothing
|
|
8
|
-
* about the built-ins is privileged.
|
|
9
|
-
*
|
|
10
|
-
* Discovery is name-agnostic: the CLI globs every module under `connectors/`,
|
|
11
|
-
* imports the single connector each one exposes as its default export, and hands
|
|
12
|
-
* them to {@link collectConnectors}, which validates the brand at build/startup.
|
|
13
|
-
* The two generated entrypoints each call the hook they care about — the agent
|
|
14
|
-
* graph calls {@link Connector.tools}, the managed HTTP app calls
|
|
15
|
-
* {@link Connector.http}.
|
|
16
|
-
*/
|
|
17
|
-
import type { IdentityConfig, RuntimeIdentity } from "../identity.js";
|
|
18
|
-
/**
|
|
19
|
-
* Realm-global brand marking a value as a managed connector. `Symbol.for` keeps
|
|
20
|
-
* the identity stable across duplicate module instances (e.g. a connector built
|
|
21
|
-
* against one copy of the package and collected by another).
|
|
22
|
-
*/
|
|
23
|
-
export declare const CONNECTOR_BRAND: unique symbol;
|
|
24
|
-
/**
|
|
25
|
-
* Build-time context handed to {@link Connector.tools} during agent-graph
|
|
26
|
-
* construction. Intentionally minimal for v0: a connector's tools close over
|
|
27
|
-
* their own configuration, and per-run identity flows through the existing
|
|
28
|
-
* runtime seam into each tool's `invoke`, not through here. Reserved for future
|
|
29
|
-
* deployment metadata.
|
|
30
|
-
*/
|
|
31
|
-
export type ToolContext = Record<string, never>;
|
|
32
|
-
/**
|
|
33
|
-
* Request context handed to {@link Connector.http} when the managed HTTP app is
|
|
34
|
-
* built. The connector receives its own namespaced sub-router (collision-safe),
|
|
35
|
-
* the declared identity for its own authorization logic, and a
|
|
36
|
-
* {@link HttpContext.requireIdentity} helper that fails closed.
|
|
37
|
-
*/
|
|
38
|
-
export interface HttpContext {
|
|
39
|
-
/**
|
|
40
|
-
* Router the connector mounts its routes on. Already namespaced under the
|
|
41
|
-
* connector, so routes cannot collide with identity/API routes or with other
|
|
42
|
-
* connectors. Routes registered here are **secure by default** — MDA resolves
|
|
43
|
-
* and enforces caller identity before the handler runs (see
|
|
44
|
-
* {@link HttpSubRouter}).
|
|
45
|
-
*/
|
|
46
|
-
readonly router: HttpSubRouter;
|
|
47
|
-
/** The declared identity, for the connector's own authorization decisions. */
|
|
48
|
-
readonly identity?: IdentityConfig;
|
|
49
|
-
/**
|
|
50
|
-
* Resolve the caller identity from the raw request, reusing the same resolver
|
|
51
|
-
* as the managed auth handler. Throws a 401-style error when identity is
|
|
52
|
-
* absent or invalid. Secured routes already resolve identity for you; use this
|
|
53
|
-
* only inside a {@link HttpSubRouter.public} route that wants optional or
|
|
54
|
-
* conditional authentication.
|
|
55
|
-
*/
|
|
56
|
-
requireIdentity(request: Request): Promise<RuntimeIdentity>;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* The router a connector uses to register routes. Structural so the managed app
|
|
60
|
-
* can back it with Hono without leaking the framework type into the contract.
|
|
61
|
-
*
|
|
62
|
-
* Routes registered on this router are **secure by default**: MDA resolves the
|
|
63
|
-
* caller's identity (401 on failure) before invoking the handler, and passes the
|
|
64
|
-
* frozen {@link RuntimeIdentity} as the handler's second argument. Authorization
|
|
65
|
-
* (scopes, constraints, ownership) remains the connector's job.
|
|
66
|
-
*
|
|
67
|
-
* A route that must be reachable without authentication (webhooks, health
|
|
68
|
-
* checks, public callbacks) has to opt out **explicitly** via
|
|
69
|
-
* {@link HttpSubRouter.public} — the unauthenticated surface is never the
|
|
70
|
-
* accidental default.
|
|
71
|
-
*/
|
|
72
|
-
export interface HttpSubRouter {
|
|
73
|
-
get(path: string, handler: SecuredRouteHandler): void;
|
|
74
|
-
post(path: string, handler: SecuredRouteHandler): void;
|
|
75
|
-
put(path: string, handler: SecuredRouteHandler): void;
|
|
76
|
-
delete(path: string, handler: SecuredRouteHandler): void;
|
|
77
|
-
/** Explicit opt-out: routes reachable without MDA identity enforcement. */
|
|
78
|
-
readonly public: PublicSubRouter;
|
|
79
|
-
}
|
|
80
|
-
/** The unauthenticated router surface, reached only via {@link HttpSubRouter.public}. */
|
|
81
|
-
export interface PublicSubRouter {
|
|
82
|
-
get(path: string, handler: PublicRouteHandler): void;
|
|
83
|
-
post(path: string, handler: PublicRouteHandler): void;
|
|
84
|
-
put(path: string, handler: PublicRouteHandler): void;
|
|
85
|
-
delete(path: string, handler: PublicRouteHandler): void;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Handler for a secured route. MDA has already resolved and enforced the
|
|
89
|
-
* caller's identity, which it passes as the second argument.
|
|
90
|
-
*/
|
|
91
|
-
export type SecuredRouteHandler = (request: Request, identity: RuntimeIdentity) => Response | Promise<Response>;
|
|
92
|
-
/** Handler for an explicitly public route. No identity is resolved by MDA. */
|
|
93
|
-
export type PublicRouteHandler = (request: Request) => Response | Promise<Response>;
|
|
94
|
-
/** Tools a connector contributes to the agent. Kept structural (`unknown[]`). */
|
|
95
|
-
export type ConnectorToolList = unknown[];
|
|
96
|
-
/**
|
|
97
|
-
* A managed connector. Implement at least one of {@link Connector.tools} or
|
|
98
|
-
* {@link Connector.http}; a connector implementing neither does nothing and is
|
|
99
|
-
* rejected by {@link collectConnectors}.
|
|
100
|
-
*/
|
|
101
|
-
export interface Connector {
|
|
102
|
-
readonly [CONNECTOR_BRAND]: true;
|
|
103
|
-
/** Diagnostic label, e.g. `"mcp_servers"` or `"langsmith"`. Not used for routing. */
|
|
104
|
-
readonly kind: string;
|
|
105
|
-
/** Contribute tools during agent-graph construction. MCP implements this. */
|
|
106
|
-
tools?(ctx: ToolContext): ConnectorToolList | Promise<ConnectorToolList>;
|
|
107
|
-
/** Mount HTTP routes during managed-app construction. LangSmith implements this. */
|
|
108
|
-
http?(ctx: HttpContext): void | Promise<void>;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Run the `tools` hook of every connector that implements it and concatenate the
|
|
112
|
-
* results, preserving connector order. Connectors without a `tools` hook (e.g.
|
|
113
|
-
* HTTP-only connectors) contribute nothing.
|
|
114
|
-
*/
|
|
115
|
-
export declare function loadConnectorTools(connectors: readonly Connector[], ctx?: ToolContext): Promise<unknown[]>;
|
|
116
|
-
/** A discovered `connectors/` module paired with its source path for diagnostics. */
|
|
117
|
-
export interface DiscoveredConnectorModule {
|
|
118
|
-
/** Project-relative path of the module, used in error messages. */
|
|
119
|
-
readonly source: string;
|
|
120
|
-
/** The imported module namespace; its default export is the connector. */
|
|
121
|
-
readonly module: {
|
|
122
|
-
default?: unknown;
|
|
123
|
-
} & Record<string, unknown>;
|
|
124
|
-
}
|
|
125
|
-
/** Narrow an arbitrary value to a {@link Connector} by its brand and hooks. */
|
|
126
|
-
export declare function isConnector(value: unknown): value is Connector;
|
|
127
|
-
/**
|
|
128
|
-
* Validate and collect the connectors discovered under `connectors/`.
|
|
129
|
-
*
|
|
130
|
-
* Each module must expose exactly one connector as its default export. A module
|
|
131
|
-
* whose default export is missing or is not a branded connector is a hard build
|
|
132
|
-
* error — the file was placed under `connectors/` on purpose, so a silent no-op
|
|
133
|
-
* would be the worst outcome. A connector implementing neither hook is likewise
|
|
134
|
-
* rejected. Duplicate connector objects (re-exported from two modules) are
|
|
135
|
-
* de-duplicated by identity.
|
|
136
|
-
*/
|
|
137
|
-
export declare function collectConnectors(modules: readonly DiscoveredConnectorModule[]): Connector[];
|
|
138
|
-
//# sourceMappingURL=connector.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connector.d.ts","sourceRoot":"","sources":["../../src/runtime/connector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtE;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,OAAO,MAAoC,CAAC;AAE1E;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;;;OAMG;IACH,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,8EAA8E;IAC9E,QAAQ,CAAC,QAAQ,CAAC,EAAE,cAAc,CAAC;IACnC;;;;;;OAMG;IACH,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CAC7D;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACtD,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACvD,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAm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;CAC/C;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,SAAS,SAAS,EAAE,EAChC,GAAG,GAAE,WAAgB,GACpB,OAAO,CAAC,OAAO,EAAE,CAAC,CAQpB;AAED,qFAAqF;AACrF,MAAM,WAAW,yBAAyB;IACxC,mEAAmE;IACnE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,0EAA0E;IAC1E,QAAQ,CAAC,MAAM,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClE;AAED,+EAA+E;AAC/E,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAM9D;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,SAAS,yBAAyB,EAAE,GAC5C,SAAS,EAAE,CAoCb"}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The managed connector protocol.
|
|
3
|
-
*
|
|
4
|
-
* A connector is any object carrying {@link CONNECTOR_BRAND} that knows how to
|
|
5
|
-
* contribute to a managed Deep Agent. MCP is one built-in implementation
|
|
6
|
-
* (contributes tools); the LangSmith connector is another (mounts HTTP routes).
|
|
7
|
-
* Third parties implement the same interface with their own `kind` — nothing
|
|
8
|
-
* about the built-ins is privileged.
|
|
9
|
-
*
|
|
10
|
-
* Discovery is name-agnostic: the CLI globs every module under `connectors/`,
|
|
11
|
-
* imports the single connector each one exposes as its default export, and hands
|
|
12
|
-
* them to {@link collectConnectors}, which validates the brand at build/startup.
|
|
13
|
-
* The two generated entrypoints each call the hook they care about — the agent
|
|
14
|
-
* graph calls {@link Connector.tools}, the managed HTTP app calls
|
|
15
|
-
* {@link Connector.http}.
|
|
16
|
-
*/
|
|
17
|
-
/**
|
|
18
|
-
* Realm-global brand marking a value as a managed connector. `Symbol.for` keeps
|
|
19
|
-
* the identity stable across duplicate module instances (e.g. a connector built
|
|
20
|
-
* against one copy of the package and collected by another).
|
|
21
|
-
*/
|
|
22
|
-
export const CONNECTOR_BRAND = Symbol.for("mda.connector");
|
|
23
|
-
/**
|
|
24
|
-
* Run the `tools` hook of every connector that implements it and concatenate the
|
|
25
|
-
* results, preserving connector order. Connectors without a `tools` hook (e.g.
|
|
26
|
-
* HTTP-only connectors) contribute nothing.
|
|
27
|
-
*/
|
|
28
|
-
export async function loadConnectorTools(connectors, ctx = {}) {
|
|
29
|
-
const tools = [];
|
|
30
|
-
for (const connector of connectors) {
|
|
31
|
-
if (typeof connector.tools === "function") {
|
|
32
|
-
tools.push(...(await connector.tools(ctx)));
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return tools;
|
|
36
|
-
}
|
|
37
|
-
/** Narrow an arbitrary value to a {@link Connector} by its brand and hooks. */
|
|
38
|
-
export function isConnector(value) {
|
|
39
|
-
if (typeof value !== "object" || value === null) {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
const branded = value[CONNECTOR_BRAND];
|
|
43
|
-
return branded === true;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Validate and collect the connectors discovered under `connectors/`.
|
|
47
|
-
*
|
|
48
|
-
* Each module must expose exactly one connector as its default export. A module
|
|
49
|
-
* whose default export is missing or is not a branded connector is a hard build
|
|
50
|
-
* error — the file was placed under `connectors/` on purpose, so a silent no-op
|
|
51
|
-
* would be the worst outcome. A connector implementing neither hook is likewise
|
|
52
|
-
* rejected. Duplicate connector objects (re-exported from two modules) are
|
|
53
|
-
* de-duplicated by identity.
|
|
54
|
-
*/
|
|
55
|
-
export function collectConnectors(modules) {
|
|
56
|
-
const collected = [];
|
|
57
|
-
const seen = new Set();
|
|
58
|
-
for (const { source, module } of modules) {
|
|
59
|
-
const candidate = module.default;
|
|
60
|
-
if (candidate === undefined) {
|
|
61
|
-
throw new Error(`${source} exports no default connector. A file under connectors/ must ` +
|
|
62
|
-
`\`export default\` exactly one connector (e.g. ` +
|
|
63
|
-
`\`export default defineMcpServers(...)\`). Move helpers outside connectors/.`);
|
|
64
|
-
}
|
|
65
|
-
if (!isConnector(candidate)) {
|
|
66
|
-
throw new Error(`${source} default export is not a managed connector. Export the result ` +
|
|
67
|
-
`of a connector builder such as \`defineMcpServers(...)\`.`);
|
|
68
|
-
}
|
|
69
|
-
if (typeof candidate.tools !== "function" &&
|
|
70
|
-
typeof candidate.http !== "function") {
|
|
71
|
-
throw new Error(`${source} default export (kind "${candidate.kind}") implements neither ` +
|
|
72
|
-
`\`tools\` nor \`http\` and would do nothing.`);
|
|
73
|
-
}
|
|
74
|
-
if (seen.has(candidate)) {
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
seen.add(candidate);
|
|
78
|
-
collected.push(candidate);
|
|
79
|
-
}
|
|
80
|
-
return collected;
|
|
81
|
-
}
|
|
82
|
-
//# sourceMappingURL=connector.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connector.js","sourceRoot":"","sources":["../../src/runtime/connector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAkB,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;AAqG1E;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,UAAgC,EAChC,MAAmB,EAAE;IAErB,MAAM,KAAK,GAAc,EAAE,CAAC;IAC5B,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,IAAI,OAAO,SAAS,CAAC,KAAK,KAAK,UAAU,EAAE,CAAC;YAC1C,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAUD,+EAA+E;AAC/E,M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CAAC"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import type { CredentialTarget, IdentityConfig, ResolvedCredential, RuntimeIdentity } from "../identity.js";
|
|
2
|
-
/**
|
|
3
|
-
* Component 5 — Credentials, custom mode (`scoping.credentials: "custom"`, §7.2).
|
|
4
|
-
*
|
|
5
|
-
* The escape hatch Agent Auth can't cover: bespoke per-actor credential minting
|
|
6
|
-
* via an in-process resolver callback or a hosted token-exchange endpoint. It
|
|
7
|
-
* runs in the worker (not the shared ingress auth handler), applies the output
|
|
8
|
-
* to downstream calls, and caches per `(actor, tenant, target)` until the
|
|
9
|
-
* credential's `expiresAt`. Secrets live only in this in-memory cache keyed by
|
|
10
|
-
* identity — never in thread state or traces (§7.2, §8, identity-final §10).
|
|
11
|
-
*
|
|
12
|
-
* The managed modes (`agent`/`actor`) route to Agent Auth
|
|
13
|
-
* (`@langchain/auth`/`langchain-auth`, §7.1) and are wired separately; this
|
|
14
|
-
* module is only the custom path.
|
|
15
|
-
*/
|
|
16
|
-
/** Env var holding the HMAC secret MDA signs the endpoint assertion with. */
|
|
17
|
-
export declare const CREDENTIAL_SIGNING_SECRET_ENV = "MDA_TOKEN_EXCHANGE_SECRET";
|
|
18
|
-
/** Per-call options for {@link CredentialsProvider.for}. */
|
|
19
|
-
export interface CredentialForOptions {
|
|
20
|
-
/** Skip the cache and force a fresh mint (e.g. after a downstream 401). */
|
|
21
|
-
forceRefresh?: boolean;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* The per-run credential surface a tool receives as `runtime.credentials`.
|
|
25
|
-
* Tools call `runtime.credentials.for(target)` and attach the returned headers
|
|
26
|
-
* to their downstream request.
|
|
27
|
-
*/
|
|
28
|
-
export interface CredentialsProvider {
|
|
29
|
-
for(target: CredentialTarget, options?: CredentialForOptions): Promise<ResolvedCredential>;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Side effects the executor depends on, injectable so resolution is
|
|
33
|
-
* deterministic under test (no real clock, network, or signing key).
|
|
34
|
-
*/
|
|
35
|
-
export interface CredentialDeps {
|
|
36
|
-
fetch: typeof fetch;
|
|
37
|
-
now: () => number;
|
|
38
|
-
/** Signs the assertion MDA presents to a hosted token-exchange endpoint. */
|
|
39
|
-
signAssertion: (identity: RuntimeIdentity, target: CredentialTarget) => Promise<string>;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* TTL cache for resolved credentials, keyed by `(actor, tenant, target)` so
|
|
43
|
-
* per-repo/per-install tokens never collide. Kept out of thread state; entries
|
|
44
|
-
* expire at the credential's `expiresAt`.
|
|
45
|
-
*/
|
|
46
|
-
export declare class CredentialCache {
|
|
47
|
-
private readonly entries;
|
|
48
|
-
get(key: string, nowMs: number): ResolvedCredential | undefined;
|
|
49
|
-
set(key: string, value: ResolvedCredential): void;
|
|
50
|
-
clear(): void;
|
|
51
|
-
}
|
|
52
|
-
/** Clear the process-level credential cache. Test-only. */
|
|
53
|
-
export declare function clearCredentialCacheForTests(): void;
|
|
54
|
-
/**
|
|
55
|
-
* Build the `runtime.credentials` provider for a run, or `undefined` when the
|
|
56
|
-
* deployment isn't in custom-credentials mode. The provider is bound to the
|
|
57
|
-
* run's resolved identity; every `for(target)` call is scoped to that actor.
|
|
58
|
-
*/
|
|
59
|
-
export declare function createCredentialsProvider(cfg: IdentityConfig, identity: RuntimeIdentity | undefined, deps?: Partial<CredentialDeps>, cache?: CredentialCache): CredentialsProvider | undefined;
|
|
60
|
-
//# sourceMappingURL=credentials.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../src/runtime/credentials.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,eAAe,EAChB,MAAM,gBAAgB,CAAC;AAExB;;;;;;;;;;;;;GAaG;AAEH,6EAA6E;AAC7E,eAAO,MAAM,6BAA6B,8BAA8B,CAAC;AAKzE,4DAA4D;AAC5D,MAAM,WAAW,oBAAoB;IACnC,2EAA2E;IAC3E,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,GAAG,CACD,MAAM,EAAE,gBAAgB,EACxB,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAChC;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,OAAO,KAAK,CAAC;IACpB,GAAG,EAAE,MAAM,MAAM,CAAC;IAClB,4EAA4E;IAC5E,aAAa,EAAE,CACb,QAAQ,EAAE,eAAe,EACzB,MAAM,EAAE,gBAAgB,KACrB,OAAO,CAAC,MAAM,CAAC,CAAC;CACtB;AAQD;;;;GAIG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiC;IAEzD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS;IAY/D,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,kBAAkB,GAAG,IAAI;IASjD,KAAK,IAAI,IAAI;CAGd;AAKD,2DAA2D;AAC3D,wBAAgB,4BAA4B,IAAI,IAAI,CAEnD;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,cAAc,EACnB,QAAQ,EAAE,eAAe,GAAG,SAAS,EACrC,IAAI,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,EAC9B,KAAK,GAAE,eAA8B,GACpC,mBAAmB,GAAG,SAAS,CA8BjC"}
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import { SignJWT } from "jose";
|
|
2
|
-
/**
|
|
3
|
-
* Component 5 — Credentials, custom mode (`scoping.credentials: "custom"`, §7.2).
|
|
4
|
-
*
|
|
5
|
-
* The escape hatch Agent Auth can't cover: bespoke per-actor credential minting
|
|
6
|
-
* via an in-process resolver callback or a hosted token-exchange endpoint. It
|
|
7
|
-
* runs in the worker (not the shared ingress auth handler), applies the output
|
|
8
|
-
* to downstream calls, and caches per `(actor, tenant, target)` until the
|
|
9
|
-
* credential's `expiresAt`. Secrets live only in this in-memory cache keyed by
|
|
10
|
-
* identity — never in thread state or traces (§7.2, §8, identity-final §10).
|
|
11
|
-
*
|
|
12
|
-
* The managed modes (`agent`/`actor`) route to Agent Auth
|
|
13
|
-
* (`@langchain/auth`/`langchain-auth`, §7.1) and are wired separately; this
|
|
14
|
-
* module is only the custom path.
|
|
15
|
-
*/
|
|
16
|
-
/** Env var holding the HMAC secret MDA signs the endpoint assertion with. */
|
|
17
|
-
export const CREDENTIAL_SIGNING_SECRET_ENV = "MDA_TOKEN_EXCHANGE_SECRET";
|
|
18
|
-
/** How long a signed endpoint assertion is valid, in seconds. */
|
|
19
|
-
const ASSERTION_TTL_SECONDS = 60;
|
|
20
|
-
/**
|
|
21
|
-
* TTL cache for resolved credentials, keyed by `(actor, tenant, target)` so
|
|
22
|
-
* per-repo/per-install tokens never collide. Kept out of thread state; entries
|
|
23
|
-
* expire at the credential's `expiresAt`.
|
|
24
|
-
*/
|
|
25
|
-
export class CredentialCache {
|
|
26
|
-
entries = new Map();
|
|
27
|
-
get(key, nowMs) {
|
|
28
|
-
const hit = this.entries.get(key);
|
|
29
|
-
if (!hit) {
|
|
30
|
-
return undefined;
|
|
31
|
-
}
|
|
32
|
-
if (hit.expiresAtMs !== undefined && nowMs >= hit.expiresAtMs) {
|
|
33
|
-
this.entries.delete(key);
|
|
34
|
-
return undefined;
|
|
35
|
-
}
|
|
36
|
-
return hit.value;
|
|
37
|
-
}
|
|
38
|
-
set(key, value) {
|
|
39
|
-
let expiresAtMs;
|
|
40
|
-
if (value.expiresAt) {
|
|
41
|
-
const parsed = Date.parse(value.expiresAt);
|
|
42
|
-
expiresAtMs = Number.isNaN(parsed) ? undefined : parsed;
|
|
43
|
-
}
|
|
44
|
-
this.entries.set(key, { value, expiresAtMs });
|
|
45
|
-
}
|
|
46
|
-
clear() {
|
|
47
|
-
this.entries.clear();
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
/** Process-level cache shared across runs for the lifetime of the deployment. */
|
|
51
|
-
const defaultCache = new CredentialCache();
|
|
52
|
-
/** Clear the process-level credential cache. Test-only. */
|
|
53
|
-
export function clearCredentialCacheForTests() {
|
|
54
|
-
defaultCache.clear();
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Build the `runtime.credentials` provider for a run, or `undefined` when the
|
|
58
|
-
* deployment isn't in custom-credentials mode. The provider is bound to the
|
|
59
|
-
* run's resolved identity; every `for(target)` call is scoped to that actor.
|
|
60
|
-
*/
|
|
61
|
-
export function createCredentialsProvider(cfg, identity, deps, cache = defaultCache) {
|
|
62
|
-
if (cfg.scoping.credentials !== "custom" || !cfg.credentials) {
|
|
63
|
-
return undefined;
|
|
64
|
-
}
|
|
65
|
-
const resolved = {
|
|
66
|
-
fetch: deps?.fetch ?? fetch,
|
|
67
|
-
now: deps?.now ?? (() => Date.now()),
|
|
68
|
-
signAssertion: deps?.signAssertion ?? defaultSignAssertion,
|
|
69
|
-
};
|
|
70
|
-
return {
|
|
71
|
-
async for(target, options) {
|
|
72
|
-
if (!identity) {
|
|
73
|
-
throw new Error("runtime.credentials.for(...) requires a resolved identity, but none " +
|
|
74
|
-
"was available for this run.");
|
|
75
|
-
}
|
|
76
|
-
const key = cacheKey(identity, target);
|
|
77
|
-
if (!options?.forceRefresh) {
|
|
78
|
-
const hit = cache.get(key, resolved.now());
|
|
79
|
-
if (hit) {
|
|
80
|
-
return hit;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
// Fail-closed: a resolver/endpoint error propagates and nothing is cached.
|
|
84
|
-
const out = await resolveCredential(cfg, identity, target, resolved);
|
|
85
|
-
cache.set(key, out);
|
|
86
|
-
return out;
|
|
87
|
-
},
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
async function resolveCredential(cfg, identity, target, deps) {
|
|
91
|
-
const creds = cfg.credentials;
|
|
92
|
-
if (!creds) {
|
|
93
|
-
throw new Error("No credentials resolver is configured for this deployment.");
|
|
94
|
-
}
|
|
95
|
-
if ("resolve" in creds) {
|
|
96
|
-
const out = await creds.resolve({ identity, target });
|
|
97
|
-
return normalizeResolved(out, "resolver");
|
|
98
|
-
}
|
|
99
|
-
const assertion = await deps.signAssertion(identity, target);
|
|
100
|
-
return callTokenExchange(creds.endpoint.url, assertion, deps);
|
|
101
|
-
}
|
|
102
|
-
async function callTokenExchange(url, assertion, deps) {
|
|
103
|
-
const response = await deps.fetch(url, {
|
|
104
|
-
method: "POST",
|
|
105
|
-
headers: {
|
|
106
|
-
"content-type": "application/json",
|
|
107
|
-
authorization: `Bearer ${assertion}`,
|
|
108
|
-
},
|
|
109
|
-
body: JSON.stringify({ assertion }),
|
|
110
|
-
});
|
|
111
|
-
if (!response.ok) {
|
|
112
|
-
throw new Error(`Credential token-exchange endpoint ${url} responded ${response.status}.`);
|
|
113
|
-
}
|
|
114
|
-
return normalizeResolved(await response.json(), `endpoint ${url}`);
|
|
115
|
-
}
|
|
116
|
-
async function defaultSignAssertion(identity, target) {
|
|
117
|
-
const secret = process.env[CREDENTIAL_SIGNING_SECRET_ENV];
|
|
118
|
-
if (!secret) {
|
|
119
|
-
throw new Error(`A hosted credential endpoint requires a signing secret. Set ` +
|
|
120
|
-
`${CREDENTIAL_SIGNING_SECRET_ENV} in the deployment environment.`);
|
|
121
|
-
}
|
|
122
|
-
const issuedAt = Math.floor(Date.now() / 1000);
|
|
123
|
-
return new SignJWT({
|
|
124
|
-
actor_id: identity.actor.id,
|
|
125
|
-
actor_type: identity.actor.type,
|
|
126
|
-
tenant_id: identity.tenant?.id,
|
|
127
|
-
target: { kind: target.kind, name: target.name, intent: target.intent },
|
|
128
|
-
})
|
|
129
|
-
.setProtectedHeader({ alg: "HS256" })
|
|
130
|
-
.setSubject(identity.actor.id)
|
|
131
|
-
.setIssuedAt(issuedAt)
|
|
132
|
-
.setExpirationTime(issuedAt + ASSERTION_TTL_SECONDS)
|
|
133
|
-
.sign(new TextEncoder().encode(secret));
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* The cache key that discriminates a minted credential: the actor + tenant it
|
|
137
|
-
* belongs to, plus the target's kind/name/intent/thread and metadata (§7.2).
|
|
138
|
-
*/
|
|
139
|
-
function cacheKey(identity, target) {
|
|
140
|
-
return stableStringify([
|
|
141
|
-
identity.actor.id,
|
|
142
|
-
identity.tenant?.id ?? null,
|
|
143
|
-
target.kind,
|
|
144
|
-
target.name,
|
|
145
|
-
target.intent ?? null,
|
|
146
|
-
target.threadId ?? null,
|
|
147
|
-
target.metadata ?? null,
|
|
148
|
-
]);
|
|
149
|
-
}
|
|
150
|
-
/** Deterministic JSON with object keys sorted, so the cache key is stable. */
|
|
151
|
-
function stableStringify(value) {
|
|
152
|
-
if (value === null || typeof value !== "object") {
|
|
153
|
-
return JSON.stringify(value) ?? "null";
|
|
154
|
-
}
|
|
155
|
-
if (Array.isArray(value)) {
|
|
156
|
-
return `[${value.map(stableStringify).join(",")}]`;
|
|
157
|
-
}
|
|
158
|
-
const obj = value;
|
|
159
|
-
return `{${Object.keys(obj)
|
|
160
|
-
.sort()
|
|
161
|
-
.map((key) => `${JSON.stringify(key)}:${stableStringify(obj[key])}`)
|
|
162
|
-
.join(",")}}`;
|
|
163
|
-
}
|
|
164
|
-
/** Validate a resolver/endpoint result into a {@link ResolvedCredential}. */
|
|
165
|
-
function normalizeResolved(value, sourceLabel) {
|
|
166
|
-
if (!value || typeof value !== "object") {
|
|
167
|
-
throw new Error(`Credential ${sourceLabel} returned a non-object result.`);
|
|
168
|
-
}
|
|
169
|
-
const { headers, expiresAt } = value;
|
|
170
|
-
if (!headers || typeof headers !== "object" || Array.isArray(headers)) {
|
|
171
|
-
throw new Error(`Credential ${sourceLabel} result is missing a headers object.`);
|
|
172
|
-
}
|
|
173
|
-
const normalizedHeaders = {};
|
|
174
|
-
for (const [name, headerValue] of Object.entries(headers)) {
|
|
175
|
-
if (typeof headerValue !== "string") {
|
|
176
|
-
throw new Error(`Credential ${sourceLabel} header "${name}" must be a string.`);
|
|
177
|
-
}
|
|
178
|
-
normalizedHeaders[name] = headerValue;
|
|
179
|
-
}
|
|
180
|
-
const result = { headers: normalizedHeaders };
|
|
181
|
-
if (expiresAt !== undefined) {
|
|
182
|
-
if (typeof expiresAt !== "string") {
|
|
183
|
-
throw new Error(`Credential ${sourceLabel} \`expiresAt\` must be an ISO string.`);
|
|
184
|
-
}
|
|
185
|
-
result.expiresAt = expiresAt;
|
|
186
|
-
}
|
|
187
|
-
return result;
|
|
188
|
-
}
|
|
189
|
-
//# sourceMappingURL=credentials.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../../src/runtime/credentials.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAS/B;;;;;;;;;;;;;GAaG;AAEH,6EAA6E;AAC7E,MAAM,CAAC,MAAM,6BAA6B,GAAG,2BAA2B,CAAC;AAEzE,iEAAiE;AACjE,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAwCjC;;;;GAIG;AACH,MAAM,OAAO,eAAe;IACT,OAAO,GAAG,IAAI,GAAG,EAAsB,CAAC;IAEzD,GAAG,CAAC,GAAW,EAAE,KAAa;QAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,IAAI,GAAG,CAAC,WAAW,KAAK,SAAS,IAAI,KAAK,IAAI,GAAG,CAAC,WAAW,EAAE,CAAC;YAC9D,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACzB,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,O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 +0,0 @@
|
|
|
1
|
-
import { Hono } from "hono";
|
|
2
|
-
import type { IdentityDefinition } from "../identity.js";
|
|
3
|
-
import type { Connector } from "./connector.js";
|
|
4
|
-
/** Inputs the managed HTTP app is built from. */
|
|
5
|
-
export interface ManagedHttpAppInputs {
|
|
6
|
-
/** The declared identity, if the project opts into managed identity. */
|
|
7
|
-
identity?: IdentityDefinition;
|
|
8
|
-
/** Discovered connectors; those implementing `http` mount routes. */
|
|
9
|
-
connectors?: Connector[];
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Build the single managed HTTP app mounted via `langgraph.json` `http.app`.
|
|
13
|
-
*
|
|
14
|
-
* It layers two concerns onto the built-in LangGraph routes:
|
|
15
|
-
* - **identity** — public guest issuance (`POST /identity/guest`) when the
|
|
16
|
-
* declared identity enables a guest provider;
|
|
17
|
-
* - **connectors** — each connector implementing `http` gets a sub-router
|
|
18
|
-
* namespaced under `/connectors/{kind}` and mounts its own routes.
|
|
19
|
-
*
|
|
20
|
-
* Connector routes are **secure by default**: MDA resolves and enforces the
|
|
21
|
-
* caller's identity before the handler runs, and a route must opt out of
|
|
22
|
-
* authentication explicitly (`router.public.*`). The connector HTTP surface is
|
|
23
|
-
* logged at construction so the (especially unauthenticated) routes are never
|
|
24
|
-
* invisible.
|
|
25
|
-
*/
|
|
26
|
-
export declare function buildManagedHttpApp(inputs: ManagedHttpAppInputs): Hono;
|
|
27
|
-
//# sourceMappingURL=identity-http.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"identity-http.d.ts","sourceRoot":"","sources":["../../src/runtime/identity-http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,KAAK,EAAkB,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEzE,OAAO,KAAK,EACV,SAAS,EAKV,MAAM,gBAAgB,CAAC;AAGxB,iDAAiD;AACjD,MAAM,WAAW,oBAAoB;IACnC,wEAAwE;IACxE,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B,qEAAqE;IACrE,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC;CAC1B;AAuBD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,oBAAoB,GAAG,IAAI,CAgBtE"}
|