@sentry/junior-plugin-api 0.296.0 → 0.298.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
@@ -1,6 +1,83 @@
1
1
  import * as z from "zod";
2
2
  import { ZodTypeAny } from "zod";
3
3
  import { Command } from "commander";
4
+ /** Small, provider-neutral facts. Missing values mean unknown, not success. */
5
+ export declare const objectFactsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
6
+ type: z.ZodLiteral<"code_change">;
7
+ author: z.ZodOptional<z.ZodString>;
8
+ sourceBranch: z.ZodOptional<z.ZodString>;
9
+ targetBranch: z.ZodOptional<z.ZodString>;
10
+ reviewers: z.ZodOptional<z.ZodArray<z.ZodString>>;
11
+ review: z.ZodOptional<z.ZodEnum<{
12
+ approved: "approved";
13
+ changes_requested: "changes_requested";
14
+ required: "required";
15
+ }>>;
16
+ checks: z.ZodOptional<z.ZodObject<{
17
+ passed: z.ZodNumber;
18
+ failed: z.ZodNumber;
19
+ pending: z.ZodNumber;
20
+ }, z.core.$strict>>;
21
+ mergeable: z.ZodOptional<z.ZodBoolean>;
22
+ changedFiles: z.ZodOptional<z.ZodNumber>;
23
+ additions: z.ZodOptional<z.ZodNumber>;
24
+ deletions: z.ZodOptional<z.ZodNumber>;
25
+ }, z.core.$strict>, z.ZodObject<{
26
+ type: z.ZodLiteral<"task">;
27
+ assignees: z.ZodOptional<z.ZodArray<z.ZodString>>;
28
+ priority: z.ZodOptional<z.ZodString>;
29
+ project: z.ZodOptional<z.ZodString>;
30
+ cycle: z.ZodOptional<z.ZodString>;
31
+ dueDate: z.ZodOptional<z.ZodISODate>;
32
+ labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
33
+ }, z.core.$strict>, z.ZodObject<{
34
+ type: z.ZodLiteral<"deployment">;
35
+ project: z.ZodOptional<z.ZodString>;
36
+ environment: z.ZodOptional<z.ZodString>;
37
+ revision: z.ZodOptional<z.ZodString>;
38
+ branch: z.ZodOptional<z.ZodString>;
39
+ }, z.core.$strict>, z.ZodObject<{
40
+ type: z.ZodLiteral<"calendar_event">;
41
+ when: z.ZodOptional<z.ZodString>;
42
+ attendees: z.ZodOptional<z.ZodArray<z.ZodString>>;
43
+ }, z.core.$strict>], "type">;
44
+ export type ObjectFacts = z.output<typeof objectFactsSchema>;
45
+ type ObjectField = {
46
+ key: string;
47
+ label: string;
48
+ value: string;
49
+ };
50
+ /** Show at most four card attributes, in priority order, on every surface. */
51
+ export declare function objectFactFields(facts: ObjectFacts | undefined): ObjectField[];
52
+ /** Native object types. `task` is the stored name for a Ticket. */
53
+ export declare const objectTypeSchema: z.ZodEnum<{
54
+ automation: "automation";
55
+ calendar_event: "calendar_event";
56
+ code_change: "code_change";
57
+ deployment: "deployment";
58
+ item: "item";
59
+ task: "task";
60
+ }>;
61
+ export type ObjectType = z.output<typeof objectTypeSchema>;
62
+ declare const objectIconNames: readonly ["issue-opened", "issue-closed", "git-pull-request", "git-pull-request-draft", "git-pull-request-closed", "git-merge", "workflow", "rocket", "calendar", "package"];
63
+ export type ObjectIconName = (typeof objectIconNames)[number];
64
+ export type ObjectTone = "neutral" | "success" | "danger" | "warning" | "info" | "accent";
65
+ /** Resolve identity and state without replacing the type icon with a warning. */
66
+ export declare function objectPresentation(object: {
67
+ objectType: ObjectType;
68
+ status?: string;
69
+ facts?: {
70
+ type: string;
71
+ };
72
+ }): {
73
+ icon: ObjectIconName;
74
+ tone: ObjectTone;
75
+ label: string;
76
+ };
77
+ /** Public, versioned asset path shared by Slack delivery and the web host. */
78
+ export declare function objectIconPath(icon: ObjectIconName): string;
79
+ /** Return whether facts fit an object type. Deployment facts also fit an item. */
80
+ export declare function objectFactsMatchType(facts: ObjectFacts, objectType: ObjectType): boolean;
4
81
  /**
5
82
  * Verified facts shared by Conversation annotations and Message cards.
6
83
  * Plugins select small facts from responses they already have. Each surface owns
@@ -137,33 +214,6 @@ export declare const ownedObjectAnnotationSchema: z.ZodObject<{
137
214
  plugin: z.ZodString;
138
215
  }, z.core.$strict>;
139
216
  export type OwnedObjectAnnotation = z.output<typeof ownedObjectAnnotationSchema>;
140
- /** Native object types. `task` is the stored name for a Ticket. */
141
- export declare const objectTypeSchema: z.ZodEnum<{
142
- automation: "automation";
143
- calendar_event: "calendar_event";
144
- code_change: "code_change";
145
- deployment: "deployment";
146
- item: "item";
147
- task: "task";
148
- }>;
149
- export type ObjectType = z.output<typeof objectTypeSchema>;
150
- declare const objectIconNames: readonly ["issue-opened", "issue-closed", "git-pull-request", "git-pull-request-draft", "git-pull-request-closed", "git-merge", "workflow", "rocket", "calendar", "package"];
151
- export type ObjectIconName = (typeof objectIconNames)[number];
152
- export type ObjectTone = "neutral" | "success" | "danger" | "warning" | "info" | "accent";
153
- /** Resolve identity and state without replacing the type icon with a warning. */
154
- export declare function objectPresentation(object: {
155
- objectType: ObjectType;
156
- status?: string;
157
- facts?: {
158
- type: string;
159
- };
160
- }): {
161
- icon: ObjectIconName;
162
- tone: ObjectTone;
163
- label: string;
164
- };
165
- /** Public, versioned asset path shared by Slack delivery and the web host. */
166
- export declare function objectIconPath(icon: ObjectIconName): string;
167
217
  /** Original Octicons paths, shared by web and Slack image assets. */
168
218
  export declare const objectIconPaths: {
169
219
  "issue-opened": string[];
@@ -177,54 +227,6 @@ export declare const objectIconPaths: {
177
227
  calendar: string[];
178
228
  package: string[];
179
229
  };
180
- /** Small, provider-neutral facts. Missing values mean unknown, not success. */
181
- export declare const objectFactsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
182
- type: z.ZodLiteral<"code_change">;
183
- author: z.ZodOptional<z.ZodString>;
184
- sourceBranch: z.ZodOptional<z.ZodString>;
185
- targetBranch: z.ZodOptional<z.ZodString>;
186
- reviewers: z.ZodOptional<z.ZodArray<z.ZodString>>;
187
- review: z.ZodOptional<z.ZodEnum<{
188
- approved: "approved";
189
- changes_requested: "changes_requested";
190
- required: "required";
191
- }>>;
192
- checks: z.ZodOptional<z.ZodObject<{
193
- passed: z.ZodNumber;
194
- failed: z.ZodNumber;
195
- pending: z.ZodNumber;
196
- }, z.core.$strict>>;
197
- mergeable: z.ZodOptional<z.ZodBoolean>;
198
- changedFiles: z.ZodOptional<z.ZodNumber>;
199
- additions: z.ZodOptional<z.ZodNumber>;
200
- deletions: z.ZodOptional<z.ZodNumber>;
201
- }, z.core.$strict>, z.ZodObject<{
202
- type: z.ZodLiteral<"task">;
203
- assignees: z.ZodOptional<z.ZodArray<z.ZodString>>;
204
- priority: z.ZodOptional<z.ZodString>;
205
- project: z.ZodOptional<z.ZodString>;
206
- cycle: z.ZodOptional<z.ZodString>;
207
- dueDate: z.ZodOptional<z.ZodISODate>;
208
- labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
209
- }, z.core.$strict>, z.ZodObject<{
210
- type: z.ZodLiteral<"deployment">;
211
- project: z.ZodOptional<z.ZodString>;
212
- environment: z.ZodOptional<z.ZodString>;
213
- revision: z.ZodOptional<z.ZodString>;
214
- branch: z.ZodOptional<z.ZodString>;
215
- }, z.core.$strict>, z.ZodObject<{
216
- type: z.ZodLiteral<"calendar_event">;
217
- when: z.ZodOptional<z.ZodString>;
218
- attendees: z.ZodOptional<z.ZodArray<z.ZodString>>;
219
- }, z.core.$strict>], "type">;
220
- export type ObjectFacts = z.output<typeof objectFactsSchema>;
221
- type ObjectField = {
222
- key: string;
223
- label: string;
224
- value: string;
225
- };
226
- /** Show at most four card attributes, in priority order, on every surface. */
227
- export declare function objectFactFields(facts: ObjectFacts | undefined): ObjectField[];
228
230
  /** Exact non-blank actor user id that rejects the sentinel "unknown". */
229
231
  export declare const actorUserIdSchema: z.ZodString;
230
232
  export declare const nonBlankStringSchema: z.ZodString;
@@ -922,6 +924,15 @@ export interface CodeChangePublisher {
922
924
  providerId: string;
923
925
  }): Promise<void>;
924
926
  record(input: CodeChangeInput): Promise<void>;
927
+ /**
928
+ * Record a push, review, or comment by a person on a code change. Junior
929
+ * ignores activity on code changes that it did not record.
930
+ */
931
+ recordActivity(input: {
932
+ at: Date;
933
+ number: number;
934
+ repositoryProviderId: string;
935
+ }): Promise<void>;
925
936
  }
926
937
  export declare const conversationEventIconSchema: z.ZodEnum<{
927
938
  activity: "activity";
@@ -2051,269 +2062,44 @@ export interface IssueCredentialHookContext extends PluginContext {
2051
2062
  grant: PluginGrant;
2052
2063
  tokens: PluginTokenStore;
2053
2064
  }
2065
+ export interface PluginEnv {
2066
+ get(key: string): string | undefined;
2067
+ set(key: string, value: string): void;
2068
+ }
2054
2069
  /**
2055
- * An item that a plugin puts on the review desk: a notice for information,
2056
- * or an ask that waits on its assignees.
2070
+ * Decide what happens to one tool call in `beforeToolExecute`.
2071
+ *
2072
+ * `redirect` and `deny` both stop the tool before it runs. Neither ends the
2073
+ * turn: the agent gets the message as the tool result.
2057
2074
  */
2058
- export interface PluginReviewNotice {
2059
- /**
2060
- * Junior assigns the User linked to each Identity, but only when that User
2061
- * is in the notice's Conversation. It leaves out the others.
2062
- */
2063
- assigneeIdentityIds: string[];
2064
- /** Markdown details for the person. */
2065
- body: string;
2066
- /**
2067
- * Stable key for what the notice is about. A plugin has at most one open
2068
- * item for each key.
2069
- */
2070
- dedupeKey: string;
2071
- /** What the notice is about, such as a pull request. Search matches `id`. */
2072
- subject?: {
2073
- id: string;
2074
- title?: string;
2075
- url?: string;
2076
- };
2075
+ export interface PluginDecision {
2077
2076
  /**
2078
- * For an item that waits on its assignees, name their step, such as
2079
- * `Ready to merge · #946`. It is the reason that the dashboard shows.
2077
+ * Block the call as a policy refusal. The agent is told not to retry or
2078
+ * reach the same result another way, and to explain the block.
2080
2079
  */
2081
- title: string;
2080
+ deny(reason: string): void;
2082
2081
  /**
2083
- * The assignees must act, such as merge a pull request that is ready. The
2084
- * item then waits on them: its Conversation shows in their Needs you, and
2085
- * it counts in their Inbox. Leave it unset for a notice that is only for
2086
- * information.
2082
+ * Block the call because a different path is correct, such as another
2083
+ * tool. The message tells the agent what to do instead.
2087
2084
  */
2088
- waitsOnAssignees?: boolean;
2085
+ redirect(message: string): void;
2086
+ replaceInput(input: Record<string, unknown>): void;
2089
2087
  }
2090
2088
  /**
2091
- * Review items that a plugin adds and closes from its own events. Each item
2092
- * belongs to one Conversation. Core owns visibility, assignment rules, and
2093
- * the Slack cards.
2089
+ * Decide what the agent reads after one tool call in `afterToolExecute`.
2090
+ *
2091
+ * The tool already ran, so neither choice undoes its effects.
2094
2092
  */
2095
- export interface PluginReviewItems {
2096
- /** Add an open item, or replace the content of the open one with the key. */
2097
- upsert(notice: PluginReviewNotice): Promise<void>;
2098
- /** Close the open item with the key. Do nothing when no item is open. */
2099
- close(input: {
2100
- dedupeKey: string;
2101
- reason: string;
2102
- status: "done" | "dismissed";
2103
- }): Promise<void>;
2104
- }
2105
- /** Review items of a plugin, for the Conversation that each item belongs to. */
2106
- export interface PluginConversationReviewItems {
2107
- forConversation(conversationId: string): PluginReviewItems;
2108
- }
2109
- export interface HeartbeatHookContext extends PluginContext {
2110
- agent: {
2111
- dispatch(options: DispatchOptions): Promise<DispatchResult>;
2112
- get(id: string): Promise<Dispatch | undefined>;
2113
- };
2114
- /** Host embedder bound to the configured embedding model. */
2115
- embedder: PluginEmbedder;
2116
- /** Publish events, as from a plugin route. */
2117
- events: EventPublisher;
2118
- nowMs: number;
2119
- state: PluginState;
2120
- }
2121
- export interface HeartbeatResult {
2122
- dispatchCount?: number;
2123
- }
2124
- export interface UnfinishedWorkHookContext extends PluginContext {
2093
+ export interface PluginToolResultDecision {
2125
2094
  /**
2126
- * Bounded conversation candidates selected by the host, with the child
2127
- * conversations of candidate roots. Work in a child counts for its root.
2095
+ * Reject the result as a policy refusal. The agent gets the reason instead
2096
+ * of the result, and is told not to retry. Undo the tool's effects first
2097
+ * when they must not stay.
2128
2098
  */
2129
- conversationIds: string[];
2130
- }
2131
- export interface UnfinishedWorkResult {
2132
- /** Candidate conversations that have plugin-owned work to finish. */
2133
- conversationIds: string[];
2099
+ deny(reason: string): void;
2134
2100
  /**
2135
- * Candidate conversations that have any associated plugin-owned work,
2136
- * finished or unfinished. Omit when the plugin cannot distinguish assignment.
2137
- *
2138
- * The host uses this with unfinished work and finish times to set feed
2139
- * `isPriority`. Finished assigned work stays out of Priority unless the
2140
- * conversation has activity after the finish time.
2141
- */
2142
- assignedConversationIds?: string[];
2143
- /**
2144
- * Latest time when all known work finished, keyed by conversation id.
2145
- * ISO-8601 timestamps. Used with conversation activity to decide whether
2146
- * finished work still belongs in Priority, and whether auto-archive may
2147
- * archive the conversation for users who turned it on.
2148
- */
2149
- finishedWorkAtByConversationId?: Record<string, string>;
2150
- }
2151
- export type PluginOperationalTone = "danger" | "good" | "neutral" | "warning";
2152
- export interface PluginOperationalMetric {
2153
- label: string;
2154
- tone?: PluginOperationalTone;
2155
- value: string;
2156
- }
2157
- export interface PluginOperationalField {
2158
- key: string;
2159
- label: string;
2160
- }
2161
- export interface PluginOperationalRecord {
2162
- id: string;
2163
- tone?: PluginOperationalTone;
2164
- values: Record<string, string>;
2165
- }
2166
- export interface PluginOperationalRecordSet {
2167
- fields?: PluginOperationalField[];
2168
- emptyText?: string;
2169
- records?: PluginOperationalRecord[];
2170
- title: string;
2171
- }
2172
- export interface PluginOperationalChartSeries {
2173
- format?: "usd";
2174
- key: string;
2175
- label: string;
2176
- tone?: PluginOperationalTone;
2177
- }
2178
- export interface PluginOperationalChartCategory {
2179
- id: string;
2180
- label: string;
2181
- values: Record<string, number>;
2182
- }
2183
- export interface PluginOperationalBarChartWidget {
2184
- categories: PluginOperationalChartCategory[];
2185
- description?: string;
2186
- emptyText?: string;
2187
- id: string;
2188
- series: PluginOperationalChartSeries[];
2189
- timeRangeDays?: Array<1 | 7 | 30 | 90>;
2190
- title: string;
2191
- type: "bar_chart";
2192
- }
2193
- export interface PluginOperationalReportContent {
2194
- generatedAt?: string;
2195
- metrics?: PluginOperationalMetric[];
2196
- recordSets?: PluginOperationalRecordSet[];
2197
- title?: string;
2198
- widgets?: PluginOperationalBarChartWidget[];
2199
- }
2200
- export interface PluginOperationalReport extends PluginOperationalReportContent {
2201
- pluginName: string;
2202
- }
2203
- export interface OperationalReportHookContext extends PluginContext {
2204
- eventStats: PluginConversationEventStats;
2205
- nowMs: number;
2206
- state: PluginReadState;
2207
- }
2208
- /** Read-only context for one person-scoped plugin report on a profile page. */
2209
- export interface ProfileReportHookContext extends PluginContext {
2210
- nowMs: number;
2211
- state: PluginReadState;
2212
- /** Canonical user for the profile being viewed. */
2213
- subject: User;
2214
- /** Canonical user for the authenticated viewer. */
2215
- viewer: User;
2216
- }
2217
- export type PluginRouteMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS" | "ALL";
2218
- export type PluginRouteHandler = {
2219
- bivarianceHack(request: Request): Promise<Response> | Response;
2220
- }["bivarianceHack"];
2221
- export interface PluginRoute {
2222
- handler: PluginRouteHandler;
2223
- method?: PluginRouteMethod | PluginRouteMethod[];
2224
- path: string;
2225
- }
2226
- /** Fetch-compatible plugin HTTP app mounted by Junior. */
2227
- export type PluginRouteApp = {
2228
- fetch(request: Request, context?: PluginApiRouteRequestContext): Promise<Response> | Response;
2229
- };
2230
- export interface RouteRegistrationHookContext extends PluginContext {
2231
- annotations: PluginConversationAnnotations;
2232
- /** Provider-neutral write boundary for Junior's native code index. */
2233
- codeChanges: CodeChangePublisher;
2234
- /** Core-owned delivery boundary for provider webhook events. */
2235
- events: EventPublisher;
2236
- /** Review desk items that the plugin adds and closes from its events. */
2237
- reviewItems: PluginConversationReviewItems;
2238
- /** Plugin-namespaced state, the same as in heartbeats. */
2239
- state: PluginState;
2240
- users: {
2241
- /**
2242
- * Read one stored identity and the user it links to now, with every
2243
- * identity of that user. A plugin that saved an identity id uses this to
2244
- * find the person's other linked accounts later.
2245
- */
2246
- readIdentity(identityId: string): Promise<{
2247
- identity: Identity;
2248
- user?: User;
2249
- } | undefined>;
2250
- };
2251
- }
2252
- export interface ApiRouteRegistrationHookContext extends PluginContext {
2253
- conversationEvents: PluginConversationEventReader;
2254
- eventStats: PluginConversationEventStats;
2255
- users: {
2256
- /** Resolve or create the canonical user for one verified email. */
2257
- resolve(email: string): Promise<User | undefined>;
2258
- };
2259
- }
2260
- /** Per-request context Junior passes to authenticated plugin product API routes. */
2261
- export declare const pluginApiRouteRequestContextSchema: z.ZodObject<{
2262
- auth: z.ZodObject<{
2263
- user: z.ZodObject<{
2264
- email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2265
- emailVerified: z.ZodOptional<z.ZodBoolean>;
2266
- isAdmin: z.ZodBoolean;
2267
- name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2268
- }, z.core.$strict>;
2269
- }, z.core.$strict>;
2270
- pluginName: z.ZodString;
2271
- }, z.core.$strict>;
2272
- export type PluginApiRouteRequestContext = z.output<typeof pluginApiRouteRequestContextSchema>;
2273
- export interface SlackConversationLink {
2274
- url: string;
2275
- }
2276
- export interface SlackConversationLinkHookContext extends PluginContext {
2277
- conversationId: string;
2278
- }
2279
- export interface PluginEnv {
2280
- get(key: string): string | undefined;
2281
- set(key: string, value: string): void;
2282
- }
2283
- /**
2284
- * Decide what happens to one tool call in `beforeToolExecute`.
2285
- *
2286
- * `redirect` and `deny` both stop the tool before it runs. Neither ends the
2287
- * turn: the agent gets the message as the tool result.
2288
- */
2289
- export interface PluginDecision {
2290
- /**
2291
- * Block the call as a policy refusal. The agent is told not to retry or
2292
- * reach the same result another way, and to explain the block.
2293
- */
2294
- deny(reason: string): void;
2295
- /**
2296
- * Block the call because a different path is correct, such as another
2297
- * tool. The message tells the agent what to do instead.
2298
- */
2299
- redirect(message: string): void;
2300
- replaceInput(input: Record<string, unknown>): void;
2301
- }
2302
- /**
2303
- * Decide what the agent reads after one tool call in `afterToolExecute`.
2304
- *
2305
- * The tool already ran, so neither choice undoes its effects.
2306
- */
2307
- export interface PluginToolResultDecision {
2308
- /**
2309
- * Reject the result as a policy refusal. The agent gets the reason instead
2310
- * of the result, and is told not to retry. Undo the tool's effects first
2311
- * when they must not stay.
2312
- */
2313
- deny(reason: string): void;
2314
- /**
2315
- * Add guidance after the result, such as a problem to fix in the change
2316
- * that the tool made. The agent reads the result and the guidance.
2101
+ * Add guidance after the result, such as a problem to fix in the change
2102
+ * that the tool made. The agent reads the result and the guidance.
2317
2103
  */
2318
2104
  nudge(message: string): void;
2319
2105
  }
@@ -2727,8 +2513,6 @@ export interface SlackToolRegistrationHookContext {
2727
2513
  canCreateCanvas: boolean;
2728
2514
  canPostToChannel: boolean;
2729
2515
  };
2730
- /** Host-owned link to this conversation, preferring the dashboard when enabled. */
2731
- conversationLink?: SlackConversationLink;
2732
2516
  credentialSubject?: Extract<PluginCredentialSubject, {
2733
2517
  allowedWhen: "private-direct-conversation";
2734
2518
  }>;
@@ -2775,6 +2559,10 @@ interface BaseToolRegistrationHookContext extends PluginContext {
2775
2559
  automationLink?: {
2776
2560
  url: string;
2777
2561
  };
2562
+ /** Host-owned dashboard link to this conversation, when the dashboard is enabled. */
2563
+ conversationLink?: {
2564
+ url: string;
2565
+ };
2778
2566
  embedder: PluginEmbedder;
2779
2567
  egress: PluginEgress;
2780
2568
  mcp?: PluginMcp;
@@ -2802,6 +2590,235 @@ export type ToolRegistrationHookContext = BaseToolRegistrationHookContext & Invo
2802
2590
  /** Slack tool details when the Conversation has a Slack Location. */
2803
2591
  slack?: SlackToolRegistrationHookContext;
2804
2592
  };
2593
+ /**
2594
+ * An item that a plugin puts on the review desk: a notice for information,
2595
+ * or an ask that waits on its assignees.
2596
+ */
2597
+ export interface PluginReviewNotice {
2598
+ /**
2599
+ * Junior assigns the User linked to each Identity, but only when that User
2600
+ * is in the notice's Conversation. It leaves out the others.
2601
+ */
2602
+ assigneeIdentityIds: string[];
2603
+ /** Markdown details for the person. */
2604
+ body: string;
2605
+ /**
2606
+ * Stable key for what the notice is about. A plugin has at most one open
2607
+ * item for each key.
2608
+ */
2609
+ dedupeKey: string;
2610
+ /** What the notice is about, such as a pull request. Search matches `id`. */
2611
+ subject?: {
2612
+ id: string;
2613
+ title?: string;
2614
+ url?: string;
2615
+ };
2616
+ /**
2617
+ * For an item that waits on its assignees, name their step, such as
2618
+ * `Ready to merge · #946`. It is the reason that the dashboard shows.
2619
+ */
2620
+ title: string;
2621
+ /**
2622
+ * The assignees must act, such as merge a pull request that is ready. The
2623
+ * item then waits on them: its Conversation shows in their Needs you, and
2624
+ * it counts in their Inbox. Leave it unset for a notice that is only for
2625
+ * information.
2626
+ */
2627
+ waitsOnAssignees?: boolean;
2628
+ }
2629
+ /**
2630
+ * Review items that a plugin adds and closes from its own events. Each item
2631
+ * belongs to one Conversation. Core owns visibility, assignment rules, and
2632
+ * the Slack cards.
2633
+ */
2634
+ export interface PluginReviewItems {
2635
+ /** Add an open item, or replace the content of the open one with the key. */
2636
+ upsert(notice: PluginReviewNotice): Promise<void>;
2637
+ /** Close the open item with the key. Do nothing when no item is open. */
2638
+ close(input: {
2639
+ dedupeKey: string;
2640
+ reason: string;
2641
+ status: "done" | "dismissed";
2642
+ }): Promise<void>;
2643
+ }
2644
+ /** Review items of a plugin, for the Conversation that each item belongs to. */
2645
+ export interface PluginConversationReviewItems {
2646
+ forConversation(conversationId: string): PluginReviewItems;
2647
+ }
2648
+ export interface HeartbeatHookContext extends PluginContext {
2649
+ agent: {
2650
+ dispatch(options: DispatchOptions): Promise<DispatchResult>;
2651
+ get(id: string): Promise<Dispatch | undefined>;
2652
+ };
2653
+ /** Conversation annotations, as from a plugin route. */
2654
+ annotations: PluginConversationAnnotations;
2655
+ /** Junior's native code index, as from a plugin route. */
2656
+ codeChanges: CodeChangePublisher;
2657
+ /** Host embedder bound to the configured embedding model. */
2658
+ embedder: PluginEmbedder;
2659
+ /** Publish events, as from a plugin route. */
2660
+ events: EventPublisher;
2661
+ nowMs: number;
2662
+ state: PluginState;
2663
+ }
2664
+ export interface HeartbeatResult {
2665
+ dispatchCount?: number;
2666
+ }
2667
+ export interface UnfinishedWorkHookContext extends PluginContext {
2668
+ /**
2669
+ * Bounded conversation candidates selected by the host, with the child
2670
+ * conversations of candidate roots. Work in a child counts for its root.
2671
+ */
2672
+ conversationIds: string[];
2673
+ }
2674
+ export interface UnfinishedWorkResult {
2675
+ /** Candidate conversations that have plugin-owned work to finish. */
2676
+ conversationIds: string[];
2677
+ /**
2678
+ * Candidate conversations that have any associated plugin-owned work,
2679
+ * finished or unfinished. Omit when the plugin cannot distinguish assignment.
2680
+ *
2681
+ * The host uses this with unfinished work and finish times to set feed
2682
+ * `isPriority`. Finished assigned work stays out of Priority unless the
2683
+ * conversation has activity after the finish time.
2684
+ */
2685
+ assignedConversationIds?: string[];
2686
+ /**
2687
+ * Latest time when all known work finished, keyed by conversation id.
2688
+ * ISO-8601 timestamps. Used with conversation activity to decide whether
2689
+ * finished work still belongs in Priority, and whether auto-archive may
2690
+ * archive the conversation for users who turned it on.
2691
+ */
2692
+ finishedWorkAtByConversationId?: Record<string, string>;
2693
+ }
2694
+ export type PluginOperationalTone = "danger" | "good" | "neutral" | "warning";
2695
+ export interface PluginOperationalMetric {
2696
+ label: string;
2697
+ tone?: PluginOperationalTone;
2698
+ value: string;
2699
+ }
2700
+ export interface PluginOperationalField {
2701
+ key: string;
2702
+ label: string;
2703
+ }
2704
+ export interface PluginOperationalRecord {
2705
+ id: string;
2706
+ tone?: PluginOperationalTone;
2707
+ values: Record<string, string>;
2708
+ }
2709
+ export interface PluginOperationalRecordSet {
2710
+ fields?: PluginOperationalField[];
2711
+ emptyText?: string;
2712
+ records?: PluginOperationalRecord[];
2713
+ title: string;
2714
+ }
2715
+ export interface PluginOperationalChartSeries {
2716
+ format?: "usd";
2717
+ key: string;
2718
+ label: string;
2719
+ tone?: PluginOperationalTone;
2720
+ }
2721
+ export interface PluginOperationalChartCategory {
2722
+ id: string;
2723
+ label: string;
2724
+ values: Record<string, number>;
2725
+ }
2726
+ export interface PluginOperationalBarChartWidget {
2727
+ categories: PluginOperationalChartCategory[];
2728
+ description?: string;
2729
+ emptyText?: string;
2730
+ id: string;
2731
+ series: PluginOperationalChartSeries[];
2732
+ timeRangeDays?: Array<1 | 7 | 30 | 90>;
2733
+ title: string;
2734
+ type: "bar_chart";
2735
+ }
2736
+ export interface PluginOperationalReportContent {
2737
+ generatedAt?: string;
2738
+ metrics?: PluginOperationalMetric[];
2739
+ recordSets?: PluginOperationalRecordSet[];
2740
+ title?: string;
2741
+ widgets?: PluginOperationalBarChartWidget[];
2742
+ }
2743
+ export interface PluginOperationalReport extends PluginOperationalReportContent {
2744
+ pluginName: string;
2745
+ }
2746
+ export interface OperationalReportHookContext extends PluginContext {
2747
+ eventStats: PluginConversationEventStats;
2748
+ nowMs: number;
2749
+ state: PluginReadState;
2750
+ }
2751
+ /** Read-only context for one person-scoped plugin report on a profile page. */
2752
+ export interface ProfileReportHookContext extends PluginContext {
2753
+ nowMs: number;
2754
+ state: PluginReadState;
2755
+ /** Canonical user for the profile being viewed. */
2756
+ subject: User;
2757
+ /** Canonical user for the authenticated viewer. */
2758
+ viewer: User;
2759
+ }
2760
+ export type PluginRouteMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS" | "ALL";
2761
+ export type PluginRouteHandler = {
2762
+ bivarianceHack(request: Request): Promise<Response> | Response;
2763
+ }["bivarianceHack"];
2764
+ export interface PluginRoute {
2765
+ handler: PluginRouteHandler;
2766
+ method?: PluginRouteMethod | PluginRouteMethod[];
2767
+ path: string;
2768
+ }
2769
+ /** Fetch-compatible plugin HTTP app mounted by Junior. */
2770
+ export type PluginRouteApp = {
2771
+ fetch(request: Request, context?: PluginApiRouteRequestContext): Promise<Response> | Response;
2772
+ };
2773
+ export interface RouteRegistrationHookContext extends PluginContext {
2774
+ annotations: PluginConversationAnnotations;
2775
+ /** Provider-neutral write boundary for Junior's native code index. */
2776
+ codeChanges: CodeChangePublisher;
2777
+ /** Core-owned delivery boundary for provider webhook events. */
2778
+ events: EventPublisher;
2779
+ /** Review desk items that the plugin adds and closes from its events. */
2780
+ reviewItems: PluginConversationReviewItems;
2781
+ /** Plugin-namespaced state, the same as in heartbeats. */
2782
+ state: PluginState;
2783
+ users: {
2784
+ /**
2785
+ * Read one stored identity and the user it links to now, with every
2786
+ * identity of that user. A plugin that saved an identity id uses this to
2787
+ * find the person's other linked accounts later.
2788
+ */
2789
+ readIdentity(identityId: string): Promise<{
2790
+ identity: Identity;
2791
+ user?: User;
2792
+ } | undefined>;
2793
+ };
2794
+ }
2795
+ export interface ApiRouteRegistrationHookContext extends PluginContext {
2796
+ conversationEvents: PluginConversationEventReader;
2797
+ eventStats: PluginConversationEventStats;
2798
+ users: {
2799
+ /** Resolve or create the canonical user for one verified email. */
2800
+ resolve(email: string): Promise<User | undefined>;
2801
+ };
2802
+ }
2803
+ /** Per-request context Junior passes to authenticated plugin product API routes. */
2804
+ export declare const pluginApiRouteRequestContextSchema: z.ZodObject<{
2805
+ auth: z.ZodObject<{
2806
+ user: z.ZodObject<{
2807
+ email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2808
+ emailVerified: z.ZodOptional<z.ZodBoolean>;
2809
+ isAdmin: z.ZodBoolean;
2810
+ name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2811
+ }, z.core.$strict>;
2812
+ }, z.core.$strict>;
2813
+ pluginName: z.ZodString;
2814
+ }, z.core.$strict>;
2815
+ export type PluginApiRouteRequestContext = z.output<typeof pluginApiRouteRequestContextSchema>;
2816
+ export interface SlackConversationLink {
2817
+ url: string;
2818
+ }
2819
+ export interface SlackConversationLinkHookContext extends PluginContext {
2820
+ conversationId: string;
2821
+ }
2805
2822
  /**
2806
2823
  * Deny provider egress when a plugin policy does not allow the request.
2807
2824
  *
package/dist/index.js CHANGED
@@ -148,6 +148,10 @@ function objectIconPath(icon) {
148
148
  return `/_junior/dashboard/object-icons/v1/${icon}.png`;
149
149
  }
150
150
  // src/object-annotations.ts
151
+ /** Return whether facts fit an object type. Deployment facts also fit an item. */
152
+ function objectFactsMatchType(facts, objectType) {
153
+ return facts.type === "deployment" ? objectType === "deployment" || objectType === "item" : facts.type === objectType;
154
+ }
151
155
  /**
152
156
  * Verified facts shared by Conversation annotations and Message cards.
153
157
  * Plugins select small facts from responses they already have. Each surface owns
@@ -174,7 +178,7 @@ const objectAnnotationSchema = z.object({
174
178
  displayType: z.string().trim().min(1).max(80).optional(),
175
179
  sourceUpdatedAt: z.iso.datetime({ offset: true }).optional(),
176
180
  facts: objectFactsSchema.refine((facts) => new TextEncoder().encode(JSON.stringify(facts)).length <= 4096, "Object facts must not exceed 4 KiB").optional()
177
- }).strict().refine((annotation) => !annotation.facts || (annotation.facts.type === "deployment" ? annotation.objectType === "deployment" || annotation.objectType === "item" : annotation.facts.type === annotation.objectType), "Object facts must match the object type");
181
+ }).strict().refine((annotation) => !annotation.facts || objectFactsMatchType(annotation.facts, annotation.objectType), "Object facts must match the object type");
178
182
  /** A saved object snapshot with its trusted owner. */
179
183
  const ownedObjectAnnotationSchema = objectAnnotationSchema.safeExtend({ plugin: z.string().min(1) });
180
184
  // src/object-icons.ts
@@ -1833,4 +1837,4 @@ const pluginUserPageInputSchema = z.object({
1833
1837
  limit: z.number().int().min(1).max(50),
1834
1838
  query: pluginUserPageQuerySchema
1835
1839
  }).strict();
1836
- export { EVENT_DATA_MAX_JSON_BYTES, EVENT_DATA_MAX_KEYS, EVENT_GUIDANCE_MAX_LENGTH, EVENT_SUMMARY_MAX_LENGTH, EVENT_TEXT_MAX_LENGTH, EgressAuthRequired, EgressPolicyDenied, PluginToolInputError, REQUIRED_TOOL_ANNOTATION_KEYS, actorSchema, actorUserIdSchema, agentEventKeys, agentEventMatchKey, agentEventMatchSchema, agentInvocationSourceSchema, anyResourceEvents, anyResourceMatchFields, codeChangeInputSchema, codeChangeStateSchema, conversationAnnotationInputSchema, conversationEventIconSchema, conversationEventPresentationSchema, conversationSidebarAnnotationSchema, conversationSidebarIconSchema, createEventSource, createLocalSource, createSlackSource, createWebSource, declaredEventKeys, defineConversationEvent, defineJuniorPlugin, definePluginTool, definePromptContext, describeEventTrigger, destinationSchema, destinationVisibilitySchema, dispatchOptionsSchema, enforceEgressPolicy, eventAutomationSourceSchema, eventDataSchema, eventIdentifierSchema, eventInputSchema, eventMatchFieldSchema, eventMatchFieldsSchema, eventMatchFilterText, eventMatchSchema, eventMatches, eventPersonSchema, eventReachSchema, eventSchema, eventSourceSchema, eventTriggerChoices, eventTriggerFiltersText, eventTriggerProblems, eventTriggerText, eventTypeSchema, eventTypeText, eventsWithoutMatchField, getSourceKey, identitySchema, isPluginModelCostEventName, isPrivateSource, isSlackDestination, localActorSchema, localDestinationSchema, localSourceSchema, locationSchema, mergeEventMatchFields, missingToolAnnotationKeys, nonBlankStringSchema, normalizeEventIdentifier, normalizeEventMatch, objectAnnotationSchema, objectFactFields, objectFactsSchema, objectIconPath, objectIconPaths, objectPresentation, objectTypeSchema, ownedObjectAnnotationSchema, parseShellCommands, platformSchema, pluginApiRouteRequestContextSchema, pluginAuditAttributesSchema, pluginAuthorizationSchema, pluginCredentialHeaderTransformSchema, pluginCredentialLeaseSchema, pluginCredentialResultSchema, pluginCredentialSubjectSchema, pluginDispatchSourceSchema, pluginEventDeclarationSchema, pluginEventTypeSchema, pluginEventsSchema, pluginGrantSchema, pluginModelCostEventNames, pluginProviderAccountSchema, pluginRunContextSchema, pluginRunTranscriptEntrySchema, pluginRunTranscriptProvenanceSchema, pluginStoredTokensSchema, pluginToolContentSchema, pluginToolContinuationSchema, pluginToolOutputSchema, pluginToolReplySchema, pluginUserPageContentSchema, pluginUserPageCursorSchema, pluginUserPageFilterSchema, pluginUserPageInputSchema, pluginUserPageLinkSchema, pluginUserPageLinksSchema, pluginUserPageQuerySchema, promptContextSchema, promptMessageSchema, replyAttributionSchema, resourceLinkAnnotationSchema, resourceTypeSchema, scheduledAutomationSourceSchema, slackActorSchema, slackDestinationSchema, slackLocationSchema, slackSourceSchema, sourceSchema, sourceVisibilitySchema, stableEventMatchKey, subscribableResourceSchema, systemActorSchema, taskOutcomeSchema, toolApprovalModeSchema, userSchema, watchResultSchema, webActorSchema, webSourceSchema, zodTool };
1840
+ export { EVENT_DATA_MAX_JSON_BYTES, EVENT_DATA_MAX_KEYS, EVENT_GUIDANCE_MAX_LENGTH, EVENT_SUMMARY_MAX_LENGTH, EVENT_TEXT_MAX_LENGTH, EgressAuthRequired, EgressPolicyDenied, PluginToolInputError, REQUIRED_TOOL_ANNOTATION_KEYS, actorSchema, actorUserIdSchema, agentEventKeys, agentEventMatchKey, agentEventMatchSchema, agentInvocationSourceSchema, anyResourceEvents, anyResourceMatchFields, codeChangeInputSchema, codeChangeStateSchema, conversationAnnotationInputSchema, conversationEventIconSchema, conversationEventPresentationSchema, conversationSidebarAnnotationSchema, conversationSidebarIconSchema, createEventSource, createLocalSource, createSlackSource, createWebSource, declaredEventKeys, defineConversationEvent, defineJuniorPlugin, definePluginTool, definePromptContext, describeEventTrigger, destinationSchema, destinationVisibilitySchema, dispatchOptionsSchema, enforceEgressPolicy, eventAutomationSourceSchema, eventDataSchema, eventIdentifierSchema, eventInputSchema, eventMatchFieldSchema, eventMatchFieldsSchema, eventMatchFilterText, eventMatchSchema, eventMatches, eventPersonSchema, eventReachSchema, eventSchema, eventSourceSchema, eventTriggerChoices, eventTriggerFiltersText, eventTriggerProblems, eventTriggerText, eventTypeSchema, eventTypeText, eventsWithoutMatchField, getSourceKey, identitySchema, isPluginModelCostEventName, isPrivateSource, isSlackDestination, localActorSchema, localDestinationSchema, localSourceSchema, locationSchema, mergeEventMatchFields, missingToolAnnotationKeys, nonBlankStringSchema, normalizeEventIdentifier, normalizeEventMatch, objectAnnotationSchema, objectFactFields, objectFactsMatchType, objectFactsSchema, objectIconPath, objectIconPaths, objectPresentation, objectTypeSchema, ownedObjectAnnotationSchema, parseShellCommands, platformSchema, pluginApiRouteRequestContextSchema, pluginAuditAttributesSchema, pluginAuthorizationSchema, pluginCredentialHeaderTransformSchema, pluginCredentialLeaseSchema, pluginCredentialResultSchema, pluginCredentialSubjectSchema, pluginDispatchSourceSchema, pluginEventDeclarationSchema, pluginEventTypeSchema, pluginEventsSchema, pluginGrantSchema, pluginModelCostEventNames, pluginProviderAccountSchema, pluginRunContextSchema, pluginRunTranscriptEntrySchema, pluginRunTranscriptProvenanceSchema, pluginStoredTokensSchema, pluginToolContentSchema, pluginToolContinuationSchema, pluginToolOutputSchema, pluginToolReplySchema, pluginUserPageContentSchema, pluginUserPageCursorSchema, pluginUserPageFilterSchema, pluginUserPageInputSchema, pluginUserPageLinkSchema, pluginUserPageLinksSchema, pluginUserPageQuerySchema, promptContextSchema, promptMessageSchema, replyAttributionSchema, resourceLinkAnnotationSchema, resourceTypeSchema, scheduledAutomationSourceSchema, slackActorSchema, slackDestinationSchema, slackLocationSchema, slackSourceSchema, sourceSchema, sourceVisibilitySchema, stableEventMatchKey, subscribableResourceSchema, systemActorSchema, taskOutcomeSchema, toolApprovalModeSchema, userSchema, watchResultSchema, webActorSchema, webSourceSchema, zodTool };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/junior-plugin-api",
3
- "version": "0.296.0",
3
+ "version": "0.298.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"