managed-deepagents 0.5.0-dev.89 → 0.5.0-dev.90
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/channels/index.d.ts +6 -5
- package/dist/channels/index.d.ts.map +1 -1
- package/dist/channels/index.js +6 -5
- package/dist/channels/index.js.map +1 -1
- package/dist/channels/messaging-registry.d.ts +8 -4
- package/dist/channels/messaging-registry.d.ts.map +1 -1
- package/dist/channels/messaging-registry.js +22 -16
- package/dist/channels/messaging-registry.js.map +1 -1
- package/dist/channels/registry-types.d.ts +1 -1
- package/dist/channels/registry-types.d.ts.map +1 -1
- package/dist/channels/registry.d.ts.map +1 -1
- package/dist/channels/registry.js +1 -3
- package/dist/channels/registry.js.map +1 -1
- package/dist/channels/schedule-delivery.js +1 -1
- package/dist/channels/schedule-delivery.js.map +1 -1
- package/dist/{connectors → channels}/slack/adapter-core.d.ts +1 -1
- package/dist/channels/slack/adapter-core.d.ts.map +1 -0
- package/dist/channels/slack/adapter-core.js.map +1 -0
- package/dist/{connectors → channels}/slack/adapter.d.ts +3 -3
- package/dist/channels/slack/adapter.d.ts.map +1 -0
- package/dist/channels/slack/adapter.js.map +1 -0
- package/dist/{connectors → channels}/slack/http.d.ts +4 -4
- package/dist/channels/slack/http.d.ts.map +1 -0
- package/dist/{connectors → channels}/slack/http.js +6 -6
- package/dist/channels/slack/http.js.map +1 -0
- package/dist/channels/slack/index.d.ts +89 -0
- package/dist/channels/slack/index.d.ts.map +1 -0
- package/dist/channels/slack/index.js +148 -0
- package/dist/channels/slack/index.js.map +1 -0
- package/dist/{connectors → channels}/slack/normalize.d.ts +3 -3
- package/dist/channels/slack/normalize.d.ts.map +1 -0
- package/dist/{connectors → channels}/slack/normalize.js +1 -1
- package/dist/channels/slack/normalize.js.map +1 -0
- package/dist/channels/slack/source-thread.d.ts.map +1 -0
- package/dist/channels/slack/source-thread.js.map +1 -0
- package/dist/{connectors → channels}/slack/transport.d.ts +1 -1
- package/dist/channels/slack/transport.d.ts.map +1 -0
- package/dist/{connectors → channels}/slack/transport.js +1 -1
- package/dist/channels/slack/transport.js.map +1 -0
- package/dist/connectors/slack/index.d.ts +10 -79
- package/dist/connectors/slack/index.d.ts.map +1 -1
- package/dist/connectors/slack/index.js +24 -127
- package/dist/connectors/slack/index.js.map +1 -1
- package/dist/connectors/toolserver/catalog.d.ts +4 -10
- package/dist/connectors/toolserver/catalog.d.ts.map +1 -1
- package/dist/connectors/toolserver/catalog.js +6 -54
- package/dist/connectors/toolserver/catalog.js.map +1 -1
- package/dist/connectors/toolserver/index.d.ts +5 -7
- package/dist/connectors/toolserver/index.d.ts.map +1 -1
- package/dist/connectors/toolserver/index.js +4 -6
- package/dist/connectors/toolserver/index.js.map +1 -1
- package/dist/connectors/toolserver/integrations.d.ts +4 -4
- package/dist/connectors/toolserver/integrations.d.ts.map +1 -1
- package/dist/extension.d.ts +1 -1
- package/dist/extension.js +1 -1
- package/dist/identity/connect-inference.d.ts +6 -7
- package/dist/identity/connect-inference.d.ts.map +1 -1
- package/dist/identity/connect-inference.js +7 -9
- package/dist/identity/connect-inference.js.map +1 -1
- package/dist/identity/github/connect-http.d.ts +4 -4
- package/dist/identity/github/connect-http.js +4 -4
- package/dist/identity/github/index.d.ts +0 -2
- package/dist/identity/github/index.d.ts.map +1 -1
- package/dist/identity/github/index.js +0 -2
- package/dist/identity/github/index.js.map +1 -1
- package/dist/identity/options.d.ts +2 -3
- package/dist/identity/options.d.ts.map +1 -1
- package/dist/identity/options.js.map +1 -1
- package/dist/identity/slack/connect-http.d.ts +3 -1
- package/dist/identity/slack/connect-http.d.ts.map +1 -1
- package/dist/identity/slack/connect-http.js +3 -1
- package/dist/identity/slack/connect-http.js.map +1 -1
- package/dist/identity/slack/links.d.ts +2 -1
- package/dist/identity/slack/links.d.ts.map +1 -1
- package/dist/identity/slack/links.js +2 -1
- package/dist/identity/slack/links.js.map +1 -1
- package/dist/identity/types.d.ts +1 -1
- package/dist/identity/types.d.ts.map +1 -1
- package/dist/index.d.ts +4 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/namespaces.d.ts +45 -83
- package/dist/namespaces.d.ts.map +1 -1
- package/dist/namespaces.js +12 -21
- package/dist/namespaces.js.map +1 -1
- package/dist/runtime/auth.d.ts +1 -1
- package/dist/runtime/auth.d.ts.map +1 -1
- package/dist/runtime/auth.js +13 -3
- package/dist/runtime/auth.js.map +1 -1
- package/dist/runtime/channel.d.ts +91 -0
- package/dist/runtime/channel.d.ts.map +1 -0
- package/dist/runtime/channel.js +98 -0
- package/dist/runtime/channel.js.map +1 -0
- package/dist/runtime/connector.d.ts +1 -1
- package/dist/runtime/connector.js +5 -1
- package/dist/runtime/connector.js.map +1 -1
- package/dist/runtime/cors.d.ts +1 -1
- package/dist/runtime/cors.d.ts.map +1 -1
- package/dist/runtime/cors.js +5 -1
- package/dist/runtime/cors.js.map +1 -1
- package/dist/runtime/http.d.ts +1 -2
- package/dist/runtime/http.d.ts.map +1 -1
- package/dist/runtime/http.js +1 -2
- package/dist/runtime/http.js.map +1 -1
- package/dist/runtime/identity-http.d.ts +8 -3
- package/dist/runtime/identity-http.d.ts.map +1 -1
- package/dist/runtime/identity-http.js +50 -8
- package/dist/runtime/identity-http.js.map +1 -1
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +4 -0
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/types.d.ts +8 -0
- package/dist/runtime/types.d.ts.map +1 -1
- package/package.json +7 -7
- package/dist/connectors/github/adapter-core.d.ts +0 -15
- package/dist/connectors/github/adapter-core.d.ts.map +0 -1
- package/dist/connectors/github/adapter-core.js +0 -52
- package/dist/connectors/github/adapter-core.js.map +0 -1
- package/dist/connectors/github/define.d.ts +0 -168
- package/dist/connectors/github/define.d.ts.map +0 -1
- package/dist/connectors/github/define.js +0 -72
- package/dist/connectors/github/define.js.map +0 -1
- package/dist/connectors/github/http.d.ts +0 -25
- package/dist/connectors/github/http.d.ts.map +0 -1
- package/dist/connectors/github/http.js +0 -146
- package/dist/connectors/github/http.js.map +0 -1
- package/dist/connectors/github/index.d.ts +0 -121
- package/dist/connectors/github/index.d.ts.map +0 -1
- package/dist/connectors/github/index.js +0 -192
- package/dist/connectors/github/index.js.map +0 -1
- package/dist/connectors/github/match.d.ts +0 -20
- package/dist/connectors/github/match.d.ts.map +0 -1
- package/dist/connectors/github/match.js +0 -41
- package/dist/connectors/github/match.js.map +0 -1
- package/dist/connectors/github/normalize.d.ts +0 -32
- package/dist/connectors/github/normalize.d.ts.map +0 -1
- package/dist/connectors/github/normalize.js +0 -152
- package/dist/connectors/github/normalize.js.map +0 -1
- package/dist/connectors/github/sandbox.d.ts +0 -54
- package/dist/connectors/github/sandbox.d.ts.map +0 -1
- package/dist/connectors/github/sandbox.js +0 -532
- package/dist/connectors/github/sandbox.js.map +0 -1
- package/dist/connectors/github/source-thread.d.ts +0 -24
- package/dist/connectors/github/source-thread.d.ts.map +0 -1
- package/dist/connectors/github/source-thread.js +0 -54
- package/dist/connectors/github/source-thread.js.map +0 -1
- package/dist/connectors/github/transport.d.ts +0 -25
- package/dist/connectors/github/transport.d.ts.map +0 -1
- package/dist/connectors/github/transport.js +0 -106
- package/dist/connectors/github/transport.js.map +0 -1
- package/dist/connectors/langsmith/index.d.ts +0 -397
- package/dist/connectors/langsmith/index.d.ts.map +0 -1
- package/dist/connectors/langsmith/index.js +0 -436
- package/dist/connectors/langsmith/index.js.map +0 -1
- package/dist/connectors/langsmith/routes.d.ts +0 -236
- package/dist/connectors/langsmith/routes.d.ts.map +0 -1
- package/dist/connectors/langsmith/routes.js +0 -1154
- package/dist/connectors/langsmith/routes.js.map +0 -1
- package/dist/connectors/slack/adapter-core.d.ts.map +0 -1
- package/dist/connectors/slack/adapter-core.js.map +0 -1
- package/dist/connectors/slack/adapter.d.ts.map +0 -1
- package/dist/connectors/slack/adapter.js.map +0 -1
- package/dist/connectors/slack/http.d.ts.map +0 -1
- package/dist/connectors/slack/http.js.map +0 -1
- package/dist/connectors/slack/normalize.d.ts.map +0 -1
- package/dist/connectors/slack/normalize.js.map +0 -1
- package/dist/connectors/slack/source-thread.d.ts.map +0 -1
- package/dist/connectors/slack/source-thread.js.map +0 -1
- package/dist/connectors/slack/transport.d.ts.map +0 -1
- package/dist/connectors/slack/transport.js.map +0 -1
- /package/dist/{connectors → channels}/slack/adapter-core.js +0 -0
- /package/dist/{connectors → channels}/slack/adapter.js +0 -0
- /package/dist/{connectors → channels}/slack/source-thread.d.ts +0 -0
- /package/dist/{connectors → channels}/slack/source-thread.js +0 -0
|
@@ -1,436 +0,0 @@
|
|
|
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 `./routes.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 { defineExtension } from "../../extension.js";
|
|
17
|
-
import { mountLangSmithRoutes } from "./routes.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: ["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: "user",
|
|
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 ?? "user",
|
|
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 in `capabilities`.
|
|
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 const connector = connectors.langsmith({
|
|
284
|
-
* capabilities: [connectors.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 in `capabilities`.
|
|
323
|
-
*
|
|
324
|
-
* @returns Capability grant for redacted run read/share.
|
|
325
|
-
*
|
|
326
|
-
* @example
|
|
327
|
-
* ```ts
|
|
328
|
-
* export const connector = connectors.langsmith({
|
|
329
|
-
* capabilities: [connectors.langsmith.traceViewer()],
|
|
330
|
-
* });
|
|
331
|
-
* // POST /connectors/langsmith/capabilities/langsmith:trace-viewer
|
|
332
|
-
* ```
|
|
333
|
-
*/
|
|
334
|
-
export function traceViewer() {
|
|
335
|
-
return [
|
|
336
|
-
runs({
|
|
337
|
-
id: "langsmith:trace-viewer",
|
|
338
|
-
exposeTo: ["browser"],
|
|
339
|
-
actions: ["read", "share"],
|
|
340
|
-
scope: "thread",
|
|
341
|
-
}),
|
|
342
|
-
];
|
|
343
|
-
}
|
|
344
|
-
// --- Validation ------------------------------------------------------------
|
|
345
|
-
/**
|
|
346
|
-
* Fail-closed authoring checks that do not require the identity config. The
|
|
347
|
-
* identity-dependent checks (scope/ingress sanity, tenancy) run when the
|
|
348
|
-
* connector's `http` hook is mounted, where the resolved identity is available.
|
|
349
|
-
*/
|
|
350
|
-
export function validateLangSmithConnector(capabilities) {
|
|
351
|
-
if (capabilities.length === 0) {
|
|
352
|
-
throw new Error("connectors.langsmith(...) requires at least one capability.");
|
|
353
|
-
}
|
|
354
|
-
const seen = new Set();
|
|
355
|
-
for (const capability of capabilities) {
|
|
356
|
-
validateCapability(capability, seen);
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
function validateCapability(capability, seen) {
|
|
360
|
-
if (!capability.id) {
|
|
361
|
-
throw new Error("Every LangSmith capability requires an `id`.");
|
|
362
|
-
}
|
|
363
|
-
if (seen.has(capability.id)) {
|
|
364
|
-
throw new Error(`Duplicate LangSmith capability id: "${capability.id}".`);
|
|
365
|
-
}
|
|
366
|
-
seen.add(capability.id);
|
|
367
|
-
if (capability.exposeTo.length === 0) {
|
|
368
|
-
throw new Error(`LangSmith capability "${capability.id}" must declare at least one exposeTo surface.`);
|
|
369
|
-
}
|
|
370
|
-
if (capability.actions.length === 0) {
|
|
371
|
-
throw new Error(`LangSmith capability "${capability.id}" must declare at least one action.`);
|
|
372
|
-
}
|
|
373
|
-
// Every external-surface grant needs an explicit include allowlist.
|
|
374
|
-
const include = capability.response?.include;
|
|
375
|
-
if (!include || include.length === 0) {
|
|
376
|
-
throw new Error(`LangSmith capability "${capability.id}" must set response.include ` +
|
|
377
|
-
`(fail-closed: unknown fields are dropped).`);
|
|
378
|
-
}
|
|
379
|
-
assertSensitiveOptIn(capability, include);
|
|
380
|
-
assertKnownConstraintKeys(capability);
|
|
381
|
-
}
|
|
382
|
-
function assertSensitiveOptIn(capability, include) {
|
|
383
|
-
const sensitive = SENSITIVE_FIELDS[capability.resource] ?? [];
|
|
384
|
-
const acknowledged = new Set(capability.allowSensitive ?? []);
|
|
385
|
-
const browserExposed = capability.exposeTo.includes("browser");
|
|
386
|
-
if (!browserExposed) {
|
|
387
|
-
return;
|
|
388
|
-
}
|
|
389
|
-
for (const field of include) {
|
|
390
|
-
const root = field.split(".")[0] ?? field;
|
|
391
|
-
if (sensitive.includes(root) && !acknowledged.has(root)) {
|
|
392
|
-
throw new Error(`LangSmith capability "${capability.id}" includes sensitive field ` +
|
|
393
|
-
`"${root}" for a browser surface. Add allowSensitive: ["${root}"] to ` +
|
|
394
|
-
`acknowledge exposing it.`);
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
function assertKnownConstraintKeys(capability) {
|
|
399
|
-
const allowed = ALLOWED_CONSTRAINT_KEYS[capability.resource];
|
|
400
|
-
if (!capability.constraints || allowed === undefined) {
|
|
401
|
-
return;
|
|
402
|
-
}
|
|
403
|
-
for (const key of Object.keys(capability.constraints)) {
|
|
404
|
-
if (!allowed.includes(key)) {
|
|
405
|
-
throw new Error(`LangSmith capability "${capability.id}" has unknown constraint ` +
|
|
406
|
-
`"${key}" for resource "${capability.resource}".`);
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
/**
|
|
411
|
-
* Build a branded LangSmith connector from capabilities (or preset-produced
|
|
412
|
-
* capability arrays). Runs {@link validateLangSmithConnector} eagerly, then
|
|
413
|
-
* returns a connector whose `http` hook mounts the enforcement engine.
|
|
414
|
-
*
|
|
415
|
-
* Mounting must be synchronous: `buildManagedHttpApp` does not await hooks, and
|
|
416
|
-
* LangGraph captures custom routes at import time. A dynamic `import()` here
|
|
417
|
-
* would race that capture and leave connector paths as platform 404s.
|
|
418
|
-
*
|
|
419
|
-
* `args` is a function rather than a schema: capabilities come from the
|
|
420
|
-
* builders above, already typed, and what is left to check is policy that spans
|
|
421
|
-
* fields — a browser-exposed grant acknowledging its sensitive fields,
|
|
422
|
-
* constraint keys that depend on the resource. Those read better as code.
|
|
423
|
-
*/
|
|
424
|
-
export const langsmithConnector = defineExtension("connector", {
|
|
425
|
-
kind: "langsmith",
|
|
426
|
-
label: "connectors.langsmith",
|
|
427
|
-
args: (config) => {
|
|
428
|
-
const capabilities = (config?.capabilities ?? []).flat();
|
|
429
|
-
validateLangSmithConnector(capabilities);
|
|
430
|
-
return { capabilities };
|
|
431
|
-
},
|
|
432
|
-
http(ctx, self) {
|
|
433
|
-
mountLangSmithRoutes(ctx, self.capabilities);
|
|
434
|
-
},
|
|
435
|
-
});
|
|
436
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/connectors/langsmith/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AA8CnD,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;AAClF,MAAM,gBAAgB,GAAiD;IACrE,IAAI,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC;IACrC,OAAO,EAAE,CAAC,SAAS,EAAE,UAAU,CAAC;IAChC,OAAO,EAAE,CAAC,UAAU,EAAE,QAAQ,CAAC;CAChC,CAAC;AAEF,+EAA+E;AAC/E,MAAM,uBAAuB,GAAiD;IAC5E,IAAI,EAAE,EAAE;IACR,QAAQ,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,iBAAiB,EAAE,aAAa,CAAC;IAC9D,QAAQ,EAAE,CAAC,SAAS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AAM,kBAAkB,GAEL,eAAe,CAAC,WAAW,EAAE;IACrD,IAAI,EAAE,WAAW;IACjB,KAAK,EAAE,sBAAsB;IAC7B,IAAI,EAAE,CAAC,MAAgC,EAAE,EAAE;QACzC,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,YAAY,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QACzD,0BAA0B,CAAC,YAAY,CAAC,CAAC;QACzC,OAAO,EAAE,YAAY,EAAE,CAAC;IAC1B,CAAC;IACD,IAAI,CAAC,GAAG,EAAE,IAAI;QACZ,oBAAoB,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAC/C,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -1,236 +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, proves capability ownership from `runtime.identity`, validates typed
|
|
12
|
-
* constraints, performs the LangSmith operation server-side with the workspace
|
|
13
|
-
* key, and returns an allowlisted response.
|
|
14
|
-
*
|
|
15
|
-
* v0 has no rate limiting, audit, or multi-workspace fan-out.
|
|
16
|
-
*/
|
|
17
|
-
import type { Example, Feedback, KVMap, Prompt, Run, ScoreType, ValueType } from "langsmith/schemas";
|
|
18
|
-
import type { IdentityConfig, RuntimeIdentity } from "../../identity/index.js";
|
|
19
|
-
import type { HttpContext } from "../../runtime/connector.js";
|
|
20
|
-
import type { LangSmithCapability, LangSmithCallerSurface } from "./index.js";
|
|
21
|
-
/**
|
|
22
|
-
* The thin LangSmith operations the engine needs, typed against the `langsmith`
|
|
23
|
-
* SDK's own schemas. {@link defaultClient} wraps a real {@link Client}; tests
|
|
24
|
-
* inject a fake so the enforcement logic is verified without network or SDK
|
|
25
|
-
* specifics.
|
|
26
|
-
*
|
|
27
|
-
* A connector "score" is a categorical value (e.g. `"positive"`), so it maps to
|
|
28
|
-
* a LangSmith `score` when numeric/boolean and to a feedback `value` otherwise —
|
|
29
|
-
* hence the `ScoreType | ValueType` inputs.
|
|
30
|
-
*/
|
|
31
|
-
export interface LangSmithClient {
|
|
32
|
-
createFeedback(input: {
|
|
33
|
-
runId: string;
|
|
34
|
-
key: string;
|
|
35
|
-
score?: ScoreType | ValueType;
|
|
36
|
-
comment?: string;
|
|
37
|
-
feedbackId?: string;
|
|
38
|
-
metadata?: KVMap;
|
|
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
|
-
listFeedbackForRun(input: {
|
|
49
|
-
runId: string;
|
|
50
|
-
}): Promise<Feedback[]>;
|
|
51
|
-
readFeedback(input: {
|
|
52
|
-
feedbackId: string;
|
|
53
|
-
}): Promise<Feedback>;
|
|
54
|
-
readRun(input: {
|
|
55
|
-
runId: string;
|
|
56
|
-
}): Promise<Run>;
|
|
57
|
-
shareRun(input: {
|
|
58
|
-
runId: string;
|
|
59
|
-
}): Promise<{
|
|
60
|
-
url: string;
|
|
61
|
-
}>;
|
|
62
|
-
createExample(input: {
|
|
63
|
-
dataset: string;
|
|
64
|
-
inputs: KVMap;
|
|
65
|
-
outputs?: KVMap;
|
|
66
|
-
metadata?: KVMap;
|
|
67
|
-
}): Promise<Example>;
|
|
68
|
-
listExamples(input: {
|
|
69
|
-
dataset: string;
|
|
70
|
-
metadata?: KVMap;
|
|
71
|
-
}): Promise<Example[]>;
|
|
72
|
-
enqueueRun(input: {
|
|
73
|
-
queue: string;
|
|
74
|
-
runId: string;
|
|
75
|
-
priority?: string;
|
|
76
|
-
note?: string;
|
|
77
|
-
}): Promise<void>;
|
|
78
|
-
readPrompt(input: {
|
|
79
|
-
name: string;
|
|
80
|
-
}): Promise<Prompt | null>;
|
|
81
|
-
readThread(input: {
|
|
82
|
-
threadId: string;
|
|
83
|
-
}): Promise<Run>;
|
|
84
|
-
updateThreadMetadata(input: {
|
|
85
|
-
threadId: string;
|
|
86
|
-
metadata: KVMap;
|
|
87
|
-
}): Promise<void>;
|
|
88
|
-
}
|
|
89
|
-
/** An error carrying an HTTP status the engine surfaces to the caller. */
|
|
90
|
-
export declare class EnforcementError extends Error {
|
|
91
|
-
readonly status: number;
|
|
92
|
-
/**
|
|
93
|
-
* @param status - HTTP status code returned to the caller.
|
|
94
|
-
* @param message - Human-readable error detail.
|
|
95
|
-
*/
|
|
96
|
-
constructor(status: number, message: string);
|
|
97
|
-
}
|
|
98
|
-
/** Options the engine handler closes over. */
|
|
99
|
-
export interface HandlerDeps {
|
|
100
|
-
capabilitiesById: Map<string, LangSmithCapability>;
|
|
101
|
-
client: LangSmithClient;
|
|
102
|
-
identityConfig?: IdentityConfig;
|
|
103
|
-
/**
|
|
104
|
-
* Prove the caller may access a LangGraph thread. Required when binding a
|
|
105
|
-
* client-supplied thread id (browser connector path). Injected in tests;
|
|
106
|
-
* production defaults to a same-origin `GET /threads/{id}` ownership check.
|
|
107
|
-
*/
|
|
108
|
-
assertThreadAccess?: AssertThreadAccess;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Fail closed unless the authenticated caller may access `threadId`.
|
|
112
|
-
*
|
|
113
|
-
* @param threadId - LangGraph thread id to authorize.
|
|
114
|
-
* @returns Resolves when access is allowed; rejects with `EnforcementError` on denial.
|
|
115
|
-
*/
|
|
116
|
-
export type AssertThreadAccess = (threadId: string) => Promise<void>;
|
|
117
|
-
/**
|
|
118
|
-
* Mount the capability route on the connector's namespaced sub-router. Runs the
|
|
119
|
-
* identity-dependent authoring checks at mount time (fails startup on an illegal
|
|
120
|
-
* scope/ingress combination), then registers the uniform POST endpoint.
|
|
121
|
-
*
|
|
122
|
-
* @param ctx - HTTP mount context with the namespaced router and identity config.
|
|
123
|
-
* @param capabilities - Declared LangSmith capabilities to expose.
|
|
124
|
-
* @param client - LangSmith client used for server-side operations; defaults to {@link defaultClient}.
|
|
125
|
-
*/
|
|
126
|
-
export declare function mountLangSmithRoutes(ctx: HttpContext, capabilities: LangSmithCapability[], client?: LangSmithClient): void;
|
|
127
|
-
/**
|
|
128
|
-
* Identity-aware authoring validation, run when the app is constructed.
|
|
129
|
-
* Rejects illegal scope/ingress combinations before any request is served.
|
|
130
|
-
*
|
|
131
|
-
* @param capabilities - Declared LangSmith capabilities to validate.
|
|
132
|
-
* @param identity - Deployment identity config, or `undefined` when identity is not configured.
|
|
133
|
-
* @throws {Error} When a capability's scope or exposure is illegal for this deployment.
|
|
134
|
-
*/
|
|
135
|
-
export declare function validateAgainstIdentity(capabilities: LangSmithCapability[], identity: IdentityConfig | undefined): void;
|
|
136
|
-
/**
|
|
137
|
-
* Per-request enforcement pipeline for a capability POST.
|
|
138
|
-
* Resolves the capability, checks surface/action, proves thread ownership when
|
|
139
|
-
* needed, enforces scope, performs the LangSmith call, and shapes the response.
|
|
140
|
-
*
|
|
141
|
-
* @param request - Incoming HTTP request for `/capabilities/:id`.
|
|
142
|
-
* @param identity - Frozen runtime identity resolved by the secure router.
|
|
143
|
-
* @param deps - Closed-over capabilities map, LangSmith client, and optional access prover.
|
|
144
|
-
* @returns JSON `Response` with `{ data }` on success or `{ error }` on failure.
|
|
145
|
-
*/
|
|
146
|
-
export declare function handleCapabilityRequest(request: Request, identity: RuntimeIdentity, deps: HandlerDeps): Promise<Response>;
|
|
147
|
-
/**
|
|
148
|
-
* Map the resolved identity + ingress mode to a caller surface.
|
|
149
|
-
*
|
|
150
|
-
* @param identity - Frozen runtime identity for this request.
|
|
151
|
-
* @param identityConfig - Deployment identity config (ingress mode).
|
|
152
|
-
* @returns The surface used for `exposeTo` checks (`browser`, `backend`, `channel`, or `schedule`).
|
|
153
|
-
*/
|
|
154
|
-
export declare function callerSurface(identity: RuntimeIdentity, identityConfig: IdentityConfig | undefined): LangSmithCallerSurface;
|
|
155
|
-
/**
|
|
156
|
-
* Attach a proven thread id onto a copy of the identity envelope.
|
|
157
|
-
* Returns the same object when the identity already carries that thread id.
|
|
158
|
-
*
|
|
159
|
-
* @param identity - Frozen runtime identity to copy.
|
|
160
|
-
* @param threadId - Proven thread id to bind onto `source.threadId`.
|
|
161
|
-
* @returns Identity with `source.threadId` set to `threadId`.
|
|
162
|
-
*/
|
|
163
|
-
export declare function withIdentityThread(identity: RuntimeIdentity, threadId: string): RuntimeIdentity;
|
|
164
|
-
/**
|
|
165
|
-
* Resolve the thread id for a thread/run-scoped capability and prove access
|
|
166
|
-
* when it did not come from the trusted identity envelope.
|
|
167
|
-
*
|
|
168
|
-
* - identity `source.threadId` (server-derived from agent runs) is trusted
|
|
169
|
-
* - LangSmith run session/thread (when `run_id` is present) is authoritative
|
|
170
|
-
* - bare body `threadId`/`thread_id` (no identity thread, no run) requires
|
|
171
|
-
* {@link AssertThreadAccess}
|
|
172
|
-
*
|
|
173
|
-
* @param capability - Capability whose `scope` drives whether a thread id is required.
|
|
174
|
-
* @param identity - Frozen runtime identity for this request.
|
|
175
|
-
* @param body - Parsed JSON request body.
|
|
176
|
-
* @param client - LangSmith client used to load a run when `run_id` is present.
|
|
177
|
-
* @param assertThreadAccess - Ownership prover for bare body thread ids.
|
|
178
|
-
* @returns Proven thread id, or the identity thread id for non-thread/run scopes.
|
|
179
|
-
* @throws {EnforcementError} On missing/mismatched thread ids or failed ownership proof.
|
|
180
|
-
*/
|
|
181
|
-
export declare function resolveProvenThreadId(capability: LangSmithCapability, identity: RuntimeIdentity, body: Record<string, unknown>, client: LangSmithClient, assertThreadAccess: AssertThreadAccess): Promise<string | undefined>;
|
|
182
|
-
/**
|
|
183
|
-
* Build the default ownership proof: `GET /threads/{id}` with the caller's
|
|
184
|
-
* credentials and require `metadata.owner` to match the identity's thread-owner key.
|
|
185
|
-
*
|
|
186
|
-
* @param request - Incoming request whose auth headers are forwarded to the thread GET.
|
|
187
|
-
* @param identity - Frozen runtime identity used to derive the expected owner key.
|
|
188
|
-
* @param _identityConfig - Unused; retained for call-site compatibility.
|
|
189
|
-
* @returns An `AssertThreadAccess` function closed over the request and expected owner.
|
|
190
|
-
*/
|
|
191
|
-
export declare function defaultAssertThreadAccess(request: Request, identity: RuntimeIdentity, _identityConfig: IdentityConfig | undefined): AssertThreadAccess;
|
|
192
|
-
/**
|
|
193
|
-
* Prove the capability's ownership scope from `runtime.identity` before the
|
|
194
|
-
* LangSmith call. Thread id must already be present on identity when required
|
|
195
|
-
* (see {@link resolveProvenThreadId}).
|
|
196
|
-
*
|
|
197
|
-
* @param capability - Capability whose `scope` is enforced.
|
|
198
|
-
* @param identity - Identity with any proven thread id already bound.
|
|
199
|
-
* @param body - Parsed JSON request body (used for run-scoped `run_id` checks).
|
|
200
|
-
* @param client - LangSmith client used to load runs for run-scope verification.
|
|
201
|
-
* @throws {EnforcementError} When the identity lacks the required scope fields or the run is foreign.
|
|
202
|
-
*/
|
|
203
|
-
export declare function assertCapabilityScope(capability: LangSmithCapability, identity: RuntimeIdentity, body: Record<string, unknown>, client: LangSmithClient): Promise<void>;
|
|
204
|
-
/**
|
|
205
|
-
* Apply the capability's `include` allowlist, then drop any `redact` roots.
|
|
206
|
-
*
|
|
207
|
-
* @param raw - Full LangSmith result coerced to a plain record.
|
|
208
|
-
* @param capability - Capability whose `response.include` / `response.redact` apply.
|
|
209
|
-
* @returns Allowlisted (and redacted) response object returned to the caller.
|
|
210
|
-
*/
|
|
211
|
-
export declare function shapeResponse(raw: Record<string, unknown>, capability: LangSmithCapability): Record<string, unknown>;
|
|
212
|
-
/**
|
|
213
|
-
* Read a required string from the body, accepting either camelCase or snake_case.
|
|
214
|
-
*
|
|
215
|
-
* @param body - Parsed JSON request body.
|
|
216
|
-
* @param camel - Preferred camelCase field name (used in error messages).
|
|
217
|
-
* @param snake - Alternate snake_case field name.
|
|
218
|
-
* @returns Non-empty string from either key.
|
|
219
|
-
* @throws {EnforcementError} When neither key yields a non-empty string.
|
|
220
|
-
*/
|
|
221
|
-
export declare function bodyString(body: Record<string, unknown>, camel: string, snake: string): string;
|
|
222
|
-
/**
|
|
223
|
-
* Default client backed by the `langsmith` SDK {@link Client}. The underlying
|
|
224
|
-
* client is created on first use so building the engine (e.g. for an app with no
|
|
225
|
-
* requests yet) never requires `LANGSMITH_API_KEY`.
|
|
226
|
-
*
|
|
227
|
-
* Passes `LANGSMITH_WORKSPACE_ID` when deploy (or local `.env`) provided it so
|
|
228
|
-
* run/feedback calls target that workspace rather than the API key default.
|
|
229
|
-
*
|
|
230
|
-
* A connector "score" is numeric/boolean → LangSmith `score`, or categorical
|
|
231
|
-
* (string/object) → LangSmith feedback `value`.
|
|
232
|
-
*
|
|
233
|
-
* @returns `LangSmithClient` adapter over the official SDK.
|
|
234
|
-
*/
|
|
235
|
-
export declare function defaultClient(): LangSmithClient;
|
|
236
|
-
//# sourceMappingURL=routes.d.ts.map
|