managed-deepagents 0.6.2-dev.7 → 0.6.2-dev.9

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.
Files changed (72) hide show
  1. package/dist/channels/schedule-delivery.d.ts +2 -0
  2. package/dist/channels/schedule-delivery.d.ts.map +1 -1
  3. package/dist/channels/schedule-delivery.js +40 -4
  4. package/dist/channels/schedule-delivery.js.map +1 -1
  5. package/dist/channels/trigger/client.d.ts +1 -0
  6. package/dist/channels/trigger/client.d.ts.map +1 -1
  7. package/dist/channels/trigger/client.js +19 -8
  8. package/dist/channels/trigger/client.js.map +1 -1
  9. package/dist/channels/trigger/types.d.ts +1 -1
  10. package/dist/channels/trigger/types.d.ts.map +1 -1
  11. package/dist/connectors/mcp/index.d.ts +89 -29
  12. package/dist/connectors/mcp/index.d.ts.map +1 -1
  13. package/dist/connectors/mcp/index.js +50 -227
  14. package/dist/connectors/mcp/index.js.map +1 -1
  15. package/dist/connectors/mcp/load.d.ts +12 -0
  16. package/dist/connectors/mcp/load.d.ts.map +1 -0
  17. package/dist/connectors/mcp/load.js +122 -0
  18. package/dist/connectors/mcp/load.js.map +1 -0
  19. package/dist/connectors/tool-selection.d.ts +18 -9
  20. package/dist/connectors/tool-selection.d.ts.map +1 -1
  21. package/dist/connectors/tool-selection.js +58 -32
  22. package/dist/connectors/tool-selection.js.map +1 -1
  23. package/dist/identity/index.d.ts +1 -1
  24. package/dist/identity/index.d.ts.map +1 -1
  25. package/dist/identity/index.js.map +1 -1
  26. package/dist/identity/types.d.ts +5 -45
  27. package/dist/identity/types.d.ts.map +1 -1
  28. package/dist/index.d.ts +3 -6
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +0 -1
  31. package/dist/index.js.map +1 -1
  32. package/dist/runtime/auth.d.ts +4 -9
  33. package/dist/runtime/auth.d.ts.map +1 -1
  34. package/dist/runtime/auth.js.map +1 -1
  35. package/dist/runtime/http.d.ts +1 -1
  36. package/dist/runtime/http.d.ts.map +1 -1
  37. package/dist/runtime/http.js.map +1 -1
  38. package/dist/runtime/identity-runtime.d.ts +5 -55
  39. package/dist/runtime/identity-runtime.d.ts.map +1 -1
  40. package/dist/runtime/identity-runtime.js +0 -107
  41. package/dist/runtime/identity-runtime.js.map +1 -1
  42. package/dist/runtime/index.d.ts.map +1 -1
  43. package/dist/runtime/index.js +7 -12
  44. package/dist/runtime/index.js.map +1 -1
  45. package/dist/runtime/managed-middleware.d.ts +2 -2
  46. package/dist/runtime/managed-middleware.js +6 -6
  47. package/dist/runtime/managed-tools.d.ts +15 -19
  48. package/dist/runtime/managed-tools.d.ts.map +1 -1
  49. package/dist/runtime/managed-tools.js +13 -14
  50. package/dist/runtime/managed-tools.js.map +1 -1
  51. package/dist/runtime/types.d.ts +2 -2
  52. package/package.json +7 -7
  53. package/dist/agent-auth.d.ts +0 -104
  54. package/dist/agent-auth.d.ts.map +0 -1
  55. package/dist/agent-auth.js +0 -224
  56. package/dist/agent-auth.js.map +0 -1
  57. package/dist/connectors/mcp/schema.d.ts +0 -12
  58. package/dist/connectors/mcp/schema.d.ts.map +0 -1
  59. package/dist/connectors/mcp/schema.js +0 -55
  60. package/dist/connectors/mcp/schema.js.map +0 -1
  61. package/dist/connectors/mcp/types.d.ts +0 -62
  62. package/dist/connectors/mcp/types.d.ts.map +0 -1
  63. package/dist/connectors/mcp/types.js +0 -2
  64. package/dist/connectors/mcp/types.js.map +0 -1
  65. package/dist/credential-gate.d.ts +0 -39
  66. package/dist/credential-gate.d.ts.map +0 -1
  67. package/dist/credential-gate.js +0 -209
  68. package/dist/credential-gate.js.map +0 -1
  69. package/dist/credentials.d.ts +0 -88
  70. package/dist/credentials.d.ts.map +0 -1
  71. package/dist/credentials.js +0 -246
  72. package/dist/credentials.js.map +0 -1
@@ -3,8 +3,6 @@ import { LazyManagedSandboxBackend } from "./backend.js";
3
3
  import { loadConnectorTools } from "./connector.js";
4
4
  import { createScheduleDeliveryMiddleware } from "../channels/schedule-delivery.js";
5
5
  import { createChannelResponseFormatMiddleware } from "../channels/response-format.js";
6
- import { createCredentialGateMiddleware } from "../credential-gate.js";
7
- import { mcpCredentialConsumers } from "../connectors/mcp/index.js";
8
6
  import { wrapMiddlewareWithManagedRuntime, } from "./managed-middleware.js";
9
7
  import { wrapToolsWithManagedRuntime, } from "./managed-tools.js";
10
8
  import { createMemoryInstructionsMiddleware, hasAgentMemorySlice, hotMemoryPaths, } from "../memory/index.js";
@@ -34,8 +32,8 @@ export async function compileManagedAgent(definition, config, options) {
34
32
  // one object, but mounting is owned by the managed HTTP app — leave it on
35
33
  // `options` unused here.
36
34
  // Resolution + thread/store scoping run in the generated custom-auth handler
37
- // (`buildManagedAuth`). When identity is declared, the seam also surfaces
38
- // `runtime.serverInfo.principal` to authored + connector tools (below).
35
+ // (`buildManagedAuth`). When identity is declared, the seam also surfaces the
36
+ // frozen `runtime.identity` envelope to authored + connector tools (below).
39
37
  identity,
40
38
  // The root `memory.{ts,py}` declaration. Absent → no durable memory: the
41
39
  // slices a run mounts come from here and nowhere else.
@@ -110,14 +108,15 @@ export async function compileManagedAgent(definition, config, options) {
110
108
  const authoredTools = Array.isArray(params.tools) ? params.tools : [];
111
109
  params.tools = [...authoredTools, ...connectorTools];
112
110
  }
113
- // With identity declared, surface `runtime.serverInfo.principal` on the runtime
114
- // every tool receives, projected from the trusted `langgraph_auth_user`.
111
+ // With identity declared, surface the frozen `runtime.identity` envelope on
112
+ // the runtime every tool receives, built from the trusted
113
+ // `langgraph_auth_user`.
115
114
  if (identity && Array.isArray(params.tools)) {
116
115
  params.tools = wrapToolsWithManagedRuntime(params.tools);
117
116
  }
118
117
  // Do the same for authored middleware: each hook's `runtime` (and the `wrap*`
119
- // hooks' `request.runtime`) gains `runtime.serverInfo.principal`, built from the
120
- // same trusted `langgraph_auth_user` on `runtime.configurable`.
118
+ // hooks' `request.runtime`) gains `runtime.identity`, built from the same
119
+ // trusted `langgraph_auth_user` on `runtime.configurable`.
121
120
  const authoredMiddleware = Array.isArray(params.middleware)
122
121
  ? params.middleware
123
122
  : [];
@@ -125,18 +124,14 @@ export async function compileManagedAgent(definition, config, options) {
125
124
  ? wrapMiddlewareWithManagedRuntime(authoredMiddleware)
126
125
  : authoredMiddleware;
127
126
  // Always-on schedule deliverTo auto-post (cron runs); prepend before authored.
128
- // The credential gate runs early so OAuth interrupts happen before the model
129
- // turn; it only installs when a declaration names a user-owned credential.
130
127
  // The memory policy goes last on purpose. First in this list is outermost, so a
131
128
  // middleware placed earlier can have its prompt replaced by an authored one that
132
129
  // rewrites `systemPrompt` wholesale — and this policy is a security control, not a
133
130
  // hint. Last means nothing authored runs after it. deepagents still appends its own
134
131
  // `<agent_memory>` block after the whole custom stack, so the policy's "block below"
135
132
  // wording stays accurate.
136
- const credentialGate = createCredentialGateMiddleware(mcpCredentialConsumers(connectors));
137
133
  params.middleware = [
138
134
  createScheduleDeliveryMiddleware(),
139
- ...(credentialGate ? [credentialGate] : []),
140
135
  ...wrappedAuthored,
141
136
  createChannelResponseFormatMiddleware(),
142
137
  ...(mountsMemory ? [createMemoryInstructionsMiddleware()] : []),
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,GAChB,MAAM,YAAY,CAAC;AAIpB,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,gCAAgC,EAAE,MAAM,kCAAkC,CAAC;AACpF,OAAO,EAAE,qCAAqC,EAAE,MAAM,gCAAgC,CAAC;AACvF,OAAO,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAEL,gCAAgC,GACjC,MAAM,yBAAyB,CAAC;AACjC,OAAO,E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AED,mFAAmF;IACnF,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC;IACrE,IAAI,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QACjD,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAChC,CAAC;AAMD,KAAK,UAAU,qBAAqB,CAClC,WAA+B,EAC/B,WAA+B;IAE/B,8EAA8E;IAC9E,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,iBAAiB,CAAC,WAAW,CAAC,EAAE,CAAC;IACtE,CAAC;IACD,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO;YACL,IAAI,EAAE,YAAY;YAClB,OAAO,EAAE,IAAI,iBAAiB,CAAC;gBAC7B,OAAO,EAAE,WAAW;gBACpB,WAAW,EAAE,IAAI;aAClB,CAAC;YACF,OAAO,EAAE,WAAW;SACrB,CAAC;IACJ,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -7,8 +7,8 @@ export interface ManagedMiddleware {
7
7
  [key: string]: unknown;
8
8
  }
9
9
  /**
10
- * Wrap a middleware so every hook sees `runtime.serverInfo.principal` (…) without
11
- * changing its name, schema, registered tools, or class.
10
+ * Wrap a middleware so every hook sees `runtime.identity` (…) without changing
11
+ * its name, schema, registered tools, or class.
12
12
  *
13
13
  * A `Proxy` intercepts only the hook properties: lifecycle hooks
14
14
  * (`beforeAgent`/`beforeModel`/`afterModel`/`afterAgent`, in either function or
@@ -10,10 +10,10 @@ const LIFECYCLE_HOOKS = new Set([
10
10
  const WRAP_HOOKS = new Set(["wrapModelCall", "wrapToolCall"]);
11
11
  /**
12
12
  * Return a copy of the middleware runtime with the managed primitives
13
- * (`runtime.serverInfo.principal`, …) layered on. The envelope is projected from
14
- * the trusted `runtime.configurable.langgraph_auth_user` the custom-auth handler
15
- * produced — the same channel tools use — since the platform, not us, invokes the
16
- * graph and `runtime.context` is caller-supplied per-run data we do not control.
13
+ * (`runtime.identity`, …) layered on. Identity is built from the trusted
14
+ * `runtime.configurable.langgraph_auth_user` the custom-auth handler produced —
15
+ * the same channel tools use — since the platform, not us, invokes the graph and
16
+ * `runtime.context` is caller-supplied per-run data we do not control.
17
17
  */
18
18
  function augmentRuntime(runtime) {
19
19
  const overrides = managedRuntimeOverrides(runtime);
@@ -41,8 +41,8 @@ function wrapWrapHook(target, value) {
41
41
  return (request, handler) => fn.call(target, { ...request, runtime: augmentRuntime(request?.runtime) }, handler);
42
42
  }
43
43
  /**
44
- * Wrap a middleware so every hook sees `runtime.serverInfo.principal` (…) without
45
- * changing its name, schema, registered tools, or class.
44
+ * Wrap a middleware so every hook sees `runtime.identity` (…) without changing
45
+ * its name, schema, registered tools, or class.
46
46
  *
47
47
  * A `Proxy` intercepts only the hook properties: lifecycle hooks
48
48
  * (`beforeAgent`/`beforeModel`/`afterModel`/`afterAgent`, in either function or
@@ -1,7 +1,8 @@
1
1
  import type { ToolRuntime } from "@langchain/core/tools";
2
+ import type { RuntimeIdentity } from "../identity/index.js";
2
3
  import type { RuntimeChannel } from "../channels/types.js";
3
- import type { ManagedServerInfo, RuntimeConfigLike } from "./identity-runtime.js";
4
- export type { ManagedServerInfo, RuntimeConfigLike, } from "./identity-runtime.js";
4
+ import type { RuntimeConfigLike } from "./identity-runtime.js";
5
+ export type { RuntimeConfigLike } from "./identity-runtime.js";
5
6
  /**
6
7
  * A LangChain/LangGraph tool from MDA's perspective: the only surface the runtime
7
8
  * seam touches is `invoke(input, runtime)`. Kept structural so the wrapper works
@@ -12,11 +13,7 @@ export interface InvokableTool {
12
13
  }
13
14
  /** The managed primitives MDA layers onto the tool runtime. */
14
15
  export interface ManagedRuntimeExtras {
15
- /**
16
- * LangGraph server metadata with the author-facing principal on `principal`
17
- * (plus `subject` / `link`) and LangGraph AuthUser on `user`.
18
- */
19
- serverInfo?: ManagedServerInfo;
16
+ identity?: RuntimeIdentity;
20
17
  /**
21
18
  * Present only for channel-originated runs. Ordinary HTTP and schedule runs
22
19
  * leave this undefined.
@@ -25,32 +22,31 @@ export interface ManagedRuntimeExtras {
25
22
  }
26
23
  /**
27
24
  * The runtime surface managed Deep Agent tools receive: LangGraph's
28
- * {@link ToolRuntime} plus MDA-managed primitives such as `serverInfo`.
25
+ * {@link ToolRuntime} plus MDA-managed primitives such as `identity`.
29
26
  *
30
27
  * Annotate the second parameter of a `tool(...)` handler when you need the
31
- * trusted caller for the current run (`runtime.serverInfo?.principal`).
28
+ * frozen identity envelope for the current run.
32
29
  */
33
30
  export interface ManagedDeepAgentRuntime<TState = unknown, TContext = unknown> extends ToolRuntime<TState, TContext>, ManagedRuntimeExtras {
34
31
  }
35
32
  /**
36
33
  * The fields MDA overlays onto the runtime a tool/middleware hook receives:
37
- * `serverInfo.principal` / `subject` / `link` (when an actor resolved) and a
38
- * `configurable` with the reserved identity keys stripped so downstream code
39
- * can't read a client-spoofed `actor_id`/`tenant_id`. Returns an empty object
40
- * when there is nothing to change, so the original runtime passes through
41
- * untouched.
34
+ * the frozen `identity` (when an actor resolved) and a `configurable` with the
35
+ * reserved identity keys stripped so downstream code can't read a
36
+ * client-spoofed `actor_id`/`tenant_id`. Returns an empty object when there is
37
+ * nothing to change, so the original runtime passes through untouched.
42
38
  */
43
39
  export declare function managedRuntimeOverrides(runtime: RuntimeConfigLike | undefined): ManagedRuntimeExtras & {
44
40
  configurable?: Record<string, unknown>;
45
41
  };
46
42
  /**
47
- * Wrap a tool so its runtime carries the managed primitives
48
- * (`runtime.serverInfo.principal`, …) without changing its name, schema, or class.
43
+ * Wrap a tool so its runtime carries the managed primitives (`runtime.identity`,
44
+ * …) without changing its name, schema, or class.
49
45
  *
50
46
  * Augments `invoke` (for LangGraph's `ToolNode`) and patches a shallow copy's
51
- * internal `func`/`coroutine` so the auth user reaches the authored handler even
52
- * when LangChain rewrites the runtime into a RunnableConfig before calling the
53
- * tool function. The original tool instance is left untouched.
47
+ * internal `func`/`coroutine` so identity reaches the authored handler even when
48
+ * LangChain rewrites the runtime into a RunnableConfig before calling the tool
49
+ * function. The original tool instance is left untouched.
54
50
  */
55
51
  export declare function withManagedRuntime<T extends InvokableTool>(managedTool: T): T;
56
52
  /** Wrap every tool in a list with {@link withManagedRuntime}. */
@@ -1 +1 @@
1
- {"version":3,"file":"managed-tools.d.ts","sourceRoot":"","sources":["../../src/runtime/managed-tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAM3D,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAE/B,YAAY,EACV,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAE/B;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC;CAC9D;AAED,+DAA+D;AAC/D,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC/B;;;OAGG;IACH,OAAO,CAAC,EAAE,cAAc,CAAC;CAC1B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,uBAAuB,CAAC,MAAM,GAAG,OAAO,EAAE,QAAQ,GAAG,OAAO,CAC3E,SAAQ,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,oBAAoB;CAAG;AAEhE;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,iBAAiB,GAAG,SAAS,GACrC,oBAAoB,GAAG;IAAE,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAA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AgCnE;AAwBD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,aAAa,EAAE,WAAW,EAAE,CAAC,GAAG,CAAC,CAqC7E;AAED,iEAAiE;AACjE,wBAAgB,2BAA2B,CAAC,CAAC,SAAS,aAAa,EACjE,KAAK,EAAE,SAAS,CAAC,EAAE,GAClB,CAAC,EAAE,CAEL"}
@@ -1,19 +1,18 @@
1
1
  import { resolveRuntimeChannel } from "../channels/binding.js";
2
- import { buildManagedServerInfo, resolveRuntimeConfigurable, sanitizeConfigurable, } from "./identity-runtime.js";
2
+ import { buildRuntimeIdentity, resolveRuntimeConfigurable, sanitizeConfigurable, } from "./identity-runtime.js";
3
3
  /**
4
4
  * The fields MDA overlays onto the runtime a tool/middleware hook receives:
5
- * `serverInfo.principal` / `subject` / `link` (when an actor resolved) and a
6
- * `configurable` with the reserved identity keys stripped so downstream code
7
- * can't read a client-spoofed `actor_id`/`tenant_id`. Returns an empty object
8
- * when there is nothing to change, so the original runtime passes through
9
- * untouched.
5
+ * the frozen `identity` (when an actor resolved) and a `configurable` with the
6
+ * reserved identity keys stripped so downstream code can't read a
7
+ * client-spoofed `actor_id`/`tenant_id`. Returns an empty object when there is
8
+ * nothing to change, so the original runtime passes through untouched.
10
9
  */
11
10
  export function managedRuntimeOverrides(runtime) {
12
11
  const overrides = {};
13
12
  const configurable = resolveRuntimeConfigurable(runtime);
14
- const serverInfo = buildManagedServerInfo(runtime, configurable);
15
- if (serverInfo) {
16
- overrides.serverInfo = serverInfo;
13
+ const identity = buildRuntimeIdentity(configurable);
14
+ if (identity) {
15
+ overrides.identity = identity;
17
16
  }
18
17
  if (runtime?.channel) {
19
18
  overrides.channel = runtime.channel;
@@ -50,13 +49,13 @@ function wrapToolCallable(original, receiver) {
50
49
  return (input, runManager, config) => original.call(receiver, input, runManager, augmentToolConfig(config));
51
50
  }
52
51
  /**
53
- * Wrap a tool so its runtime carries the managed primitives
54
- * (`runtime.serverInfo.principal`, …) without changing its name, schema, or class.
52
+ * Wrap a tool so its runtime carries the managed primitives (`runtime.identity`,
53
+ * …) without changing its name, schema, or class.
55
54
  *
56
55
  * Augments `invoke` (for LangGraph's `ToolNode`) and patches a shallow copy's
57
- * internal `func`/`coroutine` so the auth user reaches the authored handler even
58
- * when LangChain rewrites the runtime into a RunnableConfig before calling the
59
- * tool function. The original tool instance is left untouched.
56
+ * internal `func`/`coroutine` so identity reaches the authored handler even when
57
+ * LangChain rewrites the runtime into a RunnableConfig before calling the tool
58
+ * function. The original tool instance is left untouched.
60
59
  */
61
60
  export function withManagedRuntime(managedTool) {
62
61
  const patchable = Object.assign(Object.create(Object.getPrototypeOf(managedTool)), managedTool);
@@ -1 +1 @@
1
- {"version":3,"file":"managed-tools.js","sourceRoot":"","sources":["../../src/runtime/managed-tools.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,OAAO,EACL,sBAAsB,EACtB,0BAA0B,EAC1B,oBAAoB,GACrB,MAAM,uBAAuB,CAAC;AA4C/B;;;;;;;GAOG;AACH,MAAM,UAAU,uBAAuB,CACrC,OAAsC;IAEtC,MAAM,SAAS,GAMX,EAAE,CAAC;IACP,MAAM,YAAY,GAAG,0BAA0B,CAAC,OAAO,CAAC,CAAC;IACzD,MAAM,UAAU,GAAG,sBAAsB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACjE,IAAI,UAAU,EAAE,CAAC;QACf,SAAS,CAAC,UAAU,GAAG,UAAU,CAAC;IACpC,CAAC;IACD,IAAI,OAAO,EAAE,OAAO,EAAE,CAAC;QACrB,SAAS,CAAC,OAAO,GAAG,OAAO,CAAC,OAA0C,CAAC;IACzE,CAAC;SAAM,CAAC;QACN,MAAM,WAAW,GAAG,qBAAqB,CAAC,YAAY,CAAC,CAAC;QACxD,IAAI,WAAW,EAAE,CAAC;YAChB,SAAS,CAAC,OAAO,GAAG,WAAW,CAAC;QAClC,CAAC;IACH,CAAC;I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E,OAA2B,EAAE,EAAE;oBACrD,MAAM,SAAS,GAAG,uBAAuB,CAAC,OAAO,CAAC,CAAC;oBACnD,OAAO,MAAM,CAAC,MAAM,CAClB,KAAK,EACL,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,GAAG,CAAC;wBAC/B,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,GAAG,SAAS,EAAE;wBAC9B,CAAC,CAAC,OAAO,CACZ,CAAC;gBACJ,CAAC,CAAC;YACJ,CAAC;YACD,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACjD,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,2BAA2B,CACzC,KAAmB;IAEnB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC,CAAC;AACrE,CAAC"}
@@ -61,8 +61,8 @@ export interface ManagedAgentOptions {
61
61
  /**
62
62
  * The root `identity.ts` declaration, if the project opts into managed
63
63
  * identity. Resolution + thread scoping run in the generated custom-auth
64
- * handler (`buildManagedAuth`); this seam reserves the declaration for
65
- * `runtime.serverInfo.principal` and memory namespacing.
64
+ * handler (`buildManagedAuth`); this seam reserves the declaration for the
65
+ * frozen `runtime.identity` envelope and memory namespacing.
66
66
  */
67
67
  identity?: IdentityDefinition;
68
68
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "managed-deepagents",
3
- "version": "0.6.2-dev.7",
3
+ "version": "0.6.2-dev.9",
4
4
  "description": "Managed Deep Agents — the `defineDeepAgent` authoring interface plus the CLI that compiles and deploys a code-first Deep Agent repository to a managed LangGraph runtime.",
5
5
  "keywords": [
6
6
  "langchain",
@@ -66,12 +66,12 @@
66
66
  "zod": "^4.4.3"
67
67
  },
68
68
  "optionalDependencies": {
69
- "@langchain/managed-deepagents-darwin-arm64": "0.6.2-dev.7",
70
- "@langchain/managed-deepagents-darwin-x64": "0.6.2-dev.7",
71
- "@langchain/managed-deepagents-linux-arm64": "0.6.2-dev.7",
72
- "@langchain/managed-deepagents-linux-x64": "0.6.2-dev.7",
73
- "@langchain/managed-deepagents-win32-arm64": "0.6.2-dev.7",
74
- "@langchain/managed-deepagents-win32-x64": "0.6.2-dev.7"
69
+ "@langchain/managed-deepagents-darwin-arm64": "0.6.2-dev.9",
70
+ "@langchain/managed-deepagents-darwin-x64": "0.6.2-dev.9",
71
+ "@langchain/managed-deepagents-linux-arm64": "0.6.2-dev.9",
72
+ "@langchain/managed-deepagents-linux-x64": "0.6.2-dev.9",
73
+ "@langchain/managed-deepagents-win32-arm64": "0.6.2-dev.9",
74
+ "@langchain/managed-deepagents-win32-x64": "0.6.2-dev.9"
75
75
  },
76
76
  "devDependencies": {
77
77
  "@types/node": "^26.1.1",
@@ -1,104 +0,0 @@
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.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"agent-auth.d.ts","sourceRoot":"","sources":["../src/agent-auth.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,eAAO,MAAM,qBAAqB,QAAS,CAAC;AAC5C,eAAO,MAAM,6BAA6B,MAAM,CAAC;AACjD,eAAO,MAAM,6BAA6B,KAAK,CAAC;AAEhD,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,qEAAqE;AACrE,wBAAgB,wBAAwB,CAAC,OAAO,EAAE;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,GAAG,MAAM,CAOT;AAED,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,mBAAmB,GAC1B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAexB;AAED,0EAA0E;AAC1E,wBAAsB,oBAAoB,CAAC,OAAO,EAAE;IAClD,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,SAAS,GAAG,QAAQ,CAAC,CAAC;IAC/C,MAAM,EAAE,mBAAmB,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,OAAO,KAAK,CAAC;CACzB,GAAG,OAAO,CAAC;IACV,EAAE,EAAE,OAA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AM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CASnE;IAED;;;;OAIG;IACG,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA2B3E;IAED,6EAA6E;IACvE,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAoC1D;IAED,yDAAyD;IACnD,gBAAgB,CAAC,OAAO,EAAE;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"}
@@ -1,224 +0,0 @@
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