@sentry/junior-plugin-api 0.69.0 → 0.70.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
@@ -321,18 +321,40 @@ export declare const agentPluginCredentialResultSchema: z.ZodDiscriminatedUnion<
321
321
  export type AgentPluginGrantAccess = z.output<typeof agentPluginGrantAccessSchema>;
322
322
  /** Provider authorization Junior can start when a plugin-owned grant is missing. */
323
323
  export type AgentPluginAuthorization = z.output<typeof agentPluginAuthorizationSchema>;
324
+ /** Interrupt sandbox egress so Junior can start provider authorization. */
325
+ export declare class EgressAuthRequired extends Error {
326
+ authorization?: AgentPluginAuthorization;
327
+ constructor(message: string, options?: {
328
+ authorization?: AgentPluginAuthorization;
329
+ cause?: unknown;
330
+ });
331
+ }
324
332
  /** Provider account identity resolved by a plugin OAuth hook. */
325
333
  export type AgentPluginProviderAccount = z.output<typeof agentPluginProviderAccountSchema>;
326
334
  /** Plugin-defined grant required before Junior can forward one outbound request. */
327
335
  export type AgentPluginGrant = z.output<typeof agentPluginGrantSchema>;
328
336
  /** Request details available while selecting the grant for sandbox egress. */
329
337
  export interface AgentPluginEgressRequest {
338
+ /** Capped request body text when the host exposes it for provider-specific grant classification. */
339
+ bodyText?: string;
330
340
  method: string;
331
341
  url: string;
332
342
  }
333
343
  export interface EgressHookContext extends AgentPluginContext {
334
344
  request: AgentPluginEgressRequest;
335
345
  }
346
+ export interface AgentPluginEgressResponse {
347
+ /** Snapshot of upstream response headers; mutations do not affect pass-through. */
348
+ headers: Headers;
349
+ readText(maxBytes: number): Promise<string | undefined>;
350
+ status: number;
351
+ }
352
+ export interface EgressResponseHookContext extends AgentPluginContext {
353
+ grant: AgentPluginGrant;
354
+ permissionDenied(message: string): void;
355
+ request: Omit<AgentPluginEgressRequest, "bodyText">;
356
+ response: AgentPluginEgressResponse;
357
+ }
336
358
  /** Header mutations a plugin-issued credential lease may apply to owned domains. */
337
359
  export type AgentPluginCredentialHeaderTransform = z.output<typeof agentPluginCredentialHeaderTransformSchema>;
338
360
  /** Short-lived credential headers issued by a plugin for a selected grant. */
@@ -379,6 +401,7 @@ export interface AgentPluginHooks {
379
401
  beforeToolExecute?(ctx: BeforeToolExecuteHookContext): Promise<void> | void;
380
402
  grantForEgress?(ctx: EgressHookContext): Promise<AgentPluginGrant | undefined> | AgentPluginGrant | undefined;
381
403
  issueCredential?(ctx: IssueCredentialHookContext): Promise<AgentPluginCredentialResult> | AgentPluginCredentialResult;
404
+ onEgressResponse?(ctx: EgressResponseHookContext): Promise<void> | void;
382
405
  resolveOAuthAccount?(ctx: ResolveOAuthAccountHookContext): Promise<AgentPluginProviderAccount | undefined> | AgentPluginProviderAccount | undefined;
383
406
  routes?(ctx: RouteRegistrationHookContext): AgentPluginRoute[];
384
407
  tools?(ctx: ToolRegistrationHookContext): Record<string, AgentPluginToolDefinition>;
package/dist/index.js CHANGED
@@ -116,6 +116,14 @@ var agentPluginCredentialResultSchema = z.discriminatedUnion("type", [
116
116
  type: z.literal("unavailable")
117
117
  }).strict()
118
118
  ]);
119
+ var EgressAuthRequired = class extends Error {
120
+ authorization;
121
+ constructor(message, options) {
122
+ super(message, { cause: options?.cause });
123
+ this.name = "EgressAuthRequired";
124
+ this.authorization = options?.authorization;
125
+ }
126
+ };
119
127
  var PLUGIN_NAME_RE = /^[a-z][a-z0-9-]*$/;
120
128
  function defineJuniorPlugin(plugin) {
121
129
  if ("pluginConfig" in plugin) {
@@ -157,6 +165,7 @@ function defineJuniorPlugin(plugin) {
157
165
  }
158
166
  export {
159
167
  AgentPluginToolInputError,
168
+ EgressAuthRequired,
160
169
  agentPluginAuthorizationSchema,
161
170
  agentPluginCredentialHeaderTransformSchema,
162
171
  agentPluginCredentialLeaseSchema,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/junior-plugin-api",
3
- "version": "0.69.0",
3
+ "version": "0.70.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
package/src/index.ts CHANGED
@@ -443,6 +443,23 @@ export type AgentPluginAuthorization = z.output<
443
443
  typeof agentPluginAuthorizationSchema
444
444
  >;
445
445
 
446
+ /** Interrupt sandbox egress so Junior can start provider authorization. */
447
+ export class EgressAuthRequired extends Error {
448
+ authorization?: AgentPluginAuthorization;
449
+
450
+ constructor(
451
+ message: string,
452
+ options?: {
453
+ authorization?: AgentPluginAuthorization;
454
+ cause?: unknown;
455
+ },
456
+ ) {
457
+ super(message, { cause: options?.cause });
458
+ this.name = "EgressAuthRequired";
459
+ this.authorization = options?.authorization;
460
+ }
461
+ }
462
+
446
463
  /** Provider account identity resolved by a plugin OAuth hook. */
447
464
  export type AgentPluginProviderAccount = z.output<
448
465
  typeof agentPluginProviderAccountSchema
@@ -453,6 +470,8 @@ export type AgentPluginGrant = z.output<typeof agentPluginGrantSchema>;
453
470
 
454
471
  /** Request details available while selecting the grant for sandbox egress. */
455
472
  export interface AgentPluginEgressRequest {
473
+ /** Capped request body text when the host exposes it for provider-specific grant classification. */
474
+ bodyText?: string;
456
475
  method: string;
457
476
  url: string;
458
477
  }
@@ -461,6 +480,20 @@ export interface EgressHookContext extends AgentPluginContext {
461
480
  request: AgentPluginEgressRequest;
462
481
  }
463
482
 
483
+ export interface AgentPluginEgressResponse {
484
+ /** Snapshot of upstream response headers; mutations do not affect pass-through. */
485
+ headers: Headers;
486
+ readText(maxBytes: number): Promise<string | undefined>;
487
+ status: number;
488
+ }
489
+
490
+ export interface EgressResponseHookContext extends AgentPluginContext {
491
+ grant: AgentPluginGrant;
492
+ permissionDenied(message: string): void;
493
+ request: Omit<AgentPluginEgressRequest, "bodyText">;
494
+ response: AgentPluginEgressResponse;
495
+ }
496
+
464
497
  /** Header mutations a plugin-issued credential lease may apply to owned domains. */
465
498
  export type AgentPluginCredentialHeaderTransform = z.output<
466
499
  typeof agentPluginCredentialHeaderTransformSchema
@@ -529,6 +562,7 @@ export interface AgentPluginHooks {
529
562
  issueCredential?(
530
563
  ctx: IssueCredentialHookContext,
531
564
  ): Promise<AgentPluginCredentialResult> | AgentPluginCredentialResult;
565
+ onEgressResponse?(ctx: EgressResponseHookContext): Promise<void> | void;
532
566
  resolveOAuthAccount?(
533
567
  ctx: ResolveOAuthAccountHookContext,
534
568
  ):