managed-deepagents 0.1.0 → 0.3.0
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/langsmith.d.ts +385 -0
- package/dist/connectors/langsmith.d.ts.map +1 -0
- package/dist/connectors/langsmith.js +431 -0
- package/dist/connectors/langsmith.js.map +1 -0
- package/dist/connectors.d.ts +7 -2
- package/dist/connectors.d.ts.map +1 -1
- package/dist/connectors.js +18 -1
- package/dist/connectors.js.map +1 -1
- package/dist/identity/index.d.ts +88 -0
- package/dist/identity/index.d.ts.map +1 -0
- package/dist/identity/index.js +303 -0
- package/dist/identity/index.js.map +1 -0
- package/dist/identity/supabase.d.ts +48 -0
- package/dist/identity/supabase.d.ts.map +1 -0
- package/dist/identity/supabase.js +139 -0
- package/dist/identity/supabase.js.map +1 -0
- package/dist/identity/types.d.ts +185 -0
- package/dist/identity/types.d.ts.map +1 -0
- package/dist/identity/types.js +8 -0
- package/dist/identity/types.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/runtime/auth.d.ts +56 -0
- package/dist/runtime/auth.d.ts.map +1 -0
- package/dist/runtime/auth.js +204 -0
- package/dist/runtime/auth.js.map +1 -0
- package/dist/runtime/connector.d.ts +138 -0
- package/dist/runtime/connector.d.ts.map +1 -0
- package/dist/runtime/connector.js +82 -0
- package/dist/runtime/connector.js.map +1 -0
- package/dist/runtime/credentials.d.ts +68 -0
- package/dist/runtime/credentials.d.ts.map +1 -0
- package/dist/runtime/credentials.js +212 -0
- package/dist/runtime/credentials.js.map +1 -0
- package/dist/runtime/identity-http.d.ts +27 -0
- package/dist/runtime/identity-http.d.ts.map +1 -0
- package/dist/runtime/identity-http.js +159 -0
- package/dist/runtime/identity-http.js.map +1 -0
- package/dist/runtime/identity-runtime.d.ts +54 -0
- package/dist/runtime/identity-runtime.d.ts.map +1 -0
- package/dist/runtime/identity-runtime.js +151 -0
- package/dist/runtime/identity-runtime.js.map +1 -0
- package/dist/runtime/index.d.ts +14 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +114 -68
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/langsmith-connector.d.ts +247 -0
- package/dist/runtime/langsmith-connector.d.ts.map +1 -0
- package/dist/runtime/langsmith-connector.js +1175 -0
- package/dist/runtime/langsmith-connector.js.map +1 -0
- package/dist/runtime/managed-middleware.d.ts +25 -0
- package/dist/runtime/managed-middleware.d.ts.map +1 -0
- package/dist/runtime/managed-middleware.js +76 -0
- package/dist/runtime/managed-middleware.js.map +1 -0
- package/dist/runtime/managed-tools.d.ts +61 -0
- package/dist/runtime/managed-tools.d.ts.map +1 -0
- package/dist/runtime/managed-tools.js +102 -0
- package/dist/runtime/managed-tools.js.map +1 -0
- package/dist/runtime/sandbox-manager.d.ts +3 -2
- package/dist/runtime/sandbox-manager.d.ts.map +1 -1
- package/dist/runtime/sandbox-manager.js.map +1 -1
- package/dist/runtime/setup-script.d.ts +4 -7
- package/dist/runtime/setup-script.d.ts.map +1 -1
- package/dist/runtime/setup-script.js.map +1 -1
- package/dist/runtime/types.d.ts +23 -21
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/runtime/validated-token.d.ts +53 -0
- package/dist/runtime/validated-token.d.ts.map +1 -0
- package/dist/runtime/validated-token.js +411 -0
- package/dist/runtime/validated-token.js.map +1 -0
- package/dist/types.d.ts +15 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +12 -8
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LangSmith connector — authoring surface.
|
|
3
|
+
*
|
|
4
|
+
* A capability-delegation layer for *external / untrusted* callers (browsers,
|
|
5
|
+
* channels, schedules). The deployment declares a small set of constrained
|
|
6
|
+
* LangSmith capabilities; MDA performs them server-side with the workspace key
|
|
7
|
+
* and returns allowlisted responses. The browser never receives
|
|
8
|
+
* `LANGSMITH_API_KEY`.
|
|
9
|
+
*
|
|
10
|
+
* This module is authoring-only: typed per-resource builders + presets that
|
|
11
|
+
* compile to grants, plus eager validation. The runtime enforcement engine lives
|
|
12
|
+
* in `runtime/langsmith-connector.ts` and is mounted synchronously by the
|
|
13
|
+
* connector's `http` hook so routes register before LangGraph captures the
|
|
14
|
+
* custom HTTP app.
|
|
15
|
+
*/
|
|
16
|
+
import { CONNECTOR_BRAND, } from "../runtime/connector.js";
|
|
17
|
+
import { mountLangSmithRoutes } from "../runtime/langsmith-connector.js";
|
|
18
|
+
/** Conservative default `include` allowlists per resource (browser-safe). */
|
|
19
|
+
const DEFAULT_INCLUDE = {
|
|
20
|
+
runs: ["id", "status", "start_time", "end_time", "url", "metadata"],
|
|
21
|
+
feedback: ["id", "run_id", "key", "score", "created_at"],
|
|
22
|
+
examples: ["id", "dataset_id", "created_at"],
|
|
23
|
+
prompts: ["name", "commit_hash", "updated_at"],
|
|
24
|
+
threads: ["thread_id", "created_at", "metadata.title"],
|
|
25
|
+
};
|
|
26
|
+
/** Fields that can never reach a browser without an explicit `allowSensitive`. */
|
|
27
|
+
const SENSITIVE_FIELDS = {
|
|
28
|
+
runs: ["inputs", "outputs", "events"],
|
|
29
|
+
prompts: ["content", "messages"],
|
|
30
|
+
threads: ["messages", "values"],
|
|
31
|
+
};
|
|
32
|
+
/** Constraint keys each resource understands. Unknown keys fail validation. */
|
|
33
|
+
const ALLOWED_CONSTRAINT_KEYS = {
|
|
34
|
+
runs: [],
|
|
35
|
+
feedback: ["keys", "scores", "maxCommentChars", "onePerActor"],
|
|
36
|
+
examples: ["dataset", "allowedFields", "maxExamplesPerThread"],
|
|
37
|
+
annotation_queues: ["queue", "allowedPriorities", "maxNoteChars"],
|
|
38
|
+
prompts: [],
|
|
39
|
+
threads: ["metadataKeys", "maxTitleChars"],
|
|
40
|
+
};
|
|
41
|
+
function omitUndefined(value) {
|
|
42
|
+
return Object.fromEntries(Object.entries(value).filter(([, v]) => v !== undefined));
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Build a `runs` capability grant (`read` / `share`).
|
|
46
|
+
*
|
|
47
|
+
* Use for redacted trace summaries and share links. Prefer {@link traceViewer}
|
|
48
|
+
* when the default browser surface is enough.
|
|
49
|
+
*
|
|
50
|
+
* @param options - Grant id, surfaces, actions, scope, and optional response shaping.
|
|
51
|
+
* @returns A compiled {@link LangSmithCapability} for the `runs` resource.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* langsmith.runs({
|
|
56
|
+
* id: "app:run-summary",
|
|
57
|
+
* exposeTo: ["browser"],
|
|
58
|
+
* actions: ["read", "share"],
|
|
59
|
+
* scope: "thread",
|
|
60
|
+
* })
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export function runs(options) {
|
|
64
|
+
return {
|
|
65
|
+
id: options.id,
|
|
66
|
+
exposeTo: options.exposeTo,
|
|
67
|
+
resource: "runs",
|
|
68
|
+
actions: options.actions,
|
|
69
|
+
scope: options.scope,
|
|
70
|
+
response: {
|
|
71
|
+
include: options.include ?? DEFAULT_INCLUDE.runs,
|
|
72
|
+
redact: options.redact ?? SENSITIVE_FIELDS.runs,
|
|
73
|
+
},
|
|
74
|
+
...(options.allowSensitive
|
|
75
|
+
? { allowSensitive: options.allowSensitive }
|
|
76
|
+
: {}),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Build a `feedback` capability grant (`create` / `update` / `delete`).
|
|
81
|
+
*
|
|
82
|
+
* Constrains keys, optional categorical scores, comment length, and
|
|
83
|
+
* per-actor uniqueness. Prefer {@link chatFeedback} for the common browser
|
|
84
|
+
* thumbs-up/down + dataset capture surface.
|
|
85
|
+
*
|
|
86
|
+
* @param options - Grant id, surfaces, actions, key/score constraints, and shaping.
|
|
87
|
+
* @returns A compiled {@link LangSmithCapability} for the `feedback` resource.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```ts
|
|
91
|
+
* langsmith.feedback({
|
|
92
|
+
* id: "app:user-score",
|
|
93
|
+
* exposeTo: ["browser"],
|
|
94
|
+
* actions: ["create", "update", "delete"],
|
|
95
|
+
* scope: "run",
|
|
96
|
+
* keys: ["user_score"],
|
|
97
|
+
* scores: ["positive", "negative"],
|
|
98
|
+
* onePerActor: true,
|
|
99
|
+
* })
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
export function feedback(options) {
|
|
103
|
+
return {
|
|
104
|
+
id: options.id,
|
|
105
|
+
exposeTo: options.exposeTo,
|
|
106
|
+
resource: "feedback",
|
|
107
|
+
actions: options.actions,
|
|
108
|
+
scope: options.scope ?? "run",
|
|
109
|
+
constraints: omitUndefined({
|
|
110
|
+
keys: options.keys,
|
|
111
|
+
scores: options.scores,
|
|
112
|
+
maxCommentChars: options.maxCommentChars,
|
|
113
|
+
onePerActor: options.onePerActor,
|
|
114
|
+
}),
|
|
115
|
+
response: { include: options.include ?? DEFAULT_INCLUDE.feedback },
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Build an `examples` capability grant (`create` into a fixed dataset).
|
|
120
|
+
*
|
|
121
|
+
* The dataset name is fixed in the grant so callers cannot write to arbitrary
|
|
122
|
+
* datasets. Prefer {@link chatFeedback} when pairing with run feedback.
|
|
123
|
+
*
|
|
124
|
+
* @param options - Grant id, surfaces, dataset, and optional field/thread caps.
|
|
125
|
+
* @returns A compiled {@link LangSmithCapability} for the `examples` resource.
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```ts
|
|
129
|
+
* langsmith.examples({
|
|
130
|
+
* id: "app:capture-thread",
|
|
131
|
+
* exposeTo: ["browser"],
|
|
132
|
+
* actions: ["create"],
|
|
133
|
+
* scope: "thread",
|
|
134
|
+
* dataset: "public-feedback",
|
|
135
|
+
* allowedFields: ["messages", "answer", "feedback", "source"],
|
|
136
|
+
* })
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
export function examples(options) {
|
|
140
|
+
return {
|
|
141
|
+
id: options.id,
|
|
142
|
+
exposeTo: options.exposeTo,
|
|
143
|
+
resource: "examples",
|
|
144
|
+
actions: options.actions,
|
|
145
|
+
scope: options.scope ?? "thread",
|
|
146
|
+
constraints: omitUndefined({
|
|
147
|
+
dataset: options.dataset,
|
|
148
|
+
allowedFields: options.allowedFields,
|
|
149
|
+
maxExamplesPerThread: options.maxExamplesPerThread,
|
|
150
|
+
}),
|
|
151
|
+
response: { include: options.include ?? DEFAULT_INCLUDE.examples },
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Build an `annotation_queues` capability grant (`enqueue_run` into a fixed queue).
|
|
156
|
+
*
|
|
157
|
+
* The queue is fixed in the grant so callers cannot enqueue into arbitrary
|
|
158
|
+
* queues.
|
|
159
|
+
*
|
|
160
|
+
* @param options - Grant id, surfaces, queue, and optional priority/note limits.
|
|
161
|
+
* @returns A compiled {@link LangSmithCapability} for the `annotation_queues` resource.
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```ts
|
|
165
|
+
* langsmith.annotationQueues({
|
|
166
|
+
* id: "app:enqueue-review",
|
|
167
|
+
* exposeTo: ["trusted_backend"],
|
|
168
|
+
* actions: ["enqueue_run"],
|
|
169
|
+
* scope: "run",
|
|
170
|
+
* queue: "human-review",
|
|
171
|
+
* })
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
export function annotationQueues(options) {
|
|
175
|
+
return {
|
|
176
|
+
id: options.id,
|
|
177
|
+
exposeTo: options.exposeTo,
|
|
178
|
+
resource: "annotation_queues",
|
|
179
|
+
actions: options.actions,
|
|
180
|
+
scope: options.scope ?? "run",
|
|
181
|
+
constraints: omitUndefined({
|
|
182
|
+
queue: options.queue,
|
|
183
|
+
allowedPriorities: options.allowedPriorities,
|
|
184
|
+
maxNoteChars: options.maxNoteChars,
|
|
185
|
+
}),
|
|
186
|
+
// Enqueue is a write with no readable body; include stays minimal.
|
|
187
|
+
response: { include: ["id"] },
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Build a `prompts` capability grant (`read_metadata`).
|
|
192
|
+
*
|
|
193
|
+
* Returns prompt metadata only by default; prompt body fields stay redacted.
|
|
194
|
+
*
|
|
195
|
+
* @param options - Grant id, surfaces, and optional response shaping.
|
|
196
|
+
* @returns A compiled {@link LangSmithCapability} for the `prompts` resource.
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```ts
|
|
200
|
+
* langsmith.prompts({
|
|
201
|
+
* id: "app:prompt-meta",
|
|
202
|
+
* exposeTo: ["browser"],
|
|
203
|
+
* actions: ["read_metadata"],
|
|
204
|
+
* scope: "agent",
|
|
205
|
+
* })
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
export function prompts(options) {
|
|
209
|
+
return {
|
|
210
|
+
id: options.id,
|
|
211
|
+
exposeTo: options.exposeTo,
|
|
212
|
+
resource: "prompts",
|
|
213
|
+
actions: options.actions,
|
|
214
|
+
scope: options.scope ?? "agent",
|
|
215
|
+
response: {
|
|
216
|
+
include: options.include ?? DEFAULT_INCLUDE.prompts,
|
|
217
|
+
redact: options.redact ?? SENSITIVE_FIELDS.prompts,
|
|
218
|
+
},
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Build a `threads` capability grant (`read` / `update_metadata`).
|
|
223
|
+
*
|
|
224
|
+
* Thread message bodies stay redacted unless `allowSensitive` acknowledges
|
|
225
|
+
* them for a browser surface.
|
|
226
|
+
*
|
|
227
|
+
* @param options - Grant id, surfaces, actions, metadata constraints, and shaping.
|
|
228
|
+
* @returns A compiled {@link LangSmithCapability} for the `threads` resource.
|
|
229
|
+
*
|
|
230
|
+
* @example
|
|
231
|
+
* ```ts
|
|
232
|
+
* langsmith.threads({
|
|
233
|
+
* id: "app:thread-title",
|
|
234
|
+
* exposeTo: ["browser"],
|
|
235
|
+
* actions: ["read", "update_metadata"],
|
|
236
|
+
* scope: "actor",
|
|
237
|
+
* metadataKeys: ["title"],
|
|
238
|
+
* maxTitleChars: 120,
|
|
239
|
+
* })
|
|
240
|
+
* ```
|
|
241
|
+
*/
|
|
242
|
+
export function threads(options) {
|
|
243
|
+
return {
|
|
244
|
+
id: options.id,
|
|
245
|
+
exposeTo: options.exposeTo,
|
|
246
|
+
resource: "threads",
|
|
247
|
+
actions: options.actions,
|
|
248
|
+
scope: options.scope ?? "actor",
|
|
249
|
+
constraints: omitUndefined({
|
|
250
|
+
metadataKeys: options.metadataKeys,
|
|
251
|
+
maxTitleChars: options.maxTitleChars,
|
|
252
|
+
}),
|
|
253
|
+
response: {
|
|
254
|
+
include: options.include ?? DEFAULT_INCLUDE.threads,
|
|
255
|
+
redact: SENSITIVE_FIELDS.threads,
|
|
256
|
+
},
|
|
257
|
+
...(options.allowSensitive
|
|
258
|
+
? { allowSensitive: options.allowSensitive }
|
|
259
|
+
: {}),
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
// --- Presets ---------------------------------------------------------------
|
|
263
|
+
/**
|
|
264
|
+
* Browser chat feedback preset: thumbs up/down on a run, plus optional dataset
|
|
265
|
+
* capture of the conversation.
|
|
266
|
+
*
|
|
267
|
+
* Expands to two grants with stable capability ids (safe to hard-code in
|
|
268
|
+
* clients):
|
|
269
|
+
*
|
|
270
|
+
* - `langsmith:chat-feedback` — run-scoped {@link feedback} for browsers.
|
|
271
|
+
* Key `user_score`, scores `positive`/`negative`, comments ≤ 2000 chars,
|
|
272
|
+
* `onePerActor: true`.
|
|
273
|
+
* - `langsmith:chat-feedback-examples` — thread-scoped {@link examples} create
|
|
274
|
+
* into `dataset`, allowing fields `messages`, `answer`, `feedback`, `source`.
|
|
275
|
+
*
|
|
276
|
+
* Pass the returned array (or spread it) into {@link connector}.
|
|
277
|
+
*
|
|
278
|
+
* @param options.dataset - LangSmith dataset name for the examples capability.
|
|
279
|
+
* @returns Capability grants for feedback + example capture.
|
|
280
|
+
*
|
|
281
|
+
* @example
|
|
282
|
+
* ```ts
|
|
283
|
+
* export default langsmith.connector(
|
|
284
|
+
* langsmith.chatFeedback({ dataset: "public-feedback" }),
|
|
285
|
+
* );
|
|
286
|
+
* // POST /connectors/langsmith/capabilities/langsmith:chat-feedback
|
|
287
|
+
* ```
|
|
288
|
+
*/
|
|
289
|
+
export function chatFeedback(options) {
|
|
290
|
+
return [
|
|
291
|
+
feedback({
|
|
292
|
+
id: "langsmith:chat-feedback",
|
|
293
|
+
exposeTo: ["browser"],
|
|
294
|
+
actions: ["create", "update", "delete"],
|
|
295
|
+
scope: "run",
|
|
296
|
+
keys: ["user_score"],
|
|
297
|
+
scores: ["positive", "negative"],
|
|
298
|
+
maxCommentChars: 2000,
|
|
299
|
+
onePerActor: true,
|
|
300
|
+
}),
|
|
301
|
+
examples({
|
|
302
|
+
id: "langsmith:chat-feedback-examples",
|
|
303
|
+
exposeTo: ["browser"],
|
|
304
|
+
actions: ["create"],
|
|
305
|
+
scope: "thread",
|
|
306
|
+
dataset: options.dataset,
|
|
307
|
+
allowedFields: ["messages", "answer", "feedback", "source"],
|
|
308
|
+
}),
|
|
309
|
+
];
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Browser trace viewer preset: read a redacted run summary and create a share
|
|
313
|
+
* link for the caller's thread.
|
|
314
|
+
*
|
|
315
|
+
* Expands to one grant with a stable capability id:
|
|
316
|
+
*
|
|
317
|
+
* - `langsmith:trace-viewer` — thread-scoped {@link runs} with actions
|
|
318
|
+
* `read` and `share`, exposed to `browser`. Responses include
|
|
319
|
+
* `id` / `status` / `start_time` / `end_time` / `url` / `metadata` and redact
|
|
320
|
+
* `inputs` / `outputs` / `events` by default.
|
|
321
|
+
*
|
|
322
|
+
* Pass the returned array (or spread it) into {@link connector}.
|
|
323
|
+
*
|
|
324
|
+
* @returns Capability grant for redacted run read/share.
|
|
325
|
+
*
|
|
326
|
+
* @example
|
|
327
|
+
* ```ts
|
|
328
|
+
* export default langsmith.connector(langsmith.traceViewer());
|
|
329
|
+
* // POST /connectors/langsmith/capabilities/langsmith:trace-viewer
|
|
330
|
+
* ```
|
|
331
|
+
*/
|
|
332
|
+
export function traceViewer() {
|
|
333
|
+
return [
|
|
334
|
+
runs({
|
|
335
|
+
id: "langsmith:trace-viewer",
|
|
336
|
+
exposeTo: ["browser"],
|
|
337
|
+
actions: ["read", "share"],
|
|
338
|
+
scope: "thread",
|
|
339
|
+
}),
|
|
340
|
+
];
|
|
341
|
+
}
|
|
342
|
+
// --- Validation ------------------------------------------------------------
|
|
343
|
+
/**
|
|
344
|
+
* Fail-closed authoring checks that do not require the identity config. The
|
|
345
|
+
* identity-dependent checks (scope/ingress sanity, tenancy) run when the
|
|
346
|
+
* connector's `http` hook is mounted, where the resolved identity is available.
|
|
347
|
+
*/
|
|
348
|
+
export function validateLangSmithConnector(capabilities) {
|
|
349
|
+
if (capabilities.length === 0) {
|
|
350
|
+
throw new Error("langsmith.connector(...) requires at least one capability.");
|
|
351
|
+
}
|
|
352
|
+
const seen = new Set();
|
|
353
|
+
for (const capability of capabilities) {
|
|
354
|
+
validateCapability(capability, seen);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
function validateCapability(capability, seen) {
|
|
358
|
+
if (!capability.id) {
|
|
359
|
+
throw new Error("Every LangSmith capability requires an `id`.");
|
|
360
|
+
}
|
|
361
|
+
if (seen.has(capability.id)) {
|
|
362
|
+
throw new Error(`Duplicate LangSmith capability id: "${capability.id}".`);
|
|
363
|
+
}
|
|
364
|
+
seen.add(capability.id);
|
|
365
|
+
if (capability.exposeTo.length === 0) {
|
|
366
|
+
throw new Error(`LangSmith capability "${capability.id}" must declare at least one exposeTo surface.`);
|
|
367
|
+
}
|
|
368
|
+
if (capability.actions.length === 0) {
|
|
369
|
+
throw new Error(`LangSmith capability "${capability.id}" must declare at least one action.`);
|
|
370
|
+
}
|
|
371
|
+
// Every external-surface grant needs an explicit include allowlist.
|
|
372
|
+
const include = capability.response?.include;
|
|
373
|
+
if (!include || include.length === 0) {
|
|
374
|
+
throw new Error(`LangSmith capability "${capability.id}" must set response.include ` +
|
|
375
|
+
`(fail-closed: unknown fields are dropped).`);
|
|
376
|
+
}
|
|
377
|
+
assertSensitiveOptIn(capability, include);
|
|
378
|
+
assertKnownConstraintKeys(capability);
|
|
379
|
+
}
|
|
380
|
+
function assertSensitiveOptIn(capability, include) {
|
|
381
|
+
const sensitive = SENSITIVE_FIELDS[capability.resource] ?? [];
|
|
382
|
+
const acknowledged = new Set(capability.allowSensitive ?? []);
|
|
383
|
+
const browserExposed = capability.exposeTo.includes("browser");
|
|
384
|
+
if (!browserExposed) {
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
for (const field of include) {
|
|
388
|
+
const root = field.split(".")[0] ?? field;
|
|
389
|
+
if (sensitive.includes(root) && !acknowledged.has(root)) {
|
|
390
|
+
throw new Error(`LangSmith capability "${capability.id}" includes sensitive field ` +
|
|
391
|
+
`"${root}" for a browser surface. Add allowSensitive: ["${root}"] to ` +
|
|
392
|
+
`acknowledge exposing it.`);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
function assertKnownConstraintKeys(capability) {
|
|
397
|
+
const allowed = ALLOWED_CONSTRAINT_KEYS[capability.resource];
|
|
398
|
+
if (!capability.constraints || allowed === undefined) {
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
for (const key of Object.keys(capability.constraints)) {
|
|
402
|
+
if (!allowed.includes(key)) {
|
|
403
|
+
throw new Error(`LangSmith capability "${capability.id}" has unknown constraint ` +
|
|
404
|
+
`"${key}" for resource "${capability.resource}".`);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Build a branded LangSmith connector from capabilities (or preset-produced
|
|
410
|
+
* capability arrays). Runs {@link validateLangSmithConnector} eagerly, then
|
|
411
|
+
* returns a connector whose `http` hook mounts the enforcement engine.
|
|
412
|
+
*/
|
|
413
|
+
export function connector(...capabilities) {
|
|
414
|
+
const flat = capabilities.flat();
|
|
415
|
+
validateLangSmithConnector(flat);
|
|
416
|
+
const instance = {
|
|
417
|
+
[CONNECTOR_BRAND]: true,
|
|
418
|
+
kind: "langsmith",
|
|
419
|
+
capabilities: flat,
|
|
420
|
+
/**
|
|
421
|
+
* Mount must be synchronous: `buildManagedHttpApp` does not await hooks,
|
|
422
|
+
* and LangGraph captures custom routes at import time. A dynamic `import()`
|
|
423
|
+
* here races that capture and leaves connector paths as platform 404s.
|
|
424
|
+
*/
|
|
425
|
+
http(ctx) {
|
|
426
|
+
mountLangSmithRoutes(ctx, flat);
|
|
427
|
+
},
|
|
428
|
+
};
|
|
429
|
+
return instance;
|
|
430
|
+
}
|
|
431
|
+
//# sourceMappingURL=langsmith.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"langsmith.js","sourceRoot":"","sources":["../../src/connectors/langsmith.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,eAAe,GAGhB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAsDzE,6EAA6E;AAC7E,MAAM,eAAe,GAAiD;IACpE,IAAI,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,CAAC;IACnE,QAAQ,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,CAAC;IACxD,QAAQ,EAAE,CAAC,IAAI,EAAE,YAAY,EAAE,YAAY,CAAC;IAC5C,OAAO,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,YAAY,CAAC;IAC9C,OAAO,EAAE,CAAC,WAAW,EAAE,YAAY,EAAE,gBAAgB,CAAC;CACvD,CAAC;AAEF,kFAAkF;AACl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AC;IACD,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;QACtD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CACb,yBAAyB,UAAU,CAAC,EAAE,2BAA2B;gBAC/D,IAAI,GAAG,mBAAmB,UAAU,CAAC,QAAQ,IAAI,CACpD,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC;AAUD;;;;GAIG;AACH,MAAM,UAAU,SAAS,CACvB,GAAG,YAAgE;IAEnE,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,EAAE,CAAC;IACjC,0BAA0B,CAAC,IAAI,CAAC,CAAC;IAEjC,MAAM,QAAQ,GAAG;QACf,CAAC,eAAe,CAAC,EAAE,IAAa;QAChC,IAAI,EAAE,WAAoB;QAC1B,YAAY,EAAE,IAAI;QAClB;;;;WAIG;QACH,IAAI,CAAC,GAAgB;YACnB,oBAAoB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAClC,CAAC;KACF,CAAC;IACF,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/dist/connectors.d.ts
CHANGED
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
* });
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
|
+
import { type Connector } from "./runtime/connector.js";
|
|
38
39
|
/** Per-server MCP tool selection. Names are raw, unprefixed MCP tool names. */
|
|
39
40
|
export interface McpToolSelectionConfig {
|
|
40
41
|
/**
|
|
@@ -110,8 +111,12 @@ export interface McpServersConfig {
|
|
|
110
111
|
*/
|
|
111
112
|
onConnectionError?: "throw";
|
|
112
113
|
}
|
|
113
|
-
/**
|
|
114
|
-
|
|
114
|
+
/**
|
|
115
|
+
* The connector exported from a `connectors/` module for MCP. It is a branded
|
|
116
|
+
* managed {@link Connector} whose `tools` hook loads the declared MCP tools at
|
|
117
|
+
* runtime, plus the raw config the loader reads.
|
|
118
|
+
*/
|
|
119
|
+
export interface McpServersDefinition extends McpServersConfig, Connector {
|
|
115
120
|
/** Internal discriminator used by the MDA loader. */
|
|
116
121
|
readonly kind: "mcp_servers";
|
|
117
122
|
}
|
package/dist/connectors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connectors.d.ts","sourceRoot":"","sources":["../src/connectors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,+EAA+E;AAC/E,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,4DAA4D;AAC5D,MAAM,WAAW,yBAA0B,SAAQ,sBAAsB;IACvE,6CAA6C;IAC7C,GAAG,EAAE,MAAM,CAAC;IACZ,sEAAsE;IACtE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,2EAA2E;IAC3E,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,6CAA6C;AAC7C,MAAM,WAAW,mBAAoB,SAAQ,yBAAyB;IACpE,0DAA0D;IAC1D,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,wCAAwC;AACxC,MAAM,WAAW,kBAAmB,SAAQ,yBAAyB;IACnE,oDAAoD;IACpD,SAAS,EAAE,KAAK,CAAC;IACjB,iDAAiD;IACjD,SAAS,CAAC,EAAE;QACV,OAAO,EAAE,OAAO,CAAC;QACjB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED,gFAAgF;AAChF,MAAM,MAAM,qBAAqB,GAAG,mBAAmB,GAAG,kBAAkB,CAAC;AAE7E,0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OAAO,EAAE,OAAO,CAAC;QACjB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED,gFAAgF;AAChF,MAAM,MAAM,qBAAqB,GAAG,mBAAmB,GAAG,kBAAkB,CAAC;AAE7E,0DAA0D;AAC1D,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;IAClD;;;;OAIG;IACH,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;OAGG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAqB,SAAQ,gBAAgB,EAAE,SAAS;IACvE,qDAAqD;IACrD,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;CAC9B;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,gBAAgB,GACvB,oBAAoB,CA4CtB"}
|
package/dist/connectors.js
CHANGED
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
* });
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
|
+
import { CONNECTOR_BRAND } from "./runtime/connector.js";
|
|
38
39
|
/**
|
|
39
40
|
* Declare the MCP servers whose tools should be loaded and added to the managed
|
|
40
41
|
* Deep Agent at runtime.
|
|
@@ -61,7 +62,23 @@ export function defineMcpServers(config) {
|
|
|
61
62
|
for (const [name, server] of entries) {
|
|
62
63
|
validateRemoteServer(name, server);
|
|
63
64
|
}
|
|
64
|
-
|
|
65
|
+
const definition = { kind: "mcp_servers", ...config };
|
|
66
|
+
// Brand it as a connector without exposing the symbol as an enumerable field.
|
|
67
|
+
Object.defineProperty(definition, CONNECTOR_BRAND, {
|
|
68
|
+
value: true,
|
|
69
|
+
enumerable: false,
|
|
70
|
+
});
|
|
71
|
+
// The tools hook runs at agent-graph construction time (inside the managed
|
|
72
|
+
// runtime), so the MCP client loader is imported lazily — authoring-only
|
|
73
|
+
// installs never pull in `@langchain/mcp-adapters`.
|
|
74
|
+
Object.defineProperty(definition, "tools", {
|
|
75
|
+
value: async () => {
|
|
76
|
+
const { loadManagedMcpTools } = await import("./runtime/connectors-manager.js");
|
|
77
|
+
return loadManagedMcpTools(definition);
|
|
78
|
+
},
|
|
79
|
+
enumerable: false,
|
|
80
|
+
});
|
|
81
|
+
return definition;
|
|
65
82
|
}
|
|
66
83
|
/** Allowed remote transports. Stdio is intentionally unsupported in v0. */
|
|
67
84
|
const REMOTE_TRANSPORTS = new Set(["http", "sse"]);
|
package/dist/connectors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connectors.js","sourceRoot":"","sources":["../src/connectors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;
|
|
1
|
+
{"version":3,"file":"connectors.js","sourceRoot":"","sources":["../src/connectors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,EAAE,eAAe,EAAkB,MAAM,wBAAwB,CAAC;AA6FzE;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAC9B,MAAwB;IAExB,MAAM,QAAQ,GAAG,MAA4C,CAAC;IAC9D,MAAM,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC;IAEpC,IACE,OAAO,KAAK,IAAI;QAChB,OAAO,OAAO,KAAK,QAAQ;QAC3B,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EACtB,CAAC;QACD,MAAM,IAAI,KAAK,CACb,uEAAuE;YACrE,qCAAqC,CACxC,CAAC;IACJ,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,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CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CACb,eAAe,IAAI,iDAAiD;YAClE,qBAAqB,SAAS,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CACtD,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAS,oBAAoB,CAC3B,UAAkB,EAClB,KAAsC,EACtC,KAAc;IAEd,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CACb,eAAe,UAAU,OAAO,KAAK,iCAAiC,CACvE,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,KAAK,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;QAC5C,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzD,MAAM,IAAI,KAAK,CACb,eAAe,UAAU,OAAO,KAAK,YAAY,KAAK,8BAA8B,CACrF,CAAC;QACJ,CAAC;QACD,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CACb,eAAe,UAAU,OAAO,KAAK,oCAAoC,IAAI,IAAI,CAClF,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACjB,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The managed `identity.ts` declaration primitive.
|
|
3
|
+
*
|
|
4
|
+
* A project's root `identity.ts` exports a named `identity` created with
|
|
5
|
+
* `defineIdentity(...)` (or `defineIdentity.preset(...)`). The compiler
|
|
6
|
+
* discovers it, generates the custom-auth handler, and wires thread/memory
|
|
7
|
+
* scoping and downstream credentials.
|
|
8
|
+
*
|
|
9
|
+
* This module is pure authoring-time config construction plus eager validation —
|
|
10
|
+
* it has no runtime dependency (the `providers.*` helpers return plain data).
|
|
11
|
+
*/
|
|
12
|
+
import { type SupabaseProviderOptions } from "./supabase.js";
|
|
13
|
+
import type { IdentityConfig, IdentityDefinition, IdentityPresetName, ValidatedTokenProvider } from "./types.js";
|
|
14
|
+
export type { CredentialResolver, CredentialResolverConfig, CredentialScope, CredentialTarget, HttpIngress, IdentityConfig, IdentityDefinition, IdentityPresetName, MemoryScope, ResolvedCredential, RuntimeIdentity, Tenancy, ThreadScope, ValidatedTokenIngress, ValidatedTokenProvider, } from "./types.js";
|
|
15
|
+
export type { SupabaseProviderOptions, SupabaseRegion } from "./supabase.js";
|
|
16
|
+
export { supabaseAuthV1Base } from "./supabase.js";
|
|
17
|
+
/** The signature of {@link defineIdentity}, including its `.preset` helper. */
|
|
18
|
+
export interface DefineIdentity {
|
|
19
|
+
(config: IdentityConfig): IdentityDefinition;
|
|
20
|
+
/**
|
|
21
|
+
* Start from a named archetype and optionally override any subset of it. The
|
|
22
|
+
* headline API for the common case.
|
|
23
|
+
*/
|
|
24
|
+
preset(name: IdentityPresetName, overrides?: DeepPartial<IdentityConfig>): IdentityDefinition;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Declare the identity contract for the deployment.
|
|
28
|
+
*
|
|
29
|
+
* Most developers call {@link defineIdentity.preset} instead. The three scoping
|
|
30
|
+
* axes are the power-user layer underneath.
|
|
31
|
+
*/
|
|
32
|
+
export declare const defineIdentity: DefineIdentity;
|
|
33
|
+
/**
|
|
34
|
+
* Provider integrations — authoring-time sugar over {@link ValidatedTokenProvider}.
|
|
35
|
+
* Each returns a plain provider object you can spread-and-override, so
|
|
36
|
+
* there is no new runtime surface.
|
|
37
|
+
*/
|
|
38
|
+
export declare const providers: {
|
|
39
|
+
auth0({ domain, audience, }: {
|
|
40
|
+
domain: string;
|
|
41
|
+
audience?: string;
|
|
42
|
+
}): ValidatedTokenProvider;
|
|
43
|
+
clerk({ domain }: {
|
|
44
|
+
domain: string;
|
|
45
|
+
}): ValidatedTokenProvider;
|
|
46
|
+
okta({ domain, audience, }: {
|
|
47
|
+
domain: string;
|
|
48
|
+
audience?: string;
|
|
49
|
+
}): ValidatedTokenProvider;
|
|
50
|
+
cognito({ userPoolId, region, }: {
|
|
51
|
+
userPoolId: string;
|
|
52
|
+
region: string;
|
|
53
|
+
}): ValidatedTokenProvider;
|
|
54
|
+
entra({ tenantId, audience, }: {
|
|
55
|
+
tenantId: string;
|
|
56
|
+
audience?: string;
|
|
57
|
+
}): ValidatedTokenProvider;
|
|
58
|
+
google({ audience }?: {
|
|
59
|
+
audience?: string;
|
|
60
|
+
}): ValidatedTokenProvider;
|
|
61
|
+
/** @see {@link supabaseProvider} */
|
|
62
|
+
supabase(options: SupabaseProviderOptions): ValidatedTokenProvider;
|
|
63
|
+
/** Universal fallback for any OIDC-compliant IdP via discovery. */
|
|
64
|
+
oidc({ issuer, audience, }: {
|
|
65
|
+
issuer: string;
|
|
66
|
+
audience?: string;
|
|
67
|
+
}): ValidatedTokenProvider;
|
|
68
|
+
/**
|
|
69
|
+
* GitHub OAuth access tokens (opaque bearer tokens, not JWTs). MDA verifies
|
|
70
|
+
* each request by calling `GET https://api.github.com/user` with the token.
|
|
71
|
+
*/
|
|
72
|
+
github(): ValidatedTokenProvider;
|
|
73
|
+
/** MDA-issued anonymous/guest tokens. */
|
|
74
|
+
guest({ ttl, actorPrefix, }?: {
|
|
75
|
+
ttl?: string;
|
|
76
|
+
actorPrefix?: string;
|
|
77
|
+
}): ValidatedTokenProvider;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Eagerly reject illegal identity configs at authoring time so misconfig never
|
|
81
|
+
* reaches the compiler or runtime.
|
|
82
|
+
*/
|
|
83
|
+
export declare function validateIdentity(config: IdentityConfig): void;
|
|
84
|
+
/** Recursively merge plain objects; arrays and primitives from `patch` win. */
|
|
85
|
+
type DeepPartial<T> = T extends object ? {
|
|
86
|
+
[K in keyof T]?: DeepPartial<T[K]>;
|
|
87
|
+
} : T;
|
|
88
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/identity/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,KAAK,uBAAuB,EAAoB,MAAM,eAAe,CAAC;AAC/E,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAElB,sBAAsB,EACvB,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,kBAAkB,EAClB,wBAAwB,EACxB,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,OAAO,EACP,WAAW,EACX,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,YAAY,CAAC;AAEpB,YAAY,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AA8BnD,+EAA+E;AAC/E,MAAM,WAAW,cAAc;IAC7B,CAAC,MAAM,EAAE,cAAc,GAAG,kBAAkB,CAAC;IAC7C;;;OAGG;IACH,MAAM,CACJ,IAAI,EAAE,kBAAkB,EACxB,SAAS,CAAC,EAAE,WAAW,CAAC,cAAc,CAAC,GACtC,kBAAkB,CAAC;CACvB;AAED;;;;;GAKG;AACH,eAAO,MAAM,cAAc,EAAE,cAoB5B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,SAAS;iCAIjB;QACD,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GAAG,sBAAsB;s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