@sentry/junior-plugin-api 0.192.0 → 0.194.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/README.md CHANGED
@@ -42,9 +42,9 @@ reports, and other typed hook surfaces exported by this package.
42
42
 
43
43
  - Hook context carries the active source, actor, conversation, plugin metadata,
44
44
  database, logging, and only the host capabilities required by that hook.
45
- - Source uses `kind` to state what produced the input, including input such as
46
- a Resource event that has no provider platform. Actor and Destination keep
47
- `platform` for their provider scope.
45
+ - Source uses `kind` to state what produced the input. Resource events,
46
+ scheduled tasks, event tasks, Plugin dispatches, and Agent invocations do not
47
+ name a provider. Actor and Destination still use `platform` to name one.
48
48
  - Prompt hooks return bounded structured prompt messages rather than mutate the
49
49
  core prompt.
50
50
  - `formatMarkdown` is a pure text rewrite into ordinary Markdown before delivery.
package/dist/context.d.ts CHANGED
@@ -27,6 +27,18 @@ export type WebSource = Extract<Source, {
27
27
  export type ResourceEventSource = Extract<Source, {
28
28
  kind: "resource_event";
29
29
  }>;
30
+ export type ScheduledTaskSource = Extract<Source, {
31
+ kind: "scheduled_task";
32
+ }>;
33
+ export type EventTaskSource = Extract<Source, {
34
+ kind: "event_task";
35
+ }>;
36
+ export type PluginDispatchSource = Extract<Source, {
37
+ kind: "plugin_dispatch";
38
+ }>;
39
+ export type AgentInvocationSource = Extract<Source, {
40
+ kind: "agent_invocation";
41
+ }>;
30
42
  export type SourceVisibility = z.output<typeof sourceVisibilitySchema>;
31
43
  export type Destination = z.output<typeof destinationSchema>;
32
44
  export type SlackDestination = Extract<Destination, {
@@ -108,11 +120,15 @@ export interface WebInvocationContext extends BaseInvocationContext {
108
120
  export interface ResourceEventInvocationContext extends BaseInvocationContext {
109
121
  /** Existing conversation destination used for tool context. */
110
122
  destination: Destination;
111
- actor?: SystemActor;
123
+ actor?: Actor;
112
124
  /** Runtime-owned Resource event Source for this invocation. */
113
125
  source: ResourceEventSource;
114
126
  }
115
- export type InvocationContext = LocalInvocationContext | ResourceEventInvocationContext | SlackInvocationContext | WebInvocationContext;
127
+ export type InvocationContext = LocalInvocationContext | SlackInvocationContext | WebInvocationContext | (BaseInvocationContext & {
128
+ destination: Destination;
129
+ actor?: Actor;
130
+ source: AgentInvocationSource | EventTaskSource | PluginDispatchSource | ResourceEventSource | ScheduledTaskSource;
131
+ });
116
132
  /** Build a normalized Slack source from runtime-owned Slack coordinates. */
117
133
  export declare function createSlackSource(input: {
118
134
  channelId: string;
package/dist/index.js CHANGED
@@ -176,11 +176,19 @@ var resourceEventSourceSchema = z4.object({
176
176
  identifier: exactNonBlankStringSchema,
177
177
  namespace: exactNonBlankStringSchema
178
178
  }).strict();
179
+ var scheduledTaskSourceSchema = z4.object({ kind: z4.literal("scheduled_task") }).strict();
180
+ var eventTaskSourceSchema = z4.object({ kind: z4.literal("event_task") }).strict();
181
+ var pluginDispatchSourceSchema = z4.object({ kind: z4.literal("plugin_dispatch") }).strict();
182
+ var agentInvocationSourceSchema = z4.object({ kind: z4.literal("agent_invocation") }).strict();
179
183
  var currentSourceSchema = z4.discriminatedUnion("kind", [
180
184
  slackSourceSchema,
181
185
  localSourceSchema,
182
186
  webSourceSchema,
183
- resourceEventSourceSchema
187
+ resourceEventSourceSchema,
188
+ scheduledTaskSourceSchema,
189
+ eventTaskSourceSchema,
190
+ pluginDispatchSourceSchema,
191
+ agentInvocationSourceSchema
184
192
  ]);
185
193
  function normalizeStoredSource(value) {
186
194
  if (!value || typeof value !== "object" || Array.isArray(value)) {
@@ -318,8 +326,7 @@ var dispatchOptionsSchema = z4.object({
318
326
  destinationVisibility: destinationVisibilitySchema,
319
327
  input: nonBlankStringSchema.pipe(z4.string().max(32e3)),
320
328
  metadata: dispatchMetadataSchema.optional(),
321
- replyAttribution: replyAttributionSchema.optional(),
322
- source: sourceSchema
329
+ replyAttribution: replyAttributionSchema.optional()
323
330
  }).strict();
324
331
 
325
332
  // src/context.ts
@@ -373,6 +380,11 @@ function getSourceKey(source) {
373
380
  }
374
381
  case "resource_event":
375
382
  return `resource-event:${source.namespace}:${source.eventKey}`;
383
+ case "scheduled_task":
384
+ case "event_task":
385
+ case "plugin_dispatch":
386
+ case "agent_invocation":
387
+ return void 0;
376
388
  }
377
389
  }
378
390
  function isSlackDestination(destination) {
@@ -1044,6 +1056,7 @@ export {
1044
1056
  RESOURCE_EVENT_TEXT_MAX_LENGTH,
1045
1057
  actorSchema,
1046
1058
  actorUserIdSchema,
1059
+ agentInvocationSourceSchema,
1047
1060
  codeChangeInputSchema,
1048
1061
  codeChangeStateSchema,
1049
1062
  conversationAnnotationInputSchema,
@@ -1063,6 +1076,7 @@ export {
1063
1076
  destinationVisibilitySchema,
1064
1077
  dispatchOptionsSchema,
1065
1078
  enforceEgressPolicy,
1079
+ eventTaskSourceSchema,
1066
1080
  getSourceKey,
1067
1081
  identitySchema,
1068
1082
  isPrivateSource,
@@ -1081,6 +1095,7 @@ export {
1081
1095
  pluginCredentialLeaseSchema,
1082
1096
  pluginCredentialResultSchema,
1083
1097
  pluginCredentialSubjectSchema,
1098
+ pluginDispatchSourceSchema,
1084
1099
  pluginGrantSchema,
1085
1100
  pluginProviderAccountSchema,
1086
1101
  pluginResourceEventTypeSchema,
@@ -1114,6 +1129,7 @@ export {
1114
1129
  resourceEventTypeSchema,
1115
1130
  resourceLinkAnnotationSchema,
1116
1131
  resourceTypeSchema,
1132
+ scheduledTaskSourceSchema,
1117
1133
  slackActorSchema,
1118
1134
  slackDestinationSchema,
1119
1135
  slackLocationSchema,
package/dist/schemas.d.ts CHANGED
@@ -88,6 +88,22 @@ export declare const resourceEventSourceSchema: z.ZodObject<{
88
88
  identifier: z.ZodString;
89
89
  namespace: z.ZodString;
90
90
  }, z.core.$strict>;
91
+ /** Runtime-owned Scheduled task input Source. */
92
+ export declare const scheduledTaskSourceSchema: z.ZodObject<{
93
+ kind: z.ZodLiteral<"scheduled_task">;
94
+ }, z.core.$strict>;
95
+ /** Runtime-owned Event task input Source. */
96
+ export declare const eventTaskSourceSchema: z.ZodObject<{
97
+ kind: z.ZodLiteral<"event_task">;
98
+ }, z.core.$strict>;
99
+ /** Runtime-owned Plugin dispatch input Source. */
100
+ export declare const pluginDispatchSourceSchema: z.ZodObject<{
101
+ kind: z.ZodLiteral<"plugin_dispatch">;
102
+ }, z.core.$strict>;
103
+ /** Runtime-owned Agent invocation input Source. */
104
+ export declare const agentInvocationSourceSchema: z.ZodObject<{
105
+ kind: z.ZodLiteral<"agent_invocation">;
106
+ }, z.core.$strict>;
91
107
  /** Runtime-owned input Source. Stored `platform` and Location fields normalize on read. */
92
108
  export declare const sourceSchema: z.ZodPreprocess<z.ZodDiscriminatedUnion<[z.ZodObject<{
93
109
  kind: z.ZodLiteral<"slack">;
@@ -116,6 +132,14 @@ export declare const sourceSchema: z.ZodPreprocess<z.ZodDiscriminatedUnion<[z.Zo
116
132
  eventType: z.ZodString;
117
133
  identifier: z.ZodString;
118
134
  namespace: z.ZodString;
135
+ }, z.core.$strict>, z.ZodObject<{
136
+ kind: z.ZodLiteral<"scheduled_task">;
137
+ }, z.core.$strict>, z.ZodObject<{
138
+ kind: z.ZodLiteral<"event_task">;
139
+ }, z.core.$strict>, z.ZodObject<{
140
+ kind: z.ZodLiteral<"plugin_dispatch">;
141
+ }, z.core.$strict>, z.ZodObject<{
142
+ kind: z.ZodLiteral<"agent_invocation">;
119
143
  }, z.core.$strict>], "kind">, unknown>;
120
144
  /** Stable user credential subject shape accepted from plugins. */
121
145
  export declare const pluginCredentialSubjectSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -234,32 +258,4 @@ export declare const dispatchOptionsSchema: z.ZodObject<{
234
258
  label: z.ZodPipe<z.ZodString, z.ZodString>;
235
259
  detail: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodString>>;
236
260
  }, z.core.$strict>>;
237
- source: z.ZodPreprocess<z.ZodDiscriminatedUnion<[z.ZodObject<{
238
- kind: z.ZodLiteral<"slack">;
239
- teamId: z.ZodString;
240
- channelId: z.ZodString;
241
- visibility: z.ZodEnum<{
242
- public: "public";
243
- private: "private";
244
- }>;
245
- messageTs: z.ZodOptional<z.ZodString>;
246
- threadTs: z.ZodOptional<z.ZodString>;
247
- }, z.core.$strict>, z.ZodObject<{
248
- kind: z.ZodLiteral<"local">;
249
- visibility: z.ZodLiteral<"private">;
250
- conversationId: z.ZodString;
251
- }, z.core.$strict>, z.ZodObject<{
252
- kind: z.ZodLiteral<"web">;
253
- visibility: z.ZodEnum<{
254
- public: "public";
255
- private: "private";
256
- }>;
257
- conversationId: z.ZodString;
258
- }, z.core.$strict>, z.ZodObject<{
259
- kind: z.ZodLiteral<"resource_event">;
260
- eventKey: z.ZodString;
261
- eventType: z.ZodString;
262
- identifier: z.ZodString;
263
- namespace: z.ZodString;
264
- }, z.core.$strict>], "kind">, unknown>;
265
261
  }, z.core.$strict>;
package/dist/tasks.d.ts CHANGED
@@ -175,6 +175,14 @@ export declare const pluginRunContextSchema: z.ZodObject<{
175
175
  eventType: z.ZodString;
176
176
  identifier: z.ZodString;
177
177
  namespace: z.ZodString;
178
+ }, z.core.$strict>, z.ZodObject<{
179
+ kind: z.ZodLiteral<"scheduled_task">;
180
+ }, z.core.$strict>, z.ZodObject<{
181
+ kind: z.ZodLiteral<"event_task">;
182
+ }, z.core.$strict>, z.ZodObject<{
183
+ kind: z.ZodLiteral<"plugin_dispatch">;
184
+ }, z.core.$strict>, z.ZodObject<{
185
+ kind: z.ZodLiteral<"agent_invocation">;
178
186
  }, z.core.$strict>], "kind">, unknown>;
179
187
  transcript: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
180
188
  type: z.ZodLiteral<"message">;
package/dist/tools.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Actor, Identity, LocalInvocationContext, ResourceEventInvocationContext, PluginContext, PluginEmbedder, PluginModel, SlackInvocationContext, User, WebInvocationContext } from "./context";
1
+ import type { Actor, Identity, InvocationContext, PluginContext, PluginEmbedder, PluginModel, User } from "./context";
2
2
  import type { PluginCredentialSubject } from "./credentials";
3
3
  import type { PluginAnnotations } from "./annotations";
4
4
  import type { SlackConversationLink } from "./operations";
@@ -276,8 +276,8 @@ export declare function zodTool<TInputSchema extends ZodTypeAny, TOutputSchema e
276
276
  export declare function definePluginTool<TInputSchema extends ZodTypeAny, TOutputSchema extends ZodTypeAny, TExecuteResult extends z.input<TOutputSchema> | PluginToolOutputEnvelope<z.input<TOutputSchema>>>(definition: ZodPluginToolDefinition<TInputSchema, TOutputSchema, TExecuteResult>): PluginToolDefinition<z.output<TInputSchema>, z.output<TOutputSchema>, ParsedPluginToolExecuteResult<TOutputSchema, TExecuteResult>>;
277
277
  export interface SlackToolRegistrationHookContext {
278
278
  /**
279
- * Capabilities of the source Slack conversation exposed to this plugin.
280
- * Recomputed from `source.channelId`, not from `destination`.
279
+ * What Slack tools can do in the Conversation Location.
280
+ * Computed from Location, not from Source or Destination.
281
281
  */
282
282
  channelCapabilities: {
283
283
  canAddReactions: boolean;
@@ -334,17 +334,8 @@ interface BaseToolRegistrationHookContext extends PluginContext {
334
334
  userText?: string;
335
335
  workspaces: PluginWorkspaceToolContext;
336
336
  }
337
- interface SlackToolRegistrationContext extends BaseToolRegistrationHookContext, SlackInvocationContext {
338
- slack: SlackToolRegistrationHookContext;
339
- }
340
- interface LocalToolRegistrationContext extends BaseToolRegistrationHookContext, LocalInvocationContext {
341
- slack?: never;
342
- }
343
- interface WebToolRegistrationContext extends BaseToolRegistrationHookContext, WebInvocationContext {
344
- slack?: never;
345
- }
346
- interface ResourceEventToolRegistrationContext extends BaseToolRegistrationHookContext, ResourceEventInvocationContext {
347
- slack?: never;
348
- }
349
- export type ToolRegistrationHookContext = LocalToolRegistrationContext | ResourceEventToolRegistrationContext | SlackToolRegistrationContext | WebToolRegistrationContext;
337
+ export type ToolRegistrationHookContext = BaseToolRegistrationHookContext & InvocationContext & {
338
+ /** Slack tool details when the Conversation has a Slack Location. */
339
+ slack?: SlackToolRegistrationHookContext;
340
+ };
350
341
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/junior-plugin-api",
3
- "version": "0.192.0",
3
+ "version": "0.194.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
package/src/context.ts CHANGED
@@ -34,6 +34,13 @@ export type SlackSource = Extract<Source, { kind: "slack" }>;
34
34
  export type LocalSource = Extract<Source, { kind: "local" }>;
35
35
  export type WebSource = Extract<Source, { kind: "web" }>;
36
36
  export type ResourceEventSource = Extract<Source, { kind: "resource_event" }>;
37
+ export type ScheduledTaskSource = Extract<Source, { kind: "scheduled_task" }>;
38
+ export type EventTaskSource = Extract<Source, { kind: "event_task" }>;
39
+ export type PluginDispatchSource = Extract<Source, { kind: "plugin_dispatch" }>;
40
+ export type AgentInvocationSource = Extract<
41
+ Source,
42
+ { kind: "agent_invocation" }
43
+ >;
37
44
  export type SourceVisibility = z.output<typeof sourceVisibilitySchema>;
38
45
 
39
46
  export type Destination = z.output<typeof destinationSchema>;
@@ -122,16 +129,25 @@ export interface WebInvocationContext extends BaseInvocationContext {
122
129
  export interface ResourceEventInvocationContext extends BaseInvocationContext {
123
130
  /** Existing conversation destination used for tool context. */
124
131
  destination: Destination;
125
- actor?: SystemActor;
132
+ actor?: Actor;
126
133
  /** Runtime-owned Resource event Source for this invocation. */
127
134
  source: ResourceEventSource;
128
135
  }
129
136
 
130
137
  export type InvocationContext =
131
138
  | LocalInvocationContext
132
- | ResourceEventInvocationContext
133
139
  | SlackInvocationContext
134
- | WebInvocationContext;
140
+ | WebInvocationContext
141
+ | (BaseInvocationContext & {
142
+ destination: Destination;
143
+ actor?: Actor;
144
+ source:
145
+ | AgentInvocationSource
146
+ | EventTaskSource
147
+ | PluginDispatchSource
148
+ | ResourceEventSource
149
+ | ScheduledTaskSource;
150
+ });
135
151
 
136
152
  /** Build a normalized Slack source from runtime-owned Slack coordinates. */
137
153
  export function createSlackSource(input: {
@@ -209,6 +225,11 @@ export function getSourceKey(source: Source): string | undefined {
209
225
  }
210
226
  case "resource_event":
211
227
  return `resource-event:${source.namespace}:${source.eventKey}`;
228
+ case "scheduled_task":
229
+ case "event_task":
230
+ case "plugin_dispatch":
231
+ case "agent_invocation":
232
+ return undefined;
212
233
  }
213
234
  }
214
235
 
package/src/schemas.ts CHANGED
@@ -121,11 +121,35 @@ export const resourceEventSourceSchema = z
121
121
  })
122
122
  .strict();
123
123
 
124
+ /** Runtime-owned Scheduled task input Source. */
125
+ export const scheduledTaskSourceSchema = z
126
+ .object({ kind: z.literal("scheduled_task") })
127
+ .strict();
128
+
129
+ /** Runtime-owned Event task input Source. */
130
+ export const eventTaskSourceSchema = z
131
+ .object({ kind: z.literal("event_task") })
132
+ .strict();
133
+
134
+ /** Runtime-owned Plugin dispatch input Source. */
135
+ export const pluginDispatchSourceSchema = z
136
+ .object({ kind: z.literal("plugin_dispatch") })
137
+ .strict();
138
+
139
+ /** Runtime-owned Agent invocation input Source. */
140
+ export const agentInvocationSourceSchema = z
141
+ .object({ kind: z.literal("agent_invocation") })
142
+ .strict();
143
+
124
144
  const currentSourceSchema = z.discriminatedUnion("kind", [
125
145
  slackSourceSchema,
126
146
  localSourceSchema,
127
147
  webSourceSchema,
128
148
  resourceEventSourceSchema,
149
+ scheduledTaskSourceSchema,
150
+ eventTaskSourceSchema,
151
+ pluginDispatchSourceSchema,
152
+ agentInvocationSourceSchema,
129
153
  ]);
130
154
 
131
155
  function normalizeStoredSource(value: unknown): unknown {
@@ -320,6 +344,5 @@ export const dispatchOptionsSchema = z
320
344
  input: nonBlankStringSchema.pipe(z.string().max(32_000)),
321
345
  metadata: dispatchMetadataSchema.optional(),
322
346
  replyAttribution: replyAttributionSchema.optional(),
323
- source: sourceSchema,
324
347
  })
325
348
  .strict();
package/src/tools.ts CHANGED
@@ -1,14 +1,11 @@
1
1
  import type {
2
2
  Actor,
3
3
  Identity,
4
- LocalInvocationContext,
5
- ResourceEventInvocationContext,
4
+ InvocationContext,
6
5
  PluginContext,
7
6
  PluginEmbedder,
8
7
  PluginModel,
9
- SlackInvocationContext,
10
8
  User,
11
- WebInvocationContext,
12
9
  } from "./context";
13
10
  import type { PluginCredentialSubject } from "./credentials";
14
11
  import type { PluginAnnotations } from "./annotations";
@@ -508,8 +505,8 @@ export function definePluginTool<
508
505
 
509
506
  export interface SlackToolRegistrationHookContext {
510
507
  /**
511
- * Capabilities of the source Slack conversation exposed to this plugin.
512
- * Recomputed from `source.channelId`, not from `destination`.
508
+ * What Slack tools can do in the Conversation Location.
509
+ * Computed from Location, not from Source or Destination.
513
510
  */
514
511
  channelCapabilities: {
515
512
  canAddReactions: boolean;
@@ -568,28 +565,8 @@ interface BaseToolRegistrationHookContext extends PluginContext {
568
565
  workspaces: PluginWorkspaceToolContext;
569
566
  }
570
567
 
571
- interface SlackToolRegistrationContext
572
- extends BaseToolRegistrationHookContext, SlackInvocationContext {
573
- slack: SlackToolRegistrationHookContext;
574
- }
575
-
576
- interface LocalToolRegistrationContext
577
- extends BaseToolRegistrationHookContext, LocalInvocationContext {
578
- slack?: never;
579
- }
580
-
581
- interface WebToolRegistrationContext
582
- extends BaseToolRegistrationHookContext, WebInvocationContext {
583
- slack?: never;
584
- }
585
-
586
- interface ResourceEventToolRegistrationContext
587
- extends BaseToolRegistrationHookContext, ResourceEventInvocationContext {
588
- slack?: never;
589
- }
590
-
591
- export type ToolRegistrationHookContext =
592
- | LocalToolRegistrationContext
593
- | ResourceEventToolRegistrationContext
594
- | SlackToolRegistrationContext
595
- | WebToolRegistrationContext;
568
+ export type ToolRegistrationHookContext = BaseToolRegistrationHookContext &
569
+ InvocationContext & {
570
+ /** Slack tool details when the Conversation has a Slack Location. */
571
+ slack?: SlackToolRegistrationHookContext;
572
+ };