@sentry/junior-plugin-api 0.63.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 CHANGED
@@ -171,14 +171,92 @@ 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 JuniorPluginConfig {
175
- legacyStatePrefixes?: string[];
176
- packages?: string[];
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 JuniorPlugin {
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 = {
179
252
  hooks?: AgentPluginHooks;
253
+ legacyStatePrefixes?: string[];
254
+ manifest: JuniorPluginManifest;
255
+ name?: string;
256
+ packageName?: string;
257
+ };
258
+ export interface JuniorPluginRegistration extends JuniorPluginRegistrationInput {
180
259
  name: string;
181
- pluginConfig?: JuniorPluginConfig;
182
260
  }
183
- /** Define a trusted Junior plugin with optional package config and agent hooks. */
184
- export declare function defineJuniorPlugin(plugin: JuniorPlugin): JuniorPlugin;
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
- return plugin;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/junior-plugin-api",
3
- "version": "0.63.0",
3
+ "version": "0.64.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
package/src/index.ts CHANGED
@@ -222,18 +222,155 @@ export interface AgentPluginHooks {
222
222
  ): SlackConversationLink | undefined;
223
223
  }
224
224
 
225
- export interface JuniorPluginConfig {
226
- legacyStatePrefixes?: string[];
227
- packages?: string[];
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;
228
296
  }
229
297
 
230
- export interface JuniorPlugin {
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 = {
231
320
  hooks?: AgentPluginHooks;
321
+ legacyStatePrefixes?: string[];
322
+ manifest: JuniorPluginManifest;
323
+ name?: string;
324
+ packageName?: string;
325
+ };
326
+
327
+ export interface JuniorPluginRegistration extends JuniorPluginRegistrationInput {
232
328
  name: string;
233
- pluginConfig?: JuniorPluginConfig;
234
329
  }
235
330
 
236
- /** Define a trusted Junior plugin with optional package config and agent hooks. */
237
- export function defineJuniorPlugin(plugin: JuniorPlugin): JuniorPlugin {
238
- return plugin;
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
+ };
239
376
  }