@sentry/junior-plugin-api 0.299.0 → 0.300.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.
Files changed (3) hide show
  1. package/dist/index.d.ts +1600 -1443
  2. package/dist/index.js +64 -1
  3. package/package.json +2 -2
package/dist/index.d.ts CHANGED
@@ -1,9 +1,12 @@
1
1
  import * as z from "zod";
2
2
  import { ZodTypeAny } from "zod";
3
3
  import { Command } from "commander";
4
+ /** The longest object summary, in UTF-16 code units. */
5
+ export declare const OBJECT_SUMMARY_MAX_LENGTH = 280;
4
6
  /** Small, provider-neutral facts. Missing values mean unknown, not success. */
5
7
  export declare const objectFactsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
6
8
  type: z.ZodLiteral<"code_change">;
9
+ summary: z.ZodOptional<z.ZodString>;
7
10
  author: z.ZodOptional<z.ZodString>;
8
11
  sourceBranch: z.ZodOptional<z.ZodString>;
9
12
  targetBranch: z.ZodOptional<z.ZodString>;
@@ -25,6 +28,7 @@ export declare const objectFactsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
25
28
  previewImageUrls: z.ZodOptional<z.ZodArray<z.ZodURL>>;
26
29
  }, z.core.$strict>, z.ZodObject<{
27
30
  type: z.ZodLiteral<"task">;
31
+ summary: z.ZodOptional<z.ZodString>;
28
32
  assignees: z.ZodOptional<z.ZodArray<z.ZodString>>;
29
33
  priority: z.ZodOptional<z.ZodString>;
30
34
  project: z.ZodOptional<z.ZodString>;
@@ -33,31 +37,52 @@ export declare const objectFactsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
33
37
  labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
34
38
  }, z.core.$strict>, z.ZodObject<{
35
39
  type: z.ZodLiteral<"deployment">;
40
+ summary: z.ZodOptional<z.ZodString>;
36
41
  project: z.ZodOptional<z.ZodString>;
37
42
  environment: z.ZodOptional<z.ZodString>;
38
43
  revision: z.ZodOptional<z.ZodString>;
39
44
  branch: z.ZodOptional<z.ZodString>;
40
45
  }, z.core.$strict>, z.ZodObject<{
41
46
  type: z.ZodLiteral<"calendar_event">;
47
+ summary: z.ZodOptional<z.ZodString>;
42
48
  when: z.ZodOptional<z.ZodString>;
43
49
  attendees: z.ZodOptional<z.ZodArray<z.ZodString>>;
44
50
  }, z.core.$strict>, z.ZodObject<{
45
51
  type: z.ZodLiteral<"conversation">;
52
+ summary: z.ZodOptional<z.ZodString>;
46
53
  participants: z.ZodOptional<z.ZodArray<z.ZodString>>;
47
54
  lastActivityAt: z.ZodOptional<z.ZodISODateTime>;
55
+ }, z.core.$strict>, z.ZodObject<{
56
+ type: z.ZodLiteral<"document">;
57
+ summary: z.ZodOptional<z.ZodString>;
58
+ owner: z.ZodOptional<z.ZodString>;
59
+ modifiedAt: z.ZodOptional<z.ZodISODateTime>;
48
60
  }, z.core.$strict>, z.ZodObject<{
49
61
  type: z.ZodLiteral<"message">;
62
+ summary: z.ZodOptional<z.ZodString>;
50
63
  channel: z.ZodOptional<z.ZodString>;
51
64
  author: z.ZodOptional<z.ZodString>;
52
65
  sentAt: z.ZodOptional<z.ZodISODateTime>;
66
+ }, z.core.$strict>, z.ZodObject<{
67
+ type: z.ZodLiteral<"web_page">;
68
+ summary: z.ZodOptional<z.ZodString>;
69
+ siteName: z.ZodOptional<z.ZodString>;
70
+ author: z.ZodOptional<z.ZodString>;
71
+ thumbnailUrl: z.ZodOptional<z.ZodString>;
53
72
  }, z.core.$strict>, z.ZodObject<{
54
73
  type: z.ZodLiteral<"person">;
74
+ summary: z.ZodOptional<z.ZodString>;
55
75
  email: z.ZodOptional<z.ZodString>;
56
76
  slackHandle: z.ZodOptional<z.ZodString>;
57
77
  githubHandle: z.ZodOptional<z.ZodString>;
58
78
  avatarUrl: z.ZodOptional<z.ZodString>;
59
79
  }, z.core.$strict>], "type">;
60
80
  export type ObjectFacts = z.output<typeof objectFactsSchema>;
81
+ /**
82
+ * Make an object summary from plain text. Join whitespace and cut overlong
83
+ * text at a word, with an ellipsis. Empty text gives no summary.
84
+ */
85
+ export declare function objectSummary(text: string): string | undefined;
61
86
  type ObjectField = {
62
87
  href?: string;
63
88
  key: string;
@@ -73,13 +98,15 @@ export declare const objectTypeSchema: z.ZodEnum<{
73
98
  code_change: "code_change";
74
99
  conversation: "conversation";
75
100
  deployment: "deployment";
101
+ document: "document";
76
102
  item: "item";
77
103
  message: "message";
78
104
  person: "person";
79
105
  task: "task";
106
+ web_page: "web_page";
80
107
  }>;
81
108
  export type ObjectType = z.output<typeof objectTypeSchema>;
82
- declare const objectIconNames: readonly ["issue-opened", "issue-closed", "git-pull-request", "git-pull-request-draft", "git-pull-request-closed", "git-merge", "workflow", "rocket", "calendar", "comment-discussion", "person", "comment", "package"];
109
+ declare const objectIconNames: readonly ["issue-opened", "issue-closed", "git-pull-request", "git-pull-request-draft", "git-pull-request-closed", "git-merge", "workflow", "rocket", "calendar", "comment-discussion", "person", "file", "comment", "globe", "package"];
83
110
  export type ObjectIconName = (typeof objectIconNames)[number];
84
111
  export type ObjectTone = "neutral" | "success" | "danger" | "warning" | "info" | "accent";
85
112
  /** Resolve identity and state without replacing the type icon with a warning. */
@@ -124,10 +151,12 @@ export declare const objectAnnotationSchema: z.ZodObject<{
124
151
  code_change: "code_change";
125
152
  conversation: "conversation";
126
153
  deployment: "deployment";
154
+ document: "document";
127
155
  item: "item";
128
156
  message: "message";
129
157
  person: "person";
130
158
  task: "task";
159
+ web_page: "web_page";
131
160
  }>;
132
161
  title: z.ZodString;
133
162
  url: z.ZodNullable<z.ZodURL>;
@@ -139,6 +168,7 @@ export declare const objectAnnotationSchema: z.ZodObject<{
139
168
  sourceUpdatedAt: z.ZodOptional<z.ZodISODateTime>;
140
169
  facts: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
141
170
  type: z.ZodLiteral<"code_change">;
171
+ summary: z.ZodOptional<z.ZodString>;
142
172
  author: z.ZodOptional<z.ZodString>;
143
173
  sourceBranch: z.ZodOptional<z.ZodString>;
144
174
  targetBranch: z.ZodOptional<z.ZodString>;
@@ -160,6 +190,7 @@ export declare const objectAnnotationSchema: z.ZodObject<{
160
190
  previewImageUrls: z.ZodOptional<z.ZodArray<z.ZodURL>>;
161
191
  }, z.core.$strict>, z.ZodObject<{
162
192
  type: z.ZodLiteral<"task">;
193
+ summary: z.ZodOptional<z.ZodString>;
163
194
  assignees: z.ZodOptional<z.ZodArray<z.ZodString>>;
164
195
  priority: z.ZodOptional<z.ZodString>;
165
196
  project: z.ZodOptional<z.ZodString>;
@@ -168,25 +199,41 @@ export declare const objectAnnotationSchema: z.ZodObject<{
168
199
  labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
169
200
  }, z.core.$strict>, z.ZodObject<{
170
201
  type: z.ZodLiteral<"deployment">;
202
+ summary: z.ZodOptional<z.ZodString>;
171
203
  project: z.ZodOptional<z.ZodString>;
172
204
  environment: z.ZodOptional<z.ZodString>;
173
205
  revision: z.ZodOptional<z.ZodString>;
174
206
  branch: z.ZodOptional<z.ZodString>;
175
207
  }, z.core.$strict>, z.ZodObject<{
176
208
  type: z.ZodLiteral<"calendar_event">;
209
+ summary: z.ZodOptional<z.ZodString>;
177
210
  when: z.ZodOptional<z.ZodString>;
178
211
  attendees: z.ZodOptional<z.ZodArray<z.ZodString>>;
179
212
  }, z.core.$strict>, z.ZodObject<{
180
213
  type: z.ZodLiteral<"conversation">;
214
+ summary: z.ZodOptional<z.ZodString>;
181
215
  participants: z.ZodOptional<z.ZodArray<z.ZodString>>;
182
216
  lastActivityAt: z.ZodOptional<z.ZodISODateTime>;
217
+ }, z.core.$strict>, z.ZodObject<{
218
+ type: z.ZodLiteral<"document">;
219
+ summary: z.ZodOptional<z.ZodString>;
220
+ owner: z.ZodOptional<z.ZodString>;
221
+ modifiedAt: z.ZodOptional<z.ZodISODateTime>;
183
222
  }, z.core.$strict>, z.ZodObject<{
184
223
  type: z.ZodLiteral<"message">;
224
+ summary: z.ZodOptional<z.ZodString>;
185
225
  channel: z.ZodOptional<z.ZodString>;
186
226
  author: z.ZodOptional<z.ZodString>;
187
227
  sentAt: z.ZodOptional<z.ZodISODateTime>;
228
+ }, z.core.$strict>, z.ZodObject<{
229
+ type: z.ZodLiteral<"web_page">;
230
+ summary: z.ZodOptional<z.ZodString>;
231
+ siteName: z.ZodOptional<z.ZodString>;
232
+ author: z.ZodOptional<z.ZodString>;
233
+ thumbnailUrl: z.ZodOptional<z.ZodString>;
188
234
  }, z.core.$strict>, z.ZodObject<{
189
235
  type: z.ZodLiteral<"person">;
236
+ summary: z.ZodOptional<z.ZodString>;
190
237
  email: z.ZodOptional<z.ZodString>;
191
238
  slackHandle: z.ZodOptional<z.ZodString>;
192
239
  githubHandle: z.ZodOptional<z.ZodString>;
@@ -205,10 +252,12 @@ export declare const ownedObjectAnnotationSchema: z.ZodObject<{
205
252
  code_change: "code_change";
206
253
  conversation: "conversation";
207
254
  deployment: "deployment";
255
+ document: "document";
208
256
  item: "item";
209
257
  message: "message";
210
258
  person: "person";
211
259
  task: "task";
260
+ web_page: "web_page";
212
261
  }>;
213
262
  title: z.ZodString;
214
263
  url: z.ZodNullable<z.ZodURL>;
@@ -220,6 +269,7 @@ export declare const ownedObjectAnnotationSchema: z.ZodObject<{
220
269
  sourceUpdatedAt: z.ZodOptional<z.ZodISODateTime>;
221
270
  facts: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
222
271
  type: z.ZodLiteral<"code_change">;
272
+ summary: z.ZodOptional<z.ZodString>;
223
273
  author: z.ZodOptional<z.ZodString>;
224
274
  sourceBranch: z.ZodOptional<z.ZodString>;
225
275
  targetBranch: z.ZodOptional<z.ZodString>;
@@ -241,6 +291,7 @@ export declare const ownedObjectAnnotationSchema: z.ZodObject<{
241
291
  previewImageUrls: z.ZodOptional<z.ZodArray<z.ZodURL>>;
242
292
  }, z.core.$strict>, z.ZodObject<{
243
293
  type: z.ZodLiteral<"task">;
294
+ summary: z.ZodOptional<z.ZodString>;
244
295
  assignees: z.ZodOptional<z.ZodArray<z.ZodString>>;
245
296
  priority: z.ZodOptional<z.ZodString>;
246
297
  project: z.ZodOptional<z.ZodString>;
@@ -249,25 +300,41 @@ export declare const ownedObjectAnnotationSchema: z.ZodObject<{
249
300
  labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
250
301
  }, z.core.$strict>, z.ZodObject<{
251
302
  type: z.ZodLiteral<"deployment">;
303
+ summary: z.ZodOptional<z.ZodString>;
252
304
  project: z.ZodOptional<z.ZodString>;
253
305
  environment: z.ZodOptional<z.ZodString>;
254
306
  revision: z.ZodOptional<z.ZodString>;
255
307
  branch: z.ZodOptional<z.ZodString>;
256
308
  }, z.core.$strict>, z.ZodObject<{
257
309
  type: z.ZodLiteral<"calendar_event">;
310
+ summary: z.ZodOptional<z.ZodString>;
258
311
  when: z.ZodOptional<z.ZodString>;
259
312
  attendees: z.ZodOptional<z.ZodArray<z.ZodString>>;
260
313
  }, z.core.$strict>, z.ZodObject<{
261
314
  type: z.ZodLiteral<"conversation">;
315
+ summary: z.ZodOptional<z.ZodString>;
262
316
  participants: z.ZodOptional<z.ZodArray<z.ZodString>>;
263
317
  lastActivityAt: z.ZodOptional<z.ZodISODateTime>;
318
+ }, z.core.$strict>, z.ZodObject<{
319
+ type: z.ZodLiteral<"document">;
320
+ summary: z.ZodOptional<z.ZodString>;
321
+ owner: z.ZodOptional<z.ZodString>;
322
+ modifiedAt: z.ZodOptional<z.ZodISODateTime>;
264
323
  }, z.core.$strict>, z.ZodObject<{
265
324
  type: z.ZodLiteral<"message">;
325
+ summary: z.ZodOptional<z.ZodString>;
266
326
  channel: z.ZodOptional<z.ZodString>;
267
327
  author: z.ZodOptional<z.ZodString>;
268
328
  sentAt: z.ZodOptional<z.ZodISODateTime>;
329
+ }, z.core.$strict>, z.ZodObject<{
330
+ type: z.ZodLiteral<"web_page">;
331
+ summary: z.ZodOptional<z.ZodString>;
332
+ siteName: z.ZodOptional<z.ZodString>;
333
+ author: z.ZodOptional<z.ZodString>;
334
+ thumbnailUrl: z.ZodOptional<z.ZodString>;
269
335
  }, z.core.$strict>, z.ZodObject<{
270
336
  type: z.ZodLiteral<"person">;
337
+ summary: z.ZodOptional<z.ZodString>;
271
338
  email: z.ZodOptional<z.ZodString>;
272
339
  slackHandle: z.ZodOptional<z.ZodString>;
273
340
  githubHandle: z.ZodOptional<z.ZodString>;
@@ -289,7 +356,9 @@ export declare const objectIconPaths: {
289
356
  calendar: string[];
290
357
  "comment-discussion": string[];
291
358
  person: string[];
359
+ file: string[];
292
360
  comment: string[];
361
+ globe: string[];
293
362
  package: string[];
294
363
  };
295
364
  /** Exact non-blank actor user id that rejects the sentinel "unknown". */
@@ -791,478 +860,524 @@ export declare function isPrivateSource(source: Source): boolean;
791
860
  export declare function getSourceKey(source: Source): string | undefined;
792
861
  /** Narrow a runtime destination to the Slack-specific address shape. */
793
862
  export declare function isSlackDestination(destination: Destination | undefined): destination is SlackDestination;
794
- /** Which URLs a link type claims. Give at most one path field. */
795
- export declare const objectLinkFilterSchema: z.ZodObject<{
796
- scheme: z.ZodOptional<z.ZodEnum<{
797
- http: "http";
798
- https: "https";
799
- mailto: "mailto";
800
- }>>;
801
- host: z.ZodOptional<z.ZodString>;
802
- path: z.ZodOptional<z.ZodString>;
803
- pathPattern: z.ZodOptional<z.ZodString>;
804
- pathPrefix: z.ZodOptional<z.ZodString>;
805
- }, z.core.$strict>;
806
- export type ObjectLinkFilter = z.output<typeof objectLinkFilterSchema>;
807
- /** Return whether a filter claims a URL. A trailing slash does not count. */
808
- export declare function objectLinkFilterMatches(filter: ObjectLinkFilter, url: URL): boolean;
809
- /**
810
- * Rank how specific a filter is. Compare ranks in order: an exact host
811
- * before a wildcard host, an exact path before a pattern before a prefix,
812
- * and then the longer match.
813
- */
814
- export declare function objectLinkFilterSpecificity(filter: ObjectLinkFilter): number[];
815
- /** Trusted host context for one link resolution. */
816
- export interface ObjectLinkContext extends PluginContext {
817
- /** The signed-in person who sees the card. */
863
+ /** How Junior fetches one image. */
864
+ export interface ImageFetch {
865
+ /**
866
+ * Request headers, such as the plugin's credential. Junior sends them only
867
+ * to the origin of `url`, not after a redirect to another origin.
868
+ */
869
+ headers?: Record<string, string>;
870
+ url: string;
871
+ }
872
+ /** Trusted host context for one image read. */
873
+ export interface ImageSourceContext extends PluginContext {
874
+ /** The signed-in person who sees the image. */
818
875
  viewer: User;
819
876
  }
820
877
  /**
821
- * One link type of a plugin. `resolve` reads the object with the viewer's
822
- * own access. Return nothing when the viewer cannot read the object, so the
823
- * card does not show that it exists. Junior does not save the result.
878
+ * Images that a plugin serves through the Junior image proxy. `resolve`
879
+ * checks that the viewer may see the image and returns how to fetch it.
880
+ * Return nothing when the viewer cannot see it. Junior checks the address,
881
+ * the type, and the size of each image, and caches it for every viewer.
824
882
  */
825
- export interface PluginObjectLinkDefinition {
826
- filters: ObjectLinkFilter[];
827
- objectType: ObjectType;
828
- resolve(ctx: ObjectLinkContext, url: URL): Promise<ObjectAnnotation | undefined>;
883
+ export interface PluginImageSource {
884
+ resolve(ctx: ImageSourceContext, ref: string): Promise<ImageFetch | undefined>;
829
885
  }
886
+ declare const pluginGrantAccessSchema: z.ZodUnion<readonly [z.ZodLiteral<"read">, z.ZodLiteral<"write">]>;
887
+ /** Runtime schema for provider authorization a plugin may request. */
888
+ export declare const pluginAuthorizationSchema: z.ZodObject<{
889
+ provider: z.ZodString;
890
+ scope: z.ZodOptional<z.ZodString>;
891
+ type: z.ZodLiteral<"oauth">;
892
+ }, z.core.$strict>;
893
+ /** Runtime schema for a provider account attached to stored OAuth tokens. */
894
+ export declare const pluginProviderAccountSchema: z.ZodObject<{
895
+ displayName: z.ZodOptional<z.ZodString>;
896
+ handle: z.ZodOptional<z.ZodString>;
897
+ id: z.ZodString;
898
+ label: z.ZodOptional<z.ZodString>;
899
+ url: z.ZodOptional<z.ZodString>;
900
+ verifiedEmails: z.ZodOptional<z.ZodArray<z.ZodString>>;
901
+ }, z.core.$strict>;
902
+ /** Runtime schema for OAuth tokens stored by the host for plugin credentials. */
903
+ export declare const pluginStoredTokensSchema: z.ZodObject<{
904
+ account: z.ZodOptional<z.ZodObject<{
905
+ displayName: z.ZodOptional<z.ZodString>;
906
+ handle: z.ZodOptional<z.ZodString>;
907
+ id: z.ZodString;
908
+ label: z.ZodOptional<z.ZodString>;
909
+ url: z.ZodOptional<z.ZodString>;
910
+ verifiedEmails: z.ZodOptional<z.ZodArray<z.ZodString>>;
911
+ }, z.core.$strict>>;
912
+ accessToken: z.ZodString;
913
+ expiresAt: z.ZodOptional<z.ZodNumber>;
914
+ refreshToken: z.ZodString;
915
+ refreshTokenExpiresAt: z.ZodOptional<z.ZodNumber>;
916
+ scope: z.ZodOptional<z.ZodString>;
917
+ }, z.core.$strict>;
830
918
  /**
831
- * Link an object to a Conversation when the owner has no typed object preview.
832
- * Keep a stable key, compact label, source URL, and optional short context or
833
- * status. Do not fetch a full object merely to save a link. Rich preview intent
834
- * belongs to objectAnnotationSchema, not a second set of resource-link fields.
919
+ * Provider facts for egress audit events, such as the target repository.
920
+ * Keys use the plugin's `app.<provider>.*` names. Telemetry only.
835
921
  */
836
- export declare const resourceLinkAnnotationSchema: z.ZodObject<{
837
- kind: z.ZodLiteral<"resource_link">;
838
- objectType: z.ZodOptional<z.ZodEnum<{
839
- automation: "automation";
840
- calendar_event: "calendar_event";
841
- code_change: "code_change";
842
- conversation: "conversation";
843
- deployment: "deployment";
844
- item: "item";
845
- message: "message";
846
- person: "person";
847
- task: "task";
848
- }>>;
849
- key: z.ZodString;
850
- label: z.ZodString;
851
- url: z.ZodString;
852
- description: z.ZodOptional<z.ZodString>;
853
- status: z.ZodOptional<z.ZodEnum<{
854
- closed: "closed";
855
- draft: "draft";
856
- merged: "merged";
857
- open: "open";
858
- warning: "warning";
859
- }>>;
922
+ export declare const pluginAuditAttributesSchema: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>]>>;
923
+ /** Runtime schema for a plugin-defined outbound credential grant. */
924
+ export declare const pluginGrantSchema: z.ZodObject<{
925
+ access: z.ZodUnion<readonly [z.ZodLiteral<"read">, z.ZodLiteral<"write">]>;
926
+ auditAttributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>]>>>;
927
+ leaseScope: z.ZodOptional<z.ZodString>;
928
+ name: z.ZodString;
929
+ reason: z.ZodOptional<z.ZodString>;
930
+ requirements: z.ZodOptional<z.ZodArray<z.ZodString>>;
860
931
  }, z.core.$strict>;
861
- /** Core-known annotation shapes that plugins may attach to a conversation. */
862
- export declare const conversationAnnotationInputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
863
- kind: z.ZodLiteral<"resource_link">;
864
- objectType: z.ZodOptional<z.ZodEnum<{
865
- automation: "automation";
866
- calendar_event: "calendar_event";
867
- code_change: "code_change";
868
- conversation: "conversation";
869
- deployment: "deployment";
870
- item: "item";
871
- message: "message";
872
- person: "person";
873
- task: "task";
874
- }>>;
875
- key: z.ZodString;
876
- label: z.ZodString;
877
- url: z.ZodString;
878
- description: z.ZodOptional<z.ZodString>;
879
- status: z.ZodOptional<z.ZodEnum<{
880
- closed: "closed";
881
- draft: "draft";
882
- merged: "merged";
883
- open: "open";
884
- warning: "warning";
885
- }>>;
886
- }, z.core.$strict>, z.ZodObject<{
887
- kind: z.ZodLiteral<"object">;
888
- key: z.ZodString;
889
- label: z.ZodString;
890
- objectType: z.ZodEnum<{
891
- automation: "automation";
892
- calendar_event: "calendar_event";
893
- code_change: "code_change";
894
- conversation: "conversation";
895
- deployment: "deployment";
896
- item: "item";
897
- message: "message";
898
- person: "person";
899
- task: "task";
900
- }>;
901
- title: z.ZodString;
902
- url: z.ZodNullable<z.ZodURL>;
903
- description: z.ZodOptional<z.ZodString>;
904
- status: z.ZodOptional<z.ZodString>;
905
- trigger: z.ZodOptional<z.ZodString>;
906
- warning: z.ZodOptional<z.ZodString>;
907
- displayType: z.ZodOptional<z.ZodString>;
908
- sourceUpdatedAt: z.ZodOptional<z.ZodISODateTime>;
909
- facts: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
910
- type: z.ZodLiteral<"code_change">;
911
- author: z.ZodOptional<z.ZodString>;
912
- sourceBranch: z.ZodOptional<z.ZodString>;
913
- targetBranch: z.ZodOptional<z.ZodString>;
914
- reviewers: z.ZodOptional<z.ZodArray<z.ZodString>>;
915
- review: z.ZodOptional<z.ZodEnum<{
916
- approved: "approved";
917
- changes_requested: "changes_requested";
918
- required: "required";
919
- }>>;
920
- checks: z.ZodOptional<z.ZodObject<{
921
- passed: z.ZodNumber;
922
- failed: z.ZodNumber;
923
- pending: z.ZodNumber;
932
+ /** Runtime schema for plugin-issued header mutations. */
933
+ export declare const pluginCredentialHeaderTransformSchema: z.ZodObject<{
934
+ domain: z.ZodString;
935
+ headers: z.ZodRecord<z.ZodString, z.ZodString>;
936
+ }, z.core.$strict>;
937
+ /** Runtime schema for a short-lived plugin-issued credential lease. */
938
+ export declare const pluginCredentialLeaseSchema: z.ZodObject<{
939
+ account: z.ZodOptional<z.ZodObject<{
940
+ displayName: z.ZodOptional<z.ZodString>;
941
+ handle: z.ZodOptional<z.ZodString>;
942
+ id: z.ZodString;
943
+ label: z.ZodOptional<z.ZodString>;
944
+ url: z.ZodOptional<z.ZodString>;
945
+ verifiedEmails: z.ZodOptional<z.ZodArray<z.ZodString>>;
946
+ }, z.core.$strict>>;
947
+ authorization: z.ZodOptional<z.ZodObject<{
948
+ provider: z.ZodString;
949
+ scope: z.ZodOptional<z.ZodString>;
950
+ type: z.ZodLiteral<"oauth">;
951
+ }, z.core.$strict>>;
952
+ expiresAt: z.ZodString;
953
+ headerTransforms: z.ZodArray<z.ZodObject<{
954
+ domain: z.ZodString;
955
+ headers: z.ZodRecord<z.ZodString, z.ZodString>;
956
+ }, z.core.$strict>>;
957
+ }, z.core.$strict>;
958
+ /** Runtime schema for the result returned by a plugin credential hook. */
959
+ export declare const pluginCredentialResultSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
960
+ lease: z.ZodObject<{
961
+ account: z.ZodOptional<z.ZodObject<{
962
+ displayName: z.ZodOptional<z.ZodString>;
963
+ handle: z.ZodOptional<z.ZodString>;
964
+ id: z.ZodString;
965
+ label: z.ZodOptional<z.ZodString>;
966
+ url: z.ZodOptional<z.ZodString>;
967
+ verifiedEmails: z.ZodOptional<z.ZodArray<z.ZodString>>;
924
968
  }, z.core.$strict>>;
925
- mergeable: z.ZodOptional<z.ZodBoolean>;
926
- changedFiles: z.ZodOptional<z.ZodNumber>;
927
- additions: z.ZodOptional<z.ZodNumber>;
928
- deletions: z.ZodOptional<z.ZodNumber>;
929
- previewImageUrls: z.ZodOptional<z.ZodArray<z.ZodURL>>;
930
- }, z.core.$strict>, z.ZodObject<{
931
- type: z.ZodLiteral<"task">;
932
- assignees: z.ZodOptional<z.ZodArray<z.ZodString>>;
933
- priority: z.ZodOptional<z.ZodString>;
934
- project: z.ZodOptional<z.ZodString>;
935
- cycle: z.ZodOptional<z.ZodString>;
936
- dueDate: z.ZodOptional<z.ZodISODate>;
937
- labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
938
- }, z.core.$strict>, z.ZodObject<{
939
- type: z.ZodLiteral<"deployment">;
940
- project: z.ZodOptional<z.ZodString>;
941
- environment: z.ZodOptional<z.ZodString>;
942
- revision: z.ZodOptional<z.ZodString>;
943
- branch: z.ZodOptional<z.ZodString>;
944
- }, z.core.$strict>, z.ZodObject<{
945
- type: z.ZodLiteral<"calendar_event">;
946
- when: z.ZodOptional<z.ZodString>;
947
- attendees: z.ZodOptional<z.ZodArray<z.ZodString>>;
948
- }, z.core.$strict>, z.ZodObject<{
949
- type: z.ZodLiteral<"conversation">;
950
- participants: z.ZodOptional<z.ZodArray<z.ZodString>>;
951
- lastActivityAt: z.ZodOptional<z.ZodISODateTime>;
952
- }, z.core.$strict>, z.ZodObject<{
953
- type: z.ZodLiteral<"message">;
954
- channel: z.ZodOptional<z.ZodString>;
955
- author: z.ZodOptional<z.ZodString>;
956
- sentAt: z.ZodOptional<z.ZodISODateTime>;
957
- }, z.core.$strict>, z.ZodObject<{
958
- type: z.ZodLiteral<"person">;
959
- email: z.ZodOptional<z.ZodString>;
960
- slackHandle: z.ZodOptional<z.ZodString>;
961
- githubHandle: z.ZodOptional<z.ZodString>;
962
- avatarUrl: z.ZodOptional<z.ZodString>;
963
- }, z.core.$strict>], "type">>;
964
- }, z.core.$strict>], "kind">;
965
- export type ConversationAnnotationInput = z.output<typeof conversationAnnotationInputSchema>;
966
- export type ConversationAnnotation = ConversationAnnotationInput & {
967
- plugin: string;
968
- createdAt: string;
969
- updatedAt: string;
969
+ authorization: z.ZodOptional<z.ZodObject<{
970
+ provider: z.ZodString;
971
+ scope: z.ZodOptional<z.ZodString>;
972
+ type: z.ZodLiteral<"oauth">;
973
+ }, z.core.$strict>>;
974
+ expiresAt: z.ZodString;
975
+ headerTransforms: z.ZodArray<z.ZodObject<{
976
+ domain: z.ZodString;
977
+ headers: z.ZodRecord<z.ZodString, z.ZodString>;
978
+ }, z.core.$strict>>;
979
+ }, z.core.$strict>;
980
+ type: z.ZodLiteral<"lease">;
981
+ }, z.core.$strict>, z.ZodObject<{
982
+ authorization: z.ZodOptional<z.ZodObject<{
983
+ provider: z.ZodString;
984
+ scope: z.ZodOptional<z.ZodString>;
985
+ type: z.ZodLiteral<"oauth">;
986
+ }, z.core.$strict>>;
987
+ message: z.ZodString;
988
+ type: z.ZodLiteral<"needed">;
989
+ }, z.core.$strict>, z.ZodObject<{
990
+ message: z.ZodString;
991
+ type: z.ZodLiteral<"unavailable">;
992
+ }, z.core.$strict>], "type">;
993
+ export type PluginCredentialSubject = z.output<typeof pluginCredentialSubjectSchema>;
994
+ export type PluginGrantAccess = z.output<typeof pluginGrantAccessSchema>;
995
+ /** Provider authorization Junior can start when a plugin-owned grant is missing. */
996
+ export type PluginAuthorization = z.output<typeof pluginAuthorizationSchema>;
997
+ /** Interrupt sandbox egress so Junior can start provider authorization. */
998
+ export declare class EgressAuthRequired extends Error {
999
+ authorization?: PluginAuthorization;
1000
+ constructor(message: string, options?: {
1001
+ authorization?: PluginAuthorization;
1002
+ cause?: unknown;
1003
+ });
1004
+ }
1005
+ /** Deny provider egress before Junior issues credentials for a disallowed operation. */
1006
+ export declare class EgressPolicyDenied extends Error {
1007
+ /** Provider facts for the policy denial event. */
1008
+ readonly auditAttributes?: PluginAuditAttributes;
1009
+ constructor(message: string, options?: {
1010
+ auditAttributes?: PluginAuditAttributes;
1011
+ cause?: unknown;
1012
+ });
1013
+ }
1014
+ /** Provider facts for egress audit events. */
1015
+ export type PluginAuditAttributes = z.output<typeof pluginAuditAttributesSchema>;
1016
+ /** Provider account identity resolved by a plugin OAuth hook. */
1017
+ export type PluginProviderAccount = z.output<typeof pluginProviderAccountSchema>;
1018
+ /** Plugin-defined grant required before Junior can forward one outbound request. */
1019
+ export type PluginGrant = z.output<typeof pluginGrantSchema>;
1020
+ /** One ref update command in a Git push. */
1021
+ export interface PluginGitRefUpdate {
1022
+ /** True when the push deletes the ref: its new object id is all zeros. */
1023
+ deletes: boolean;
1024
+ /** Full ref name, such as `refs/heads/main`. */
1025
+ ref: string;
1026
+ }
1027
+ /** Why the host could not read the ref updates of a Git push. */
1028
+ export type PluginGitPushUnreadableReason = "gzip" | "malformed" | "signed" | "unterminated";
1029
+ /**
1030
+ * Ref updates of a Git smart HTTP push (`git-receive-pack`), which the host
1031
+ * reads from the body before the pack data. An `unreadable` push changes
1032
+ * refs that the host cannot name.
1033
+ */
1034
+ export type PluginGitPush = {
1035
+ kind: "commands";
1036
+ updates: PluginGitRefUpdate[];
1037
+ } | {
1038
+ kind: "unreadable";
1039
+ reason: PluginGitPushUnreadableReason;
970
1040
  };
971
- export interface PluginAnnotations {
972
- upsert(annotation: ConversationAnnotationInput): Promise<void>;
973
- remove(kind: ConversationAnnotationInput["kind"], key: string): Promise<void>;
974
- list(): Promise<ConversationAnnotation[]>;
1041
+ /** One field that a GraphQL operation selects. */
1042
+ export interface PluginGraphqlField {
1043
+ /** Names of the arguments that the field passes. */
1044
+ arguments: string[];
1045
+ /** Schema field name. An alias does not replace it. */
1046
+ name: string;
975
1047
  }
976
- export interface PluginConversationAnnotations {
977
- forConversation(conversationId: string): PluginAnnotations;
1048
+ /** The GraphQL operation that one request runs. */
1049
+ export interface PluginGraphqlOperation {
1050
+ /**
1051
+ * Each distinct field that the operation selects at any depth, also through
1052
+ * fragments.
1053
+ */
1054
+ fields: PluginGraphqlField[];
1055
+ name?: string;
1056
+ /**
1057
+ * Field names at the operation root, also through fragments. There is one
1058
+ * entry for each field selection, so an aliased repeat shows twice.
1059
+ */
1060
+ rootFields: string[];
1061
+ type: "mutation" | "query" | "subscription";
978
1062
  }
979
- export declare const conversationSidebarIconSchema: z.ZodEnum<{
980
- "circle-dashed": "circle-dashed";
981
- "circle-dot": "circle-dot";
982
- "circle-x": "circle-x";
983
- "git-merge": "git-merge";
984
- "git-pull-request": "git-pull-request";
985
- "triangle-alert": "triangle-alert";
986
- }>;
987
- export declare const conversationSidebarAnnotationSchema: z.ZodObject<{
988
- icon: z.ZodOptional<z.ZodEnum<{
989
- "circle-dashed": "circle-dashed";
990
- "circle-dot": "circle-dot";
991
- "circle-x": "circle-x";
992
- "git-merge": "git-merge";
993
- "git-pull-request": "git-pull-request";
994
- "triangle-alert": "triangle-alert";
995
- }>>;
1063
+ /**
1064
+ * Why the host could not read the operation of a GraphQL request:
1065
+ *
1066
+ * - `document`: the query does not parse, or it spreads a fragment that it
1067
+ * does not define.
1068
+ * - `gzip`: the body is compressed.
1069
+ * - `json`: the body is not a JSON object or a JSON array of objects.
1070
+ * - `operation`: `operationName` names no operation, or the document has more
1071
+ * than one operation and no `operationName`.
1072
+ * - `query`: the body has no `query` string, such as a persisted query hash.
1073
+ * - `too-large`: the body is larger than the host reads before it issues
1074
+ * credentials.
1075
+ */
1076
+ export type PluginGraphqlUnreadableReason = "document" | "gzip" | "json" | "operation" | "query" | "too-large";
1077
+ /**
1078
+ * The operations of a GraphQL POST, which the host reads from the JSON body.
1079
+ * A `batch` is a JSON array of requests. An `unreadable` request can run any
1080
+ * operation, mutations included.
1081
+ */
1082
+ export type PluginGraphqlRequest = {
1083
+ kind: "batch";
1084
+ operations: PluginGraphqlOperation[];
1085
+ } | {
1086
+ kind: "operation";
1087
+ operation: PluginGraphqlOperation;
1088
+ } | {
1089
+ kind: "unreadable";
1090
+ reason: PluginGraphqlUnreadableReason;
1091
+ };
1092
+ /** Request details available while selecting the grant for sandbox egress. */
1093
+ export interface PluginEgressRequest {
1094
+ /**
1095
+ * Capped request body text when the host exposes it for provider-specific
1096
+ * grant classification.
1097
+ */
1098
+ bodyText?: string;
1099
+ /** Set for every Git `git-receive-pack` POST. */
1100
+ gitPush?: PluginGitPush;
1101
+ /** Set for every POST to a URL path that ends in `/graphql`. */
1102
+ graphql?: PluginGraphqlRequest;
1103
+ method: string;
1104
+ /** Plugin-declared operation this request performs, used for grant classification and diagnostics. */
1105
+ operation?: string;
1106
+ url: string;
1107
+ }
1108
+ export interface EgressHookContext extends PluginContext {
1109
+ request: PluginEgressRequest;
1110
+ }
1111
+ export interface PluginEgressResponse {
1112
+ /** Snapshot of upstream response headers; mutations do not affect pass-through. */
1113
+ headers: Headers;
1114
+ readText(maxBytes: number): Promise<string | undefined>;
1115
+ status: number;
1116
+ }
1117
+ export interface EgressResponseHookContext extends PluginContext {
1118
+ grant: PluginGrant;
1119
+ permissionDenied(message: string): void;
1120
+ request: Omit<PluginEgressRequest, "bodyText" | "gitPush" | "graphql">;
1121
+ response: PluginEgressResponse;
1122
+ }
1123
+ /** Header mutations a plugin-issued credential lease may apply to owned domains. */
1124
+ export type PluginCredentialHeaderTransform = z.output<typeof pluginCredentialHeaderTransformSchema>;
1125
+ /** Short-lived credential headers issued by a plugin for a selected grant. */
1126
+ export type PluginCredentialLease = z.output<typeof pluginCredentialLeaseSchema>;
1127
+ export type PluginCredentialResult = z.output<typeof pluginCredentialResultSchema>;
1128
+ export type PluginCredentialActor = {
1129
+ platform: "system";
1130
+ name: string;
1131
+ } | {
1132
+ type: "user";
1133
+ userId: string;
1134
+ };
1135
+ export interface PluginResolvedCredentialUser {
1136
+ type: "user";
1137
+ userId: string;
1138
+ }
1139
+ export type PluginStoredTokens = z.output<typeof pluginStoredTokensSchema>;
1140
+ export interface PluginUserTokenSlot {
1141
+ get(): Promise<PluginStoredTokens | undefined>;
1142
+ set(tokens: PluginStoredTokens): Promise<void>;
1143
+ /** Run token refresh work after the host has serialized this user/provider slot, or throw after a bounded wait. */
1144
+ withRefresh<T>(callback: () => Promise<T>): Promise<T>;
1145
+ userId: string;
1146
+ }
1147
+ export interface PluginTokenStore {
1148
+ credentialSubject?: PluginUserTokenSlot;
1149
+ currentUser?: PluginUserTokenSlot;
1150
+ }
1151
+ export interface ResolveOAuthAccountHookContext extends PluginContext {
1152
+ tokens: PluginStoredTokens;
1153
+ /**
1154
+ * Parsed JSON body of the provider token response. Some providers return
1155
+ * the authorized account in this body.
1156
+ */
1157
+ tokenResponse: Record<string, unknown>;
1158
+ }
1159
+ export interface IssueCredentialHookContext extends PluginContext {
1160
+ actor: PluginCredentialActor;
1161
+ credentialSubject?: PluginResolvedCredentialUser;
1162
+ grant: PluginGrant;
1163
+ tokens: PluginTokenStore;
1164
+ }
1165
+ /**
1166
+ * Link an object to a Conversation when the owner has no typed object preview.
1167
+ * Keep a stable key, compact label, source URL, and optional short context or
1168
+ * status. Do not fetch a full object merely to save a link. Rich preview intent
1169
+ * belongs to objectAnnotationSchema, not a second set of resource-link fields.
1170
+ */
1171
+ export declare const resourceLinkAnnotationSchema: z.ZodObject<{
1172
+ kind: z.ZodLiteral<"resource_link">;
996
1173
  objectType: z.ZodOptional<z.ZodEnum<{
997
1174
  automation: "automation";
998
1175
  calendar_event: "calendar_event";
999
1176
  code_change: "code_change";
1000
1177
  conversation: "conversation";
1001
1178
  deployment: "deployment";
1179
+ document: "document";
1002
1180
  item: "item";
1003
1181
  message: "message";
1004
1182
  person: "person";
1005
1183
  task: "task";
1184
+ web_page: "web_page";
1006
1185
  }>>;
1007
- status: z.ZodOptional<z.ZodString>;
1008
1186
  key: z.ZodString;
1009
1187
  label: z.ZodString;
1188
+ url: z.ZodString;
1189
+ description: z.ZodOptional<z.ZodString>;
1190
+ status: z.ZodOptional<z.ZodEnum<{
1191
+ closed: "closed";
1192
+ draft: "draft";
1193
+ merged: "merged";
1194
+ open: "open";
1195
+ warning: "warning";
1196
+ }>>;
1010
1197
  }, z.core.$strict>;
1011
- export type ConversationSidebarAnnotation = z.output<typeof conversationSidebarAnnotationSchema>;
1012
- export interface ConversationSidebarHookContext extends PluginContext {
1013
- /** Stored annotations owned by this plugin, keyed by candidate conversation. */
1014
- annotationsByConversationId: Record<string, ConversationAnnotation[]>;
1015
- conversationIds: string[];
1016
- }
1017
- export interface ConversationSidebarResult {
1018
- /** Sidebar annotations in display order. Put the newest annotation first. */
1019
- annotationsByConversationId: Record<string, ConversationSidebarAnnotation[]>;
1020
- }
1021
- export declare const codeChangeStateSchema: z.ZodEnum<{
1022
- closed: "closed";
1023
- merged: "merged";
1024
- open: "open";
1025
- }>;
1026
- export type CodeChangeState = z.output<typeof codeChangeStateSchema>;
1027
- export declare const codeChangeInputSchema: z.ZodObject<{
1028
- closedAt: z.ZodOptional<z.ZodDate>;
1029
- conversationIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
1030
- draft: z.ZodOptional<z.ZodBoolean>;
1031
- mergedAt: z.ZodOptional<z.ZodDate>;
1032
- number: z.ZodNumber;
1033
- openedAt: z.ZodDate;
1034
- providerId: z.ZodString;
1035
- repository: z.ZodObject<{
1036
- name: z.ZodString;
1037
- providerId: z.ZodString;
1038
- url: z.ZodOptional<z.ZodString>;
1039
- }, z.core.$strict>;
1040
- state: z.ZodEnum<{
1198
+ /** Core-known annotation shapes that plugins may attach to a conversation. */
1199
+ export declare const conversationAnnotationInputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1200
+ kind: z.ZodLiteral<"resource_link">;
1201
+ objectType: z.ZodOptional<z.ZodEnum<{
1202
+ automation: "automation";
1203
+ calendar_event: "calendar_event";
1204
+ code_change: "code_change";
1205
+ conversation: "conversation";
1206
+ deployment: "deployment";
1207
+ document: "document";
1208
+ item: "item";
1209
+ message: "message";
1210
+ person: "person";
1211
+ task: "task";
1212
+ web_page: "web_page";
1213
+ }>>;
1214
+ key: z.ZodString;
1215
+ label: z.ZodString;
1216
+ url: z.ZodString;
1217
+ description: z.ZodOptional<z.ZodString>;
1218
+ status: z.ZodOptional<z.ZodEnum<{
1041
1219
  closed: "closed";
1220
+ draft: "draft";
1042
1221
  merged: "merged";
1043
1222
  open: "open";
1223
+ warning: "warning";
1224
+ }>>;
1225
+ }, z.core.$strict>, z.ZodObject<{
1226
+ kind: z.ZodLiteral<"object">;
1227
+ key: z.ZodString;
1228
+ label: z.ZodString;
1229
+ objectType: z.ZodEnum<{
1230
+ automation: "automation";
1231
+ calendar_event: "calendar_event";
1232
+ code_change: "code_change";
1233
+ conversation: "conversation";
1234
+ deployment: "deployment";
1235
+ document: "document";
1236
+ item: "item";
1237
+ message: "message";
1238
+ person: "person";
1239
+ task: "task";
1240
+ web_page: "web_page";
1044
1241
  }>;
1045
- title: z.ZodOptional<z.ZodString>;
1046
- updatedAt: z.ZodDate;
1047
- url: z.ZodOptional<z.ZodString>;
1048
- }, z.core.$strict>;
1049
- export type CodeChangeInput = z.input<typeof codeChangeInputSchema>;
1050
- /** Write code changes from a plugin to Junior's code records. */
1051
- export interface CodeChangePublisher {
1052
- associateConversations(input: {
1053
- conversationIds: string[];
1054
- providerId: string;
1055
- }): Promise<void>;
1056
- record(input: CodeChangeInput): Promise<void>;
1057
- /**
1058
- * Record a push, review, or comment by a person on a code change. Junior
1059
- * ignores activity on code changes that it did not record.
1060
- */
1061
- recordActivity(input: {
1062
- at: Date;
1063
- number: number;
1064
- repositoryProviderId: string;
1065
- }): Promise<void>;
1242
+ title: z.ZodString;
1243
+ url: z.ZodNullable<z.ZodURL>;
1244
+ description: z.ZodOptional<z.ZodString>;
1245
+ status: z.ZodOptional<z.ZodString>;
1246
+ trigger: z.ZodOptional<z.ZodString>;
1247
+ warning: z.ZodOptional<z.ZodString>;
1248
+ displayType: z.ZodOptional<z.ZodString>;
1249
+ sourceUpdatedAt: z.ZodOptional<z.ZodISODateTime>;
1250
+ facts: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
1251
+ type: z.ZodLiteral<"code_change">;
1252
+ summary: z.ZodOptional<z.ZodString>;
1253
+ author: z.ZodOptional<z.ZodString>;
1254
+ sourceBranch: z.ZodOptional<z.ZodString>;
1255
+ targetBranch: z.ZodOptional<z.ZodString>;
1256
+ reviewers: z.ZodOptional<z.ZodArray<z.ZodString>>;
1257
+ review: z.ZodOptional<z.ZodEnum<{
1258
+ approved: "approved";
1259
+ changes_requested: "changes_requested";
1260
+ required: "required";
1261
+ }>>;
1262
+ checks: z.ZodOptional<z.ZodObject<{
1263
+ passed: z.ZodNumber;
1264
+ failed: z.ZodNumber;
1265
+ pending: z.ZodNumber;
1266
+ }, z.core.$strict>>;
1267
+ mergeable: z.ZodOptional<z.ZodBoolean>;
1268
+ changedFiles: z.ZodOptional<z.ZodNumber>;
1269
+ additions: z.ZodOptional<z.ZodNumber>;
1270
+ deletions: z.ZodOptional<z.ZodNumber>;
1271
+ previewImageUrls: z.ZodOptional<z.ZodArray<z.ZodURL>>;
1272
+ }, z.core.$strict>, z.ZodObject<{
1273
+ type: z.ZodLiteral<"task">;
1274
+ summary: z.ZodOptional<z.ZodString>;
1275
+ assignees: z.ZodOptional<z.ZodArray<z.ZodString>>;
1276
+ priority: z.ZodOptional<z.ZodString>;
1277
+ project: z.ZodOptional<z.ZodString>;
1278
+ cycle: z.ZodOptional<z.ZodString>;
1279
+ dueDate: z.ZodOptional<z.ZodISODate>;
1280
+ labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
1281
+ }, z.core.$strict>, z.ZodObject<{
1282
+ type: z.ZodLiteral<"deployment">;
1283
+ summary: z.ZodOptional<z.ZodString>;
1284
+ project: z.ZodOptional<z.ZodString>;
1285
+ environment: z.ZodOptional<z.ZodString>;
1286
+ revision: z.ZodOptional<z.ZodString>;
1287
+ branch: z.ZodOptional<z.ZodString>;
1288
+ }, z.core.$strict>, z.ZodObject<{
1289
+ type: z.ZodLiteral<"calendar_event">;
1290
+ summary: z.ZodOptional<z.ZodString>;
1291
+ when: z.ZodOptional<z.ZodString>;
1292
+ attendees: z.ZodOptional<z.ZodArray<z.ZodString>>;
1293
+ }, z.core.$strict>, z.ZodObject<{
1294
+ type: z.ZodLiteral<"conversation">;
1295
+ summary: z.ZodOptional<z.ZodString>;
1296
+ participants: z.ZodOptional<z.ZodArray<z.ZodString>>;
1297
+ lastActivityAt: z.ZodOptional<z.ZodISODateTime>;
1298
+ }, z.core.$strict>, z.ZodObject<{
1299
+ type: z.ZodLiteral<"document">;
1300
+ summary: z.ZodOptional<z.ZodString>;
1301
+ owner: z.ZodOptional<z.ZodString>;
1302
+ modifiedAt: z.ZodOptional<z.ZodISODateTime>;
1303
+ }, z.core.$strict>, z.ZodObject<{
1304
+ type: z.ZodLiteral<"message">;
1305
+ summary: z.ZodOptional<z.ZodString>;
1306
+ channel: z.ZodOptional<z.ZodString>;
1307
+ author: z.ZodOptional<z.ZodString>;
1308
+ sentAt: z.ZodOptional<z.ZodISODateTime>;
1309
+ }, z.core.$strict>, z.ZodObject<{
1310
+ type: z.ZodLiteral<"web_page">;
1311
+ summary: z.ZodOptional<z.ZodString>;
1312
+ siteName: z.ZodOptional<z.ZodString>;
1313
+ author: z.ZodOptional<z.ZodString>;
1314
+ thumbnailUrl: z.ZodOptional<z.ZodString>;
1315
+ }, z.core.$strict>, z.ZodObject<{
1316
+ type: z.ZodLiteral<"person">;
1317
+ summary: z.ZodOptional<z.ZodString>;
1318
+ email: z.ZodOptional<z.ZodString>;
1319
+ slackHandle: z.ZodOptional<z.ZodString>;
1320
+ githubHandle: z.ZodOptional<z.ZodString>;
1321
+ avatarUrl: z.ZodOptional<z.ZodString>;
1322
+ }, z.core.$strict>], "type">>;
1323
+ }, z.core.$strict>], "kind">;
1324
+ export type ConversationAnnotationInput = z.output<typeof conversationAnnotationInputSchema>;
1325
+ export type ConversationAnnotation = ConversationAnnotationInput & {
1326
+ plugin: string;
1327
+ createdAt: string;
1328
+ updatedAt: string;
1329
+ };
1330
+ export interface PluginAnnotations {
1331
+ upsert(annotation: ConversationAnnotationInput): Promise<void>;
1332
+ remove(kind: ConversationAnnotationInput["kind"], key: string): Promise<void>;
1333
+ list(): Promise<ConversationAnnotation[]>;
1066
1334
  }
1067
- export declare const conversationEventIconSchema: z.ZodEnum<{
1068
- activity: "activity";
1069
- brain: "brain";
1070
- calendar: "calendar";
1071
- check: "check";
1072
- database: "database";
1073
- info: "info";
1074
- key: "key";
1075
- link: "link";
1076
- sparkles: "sparkles";
1077
- warning: "warning";
1335
+ export interface PluginConversationAnnotations {
1336
+ forConversation(conversationId: string): PluginAnnotations;
1337
+ }
1338
+ export declare const conversationSidebarIconSchema: z.ZodEnum<{
1339
+ "circle-dashed": "circle-dashed";
1340
+ "circle-dot": "circle-dot";
1341
+ "circle-x": "circle-x";
1342
+ "git-merge": "git-merge";
1343
+ "git-pull-request": "git-pull-request";
1344
+ "triangle-alert": "triangle-alert";
1078
1345
  }>;
1079
- /** Safe, core-rendered presentation for one plugin conversation event. */
1080
- export declare const conversationEventPresentationSchema: z.ZodObject<{
1081
- details: z.ZodOptional<z.ZodArray<z.ZodObject<{
1082
- content: z.ZodOptional<z.ZodString>;
1083
- description: z.ZodOptional<z.ZodString>;
1084
- metadata: z.ZodOptional<z.ZodArray<z.ZodString>>;
1085
- title: z.ZodString;
1086
- }, z.core.$strict>>>;
1346
+ export declare const conversationSidebarAnnotationSchema: z.ZodObject<{
1087
1347
  icon: z.ZodOptional<z.ZodEnum<{
1088
- activity: "activity";
1089
- brain: "brain";
1090
- calendar: "calendar";
1091
- check: "check";
1092
- database: "database";
1093
- info: "info";
1094
- key: "key";
1095
- link: "link";
1096
- sparkles: "sparkles";
1097
- warning: "warning";
1348
+ "circle-dashed": "circle-dashed";
1349
+ "circle-dot": "circle-dot";
1350
+ "circle-x": "circle-x";
1351
+ "git-merge": "git-merge";
1352
+ "git-pull-request": "git-pull-request";
1353
+ "triangle-alert": "triangle-alert";
1098
1354
  }>>;
1099
- preview: z.ZodOptional<z.ZodString>;
1100
- title: z.ZodString;
1355
+ objectType: z.ZodOptional<z.ZodEnum<{
1356
+ automation: "automation";
1357
+ calendar_event: "calendar_event";
1358
+ code_change: "code_change";
1359
+ conversation: "conversation";
1360
+ deployment: "deployment";
1361
+ document: "document";
1362
+ item: "item";
1363
+ message: "message";
1364
+ person: "person";
1365
+ task: "task";
1366
+ web_page: "web_page";
1367
+ }>>;
1368
+ status: z.ZodOptional<z.ZodString>;
1369
+ key: z.ZodString;
1370
+ label: z.ZodString;
1101
1371
  }, z.core.$strict>;
1102
- export type ConversationEventPresentation = z.output<typeof conversationEventPresentationSchema>;
1103
- /** One validated plugin event value waiting for conversation-bound emission. */
1104
- export interface PluginConversationEventValue {
1105
- readonly data: Record<string, unknown>;
1106
- readonly definition: PluginConversationEventDefinition;
1107
- }
1108
- /** Registered schema and optional transcript presentation for one event version. */
1109
- export interface PluginConversationEventDefinition {
1110
- readonly eventName: string;
1111
- readonly version: number;
1112
- parse(data: unknown): Record<string, unknown>;
1113
- renderEvent(data: Record<string, unknown>): ConversationEventPresentation | undefined;
1114
- }
1115
- /** Typed factory returned while authoring one plugin conversation event. */
1116
- export interface DefinedConversationEvent<TInput> extends PluginConversationEventDefinition {
1117
- (data: TInput): PluginConversationEventValue;
1118
- }
1119
- /** Define one typed, versioned plugin-owned conversation event. */
1120
- export declare function defineConversationEvent<TSchema extends z.ZodType<Record<string, unknown>>>(definition: {
1121
- name: string;
1122
- version: number;
1123
- schema: TSchema;
1124
- renderEvent(event: z.output<TSchema>): z.input<typeof conversationEventPresentationSchema> | undefined;
1125
- }): DefinedConversationEvent<z.input<TSchema>>;
1126
- /** Conversation-bound event writer supplied by Junior core. */
1127
- export interface PluginConversationEvents {
1128
- emit(event: PluginConversationEventValue): Promise<void>;
1129
- }
1130
- export interface PluginConversationEventCostDay {
1131
- costUsd: number;
1132
- date: string;
1133
- events: number;
1372
+ export type ConversationSidebarAnnotation = z.output<typeof conversationSidebarAnnotationSchema>;
1373
+ export interface ConversationSidebarHookContext extends PluginContext {
1374
+ /** Stored annotations owned by this plugin, keyed by candidate conversation. */
1375
+ annotationsByConversationId: Record<string, ConversationAnnotation[]>;
1376
+ conversationIds: string[];
1134
1377
  }
1135
- export interface PluginConversationEventRecord {
1136
- content: Record<string, unknown>;
1137
- createdAt: string;
1138
- /** Position in the Conversation's events. The transcript opens there. */
1139
- seq: number;
1140
- /** Turn that emitted the event. Events from outside a Turn have none. */
1141
- turnId?: string;
1142
- version: number;
1143
- }
1144
- /** Read events owned by the current plugin namespace after Conversation access checks. */
1145
- export interface PluginConversationEventReader {
1146
- list(input: {
1147
- conversationId: string;
1148
- eventName: string;
1149
- viewer: User;
1150
- }): Promise<PluginConversationEventRecord[] | undefined>;
1151
- }
1152
- /**
1153
- * Events that Junior writes in a plugin's namespace for the cost of each
1154
- * priced `model`, `decider`, `embedder`, or `reranker` call in a
1155
- * Conversation, by the context that made the call. Junior counts them in
1156
- * Conversation cost, so plugin events must not repeat that cost. A plugin
1157
- * cannot register these names. It can read their costs through
1158
- * `PluginConversationEventStats`.
1159
- */
1160
- export declare const pluginModelCostEventNames: {
1161
- readonly afterToolExecute: "after_tool_execute_model_called";
1162
- readonly task: "task_model_called";
1163
- readonly tool: "tool_model_called";
1164
- readonly userPrompt: "user_prompt_model_called";
1165
- };
1166
- /** Whether an event name is one of `pluginModelCostEventNames`. */
1167
- export declare function isPluginModelCostEventName(eventName: string): boolean;
1168
- /**
1169
- * Read aggregate costs for events owned by the current plugin namespace:
1170
- * registered events and `pluginModelCostEventNames`.
1171
- */
1172
- export interface PluginConversationEventStats {
1173
- costsByDay(input: {
1174
- days: 7 | 30 | 90;
1175
- eventName: string;
1176
- }): Promise<PluginConversationEventCostDay[]>;
1177
- costsByHour(input: {
1178
- eventName: string;
1179
- hours?: number;
1180
- }): Promise<PluginConversationEventCostDay[]>;
1181
- }
1182
- export interface PluginState {
1183
- delete(key: string): Promise<void>;
1184
- get<T = unknown>(key: string): Promise<T | undefined>;
1185
- set(key: string, value: unknown, ttlMs?: number): Promise<void>;
1186
- setIfNotExists(key: string, value: unknown, ttlMs?: number): Promise<boolean>;
1187
- withLock<T>(key: string, ttlMs: number, callback: () => Promise<T>): Promise<T>;
1188
- }
1189
- export interface PluginReadState {
1190
- get<T = unknown>(key: string): Promise<T | undefined>;
1191
- }
1192
- export declare const promptMessageSchema: z.ZodObject<{
1193
- text: z.ZodString;
1194
- }, z.core.$strict>;
1195
- /** Small plugin-owned prompt text block rendered by Junior core. */
1196
- type PromptMessage = z.output<typeof promptMessageSchema>;
1197
- export declare const promptContextSchema: z.ZodObject<{
1198
- kind: z.ZodString;
1199
- version: z.ZodNumber;
1200
- content: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1201
- }, z.core.$strict>;
1202
- /** Structured plugin context retained alongside its model-visible rendering. */
1203
- type PromptContext = z.output<typeof promptContextSchema>;
1204
- /** Runtime contribution produced from one validated plugin context value. */
1205
- interface PromptContextContribution {
1206
- context: PromptContext;
1207
- renderPrompt(): string;
1208
- }
1209
- /** Define one typed, versioned plugin context contribution. */
1210
- export declare function definePromptContext<TSchema extends z.ZodType<Record<string, unknown>>>(definition: {
1211
- kind: string;
1212
- version: number;
1213
- schema: TSchema;
1214
- renderPrompt(content: z.output<TSchema>): string;
1215
- }): (content: z.input<TSchema>) => PromptContextContribution;
1216
- /** One request-scoped plugin contribution to the model-visible user prompt. */
1217
- type UserPromptContribution = PromptMessage | PromptContextContribution;
1218
- /** Stable platform context for plugin system prompt guidance. */
1219
- type SystemPromptContext = Pick<PluginContext, "db" | "log" | "plugin"> & {
1220
- platform: Platform;
1221
- };
1222
- /** Runtime facts available while building plugin user prompt context. */
1223
- type UserPromptContext = Pick<PluginContext, "db" | "log" | "plugin"> & {
1224
- conversationId?: string;
1225
- destination: Destination;
1226
- embedder: PluginEmbedder;
1227
- /** Conversation-bound event writer when the prompt belongs to a durable turn. */
1228
- events?: PluginConversationEvents;
1229
- model: PluginModel;
1230
- /** Host reranker bound to the configured reranking model. */
1231
- reranker: PluginReranker;
1232
- /**
1233
- * Record numeric diagnostics on the host span for this hook. Keys must
1234
- * start with `app.<plugin name>.`; the host drops other keys and
1235
- * non-finite values.
1236
- */
1237
- setSpanAttributes(attributes: Record<string, number>): void;
1238
- /** Location associated with this Conversation. */
1239
- locationId?: string;
1240
- actor?: Actor;
1241
- source: Source;
1242
- state: PluginState;
1243
- text: string;
1244
- users: {
1245
- /** Resolve the current Actor's Identity and User. */
1246
- resolveActor(): Promise<{
1247
- identity: Identity;
1248
- user?: User;
1249
- } | undefined>;
1250
- };
1251
- };
1252
- export type DestinationVisibility = z.output<typeof destinationVisibilitySchema>;
1253
- export type DispatchOptions = z.output<typeof dispatchOptionsSchema>;
1254
- /** Compact destination-visible context explaining what produced a reply. */
1255
- export type ReplyAttribution = z.output<typeof replyAttributionSchema>;
1256
- export type TaskOutcome = z.output<typeof taskOutcomeSchema>;
1257
- export interface DispatchResult {
1258
- id: string;
1259
- status: "created" | "already_exists";
1260
- }
1261
- export interface Dispatch {
1262
- errorMessage?: string;
1263
- id: string;
1264
- resultMessageTs?: string;
1265
- status: "pending" | "running" | "awaiting_resume" | "completed" | "failed" | "blocked";
1378
+ export interface ConversationSidebarResult {
1379
+ /** Sidebar annotations in display order. Put the newest annotation first. */
1380
+ annotationsByConversationId: Record<string, ConversationSidebarAnnotation[]>;
1266
1381
  }
1267
1382
  export declare const EVENT_SUMMARY_MAX_LENGTH = 4000;
1268
1383
  export declare const EVENT_TEXT_MAX_LENGTH = 8000;
@@ -1483,10 +1598,12 @@ export declare const eventInputSchema: z.ZodObject<{
1483
1598
  code_change: "code_change";
1484
1599
  conversation: "conversation";
1485
1600
  deployment: "deployment";
1601
+ document: "document";
1486
1602
  item: "item";
1487
1603
  message: "message";
1488
1604
  person: "person";
1489
1605
  task: "task";
1606
+ web_page: "web_page";
1490
1607
  }>>;
1491
1608
  eventKey: z.ZodString;
1492
1609
  eventType: z.ZodString;
@@ -1518,10 +1635,12 @@ export declare const eventSchema: z.ZodObject<{
1518
1635
  code_change: "code_change";
1519
1636
  conversation: "conversation";
1520
1637
  deployment: "deployment";
1638
+ document: "document";
1521
1639
  item: "item";
1522
1640
  message: "message";
1523
1641
  person: "person";
1524
1642
  task: "task";
1643
+ web_page: "web_page";
1525
1644
  }>>;
1526
1645
  eventKey: z.ZodString;
1527
1646
  eventType: z.ZodString;
@@ -1572,885 +1691,269 @@ export interface EventPublisher {
1572
1691
  identifiers: string[];
1573
1692
  }): Promise<string[]>;
1574
1693
  }
1575
- type EventMatchField = EventMatchFields[string];
1576
- /** One reason a selection of events and filters cannot work. */
1577
- export interface EventTriggerProblem {
1578
- /**
1579
- * - `unknown_resource_type`: the source has no such enabled resource type.
1580
- * - `unknown_event`: the resource type has no such event.
1581
- * - `identifier_required`: a trigger with no identifier selects an event
1582
- * that cannot run for every resource.
1583
- * - `filter_required`: a trigger with no identifier selects an event whose
1584
- * reach names filters, and the trigger sets none of them.
1585
- * - `unknown_field`: the resource type has no such filter. Saved triggers
1586
- * get this after a plugin renames or removes a filter.
1587
- * - `field_not_set`: a selected event never sets the filter, so the filter
1588
- * never matches that event.
1589
- * - `invalid_value`: the filter value has the wrong type or is not allowed.
1590
- */
1591
- reason: "unknown_resource_type" | "unknown_event" | "identifier_required" | "filter_required" | "unknown_field" | "field_not_set" | "invalid_value";
1592
- /** The filter with the problem. Missing for a resource type or event problem. */
1593
- field?: string;
1594
- /** Plain words for the person or agent who changes the selection. */
1595
- message: string;
1694
+ export interface PluginState {
1695
+ delete(key: string): Promise<void>;
1696
+ get<T = unknown>(key: string): Promise<T | undefined>;
1697
+ set(key: string, value: unknown, ttlMs?: number): Promise<void>;
1698
+ setIfNotExists(key: string, value: unknown, ttlMs?: number): Promise<boolean>;
1699
+ withLock<T>(key: string, ttlMs: number, callback: () => Promise<T>): Promise<T>;
1700
+ }
1701
+ export interface PluginReadState {
1702
+ get<T = unknown>(key: string): Promise<T | undefined>;
1703
+ }
1704
+ export interface PluginEnv {
1705
+ get(key: string): string | undefined;
1706
+ set(key: string, value: string): void;
1596
1707
  }
1597
1708
  /**
1598
- * The selection to check: one resource type, its events, and its filters.
1599
- * Leave out the resource type for a trigger with no identifier. It runs for
1600
- * every resource of the source that its filters match.
1709
+ * Decide what happens to one tool call in `beforeToolExecute`.
1710
+ *
1711
+ * `redirect` and `deny` both stop the tool before it runs. Neither ends the
1712
+ * turn: the agent gets the message as the tool result.
1601
1713
  */
1602
- export interface EventTriggerSelection {
1603
- resourceType?: string;
1604
- events: readonly string[];
1605
- match?: EventMatch;
1606
- }
1607
- /** The enabled resource types of one source, and the reach of each of its events. */
1608
- export interface EventTriggerSource {
1609
- resourceTypes: readonly Pick<PluginEventType, "type" | "matchFields" | "supportedEvents">[];
1610
- events: Readonly<Record<string, {
1611
- reach: EventReach;
1612
- }>>;
1714
+ export interface PluginDecision {
1613
1715
  /**
1614
- * The filters of every resource type, for a trigger with no identifier.
1615
- * Merge them once with `anyResourceMatchFields` when the catalog is built,
1616
- * not for each check.
1716
+ * Block the call as a policy refusal. The agent is told not to retry or
1717
+ * reach the same result another way, and to explain the block.
1617
1718
  */
1618
- anyResourceFields: EventMatchFields;
1719
+ deny(reason: string): void;
1720
+ /**
1721
+ * Block the call because a different path is correct, such as another
1722
+ * tool. The message tells the agent what to do instead.
1723
+ */
1724
+ redirect(message: string): void;
1725
+ replaceInput(input: Record<string, unknown>): void;
1619
1726
  }
1620
- /** The events of a source that a trigger with no identifier can select. */
1621
- export declare function anyResourceEvents(source: EventTriggerSource): string[];
1622
- /** Return the selected events that never set one filter field. */
1623
- export declare function eventsWithoutMatchField(field: Pick<EventMatchField, "events">, events: readonly string[]): string[];
1624
1727
  /**
1625
- * Return the events and filters that a selection can use: those of its
1626
- * resource type, or with no resource type, the events whose reach is not
1627
- * `"resource"`, with the filters of every resource type. Return nothing when the source
1628
- * has no such resource type or cannot run for every resource.
1629
- */
1630
- export declare function eventTriggerChoices(source: EventTriggerSource, selection: Pick<EventTriggerSelection, "resourceType">): {
1631
- events: readonly string[];
1632
- fields: EventMatchFields;
1633
- } | undefined;
1634
- /**
1635
- * List why a selection cannot work with the resource types of one source. An
1636
- * empty list means the resource type exists, every selected event is
1637
- * supported, and every selected event can match every filter. A filter on a
1638
- * list field (`list: true`) matches when the event list includes the value.
1639
- * A selection with no resource type can use only events whose reach is not
1640
- * `"resource"`, with the filters of every resource type, and must set one of
1641
- * the filters that the reach of each selected event names.
1642
- * Set `inputKeys` for the agent, so messages name the snake_case
1643
- * `match.<key>` input.
1728
+ * Decide what the agent reads after one tool call in `afterToolExecute`.
1729
+ *
1730
+ * The tool already ran, so neither choice undoes its effects.
1644
1731
  */
1645
- export declare function eventTriggerProblems(source: EventTriggerSource, selection: EventTriggerSelection, options?: {
1646
- inputKeys?: boolean;
1647
- }): EventTriggerProblem[];
1648
- /** How people see one Event trigger. Each entry is one line of plain text. */
1649
- export interface EventTriggerDescription {
1650
- /** Each selected event in plain words, such as "pull request opened". */
1651
- events: string[];
1652
- /** Each filter in plain words. Every filter must match. */
1653
- filters: string[];
1654
- /** Why the trigger cannot work as saved. Empty when it can. */
1655
- problems: string[];
1732
+ export interface PluginToolResultDecision {
1733
+ /**
1734
+ * Reject the result as a policy refusal. The agent gets the reason instead
1735
+ * of the result, and is told not to retry. Undo the tool's effects first
1736
+ * when they must not stay.
1737
+ */
1738
+ deny(reason: string): void;
1739
+ /**
1740
+ * Add guidance after the result, such as a problem to fix in the change
1741
+ * that the tool made. The agent reads the result and the guidance.
1742
+ */
1743
+ nudge(message: string): void;
1656
1744
  }
1657
- /** Write one event type in plain words: `pull_request.opened` is "pull request opened". */
1658
- export declare function eventTypeText(eventType: string): string;
1659
- /**
1660
- * Write one filter in plain words. A list field (`list: true`) reads
1661
- * "authors includes alice"; other fields read "repo is api or web".
1662
- */
1663
- export declare function eventMatchFilterText(key: string, field: EventMatchField | undefined, value: EventMatch[string]): string;
1664
- /**
1665
- * Describe a selection for the dashboard and Slack, so both show the same
1666
- * words. Pass the selection's source, as for `eventTriggerProblems`. Its
1667
- * problems are the messages of that check.
1668
- */
1669
- export declare function describeEventTrigger(source: EventTriggerSource, selection: EventTriggerSelection): EventTriggerDescription;
1670
- /** Join filters into one line. Every filter must match, so join with "and". */
1671
- export declare function eventTriggerFiltersText(filters: readonly string[]): string;
1672
- /**
1673
- * Write a whole trigger as one line, for cards and lists:
1674
- * "Pull request · pull request opened · filters: isDraft is false".
1675
- */
1676
- export declare function eventTriggerText(resource: string, description: Pick<EventTriggerDescription, "events" | "filters">): string;
1745
+ /** Thrown when a plugin tool rejects invalid model or user input. */
1746
+ export declare class PluginToolInputError extends Error {
1747
+ constructor(message: string, options?: {
1748
+ cause?: unknown;
1749
+ });
1750
+ }
1751
+ export interface PluginSandbox {
1752
+ juniorRoot: string;
1753
+ root: string;
1754
+ readFile(path: string): Promise<Uint8Array | null>;
1755
+ run(input: {
1756
+ args?: string[];
1757
+ cmd: string;
1758
+ cwd?: string;
1759
+ env?: Record<string, string>;
1760
+ signal?: AbortSignal;
1761
+ sudo?: boolean;
1762
+ }): Promise<{
1763
+ exitCode: number;
1764
+ stderr: string;
1765
+ stdout: string;
1766
+ }>;
1767
+ writeFile(input: {
1768
+ content: string | Uint8Array;
1769
+ mode?: number;
1770
+ path: string;
1771
+ }): Promise<void>;
1772
+ }
1773
+ export interface PluginEgress {
1774
+ /**
1775
+ * Fetch a provider URL with host-owned credentials.
1776
+ *
1777
+ * The runtime selects and injects credentials for `provider`; plugin code
1778
+ * owns the request shape and response handling. `operation` names the
1779
+ * provider action for grant selection and diagnostics.
1780
+ */
1781
+ fetch(input: {
1782
+ operation: string;
1783
+ provider: string;
1784
+ request: Request;
1785
+ }): Promise<Response>;
1786
+ }
1787
+ export declare const pluginToolContentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1788
+ type: z.ZodLiteral<"text">;
1789
+ text: z.ZodString;
1790
+ }, z.core.$strict>, z.ZodObject<{
1791
+ type: z.ZodLiteral<"image">;
1792
+ data: z.ZodString;
1793
+ mimeType: z.ZodString;
1794
+ }, z.core.$strict>], "type">;
1795
+ /** Model-visible content returned by a plugin tool. */
1796
+ export type PluginToolContent = z.output<typeof pluginToolContentSchema>;
1797
+ /** Pi-native projection with model-facing content and canonical runtime details. */
1798
+ export interface PluginToolOutputEnvelope<TDetails = unknown> {
1799
+ content: PluginToolContent[];
1800
+ details: TDetails;
1801
+ }
1802
+ export type PluginMcpContent = PluginToolContent;
1803
+ /** Successful raw provider result returned to a plugin-owned wrapper tool. */
1804
+ export type PluginMcpToolSuccess = {
1805
+ content: PluginMcpContent[];
1806
+ status: "success";
1807
+ structuredContent?: unknown;
1808
+ };
1809
+ /** Handled provider authorization pause with no provider result to consume. */
1810
+ export type PluginMcpAuthorizationPending = {
1811
+ status: "authorization_pending";
1812
+ };
1813
+ /** Definitive provider rejection; transport and session failures still throw. */
1814
+ export type PluginMcpToolError = {
1815
+ message: string;
1816
+ status: "error";
1817
+ };
1818
+ export type PluginMcpToolResult = PluginMcpAuthorizationPending | PluginMcpToolError | PluginMcpToolSuccess;
1819
+ /** Access to this plugin's hosted MCP provider without exposing credentials. */
1820
+ export interface PluginMcp {
1821
+ /**
1822
+ * Call a provider tool declared in `wrappedTools`.
1823
+ *
1824
+ * The host activates the provider when needed. Successful calls return the
1825
+ * provider's original content, provider rejections return an error result,
1826
+ * and authorization pauses return no tool content. Transport failures throw.
1827
+ */
1828
+ callTool(input: {
1829
+ arguments?: Record<string, unknown>;
1830
+ name: string;
1831
+ toolCallId?: string;
1832
+ }): Promise<PluginMcpToolResult>;
1833
+ /**
1834
+ * Activate the provider before wrapper-owned state changes.
1835
+ *
1836
+ * Ordinary wrappers can call `callTool` directly. Durable mutation wrappers
1837
+ * may prepare first so an initial authorization pause happens before they
1838
+ * record pending work.
1839
+ */
1840
+ prepare(): Promise<"authorization_pending" | "ready">;
1841
+ }
1842
+ /** Complete Workspace repository preparation after credential egress is removed. */
1843
+ export type WorkspaceFinalize = () => Promise<void> | void;
1677
1844
  /**
1678
- * Runtime-owned provenance for a transcript message: whether it is a durable
1679
- * instruction or ambient context, plus the actor identity when known. Missing
1680
- * provenance on an entry means unattributed context.
1845
+ * Provider-owned, repeatable repository preparation for a Workspace Sandbox.
1846
+ * Implementations should refresh complete checkouts and replace missing or
1847
+ * partial ones.
1681
1848
  */
1682
- export declare const pluginRunTranscriptProvenanceSchema: z.ZodObject<{
1683
- authority: z.ZodEnum<{
1684
- context: "context";
1685
- instruction: "instruction";
1849
+ export interface WorkspacePrepareHookContext extends PluginContext {
1850
+ repos: Array<{
1851
+ path: string;
1852
+ repo: string;
1686
1853
  }>;
1687
- actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
1688
- email: z.ZodOptional<z.ZodString>;
1689
- fullName: z.ZodOptional<z.ZodString>;
1690
- userId: z.ZodString;
1691
- userName: z.ZodOptional<z.ZodString>;
1692
- platform: z.ZodLiteral<"slack">;
1693
- teamId: z.ZodString;
1694
- }, z.core.$strict>, z.ZodObject<{
1695
- email: z.ZodOptional<z.ZodString>;
1696
- fullName: z.ZodOptional<z.ZodString>;
1697
- userId: z.ZodString;
1698
- userName: z.ZodOptional<z.ZodString>;
1699
- platform: z.ZodLiteral<"local">;
1700
- }, z.core.$strict>, z.ZodObject<{
1701
- email: z.ZodOptional<z.ZodString>;
1702
- fullName: z.ZodOptional<z.ZodString>;
1703
- userId: z.ZodString;
1704
- userName: z.ZodOptional<z.ZodString>;
1705
- platform: z.ZodLiteral<"web">;
1706
- }, z.core.$strict>, z.ZodObject<{
1707
- platform: z.ZodLiteral<"system">;
1708
- name: z.ZodString;
1709
- }, z.core.$strict>], "platform">>;
1854
+ sandbox: PluginSandbox;
1855
+ }
1856
+ export interface SandboxPrepareHookContext extends PluginContext {
1857
+ actor?: Actor;
1858
+ sandbox: PluginSandbox;
1859
+ }
1860
+ export interface BeforeToolExecuteHookContext extends PluginContext {
1861
+ decision: PluginDecision;
1862
+ env: PluginEnv;
1863
+ /** Same directory as `PluginSandbox.juniorRoot` from `sandboxPrepare`. */
1864
+ juniorRoot: string;
1865
+ actor?: Actor;
1866
+ /** All actors who contributed instructions to the run so far; see `multi-actor-runs.md`. */
1867
+ actors?: Actor[];
1868
+ tool: {
1869
+ input: Record<string, unknown>;
1870
+ name: string;
1871
+ };
1872
+ /**
1873
+ * Resolve the current actor's stored identity and linked user.
1874
+ * Same contract as tool registration; used for commit attribution.
1875
+ */
1876
+ users: {
1877
+ resolveActor(): Promise<{
1878
+ identity: Identity;
1879
+ user?: User;
1880
+ } | undefined>;
1881
+ };
1882
+ }
1883
+ /**
1884
+ * Context for checks after a tool call finishes without an error.
1885
+ *
1886
+ * Runs for every tool, including sandbox tools and Code Mode script calls.
1887
+ * Return early for tools that the check does not cover: each check adds time
1888
+ * to every tool call.
1889
+ */
1890
+ export interface AfterToolExecuteHookContext extends PluginContext {
1891
+ decision: PluginToolResultDecision;
1892
+ /** Decision model for one narrow choice, such as a classifier for a diff. */
1893
+ decider: PluginDecider;
1894
+ /** Structured model calls for judgments that need reasoning. */
1895
+ model: PluginModel;
1896
+ /** The Run's sandbox. A call acquires it when no tool has used it yet. */
1897
+ sandbox: PluginSandbox;
1898
+ signal?: AbortSignal;
1899
+ /** Tool input after `beforeToolExecute` changes, without hook env. */
1900
+ tool: {
1901
+ input: Record<string, unknown>;
1902
+ name: string;
1903
+ };
1904
+ /** Active Workspace, with each repository's checkout path in the sandbox. */
1905
+ workspace?: {
1906
+ name: string;
1907
+ repos: Array<{
1908
+ /** Checkout path relative to `sandbox.root`. */
1909
+ path: string;
1910
+ provider: string;
1911
+ repo: string;
1912
+ }>;
1913
+ };
1914
+ }
1915
+ /**
1916
+ * Context for post-success MCP tool processing.
1917
+ *
1918
+ * Runs after a hosted MCP tool succeeds on the model-facing path. Use for
1919
+ * junior-owned side effects such as conversation annotations without replacing
1920
+ * the provider tool contract.
1921
+ */
1922
+ export interface AfterMcpToolHookContext extends PluginContext {
1923
+ /**
1924
+ * Opaque Junior conversation/session identity for this turn.
1925
+ * Interactive Slack turns use `slack:{channelId}:{threadTs}`.
1926
+ */
1927
+ conversationId?: string;
1928
+ annotations?: PluginAnnotations;
1929
+ result: {
1930
+ /** Provider content before model-facing truncation. */
1931
+ content?: PluginMcpContent[];
1932
+ structuredContent?: unknown;
1933
+ };
1934
+ tool: {
1935
+ arguments: Record<string, unknown>;
1936
+ /** Provider-local MCP tool name, for example `save_issue`. */
1937
+ name: string;
1938
+ };
1939
+ }
1940
+ export interface PluginToolExecuteOptions {
1941
+ /**
1942
+ * @deprecated Internal compatibility escape hatch for legacy tool bridges.
1943
+ * Plugin tools should use typed input fields and runtime hook context instead.
1944
+ */
1945
+ experimental_context?: unknown;
1946
+ /** Abort when the owning agent tool call is cancelled or times out. */
1947
+ signal?: AbortSignal;
1948
+ /** Stable runtime tool-call id; durable create tools should derive idempotency keys from it. */
1949
+ toolCallId?: string;
1950
+ }
1951
+ export declare const pluginToolContinuationSchema: z.ZodObject<{
1952
+ arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1953
+ reason: z.ZodOptional<z.ZodString>;
1710
1954
  }, z.core.$strict>;
1711
- /** One normalized transcript entry from the completed run exposed to plugin tasks. */
1712
- export declare const pluginRunTranscriptEntrySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1713
- type: z.ZodLiteral<"message">;
1714
- role: z.ZodEnum<{
1715
- assistant: "assistant";
1716
- user: "user";
1717
- }>;
1718
- text: z.ZodString;
1719
- provenance: z.ZodOptional<z.ZodObject<{
1720
- authority: z.ZodEnum<{
1721
- context: "context";
1722
- instruction: "instruction";
1723
- }>;
1724
- actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
1725
- email: z.ZodOptional<z.ZodString>;
1726
- fullName: z.ZodOptional<z.ZodString>;
1727
- userId: z.ZodString;
1728
- userName: z.ZodOptional<z.ZodString>;
1729
- platform: z.ZodLiteral<"slack">;
1730
- teamId: z.ZodString;
1731
- }, z.core.$strict>, z.ZodObject<{
1732
- email: z.ZodOptional<z.ZodString>;
1733
- fullName: z.ZodOptional<z.ZodString>;
1734
- userId: z.ZodString;
1735
- userName: z.ZodOptional<z.ZodString>;
1736
- platform: z.ZodLiteral<"local">;
1737
- }, z.core.$strict>, z.ZodObject<{
1738
- email: z.ZodOptional<z.ZodString>;
1739
- fullName: z.ZodOptional<z.ZodString>;
1740
- userId: z.ZodString;
1741
- userName: z.ZodOptional<z.ZodString>;
1742
- platform: z.ZodLiteral<"web">;
1743
- }, z.core.$strict>, z.ZodObject<{
1744
- platform: z.ZodLiteral<"system">;
1745
- name: z.ZodString;
1746
- }, z.core.$strict>], "platform">>;
1747
- }, z.core.$strict>>;
1748
- isRunActor: z.ZodOptional<z.ZodBoolean>;
1749
- }, z.core.$strict>, z.ZodObject<{
1750
- type: z.ZodLiteral<"toolResult">;
1751
- toolName: z.ZodString;
1752
- isError: z.ZodBoolean;
1753
- text: z.ZodOptional<z.ZodString>;
1754
- }, z.core.$strict>], "type">;
1755
- export type PluginRunTranscriptProvenance = z.output<typeof pluginRunTranscriptProvenanceSchema>;
1756
- /** Runtime-owned completed-run projection exposed to plugin tasks. */
1757
- export declare const pluginRunContextSchema: z.ZodObject<{
1758
- actorUserId: z.ZodOptional<z.ZodString>;
1759
- completedAtMs: z.ZodNumber;
1760
- conversationId: z.ZodString;
1761
- destination: z.ZodDiscriminatedUnion<[z.ZodObject<{
1762
- platform: z.ZodLiteral<"slack">;
1763
- teamId: z.ZodString;
1764
- channelId: z.ZodString;
1765
- threadTs: z.ZodOptional<z.ZodString>;
1766
- }, z.core.$strict>, z.ZodObject<{
1767
- platform: z.ZodLiteral<"local">;
1768
- conversationId: z.ZodString;
1769
- }, z.core.$strict>], "platform">;
1770
- locationId: z.ZodOptional<z.ZodString>;
1771
- actors: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1772
- email: z.ZodOptional<z.ZodString>;
1773
- fullName: z.ZodOptional<z.ZodString>;
1774
- userId: z.ZodString;
1775
- userName: z.ZodOptional<z.ZodString>;
1776
- platform: z.ZodLiteral<"slack">;
1777
- teamId: z.ZodString;
1778
- }, z.core.$strict>, z.ZodObject<{
1779
- email: z.ZodOptional<z.ZodString>;
1780
- fullName: z.ZodOptional<z.ZodString>;
1781
- userId: z.ZodString;
1782
- userName: z.ZodOptional<z.ZodString>;
1783
- platform: z.ZodLiteral<"local">;
1784
- }, z.core.$strict>, z.ZodObject<{
1785
- email: z.ZodOptional<z.ZodString>;
1786
- fullName: z.ZodOptional<z.ZodString>;
1787
- userId: z.ZodString;
1788
- userName: z.ZodOptional<z.ZodString>;
1789
- platform: z.ZodLiteral<"web">;
1790
- }, z.core.$strict>, z.ZodObject<{
1791
- platform: z.ZodLiteral<"system">;
1792
- name: z.ZodString;
1793
- }, z.core.$strict>], "platform">>;
1794
- actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
1795
- email: z.ZodOptional<z.ZodString>;
1796
- fullName: z.ZodOptional<z.ZodString>;
1797
- userId: z.ZodString;
1798
- userName: z.ZodOptional<z.ZodString>;
1799
- platform: z.ZodLiteral<"slack">;
1800
- teamId: z.ZodString;
1801
- }, z.core.$strict>, z.ZodObject<{
1802
- email: z.ZodOptional<z.ZodString>;
1803
- fullName: z.ZodOptional<z.ZodString>;
1804
- userId: z.ZodString;
1805
- userName: z.ZodOptional<z.ZodString>;
1806
- platform: z.ZodLiteral<"local">;
1807
- }, z.core.$strict>, z.ZodObject<{
1808
- email: z.ZodOptional<z.ZodString>;
1809
- fullName: z.ZodOptional<z.ZodString>;
1810
- userId: z.ZodString;
1811
- userName: z.ZodOptional<z.ZodString>;
1812
- platform: z.ZodLiteral<"web">;
1813
- }, z.core.$strict>, z.ZodObject<{
1814
- platform: z.ZodLiteral<"system">;
1815
- name: z.ZodString;
1816
- }, z.core.$strict>], "platform">>;
1817
- runId: z.ZodString;
1818
- source: z.ZodPreprocess<z.ZodDiscriminatedUnion<[z.ZodObject<{
1819
- kind: z.ZodLiteral<"slack">;
1820
- teamId: z.ZodString;
1821
- channelId: z.ZodString;
1822
- visibility: z.ZodEnum<{
1823
- private: "private";
1824
- public: "public";
1825
- }>;
1826
- messageTs: z.ZodOptional<z.ZodString>;
1827
- threadTs: z.ZodOptional<z.ZodString>;
1828
- }, z.core.$strict>, z.ZodObject<{
1829
- kind: z.ZodLiteral<"local">;
1830
- visibility: z.ZodLiteral<"private">;
1831
- conversationId: z.ZodString;
1832
- }, z.core.$strict>, z.ZodObject<{
1833
- kind: z.ZodLiteral<"web">;
1834
- visibility: z.ZodEnum<{
1835
- private: "private";
1836
- public: "public";
1837
- }>;
1838
- conversationId: z.ZodString;
1839
- }, z.core.$strict>, z.ZodObject<{
1840
- kind: z.ZodLiteral<"event">;
1841
- eventKey: z.ZodString;
1842
- eventType: z.ZodString;
1843
- identifier: z.ZodString;
1844
- namespace: z.ZodString;
1845
- }, z.core.$strict>, z.ZodObject<{
1846
- automationId: z.ZodOptional<z.ZodString>;
1847
- automationRunId: z.ZodOptional<z.ZodString>;
1848
- kind: z.ZodLiteral<"scheduled_automation">;
1849
- }, z.core.$strict>, z.ZodObject<{
1850
- automationId: z.ZodOptional<z.ZodString>;
1851
- automationRunId: z.ZodOptional<z.ZodString>;
1852
- kind: z.ZodLiteral<"event_automation">;
1853
- }, z.core.$strict>, z.ZodObject<{
1854
- kind: z.ZodLiteral<"plugin_dispatch">;
1855
- }, z.core.$strict>, z.ZodObject<{
1856
- kind: z.ZodLiteral<"agent_invocation">;
1857
- }, z.core.$strict>], "kind">, unknown>;
1858
- transcript: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1859
- type: z.ZodLiteral<"message">;
1860
- role: z.ZodEnum<{
1861
- assistant: "assistant";
1862
- user: "user";
1863
- }>;
1864
- text: z.ZodString;
1865
- provenance: z.ZodOptional<z.ZodObject<{
1866
- authority: z.ZodEnum<{
1867
- context: "context";
1868
- instruction: "instruction";
1869
- }>;
1870
- actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
1871
- email: z.ZodOptional<z.ZodString>;
1872
- fullName: z.ZodOptional<z.ZodString>;
1873
- userId: z.ZodString;
1874
- userName: z.ZodOptional<z.ZodString>;
1875
- platform: z.ZodLiteral<"slack">;
1876
- teamId: z.ZodString;
1877
- }, z.core.$strict>, z.ZodObject<{
1878
- email: z.ZodOptional<z.ZodString>;
1879
- fullName: z.ZodOptional<z.ZodString>;
1880
- userId: z.ZodString;
1881
- userName: z.ZodOptional<z.ZodString>;
1882
- platform: z.ZodLiteral<"local">;
1883
- }, z.core.$strict>, z.ZodObject<{
1884
- email: z.ZodOptional<z.ZodString>;
1885
- fullName: z.ZodOptional<z.ZodString>;
1886
- userId: z.ZodString;
1887
- userName: z.ZodOptional<z.ZodString>;
1888
- platform: z.ZodLiteral<"web">;
1889
- }, z.core.$strict>, z.ZodObject<{
1890
- platform: z.ZodLiteral<"system">;
1891
- name: z.ZodString;
1892
- }, z.core.$strict>], "platform">>;
1893
- }, z.core.$strict>>;
1894
- isRunActor: z.ZodOptional<z.ZodBoolean>;
1895
- }, z.core.$strict>, z.ZodObject<{
1896
- type: z.ZodLiteral<"toolResult">;
1897
- toolName: z.ZodString;
1898
- isError: z.ZodBoolean;
1899
- text: z.ZodOptional<z.ZodString>;
1900
- }, z.core.$strict>], "type">>;
1901
- }, z.core.$strict>;
1902
- export type PluginRunTranscriptEntry = z.output<typeof pluginRunTranscriptEntrySchema>;
1903
- export type PluginRunContext = z.output<typeof pluginRunContextSchema>;
1904
- /** Runtime context passed to a plugin-owned background task. */
1905
- export interface PluginTaskContext extends PluginContext {
1906
- embedder: PluginEmbedder;
1907
- events: PluginConversationEvents;
1908
- id: string;
1909
- model: PluginModel;
1910
- name: string;
1911
- run: {
1912
- load(): Promise<PluginRunContext>;
1913
- };
1914
- state: PluginState;
1915
- }
1916
- /** Plugin task handler registered by name in a plugin manifest module. */
1917
- export interface PluginTaskDefinition {
1918
- run(ctx: PluginTaskContext): Promise<void> | void;
1919
- }
1920
- /** Task handlers keyed by the plugin-owned task name. */
1921
- export type PluginTasks = Record<string, PluginTaskDefinition>;
1922
- declare const pluginGrantAccessSchema: z.ZodUnion<readonly [z.ZodLiteral<"read">, z.ZodLiteral<"write">]>;
1923
- /** Runtime schema for provider authorization a plugin may request. */
1924
- export declare const pluginAuthorizationSchema: z.ZodObject<{
1925
- provider: z.ZodString;
1926
- scope: z.ZodOptional<z.ZodString>;
1927
- type: z.ZodLiteral<"oauth">;
1928
- }, z.core.$strict>;
1929
- /** Runtime schema for a provider account attached to stored OAuth tokens. */
1930
- export declare const pluginProviderAccountSchema: z.ZodObject<{
1931
- displayName: z.ZodOptional<z.ZodString>;
1932
- handle: z.ZodOptional<z.ZodString>;
1933
- id: z.ZodString;
1934
- label: z.ZodOptional<z.ZodString>;
1935
- url: z.ZodOptional<z.ZodString>;
1936
- verifiedEmails: z.ZodOptional<z.ZodArray<z.ZodString>>;
1937
- }, z.core.$strict>;
1938
- /** Runtime schema for OAuth tokens stored by the host for plugin credentials. */
1939
- export declare const pluginStoredTokensSchema: z.ZodObject<{
1940
- account: z.ZodOptional<z.ZodObject<{
1941
- displayName: z.ZodOptional<z.ZodString>;
1942
- handle: z.ZodOptional<z.ZodString>;
1943
- id: z.ZodString;
1944
- label: z.ZodOptional<z.ZodString>;
1945
- url: z.ZodOptional<z.ZodString>;
1946
- verifiedEmails: z.ZodOptional<z.ZodArray<z.ZodString>>;
1947
- }, z.core.$strict>>;
1948
- accessToken: z.ZodString;
1949
- expiresAt: z.ZodOptional<z.ZodNumber>;
1950
- refreshToken: z.ZodString;
1951
- refreshTokenExpiresAt: z.ZodOptional<z.ZodNumber>;
1952
- scope: z.ZodOptional<z.ZodString>;
1953
- }, z.core.$strict>;
1954
- /**
1955
- * Provider facts for egress audit events, such as the target repository.
1956
- * Keys use the plugin's `app.<provider>.*` names. Telemetry only.
1957
- */
1958
- export declare const pluginAuditAttributesSchema: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>]>>;
1959
- /** Runtime schema for a plugin-defined outbound credential grant. */
1960
- export declare const pluginGrantSchema: z.ZodObject<{
1961
- access: z.ZodUnion<readonly [z.ZodLiteral<"read">, z.ZodLiteral<"write">]>;
1962
- auditAttributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>]>>>;
1963
- leaseScope: z.ZodOptional<z.ZodString>;
1964
- name: z.ZodString;
1965
- reason: z.ZodOptional<z.ZodString>;
1966
- requirements: z.ZodOptional<z.ZodArray<z.ZodString>>;
1967
- }, z.core.$strict>;
1968
- /** Runtime schema for plugin-issued header mutations. */
1969
- export declare const pluginCredentialHeaderTransformSchema: z.ZodObject<{
1970
- domain: z.ZodString;
1971
- headers: z.ZodRecord<z.ZodString, z.ZodString>;
1972
- }, z.core.$strict>;
1973
- /** Runtime schema for a short-lived plugin-issued credential lease. */
1974
- export declare const pluginCredentialLeaseSchema: z.ZodObject<{
1975
- account: z.ZodOptional<z.ZodObject<{
1976
- displayName: z.ZodOptional<z.ZodString>;
1977
- handle: z.ZodOptional<z.ZodString>;
1978
- id: z.ZodString;
1979
- label: z.ZodOptional<z.ZodString>;
1980
- url: z.ZodOptional<z.ZodString>;
1981
- verifiedEmails: z.ZodOptional<z.ZodArray<z.ZodString>>;
1982
- }, z.core.$strict>>;
1983
- authorization: z.ZodOptional<z.ZodObject<{
1984
- provider: z.ZodString;
1985
- scope: z.ZodOptional<z.ZodString>;
1986
- type: z.ZodLiteral<"oauth">;
1987
- }, z.core.$strict>>;
1988
- expiresAt: z.ZodString;
1989
- headerTransforms: z.ZodArray<z.ZodObject<{
1990
- domain: z.ZodString;
1991
- headers: z.ZodRecord<z.ZodString, z.ZodString>;
1992
- }, z.core.$strict>>;
1993
- }, z.core.$strict>;
1994
- /** Runtime schema for the result returned by a plugin credential hook. */
1995
- export declare const pluginCredentialResultSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1996
- lease: z.ZodObject<{
1997
- account: z.ZodOptional<z.ZodObject<{
1998
- displayName: z.ZodOptional<z.ZodString>;
1999
- handle: z.ZodOptional<z.ZodString>;
2000
- id: z.ZodString;
2001
- label: z.ZodOptional<z.ZodString>;
2002
- url: z.ZodOptional<z.ZodString>;
2003
- verifiedEmails: z.ZodOptional<z.ZodArray<z.ZodString>>;
2004
- }, z.core.$strict>>;
2005
- authorization: z.ZodOptional<z.ZodObject<{
2006
- provider: z.ZodString;
2007
- scope: z.ZodOptional<z.ZodString>;
2008
- type: z.ZodLiteral<"oauth">;
2009
- }, z.core.$strict>>;
2010
- expiresAt: z.ZodString;
2011
- headerTransforms: z.ZodArray<z.ZodObject<{
2012
- domain: z.ZodString;
2013
- headers: z.ZodRecord<z.ZodString, z.ZodString>;
2014
- }, z.core.$strict>>;
2015
- }, z.core.$strict>;
2016
- type: z.ZodLiteral<"lease">;
2017
- }, z.core.$strict>, z.ZodObject<{
2018
- authorization: z.ZodOptional<z.ZodObject<{
2019
- provider: z.ZodString;
2020
- scope: z.ZodOptional<z.ZodString>;
2021
- type: z.ZodLiteral<"oauth">;
2022
- }, z.core.$strict>>;
2023
- message: z.ZodString;
2024
- type: z.ZodLiteral<"needed">;
2025
- }, z.core.$strict>, z.ZodObject<{
2026
- message: z.ZodString;
2027
- type: z.ZodLiteral<"unavailable">;
2028
- }, z.core.$strict>], "type">;
2029
- export type PluginCredentialSubject = z.output<typeof pluginCredentialSubjectSchema>;
2030
- export type PluginGrantAccess = z.output<typeof pluginGrantAccessSchema>;
2031
- /** Provider authorization Junior can start when a plugin-owned grant is missing. */
2032
- export type PluginAuthorization = z.output<typeof pluginAuthorizationSchema>;
2033
- /** Interrupt sandbox egress so Junior can start provider authorization. */
2034
- export declare class EgressAuthRequired extends Error {
2035
- authorization?: PluginAuthorization;
2036
- constructor(message: string, options?: {
2037
- authorization?: PluginAuthorization;
2038
- cause?: unknown;
2039
- });
2040
- }
2041
- /** Deny provider egress before Junior issues credentials for a disallowed operation. */
2042
- export declare class EgressPolicyDenied extends Error {
2043
- /** Provider facts for the policy denial event. */
2044
- readonly auditAttributes?: PluginAuditAttributes;
2045
- constructor(message: string, options?: {
2046
- auditAttributes?: PluginAuditAttributes;
2047
- cause?: unknown;
2048
- });
2049
- }
2050
- /** Provider facts for egress audit events. */
2051
- export type PluginAuditAttributes = z.output<typeof pluginAuditAttributesSchema>;
2052
- /** Provider account identity resolved by a plugin OAuth hook. */
2053
- export type PluginProviderAccount = z.output<typeof pluginProviderAccountSchema>;
2054
- /** Plugin-defined grant required before Junior can forward one outbound request. */
2055
- export type PluginGrant = z.output<typeof pluginGrantSchema>;
2056
- /** One ref update command in a Git push. */
2057
- export interface PluginGitRefUpdate {
2058
- /** True when the push deletes the ref: its new object id is all zeros. */
2059
- deletes: boolean;
2060
- /** Full ref name, such as `refs/heads/main`. */
2061
- ref: string;
2062
- }
2063
- /** Why the host could not read the ref updates of a Git push. */
2064
- export type PluginGitPushUnreadableReason = "gzip" | "malformed" | "signed" | "unterminated";
2065
- /**
2066
- * Ref updates of a Git smart HTTP push (`git-receive-pack`), which the host
2067
- * reads from the body before the pack data. An `unreadable` push changes
2068
- * refs that the host cannot name.
2069
- */
2070
- export type PluginGitPush = {
2071
- kind: "commands";
2072
- updates: PluginGitRefUpdate[];
2073
- } | {
2074
- kind: "unreadable";
2075
- reason: PluginGitPushUnreadableReason;
2076
- };
2077
- /** One field that a GraphQL operation selects. */
2078
- export interface PluginGraphqlField {
2079
- /** Names of the arguments that the field passes. */
2080
- arguments: string[];
2081
- /** Schema field name. An alias does not replace it. */
2082
- name: string;
2083
- }
2084
- /** The GraphQL operation that one request runs. */
2085
- export interface PluginGraphqlOperation {
2086
- /**
2087
- * Each distinct field that the operation selects at any depth, also through
2088
- * fragments.
2089
- */
2090
- fields: PluginGraphqlField[];
2091
- name?: string;
2092
- /**
2093
- * Field names at the operation root, also through fragments. There is one
2094
- * entry for each field selection, so an aliased repeat shows twice.
2095
- */
2096
- rootFields: string[];
2097
- type: "mutation" | "query" | "subscription";
2098
- }
2099
- /**
2100
- * Why the host could not read the operation of a GraphQL request:
2101
- *
2102
- * - `document`: the query does not parse, or it spreads a fragment that it
2103
- * does not define.
2104
- * - `gzip`: the body is compressed.
2105
- * - `json`: the body is not a JSON object or a JSON array of objects.
2106
- * - `operation`: `operationName` names no operation, or the document has more
2107
- * than one operation and no `operationName`.
2108
- * - `query`: the body has no `query` string, such as a persisted query hash.
2109
- * - `too-large`: the body is larger than the host reads before it issues
2110
- * credentials.
2111
- */
2112
- export type PluginGraphqlUnreadableReason = "document" | "gzip" | "json" | "operation" | "query" | "too-large";
2113
- /**
2114
- * The operations of a GraphQL POST, which the host reads from the JSON body.
2115
- * A `batch` is a JSON array of requests. An `unreadable` request can run any
2116
- * operation, mutations included.
2117
- */
2118
- export type PluginGraphqlRequest = {
2119
- kind: "batch";
2120
- operations: PluginGraphqlOperation[];
2121
- } | {
2122
- kind: "operation";
2123
- operation: PluginGraphqlOperation;
2124
- } | {
2125
- kind: "unreadable";
2126
- reason: PluginGraphqlUnreadableReason;
2127
- };
2128
- /** Request details available while selecting the grant for sandbox egress. */
2129
- export interface PluginEgressRequest {
2130
- /**
2131
- * Capped request body text when the host exposes it for provider-specific
2132
- * grant classification.
2133
- */
2134
- bodyText?: string;
2135
- /** Set for every Git `git-receive-pack` POST. */
2136
- gitPush?: PluginGitPush;
2137
- /** Set for every POST to a URL path that ends in `/graphql`. */
2138
- graphql?: PluginGraphqlRequest;
2139
- method: string;
2140
- /** Plugin-declared operation this request performs, used for grant classification and diagnostics. */
2141
- operation?: string;
2142
- url: string;
2143
- }
2144
- export interface EgressHookContext extends PluginContext {
2145
- request: PluginEgressRequest;
2146
- }
2147
- export interface PluginEgressResponse {
2148
- /** Snapshot of upstream response headers; mutations do not affect pass-through. */
2149
- headers: Headers;
2150
- readText(maxBytes: number): Promise<string | undefined>;
2151
- status: number;
2152
- }
2153
- export interface EgressResponseHookContext extends PluginContext {
2154
- grant: PluginGrant;
2155
- permissionDenied(message: string): void;
2156
- request: Omit<PluginEgressRequest, "bodyText" | "gitPush" | "graphql">;
2157
- response: PluginEgressResponse;
2158
- }
2159
- /** Header mutations a plugin-issued credential lease may apply to owned domains. */
2160
- export type PluginCredentialHeaderTransform = z.output<typeof pluginCredentialHeaderTransformSchema>;
2161
- /** Short-lived credential headers issued by a plugin for a selected grant. */
2162
- export type PluginCredentialLease = z.output<typeof pluginCredentialLeaseSchema>;
2163
- export type PluginCredentialResult = z.output<typeof pluginCredentialResultSchema>;
2164
- export type PluginCredentialActor = {
2165
- platform: "system";
2166
- name: string;
2167
- } | {
2168
- type: "user";
2169
- userId: string;
2170
- };
2171
- export interface PluginResolvedCredentialUser {
2172
- type: "user";
2173
- userId: string;
2174
- }
2175
- export type PluginStoredTokens = z.output<typeof pluginStoredTokensSchema>;
2176
- export interface PluginUserTokenSlot {
2177
- get(): Promise<PluginStoredTokens | undefined>;
2178
- set(tokens: PluginStoredTokens): Promise<void>;
2179
- /** Run token refresh work after the host has serialized this user/provider slot, or throw after a bounded wait. */
2180
- withRefresh<T>(callback: () => Promise<T>): Promise<T>;
2181
- userId: string;
2182
- }
2183
- export interface PluginTokenStore {
2184
- credentialSubject?: PluginUserTokenSlot;
2185
- currentUser?: PluginUserTokenSlot;
2186
- }
2187
- export interface ResolveOAuthAccountHookContext extends PluginContext {
2188
- tokens: PluginStoredTokens;
2189
- /**
2190
- * Parsed JSON body of the provider token response. Some providers return
2191
- * the authorized account in this body.
2192
- */
2193
- tokenResponse: Record<string, unknown>;
2194
- }
2195
- export interface IssueCredentialHookContext extends PluginContext {
2196
- actor: PluginCredentialActor;
2197
- credentialSubject?: PluginResolvedCredentialUser;
2198
- grant: PluginGrant;
2199
- tokens: PluginTokenStore;
2200
- }
2201
- export interface PluginEnv {
2202
- get(key: string): string | undefined;
2203
- set(key: string, value: string): void;
2204
- }
2205
- /**
2206
- * Decide what happens to one tool call in `beforeToolExecute`.
2207
- *
2208
- * `redirect` and `deny` both stop the tool before it runs. Neither ends the
2209
- * turn: the agent gets the message as the tool result.
2210
- */
2211
- export interface PluginDecision {
2212
- /**
2213
- * Block the call as a policy refusal. The agent is told not to retry or
2214
- * reach the same result another way, and to explain the block.
2215
- */
2216
- deny(reason: string): void;
2217
- /**
2218
- * Block the call because a different path is correct, such as another
2219
- * tool. The message tells the agent what to do instead.
2220
- */
2221
- redirect(message: string): void;
2222
- replaceInput(input: Record<string, unknown>): void;
2223
- }
2224
- /**
2225
- * Decide what the agent reads after one tool call in `afterToolExecute`.
2226
- *
2227
- * The tool already ran, so neither choice undoes its effects.
2228
- */
2229
- export interface PluginToolResultDecision {
2230
- /**
2231
- * Reject the result as a policy refusal. The agent gets the reason instead
2232
- * of the result, and is told not to retry. Undo the tool's effects first
2233
- * when they must not stay.
2234
- */
2235
- deny(reason: string): void;
2236
- /**
2237
- * Add guidance after the result, such as a problem to fix in the change
2238
- * that the tool made. The agent reads the result and the guidance.
2239
- */
2240
- nudge(message: string): void;
2241
- }
2242
- /** Thrown when a plugin tool rejects invalid model or user input. */
2243
- export declare class PluginToolInputError extends Error {
2244
- constructor(message: string, options?: {
2245
- cause?: unknown;
2246
- });
2247
- }
2248
- export interface PluginSandbox {
2249
- juniorRoot: string;
2250
- root: string;
2251
- readFile(path: string): Promise<Uint8Array | null>;
2252
- run(input: {
2253
- args?: string[];
2254
- cmd: string;
2255
- cwd?: string;
2256
- env?: Record<string, string>;
2257
- signal?: AbortSignal;
2258
- sudo?: boolean;
2259
- }): Promise<{
2260
- exitCode: number;
2261
- stderr: string;
2262
- stdout: string;
2263
- }>;
2264
- writeFile(input: {
2265
- content: string | Uint8Array;
2266
- mode?: number;
2267
- path: string;
2268
- }): Promise<void>;
2269
- }
2270
- export interface PluginEgress {
2271
- /**
2272
- * Fetch a provider URL with host-owned credentials.
2273
- *
2274
- * The runtime selects and injects credentials for `provider`; plugin code
2275
- * owns the request shape and response handling. `operation` names the
2276
- * provider action for grant selection and diagnostics.
2277
- */
2278
- fetch(input: {
2279
- operation: string;
2280
- provider: string;
2281
- request: Request;
2282
- }): Promise<Response>;
2283
- }
2284
- export declare const pluginToolContentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
2285
- type: z.ZodLiteral<"text">;
2286
- text: z.ZodString;
2287
- }, z.core.$strict>, z.ZodObject<{
2288
- type: z.ZodLiteral<"image">;
2289
- data: z.ZodString;
2290
- mimeType: z.ZodString;
2291
- }, z.core.$strict>], "type">;
2292
- /** Model-visible content returned by a plugin tool. */
2293
- export type PluginToolContent = z.output<typeof pluginToolContentSchema>;
2294
- /** Pi-native projection with model-facing content and canonical runtime details. */
2295
- export interface PluginToolOutputEnvelope<TDetails = unknown> {
2296
- content: PluginToolContent[];
2297
- details: TDetails;
2298
- }
2299
- export type PluginMcpContent = PluginToolContent;
2300
- /** Successful raw provider result returned to a plugin-owned wrapper tool. */
2301
- export type PluginMcpToolSuccess = {
2302
- content: PluginMcpContent[];
2303
- status: "success";
2304
- structuredContent?: unknown;
2305
- };
2306
- /** Handled provider authorization pause with no provider result to consume. */
2307
- export type PluginMcpAuthorizationPending = {
2308
- status: "authorization_pending";
2309
- };
2310
- /** Definitive provider rejection; transport and session failures still throw. */
2311
- export type PluginMcpToolError = {
2312
- message: string;
2313
- status: "error";
2314
- };
2315
- export type PluginMcpToolResult = PluginMcpAuthorizationPending | PluginMcpToolError | PluginMcpToolSuccess;
2316
- /** Access to this plugin's hosted MCP provider without exposing credentials. */
2317
- export interface PluginMcp {
2318
- /**
2319
- * Call a provider tool declared in `wrappedTools`.
2320
- *
2321
- * The host activates the provider when needed. Successful calls return the
2322
- * provider's original content, provider rejections return an error result,
2323
- * and authorization pauses return no tool content. Transport failures throw.
2324
- */
2325
- callTool(input: {
2326
- arguments?: Record<string, unknown>;
2327
- name: string;
2328
- toolCallId?: string;
2329
- }): Promise<PluginMcpToolResult>;
2330
- /**
2331
- * Activate the provider before wrapper-owned state changes.
2332
- *
2333
- * Ordinary wrappers can call `callTool` directly. Durable mutation wrappers
2334
- * may prepare first so an initial authorization pause happens before they
2335
- * record pending work.
2336
- */
2337
- prepare(): Promise<"authorization_pending" | "ready">;
2338
- }
2339
- /** Complete Workspace repository preparation after credential egress is removed. */
2340
- export type WorkspaceFinalize = () => Promise<void> | void;
2341
- /**
2342
- * Provider-owned, repeatable repository preparation for a Workspace Sandbox.
2343
- * Implementations should refresh complete checkouts and replace missing or
2344
- * partial ones.
2345
- */
2346
- export interface WorkspacePrepareHookContext extends PluginContext {
2347
- repos: Array<{
2348
- path: string;
2349
- repo: string;
2350
- }>;
2351
- sandbox: PluginSandbox;
2352
- }
2353
- export interface SandboxPrepareHookContext extends PluginContext {
2354
- actor?: Actor;
2355
- sandbox: PluginSandbox;
2356
- }
2357
- export interface BeforeToolExecuteHookContext extends PluginContext {
2358
- decision: PluginDecision;
2359
- env: PluginEnv;
2360
- /** Same directory as `PluginSandbox.juniorRoot` from `sandboxPrepare`. */
2361
- juniorRoot: string;
2362
- actor?: Actor;
2363
- /** All actors who contributed instructions to the run so far; see `multi-actor-runs.md`. */
2364
- actors?: Actor[];
2365
- tool: {
2366
- input: Record<string, unknown>;
2367
- name: string;
2368
- };
2369
- /**
2370
- * Resolve the current actor's stored identity and linked user.
2371
- * Same contract as tool registration; used for commit attribution.
2372
- */
2373
- users: {
2374
- resolveActor(): Promise<{
2375
- identity: Identity;
2376
- user?: User;
2377
- } | undefined>;
2378
- };
2379
- }
2380
- /**
2381
- * Context for checks after a tool call finishes without an error.
2382
- *
2383
- * Runs for every tool, including sandbox tools and Code Mode script calls.
2384
- * Return early for tools that the check does not cover: each check adds time
2385
- * to every tool call.
2386
- */
2387
- export interface AfterToolExecuteHookContext extends PluginContext {
2388
- decision: PluginToolResultDecision;
2389
- /** Decision model for one narrow choice, such as a classifier for a diff. */
2390
- decider: PluginDecider;
2391
- /** Structured model calls for judgments that need reasoning. */
2392
- model: PluginModel;
2393
- /** The Run's sandbox. A call acquires it when no tool has used it yet. */
2394
- sandbox: PluginSandbox;
2395
- signal?: AbortSignal;
2396
- /** Tool input after `beforeToolExecute` changes, without hook env. */
2397
- tool: {
2398
- input: Record<string, unknown>;
2399
- name: string;
2400
- };
2401
- /** Active Workspace, with each repository's checkout path in the sandbox. */
2402
- workspace?: {
2403
- name: string;
2404
- repos: Array<{
2405
- /** Checkout path relative to `sandbox.root`. */
2406
- path: string;
2407
- provider: string;
2408
- repo: string;
2409
- }>;
2410
- };
2411
- }
2412
- /**
2413
- * Context for post-success MCP tool processing.
2414
- *
2415
- * Runs after a hosted MCP tool succeeds on the model-facing path. Use for
2416
- * junior-owned side effects such as conversation annotations without replacing
2417
- * the provider tool contract.
2418
- */
2419
- export interface AfterMcpToolHookContext extends PluginContext {
2420
- /**
2421
- * Opaque Junior conversation/session identity for this turn.
2422
- * Interactive Slack turns use `slack:{channelId}:{threadTs}`.
2423
- */
2424
- conversationId?: string;
2425
- annotations?: PluginAnnotations;
2426
- result: {
2427
- /** Provider content before model-facing truncation. */
2428
- content?: PluginMcpContent[];
2429
- structuredContent?: unknown;
2430
- };
2431
- tool: {
2432
- arguments: Record<string, unknown>;
2433
- /** Provider-local MCP tool name, for example `save_issue`. */
2434
- name: string;
2435
- };
2436
- }
2437
- export interface PluginToolExecuteOptions {
2438
- /**
2439
- * @deprecated Internal compatibility escape hatch for legacy tool bridges.
2440
- * Plugin tools should use typed input fields and runtime hook context instead.
2441
- */
2442
- experimental_context?: unknown;
2443
- /** Abort when the owning agent tool call is cancelled or times out. */
2444
- signal?: AbortSignal;
2445
- /** Stable runtime tool-call id; durable create tools should derive idempotency keys from it. */
2446
- toolCallId?: string;
2447
- }
2448
- export declare const pluginToolContinuationSchema: z.ZodObject<{
2449
- arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
2450
- reason: z.ZodOptional<z.ZodString>;
2451
- }, z.core.$strict>;
2452
- /** Junior text that a plugin tool posted to its provider. */
2453
- export declare const pluginToolReplySchema: z.ZodObject<{
1955
+ /** Junior text that a plugin tool posted to its provider. */
1956
+ export declare const pluginToolReplySchema: z.ZodObject<{
2454
1957
  text: z.ZodString;
2455
1958
  url: z.ZodOptional<z.ZodString>;
2456
1959
  }, z.core.$strict>;
@@ -2466,10 +1969,12 @@ export declare const pluginToolOutputSchema: z.ZodObject<{
2466
1969
  code_change: "code_change";
2467
1970
  conversation: "conversation";
2468
1971
  deployment: "deployment";
1972
+ document: "document";
2469
1973
  item: "item";
2470
1974
  message: "message";
2471
1975
  person: "person";
2472
1976
  task: "task";
1977
+ web_page: "web_page";
2473
1978
  }>;
2474
1979
  title: z.ZodString;
2475
1980
  url: z.ZodNullable<z.ZodURL>;
@@ -2481,6 +1986,7 @@ export declare const pluginToolOutputSchema: z.ZodObject<{
2481
1986
  sourceUpdatedAt: z.ZodOptional<z.ZodISODateTime>;
2482
1987
  facts: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
2483
1988
  type: z.ZodLiteral<"code_change">;
1989
+ summary: z.ZodOptional<z.ZodString>;
2484
1990
  author: z.ZodOptional<z.ZodString>;
2485
1991
  sourceBranch: z.ZodOptional<z.ZodString>;
2486
1992
  targetBranch: z.ZodOptional<z.ZodString>;
@@ -2502,6 +2008,7 @@ export declare const pluginToolOutputSchema: z.ZodObject<{
2502
2008
  previewImageUrls: z.ZodOptional<z.ZodArray<z.ZodURL>>;
2503
2009
  }, z.core.$strict>, z.ZodObject<{
2504
2010
  type: z.ZodLiteral<"task">;
2011
+ summary: z.ZodOptional<z.ZodString>;
2505
2012
  assignees: z.ZodOptional<z.ZodArray<z.ZodString>>;
2506
2013
  priority: z.ZodOptional<z.ZodString>;
2507
2014
  project: z.ZodOptional<z.ZodString>;
@@ -2510,25 +2017,41 @@ export declare const pluginToolOutputSchema: z.ZodObject<{
2510
2017
  labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
2511
2018
  }, z.core.$strict>, z.ZodObject<{
2512
2019
  type: z.ZodLiteral<"deployment">;
2020
+ summary: z.ZodOptional<z.ZodString>;
2513
2021
  project: z.ZodOptional<z.ZodString>;
2514
2022
  environment: z.ZodOptional<z.ZodString>;
2515
2023
  revision: z.ZodOptional<z.ZodString>;
2516
2024
  branch: z.ZodOptional<z.ZodString>;
2517
2025
  }, z.core.$strict>, z.ZodObject<{
2518
2026
  type: z.ZodLiteral<"calendar_event">;
2027
+ summary: z.ZodOptional<z.ZodString>;
2519
2028
  when: z.ZodOptional<z.ZodString>;
2520
2029
  attendees: z.ZodOptional<z.ZodArray<z.ZodString>>;
2521
2030
  }, z.core.$strict>, z.ZodObject<{
2522
2031
  type: z.ZodLiteral<"conversation">;
2032
+ summary: z.ZodOptional<z.ZodString>;
2523
2033
  participants: z.ZodOptional<z.ZodArray<z.ZodString>>;
2524
2034
  lastActivityAt: z.ZodOptional<z.ZodISODateTime>;
2035
+ }, z.core.$strict>, z.ZodObject<{
2036
+ type: z.ZodLiteral<"document">;
2037
+ summary: z.ZodOptional<z.ZodString>;
2038
+ owner: z.ZodOptional<z.ZodString>;
2039
+ modifiedAt: z.ZodOptional<z.ZodISODateTime>;
2525
2040
  }, z.core.$strict>, z.ZodObject<{
2526
2041
  type: z.ZodLiteral<"message">;
2042
+ summary: z.ZodOptional<z.ZodString>;
2527
2043
  channel: z.ZodOptional<z.ZodString>;
2528
2044
  author: z.ZodOptional<z.ZodString>;
2529
2045
  sentAt: z.ZodOptional<z.ZodISODateTime>;
2046
+ }, z.core.$strict>, z.ZodObject<{
2047
+ type: z.ZodLiteral<"web_page">;
2048
+ summary: z.ZodOptional<z.ZodString>;
2049
+ siteName: z.ZodOptional<z.ZodString>;
2050
+ author: z.ZodOptional<z.ZodString>;
2051
+ thumbnailUrl: z.ZodOptional<z.ZodString>;
2530
2052
  }, z.core.$strict>, z.ZodObject<{
2531
2053
  type: z.ZodLiteral<"person">;
2054
+ summary: z.ZodOptional<z.ZodString>;
2532
2055
  email: z.ZodOptional<z.ZodString>;
2533
2056
  slackHandle: z.ZodOptional<z.ZodString>;
2534
2057
  githubHandle: z.ZodOptional<z.ZodString>;
@@ -2580,173 +2103,805 @@ export interface ToolAnnotations {
2580
2103
  readOnlyHint?: boolean;
2581
2104
  title?: string;
2582
2105
  }
2583
- export declare const REQUIRED_TOOL_ANNOTATION_KEYS: readonly ["destructiveHint", "idempotentHint", "openWorldHint", "readOnlyHint"];
2584
- export type RequiredToolAnnotationKey = (typeof REQUIRED_TOOL_ANNOTATION_KEYS)[number];
2585
- /** Return behavioral annotation keys that a tool did not declare. */
2586
- export declare function missingToolAnnotationKeys(annotations: ToolAnnotations | undefined): RequiredToolAnnotationKey[];
2106
+ export declare const REQUIRED_TOOL_ANNOTATION_KEYS: readonly ["destructiveHint", "idempotentHint", "openWorldHint", "readOnlyHint"];
2107
+ export type RequiredToolAnnotationKey = (typeof REQUIRED_TOOL_ANNOTATION_KEYS)[number];
2108
+ /** Return behavioral annotation keys that a tool did not declare. */
2109
+ export declare function missingToolAnnotationKeys(annotations: ToolAnnotations | undefined): RequiredToolAnnotationKey[];
2110
+ /**
2111
+ * Canonical approval metadata declared by core and plugin tools.
2112
+ */
2113
+ export interface ToolApprovalMetadata<TInput = unknown> {
2114
+ /** Optional declared approval mode; the owning tool boundary selects defaults. */
2115
+ approvalMode?: ToolApprovalMode;
2116
+ annotations?: ToolAnnotations;
2117
+ /**
2118
+ * Describe the reviewed semantic action for the review request.
2119
+ *
2120
+ * Core owns authoritative tool, actor, source, destination, conversation,
2121
+ * credential, and input data. This description adds domain-specific context
2122
+ * only and is never an authorization grant.
2123
+ */
2124
+ describeProposal?(input: TInput): string;
2125
+ }
2126
+ /**
2127
+ * Control who may call a tool.
2128
+ *
2129
+ * | Exposure | Model tool list | Tool catalog | Code Mode script |
2130
+ * | ----------- | --------------- | ------------ | ---------------- |
2131
+ * | `direct` | yes | yes | yes |
2132
+ * | `deferred` | no | yes | yes |
2133
+ * | `modelOnly` | yes | no | no |
2134
+ * | `codemode` | no | no | yes |
2135
+ * | `hidden` | no | no | no |
2136
+ *
2137
+ * The tool catalog is `searchTools` and `executeTool`. Use `modelOnly` for
2138
+ * tools that control the agent loop or dispatch other tools.
2139
+ */
2140
+ export type ToolExposure = "direct" | "deferred" | "modelOnly" | "codemode" | "hidden";
2141
+ export interface PluginToolDefinition<TInput = unknown, TOutput = unknown, TExecuteOutput = TOutput> extends ToolApprovalMetadata<TInput> {
2142
+ description: string;
2143
+ /**
2144
+ * Why the current Turn cannot run this tool. The host keeps the tool in the
2145
+ * tool list, so the cached prompt stays the same, and rejects its calls.
2146
+ */
2147
+ disabledReason?: string;
2148
+ executionMode?: unknown;
2149
+ /** Override the host's default tool exposure. */
2150
+ exposure?: ToolExposure;
2151
+ inputSchema: unknown;
2152
+ outputSchema?: unknown;
2153
+ /**
2154
+ * Select result fields that are safe to retain in private traces.
2155
+ * Returning `undefined` suppresses private result capture.
2156
+ */
2157
+ privateTraceResult?(result: TOutput): unknown;
2158
+ prepareArguments?: (args: unknown) => TInput;
2159
+ /**
2160
+ * @deprecated Put tool-selection and usage guidance directly in `description`
2161
+ * and parameter descriptions. Retained for compatibility; may be removed in a
2162
+ * future major version.
2163
+ */
2164
+ promptGuidelines?: string[];
2165
+ /**
2166
+ * @deprecated Put tool-selection and usage guidance directly in `description`
2167
+ * and parameter descriptions. Retained for compatibility; may be removed in a
2168
+ * future major version.
2169
+ */
2170
+ promptSnippet?: string;
2171
+ execute?: PluginToolExecute<TInput, TExecuteOutput>;
2172
+ }
2173
+ type ZodPluginToolDefinition<TInputSchema extends ZodTypeAny, TOutputSchema extends ZodTypeAny, TExecuteResult extends z.input<TOutputSchema> | PluginToolOutputEnvelope<z.input<TOutputSchema>>> = Omit<PluginToolDefinition<z.output<TInputSchema>, z.output<TOutputSchema>>, "inputSchema" | "outputSchema" | "prepareArguments" | "execute"> & {
2174
+ inputSchema: TInputSchema;
2175
+ outputSchema: TOutputSchema;
2176
+ prepareArguments?: (args: unknown) => z.input<TInputSchema>;
2177
+ execute?: (input: z.output<TInputSchema>, options: PluginToolExecuteOptions) => Promise<TExecuteResult> | TExecuteResult;
2178
+ };
2179
+ type ParsedPluginToolExecuteResult<TOutputSchema extends ZodTypeAny, TResult> = TResult extends PluginToolOutputEnvelope<unknown> ? PluginToolOutputEnvelope<z.output<TOutputSchema>> : z.output<TOutputSchema>;
2180
+ /** Define a plugin tool with Zod input parsing and validated structured results. */
2181
+ export declare function zodTool<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>>;
2182
+ /** Define a plugin tool with Zod input parsing and the structured result contract. */
2183
+ 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>>;
2184
+ export interface SlackToolRegistrationHookContext {
2185
+ /**
2186
+ * What Slack tools can do in the Conversation Location.
2187
+ * Computed from Location, not from Source or Destination.
2188
+ */
2189
+ channelCapabilities: {
2190
+ canAddReactions: boolean;
2191
+ canCreateCanvas: boolean;
2192
+ canPostToChannel: boolean;
2193
+ };
2194
+ credentialSubject?: Extract<PluginCredentialSubject, {
2195
+ allowedWhen: "private-direct-conversation";
2196
+ }>;
2197
+ }
2198
+ export interface PluginEventToolContext {
2199
+ /** Whether this invocation can create a working watch. */
2200
+ canSubscribe: boolean;
2201
+ /** Create a temporary watch for the current conversation. */
2202
+ subscribe(input: {
2203
+ events: string[];
2204
+ intent: string;
2205
+ resource: SubscribableResource;
2206
+ /**
2207
+ * Guidance for this Watch only, by event type. Core adds it after the
2208
+ * resource type guidance when a matching Event arrives.
2209
+ */
2210
+ guidance?: Partial<Record<string, string>>;
2211
+ }): Promise<WatchResult>;
2212
+ }
2213
+ export interface PluginWorkspaceToolContext {
2214
+ /**
2215
+ * Workspace that the current Sandbox started from. Returns undefined for
2216
+ * the default Sandbox. `name` is missing when the recipe no longer exists.
2217
+ */
2218
+ active(): Promise<{
2219
+ name?: string;
2220
+ } | undefined>;
2221
+ /** Find named Workspaces that include one provider repository. */
2222
+ findByRepository(input: {
2223
+ provider: string;
2224
+ repo: string;
2225
+ }): Promise<string[]>;
2226
+ }
2227
+ interface BaseToolRegistrationHookContext extends PluginContext {
2228
+ /**
2229
+ * Opaque Junior conversation/session identity for this turn.
2230
+ * Interactive Slack turns use `slack:{channelId}:{threadTs}`.
2231
+ * Scheduled/web turns use an internal id such as `agent-dispatch:{id}`.
2232
+ * Do not parse as Slack unless the value starts with `slack:`.
2233
+ */
2234
+ conversationId?: string;
2235
+ annotations?: PluginAnnotations;
2236
+ /** Host-owned dashboard link to the Automation that started this run. */
2237
+ automationLink?: {
2238
+ url: string;
2239
+ };
2240
+ /** Host-owned dashboard link to this conversation, when the dashboard is enabled. */
2241
+ conversationLink?: {
2242
+ url: string;
2243
+ };
2244
+ /** Decision model for narrow choices, such as checks on text a tool writes. */
2245
+ decider: PluginDecider;
2246
+ embedder: PluginEmbedder;
2247
+ egress: PluginEgress;
2248
+ mcp?: PluginMcp;
2249
+ model: PluginModel;
2250
+ events: PluginEventToolContext;
2251
+ /** Sandbox filesystem and command capability for plugin-owned workspace tools. */
2252
+ sandbox: PluginSandbox;
2253
+ state: PluginState;
2254
+ users: {
2255
+ /** Resolve the current actor's stored identity and linked user. */
2256
+ resolveActor(): Promise<{
2257
+ identity: Identity;
2258
+ user?: User;
2259
+ } | undefined>;
2260
+ /**
2261
+ * Resolve the current actor's IANA timezone. Uses their profile when
2262
+ * Junior knows it, else the install default. Always returns a timezone.
2263
+ */
2264
+ resolveTimezone(): Promise<string>;
2265
+ };
2266
+ userText?: string;
2267
+ workspaces: PluginWorkspaceToolContext;
2268
+ }
2269
+ export type ToolRegistrationHookContext = BaseToolRegistrationHookContext & InvocationContext & {
2270
+ /** Slack tool details when the Conversation has a Slack Location. */
2271
+ slack?: SlackToolRegistrationHookContext;
2272
+ };
2273
+ /** Which URLs a link type claims. Give at most one path field. */
2274
+ export declare const objectLinkFilterSchema: z.ZodObject<{
2275
+ scheme: z.ZodOptional<z.ZodEnum<{
2276
+ http: "http";
2277
+ https: "https";
2278
+ mailto: "mailto";
2279
+ }>>;
2280
+ host: z.ZodOptional<z.ZodString>;
2281
+ path: z.ZodOptional<z.ZodString>;
2282
+ pathPattern: z.ZodOptional<z.ZodString>;
2283
+ pathPrefix: z.ZodOptional<z.ZodString>;
2284
+ }, z.core.$strict>;
2285
+ export type ObjectLinkFilter = z.output<typeof objectLinkFilterSchema>;
2286
+ /** Return whether a filter claims a URL. A trailing slash does not count. */
2287
+ export declare function objectLinkFilterMatches(filter: ObjectLinkFilter, url: URL): boolean;
2587
2288
  /**
2588
- * Canonical approval metadata declared by core and plugin tools.
2289
+ * Rank how specific a filter is. Compare ranks in order: an exact host
2290
+ * before a wildcard host, an exact path before a pattern before a prefix,
2291
+ * and then the longer match.
2589
2292
  */
2590
- export interface ToolApprovalMetadata<TInput = unknown> {
2591
- /** Optional declared approval mode; the owning tool boundary selects defaults. */
2592
- approvalMode?: ToolApprovalMode;
2593
- annotations?: ToolAnnotations;
2293
+ export declare function objectLinkFilterSpecificity(filter: ObjectLinkFilter): number[];
2294
+ /** Trusted host context for one link resolution. */
2295
+ export interface ObjectLinkContext extends PluginContext {
2594
2296
  /**
2595
- * Describe the reviewed semantic action for the review request.
2596
- *
2597
- * Core owns authoritative tool, actor, source, destination, conversation,
2598
- * credential, and input data. This description adds domain-specific context
2599
- * only and is never an authorization grant.
2297
+ * Provider egress as a system Actor. It gets only credentials that the
2298
+ * plugin owns, such as an app or Junior's own account, and never the
2299
+ * viewer's credentials. Check that the viewer may see the object before
2300
+ * you return it.
2600
2301
  */
2601
- describeProposal?(input: TInput): string;
2302
+ egress: PluginEgress;
2303
+ /** The signed-in person who sees the card. */
2304
+ viewer: User;
2602
2305
  }
2603
2306
  /**
2604
- * Control who may call a tool.
2605
- *
2606
- * | Exposure | Model tool list | Tool catalog | Code Mode script |
2607
- * | ----------- | --------------- | ------------ | ---------------- |
2608
- * | `direct` | yes | yes | yes |
2609
- * | `deferred` | no | yes | yes |
2610
- * | `modelOnly` | yes | no | no |
2611
- * | `codemode` | no | no | yes |
2612
- * | `hidden` | no | no | no |
2613
- *
2614
- * The tool catalog is `searchTools` and `executeTool`. Use `modelOnly` for
2615
- * tools that control the agent loop or dispatch other tools.
2307
+ * One link type of a plugin. Return nothing when the viewer cannot read the
2308
+ * object, so the card does not show that it exists. Junior does not save the
2309
+ * result.
2616
2310
  */
2617
- export type ToolExposure = "direct" | "deferred" | "modelOnly" | "codemode" | "hidden";
2618
- export interface PluginToolDefinition<TInput = unknown, TOutput = unknown, TExecuteOutput = TOutput> extends ToolApprovalMetadata<TInput> {
2619
- description: string;
2620
- /**
2621
- * Why the current Turn cannot run this tool. The host keeps the tool in the
2622
- * tool list, so the cached prompt stays the same, and rejects its calls.
2623
- */
2624
- disabledReason?: string;
2625
- executionMode?: unknown;
2626
- /** Override the host's default tool exposure. */
2627
- exposure?: ToolExposure;
2628
- inputSchema: unknown;
2629
- outputSchema?: unknown;
2630
- /**
2631
- * Select result fields that are safe to retain in private traces.
2632
- * Returning `undefined` suppresses private result capture.
2633
- */
2634
- privateTraceResult?(result: TOutput): unknown;
2635
- prepareArguments?: (args: unknown) => TInput;
2311
+ export interface PluginObjectLinkDefinition {
2312
+ filters: ObjectLinkFilter[];
2313
+ objectType: ObjectType;
2314
+ resolve(ctx: ObjectLinkContext, url: URL): Promise<ObjectAnnotation | undefined>;
2636
2315
  /**
2637
- * @deprecated Put tool-selection and usage guidance directly in `description`
2638
- * and parameter descriptions. Retained for compatibility; may be removed in a
2639
- * future major version.
2316
+ * The plugin tool that reads the object live, such as `readGoogleFile`.
2317
+ * When a person attaches the link to a Conversation, its next Turn is told
2318
+ * to read the object with this tool. Omit it when no tool reads the object.
2640
2319
  */
2641
- promptGuidelines?: string[];
2320
+ readTool?: string;
2321
+ }
2322
+ export declare const codeChangeStateSchema: z.ZodEnum<{
2323
+ closed: "closed";
2324
+ merged: "merged";
2325
+ open: "open";
2326
+ }>;
2327
+ export type CodeChangeState = z.output<typeof codeChangeStateSchema>;
2328
+ export declare const codeChangeInputSchema: z.ZodObject<{
2329
+ closedAt: z.ZodOptional<z.ZodDate>;
2330
+ conversationIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
2331
+ draft: z.ZodOptional<z.ZodBoolean>;
2332
+ mergedAt: z.ZodOptional<z.ZodDate>;
2333
+ number: z.ZodNumber;
2334
+ openedAt: z.ZodDate;
2335
+ providerId: z.ZodString;
2336
+ repository: z.ZodObject<{
2337
+ name: z.ZodString;
2338
+ providerId: z.ZodString;
2339
+ url: z.ZodOptional<z.ZodString>;
2340
+ }, z.core.$strict>;
2341
+ state: z.ZodEnum<{
2342
+ closed: "closed";
2343
+ merged: "merged";
2344
+ open: "open";
2345
+ }>;
2346
+ title: z.ZodOptional<z.ZodString>;
2347
+ updatedAt: z.ZodDate;
2348
+ url: z.ZodOptional<z.ZodString>;
2349
+ }, z.core.$strict>;
2350
+ export type CodeChangeInput = z.input<typeof codeChangeInputSchema>;
2351
+ /** Write code changes from a plugin to Junior's code records. */
2352
+ export interface CodeChangePublisher {
2353
+ associateConversations(input: {
2354
+ conversationIds: string[];
2355
+ providerId: string;
2356
+ }): Promise<void>;
2357
+ record(input: CodeChangeInput): Promise<void>;
2642
2358
  /**
2643
- * @deprecated Put tool-selection and usage guidance directly in `description`
2644
- * and parameter descriptions. Retained for compatibility; may be removed in a
2645
- * future major version.
2359
+ * Record a push, review, or comment by a person on a code change. Junior
2360
+ * ignores activity on code changes that it did not record.
2646
2361
  */
2647
- promptSnippet?: string;
2648
- execute?: PluginToolExecute<TInput, TExecuteOutput>;
2362
+ recordActivity(input: {
2363
+ at: Date;
2364
+ number: number;
2365
+ repositoryProviderId: string;
2366
+ }): Promise<void>;
2367
+ }
2368
+ export declare const conversationEventIconSchema: z.ZodEnum<{
2369
+ activity: "activity";
2370
+ brain: "brain";
2371
+ calendar: "calendar";
2372
+ check: "check";
2373
+ database: "database";
2374
+ info: "info";
2375
+ key: "key";
2376
+ link: "link";
2377
+ sparkles: "sparkles";
2378
+ warning: "warning";
2379
+ }>;
2380
+ /** Safe, core-rendered presentation for one plugin conversation event. */
2381
+ export declare const conversationEventPresentationSchema: z.ZodObject<{
2382
+ details: z.ZodOptional<z.ZodArray<z.ZodObject<{
2383
+ content: z.ZodOptional<z.ZodString>;
2384
+ description: z.ZodOptional<z.ZodString>;
2385
+ metadata: z.ZodOptional<z.ZodArray<z.ZodString>>;
2386
+ title: z.ZodString;
2387
+ }, z.core.$strict>>>;
2388
+ icon: z.ZodOptional<z.ZodEnum<{
2389
+ activity: "activity";
2390
+ brain: "brain";
2391
+ calendar: "calendar";
2392
+ check: "check";
2393
+ database: "database";
2394
+ info: "info";
2395
+ key: "key";
2396
+ link: "link";
2397
+ sparkles: "sparkles";
2398
+ warning: "warning";
2399
+ }>>;
2400
+ preview: z.ZodOptional<z.ZodString>;
2401
+ title: z.ZodString;
2402
+ }, z.core.$strict>;
2403
+ export type ConversationEventPresentation = z.output<typeof conversationEventPresentationSchema>;
2404
+ /** One validated plugin event value waiting for conversation-bound emission. */
2405
+ export interface PluginConversationEventValue {
2406
+ readonly data: Record<string, unknown>;
2407
+ readonly definition: PluginConversationEventDefinition;
2408
+ }
2409
+ /** Registered schema and optional transcript presentation for one event version. */
2410
+ export interface PluginConversationEventDefinition {
2411
+ readonly eventName: string;
2412
+ readonly version: number;
2413
+ parse(data: unknown): Record<string, unknown>;
2414
+ renderEvent(data: Record<string, unknown>): ConversationEventPresentation | undefined;
2415
+ }
2416
+ /** Typed factory returned while authoring one plugin conversation event. */
2417
+ export interface DefinedConversationEvent<TInput> extends PluginConversationEventDefinition {
2418
+ (data: TInput): PluginConversationEventValue;
2419
+ }
2420
+ /** Define one typed, versioned plugin-owned conversation event. */
2421
+ export declare function defineConversationEvent<TSchema extends z.ZodType<Record<string, unknown>>>(definition: {
2422
+ name: string;
2423
+ version: number;
2424
+ schema: TSchema;
2425
+ renderEvent(event: z.output<TSchema>): z.input<typeof conversationEventPresentationSchema> | undefined;
2426
+ }): DefinedConversationEvent<z.input<TSchema>>;
2427
+ /** Conversation-bound event writer supplied by Junior core. */
2428
+ export interface PluginConversationEvents {
2429
+ emit(event: PluginConversationEventValue): Promise<void>;
2430
+ }
2431
+ export interface PluginConversationEventCostDay {
2432
+ costUsd: number;
2433
+ date: string;
2434
+ events: number;
2435
+ }
2436
+ export interface PluginConversationEventRecord {
2437
+ content: Record<string, unknown>;
2438
+ createdAt: string;
2439
+ /** Position in the Conversation's events. The transcript opens there. */
2440
+ seq: number;
2441
+ /** Turn that emitted the event. Events from outside a Turn have none. */
2442
+ turnId?: string;
2443
+ version: number;
2444
+ }
2445
+ /** Read events owned by the current plugin namespace after Conversation access checks. */
2446
+ export interface PluginConversationEventReader {
2447
+ list(input: {
2448
+ conversationId: string;
2449
+ eventName: string;
2450
+ viewer: User;
2451
+ }): Promise<PluginConversationEventRecord[] | undefined>;
2452
+ }
2453
+ /**
2454
+ * Events that Junior writes in a plugin's namespace for the cost of each
2455
+ * priced `model`, `decider`, `embedder`, or `reranker` call in a
2456
+ * Conversation, by the context that made the call. Junior counts them in
2457
+ * Conversation cost, so plugin events must not repeat that cost. A plugin
2458
+ * cannot register these names. It can read their costs through
2459
+ * `PluginConversationEventStats`.
2460
+ */
2461
+ export declare const pluginModelCostEventNames: {
2462
+ readonly afterToolExecute: "after_tool_execute_model_called";
2463
+ readonly task: "task_model_called";
2464
+ readonly tool: "tool_model_called";
2465
+ readonly userPrompt: "user_prompt_model_called";
2466
+ };
2467
+ /** Whether an event name is one of `pluginModelCostEventNames`. */
2468
+ export declare function isPluginModelCostEventName(eventName: string): boolean;
2469
+ /**
2470
+ * Read aggregate costs for events owned by the current plugin namespace:
2471
+ * registered events and `pluginModelCostEventNames`.
2472
+ */
2473
+ export interface PluginConversationEventStats {
2474
+ costsByDay(input: {
2475
+ days: 7 | 30 | 90;
2476
+ eventName: string;
2477
+ }): Promise<PluginConversationEventCostDay[]>;
2478
+ costsByHour(input: {
2479
+ eventName: string;
2480
+ hours?: number;
2481
+ }): Promise<PluginConversationEventCostDay[]>;
2649
2482
  }
2650
- type ZodPluginToolDefinition<TInputSchema extends ZodTypeAny, TOutputSchema extends ZodTypeAny, TExecuteResult extends z.input<TOutputSchema> | PluginToolOutputEnvelope<z.input<TOutputSchema>>> = Omit<PluginToolDefinition<z.output<TInputSchema>, z.output<TOutputSchema>>, "inputSchema" | "outputSchema" | "prepareArguments" | "execute"> & {
2651
- inputSchema: TInputSchema;
2652
- outputSchema: TOutputSchema;
2653
- prepareArguments?: (args: unknown) => z.input<TInputSchema>;
2654
- execute?: (input: z.output<TInputSchema>, options: PluginToolExecuteOptions) => Promise<TExecuteResult> | TExecuteResult;
2483
+ export declare const promptMessageSchema: z.ZodObject<{
2484
+ text: z.ZodString;
2485
+ }, z.core.$strict>;
2486
+ /** Small plugin-owned prompt text block rendered by Junior core. */
2487
+ type PromptMessage = z.output<typeof promptMessageSchema>;
2488
+ export declare const promptContextSchema: z.ZodObject<{
2489
+ kind: z.ZodString;
2490
+ version: z.ZodNumber;
2491
+ content: z.ZodRecord<z.ZodString, z.ZodUnknown>;
2492
+ }, z.core.$strict>;
2493
+ /** Structured plugin context retained alongside its model-visible rendering. */
2494
+ type PromptContext = z.output<typeof promptContextSchema>;
2495
+ /** Runtime contribution produced from one validated plugin context value. */
2496
+ interface PromptContextContribution {
2497
+ context: PromptContext;
2498
+ renderPrompt(): string;
2499
+ }
2500
+ /** Define one typed, versioned plugin context contribution. */
2501
+ export declare function definePromptContext<TSchema extends z.ZodType<Record<string, unknown>>>(definition: {
2502
+ kind: string;
2503
+ version: number;
2504
+ schema: TSchema;
2505
+ renderPrompt(content: z.output<TSchema>): string;
2506
+ }): (content: z.input<TSchema>) => PromptContextContribution;
2507
+ /** One request-scoped plugin contribution to the model-visible user prompt. */
2508
+ type UserPromptContribution = PromptMessage | PromptContextContribution;
2509
+ /** Stable platform context for plugin system prompt guidance. */
2510
+ type SystemPromptContext = Pick<PluginContext, "db" | "log" | "plugin"> & {
2511
+ platform: Platform;
2655
2512
  };
2656
- type ParsedPluginToolExecuteResult<TOutputSchema extends ZodTypeAny, TResult> = TResult extends PluginToolOutputEnvelope<unknown> ? PluginToolOutputEnvelope<z.output<TOutputSchema>> : z.output<TOutputSchema>;
2657
- /** Define a plugin tool with Zod input parsing and validated structured results. */
2658
- export declare function zodTool<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>>;
2659
- /** Define a plugin tool with Zod input parsing and the structured result contract. */
2660
- 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>>;
2661
- export interface SlackToolRegistrationHookContext {
2513
+ /** Runtime facts available while building plugin user prompt context. */
2514
+ type UserPromptContext = Pick<PluginContext, "db" | "log" | "plugin"> & {
2515
+ conversationId?: string;
2516
+ destination: Destination;
2517
+ embedder: PluginEmbedder;
2518
+ /** Conversation-bound event writer when the prompt belongs to a durable turn. */
2519
+ events?: PluginConversationEvents;
2520
+ model: PluginModel;
2521
+ /** Host reranker bound to the configured reranking model. */
2522
+ reranker: PluginReranker;
2662
2523
  /**
2663
- * What Slack tools can do in the Conversation Location.
2664
- * Computed from Location, not from Source or Destination.
2524
+ * Record numeric diagnostics on the host span for this hook. Keys must
2525
+ * start with `app.<plugin name>.`; the host drops other keys and
2526
+ * non-finite values.
2665
2527
  */
2666
- channelCapabilities: {
2667
- canAddReactions: boolean;
2668
- canCreateCanvas: boolean;
2669
- canPostToChannel: boolean;
2528
+ setSpanAttributes(attributes: Record<string, number>): void;
2529
+ /** Location associated with this Conversation. */
2530
+ locationId?: string;
2531
+ actor?: Actor;
2532
+ source: Source;
2533
+ state: PluginState;
2534
+ text: string;
2535
+ users: {
2536
+ /** Resolve the current Actor's Identity and User. */
2537
+ resolveActor(): Promise<{
2538
+ identity: Identity;
2539
+ user?: User;
2540
+ } | undefined>;
2670
2541
  };
2671
- credentialSubject?: Extract<PluginCredentialSubject, {
2672
- allowedWhen: "private-direct-conversation";
2673
- }>;
2542
+ };
2543
+ export type DestinationVisibility = z.output<typeof destinationVisibilitySchema>;
2544
+ export type DispatchOptions = z.output<typeof dispatchOptionsSchema>;
2545
+ /** Compact destination-visible context explaining what produced a reply. */
2546
+ export type ReplyAttribution = z.output<typeof replyAttributionSchema>;
2547
+ export type TaskOutcome = z.output<typeof taskOutcomeSchema>;
2548
+ export interface DispatchResult {
2549
+ id: string;
2550
+ status: "created" | "already_exists";
2674
2551
  }
2675
- export interface PluginEventToolContext {
2676
- /** Whether this invocation can create a working watch. */
2677
- canSubscribe: boolean;
2678
- /** Create a temporary watch for the current conversation. */
2679
- subscribe(input: {
2680
- events: string[];
2681
- intent: string;
2682
- resource: SubscribableResource;
2683
- /**
2684
- * Guidance for this Watch only, by event type. Core adds it after the
2685
- * resource type guidance when a matching Event arrives.
2686
- */
2687
- guidance?: Partial<Record<string, string>>;
2688
- }): Promise<WatchResult>;
2552
+ export interface Dispatch {
2553
+ errorMessage?: string;
2554
+ id: string;
2555
+ resultMessageTs?: string;
2556
+ status: "pending" | "running" | "awaiting_resume" | "completed" | "failed" | "blocked";
2689
2557
  }
2690
- export interface PluginWorkspaceToolContext {
2558
+ type EventMatchField = EventMatchFields[string];
2559
+ /** One reason a selection of events and filters cannot work. */
2560
+ export interface EventTriggerProblem {
2691
2561
  /**
2692
- * Workspace that the current Sandbox started from. Returns undefined for
2693
- * the default Sandbox. `name` is missing when the recipe no longer exists.
2562
+ * - `unknown_resource_type`: the source has no such enabled resource type.
2563
+ * - `unknown_event`: the resource type has no such event.
2564
+ * - `identifier_required`: a trigger with no identifier selects an event
2565
+ * that cannot run for every resource.
2566
+ * - `filter_required`: a trigger with no identifier selects an event whose
2567
+ * reach names filters, and the trigger sets none of them.
2568
+ * - `unknown_field`: the resource type has no such filter. Saved triggers
2569
+ * get this after a plugin renames or removes a filter.
2570
+ * - `field_not_set`: a selected event never sets the filter, so the filter
2571
+ * never matches that event.
2572
+ * - `invalid_value`: the filter value has the wrong type or is not allowed.
2694
2573
  */
2695
- active(): Promise<{
2696
- name?: string;
2697
- } | undefined>;
2698
- /** Find named Workspaces that include one provider repository. */
2699
- findByRepository(input: {
2700
- provider: string;
2701
- repo: string;
2702
- }): Promise<string[]>;
2574
+ reason: "unknown_resource_type" | "unknown_event" | "identifier_required" | "filter_required" | "unknown_field" | "field_not_set" | "invalid_value";
2575
+ /** The filter with the problem. Missing for a resource type or event problem. */
2576
+ field?: string;
2577
+ /** Plain words for the person or agent who changes the selection. */
2578
+ message: string;
2703
2579
  }
2704
- interface BaseToolRegistrationHookContext extends PluginContext {
2580
+ /**
2581
+ * The selection to check: one resource type, its events, and its filters.
2582
+ * Leave out the resource type for a trigger with no identifier. It runs for
2583
+ * every resource of the source that its filters match.
2584
+ */
2585
+ export interface EventTriggerSelection {
2586
+ resourceType?: string;
2587
+ events: readonly string[];
2588
+ match?: EventMatch;
2589
+ }
2590
+ /** The enabled resource types of one source, and the reach of each of its events. */
2591
+ export interface EventTriggerSource {
2592
+ resourceTypes: readonly Pick<PluginEventType, "type" | "matchFields" | "supportedEvents">[];
2593
+ events: Readonly<Record<string, {
2594
+ reach: EventReach;
2595
+ }>>;
2705
2596
  /**
2706
- * Opaque Junior conversation/session identity for this turn.
2707
- * Interactive Slack turns use `slack:{channelId}:{threadTs}`.
2708
- * Scheduled/web turns use an internal id such as `agent-dispatch:{id}`.
2709
- * Do not parse as Slack unless the value starts with `slack:`.
2597
+ * The filters of every resource type, for a trigger with no identifier.
2598
+ * Merge them once with `anyResourceMatchFields` when the catalog is built,
2599
+ * not for each check.
2710
2600
  */
2711
- conversationId?: string;
2712
- annotations?: PluginAnnotations;
2713
- /** Host-owned dashboard link to the Automation that started this run. */
2714
- automationLink?: {
2715
- url: string;
2716
- };
2717
- /** Host-owned dashboard link to this conversation, when the dashboard is enabled. */
2718
- conversationLink?: {
2719
- url: string;
2720
- };
2721
- /** Decision model for narrow choices, such as checks on text a tool writes. */
2722
- decider: PluginDecider;
2601
+ anyResourceFields: EventMatchFields;
2602
+ }
2603
+ /** The events of a source that a trigger with no identifier can select. */
2604
+ export declare function anyResourceEvents(source: EventTriggerSource): string[];
2605
+ /** Return the selected events that never set one filter field. */
2606
+ export declare function eventsWithoutMatchField(field: Pick<EventMatchField, "events">, events: readonly string[]): string[];
2607
+ /**
2608
+ * Return the events and filters that a selection can use: those of its
2609
+ * resource type, or with no resource type, the events whose reach is not
2610
+ * `"resource"`, with the filters of every resource type. Return nothing when the source
2611
+ * has no such resource type or cannot run for every resource.
2612
+ */
2613
+ export declare function eventTriggerChoices(source: EventTriggerSource, selection: Pick<EventTriggerSelection, "resourceType">): {
2614
+ events: readonly string[];
2615
+ fields: EventMatchFields;
2616
+ } | undefined;
2617
+ /**
2618
+ * List why a selection cannot work with the resource types of one source. An
2619
+ * empty list means the resource type exists, every selected event is
2620
+ * supported, and every selected event can match every filter. A filter on a
2621
+ * list field (`list: true`) matches when the event list includes the value.
2622
+ * A selection with no resource type can use only events whose reach is not
2623
+ * `"resource"`, with the filters of every resource type, and must set one of
2624
+ * the filters that the reach of each selected event names.
2625
+ * Set `inputKeys` for the agent, so messages name the snake_case
2626
+ * `match.<key>` input.
2627
+ */
2628
+ export declare function eventTriggerProblems(source: EventTriggerSource, selection: EventTriggerSelection, options?: {
2629
+ inputKeys?: boolean;
2630
+ }): EventTriggerProblem[];
2631
+ /** How people see one Event trigger. Each entry is one line of plain text. */
2632
+ export interface EventTriggerDescription {
2633
+ /** Each selected event in plain words, such as "pull request opened". */
2634
+ events: string[];
2635
+ /** Each filter in plain words. Every filter must match. */
2636
+ filters: string[];
2637
+ /** Why the trigger cannot work as saved. Empty when it can. */
2638
+ problems: string[];
2639
+ }
2640
+ /** Write one event type in plain words: `pull_request.opened` is "pull request opened". */
2641
+ export declare function eventTypeText(eventType: string): string;
2642
+ /**
2643
+ * Write one filter in plain words. A list field (`list: true`) reads
2644
+ * "authors includes alice"; other fields read "repo is api or web".
2645
+ */
2646
+ export declare function eventMatchFilterText(key: string, field: EventMatchField | undefined, value: EventMatch[string]): string;
2647
+ /**
2648
+ * Describe a selection for the dashboard and Slack, so both show the same
2649
+ * words. Pass the selection's source, as for `eventTriggerProblems`. Its
2650
+ * problems are the messages of that check.
2651
+ */
2652
+ export declare function describeEventTrigger(source: EventTriggerSource, selection: EventTriggerSelection): EventTriggerDescription;
2653
+ /** Join filters into one line. Every filter must match, so join with "and". */
2654
+ export declare function eventTriggerFiltersText(filters: readonly string[]): string;
2655
+ /**
2656
+ * Write a whole trigger as one line, for cards and lists:
2657
+ * "Pull request · pull request opened · filters: isDraft is false".
2658
+ */
2659
+ export declare function eventTriggerText(resource: string, description: Pick<EventTriggerDescription, "events" | "filters">): string;
2660
+ /**
2661
+ * Runtime-owned provenance for a transcript message: whether it is a durable
2662
+ * instruction or ambient context, plus the actor identity when known. Missing
2663
+ * provenance on an entry means unattributed context.
2664
+ */
2665
+ export declare const pluginRunTranscriptProvenanceSchema: z.ZodObject<{
2666
+ authority: z.ZodEnum<{
2667
+ context: "context";
2668
+ instruction: "instruction";
2669
+ }>;
2670
+ actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
2671
+ email: z.ZodOptional<z.ZodString>;
2672
+ fullName: z.ZodOptional<z.ZodString>;
2673
+ userId: z.ZodString;
2674
+ userName: z.ZodOptional<z.ZodString>;
2675
+ platform: z.ZodLiteral<"slack">;
2676
+ teamId: z.ZodString;
2677
+ }, z.core.$strict>, z.ZodObject<{
2678
+ email: z.ZodOptional<z.ZodString>;
2679
+ fullName: z.ZodOptional<z.ZodString>;
2680
+ userId: z.ZodString;
2681
+ userName: z.ZodOptional<z.ZodString>;
2682
+ platform: z.ZodLiteral<"local">;
2683
+ }, z.core.$strict>, z.ZodObject<{
2684
+ email: z.ZodOptional<z.ZodString>;
2685
+ fullName: z.ZodOptional<z.ZodString>;
2686
+ userId: z.ZodString;
2687
+ userName: z.ZodOptional<z.ZodString>;
2688
+ platform: z.ZodLiteral<"web">;
2689
+ }, z.core.$strict>, z.ZodObject<{
2690
+ platform: z.ZodLiteral<"system">;
2691
+ name: z.ZodString;
2692
+ }, z.core.$strict>], "platform">>;
2693
+ }, z.core.$strict>;
2694
+ /** One normalized transcript entry from the completed run exposed to plugin tasks. */
2695
+ export declare const pluginRunTranscriptEntrySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
2696
+ type: z.ZodLiteral<"message">;
2697
+ role: z.ZodEnum<{
2698
+ assistant: "assistant";
2699
+ user: "user";
2700
+ }>;
2701
+ text: z.ZodString;
2702
+ provenance: z.ZodOptional<z.ZodObject<{
2703
+ authority: z.ZodEnum<{
2704
+ context: "context";
2705
+ instruction: "instruction";
2706
+ }>;
2707
+ actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
2708
+ email: z.ZodOptional<z.ZodString>;
2709
+ fullName: z.ZodOptional<z.ZodString>;
2710
+ userId: z.ZodString;
2711
+ userName: z.ZodOptional<z.ZodString>;
2712
+ platform: z.ZodLiteral<"slack">;
2713
+ teamId: z.ZodString;
2714
+ }, z.core.$strict>, z.ZodObject<{
2715
+ email: z.ZodOptional<z.ZodString>;
2716
+ fullName: z.ZodOptional<z.ZodString>;
2717
+ userId: z.ZodString;
2718
+ userName: z.ZodOptional<z.ZodString>;
2719
+ platform: z.ZodLiteral<"local">;
2720
+ }, z.core.$strict>, z.ZodObject<{
2721
+ email: z.ZodOptional<z.ZodString>;
2722
+ fullName: z.ZodOptional<z.ZodString>;
2723
+ userId: z.ZodString;
2724
+ userName: z.ZodOptional<z.ZodString>;
2725
+ platform: z.ZodLiteral<"web">;
2726
+ }, z.core.$strict>, z.ZodObject<{
2727
+ platform: z.ZodLiteral<"system">;
2728
+ name: z.ZodString;
2729
+ }, z.core.$strict>], "platform">>;
2730
+ }, z.core.$strict>>;
2731
+ isRunActor: z.ZodOptional<z.ZodBoolean>;
2732
+ }, z.core.$strict>, z.ZodObject<{
2733
+ type: z.ZodLiteral<"toolResult">;
2734
+ toolName: z.ZodString;
2735
+ isError: z.ZodBoolean;
2736
+ text: z.ZodOptional<z.ZodString>;
2737
+ }, z.core.$strict>], "type">;
2738
+ export type PluginRunTranscriptProvenance = z.output<typeof pluginRunTranscriptProvenanceSchema>;
2739
+ /** Runtime-owned completed-run projection exposed to plugin tasks. */
2740
+ export declare const pluginRunContextSchema: z.ZodObject<{
2741
+ actorUserId: z.ZodOptional<z.ZodString>;
2742
+ completedAtMs: z.ZodNumber;
2743
+ conversationId: z.ZodString;
2744
+ destination: z.ZodDiscriminatedUnion<[z.ZodObject<{
2745
+ platform: z.ZodLiteral<"slack">;
2746
+ teamId: z.ZodString;
2747
+ channelId: z.ZodString;
2748
+ threadTs: z.ZodOptional<z.ZodString>;
2749
+ }, z.core.$strict>, z.ZodObject<{
2750
+ platform: z.ZodLiteral<"local">;
2751
+ conversationId: z.ZodString;
2752
+ }, z.core.$strict>], "platform">;
2753
+ locationId: z.ZodOptional<z.ZodString>;
2754
+ actors: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
2755
+ email: z.ZodOptional<z.ZodString>;
2756
+ fullName: z.ZodOptional<z.ZodString>;
2757
+ userId: z.ZodString;
2758
+ userName: z.ZodOptional<z.ZodString>;
2759
+ platform: z.ZodLiteral<"slack">;
2760
+ teamId: z.ZodString;
2761
+ }, z.core.$strict>, z.ZodObject<{
2762
+ email: z.ZodOptional<z.ZodString>;
2763
+ fullName: z.ZodOptional<z.ZodString>;
2764
+ userId: z.ZodString;
2765
+ userName: z.ZodOptional<z.ZodString>;
2766
+ platform: z.ZodLiteral<"local">;
2767
+ }, z.core.$strict>, z.ZodObject<{
2768
+ email: z.ZodOptional<z.ZodString>;
2769
+ fullName: z.ZodOptional<z.ZodString>;
2770
+ userId: z.ZodString;
2771
+ userName: z.ZodOptional<z.ZodString>;
2772
+ platform: z.ZodLiteral<"web">;
2773
+ }, z.core.$strict>, z.ZodObject<{
2774
+ platform: z.ZodLiteral<"system">;
2775
+ name: z.ZodString;
2776
+ }, z.core.$strict>], "platform">>;
2777
+ actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
2778
+ email: z.ZodOptional<z.ZodString>;
2779
+ fullName: z.ZodOptional<z.ZodString>;
2780
+ userId: z.ZodString;
2781
+ userName: z.ZodOptional<z.ZodString>;
2782
+ platform: z.ZodLiteral<"slack">;
2783
+ teamId: z.ZodString;
2784
+ }, z.core.$strict>, z.ZodObject<{
2785
+ email: z.ZodOptional<z.ZodString>;
2786
+ fullName: z.ZodOptional<z.ZodString>;
2787
+ userId: z.ZodString;
2788
+ userName: z.ZodOptional<z.ZodString>;
2789
+ platform: z.ZodLiteral<"local">;
2790
+ }, z.core.$strict>, z.ZodObject<{
2791
+ email: z.ZodOptional<z.ZodString>;
2792
+ fullName: z.ZodOptional<z.ZodString>;
2793
+ userId: z.ZodString;
2794
+ userName: z.ZodOptional<z.ZodString>;
2795
+ platform: z.ZodLiteral<"web">;
2796
+ }, z.core.$strict>, z.ZodObject<{
2797
+ platform: z.ZodLiteral<"system">;
2798
+ name: z.ZodString;
2799
+ }, z.core.$strict>], "platform">>;
2800
+ runId: z.ZodString;
2801
+ source: z.ZodPreprocess<z.ZodDiscriminatedUnion<[z.ZodObject<{
2802
+ kind: z.ZodLiteral<"slack">;
2803
+ teamId: z.ZodString;
2804
+ channelId: z.ZodString;
2805
+ visibility: z.ZodEnum<{
2806
+ private: "private";
2807
+ public: "public";
2808
+ }>;
2809
+ messageTs: z.ZodOptional<z.ZodString>;
2810
+ threadTs: z.ZodOptional<z.ZodString>;
2811
+ }, z.core.$strict>, z.ZodObject<{
2812
+ kind: z.ZodLiteral<"local">;
2813
+ visibility: z.ZodLiteral<"private">;
2814
+ conversationId: z.ZodString;
2815
+ }, z.core.$strict>, z.ZodObject<{
2816
+ kind: z.ZodLiteral<"web">;
2817
+ visibility: z.ZodEnum<{
2818
+ private: "private";
2819
+ public: "public";
2820
+ }>;
2821
+ conversationId: z.ZodString;
2822
+ }, z.core.$strict>, z.ZodObject<{
2823
+ kind: z.ZodLiteral<"event">;
2824
+ eventKey: z.ZodString;
2825
+ eventType: z.ZodString;
2826
+ identifier: z.ZodString;
2827
+ namespace: z.ZodString;
2828
+ }, z.core.$strict>, z.ZodObject<{
2829
+ automationId: z.ZodOptional<z.ZodString>;
2830
+ automationRunId: z.ZodOptional<z.ZodString>;
2831
+ kind: z.ZodLiteral<"scheduled_automation">;
2832
+ }, z.core.$strict>, z.ZodObject<{
2833
+ automationId: z.ZodOptional<z.ZodString>;
2834
+ automationRunId: z.ZodOptional<z.ZodString>;
2835
+ kind: z.ZodLiteral<"event_automation">;
2836
+ }, z.core.$strict>, z.ZodObject<{
2837
+ kind: z.ZodLiteral<"plugin_dispatch">;
2838
+ }, z.core.$strict>, z.ZodObject<{
2839
+ kind: z.ZodLiteral<"agent_invocation">;
2840
+ }, z.core.$strict>], "kind">, unknown>;
2841
+ transcript: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
2842
+ type: z.ZodLiteral<"message">;
2843
+ role: z.ZodEnum<{
2844
+ assistant: "assistant";
2845
+ user: "user";
2846
+ }>;
2847
+ text: z.ZodString;
2848
+ provenance: z.ZodOptional<z.ZodObject<{
2849
+ authority: z.ZodEnum<{
2850
+ context: "context";
2851
+ instruction: "instruction";
2852
+ }>;
2853
+ actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
2854
+ email: z.ZodOptional<z.ZodString>;
2855
+ fullName: z.ZodOptional<z.ZodString>;
2856
+ userId: z.ZodString;
2857
+ userName: z.ZodOptional<z.ZodString>;
2858
+ platform: z.ZodLiteral<"slack">;
2859
+ teamId: z.ZodString;
2860
+ }, z.core.$strict>, z.ZodObject<{
2861
+ email: z.ZodOptional<z.ZodString>;
2862
+ fullName: z.ZodOptional<z.ZodString>;
2863
+ userId: z.ZodString;
2864
+ userName: z.ZodOptional<z.ZodString>;
2865
+ platform: z.ZodLiteral<"local">;
2866
+ }, z.core.$strict>, z.ZodObject<{
2867
+ email: z.ZodOptional<z.ZodString>;
2868
+ fullName: z.ZodOptional<z.ZodString>;
2869
+ userId: z.ZodString;
2870
+ userName: z.ZodOptional<z.ZodString>;
2871
+ platform: z.ZodLiteral<"web">;
2872
+ }, z.core.$strict>, z.ZodObject<{
2873
+ platform: z.ZodLiteral<"system">;
2874
+ name: z.ZodString;
2875
+ }, z.core.$strict>], "platform">>;
2876
+ }, z.core.$strict>>;
2877
+ isRunActor: z.ZodOptional<z.ZodBoolean>;
2878
+ }, z.core.$strict>, z.ZodObject<{
2879
+ type: z.ZodLiteral<"toolResult">;
2880
+ toolName: z.ZodString;
2881
+ isError: z.ZodBoolean;
2882
+ text: z.ZodOptional<z.ZodString>;
2883
+ }, z.core.$strict>], "type">>;
2884
+ }, z.core.$strict>;
2885
+ export type PluginRunTranscriptEntry = z.output<typeof pluginRunTranscriptEntrySchema>;
2886
+ export type PluginRunContext = z.output<typeof pluginRunContextSchema>;
2887
+ /** Runtime context passed to a plugin-owned background task. */
2888
+ export interface PluginTaskContext extends PluginContext {
2723
2889
  embedder: PluginEmbedder;
2724
- egress: PluginEgress;
2725
- mcp?: PluginMcp;
2890
+ events: PluginConversationEvents;
2891
+ id: string;
2726
2892
  model: PluginModel;
2727
- events: PluginEventToolContext;
2728
- /** Sandbox filesystem and command capability for plugin-owned workspace tools. */
2729
- sandbox: PluginSandbox;
2730
- state: PluginState;
2731
- users: {
2732
- /** Resolve the current actor's stored identity and linked user. */
2733
- resolveActor(): Promise<{
2734
- identity: Identity;
2735
- user?: User;
2736
- } | undefined>;
2737
- /**
2738
- * Resolve the current actor's IANA timezone. Uses their profile when
2739
- * Junior knows it, else the install default. Always returns a timezone.
2740
- */
2741
- resolveTimezone(): Promise<string>;
2893
+ name: string;
2894
+ run: {
2895
+ load(): Promise<PluginRunContext>;
2742
2896
  };
2743
- userText?: string;
2744
- workspaces: PluginWorkspaceToolContext;
2897
+ state: PluginState;
2745
2898
  }
2746
- export type ToolRegistrationHookContext = BaseToolRegistrationHookContext & InvocationContext & {
2747
- /** Slack tool details when the Conversation has a Slack Location. */
2748
- slack?: SlackToolRegistrationHookContext;
2749
- };
2899
+ /** Plugin task handler registered by name in a plugin manifest module. */
2900
+ export interface PluginTaskDefinition {
2901
+ run(ctx: PluginTaskContext): Promise<void> | void;
2902
+ }
2903
+ /** Task handlers keyed by the plugin-owned task name. */
2904
+ export type PluginTasks = Record<string, PluginTaskDefinition>;
2750
2905
  /**
2751
2906
  * An item that a plugin puts on the review desk: a notice for information,
2752
2907
  * or an ask that waits on its assignees.
@@ -3353,6 +3508,8 @@ export type PluginRegistrationInput = {
3353
3508
  cli?: PluginCliDefinition;
3354
3509
  conversationEvents?: PluginConversationEventDefinition[];
3355
3510
  hooks?: PluginHooks;
3511
+ /** Images that this plugin serves through the Junior image proxy. */
3512
+ images?: PluginImageSource;
3356
3513
  manifest: PluginManifest;
3357
3514
  model?: PluginModelConfig;
3358
3515
  /** URLs that this plugin shows as object cards. */