@sentry/junior-plugin-api 0.160.0 → 0.162.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
@@ -44,6 +44,7 @@ reports, and other typed hook surfaces exported by this package.
44
44
  database, logging, and only the host capabilities required by that hook.
45
45
  - Prompt hooks return bounded structured prompt messages rather than mutate the
46
46
  core prompt.
47
+ - `formatMarkdown` is a pure text rewrite into ordinary Markdown before delivery.
47
48
  - User prompt hooks for durable turns may emit registered structured events
48
49
  through `ctx.events` for auxiliary work completed while building context.
49
50
  - Tool hooks return model-visible schemas aligned with their executor inputs.
@@ -58,6 +59,9 @@ reports, and other typed hook surfaces exported by this package.
58
59
  binds the plugin namespace and owns access to the conversation event log.
59
60
  Event `costUsd` is additive operation cost and must not duplicate cost
60
61
  already recorded in the conversation's agent model usage.
62
+ - Profile report hooks return the same bounded operational report content for
63
+ one subject user on a person profile. Core owns viewer authorization,
64
+ collection, sanitization, and browser rendering.
61
65
  - Tool hooks may lazily resolve the active actor's canonical identity and linked
62
66
  user through `ctx.users.resolveActor()`.
63
67
  - Authenticated API route hooks receive `ctx.users.resolve(email)` for lazy
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import type { PluginContext } from "./context";
2
3
  export declare const resourceLinkAnnotationSchema: z.ZodObject<{
3
4
  kind: z.ZodLiteral<"resource_link">;
4
5
  key: z.ZodString;
@@ -42,3 +43,33 @@ export interface PluginAnnotations {
42
43
  export interface PluginConversationAnnotations {
43
44
  forConversation(conversationId: string): PluginAnnotations;
44
45
  }
46
+ export declare const conversationSidebarIconSchema: z.ZodEnum<{
47
+ "circle-dot": "circle-dot";
48
+ "circle-dashed": "circle-dashed";
49
+ "circle-x": "circle-x";
50
+ "git-merge": "git-merge";
51
+ "git-pull-request": "git-pull-request";
52
+ "triangle-alert": "triangle-alert";
53
+ }>;
54
+ export declare const conversationSidebarAnnotationSchema: z.ZodObject<{
55
+ icon: z.ZodOptional<z.ZodEnum<{
56
+ "circle-dot": "circle-dot";
57
+ "circle-dashed": "circle-dashed";
58
+ "circle-x": "circle-x";
59
+ "git-merge": "git-merge";
60
+ "git-pull-request": "git-pull-request";
61
+ "triangle-alert": "triangle-alert";
62
+ }>>;
63
+ key: z.ZodString;
64
+ label: z.ZodString;
65
+ }, z.core.$strict>;
66
+ export type ConversationSidebarAnnotation = z.output<typeof conversationSidebarAnnotationSchema>;
67
+ export interface ConversationSidebarHookContext extends PluginContext {
68
+ /** Stored annotations owned by this plugin, keyed by candidate conversation. */
69
+ annotationsByConversationId: Record<string, ConversationAnnotation[]>;
70
+ conversationIds: string[];
71
+ }
72
+ export interface ConversationSidebarResult {
73
+ /** Sidebar annotations in display order. Put the newest annotation first. */
74
+ annotationsByConversationId: Record<string, ConversationSidebarAnnotation[]>;
75
+ }
@@ -2,8 +2,8 @@ import { z } from "zod";
2
2
  export declare const conversationEventIconSchema: z.ZodEnum<{
3
3
  check: "check";
4
4
  key: "key";
5
- warning: "warning";
6
5
  link: "link";
6
+ warning: "warning";
7
7
  activity: "activity";
8
8
  brain: "brain";
9
9
  calendar: "calendar";
@@ -22,8 +22,8 @@ export declare const conversationEventPresentationSchema: z.ZodObject<{
22
22
  icon: z.ZodOptional<z.ZodEnum<{
23
23
  check: "check";
24
24
  key: "key";
25
- warning: "warning";
26
25
  link: "link";
26
+ warning: "warning";
27
27
  activity: "activity";
28
28
  brain: "brain";
29
29
  calendar: "calendar";
package/dist/hooks.d.ts CHANGED
@@ -1,8 +1,14 @@
1
+ import type { ConversationSidebarHookContext, ConversationSidebarResult } from "./annotations";
1
2
  import type { EgressHookContext, EgressResponseHookContext, IssueCredentialHookContext, PluginCredentialResult, PluginGrant, PluginProviderAccount, ResolveOAuthAccountHookContext } from "./credentials";
2
- import type { HeartbeatHookContext, HeartbeatResult, OperationalReportHookContext, ApiRouteRegistrationHookContext, PluginOperationalReportContent, PluginRoute, PluginRouteApp, RouteRegistrationHookContext, SlackConversationLink, SlackConversationLinkHookContext, UnfinishedWorkHookContext, UnfinishedWorkResult } from "./operations";
3
+ import type { HeartbeatHookContext, HeartbeatResult, OperationalReportHookContext, ProfileReportHookContext, ApiRouteRegistrationHookContext, PluginOperationalReportContent, PluginRoute, PluginRouteApp, RouteRegistrationHookContext, SlackConversationLink, SlackConversationLinkHookContext, UnfinishedWorkHookContext, UnfinishedWorkResult } from "./operations";
3
4
  import type { AfterMcpToolHookContext, BeforeToolExecuteHookContext, PluginToolDefinition, SandboxPrepareHookContext, ToolRegistrationHookContext } from "./tools";
4
5
  import type { PromptMessage, SystemPromptContext, UserPromptContext, UserPromptContribution } from "./prompt";
6
+ /** Input for a pure Markdown rewrite before destination delivery formatting. */
7
+ export interface FormatMarkdownHookContext {
8
+ text: string;
9
+ }
5
10
  export interface PluginHooks {
11
+ conversationSidebar?(ctx: ConversationSidebarHookContext): Promise<ConversationSidebarResult> | ConversationSidebarResult;
6
12
  systemPrompt?(ctx: SystemPromptContext): Promise<PromptMessage[]> | PromptMessage[];
7
13
  userPrompt?(ctx: UserPromptContext): Promise<UserPromptContribution[] | undefined> | UserPromptContribution[] | undefined;
8
14
  beforeToolExecute?(ctx: BeforeToolExecuteHookContext): Promise<void> | void;
@@ -19,11 +25,18 @@ export interface PluginHooks {
19
25
  issueCredential?(ctx: IssueCredentialHookContext): Promise<PluginCredentialResult> | PluginCredentialResult;
20
26
  onEgressResponse?(ctx: EgressResponseHookContext): Promise<void> | void;
21
27
  operationalReport?(ctx: OperationalReportHookContext): Promise<PluginOperationalReportContent | undefined> | PluginOperationalReportContent | undefined;
28
+ /**
29
+ * Return one person-scoped operational report for a profile page.
30
+ * Omit or return undefined when the plugin has nothing to show for the subject.
31
+ */
32
+ profileReport?(ctx: ProfileReportHookContext): Promise<PluginOperationalReportContent | undefined> | PluginOperationalReportContent | undefined;
22
33
  /** Return plugin-owned product API routes mounted under Junior's authenticated plugin namespace. */
23
34
  apiRoutes?(ctx: ApiRouteRegistrationHookContext): PluginRouteApp | undefined;
24
35
  resolveOAuthAccount?(ctx: ResolveOAuthAccountHookContext): Promise<PluginProviderAccount | undefined> | PluginProviderAccount | undefined;
25
36
  routes?(ctx: RouteRegistrationHookContext): PluginRoute[];
26
37
  sandboxPrepare?(ctx: SandboxPrepareHookContext): Promise<void> | void;
27
38
  slackConversationLink?(ctx: SlackConversationLinkHookContext): SlackConversationLink | undefined;
39
+ /** Pure Markdown rewrite. Emit ordinary Markdown only. */
40
+ formatMarkdown?(ctx: FormatMarkdownHookContext): string;
28
41
  tools?(ctx: ToolRegistrationHookContext): Record<string, PluginToolDefinition>;
29
42
  }
package/dist/index.js CHANGED
@@ -19,6 +19,19 @@ var resourceLinkAnnotationSchema = z.object({
19
19
  var conversationAnnotationInputSchema = z.discriminatedUnion("kind", [
20
20
  resourceLinkAnnotationSchema
21
21
  ]);
22
+ var conversationSidebarIconSchema = z.enum([
23
+ "circle-dot",
24
+ "circle-dashed",
25
+ "circle-x",
26
+ "git-merge",
27
+ "git-pull-request",
28
+ "triangle-alert"
29
+ ]);
30
+ var conversationSidebarAnnotationSchema = z.object({
31
+ icon: conversationSidebarIconSchema.optional(),
32
+ key: z.string().trim().min(1).max(256),
33
+ label: z.string().trim().min(1).max(256)
34
+ }).strict();
22
35
 
23
36
  // src/conversation-events.ts
24
37
  import { z as z2 } from "zod";
@@ -849,6 +862,8 @@ export {
849
862
  conversationAnnotationInputSchema,
850
863
  conversationEventIconSchema,
851
864
  conversationEventPresentationSchema,
865
+ conversationSidebarAnnotationSchema,
866
+ conversationSidebarIconSchema,
852
867
  createLocalSource,
853
868
  createSlackSource,
854
869
  createWebSource,
@@ -96,6 +96,15 @@ export interface OperationalReportHookContext extends PluginContext {
96
96
  nowMs: number;
97
97
  state: PluginReadState;
98
98
  }
99
+ /** Read-only context for one person-scoped plugin report on a profile page. */
100
+ export interface ProfileReportHookContext extends PluginContext {
101
+ nowMs: number;
102
+ state: PluginReadState;
103
+ /** Canonical user for the profile being viewed. */
104
+ subject: User;
105
+ /** Canonical user for the authenticated viewer. */
106
+ viewer: User;
107
+ }
99
108
  export type PluginRouteMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS" | "ALL";
100
109
  export type PluginRouteHandler = {
101
110
  bivarianceHack(request: Request): Promise<Response> | Response;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/junior-plugin-api",
3
- "version": "0.160.0",
3
+ "version": "0.162.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import type { PluginContext } from "./context";
2
3
 
3
4
  function usesHttpProtocol(value: string): boolean {
4
5
  try {
@@ -44,3 +45,34 @@ export interface PluginAnnotations {
44
45
  export interface PluginConversationAnnotations {
45
46
  forConversation(conversationId: string): PluginAnnotations;
46
47
  }
48
+
49
+ export const conversationSidebarIconSchema = z.enum([
50
+ "circle-dot",
51
+ "circle-dashed",
52
+ "circle-x",
53
+ "git-merge",
54
+ "git-pull-request",
55
+ "triangle-alert",
56
+ ]);
57
+
58
+ export const conversationSidebarAnnotationSchema = z
59
+ .object({
60
+ icon: conversationSidebarIconSchema.optional(),
61
+ key: z.string().trim().min(1).max(256),
62
+ label: z.string().trim().min(1).max(256),
63
+ })
64
+ .strict();
65
+ export type ConversationSidebarAnnotation = z.output<
66
+ typeof conversationSidebarAnnotationSchema
67
+ >;
68
+
69
+ export interface ConversationSidebarHookContext extends PluginContext {
70
+ /** Stored annotations owned by this plugin, keyed by candidate conversation. */
71
+ annotationsByConversationId: Record<string, ConversationAnnotation[]>;
72
+ conversationIds: string[];
73
+ }
74
+
75
+ export interface ConversationSidebarResult {
76
+ /** Sidebar annotations in display order. Put the newest annotation first. */
77
+ annotationsByConversationId: Record<string, ConversationSidebarAnnotation[]>;
78
+ }
package/src/hooks.ts CHANGED
@@ -1,3 +1,7 @@
1
+ import type {
2
+ ConversationSidebarHookContext,
3
+ ConversationSidebarResult,
4
+ } from "./annotations";
1
5
  import type {
2
6
  EgressHookContext,
3
7
  EgressResponseHookContext,
@@ -11,6 +15,7 @@ import type {
11
15
  HeartbeatHookContext,
12
16
  HeartbeatResult,
13
17
  OperationalReportHookContext,
18
+ ProfileReportHookContext,
14
19
  ApiRouteRegistrationHookContext,
15
20
  PluginOperationalReportContent,
16
21
  PluginRoute,
@@ -35,7 +40,15 @@ import type {
35
40
  UserPromptContribution,
36
41
  } from "./prompt";
37
42
 
43
+ /** Input for a pure Markdown rewrite before destination delivery formatting. */
44
+ export interface FormatMarkdownHookContext {
45
+ text: string;
46
+ }
47
+
38
48
  export interface PluginHooks {
49
+ conversationSidebar?(
50
+ ctx: ConversationSidebarHookContext,
51
+ ): Promise<ConversationSidebarResult> | ConversationSidebarResult;
39
52
  systemPrompt?(
40
53
  ctx: SystemPromptContext,
41
54
  ): Promise<PromptMessage[]> | PromptMessage[];
@@ -72,6 +85,16 @@ export interface PluginHooks {
72
85
  | Promise<PluginOperationalReportContent | undefined>
73
86
  | PluginOperationalReportContent
74
87
  | undefined;
88
+ /**
89
+ * Return one person-scoped operational report for a profile page.
90
+ * Omit or return undefined when the plugin has nothing to show for the subject.
91
+ */
92
+ profileReport?(
93
+ ctx: ProfileReportHookContext,
94
+ ):
95
+ | Promise<PluginOperationalReportContent | undefined>
96
+ | PluginOperationalReportContent
97
+ | undefined;
75
98
  /** Return plugin-owned product API routes mounted under Junior's authenticated plugin namespace. */
76
99
  apiRoutes?(ctx: ApiRouteRegistrationHookContext): PluginRouteApp | undefined;
77
100
  resolveOAuthAccount?(
@@ -85,6 +108,8 @@ export interface PluginHooks {
85
108
  slackConversationLink?(
86
109
  ctx: SlackConversationLinkHookContext,
87
110
  ): SlackConversationLink | undefined;
111
+ /** Pure Markdown rewrite. Emit ordinary Markdown only. */
112
+ formatMarkdown?(ctx: FormatMarkdownHookContext): string;
88
113
  tools?(
89
114
  ctx: ToolRegistrationHookContext,
90
115
  ): Record<string, PluginToolDefinition>;
package/src/operations.ts CHANGED
@@ -113,6 +113,16 @@ export interface OperationalReportHookContext extends PluginContext {
113
113
  state: PluginReadState;
114
114
  }
115
115
 
116
+ /** Read-only context for one person-scoped plugin report on a profile page. */
117
+ export interface ProfileReportHookContext extends PluginContext {
118
+ nowMs: number;
119
+ state: PluginReadState;
120
+ /** Canonical user for the profile being viewed. */
121
+ subject: User;
122
+ /** Canonical user for the authenticated viewer. */
123
+ viewer: User;
124
+ }
125
+
116
126
  export type PluginRouteMethod =
117
127
  | "GET"
118
128
  | "POST"