@sentry/junior-plugin-api 0.62.0 → 0.64.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/index.d.ts +104 -7
- package/dist/index.js +37 -1
- package/package.json +1 -1
- package/src/index.ts +179 -8
package/dist/index.d.ts
CHANGED
|
@@ -146,20 +146,117 @@ export interface HeartbeatHookContext extends AgentPluginContext {
|
|
|
146
146
|
export interface HeartbeatResult {
|
|
147
147
|
dispatchCount?: number;
|
|
148
148
|
}
|
|
149
|
+
export type AgentPluginRouteMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS" | "ALL";
|
|
150
|
+
export type AgentPluginRouteHandler = {
|
|
151
|
+
bivarianceHack(request: Request): Promise<Response> | Response;
|
|
152
|
+
}["bivarianceHack"];
|
|
153
|
+
export interface AgentPluginRoute {
|
|
154
|
+
handler: AgentPluginRouteHandler;
|
|
155
|
+
method?: AgentPluginRouteMethod | AgentPluginRouteMethod[];
|
|
156
|
+
path: string;
|
|
157
|
+
}
|
|
158
|
+
export interface RouteRegistrationHookContext extends AgentPluginContext {
|
|
159
|
+
}
|
|
160
|
+
export interface SlackConversationLink {
|
|
161
|
+
url: string;
|
|
162
|
+
}
|
|
163
|
+
export interface SlackConversationLinkHookContext extends AgentPluginContext {
|
|
164
|
+
conversationId: string;
|
|
165
|
+
}
|
|
149
166
|
export interface AgentPluginHooks {
|
|
150
167
|
sandboxPrepare?(ctx: SandboxPrepareHookContext): Promise<void> | void;
|
|
151
168
|
beforeToolExecute?(ctx: BeforeToolExecuteHookContext): Promise<void> | void;
|
|
169
|
+
routes?(ctx: RouteRegistrationHookContext): AgentPluginRoute[];
|
|
152
170
|
tools?(ctx: ToolRegistrationHookContext): Record<string, AgentPluginToolDefinition>;
|
|
153
171
|
heartbeat?(ctx: HeartbeatHookContext): Promise<HeartbeatResult | void> | HeartbeatResult | void;
|
|
172
|
+
slackConversationLink?(ctx: SlackConversationLinkHookContext): SlackConversationLink | undefined;
|
|
154
173
|
}
|
|
155
|
-
export interface
|
|
156
|
-
|
|
157
|
-
|
|
174
|
+
export interface JuniorPluginOAuthConfig {
|
|
175
|
+
authorizeEndpoint: string;
|
|
176
|
+
authorizeParams?: Record<string, string>;
|
|
177
|
+
clientIdEnv: string;
|
|
178
|
+
clientSecretEnv: string;
|
|
179
|
+
scope?: string;
|
|
180
|
+
tokenAuthMethod?: "body" | "basic";
|
|
181
|
+
tokenEndpoint: string;
|
|
182
|
+
tokenExtraHeaders?: Record<string, string>;
|
|
183
|
+
}
|
|
184
|
+
export interface JuniorPluginOAuthBearerCredentials {
|
|
185
|
+
apiHeaders?: Record<string, string>;
|
|
186
|
+
authTokenEnv: string;
|
|
187
|
+
authTokenPlaceholder?: string;
|
|
188
|
+
domains: string[];
|
|
189
|
+
type: "oauth-bearer";
|
|
190
|
+
}
|
|
191
|
+
export interface JuniorPluginGitHubAppCredentials {
|
|
192
|
+
apiHeaders?: Record<string, string>;
|
|
193
|
+
appIdEnv: string;
|
|
194
|
+
authTokenEnv: string;
|
|
195
|
+
authTokenPlaceholder?: string;
|
|
196
|
+
domains: string[];
|
|
197
|
+
installationIdEnv: string;
|
|
198
|
+
privateKeyEnv: string;
|
|
199
|
+
type: "github-app";
|
|
200
|
+
}
|
|
201
|
+
export type JuniorPluginCredentials = JuniorPluginOAuthBearerCredentials | JuniorPluginGitHubAppCredentials;
|
|
202
|
+
export interface JuniorPluginNpmRuntimeDependency {
|
|
203
|
+
package: string;
|
|
204
|
+
type: "npm";
|
|
205
|
+
version: string;
|
|
206
|
+
}
|
|
207
|
+
export interface JuniorPluginSystemRuntimeDependency {
|
|
208
|
+
package: string;
|
|
209
|
+
type: "system";
|
|
158
210
|
}
|
|
159
|
-
export interface
|
|
211
|
+
export interface JuniorPluginSystemRuntimeDependencyFromUrl {
|
|
212
|
+
sha256: string;
|
|
213
|
+
type: "system";
|
|
214
|
+
url: string;
|
|
215
|
+
}
|
|
216
|
+
export type JuniorPluginRuntimeDependency = JuniorPluginNpmRuntimeDependency | JuniorPluginSystemRuntimeDependency | JuniorPluginSystemRuntimeDependencyFromUrl;
|
|
217
|
+
export interface JuniorPluginRuntimePostinstallCommand {
|
|
218
|
+
args?: string[];
|
|
219
|
+
cmd: string;
|
|
220
|
+
sudo?: boolean;
|
|
221
|
+
}
|
|
222
|
+
export interface JuniorPluginMcpConfig {
|
|
223
|
+
allowedTools?: string[];
|
|
224
|
+
headers?: Record<string, string>;
|
|
225
|
+
transport: "http";
|
|
226
|
+
url: string;
|
|
227
|
+
}
|
|
228
|
+
export interface JuniorPluginEnvVarDeclaration {
|
|
229
|
+
default?: string;
|
|
230
|
+
}
|
|
231
|
+
export interface JuniorPluginManifest {
|
|
232
|
+
apiHeaders?: Record<string, string>;
|
|
233
|
+
capabilities?: string[];
|
|
234
|
+
commandEnv?: Record<string, string>;
|
|
235
|
+
configKeys?: string[];
|
|
236
|
+
credentials?: JuniorPluginCredentials;
|
|
237
|
+
description: string;
|
|
238
|
+
domains?: string[];
|
|
239
|
+
envVars?: Record<string, JuniorPluginEnvVarDeclaration>;
|
|
240
|
+
mcp?: JuniorPluginMcpConfig;
|
|
241
|
+
name: string;
|
|
242
|
+
oauth?: JuniorPluginOAuthConfig;
|
|
243
|
+
runtimeDependencies?: JuniorPluginRuntimeDependency[];
|
|
244
|
+
runtimePostinstall?: JuniorPluginRuntimePostinstallCommand[];
|
|
245
|
+
target?: {
|
|
246
|
+
commandFlags?: string[];
|
|
247
|
+
configKey: string;
|
|
248
|
+
type: string;
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
export type JuniorPluginRegistrationInput = {
|
|
160
252
|
hooks?: AgentPluginHooks;
|
|
253
|
+
legacyStatePrefixes?: string[];
|
|
254
|
+
manifest: JuniorPluginManifest;
|
|
255
|
+
name?: string;
|
|
256
|
+
packageName?: string;
|
|
257
|
+
};
|
|
258
|
+
export interface JuniorPluginRegistration extends JuniorPluginRegistrationInput {
|
|
161
259
|
name: string;
|
|
162
|
-
pluginConfig?: JuniorPluginConfig;
|
|
163
260
|
}
|
|
164
|
-
/** Define
|
|
165
|
-
export declare function defineJuniorPlugin(plugin:
|
|
261
|
+
/** Define one Junior plugin registration for app and build-time wiring. */
|
|
262
|
+
export declare function defineJuniorPlugin(plugin: JuniorPluginRegistrationInput): JuniorPluginRegistration;
|
package/dist/index.js
CHANGED
|
@@ -5,8 +5,44 @@ var AgentPluginToolInputError = class extends Error {
|
|
|
5
5
|
this.name = "AgentPluginToolInputError";
|
|
6
6
|
}
|
|
7
7
|
};
|
|
8
|
+
var PLUGIN_NAME_RE = /^[a-z][a-z0-9-]*$/;
|
|
8
9
|
function defineJuniorPlugin(plugin) {
|
|
9
|
-
|
|
10
|
+
if ("pluginConfig" in plugin) {
|
|
11
|
+
throw new Error(
|
|
12
|
+
"pluginConfig is no longer supported. Put runtime metadata in manifest and trusted state prefixes on the plugin registration."
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
const manifest = plugin.manifest;
|
|
16
|
+
if (!manifest) {
|
|
17
|
+
throw new Error(
|
|
18
|
+
"defineJuniorPlugin() requires a manifest. Use a package name string in defineJuniorPlugins([...]) for plugin.yaml packages."
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
const name = plugin.name ?? manifest.name;
|
|
22
|
+
if (!name) {
|
|
23
|
+
throw new Error(
|
|
24
|
+
"Junior plugin registrations must include name or manifest.name."
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
if (!PLUGIN_NAME_RE.test(name)) {
|
|
28
|
+
throw new Error(
|
|
29
|
+
`Junior plugin registration name "${name}" must be a lowercase plugin identifier.`
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
if (typeof manifest.description !== "string" || !manifest.description.trim()) {
|
|
33
|
+
throw new Error(
|
|
34
|
+
`Junior plugin "${name}" manifest.description is required.`
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
if (plugin.name && manifest.name && plugin.name !== manifest.name) {
|
|
38
|
+
throw new Error(
|
|
39
|
+
`Junior plugin registration name "${plugin.name}" must match manifest.name "${manifest.name}".`
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
...plugin,
|
|
44
|
+
name
|
|
45
|
+
};
|
|
10
46
|
}
|
|
11
47
|
export {
|
|
12
48
|
AgentPluginToolInputError,
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -177,29 +177,200 @@ export interface HeartbeatResult {
|
|
|
177
177
|
dispatchCount?: number;
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
+
export type AgentPluginRouteMethod =
|
|
181
|
+
| "GET"
|
|
182
|
+
| "POST"
|
|
183
|
+
| "PUT"
|
|
184
|
+
| "PATCH"
|
|
185
|
+
| "DELETE"
|
|
186
|
+
| "HEAD"
|
|
187
|
+
| "OPTIONS"
|
|
188
|
+
| "ALL";
|
|
189
|
+
|
|
190
|
+
export type AgentPluginRouteHandler = {
|
|
191
|
+
bivarianceHack(request: Request): Promise<Response> | Response;
|
|
192
|
+
}["bivarianceHack"];
|
|
193
|
+
|
|
194
|
+
export interface AgentPluginRoute {
|
|
195
|
+
handler: AgentPluginRouteHandler;
|
|
196
|
+
method?: AgentPluginRouteMethod | AgentPluginRouteMethod[];
|
|
197
|
+
path: string;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export interface RouteRegistrationHookContext extends AgentPluginContext {}
|
|
201
|
+
|
|
202
|
+
export interface SlackConversationLink {
|
|
203
|
+
url: string;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export interface SlackConversationLinkHookContext extends AgentPluginContext {
|
|
207
|
+
conversationId: string;
|
|
208
|
+
}
|
|
209
|
+
|
|
180
210
|
export interface AgentPluginHooks {
|
|
181
211
|
sandboxPrepare?(ctx: SandboxPrepareHookContext): Promise<void> | void;
|
|
182
212
|
beforeToolExecute?(ctx: BeforeToolExecuteHookContext): Promise<void> | void;
|
|
213
|
+
routes?(ctx: RouteRegistrationHookContext): AgentPluginRoute[];
|
|
183
214
|
tools?(
|
|
184
215
|
ctx: ToolRegistrationHookContext,
|
|
185
216
|
): Record<string, AgentPluginToolDefinition>;
|
|
186
217
|
heartbeat?(
|
|
187
218
|
ctx: HeartbeatHookContext,
|
|
188
219
|
): Promise<HeartbeatResult | void> | HeartbeatResult | void;
|
|
220
|
+
slackConversationLink?(
|
|
221
|
+
ctx: SlackConversationLinkHookContext,
|
|
222
|
+
): SlackConversationLink | undefined;
|
|
189
223
|
}
|
|
190
224
|
|
|
191
|
-
export interface
|
|
192
|
-
|
|
193
|
-
|
|
225
|
+
export interface JuniorPluginOAuthConfig {
|
|
226
|
+
authorizeEndpoint: string;
|
|
227
|
+
authorizeParams?: Record<string, string>;
|
|
228
|
+
clientIdEnv: string;
|
|
229
|
+
clientSecretEnv: string;
|
|
230
|
+
scope?: string;
|
|
231
|
+
tokenAuthMethod?: "body" | "basic";
|
|
232
|
+
tokenEndpoint: string;
|
|
233
|
+
tokenExtraHeaders?: Record<string, string>;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export interface JuniorPluginOAuthBearerCredentials {
|
|
237
|
+
apiHeaders?: Record<string, string>;
|
|
238
|
+
authTokenEnv: string;
|
|
239
|
+
authTokenPlaceholder?: string;
|
|
240
|
+
domains: string[];
|
|
241
|
+
type: "oauth-bearer";
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export interface JuniorPluginGitHubAppCredentials {
|
|
245
|
+
apiHeaders?: Record<string, string>;
|
|
246
|
+
appIdEnv: string;
|
|
247
|
+
authTokenEnv: string;
|
|
248
|
+
authTokenPlaceholder?: string;
|
|
249
|
+
domains: string[];
|
|
250
|
+
installationIdEnv: string;
|
|
251
|
+
privateKeyEnv: string;
|
|
252
|
+
type: "github-app";
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export type JuniorPluginCredentials =
|
|
256
|
+
| JuniorPluginOAuthBearerCredentials
|
|
257
|
+
| JuniorPluginGitHubAppCredentials;
|
|
258
|
+
|
|
259
|
+
export interface JuniorPluginNpmRuntimeDependency {
|
|
260
|
+
package: string;
|
|
261
|
+
type: "npm";
|
|
262
|
+
version: string;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export interface JuniorPluginSystemRuntimeDependency {
|
|
266
|
+
package: string;
|
|
267
|
+
type: "system";
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export interface JuniorPluginSystemRuntimeDependencyFromUrl {
|
|
271
|
+
sha256: string;
|
|
272
|
+
type: "system";
|
|
273
|
+
url: string;
|
|
194
274
|
}
|
|
195
275
|
|
|
196
|
-
export
|
|
276
|
+
export type JuniorPluginRuntimeDependency =
|
|
277
|
+
| JuniorPluginNpmRuntimeDependency
|
|
278
|
+
| JuniorPluginSystemRuntimeDependency
|
|
279
|
+
| JuniorPluginSystemRuntimeDependencyFromUrl;
|
|
280
|
+
|
|
281
|
+
export interface JuniorPluginRuntimePostinstallCommand {
|
|
282
|
+
args?: string[];
|
|
283
|
+
cmd: string;
|
|
284
|
+
sudo?: boolean;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export interface JuniorPluginMcpConfig {
|
|
288
|
+
allowedTools?: string[];
|
|
289
|
+
headers?: Record<string, string>;
|
|
290
|
+
transport: "http";
|
|
291
|
+
url: string;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
export interface JuniorPluginEnvVarDeclaration {
|
|
295
|
+
default?: string;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export interface JuniorPluginManifest {
|
|
299
|
+
apiHeaders?: Record<string, string>;
|
|
300
|
+
capabilities?: string[];
|
|
301
|
+
commandEnv?: Record<string, string>;
|
|
302
|
+
configKeys?: string[];
|
|
303
|
+
credentials?: JuniorPluginCredentials;
|
|
304
|
+
description: string;
|
|
305
|
+
domains?: string[];
|
|
306
|
+
envVars?: Record<string, JuniorPluginEnvVarDeclaration>;
|
|
307
|
+
mcp?: JuniorPluginMcpConfig;
|
|
308
|
+
name: string;
|
|
309
|
+
oauth?: JuniorPluginOAuthConfig;
|
|
310
|
+
runtimeDependencies?: JuniorPluginRuntimeDependency[];
|
|
311
|
+
runtimePostinstall?: JuniorPluginRuntimePostinstallCommand[];
|
|
312
|
+
target?: {
|
|
313
|
+
commandFlags?: string[];
|
|
314
|
+
configKey: string;
|
|
315
|
+
type: string;
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
export type JuniorPluginRegistrationInput = {
|
|
197
320
|
hooks?: AgentPluginHooks;
|
|
321
|
+
legacyStatePrefixes?: string[];
|
|
322
|
+
manifest: JuniorPluginManifest;
|
|
323
|
+
name?: string;
|
|
324
|
+
packageName?: string;
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
export interface JuniorPluginRegistration extends JuniorPluginRegistrationInput {
|
|
198
328
|
name: string;
|
|
199
|
-
pluginConfig?: JuniorPluginConfig;
|
|
200
329
|
}
|
|
201
330
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
331
|
+
const PLUGIN_NAME_RE = /^[a-z][a-z0-9-]*$/;
|
|
332
|
+
|
|
333
|
+
/** Define one Junior plugin registration for app and build-time wiring. */
|
|
334
|
+
export function defineJuniorPlugin(
|
|
335
|
+
plugin: JuniorPluginRegistrationInput,
|
|
336
|
+
): JuniorPluginRegistration {
|
|
337
|
+
if ("pluginConfig" in plugin) {
|
|
338
|
+
throw new Error(
|
|
339
|
+
"pluginConfig is no longer supported. Put runtime metadata in manifest and trusted state prefixes on the plugin registration.",
|
|
340
|
+
);
|
|
341
|
+
}
|
|
342
|
+
const manifest = plugin.manifest;
|
|
343
|
+
if (!manifest) {
|
|
344
|
+
throw new Error(
|
|
345
|
+
"defineJuniorPlugin() requires a manifest. Use a package name string in defineJuniorPlugins([...]) for plugin.yaml packages.",
|
|
346
|
+
);
|
|
347
|
+
}
|
|
348
|
+
const name = plugin.name ?? manifest.name;
|
|
349
|
+
if (!name) {
|
|
350
|
+
throw new Error(
|
|
351
|
+
"Junior plugin registrations must include name or manifest.name.",
|
|
352
|
+
);
|
|
353
|
+
}
|
|
354
|
+
if (!PLUGIN_NAME_RE.test(name)) {
|
|
355
|
+
throw new Error(
|
|
356
|
+
`Junior plugin registration name "${name}" must be a lowercase plugin identifier.`,
|
|
357
|
+
);
|
|
358
|
+
}
|
|
359
|
+
if (
|
|
360
|
+
typeof manifest.description !== "string" ||
|
|
361
|
+
!manifest.description.trim()
|
|
362
|
+
) {
|
|
363
|
+
throw new Error(
|
|
364
|
+
`Junior plugin "${name}" manifest.description is required.`,
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
if (plugin.name && manifest.name && plugin.name !== manifest.name) {
|
|
368
|
+
throw new Error(
|
|
369
|
+
`Junior plugin registration name "${plugin.name}" must match manifest.name "${manifest.name}".`,
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
return {
|
|
373
|
+
...plugin,
|
|
374
|
+
name,
|
|
375
|
+
};
|
|
205
376
|
}
|