@sentry/junior-plugin-api 0.174.0 → 0.175.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.js CHANGED
@@ -331,6 +331,7 @@ var RESOURCE_EVENT_SUMMARY_MAX_LENGTH = 4e3;
331
331
  var RESOURCE_EVENT_TEXT_MAX_LENGTH = 8e3;
332
332
  var RESOURCE_EVENT_DATA_MAX_KEYS = 32;
333
333
  var RESOURCE_EVENT_DATA_MAX_JSON_BYTES = 4e3;
334
+ var RESOURCE_EVENT_GUIDANCE_MAX_LENGTH = 1e3;
334
335
  var resourceEventDataSchema = z5.record(z5.string(), z5.unknown()).superRefine((value, context) => {
335
336
  const keys = Object.keys(value);
336
337
  if (keys.length > RESOURCE_EVENT_DATA_MAX_KEYS) {
@@ -339,7 +340,9 @@ var resourceEventDataSchema = z5.record(z5.string(), z5.unknown()).superRefine((
339
340
  message: `Resource event data may include at most ${RESOURCE_EVENT_DATA_MAX_KEYS} keys.`
340
341
  });
341
342
  }
342
- const jsonBytes = new TextEncoder().encode(JSON.stringify(value)).byteLength;
343
+ const jsonBytes = new TextEncoder().encode(
344
+ JSON.stringify(value)
345
+ ).byteLength;
343
346
  if (jsonBytes > RESOURCE_EVENT_DATA_MAX_JSON_BYTES) {
344
347
  context.addIssue({
345
348
  code: "custom",
@@ -356,7 +359,11 @@ var resourceTypeSchema = z5.string().regex(/^[a-z][a-z0-9_]*$/).describe(
356
359
  var pluginResourceEventTypeSchema = z5.object({
357
360
  type: resourceTypeSchema,
358
361
  supportedEvents: z5.array(resourceEventTypeSchema).min(1),
359
- suggestedEvents: z5.array(resourceEventTypeSchema).optional()
362
+ suggestedEvents: z5.array(resourceEventTypeSchema).optional(),
363
+ guidance: z5.record(
364
+ resourceEventTypeSchema,
365
+ z5.string().trim().min(1).max(RESOURCE_EVENT_GUIDANCE_MAX_LENGTH)
366
+ ).optional()
360
367
  }).strict().superRefine((resourceType, context) => {
361
368
  const supported = /* @__PURE__ */ new Set();
362
369
  resourceType.supportedEvents.forEach((eventType, index) => {
@@ -369,6 +376,15 @@ var pluginResourceEventTypeSchema = z5.object({
369
376
  }
370
377
  supported.add(eventType);
371
378
  });
379
+ for (const eventType of Object.keys(resourceType.guidance ?? {})) {
380
+ if (!supported.has(eventType)) {
381
+ context.addIssue({
382
+ code: "custom",
383
+ message: `Guidance resource event type "${eventType}" is not supported.`,
384
+ path: ["guidance", eventType]
385
+ });
386
+ }
387
+ }
372
388
  const suggested = /* @__PURE__ */ new Set();
373
389
  resourceType.suggestedEvents?.forEach((eventType, index) => {
374
390
  if (suggested.has(eventType)) {
@@ -421,6 +437,10 @@ var subscribableResourceSchema = z5.object({
421
437
  supportedEvents: z5.array(resourceEventTypeSchema),
422
438
  type: resourceTypeSchema
423
439
  }).strict();
440
+ var resourceEventSubscriptionResultSchema = z5.object({
441
+ events: z5.array(resourceEventTypeSchema).min(1),
442
+ id: z5.string().min(1)
443
+ }).strict();
424
444
  var resourceEventInputSchema = z5.object({
425
445
  eventKey: z5.string().min(1),
426
446
  eventType: resourceEventTypeSchema,
@@ -856,6 +876,7 @@ export {
856
876
  REQUIRED_TOOL_ANNOTATION_KEYS,
857
877
  RESOURCE_EVENT_DATA_MAX_JSON_BYTES,
858
878
  RESOURCE_EVENT_DATA_MAX_KEYS,
879
+ RESOURCE_EVENT_GUIDANCE_MAX_LENGTH,
859
880
  RESOURCE_EVENT_SUMMARY_MAX_LENGTH,
860
881
  RESOURCE_EVENT_TEXT_MAX_LENGTH,
861
882
  actorSchema,
@@ -913,6 +934,7 @@ export {
913
934
  resourceEventDataSchema,
914
935
  resourceEventInputSchema,
915
936
  resourceEventSchema,
937
+ resourceEventSubscriptionResultSchema,
916
938
  resourceEventTypeSchema,
917
939
  resourceLinkAnnotationSchema,
918
940
  resourceTypeSchema,
@@ -3,6 +3,7 @@ export declare const RESOURCE_EVENT_SUMMARY_MAX_LENGTH = 4000;
3
3
  export declare const RESOURCE_EVENT_TEXT_MAX_LENGTH = 8000;
4
4
  export declare const RESOURCE_EVENT_DATA_MAX_KEYS = 32;
5
5
  export declare const RESOURCE_EVENT_DATA_MAX_JSON_BYTES = 4000;
6
+ export declare const RESOURCE_EVENT_GUIDANCE_MAX_LENGTH = 1000;
6
7
  /** Small trusted facts from the plugin. The agent should not look these up again. */
7
8
  export declare const resourceEventDataSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
8
9
  /** Canonical dotted event type published and selected across plugins. */
@@ -12,12 +13,14 @@ export declare const pluginResourceEventTypeSchema: z.ZodObject<{
12
13
  type: z.ZodString;
13
14
  supportedEvents: z.ZodArray<z.ZodString>;
14
15
  suggestedEvents: z.ZodOptional<z.ZodArray<z.ZodString>>;
16
+ guidance: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
15
17
  }, z.core.$strict>;
16
18
  export declare const pluginResourceEventsSchema: z.ZodObject<{
17
19
  resourceTypes: z.ZodArray<z.ZodObject<{
18
20
  type: z.ZodString;
19
21
  supportedEvents: z.ZodArray<z.ZodString>;
20
22
  suggestedEvents: z.ZodOptional<z.ZodArray<z.ZodString>>;
23
+ guidance: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
21
24
  }, z.core.$strict>>;
22
25
  isEnabled: z.ZodOptional<z.ZodFunction<z.ZodTuple<readonly [], null>, z.ZodBoolean>>;
23
26
  normalizeIdentifier: z.ZodOptional<z.ZodFunction<z.ZodTuple<readonly [z.ZodString], null>, z.ZodString>>;
@@ -35,6 +38,12 @@ export declare const subscribableResourceSchema: z.ZodObject<{
35
38
  type: z.ZodString;
36
39
  }, z.core.$strict>;
37
40
  export type SubscribableResource = z.output<typeof subscribableResourceSchema>;
41
+ /** Result returned after a temporary resource subscription is created. */
42
+ export declare const resourceEventSubscriptionResultSchema: z.ZodObject<{
43
+ events: z.ZodArray<z.ZodString>;
44
+ id: z.ZodString;
45
+ }, z.core.$strict>;
46
+ export type ResourceEventSubscriptionResult = z.output<typeof resourceEventSubscriptionResultSchema>;
38
47
  export declare const resourceEventInputSchema: z.ZodObject<{
39
48
  eventKey: z.ZodString;
40
49
  eventType: z.ZodString;
package/dist/tools.d.ts CHANGED
@@ -2,6 +2,7 @@ import type { Actor, Identity, LocalInvocationContext, PluginContext, PluginEmbe
2
2
  import type { PluginCredentialSubject } from "./credentials";
3
3
  import type { PluginAnnotations } from "./annotations";
4
4
  import type { SlackConversationLink } from "./operations";
5
+ import type { ResourceEventSubscriptionResult, SubscribableResource } from "./resource-events";
5
6
  import type { PluginState } from "./state";
6
7
  import { z, type ZodTypeAny } from "zod";
7
8
  export interface PluginEnv {
@@ -286,8 +287,14 @@ export interface SlackToolRegistrationHookContext {
286
287
  }>;
287
288
  }
288
289
  export interface PluginResourceEventToolContext {
289
- /** Whether this invocation can create a working resource-event subscription. */
290
+ /** Whether this invocation can create a working resource subscription. */
290
291
  canSubscribe: boolean;
292
+ /** Create a temporary resource subscription for the current conversation. */
293
+ subscribe(input: {
294
+ events: string[];
295
+ intent: string;
296
+ resource: SubscribableResource;
297
+ }): Promise<ResourceEventSubscriptionResult>;
291
298
  }
292
299
  export interface PluginWorkspaceToolContext {
293
300
  /** Find named Workspaces that include one provider repository. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/junior-plugin-api",
3
- "version": "0.174.0",
3
+ "version": "0.175.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -4,6 +4,7 @@ export const RESOURCE_EVENT_SUMMARY_MAX_LENGTH = 4_000;
4
4
  export const RESOURCE_EVENT_TEXT_MAX_LENGTH = 8_000;
5
5
  export const RESOURCE_EVENT_DATA_MAX_KEYS = 32;
6
6
  export const RESOURCE_EVENT_DATA_MAX_JSON_BYTES = 4_000;
7
+ export const RESOURCE_EVENT_GUIDANCE_MAX_LENGTH = 1_000;
7
8
 
8
9
  /** Small trusted facts from the plugin. The agent should not look these up again. */
9
10
  export const resourceEventDataSchema = z
@@ -16,7 +17,9 @@ export const resourceEventDataSchema = z
16
17
  message: `Resource event data may include at most ${RESOURCE_EVENT_DATA_MAX_KEYS} keys.`,
17
18
  });
18
19
  }
19
- const jsonBytes = new TextEncoder().encode(JSON.stringify(value)).byteLength;
20
+ const jsonBytes = new TextEncoder().encode(
21
+ JSON.stringify(value),
22
+ ).byteLength;
20
23
  if (jsonBytes > RESOURCE_EVENT_DATA_MAX_JSON_BYTES) {
21
24
  context.addIssue({
22
25
  code: "custom",
@@ -45,6 +48,12 @@ export const pluginResourceEventTypeSchema = z
45
48
  type: resourceTypeSchema,
46
49
  supportedEvents: z.array(resourceEventTypeSchema).min(1),
47
50
  suggestedEvents: z.array(resourceEventTypeSchema).optional(),
51
+ guidance: z
52
+ .record(
53
+ resourceEventTypeSchema,
54
+ z.string().trim().min(1).max(RESOURCE_EVENT_GUIDANCE_MAX_LENGTH),
55
+ )
56
+ .optional(),
48
57
  })
49
58
  .strict()
50
59
  .superRefine((resourceType, context) => {
@@ -59,6 +68,15 @@ export const pluginResourceEventTypeSchema = z
59
68
  }
60
69
  supported.add(eventType);
61
70
  });
71
+ for (const eventType of Object.keys(resourceType.guidance ?? {})) {
72
+ if (!supported.has(eventType)) {
73
+ context.addIssue({
74
+ code: "custom",
75
+ message: `Guidance resource event type "${eventType}" is not supported.`,
76
+ path: ["guidance", eventType],
77
+ });
78
+ }
79
+ }
62
80
  const suggested = new Set<string>();
63
81
  resourceType.suggestedEvents?.forEach((eventType, index) => {
64
82
  if (suggested.has(eventType)) {
@@ -135,6 +153,18 @@ export const subscribableResourceSchema = z
135
153
 
136
154
  export type SubscribableResource = z.output<typeof subscribableResourceSchema>;
137
155
 
156
+ /** Result returned after a temporary resource subscription is created. */
157
+ export const resourceEventSubscriptionResultSchema = z
158
+ .object({
159
+ events: z.array(resourceEventTypeSchema).min(1),
160
+ id: z.string().min(1),
161
+ })
162
+ .strict();
163
+
164
+ export type ResourceEventSubscriptionResult = z.output<
165
+ typeof resourceEventSubscriptionResultSchema
166
+ >;
167
+
138
168
  export const resourceEventInputSchema = z
139
169
  .object({
140
170
  eventKey: z.string().min(1),
package/src/tools.ts CHANGED
@@ -12,6 +12,10 @@ import type {
12
12
  import type { PluginCredentialSubject } from "./credentials";
13
13
  import type { PluginAnnotations } from "./annotations";
14
14
  import type { SlackConversationLink } from "./operations";
15
+ import type {
16
+ ResourceEventSubscriptionResult,
17
+ SubscribableResource,
18
+ } from "./resource-events";
15
19
  import type { PluginState } from "./state";
16
20
  import { z, type ZodTypeAny } from "zod";
17
21
 
@@ -516,8 +520,14 @@ export interface SlackToolRegistrationHookContext {
516
520
  }
517
521
 
518
522
  export interface PluginResourceEventToolContext {
519
- /** Whether this invocation can create a working resource-event subscription. */
523
+ /** Whether this invocation can create a working resource subscription. */
520
524
  canSubscribe: boolean;
525
+ /** Create a temporary resource subscription for the current conversation. */
526
+ subscribe(input: {
527
+ events: string[];
528
+ intent: string;
529
+ resource: SubscribableResource;
530
+ }): Promise<ResourceEventSubscriptionResult>;
521
531
  }
522
532
 
523
533
  export interface PluginWorkspaceToolContext {