@sentry/junior-plugin-api 0.179.0 → 0.181.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
@@ -62,14 +62,12 @@ reports, and other typed hook surfaces exported by this package.
62
62
  - Profile report hooks return the same bounded operational report content for
63
63
  one subject user on a person profile. Core owns viewer authorization,
64
64
  collection, sanitization, and browser rendering.
65
- - Tool hooks may lazily resolve the active actor's canonical identity and linked
66
- user through `ctx.users.resolveActor()`.
65
+ - Tool hooks may resolve the active Actor's Identity and User through
66
+ `ctx.users.resolveActor()`.
67
67
  - Authenticated API route hooks receive `ctx.users.resolve(email)` for lazy
68
- canonical user resolution. Routes that do not need personal ownership do not
69
- query identity storage.
70
- - User page readers receive the canonical viewer `User` with linked identities.
71
- Plugins return bounded data and do not mount their own page routes or browser
72
- code.
68
+ User lookup. Routes that do not need User data do not query identity storage.
69
+ - User page readers receive the signed-in `User`. Plugins return limited data.
70
+ They do not mount their own page routes or browser code.
73
71
 
74
72
  ## User Pages
75
73
 
package/dist/context.d.ts CHANGED
@@ -74,6 +74,8 @@ interface BaseInvocationContext {
74
74
  * Interactive Slack turns use `slack:{channelId}:{threadTs}`.
75
75
  */
76
76
  conversationId?: string;
77
+ /** Location associated with this Conversation. */
78
+ locationId?: string;
77
79
  }
78
80
  export interface SlackInvocationContext extends BaseInvocationContext {
79
81
  /** Runtime-owned default outbound destination for this invocation. */
package/dist/index.js CHANGED
@@ -90,9 +90,10 @@ import { z as z3 } from "zod";
90
90
  var slackTeamIdSchema = z3.string().regex(/^T[A-Z0-9]+$/);
91
91
  var slackConversationIdSchema = z3.string().regex(/^(C|G|D)[A-Z0-9]+$/);
92
92
  var localConversationIdSchema = z3.string().regex(/^local:[a-z0-9_-]+:[a-z0-9][a-z0-9_-]*$/);
93
- var exactActorUserIdSchema = z3.string().min(1).refine(
93
+ var actorUserIdSchema = z3.string().min(1).refine(
94
94
  (value) => value === value.trim() && value.toLowerCase() !== "unknown"
95
95
  );
96
+ var exactActorUserIdSchema = actorUserIdSchema;
96
97
  var nonBlankStringSchema = z3.string().refine((value) => value.trim().length > 0);
97
98
  var exactNonBlankStringSchema = nonBlankStringSchema.refine(
98
99
  (value) => value === value.trim()
@@ -264,8 +265,8 @@ function createSlackSource(input) {
264
265
  visibility: input.visibility,
265
266
  teamId: input.teamId,
266
267
  channelId: input.channelId,
267
- ...input.messageTs ? { messageTs: input.messageTs } : {},
268
- ...input.threadTs ? { threadTs: input.threadTs } : {}
268
+ ...input.messageTs ? { messageTs: input.messageTs } : void 0,
269
+ ...input.threadTs ? { threadTs: input.threadTs } : void 0
269
270
  };
270
271
  }
271
272
  function createLocalSource(conversationId) {
@@ -478,9 +479,13 @@ var pluginRunTranscriptEntrySchema = z6.discriminatedUnion("type", [
478
479
  }).strict()
479
480
  ]);
480
481
  var pluginRunContextSchema = z6.object({
482
+ /** User linked to the Actor, when known. */
483
+ actorUserId: z6.string().min(1).optional(),
481
484
  completedAtMs: z6.number().finite(),
482
485
  conversationId: z6.string().min(1),
483
486
  destination: destinationSchema,
487
+ /** Location associated with this Conversation. */
488
+ locationId: z6.string().min(1).optional(),
484
489
  /**
485
490
  * All distinct actors annotated on this run's committed instruction-authority
486
491
  * messages, in first-seen order. Attribution provenance only, never an
@@ -601,7 +606,7 @@ function createZodTool(definition, helperName) {
601
606
  }
602
607
  return outputSchema.parse(result);
603
608
  }
604
- } : {}
609
+ } : void 0
605
610
  };
606
611
  }
607
612
  function zodTool(definition) {
@@ -863,11 +868,14 @@ var pluginUserPageLinkSchema = z10.object({
863
868
  pluginName: nonBlankStringSchema.max(100)
864
869
  }).strict();
865
870
  var pluginUserPageLinksSchema = z10.array(pluginUserPageLinkSchema);
871
+ var pluginUserPageCursorSchema = nonBlankStringSchema.max(1e3).optional();
872
+ var pluginUserPageFilterSchema = nonBlankStringSchema.max(64).optional();
873
+ var pluginUserPageQuerySchema = z10.string().trim().max(200).optional();
866
874
  var pluginUserPageInputSchema = z10.object({
867
- cursor: nonBlankStringSchema.max(1e3).optional(),
868
- filter: nonBlankStringSchema.max(64).optional(),
875
+ cursor: pluginUserPageCursorSchema,
876
+ filter: pluginUserPageFilterSchema,
869
877
  limit: z10.number().int().min(1).max(50),
870
- query: z10.string().trim().max(200).optional()
878
+ query: pluginUserPageQuerySchema
871
879
  }).strict();
872
880
  export {
873
881
  EgressAuthRequired,
@@ -880,6 +888,7 @@ export {
880
888
  RESOURCE_EVENT_SUMMARY_MAX_LENGTH,
881
889
  RESOURCE_EVENT_TEXT_MAX_LENGTH,
882
890
  actorSchema,
891
+ actorUserIdSchema,
883
892
  conversationAnnotationInputSchema,
884
893
  conversationEventIconSchema,
885
894
  conversationEventPresentationSchema,
@@ -925,9 +934,12 @@ export {
925
934
  pluginToolContinuationSchema,
926
935
  pluginToolOutputSchema,
927
936
  pluginUserPageContentSchema,
937
+ pluginUserPageCursorSchema,
938
+ pluginUserPageFilterSchema,
928
939
  pluginUserPageInputSchema,
929
940
  pluginUserPageLinkSchema,
930
941
  pluginUserPageLinksSchema,
942
+ pluginUserPageQuerySchema,
931
943
  promptContextSchema,
932
944
  promptMessageSchema,
933
945
  replyAttributionSchema,
package/dist/prompt.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import type { Destination, Platform, PluginContext, PluginEmbedder, PluginModel, Actor, Source } from "./context";
2
+ import type { Destination, Platform, PluginContext, PluginEmbedder, PluginModel, Actor, Identity, Source, User } from "./context";
3
3
  import type { PluginState } from "./state";
4
4
  import type { PluginConversationEvents } from "./conversation-events";
5
5
  export declare const promptMessageSchema: z.ZodObject<{
@@ -40,8 +40,17 @@ export type UserPromptContext = Pick<PluginContext, "db" | "log" | "plugin"> & {
40
40
  /** Conversation-bound event writer when the prompt belongs to a durable turn. */
41
41
  events?: PluginConversationEvents;
42
42
  model: PluginModel;
43
+ /** Location associated with this Conversation. */
44
+ locationId?: string;
43
45
  actor?: Actor;
44
46
  source: Source;
45
47
  state: PluginState;
46
48
  text: string;
49
+ users: {
50
+ /** Resolve the current Actor's Identity and User. */
51
+ resolveActor(): Promise<{
52
+ identity: Identity;
53
+ user?: User;
54
+ } | undefined>;
55
+ };
47
56
  };
package/dist/schemas.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import { z } from "zod";
2
+ /** Exact non-blank actor user id that rejects the sentinel "unknown". */
3
+ export declare const actorUserIdSchema: z.ZodString;
2
4
  export declare const nonBlankStringSchema: z.ZodString;
3
5
  /** Runtime platform names supported by plugin public contracts. */
4
6
  export declare const platformSchema: z.ZodEnum<{
package/dist/tasks.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Public plugin background-task contracts.
3
3
  *
4
- * Plugins register small task handlers, while Junior core owns durable
5
- * scheduling, queue delivery, retries, and the bounded run projection.
4
+ * Plugins register small task handlers. Junior core owns scheduling, delivery,
5
+ * retries, and the bounded run projection.
6
6
  */
7
7
  import { z } from "zod";
8
8
  import type { PluginConversationEvents } from "./conversation-events";
@@ -89,6 +89,7 @@ export declare const pluginRunTranscriptEntrySchema: z.ZodDiscriminatedUnion<[z.
89
89
  export type PluginRunTranscriptProvenance = z.output<typeof pluginRunTranscriptProvenanceSchema>;
90
90
  /** Runtime-owned completed-run projection exposed to plugin tasks. */
91
91
  export declare const pluginRunContextSchema: z.ZodObject<{
92
+ actorUserId: z.ZodOptional<z.ZodString>;
92
93
  completedAtMs: z.ZodNumber;
93
94
  conversationId: z.ZodString;
94
95
  destination: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -99,6 +100,7 @@ export declare const pluginRunContextSchema: z.ZodObject<{
99
100
  platform: z.ZodLiteral<"local">;
100
101
  conversationId: z.ZodString;
101
102
  }, z.core.$strict>], "platform">;
103
+ locationId: z.ZodOptional<z.ZodString>;
102
104
  actors: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
103
105
  platform: z.ZodLiteral<"slack">;
104
106
  teamId: z.ZodString;
@@ -68,6 +68,12 @@ export declare const pluginUserPageLinksSchema: z.ZodArray<z.ZodObject<{
68
68
  }, z.core.$strict>>;
69
69
  /** Safe navigation metadata for one registered plugin user page. */
70
70
  export type PluginUserPageLink = z.output<typeof pluginUserPageLinkSchema>;
71
+ /** Optional cursor token for one plugin user page reader. */
72
+ export declare const pluginUserPageCursorSchema: z.ZodOptional<z.ZodString>;
73
+ /** Optional filter token for one plugin user page reader. */
74
+ export declare const pluginUserPageFilterSchema: z.ZodOptional<z.ZodString>;
75
+ /** Optional free-text query for one plugin user page reader. */
76
+ export declare const pluginUserPageQuerySchema: z.ZodOptional<z.ZodString>;
71
77
  /** Validated query state passed to one plugin user page reader. */
72
78
  export declare const pluginUserPageInputSchema: z.ZodObject<{
73
79
  cursor: z.ZodOptional<z.ZodString>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/junior-plugin-api",
3
- "version": "0.179.0",
3
+ "version": "0.181.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -26,7 +26,8 @@
26
26
  "zod": "^4.4.3"
27
27
  },
28
28
  "devDependencies": {
29
- "oxlint": "^1.66.0",
29
+ "@oxlint/plugins": "1.79.0",
30
+ "oxlint": "^1.79.0",
30
31
  "tsup": "^8.5.1",
31
32
  "typescript": "^6.0.3"
32
33
  },
package/src/context.ts CHANGED
@@ -83,6 +83,8 @@ interface BaseInvocationContext {
83
83
  * Interactive Slack turns use `slack:{channelId}:{threadTs}`.
84
84
  */
85
85
  conversationId?: string;
86
+ /** Location associated with this Conversation. */
87
+ locationId?: string;
86
88
  }
87
89
 
88
90
  export interface SlackInvocationContext extends BaseInvocationContext {
@@ -128,8 +130,8 @@ export function createSlackSource(input: {
128
130
  visibility: input.visibility,
129
131
  teamId: input.teamId,
130
132
  channelId: input.channelId,
131
- ...(input.messageTs ? { messageTs: input.messageTs } : {}),
132
- ...(input.threadTs ? { threadTs: input.threadTs } : {}),
133
+ ...(input.messageTs ? { messageTs: input.messageTs } : undefined),
134
+ ...(input.threadTs ? { threadTs: input.threadTs } : undefined),
133
135
  };
134
136
  }
135
137
 
package/src/prompt.ts CHANGED
@@ -6,7 +6,9 @@ import type {
6
6
  PluginEmbedder,
7
7
  PluginModel,
8
8
  Actor,
9
+ Identity,
9
10
  Source,
11
+ User,
10
12
  } from "./context";
11
13
  import type { PluginState } from "./state";
12
14
  import type { PluginConversationEvents } from "./conversation-events";
@@ -84,8 +86,14 @@ export type UserPromptContext = Pick<PluginContext, "db" | "log" | "plugin"> & {
84
86
  /** Conversation-bound event writer when the prompt belongs to a durable turn. */
85
87
  events?: PluginConversationEvents;
86
88
  model: PluginModel;
89
+ /** Location associated with this Conversation. */
90
+ locationId?: string;
87
91
  actor?: Actor;
88
92
  source: Source;
89
93
  state: PluginState;
90
94
  text: string;
95
+ users: {
96
+ /** Resolve the current Actor's Identity and User. */
97
+ resolveActor(): Promise<{ identity: Identity; user?: User } | undefined>;
98
+ };
91
99
  };
package/src/schemas.ts CHANGED
@@ -5,12 +5,14 @@ const slackConversationIdSchema = z.string().regex(/^(C|G|D)[A-Z0-9]+$/);
5
5
  const localConversationIdSchema = z
6
6
  .string()
7
7
  .regex(/^local:[a-z0-9_-]+:[a-z0-9][a-z0-9_-]*$/);
8
- const exactActorUserIdSchema = z
8
+ /** Exact non-blank actor user id that rejects the sentinel "unknown". */
9
+ export const actorUserIdSchema = z
9
10
  .string()
10
11
  .min(1)
11
12
  .refine(
12
13
  (value) => value === value.trim() && value.toLowerCase() !== "unknown",
13
14
  );
15
+ const exactActorUserIdSchema = actorUserIdSchema;
14
16
 
15
17
  export const nonBlankStringSchema = z
16
18
  .string()
@@ -147,6 +149,8 @@ export const systemActorSchema = z
147
149
  })
148
150
  .strict();
149
151
 
152
+ // TODO(dcramer): Separate actor kind from provider platform.
153
+ // System actors should not use `platform: "system"`.
150
154
  /** Runtime-provided actor identity visible to plugin hooks. */
151
155
  export const actorSchema = z.discriminatedUnion("platform", [
152
156
  slackActorSchema,
package/src/tasks.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Public plugin background-task contracts.
3
3
  *
4
- * Plugins register small task handlers, while Junior core owns durable
5
- * scheduling, queue delivery, retries, and the bounded run projection.
4
+ * Plugins register small task handlers. Junior core owns scheduling, delivery,
5
+ * retries, and the bounded run projection.
6
6
  */
7
7
  import { z } from "zod";
8
8
  import type { PluginConversationEvents } from "./conversation-events";
@@ -50,9 +50,13 @@ export type PluginRunTranscriptProvenance = z.output<
50
50
  /** Runtime-owned completed-run projection exposed to plugin tasks. */
51
51
  export const pluginRunContextSchema = z
52
52
  .object({
53
+ /** User linked to the Actor, when known. */
54
+ actorUserId: z.string().min(1).optional(),
53
55
  completedAtMs: z.number().finite(),
54
56
  conversationId: z.string().min(1),
55
57
  destination: destinationSchema,
58
+ /** Location associated with this Conversation. */
59
+ locationId: z.string().min(1).optional(),
56
60
  /**
57
61
  * All distinct actors annotated on this run's committed instruction-authority
58
62
  * messages, in first-seen order. Attribution provenance only, never an
package/src/tools.ts CHANGED
@@ -455,7 +455,7 @@ function createZodTool<
455
455
  return outputSchema.parse(result);
456
456
  },
457
457
  }
458
- : {}),
458
+ : undefined),
459
459
  } as PluginToolDefinition<
460
460
  z.output<TInputSchema>,
461
461
  z.output<TOutputSchema>,
package/src/user-pages.ts CHANGED
@@ -86,13 +86,26 @@ export const pluginUserPageLinksSchema = z.array(pluginUserPageLinkSchema);
86
86
  /** Safe navigation metadata for one registered plugin user page. */
87
87
  export type PluginUserPageLink = z.output<typeof pluginUserPageLinkSchema>;
88
88
 
89
+ /** Optional cursor token for one plugin user page reader. */
90
+ export const pluginUserPageCursorSchema = nonBlankStringSchema
91
+ .max(1_000)
92
+ .optional();
93
+
94
+ /** Optional filter token for one plugin user page reader. */
95
+ export const pluginUserPageFilterSchema = nonBlankStringSchema
96
+ .max(64)
97
+ .optional();
98
+
99
+ /** Optional free-text query for one plugin user page reader. */
100
+ export const pluginUserPageQuerySchema = z.string().trim().max(200).optional();
101
+
89
102
  /** Validated query state passed to one plugin user page reader. */
90
103
  export const pluginUserPageInputSchema = z
91
104
  .object({
92
- cursor: nonBlankStringSchema.max(1_000).optional(),
93
- filter: nonBlankStringSchema.max(64).optional(),
105
+ cursor: pluginUserPageCursorSchema,
106
+ filter: pluginUserPageFilterSchema,
94
107
  limit: z.number().int().min(1).max(50),
95
- query: z.string().trim().max(200).optional(),
108
+ query: pluginUserPageQuerySchema,
96
109
  })
97
110
  .strict();
98
111