managed-deepagents 0.0.3-dev.33 → 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.
Files changed (61) hide show
  1. package/dist/connectors.d.ts +2 -7
  2. package/dist/connectors.d.ts.map +1 -1
  3. package/dist/connectors.js +1 -18
  4. package/dist/connectors.js.map +1 -1
  5. package/dist/index.d.ts +0 -5
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +0 -2
  8. package/dist/index.js.map +1 -1
  9. package/dist/runtime/index.d.ts +0 -13
  10. package/dist/runtime/index.d.ts.map +1 -1
  11. package/dist/runtime/index.js +12 -39
  12. package/dist/runtime/index.js.map +1 -1
  13. package/dist/runtime/types.d.ts +7 -23
  14. package/dist/runtime/types.d.ts.map +1 -1
  15. package/dist/types.d.ts +0 -9
  16. package/dist/types.d.ts.map +1 -1
  17. package/package.json +8 -12
  18. package/dist/connectors/langsmith.d.ts +0 -133
  19. package/dist/connectors/langsmith.d.ts.map +0 -1
  20. package/dist/connectors/langsmith.js +0 -262
  21. package/dist/connectors/langsmith.js.map +0 -1
  22. package/dist/identity.d.ts +0 -273
  23. package/dist/identity.d.ts.map +0 -1
  24. package/dist/identity.js +0 -358
  25. package/dist/identity.js.map +0 -1
  26. package/dist/runtime/auth.d.ts +0 -54
  27. package/dist/runtime/auth.d.ts.map +0 -1
  28. package/dist/runtime/auth.js +0 -191
  29. package/dist/runtime/auth.js.map +0 -1
  30. package/dist/runtime/connector.d.ts +0 -138
  31. package/dist/runtime/connector.d.ts.map +0 -1
  32. package/dist/runtime/connector.js +0 -82
  33. package/dist/runtime/connector.js.map +0 -1
  34. package/dist/runtime/credentials.d.ts +0 -60
  35. package/dist/runtime/credentials.d.ts.map +0 -1
  36. package/dist/runtime/credentials.js +0 -189
  37. package/dist/runtime/credentials.js.map +0 -1
  38. package/dist/runtime/identity-http.d.ts +0 -27
  39. package/dist/runtime/identity-http.d.ts.map +0 -1
  40. package/dist/runtime/identity-http.js +0 -213
  41. package/dist/runtime/identity-http.js.map +0 -1
  42. package/dist/runtime/identity-runtime.d.ts +0 -54
  43. package/dist/runtime/identity-runtime.d.ts.map +0 -1
  44. package/dist/runtime/identity-runtime.js +0 -151
  45. package/dist/runtime/identity-runtime.js.map +0 -1
  46. package/dist/runtime/langsmith-connector.d.ts +0 -112
  47. package/dist/runtime/langsmith-connector.d.ts.map +0 -1
  48. package/dist/runtime/langsmith-connector.js +0 -411
  49. package/dist/runtime/langsmith-connector.js.map +0 -1
  50. package/dist/runtime/managed-middleware.d.ts +0 -25
  51. package/dist/runtime/managed-middleware.d.ts.map +0 -1
  52. package/dist/runtime/managed-middleware.js +0 -76
  53. package/dist/runtime/managed-middleware.js.map +0 -1
  54. package/dist/runtime/managed-tools.d.ts +0 -61
  55. package/dist/runtime/managed-tools.d.ts.map +0 -1
  56. package/dist/runtime/managed-tools.js +0 -102
  57. package/dist/runtime/managed-tools.js.map +0 -1
  58. package/dist/runtime/validated-token.d.ts +0 -25
  59. package/dist/runtime/validated-token.d.ts.map +0 -1
  60. package/dist/runtime/validated-token.js +0 -260
  61. package/dist/runtime/validated-token.js.map +0 -1
@@ -1,213 +0,0 @@
1
- import { Hono } from "hono";
2
- import { cors } from "hono/cors";
3
- import { resolveRequestIdentity } from "./auth.js";
4
- import { issueGuestToken } from "./validated-token.js";
5
- /**
6
- * Deployment env var carrying the browser origins allowed to call the managed
7
- * HTTP surface (comma-separated). The managed routes are token-based (Bearer
8
- * `Authorization`, no ambient cookies), so an unset value defaults to `*`.
9
- */
10
- const CORS_ORIGINS_ENV = "MDA_HTTP_CORS_ORIGINS";
11
- /** Request headers the browser is allowed to send to the managed routes. */
12
- const CORS_ALLOW_HEADERS = [
13
- "Authorization",
14
- "Content-Type",
15
- "X-Supabase-Region",
16
- "X-Auth-Key",
17
- "x-mda-actor-id",
18
- "x-mda-tenant-id",
19
- ];
20
- /** Signals a secured route was reached but no identity is declared to resolve it. */
21
- class IdentityNotConfiguredError extends Error {
22
- status = 401;
23
- constructor() {
24
- super("secured connector route requires an identity declaration, but this " +
25
- "deployment has none");
26
- }
27
- }
28
- /**
29
- * Build the single managed HTTP app mounted via `langgraph.json` `http.app`.
30
- *
31
- * It layers two concerns onto the built-in LangGraph routes:
32
- * - **identity** — public guest issuance (`POST /identity/guest`) when the
33
- * declared identity enables a guest provider;
34
- * - **connectors** — each connector implementing `http` gets a sub-router
35
- * namespaced under `/connectors/{kind}` and mounts its own routes.
36
- *
37
- * Connector routes are **secure by default**: MDA resolves and enforces the
38
- * caller's identity before the handler runs, and a route must opt out of
39
- * authentication explicitly (`router.public.*`). The connector HTTP surface is
40
- * logged at construction so the (especially unauthenticated) routes are never
41
- * invisible.
42
- */
43
- export function buildManagedHttpApp(inputs) {
44
- const app = new Hono();
45
- // The managed connector/identity routes are meant to be called directly from
46
- // the browser, so CORS (preflight + `Access-Control-*`) must be enabled.
47
- // Registered before the routes so it also covers preflight `OPTIONS`.
48
- if (hasManagedSurface(inputs)) {
49
- applyCors(app);
50
- }
51
- if (inputs.identity) {
52
- mountIdentityRoutes(app, inputs.identity);
53
- }
54
- const mounted = [];
55
- for (const connector of inputs.connectors ?? []) {
56
- if (typeof connector.http === "function") {
57
- mountConnectorRoutes(app, connector, inputs.identity?.config, mounted);
58
- }
59
- }
60
- logConnectorSurface(mounted);
61
- return app;
62
- }
63
- /**
64
- * Whether the project contributes any managed HTTP routes (guest issuance or a
65
- * connector `http` hook). CORS is only enabled when there is a surface to call,
66
- * so an empty managed app stays a pure no-op on top of the platform API.
67
- */
68
- function hasManagedSurface(inputs) {
69
- const http = inputs.identity?.config.ingress.http;
70
- const hasGuest = http !== undefined &&
71
- http !== "trusted_backend" &&
72
- http.providers.some((provider) => provider.guest?.issue);
73
- const hasConnectorHttp = (inputs.connectors ?? []).some((connector) => typeof connector.http === "function");
74
- return Boolean(hasGuest) || hasConnectorHttp;
75
- }
76
- /**
77
- * Enable CORS on the managed HTTP surface. Origins come from
78
- * `MDA_HTTP_CORS_ORIGINS` (comma-separated); unset means `*`. A wildcard cannot
79
- * be combined with credentials per the CORS spec, and the managed routes never
80
- * rely on cookies, so credentials are only enabled with an explicit allowlist.
81
- */
82
- function applyCors(app) {
83
- const raw = (process.env[CORS_ORIGINS_ENV] ?? "").trim();
84
- let origin;
85
- let credentials;
86
- if (raw && raw !== "*") {
87
- origin = raw
88
- .split(",")
89
- .map((value) => value.trim())
90
- .filter(Boolean);
91
- credentials = true;
92
- }
93
- else {
94
- origin = "*";
95
- credentials = false;
96
- }
97
- app.use("*", cors({
98
- origin,
99
- credentials,
100
- allowMethods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
101
- allowHeaders: CORS_ALLOW_HEADERS,
102
- }));
103
- }
104
- /** Mount the public identity routes (guest issuance) onto `app`. */
105
- function mountIdentityRoutes(app, identity) {
106
- const http = identity.config.ingress.http;
107
- if (http === "trusted_backend") {
108
- return;
109
- }
110
- const guestProvider = http.providers.find((provider) => provider.guest?.issue);
111
- if (!guestProvider) {
112
- return;
113
- }
114
- app.post("/identity/guest", async (c) => {
115
- const token = await issueGuestToken(guestProvider);
116
- return c.json({ token });
117
- });
118
- }
119
- /**
120
- * Mount a connector's `http` routes on a sub-router namespaced under
121
- * `/connectors/{kind}`, so connector routes cannot collide with identity/API
122
- * routes or with each other.
123
- */
124
- function mountConnectorRoutes(app, connector, cfg, mounted) {
125
- const sub = new Hono();
126
- const router = honoConnectorRouter(sub, connector.kind, cfg, mounted);
127
- const ctx = {
128
- router,
129
- identity: cfg,
130
- requireIdentity: (request) => {
131
- if (!cfg) {
132
- return Promise.reject(new Error("identity is not configured for this deployment; declare an " +
133
- "identity to resolve caller identity on connector routes."));
134
- }
135
- return resolveRequestIdentity(cfg, request);
136
- },
137
- };
138
- connector.http?.(ctx);
139
- app.route(`/connectors/${connector.kind}`, sub);
140
- }
141
- /**
142
- * Build the secure-by-default {@link HttpSubRouter} over a Hono sub-app. Secured
143
- * routes resolve identity (401 on failure) before the handler runs; `public.*`
144
- * routes skip enforcement. Every registration is recorded in `mounted`.
145
- */
146
- function honoConnectorRouter(sub, kind, cfg, mounted) {
147
- const secured = (method) => (path, handler) => {
148
- mounted.push({ connector: kind, method, path, secured: true });
149
- sub[method](path, async (c) => {
150
- const request = c.req.raw;
151
- if (!cfg) {
152
- return unauthorizedResponse(new IdentityNotConfiguredError());
153
- }
154
- let identity;
155
- try {
156
- identity = await resolveRequestIdentity(cfg, request);
157
- }
158
- catch (error) {
159
- return unauthorizedResponse(error);
160
- }
161
- return handler(request, identity);
162
- });
163
- };
164
- const publicRoute = (method) => (path, handler) => {
165
- mounted.push({ connector: kind, method, path, secured: false });
166
- sub[method](path, (c) => handler(c.req.raw));
167
- };
168
- return {
169
- get: secured("get"),
170
- post: secured("post"),
171
- put: secured("put"),
172
- delete: secured("delete"),
173
- public: {
174
- get: publicRoute("get"),
175
- post: publicRoute("post"),
176
- put: publicRoute("put"),
177
- delete: publicRoute("delete"),
178
- },
179
- };
180
- }
181
- /** Map a resolution error to a fail-closed JSON response. */
182
- function unauthorizedResponse(error) {
183
- const status = typeof error.status === "number"
184
- ? error.status
185
- : 401;
186
- const message = error instanceof Error && error.message ? error.message : "unauthorized";
187
- return new Response(JSON.stringify({ error: message }), {
188
- status,
189
- headers: { "content-type": "application/json" },
190
- });
191
- }
192
- /**
193
- * Log the connector HTTP surface so both secured and (loudly) public routes are
194
- * visible in deploy/dev startup logs — the routes are mounted at runtime, so
195
- * this is where the actual surface can be enumerated.
196
- */
197
- function logConnectorSurface(mounted) {
198
- if (mounted.length === 0) {
199
- return;
200
- }
201
- console.info(`[mda] connector HTTP surface (${mounted.length} route(s)):`);
202
- for (const route of mounted) {
203
- const full = `/connectors/${route.connector}${route.path}`;
204
- const line = `[mda] ${route.method.toUpperCase().padEnd(6)} ${full}`;
205
- if (route.secured) {
206
- console.info(`${line} (identity enforced)`);
207
- }
208
- else {
209
- console.warn(`${line} (PUBLIC — no identity enforcement)`);
210
- }
211
- }
212
- }
213
- //# sourceMappingURL=identity-http.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"identity-http.js","sourceRoot":"","sources":["../../src/runtime/identity-http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAQnD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAYvD;;;;GAIG;AACH,MAAM,gBAAgB,GAAG,uBAAuB,CAAC;AAEjD,4EAA4E;AAC5E,MAAM,kBAAkB,GAAG;IACzB,eAAe;IACf,cAAc;IACd,mBAAmB;IACnB,YAAY;IACZ,gBAAgB;IAChB,iBAAiB;CAClB,CAAC;AAUF,qFAAqF;AACrF,MAAM,0BAA2B,SAAQ,KAAK;IACnC,MAAM,GAAG,GAAG,CAAC;IACtB;QACE,KAAK,CACH,qEAAqE;YACnE,qBAAqB,CACxB,CAAC;IACJ,CAAC;CACF;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAA4B;IAC9D,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IAEvB,6EAA6E;IAC7E,yEAAyE;IACzE,sEAAsE;IACtE,IAAI,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC;QAC9B,SAAS,CAAC,GAAG,CAAC,CAAC;IACjB,CAAC;IAED,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpB,mBAAmB,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM,OAAO,GAAmB,EAAE,CAAC;IACnC,KAAK,MAAM,SAAS,IAAI,MAAM,CAAC,UAAU,IAAI,EAAE,EAAE,CAAC;QAChD,IAAI,OAAO,SAAS,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YACzC,oBAAoB,CAAC,G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B,EAAE;KAChD,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,SAAS,mBAAmB,CAAC,OAAuB;IAClD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO;IACT,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,iCAAiC,OAAO,CAAC,MAAM,aAAa,CAAC,CAAC;IAC3E,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,MAAM,IAAI,GAAG,eAAe,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;QAC3D,MAAM,IAAI,GAAG,WAAW,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC;QACvE,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;YAClB,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,uBAAuB,CAAC,CAAC;QAC/C,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,sCAAsC,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -1,54 +0,0 @@
1
- import type { IdentityConfig, MemoryScope, RuntimeIdentity, Tenancy } from "../identity.js";
2
- import type { ConfigurableCarrier } from "./types.js";
3
- /**
4
- * Resolve the LangGraph `configurable` bag from either a flat runtime or the
5
- * nested `ToolRuntime` shape LangChain passes to tools (`runtime.config.configurable`).
6
- */
7
- export declare function resolveRuntimeConfigurable(runtime: RuntimeConfigLike | undefined): Record<string, unknown> | undefined;
8
- /**
9
- * Build the frozen identity envelope for the current run from the trusted
10
- * `langgraph_auth_user` the custom-auth handler produced (§6.1). Returns
11
- * `undefined` when the deployment has no resolvable actor (identity is opt-in).
12
- */
13
- export declare function buildRuntimeIdentity(configurable: Record<string, unknown> | undefined): RuntimeIdentity | undefined;
14
- /**
15
- * The durable Store namespace for the run, per `scoping.memory` (§6.2). A
16
- * `deploymentId` prefix isolates deployments; identity segments follow. Returns
17
- * `undefined` for `none` (no durable memory). Fail-closed: an `actor` scope with
18
- * no actor already rejects at ingress, so the segments are never empty here.
19
- */
20
- export declare function memoryNamespace(cfg: IdentityConfig, ident: RuntimeIdentity, deploymentId: string): string[] | undefined;
21
- /**
22
- * The runtime the managed seam sees: the shared `configurable` carrier, plus the
23
- * optional nested `config` (e.g. LangGraph `ToolRuntime.config`) and the frozen
24
- * `identity` envelope the seam layers on. Single source for the tool, middleware,
25
- * and memory-namespace helpers.
26
- */
27
- export interface RuntimeConfigLike extends ConfigurableCarrier {
28
- identity?: RuntimeIdentity;
29
- config?: {
30
- configurable?: Record<string, unknown>;
31
- };
32
- }
33
- /**
34
- * Resolve the durable memory namespace for a run directly from the runtime the
35
- * memory `StoreBackend` receives, per `scoping.memory` (§6.2). This is the
36
- * plug-in point for the (deferred) Store-backed memory: a `StoreBackend`
37
- * namespace factory becomes `(ctx) => memoryNamespaceFor(ctx.runtime, cfg, id)`.
38
- * Returns `undefined` when the run has no durable namespace (`none`, or a
39
- * per-actor scope with no resolved actor).
40
- */
41
- export declare function memoryNamespaceFor(runtime: RuntimeConfigLike | undefined, cfg: IdentityConfig, deploymentId: string): string[] | undefined;
42
- /**
43
- * The identity portion of the memory namespace (no deployment prefix), shared by
44
- * the memory `StoreBackend` and the `@auth.on.store` boundary check so both agree
45
- * on exactly which segments identify a namespace.
46
- */
47
- export declare function memoryIdentitySegments(scope: MemoryScope, tenancy: Tenancy, actorId: string | undefined, tenantId: string | undefined): string[];
48
- /**
49
- * Strip client-supplied identity keys from an incoming `configurable` so a
50
- * request body can never spoof the actor/tenant the handler resolved (§8). The
51
- * platform-set `langgraph_auth_user` is preserved — it is the only trusted source.
52
- */
53
- export declare function sanitizeConfigurable(configurable: Record<string, unknown> | undefined): Record<string, unknown>;
54
- //# sourceMappingURL=identity-runtime.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"identity-runtime.d.ts","sourceRoot":"","sources":["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AAO,CAAC,GAAG,SAAS,GAChD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CASzB"}
@@ -1,151 +0,0 @@
1
- /**
2
- * Identity fields a client must never assert via `config.configurable`; only the
3
- * custom-auth handler (`langgraph_auth_user`) is trusted (§8, tamper-proofing).
4
- */
5
- const RESERVED_CONFIGURABLE_KEYS = new Set([
6
- "actor_id",
7
- "tenant_id",
8
- "mda_actor_id",
9
- "mda_tenant_id",
10
- "mda_actor_email",
11
- "mda_claims",
12
- "mda_actor_type",
13
- "mda_source_thread_id",
14
- ]);
15
- /** Source channels a run can originate from (`runtime.identity.source.provider`). */
16
- const SOURCE_PROVIDERS = new Set([
17
- "http",
18
- "slack",
19
- "schedule",
20
- "cli",
21
- "studio",
22
- ]);
23
- /**
24
- * Resolve the LangGraph `configurable` bag from either a flat runtime or the
25
- * nested `ToolRuntime` shape LangChain passes to tools (`runtime.config.configurable`).
26
- */
27
- export function resolveRuntimeConfigurable(runtime) {
28
- return runtime?.configurable ?? runtime?.config?.configurable;
29
- }
30
- /**
31
- * Build the frozen identity envelope for the current run from the trusted
32
- * `langgraph_auth_user` the custom-auth handler produced (§6.1). Returns
33
- * `undefined` when the deployment has no resolvable actor (identity is opt-in).
34
- */
35
- export function buildRuntimeIdentity(configurable) {
36
- const user = configurable?.langgraph_auth_user;
37
- const actorId = user?.mda_actor_id;
38
- if (!user || !actorId) {
39
- return undefined;
40
- }
41
- const identity = {
42
- actor: {
43
- type: user.mda_actor_type === "service" ? "service" : "user",
44
- id: String(actorId),
45
- ...(user.mda_actor_email ? { email: String(user.mda_actor_email) } : {}),
46
- },
47
- source: {
48
- provider: sourceProvider(configurable),
49
- ...(threadId(configurable) ? { threadId: threadId(configurable) } : {}),
50
- },
51
- };
52
- if (user.mda_tenant_id) {
53
- identity.tenant = { id: String(user.mda_tenant_id) };
54
- }
55
- if (user.mda_claims && typeof user.mda_claims === "object") {
56
- identity.claims = user.mda_claims;
57
- }
58
- // Immutable: tools/middleware get a read-only view they cannot tamper with (§8).
59
- return deepFreeze(identity);
60
- }
61
- /** Recursively freeze an object graph so the identity envelope is read-only. */
62
- function deepFreeze(value) {
63
- if (value && typeof value === "object" && !Object.isFrozen(value)) {
64
- for (const nested of Object.values(value)) {
65
- deepFreeze(nested);
66
- }
67
- Object.freeze(value);
68
- }
69
- return value;
70
- }
71
- /**
72
- * The durable Store namespace for the run, per `scoping.memory` (§6.2). A
73
- * `deploymentId` prefix isolates deployments; identity segments follow. Returns
74
- * `undefined` for `none` (no durable memory). Fail-closed: an `actor` scope with
75
- * no actor already rejects at ingress, so the segments are never empty here.
76
- */
77
- export function memoryNamespace(cfg, ident, deploymentId) {
78
- const scope = cfg.scoping.memory;
79
- if (scope === "none") {
80
- return undefined;
81
- }
82
- if (scope === "agent") {
83
- return [deploymentId, "agent"];
84
- }
85
- return [
86
- deploymentId,
87
- ...memoryIdentitySegments(scope, cfg.tenancy, ident.actor.id, ident.tenant?.id),
88
- ];
89
- }
90
- /**
91
- * Resolve the durable memory namespace for a run directly from the runtime the
92
- * memory `StoreBackend` receives, per `scoping.memory` (§6.2). This is the
93
- * plug-in point for the (deferred) Store-backed memory: a `StoreBackend`
94
- * namespace factory becomes `(ctx) => memoryNamespaceFor(ctx.runtime, cfg, id)`.
95
- * Returns `undefined` when the run has no durable namespace (`none`, or a
96
- * per-actor scope with no resolved actor).
97
- */
98
- export function memoryNamespaceFor(runtime, cfg, deploymentId) {
99
- const configurable = runtime?.configurable ?? runtime?.config?.configurable;
100
- const identity = buildRuntimeIdentity(configurable);
101
- if (identity) {
102
- return memoryNamespace(cfg, identity, deploymentId);
103
- }
104
- // No resolved actor: only the actor-independent `agent` scope has a namespace.
105
- return cfg.scoping.memory === "agent" ? [deploymentId, "agent"] : undefined;
106
- }
107
- /**
108
- * The identity portion of the memory namespace (no deployment prefix), shared by
109
- * the memory `StoreBackend` and the `@auth.on.store` boundary check so both agree
110
- * on exactly which segments identify a namespace.
111
- */
112
- export function memoryIdentitySegments(scope, tenancy, actorId, tenantId) {
113
- if (scope === "actor") {
114
- const segments = [];
115
- if (tenancy === "multi" && tenantId) {
116
- segments.push(tenantId);
117
- }
118
- if (actorId) {
119
- segments.push(actorId);
120
- }
121
- return segments;
122
- }
123
- if (scope === "tenant") {
124
- return tenantId ? [tenantId] : [];
125
- }
126
- // "agent" (shared) | "none" (no memory) → no per-identity restriction.
127
- return [];
128
- }
129
- /**
130
- * Strip client-supplied identity keys from an incoming `configurable` so a
131
- * request body can never spoof the actor/tenant the handler resolved (§8). The
132
- * platform-set `langgraph_auth_user` is preserved — it is the only trusted source.
133
- */
134
- export function sanitizeConfigurable(configurable) {
135
- if (!configurable) {
136
- return {};
137
- }
138
- return Object.fromEntries(Object.entries(configurable).filter(([key]) => !RESERVED_CONFIGURABLE_KEYS.has(key)));
139
- }
140
- function sourceProvider(configurable) {
141
- const declared = configurable?.mda_source_provider;
142
- if (typeof declared === "string" && SOURCE_PROVIDERS.has(declared)) {
143
- return declared;
144
- }
145
- return "http";
146
- }
147
- function threadId(configurable) {
148
- const value = configurable?.thread_id;
149
- return value == null ? undefined : String(value);
150
- }
151
- //# sourceMappingURL=identity-runtime.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"identity-runtime.js","sourceRoot":"","sources":["../../src/runtime/identity-runtime.ts"],"names":[],"mappings":"AASA;;;GAGG;AACH,MAAM,0BAA0B,GAAG,IAAI,GAAG,CAAC;IACzC,UAAU;IACV,WAAW;IACX,cAAc;IACd,eAAe;IACf,iBAAiB;IACjB,YAAY;IACZ,gBAAgB;IAChB,sBAAsB;CACvB,CAAC,CAAC;AAEH,qFAAqF;AACrF,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC;IAC/B,MAAM;IACN,OAAO;IACP,UAAU;IACV,KAAK;IACL,QAAQ;CACT,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CACxC,OAAsC;IAEtC,OAAO,OAAO,EAAE,YAAY,IAAI,OAAO,EAAE,MAA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nE,OAAO,QAAiD,CAAC;IAC3D,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,QAAQ,CACf,YAAiD;IAEjD,MAAM,KAAK,GAAG,YAAY,EAAE,SAAS,CAAC;IACtC,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACnD,CAAC"}
@@ -1,112 +0,0 @@
1
- /**
2
- * LangSmith connector — runtime enforcement engine.
3
- *
4
- * Mounted by the connector's `http(ctx)` hook on its namespaced sub-router.
5
- * Exposes one uniform endpoint per capability:
6
- *
7
- * POST /connectors/langsmith/capabilities/{capability_id}
8
- *
9
- * with a JSON body naming the `action` and its parameters. Per request the
10
- * engine resolves identity (resolve-or-401), checks the caller surface, checks
11
- * the action, validates typed constraints, performs the LangSmith operation
12
- * server-side with the workspace key, and returns an allowlisted response.
13
- *
14
- * v0 does NOT prove object ownership (`runId` is treated as an unguessable
15
- * capability, matching the app being replaced), and has no rate limiting, audit,
16
- * or multi-workspace fan-out.
17
- */
18
- import type { Example, Feedback, KVMap, Prompt, Run, ScoreType, ValueType } from "langsmith/schemas";
19
- import type { IdentityConfig, RuntimeIdentity } from "../identity.js";
20
- import type { LangSmithCapability, LangSmithCallerSurface } from "../connectors/langsmith.js";
21
- import type { HttpContext } from "./connector.js";
22
- /**
23
- * The thin LangSmith operations the engine needs, typed against the `langsmith`
24
- * SDK's own schemas. {@link defaultClient} wraps a real {@link Client}; tests
25
- * inject a fake so the enforcement logic is verified without network or SDK
26
- * specifics.
27
- *
28
- * A connector "score" is a categorical value (e.g. `"positive"`), so it maps to
29
- * a LangSmith `score` when numeric/boolean and to a feedback `value` otherwise —
30
- * hence the `ScoreType | ValueType` inputs.
31
- */
32
- export interface LangSmithClient {
33
- createFeedback(input: {
34
- runId: string;
35
- key: string;
36
- score?: ScoreType | ValueType;
37
- comment?: string;
38
- feedbackId?: string;
39
- }): Promise<Feedback>;
40
- updateFeedback(input: {
41
- feedbackId: string;
42
- score?: ScoreType | ValueType;
43
- comment?: string;
44
- }): Promise<void>;
45
- deleteFeedback(input: {
46
- feedbackId: string;
47
- }): Promise<void>;
48
- readRun(input: {
49
- runId: string;
50
- }): Promise<Run>;
51
- shareRun(input: {
52
- runId: string;
53
- }): Promise<{
54
- url: string;
55
- }>;
56
- createExample(input: {
57
- dataset: string;
58
- inputs: KVMap;
59
- outputs?: KVMap;
60
- }): Promise<Example>;
61
- enqueueRun(input: {
62
- queue: string;
63
- runId: string;
64
- priority?: string;
65
- note?: string;
66
- }): Promise<void>;
67
- readPrompt(input: {
68
- name: string;
69
- }): Promise<Prompt | null>;
70
- readThread(input: {
71
- threadId: string;
72
- }): Promise<Run>;
73
- updateThreadMetadata(input: {
74
- threadId: string;
75
- metadata: KVMap;
76
- }): Promise<void>;
77
- }
78
- /** An error carrying an HTTP status the engine surfaces to the caller. */
79
- export declare class EnforcementError extends Error {
80
- readonly status: number;
81
- constructor(status: number, message: string);
82
- }
83
- /** Options the engine handler closes over. */
84
- export interface HandlerDeps {
85
- capabilitiesById: Map<string, LangSmithCapability>;
86
- client: LangSmithClient;
87
- identityConfig?: IdentityConfig;
88
- }
89
- /**
90
- * Mount the capability route on the connector's namespaced sub-router. Runs the
91
- * identity-dependent authoring checks at mount time (fails startup on an illegal
92
- * scope/ingress combination), then registers the uniform POST endpoint.
93
- */
94
- export declare function mountLangSmithRoutes(ctx: HttpContext, capabilities: LangSmithCapability[], client?: LangSmithClient): void;
95
- /** Identity-aware authoring validation, run when the app is constructed. */
96
- export declare function validateAgainstIdentity(capabilities: LangSmithCapability[], identity: IdentityConfig | undefined): void;
97
- /** The per-request enforcement pipeline. Returns a JSON `Response`. */
98
- export declare function handleCapabilityRequest(request: Request, identity: RuntimeIdentity, deps: HandlerDeps): Promise<Response>;
99
- /** Map the resolved identity + ingress mode to a caller surface. */
100
- export declare function callerSurface(identity: RuntimeIdentity, identityConfig: IdentityConfig | undefined): LangSmithCallerSurface;
101
- /** Apply the capability's `include` allowlist, then drop any `redact` roots. */
102
- export declare function shapeResponse(raw: Record<string, unknown>, capability: LangSmithCapability): Record<string, unknown>;
103
- /**
104
- * Default client backed by the `langsmith` SDK {@link Client}. The underlying
105
- * client is created on first use so building the engine (e.g. for an app with no
106
- * requests yet) never requires `LANGSMITH_API_KEY`.
107
- *
108
- * A connector "score" is numeric/boolean → LangSmith `score`, or categorical
109
- * (string/object) → LangSmith feedback `value`.
110
- */
111
- export declare function defaultClient(): LangSmithClient;
112
- //# sourceMappingURL=langsmith-connector.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"langsmith-connector.d.ts","sourceRoot":"","sources":["../../src/runtime/langsmith-connector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EACV,OAAO,EACP,QAAQ,EACR,KAAK,EACL,MAAM,EACN,GAAG,EACH,SAAS,EACT,SAAS,EACV,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,KAAK,EACV,mBAAmB,EACnB,sBAAsB,EACvB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD;;;;;;;;;GASG;AACH,MAAM,WAAW,eAAe;IAC9B,cAAc,CAAC,KAAK,EAAE;QACpB,KAAK,EAAE,MAAM,CAAC;QACd,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;QAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IACtB,cAAc,CAAC,KAAK,EAAE;QACpB,UAAU,EAAE,MAAM,CAAC;QACnB,KAAK,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;QAC9B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