@sentry/junior-plugin-api 0.63.0 → 0.65.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 +86 -7
- package/dist/index.js +37 -1
- package/package.json +1 -1
- package/src/index.ts +146 -8
package/dist/index.d.ts
CHANGED
|
@@ -171,14 +171,93 @@ export interface AgentPluginHooks {
|
|
|
171
171
|
heartbeat?(ctx: HeartbeatHookContext): Promise<HeartbeatResult | void> | HeartbeatResult | void;
|
|
172
172
|
slackConversationLink?(ctx: SlackConversationLinkHookContext): SlackConversationLink | undefined;
|
|
173
173
|
}
|
|
174
|
-
export interface
|
|
175
|
-
|
|
176
|
-
|
|
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";
|
|
210
|
+
}
|
|
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;
|
|
177
221
|
}
|
|
178
|
-
export interface
|
|
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
|
+
exposeToCommandEnv?: boolean;
|
|
231
|
+
}
|
|
232
|
+
export interface JuniorPluginManifest {
|
|
233
|
+
apiHeaders?: Record<string, string>;
|
|
234
|
+
capabilities?: string[];
|
|
235
|
+
commandEnv?: Record<string, string>;
|
|
236
|
+
configKeys?: string[];
|
|
237
|
+
credentials?: JuniorPluginCredentials;
|
|
238
|
+
description: string;
|
|
239
|
+
domains?: string[];
|
|
240
|
+
envVars?: Record<string, JuniorPluginEnvVarDeclaration>;
|
|
241
|
+
mcp?: JuniorPluginMcpConfig;
|
|
242
|
+
name: string;
|
|
243
|
+
oauth?: JuniorPluginOAuthConfig;
|
|
244
|
+
runtimeDependencies?: JuniorPluginRuntimeDependency[];
|
|
245
|
+
runtimePostinstall?: JuniorPluginRuntimePostinstallCommand[];
|
|
246
|
+
target?: {
|
|
247
|
+
commandFlags?: string[];
|
|
248
|
+
configKey: string;
|
|
249
|
+
type: string;
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
export type JuniorPluginRegistrationInput = {
|
|
179
253
|
hooks?: AgentPluginHooks;
|
|
254
|
+
legacyStatePrefixes?: string[];
|
|
255
|
+
manifest: JuniorPluginManifest;
|
|
256
|
+
name?: string;
|
|
257
|
+
packageName?: string;
|
|
258
|
+
};
|
|
259
|
+
export interface JuniorPluginRegistration extends JuniorPluginRegistrationInput {
|
|
180
260
|
name: string;
|
|
181
|
-
pluginConfig?: JuniorPluginConfig;
|
|
182
261
|
}
|
|
183
|
-
/** Define
|
|
184
|
-
export declare function defineJuniorPlugin(plugin:
|
|
262
|
+
/** Define one Junior plugin registration for app and build-time wiring. */
|
|
263
|
+
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
|
@@ -222,18 +222,156 @@ export interface AgentPluginHooks {
|
|
|
222
222
|
): SlackConversationLink | undefined;
|
|
223
223
|
}
|
|
224
224
|
|
|
225
|
-
export interface
|
|
226
|
-
|
|
227
|
-
|
|
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;
|
|
274
|
+
}
|
|
275
|
+
|
|
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
|
+
exposeToCommandEnv?: boolean;
|
|
228
297
|
}
|
|
229
298
|
|
|
230
|
-
export interface
|
|
299
|
+
export interface JuniorPluginManifest {
|
|
300
|
+
apiHeaders?: Record<string, string>;
|
|
301
|
+
capabilities?: string[];
|
|
302
|
+
commandEnv?: Record<string, string>;
|
|
303
|
+
configKeys?: string[];
|
|
304
|
+
credentials?: JuniorPluginCredentials;
|
|
305
|
+
description: string;
|
|
306
|
+
domains?: string[];
|
|
307
|
+
envVars?: Record<string, JuniorPluginEnvVarDeclaration>;
|
|
308
|
+
mcp?: JuniorPluginMcpConfig;
|
|
309
|
+
name: string;
|
|
310
|
+
oauth?: JuniorPluginOAuthConfig;
|
|
311
|
+
runtimeDependencies?: JuniorPluginRuntimeDependency[];
|
|
312
|
+
runtimePostinstall?: JuniorPluginRuntimePostinstallCommand[];
|
|
313
|
+
target?: {
|
|
314
|
+
commandFlags?: string[];
|
|
315
|
+
configKey: string;
|
|
316
|
+
type: string;
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
export type JuniorPluginRegistrationInput = {
|
|
231
321
|
hooks?: AgentPluginHooks;
|
|
322
|
+
legacyStatePrefixes?: string[];
|
|
323
|
+
manifest: JuniorPluginManifest;
|
|
324
|
+
name?: string;
|
|
325
|
+
packageName?: string;
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
export interface JuniorPluginRegistration extends JuniorPluginRegistrationInput {
|
|
232
329
|
name: string;
|
|
233
|
-
pluginConfig?: JuniorPluginConfig;
|
|
234
330
|
}
|
|
235
331
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
332
|
+
const PLUGIN_NAME_RE = /^[a-z][a-z0-9-]*$/;
|
|
333
|
+
|
|
334
|
+
/** Define one Junior plugin registration for app and build-time wiring. */
|
|
335
|
+
export function defineJuniorPlugin(
|
|
336
|
+
plugin: JuniorPluginRegistrationInput,
|
|
337
|
+
): JuniorPluginRegistration {
|
|
338
|
+
if ("pluginConfig" in plugin) {
|
|
339
|
+
throw new Error(
|
|
340
|
+
"pluginConfig is no longer supported. Put runtime metadata in manifest and trusted state prefixes on the plugin registration.",
|
|
341
|
+
);
|
|
342
|
+
}
|
|
343
|
+
const manifest = plugin.manifest;
|
|
344
|
+
if (!manifest) {
|
|
345
|
+
throw new Error(
|
|
346
|
+
"defineJuniorPlugin() requires a manifest. Use a package name string in defineJuniorPlugins([...]) for plugin.yaml packages.",
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
const name = plugin.name ?? manifest.name;
|
|
350
|
+
if (!name) {
|
|
351
|
+
throw new Error(
|
|
352
|
+
"Junior plugin registrations must include name or manifest.name.",
|
|
353
|
+
);
|
|
354
|
+
}
|
|
355
|
+
if (!PLUGIN_NAME_RE.test(name)) {
|
|
356
|
+
throw new Error(
|
|
357
|
+
`Junior plugin registration name "${name}" must be a lowercase plugin identifier.`,
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
if (
|
|
361
|
+
typeof manifest.description !== "string" ||
|
|
362
|
+
!manifest.description.trim()
|
|
363
|
+
) {
|
|
364
|
+
throw new Error(
|
|
365
|
+
`Junior plugin "${name}" manifest.description is required.`,
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
if (plugin.name && manifest.name && plugin.name !== manifest.name) {
|
|
369
|
+
throw new Error(
|
|
370
|
+
`Junior plugin registration name "${plugin.name}" must match manifest.name "${manifest.name}".`,
|
|
371
|
+
);
|
|
372
|
+
}
|
|
373
|
+
return {
|
|
374
|
+
...plugin,
|
|
375
|
+
name,
|
|
376
|
+
};
|
|
239
377
|
}
|