@sentry/junior-plugin-api 0.299.0 → 0.301.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 +1373 -1131
  2. package/dist/index.js +92 -4
  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,86 +860,333 @@ 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>;
863
+ declare const pluginGrantAccessSchema: z.ZodUnion<readonly [z.ZodLiteral<"read">, z.ZodLiteral<"write">]>;
864
+ /** Runtime schema for provider authorization a plugin may request. */
865
+ export declare const pluginAuthorizationSchema: z.ZodObject<{
866
+ provider: z.ZodString;
867
+ scope: z.ZodOptional<z.ZodString>;
868
+ type: z.ZodLiteral<"oauth">;
869
+ }, z.core.$strict>;
870
+ /** Runtime schema for a provider account attached to stored OAuth tokens. */
871
+ export declare const pluginProviderAccountSchema: z.ZodObject<{
872
+ displayName: z.ZodOptional<z.ZodString>;
873
+ handle: z.ZodOptional<z.ZodString>;
874
+ id: z.ZodString;
875
+ label: z.ZodOptional<z.ZodString>;
876
+ url: z.ZodOptional<z.ZodString>;
877
+ verifiedEmails: z.ZodOptional<z.ZodArray<z.ZodString>>;
878
+ }, z.core.$strict>;
879
+ /** Runtime schema for OAuth tokens stored by the host for plugin credentials. */
880
+ export declare const pluginStoredTokensSchema: z.ZodObject<{
881
+ account: z.ZodOptional<z.ZodObject<{
882
+ displayName: z.ZodOptional<z.ZodString>;
883
+ handle: z.ZodOptional<z.ZodString>;
884
+ id: z.ZodString;
885
+ label: z.ZodOptional<z.ZodString>;
886
+ url: z.ZodOptional<z.ZodString>;
887
+ verifiedEmails: z.ZodOptional<z.ZodArray<z.ZodString>>;
888
+ }, z.core.$strict>>;
889
+ accessToken: z.ZodString;
890
+ expiresAt: z.ZodOptional<z.ZodNumber>;
891
+ refreshToken: z.ZodString;
892
+ refreshTokenExpiresAt: z.ZodOptional<z.ZodNumber>;
893
+ scope: z.ZodOptional<z.ZodString>;
805
894
  }, 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
895
  /**
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.
896
+ * Provider facts for egress audit events, such as the target repository.
897
+ * Keys use the plugin's `app.<provider>.*` names. Telemetry only.
813
898
  */
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. */
818
- viewer: User;
899
+ export declare const pluginAuditAttributesSchema: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>]>>;
900
+ /** Runtime schema for a plugin-defined outbound credential grant. */
901
+ export declare const pluginGrantSchema: z.ZodObject<{
902
+ access: z.ZodUnion<readonly [z.ZodLiteral<"read">, z.ZodLiteral<"write">]>;
903
+ auditAttributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString>]>>>;
904
+ leaseScope: z.ZodOptional<z.ZodString>;
905
+ name: z.ZodString;
906
+ reason: z.ZodOptional<z.ZodString>;
907
+ requirements: z.ZodOptional<z.ZodArray<z.ZodString>>;
908
+ }, z.core.$strict>;
909
+ /** Runtime schema for plugin-issued header mutations. */
910
+ export declare const pluginCredentialHeaderTransformSchema: z.ZodObject<{
911
+ domain: z.ZodString;
912
+ headers: z.ZodRecord<z.ZodString, z.ZodString>;
913
+ }, z.core.$strict>;
914
+ /** Runtime schema for a short-lived plugin-issued credential lease. */
915
+ export declare const pluginCredentialLeaseSchema: z.ZodObject<{
916
+ account: z.ZodOptional<z.ZodObject<{
917
+ displayName: z.ZodOptional<z.ZodString>;
918
+ handle: z.ZodOptional<z.ZodString>;
919
+ id: z.ZodString;
920
+ label: z.ZodOptional<z.ZodString>;
921
+ url: z.ZodOptional<z.ZodString>;
922
+ verifiedEmails: z.ZodOptional<z.ZodArray<z.ZodString>>;
923
+ }, z.core.$strict>>;
924
+ authorization: z.ZodOptional<z.ZodObject<{
925
+ provider: z.ZodString;
926
+ scope: z.ZodOptional<z.ZodString>;
927
+ type: z.ZodLiteral<"oauth">;
928
+ }, z.core.$strict>>;
929
+ expiresAt: z.ZodString;
930
+ headerTransforms: z.ZodArray<z.ZodObject<{
931
+ domain: z.ZodString;
932
+ headers: z.ZodRecord<z.ZodString, z.ZodString>;
933
+ }, z.core.$strict>>;
934
+ }, z.core.$strict>;
935
+ /** Runtime schema for the result returned by a plugin credential hook. */
936
+ export declare const pluginCredentialResultSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
937
+ lease: z.ZodObject<{
938
+ account: z.ZodOptional<z.ZodObject<{
939
+ displayName: z.ZodOptional<z.ZodString>;
940
+ handle: z.ZodOptional<z.ZodString>;
941
+ id: z.ZodString;
942
+ label: z.ZodOptional<z.ZodString>;
943
+ url: z.ZodOptional<z.ZodString>;
944
+ verifiedEmails: z.ZodOptional<z.ZodArray<z.ZodString>>;
945
+ }, z.core.$strict>>;
946
+ authorization: z.ZodOptional<z.ZodObject<{
947
+ provider: z.ZodString;
948
+ scope: z.ZodOptional<z.ZodString>;
949
+ type: z.ZodLiteral<"oauth">;
950
+ }, z.core.$strict>>;
951
+ expiresAt: z.ZodString;
952
+ headerTransforms: z.ZodArray<z.ZodObject<{
953
+ domain: z.ZodString;
954
+ headers: z.ZodRecord<z.ZodString, z.ZodString>;
955
+ }, z.core.$strict>>;
956
+ }, z.core.$strict>;
957
+ type: z.ZodLiteral<"lease">;
958
+ }, z.core.$strict>, z.ZodObject<{
959
+ authorization: z.ZodOptional<z.ZodObject<{
960
+ provider: z.ZodString;
961
+ scope: z.ZodOptional<z.ZodString>;
962
+ type: z.ZodLiteral<"oauth">;
963
+ }, z.core.$strict>>;
964
+ message: z.ZodString;
965
+ type: z.ZodLiteral<"needed">;
966
+ }, z.core.$strict>, z.ZodObject<{
967
+ message: z.ZodString;
968
+ type: z.ZodLiteral<"unavailable">;
969
+ }, z.core.$strict>], "type">;
970
+ export type PluginCredentialSubject = z.output<typeof pluginCredentialSubjectSchema>;
971
+ export type PluginGrantAccess = z.output<typeof pluginGrantAccessSchema>;
972
+ /** Provider authorization Junior can start when a plugin-owned grant is missing. */
973
+ export type PluginAuthorization = z.output<typeof pluginAuthorizationSchema>;
974
+ /** Interrupt sandbox egress so Junior can start provider authorization. */
975
+ export declare class EgressAuthRequired extends Error {
976
+ authorization?: PluginAuthorization;
977
+ constructor(message: string, options?: {
978
+ authorization?: PluginAuthorization;
979
+ cause?: unknown;
980
+ });
981
+ }
982
+ /** Deny provider egress before Junior issues credentials for a disallowed operation. */
983
+ export declare class EgressPolicyDenied extends Error {
984
+ /** Provider facts for the policy denial event. */
985
+ readonly auditAttributes?: PluginAuditAttributes;
986
+ constructor(message: string, options?: {
987
+ auditAttributes?: PluginAuditAttributes;
988
+ cause?: unknown;
989
+ });
990
+ }
991
+ /** Provider facts for egress audit events. */
992
+ export type PluginAuditAttributes = z.output<typeof pluginAuditAttributesSchema>;
993
+ /** Provider account identity resolved by a plugin OAuth hook. */
994
+ export type PluginProviderAccount = z.output<typeof pluginProviderAccountSchema>;
995
+ /** Plugin-defined grant required before Junior can forward one outbound request. */
996
+ export type PluginGrant = z.output<typeof pluginGrantSchema>;
997
+ /** One ref update command in a Git push. */
998
+ export interface PluginGitRefUpdate {
999
+ /** True when the push deletes the ref: its new object id is all zeros. */
1000
+ deletes: boolean;
1001
+ /** Full ref name, such as `refs/heads/main`. */
1002
+ ref: string;
819
1003
  }
1004
+ /** Why the host could not read the ref updates of a Git push. */
1005
+ export type PluginGitPushUnreadableReason = "gzip" | "malformed" | "signed" | "unterminated";
820
1006
  /**
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.
1007
+ * Ref updates of a Git smart HTTP push (`git-receive-pack`), which the host
1008
+ * reads from the body before the pack data. An `unreadable` push changes
1009
+ * refs that the host cannot name.
824
1010
  */
825
- export interface PluginObjectLinkDefinition {
826
- filters: ObjectLinkFilter[];
827
- objectType: ObjectType;
828
- resolve(ctx: ObjectLinkContext, url: URL): Promise<ObjectAnnotation | undefined>;
1011
+ export type PluginGitPush = {
1012
+ kind: "commands";
1013
+ updates: PluginGitRefUpdate[];
1014
+ } | {
1015
+ kind: "unreadable";
1016
+ reason: PluginGitPushUnreadableReason;
1017
+ };
1018
+ /** One field that a GraphQL operation selects. */
1019
+ export interface PluginGraphqlField {
1020
+ /** Names of the arguments that the field passes. */
1021
+ arguments: string[];
1022
+ /** Schema field name. An alias does not replace it. */
1023
+ name: string;
1024
+ }
1025
+ /** The GraphQL operation that one request runs. */
1026
+ export interface PluginGraphqlOperation {
1027
+ /**
1028
+ * Each distinct field that the operation selects at any depth, also through
1029
+ * fragments.
1030
+ */
1031
+ fields: PluginGraphqlField[];
1032
+ name?: string;
1033
+ /**
1034
+ * Field names at the operation root, also through fragments. There is one
1035
+ * entry for each field selection, so an aliased repeat shows twice.
1036
+ */
1037
+ rootFields: string[];
1038
+ type: "mutation" | "query" | "subscription";
829
1039
  }
830
1040
  /**
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.
1041
+ * Why the host could not read the operation of a GraphQL request:
1042
+ *
1043
+ * - `document`: the query does not parse, or it spreads a fragment that it
1044
+ * does not define.
1045
+ * - `gzip`: the body is compressed.
1046
+ * - `json`: the body is not a JSON object or a JSON array of objects.
1047
+ * - `operation`: `operationName` names no operation, or the document has more
1048
+ * than one operation and no `operationName`.
1049
+ * - `query`: the body has no `query` string, such as a persisted query hash.
1050
+ * - `too-large`: the body is larger than the host reads before it issues
1051
+ * credentials.
835
1052
  */
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
- }>>;
860
- }, 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";
1053
+ export type PluginGraphqlUnreadableReason = "document" | "gzip" | "json" | "operation" | "query" | "too-large";
1054
+ /**
1055
+ * The operations of a GraphQL POST, which the host reads from the JSON body.
1056
+ * A `batch` is a JSON array of requests. An `unreadable` request can run any
1057
+ * operation, mutations included.
1058
+ */
1059
+ export type PluginGraphqlRequest = {
1060
+ kind: "batch";
1061
+ operations: PluginGraphqlOperation[];
1062
+ } | {
1063
+ kind: "operation";
1064
+ operation: PluginGraphqlOperation;
1065
+ } | {
1066
+ kind: "unreadable";
1067
+ reason: PluginGraphqlUnreadableReason;
1068
+ };
1069
+ /** Request details available while selecting the grant for sandbox egress. */
1070
+ export interface PluginEgressRequest {
1071
+ /**
1072
+ * Capped request body text when the host exposes it for provider-specific
1073
+ * grant classification.
1074
+ */
1075
+ bodyText?: string;
1076
+ /** Set for every Git `git-receive-pack` POST. */
1077
+ gitPush?: PluginGitPush;
1078
+ /** Set for every POST to a URL path that ends in `/graphql`. */
1079
+ graphql?: PluginGraphqlRequest;
1080
+ method: string;
1081
+ /** Plugin-declared operation this request performs, used for grant classification and diagnostics. */
1082
+ operation?: string;
1083
+ url: string;
1084
+ }
1085
+ export interface EgressHookContext extends PluginContext {
1086
+ request: PluginEgressRequest;
1087
+ }
1088
+ export interface PluginEgressResponse {
1089
+ /** Snapshot of upstream response headers; mutations do not affect pass-through. */
1090
+ headers: Headers;
1091
+ readText(maxBytes: number): Promise<string | undefined>;
1092
+ status: number;
1093
+ }
1094
+ export interface EgressResponseHookContext extends PluginContext {
1095
+ grant: PluginGrant;
1096
+ permissionDenied(message: string): void;
1097
+ request: Omit<PluginEgressRequest, "bodyText" | "gitPush" | "graphql">;
1098
+ response: PluginEgressResponse;
1099
+ }
1100
+ /** Header mutations a plugin-issued credential lease may apply to owned domains. */
1101
+ export type PluginCredentialHeaderTransform = z.output<typeof pluginCredentialHeaderTransformSchema>;
1102
+ /** Short-lived credential headers issued by a plugin for a selected grant. */
1103
+ export type PluginCredentialLease = z.output<typeof pluginCredentialLeaseSchema>;
1104
+ export type PluginCredentialResult = z.output<typeof pluginCredentialResultSchema>;
1105
+ export type PluginCredentialActor = {
1106
+ platform: "system";
1107
+ name: string;
1108
+ } | {
1109
+ type: "user";
1110
+ userId: string;
1111
+ };
1112
+ export interface PluginResolvedCredentialUser {
1113
+ type: "user";
1114
+ userId: string;
1115
+ }
1116
+ export type PluginStoredTokens = z.output<typeof pluginStoredTokensSchema>;
1117
+ export interface PluginUserTokenSlot {
1118
+ get(): Promise<PluginStoredTokens | undefined>;
1119
+ set(tokens: PluginStoredTokens): Promise<void>;
1120
+ /** Run token refresh work after the host has serialized this user/provider slot, or throw after a bounded wait. */
1121
+ withRefresh<T>(callback: () => Promise<T>): Promise<T>;
1122
+ userId: string;
1123
+ }
1124
+ export interface PluginTokenStore {
1125
+ credentialSubject?: PluginUserTokenSlot;
1126
+ currentUser?: PluginUserTokenSlot;
1127
+ }
1128
+ export interface ResolveOAuthAccountHookContext extends PluginContext {
1129
+ tokens: PluginStoredTokens;
1130
+ /**
1131
+ * Parsed JSON body of the provider token response. Some providers return
1132
+ * the authorized account in this body.
1133
+ */
1134
+ tokenResponse: Record<string, unknown>;
1135
+ }
1136
+ export interface IssueCredentialHookContext extends PluginContext {
1137
+ actor: PluginCredentialActor;
1138
+ credentialSubject?: PluginResolvedCredentialUser;
1139
+ grant: PluginGrant;
1140
+ tokens: PluginTokenStore;
1141
+ }
1142
+ /**
1143
+ * Link an object to a Conversation when the owner has no typed object preview.
1144
+ * Keep a stable key, compact label, source URL, and optional short context or
1145
+ * status. Do not fetch a full object merely to save a link. Rich preview intent
1146
+ * belongs to objectAnnotationSchema, not a second set of resource-link fields.
1147
+ */
1148
+ export declare const resourceLinkAnnotationSchema: z.ZodObject<{
1149
+ kind: z.ZodLiteral<"resource_link">;
1150
+ objectType: z.ZodOptional<z.ZodEnum<{
1151
+ automation: "automation";
1152
+ calendar_event: "calendar_event";
1153
+ code_change: "code_change";
1154
+ conversation: "conversation";
1155
+ deployment: "deployment";
1156
+ document: "document";
1157
+ item: "item";
1158
+ message: "message";
1159
+ person: "person";
1160
+ task: "task";
1161
+ web_page: "web_page";
1162
+ }>>;
1163
+ key: z.ZodString;
1164
+ label: z.ZodString;
1165
+ url: z.ZodString;
1166
+ description: z.ZodOptional<z.ZodString>;
1167
+ status: z.ZodOptional<z.ZodEnum<{
1168
+ closed: "closed";
1169
+ draft: "draft";
1170
+ merged: "merged";
1171
+ open: "open";
1172
+ warning: "warning";
1173
+ }>>;
1174
+ }, z.core.$strict>;
1175
+ /** Core-known annotation shapes that plugins may attach to a conversation. */
1176
+ export declare const conversationAnnotationInputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1177
+ kind: z.ZodLiteral<"resource_link">;
1178
+ objectType: z.ZodOptional<z.ZodEnum<{
1179
+ automation: "automation";
1180
+ calendar_event: "calendar_event";
1181
+ code_change: "code_change";
1182
+ conversation: "conversation";
1183
+ deployment: "deployment";
1184
+ document: "document";
870
1185
  item: "item";
871
1186
  message: "message";
872
1187
  person: "person";
873
1188
  task: "task";
1189
+ web_page: "web_page";
874
1190
  }>>;
875
1191
  key: z.ZodString;
876
1192
  label: z.ZodString;
@@ -893,10 +1209,12 @@ export declare const conversationAnnotationInputSchema: z.ZodDiscriminatedUnion<
893
1209
  code_change: "code_change";
894
1210
  conversation: "conversation";
895
1211
  deployment: "deployment";
1212
+ document: "document";
896
1213
  item: "item";
897
1214
  message: "message";
898
1215
  person: "person";
899
1216
  task: "task";
1217
+ web_page: "web_page";
900
1218
  }>;
901
1219
  title: z.ZodString;
902
1220
  url: z.ZodNullable<z.ZodURL>;
@@ -908,6 +1226,7 @@ export declare const conversationAnnotationInputSchema: z.ZodDiscriminatedUnion<
908
1226
  sourceUpdatedAt: z.ZodOptional<z.ZodISODateTime>;
909
1227
  facts: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
910
1228
  type: z.ZodLiteral<"code_change">;
1229
+ summary: z.ZodOptional<z.ZodString>;
911
1230
  author: z.ZodOptional<z.ZodString>;
912
1231
  sourceBranch: z.ZodOptional<z.ZodString>;
913
1232
  targetBranch: z.ZodOptional<z.ZodString>;
@@ -929,6 +1248,7 @@ export declare const conversationAnnotationInputSchema: z.ZodDiscriminatedUnion<
929
1248
  previewImageUrls: z.ZodOptional<z.ZodArray<z.ZodURL>>;
930
1249
  }, z.core.$strict>, z.ZodObject<{
931
1250
  type: z.ZodLiteral<"task">;
1251
+ summary: z.ZodOptional<z.ZodString>;
932
1252
  assignees: z.ZodOptional<z.ZodArray<z.ZodString>>;
933
1253
  priority: z.ZodOptional<z.ZodString>;
934
1254
  project: z.ZodOptional<z.ZodString>;
@@ -937,25 +1257,41 @@ export declare const conversationAnnotationInputSchema: z.ZodDiscriminatedUnion<
937
1257
  labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
938
1258
  }, z.core.$strict>, z.ZodObject<{
939
1259
  type: z.ZodLiteral<"deployment">;
1260
+ summary: z.ZodOptional<z.ZodString>;
940
1261
  project: z.ZodOptional<z.ZodString>;
941
1262
  environment: z.ZodOptional<z.ZodString>;
942
1263
  revision: z.ZodOptional<z.ZodString>;
943
1264
  branch: z.ZodOptional<z.ZodString>;
944
1265
  }, z.core.$strict>, z.ZodObject<{
945
1266
  type: z.ZodLiteral<"calendar_event">;
1267
+ summary: z.ZodOptional<z.ZodString>;
946
1268
  when: z.ZodOptional<z.ZodString>;
947
1269
  attendees: z.ZodOptional<z.ZodArray<z.ZodString>>;
948
1270
  }, z.core.$strict>, z.ZodObject<{
949
1271
  type: z.ZodLiteral<"conversation">;
1272
+ summary: z.ZodOptional<z.ZodString>;
950
1273
  participants: z.ZodOptional<z.ZodArray<z.ZodString>>;
951
1274
  lastActivityAt: z.ZodOptional<z.ZodISODateTime>;
1275
+ }, z.core.$strict>, z.ZodObject<{
1276
+ type: z.ZodLiteral<"document">;
1277
+ summary: z.ZodOptional<z.ZodString>;
1278
+ owner: z.ZodOptional<z.ZodString>;
1279
+ modifiedAt: z.ZodOptional<z.ZodISODateTime>;
952
1280
  }, z.core.$strict>, z.ZodObject<{
953
1281
  type: z.ZodLiteral<"message">;
1282
+ summary: z.ZodOptional<z.ZodString>;
954
1283
  channel: z.ZodOptional<z.ZodString>;
955
1284
  author: z.ZodOptional<z.ZodString>;
956
1285
  sentAt: z.ZodOptional<z.ZodISODateTime>;
1286
+ }, z.core.$strict>, z.ZodObject<{
1287
+ type: z.ZodLiteral<"web_page">;
1288
+ summary: z.ZodOptional<z.ZodString>;
1289
+ siteName: z.ZodOptional<z.ZodString>;
1290
+ author: z.ZodOptional<z.ZodString>;
1291
+ thumbnailUrl: z.ZodOptional<z.ZodString>;
957
1292
  }, z.core.$strict>, z.ZodObject<{
958
1293
  type: z.ZodLiteral<"person">;
1294
+ summary: z.ZodOptional<z.ZodString>;
959
1295
  email: z.ZodOptional<z.ZodString>;
960
1296
  slackHandle: z.ZodOptional<z.ZodString>;
961
1297
  githubHandle: z.ZodOptional<z.ZodString>;
@@ -999,10 +1335,12 @@ export declare const conversationSidebarAnnotationSchema: z.ZodObject<{
999
1335
  code_change: "code_change";
1000
1336
  conversation: "conversation";
1001
1337
  deployment: "deployment";
1338
+ document: "document";
1002
1339
  item: "item";
1003
1340
  message: "message";
1004
1341
  person: "person";
1005
1342
  task: "task";
1343
+ web_page: "web_page";
1006
1344
  }>>;
1007
1345
  status: z.ZodOptional<z.ZodString>;
1008
1346
  key: z.ZodString;
@@ -1018,277 +1356,31 @@ export interface ConversationSidebarResult {
1018
1356
  /** Sidebar annotations in display order. Put the newest annotation first. */
1019
1357
  annotationsByConversationId: Record<string, ConversationSidebarAnnotation[]>;
1020
1358
  }
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<{
1041
- closed: "closed";
1042
- merged: "merged";
1043
- open: "open";
1359
+ export declare const EVENT_SUMMARY_MAX_LENGTH = 4000;
1360
+ export declare const EVENT_TEXT_MAX_LENGTH = 8000;
1361
+ export declare const EVENT_DATA_MAX_KEYS = 32;
1362
+ export declare const EVENT_DATA_MAX_JSON_BYTES = 4000;
1363
+ export declare const EVENT_GUIDANCE_MAX_LENGTH = 1000;
1364
+ /** Small trusted data from the plugin. The agent should not look these up again. */
1365
+ export declare const eventDataSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1366
+ /** Canonical dotted event type published and selected across plugins. */
1367
+ export declare const eventTypeSchema: z.ZodString;
1368
+ export declare const resourceTypeSchema: z.ZodString;
1369
+ /** One exact value a watch or event automation may require on trusted event data. */
1370
+ export declare const eventMatchFieldSchema: z.ZodObject<{
1371
+ kind: z.ZodEnum<{
1372
+ boolean: "boolean";
1373
+ number: "number";
1374
+ string: "string";
1044
1375
  }>;
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>;
1066
- }
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";
1078
- }>;
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>>>;
1087
- 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";
1376
+ description: z.ZodString;
1377
+ enum: z.ZodOptional<z.ZodArray<z.ZodString>>;
1378
+ list: z.ZodOptional<z.ZodLiteral<true>>;
1379
+ case: z.ZodOptional<z.ZodEnum<{
1380
+ lower: "lower";
1381
+ upper: "upper";
1098
1382
  }>>;
1099
- preview: z.ZodOptional<z.ZodString>;
1100
- title: z.ZodString;
1101
- }, 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;
1134
- }
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";
1266
- }
1267
- export declare const EVENT_SUMMARY_MAX_LENGTH = 4000;
1268
- export declare const EVENT_TEXT_MAX_LENGTH = 8000;
1269
- export declare const EVENT_DATA_MAX_KEYS = 32;
1270
- export declare const EVENT_DATA_MAX_JSON_BYTES = 4000;
1271
- export declare const EVENT_GUIDANCE_MAX_LENGTH = 1000;
1272
- /** Small trusted data from the plugin. The agent should not look these up again. */
1273
- export declare const eventDataSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1274
- /** Canonical dotted event type published and selected across plugins. */
1275
- export declare const eventTypeSchema: z.ZodString;
1276
- export declare const resourceTypeSchema: z.ZodString;
1277
- /** One exact value a watch or event automation may require on trusted event data. */
1278
- export declare const eventMatchFieldSchema: z.ZodObject<{
1279
- kind: z.ZodEnum<{
1280
- boolean: "boolean";
1281
- number: "number";
1282
- string: "string";
1283
- }>;
1284
- description: z.ZodString;
1285
- enum: z.ZodOptional<z.ZodArray<z.ZodString>>;
1286
- list: z.ZodOptional<z.ZodLiteral<true>>;
1287
- case: z.ZodOptional<z.ZodEnum<{
1288
- lower: "lower";
1289
- upper: "upper";
1290
- }>>;
1291
- events: z.ZodOptional<z.ZodArray<z.ZodString>>;
1383
+ events: z.ZodOptional<z.ZodArray<z.ZodString>>;
1292
1384
  }, z.core.$strict>;
1293
1385
  export declare const eventMatchFieldsSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
1294
1386
  kind: z.ZodEnum<{
@@ -1483,10 +1575,12 @@ export declare const eventInputSchema: z.ZodObject<{
1483
1575
  code_change: "code_change";
1484
1576
  conversation: "conversation";
1485
1577
  deployment: "deployment";
1578
+ document: "document";
1486
1579
  item: "item";
1487
1580
  message: "message";
1488
1581
  person: "person";
1489
1582
  task: "task";
1583
+ web_page: "web_page";
1490
1584
  }>>;
1491
1585
  eventKey: z.ZodString;
1492
1586
  eventType: z.ZodString;
@@ -1518,10 +1612,12 @@ export declare const eventSchema: z.ZodObject<{
1518
1612
  code_change: "code_change";
1519
1613
  conversation: "conversation";
1520
1614
  deployment: "deployment";
1615
+ document: "document";
1521
1616
  item: "item";
1522
1617
  message: "message";
1523
1618
  person: "person";
1524
1619
  task: "task";
1620
+ web_page: "web_page";
1525
1621
  }>>;
1526
1622
  eventKey: z.ZodString;
1527
1623
  eventType: z.ZodString;
@@ -1572,659 +1668,43 @@ export interface EventPublisher {
1572
1668
  identifiers: string[];
1573
1669
  }): Promise<string[]>;
1574
1670
  }
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;
1671
+ export interface PluginState {
1672
+ delete(key: string): Promise<void>;
1673
+ get<T = unknown>(key: string): Promise<T | undefined>;
1674
+ set(key: string, value: unknown, ttlMs?: number): Promise<void>;
1675
+ setIfNotExists(key: string, value: unknown, ttlMs?: number): Promise<boolean>;
1676
+ withLock<T>(key: string, ttlMs: number, callback: () => Promise<T>): Promise<T>;
1677
+ }
1678
+ export interface PluginReadState {
1679
+ get<T = unknown>(key: string): Promise<T | undefined>;
1680
+ }
1681
+ export interface PluginEnv {
1682
+ get(key: string): string | undefined;
1683
+ set(key: string, value: string): void;
1596
1684
  }
1597
1685
  /**
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.
1686
+ * Decide what happens to one tool call in `beforeToolExecute`.
1687
+ *
1688
+ * `redirect` and `deny` both stop the tool before it runs. Neither ends the
1689
+ * turn: the agent gets the message as the tool result.
1601
1690
  */
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
- }>>;
1691
+ export interface PluginDecision {
1613
1692
  /**
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.
1693
+ * Block the call as a policy refusal. The agent is told not to retry or
1694
+ * reach the same result another way, and to explain the block.
1617
1695
  */
1618
- anyResourceFields: EventMatchFields;
1696
+ deny(reason: string): void;
1697
+ /**
1698
+ * Block the call because a different path is correct, such as another
1699
+ * tool. The message tells the agent what to do instead.
1700
+ */
1701
+ redirect(message: string): void;
1702
+ replaceInput(input: Record<string, unknown>): void;
1619
1703
  }
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
1704
  /**
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.
1644
- */
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[];
1656
- }
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;
1677
- /**
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.
1681
- */
1682
- export declare const pluginRunTranscriptProvenanceSchema: z.ZodObject<{
1683
- authority: z.ZodEnum<{
1684
- context: "context";
1685
- instruction: "instruction";
1686
- }>;
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">>;
1710
- }, 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.
1705
+ * Decide what the agent reads after one tool call in `afterToolExecute`.
1706
+ *
1707
+ * The tool already ran, so neither choice undoes its effects.
2228
1708
  */
2229
1709
  export interface PluginToolResultDecision {
2230
1710
  /**
@@ -2466,10 +1946,12 @@ export declare const pluginToolOutputSchema: z.ZodObject<{
2466
1946
  code_change: "code_change";
2467
1947
  conversation: "conversation";
2468
1948
  deployment: "deployment";
1949
+ document: "document";
2469
1950
  item: "item";
2470
1951
  message: "message";
2471
1952
  person: "person";
2472
1953
  task: "task";
1954
+ web_page: "web_page";
2473
1955
  }>;
2474
1956
  title: z.ZodString;
2475
1957
  url: z.ZodNullable<z.ZodURL>;
@@ -2481,6 +1963,7 @@ export declare const pluginToolOutputSchema: z.ZodObject<{
2481
1963
  sourceUpdatedAt: z.ZodOptional<z.ZodISODateTime>;
2482
1964
  facts: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
2483
1965
  type: z.ZodLiteral<"code_change">;
1966
+ summary: z.ZodOptional<z.ZodString>;
2484
1967
  author: z.ZodOptional<z.ZodString>;
2485
1968
  sourceBranch: z.ZodOptional<z.ZodString>;
2486
1969
  targetBranch: z.ZodOptional<z.ZodString>;
@@ -2502,6 +1985,7 @@ export declare const pluginToolOutputSchema: z.ZodObject<{
2502
1985
  previewImageUrls: z.ZodOptional<z.ZodArray<z.ZodURL>>;
2503
1986
  }, z.core.$strict>, z.ZodObject<{
2504
1987
  type: z.ZodLiteral<"task">;
1988
+ summary: z.ZodOptional<z.ZodString>;
2505
1989
  assignees: z.ZodOptional<z.ZodArray<z.ZodString>>;
2506
1990
  priority: z.ZodOptional<z.ZodString>;
2507
1991
  project: z.ZodOptional<z.ZodString>;
@@ -2510,25 +1994,41 @@ export declare const pluginToolOutputSchema: z.ZodObject<{
2510
1994
  labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
2511
1995
  }, z.core.$strict>, z.ZodObject<{
2512
1996
  type: z.ZodLiteral<"deployment">;
1997
+ summary: z.ZodOptional<z.ZodString>;
2513
1998
  project: z.ZodOptional<z.ZodString>;
2514
1999
  environment: z.ZodOptional<z.ZodString>;
2515
2000
  revision: z.ZodOptional<z.ZodString>;
2516
2001
  branch: z.ZodOptional<z.ZodString>;
2517
2002
  }, z.core.$strict>, z.ZodObject<{
2518
2003
  type: z.ZodLiteral<"calendar_event">;
2004
+ summary: z.ZodOptional<z.ZodString>;
2519
2005
  when: z.ZodOptional<z.ZodString>;
2520
2006
  attendees: z.ZodOptional<z.ZodArray<z.ZodString>>;
2521
2007
  }, z.core.$strict>, z.ZodObject<{
2522
2008
  type: z.ZodLiteral<"conversation">;
2009
+ summary: z.ZodOptional<z.ZodString>;
2523
2010
  participants: z.ZodOptional<z.ZodArray<z.ZodString>>;
2524
2011
  lastActivityAt: z.ZodOptional<z.ZodISODateTime>;
2012
+ }, z.core.$strict>, z.ZodObject<{
2013
+ type: z.ZodLiteral<"document">;
2014
+ summary: z.ZodOptional<z.ZodString>;
2015
+ owner: z.ZodOptional<z.ZodString>;
2016
+ modifiedAt: z.ZodOptional<z.ZodISODateTime>;
2525
2017
  }, z.core.$strict>, z.ZodObject<{
2526
2018
  type: z.ZodLiteral<"message">;
2019
+ summary: z.ZodOptional<z.ZodString>;
2527
2020
  channel: z.ZodOptional<z.ZodString>;
2528
2021
  author: z.ZodOptional<z.ZodString>;
2529
2022
  sentAt: z.ZodOptional<z.ZodISODateTime>;
2023
+ }, z.core.$strict>, z.ZodObject<{
2024
+ type: z.ZodLiteral<"web_page">;
2025
+ summary: z.ZodOptional<z.ZodString>;
2026
+ siteName: z.ZodOptional<z.ZodString>;
2027
+ author: z.ZodOptional<z.ZodString>;
2028
+ thumbnailUrl: z.ZodOptional<z.ZodString>;
2530
2029
  }, z.core.$strict>, z.ZodObject<{
2531
2030
  type: z.ZodLiteral<"person">;
2031
+ summary: z.ZodOptional<z.ZodString>;
2532
2032
  email: z.ZodOptional<z.ZodString>;
2533
2033
  slackHandle: z.ZodOptional<z.ZodString>;
2534
2034
  githubHandle: z.ZodOptional<z.ZodString>;
@@ -2566,187 +2066,901 @@ export declare const toolApprovalModeSchema: z.ZodEnum<{
2566
2066
  }>;
2567
2067
  export type ToolApprovalMode = z.output<typeof toolApprovalModeSchema>;
2568
2068
  /**
2569
- * Reviewer signals describing a tool's side-effect behavior.
2570
- *
2571
- * These hints follow the MCP tool annotation contract. Guardian may use
2572
- * them as signals, but they never grant authority or override deterministic
2573
- * authorization.
2069
+ * Reviewer signals describing a tool's side-effect behavior.
2070
+ *
2071
+ * These hints follow the MCP tool annotation contract. Guardian may use
2072
+ * them as signals, but they never grant authority or override deterministic
2073
+ * authorization.
2074
+ */
2075
+ export interface ToolAnnotations {
2076
+ [key: string]: unknown;
2077
+ destructiveHint?: boolean;
2078
+ idempotentHint?: boolean;
2079
+ openWorldHint?: boolean;
2080
+ readOnlyHint?: boolean;
2081
+ title?: string;
2082
+ }
2083
+ export declare const REQUIRED_TOOL_ANNOTATION_KEYS: readonly ["destructiveHint", "idempotentHint", "openWorldHint", "readOnlyHint"];
2084
+ export type RequiredToolAnnotationKey = (typeof REQUIRED_TOOL_ANNOTATION_KEYS)[number];
2085
+ /** Return behavioral annotation keys that a tool did not declare. */
2086
+ export declare function missingToolAnnotationKeys(annotations: ToolAnnotations | undefined): RequiredToolAnnotationKey[];
2087
+ /**
2088
+ * Canonical approval metadata declared by core and plugin tools.
2089
+ */
2090
+ export interface ToolApprovalMetadata<TInput = unknown> {
2091
+ /** Optional declared approval mode; the owning tool boundary selects defaults. */
2092
+ approvalMode?: ToolApprovalMode;
2093
+ annotations?: ToolAnnotations;
2094
+ /**
2095
+ * Describe the reviewed semantic action for the review request.
2096
+ *
2097
+ * Core owns authoritative tool, actor, source, destination, conversation,
2098
+ * credential, and input data. This description adds domain-specific context
2099
+ * only and is never an authorization grant.
2100
+ */
2101
+ describeProposal?(input: TInput): string;
2102
+ }
2103
+ /**
2104
+ * Control who may call a tool.
2105
+ *
2106
+ * | Exposure | Model tool list | Tool catalog | Code Mode script |
2107
+ * | ----------- | --------------- | ------------ | ---------------- |
2108
+ * | `direct` | yes | yes | yes |
2109
+ * | `deferred` | no | yes | yes |
2110
+ * | `modelOnly` | yes | no | no |
2111
+ * | `codemode` | no | no | yes |
2112
+ * | `hidden` | no | no | no |
2113
+ *
2114
+ * The tool catalog is `searchTools` and `executeTool`. Use `modelOnly` for
2115
+ * tools that control the agent loop or dispatch other tools.
2116
+ */
2117
+ export type ToolExposure = "direct" | "deferred" | "modelOnly" | "codemode" | "hidden";
2118
+ export interface PluginToolDefinition<TInput = unknown, TOutput = unknown, TExecuteOutput = TOutput> extends ToolApprovalMetadata<TInput> {
2119
+ description: string;
2120
+ /**
2121
+ * Why the current Turn cannot run this tool. The host keeps the tool in the
2122
+ * tool list, so the cached prompt stays the same, and rejects its calls.
2123
+ */
2124
+ disabledReason?: string;
2125
+ executionMode?: unknown;
2126
+ /** Override the host's default tool exposure. */
2127
+ exposure?: ToolExposure;
2128
+ inputSchema: unknown;
2129
+ outputSchema?: unknown;
2130
+ /**
2131
+ * Select result fields that are safe to retain in private traces.
2132
+ * Returning `undefined` suppresses private result capture.
2133
+ */
2134
+ privateTraceResult?(result: TOutput): unknown;
2135
+ prepareArguments?: (args: unknown) => TInput;
2136
+ /**
2137
+ * @deprecated Put tool-selection and usage guidance directly in `description`
2138
+ * and parameter descriptions. Retained for compatibility; may be removed in a
2139
+ * future major version.
2140
+ */
2141
+ promptGuidelines?: string[];
2142
+ /**
2143
+ * @deprecated Put tool-selection and usage guidance directly in `description`
2144
+ * and parameter descriptions. Retained for compatibility; may be removed in a
2145
+ * future major version.
2146
+ */
2147
+ promptSnippet?: string;
2148
+ execute?: PluginToolExecute<TInput, TExecuteOutput>;
2149
+ }
2150
+ 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"> & {
2151
+ inputSchema: TInputSchema;
2152
+ outputSchema: TOutputSchema;
2153
+ prepareArguments?: (args: unknown) => z.input<TInputSchema>;
2154
+ execute?: (input: z.output<TInputSchema>, options: PluginToolExecuteOptions) => Promise<TExecuteResult> | TExecuteResult;
2155
+ };
2156
+ type ParsedPluginToolExecuteResult<TOutputSchema extends ZodTypeAny, TResult> = TResult extends PluginToolOutputEnvelope<unknown> ? PluginToolOutputEnvelope<z.output<TOutputSchema>> : z.output<TOutputSchema>;
2157
+ /** Define a plugin tool with Zod input parsing and validated structured results. */
2158
+ 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>>;
2159
+ /** Define a plugin tool with Zod input parsing and the structured result contract. */
2160
+ 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>>;
2161
+ export interface SlackToolRegistrationHookContext {
2162
+ /**
2163
+ * What Slack tools can do in the Conversation Location.
2164
+ * Computed from Location, not from Source or Destination.
2165
+ */
2166
+ channelCapabilities: {
2167
+ canAddReactions: boolean;
2168
+ canCreateCanvas: boolean;
2169
+ canPostToChannel: boolean;
2170
+ };
2171
+ credentialSubject?: Extract<PluginCredentialSubject, {
2172
+ allowedWhen: "private-direct-conversation";
2173
+ }>;
2174
+ }
2175
+ export interface PluginEventToolContext {
2176
+ /** Whether this invocation can create a working watch. */
2177
+ canSubscribe: boolean;
2178
+ /** Create a temporary watch for the current conversation. */
2179
+ subscribe(input: {
2180
+ events: string[];
2181
+ intent: string;
2182
+ resource: SubscribableResource;
2183
+ /**
2184
+ * Guidance for this Watch only, by event type. Core adds it after the
2185
+ * resource type guidance when a matching Event arrives.
2186
+ */
2187
+ guidance?: Partial<Record<string, string>>;
2188
+ }): Promise<WatchResult>;
2189
+ }
2190
+ export interface PluginWorkspaceToolContext {
2191
+ /**
2192
+ * Workspace that the current Sandbox started from. Returns undefined for
2193
+ * the default Sandbox. `name` is missing when the recipe no longer exists.
2194
+ */
2195
+ active(): Promise<{
2196
+ name?: string;
2197
+ } | undefined>;
2198
+ /** Find named Workspaces that include one provider repository. */
2199
+ findByRepository(input: {
2200
+ provider: string;
2201
+ repo: string;
2202
+ }): Promise<string[]>;
2203
+ }
2204
+ interface BaseToolRegistrationHookContext extends PluginContext {
2205
+ /**
2206
+ * Opaque Junior conversation/session identity for this turn.
2207
+ * Interactive Slack turns use `slack:{channelId}:{threadTs}`.
2208
+ * Scheduled/web turns use an internal id such as `agent-dispatch:{id}`.
2209
+ * Do not parse as Slack unless the value starts with `slack:`.
2210
+ */
2211
+ conversationId?: string;
2212
+ annotations?: PluginAnnotations;
2213
+ /** Host-owned dashboard link to the Automation that started this run. */
2214
+ automationLink?: {
2215
+ url: string;
2216
+ };
2217
+ /** Host-owned dashboard link to this conversation, when the dashboard is enabled. */
2218
+ conversationLink?: {
2219
+ url: string;
2220
+ };
2221
+ /** Decision model for narrow choices, such as checks on text a tool writes. */
2222
+ decider: PluginDecider;
2223
+ embedder: PluginEmbedder;
2224
+ egress: PluginEgress;
2225
+ mcp?: PluginMcp;
2226
+ model: PluginModel;
2227
+ events: PluginEventToolContext;
2228
+ /** Sandbox filesystem and command capability for plugin-owned workspace tools. */
2229
+ sandbox: PluginSandbox;
2230
+ state: PluginState;
2231
+ users: {
2232
+ /** Resolve the current actor's stored identity and linked user. */
2233
+ resolveActor(): Promise<{
2234
+ identity: Identity;
2235
+ user?: User;
2236
+ } | undefined>;
2237
+ /**
2238
+ * Resolve the current actor's IANA timezone. Uses their profile when
2239
+ * Junior knows it, else the install default. Always returns a timezone.
2240
+ */
2241
+ resolveTimezone(): Promise<string>;
2242
+ /**
2243
+ * Rewrite Slack mention syntax in every string of `value`, such as a tool
2244
+ * input that goes to `provider`. A Slack user becomes `@handle` of their
2245
+ * linked `provider` account, or else their name. Markdown code stays as
2246
+ * written. Call it before you send model text out.
2247
+ */
2248
+ replaceSlackMentions<T>(value: T, provider: string): Promise<T>;
2249
+ };
2250
+ userText?: string;
2251
+ workspaces: PluginWorkspaceToolContext;
2252
+ }
2253
+ export type ToolRegistrationHookContext = BaseToolRegistrationHookContext & InvocationContext & {
2254
+ /** Slack tool details when the Conversation has a Slack Location. */
2255
+ slack?: SlackToolRegistrationHookContext;
2256
+ };
2257
+ /** How Junior fetches one image. */
2258
+ export interface ImageFetch {
2259
+ /**
2260
+ * Request headers, such as the plugin's credential. Junior sends them only
2261
+ * to the origin of `url`, not after a redirect to another origin.
2262
+ */
2263
+ headers?: Record<string, string>;
2264
+ /**
2265
+ * Return the address to fetch instead of `url`, such as a short-lived
2266
+ * signed URL that the plugin reads through egress. Junior calls it only
2267
+ * when it fetches the image, not when it serves a cached copy, and sends
2268
+ * no `headers` to it. `url` stays the identity of the cached image.
2269
+ * Return nothing when the image is gone.
2270
+ */
2271
+ location?: () => Promise<string | undefined>;
2272
+ url: string;
2273
+ }
2274
+ /** Trusted host context for one image read. */
2275
+ export interface ImageSourceContext extends PluginContext {
2276
+ /**
2277
+ * Provider egress as a system Actor. It gets only credentials that the
2278
+ * plugin owns, such as an app, and never the viewer's credentials. Check
2279
+ * that the viewer may see the image before you fetch it.
2280
+ */
2281
+ egress: PluginEgress;
2282
+ /** The signed-in person who sees the image. */
2283
+ viewer: User;
2284
+ }
2285
+ /**
2286
+ * Images that a plugin serves through the Junior image proxy. `resolve`
2287
+ * checks that the viewer may see the image and returns how to fetch it.
2288
+ * Return nothing when the viewer cannot see it. Junior checks the address,
2289
+ * the type, and the size of each image, and caches it for every viewer.
2290
+ * The preview images of the plugin's object annotations come with refs from
2291
+ * `encodeObjectImageRef`.
2574
2292
  */
2575
- export interface ToolAnnotations {
2576
- [key: string]: unknown;
2577
- destructiveHint?: boolean;
2578
- idempotentHint?: boolean;
2579
- openWorldHint?: boolean;
2580
- readOnlyHint?: boolean;
2581
- title?: string;
2293
+ export interface PluginImageSource {
2294
+ resolve(ctx: ImageSourceContext, ref: string): Promise<ImageFetch | undefined>;
2582
2295
  }
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[];
2296
+ declare const objectImageRefSchema: z.ZodObject<{
2297
+ key: z.ZodString;
2298
+ url: z.ZodString;
2299
+ }, z.core.$strict>;
2587
2300
  /**
2588
- * Canonical approval metadata declared by core and plugin tools.
2301
+ * One preview image of an object annotation, such as `previewImageUrls` of a
2302
+ * code change. `key` is the annotation key, so the plugin can check that the
2303
+ * viewer may see that object.
2589
2304
  */
2590
- export interface ToolApprovalMetadata<TInput = unknown> {
2591
- /** Optional declared approval mode; the owning tool boundary selects defaults. */
2592
- approvalMode?: ToolApprovalMode;
2593
- annotations?: ToolAnnotations;
2305
+ export type ObjectImageRef = z.output<typeof objectImageRefSchema>;
2306
+ /** Return the image source ref of one object preview image. */
2307
+ export declare function encodeObjectImageRef(image: ObjectImageRef): string;
2308
+ /**
2309
+ * Return the object preview image of an image source ref, or nothing when
2310
+ * the ref names another kind of image.
2311
+ */
2312
+ export declare function decodeObjectImageRef(ref: string): ObjectImageRef | undefined;
2313
+ /** Which URLs a link type claims. Give at most one path field. */
2314
+ export declare const objectLinkFilterSchema: z.ZodObject<{
2315
+ scheme: z.ZodOptional<z.ZodEnum<{
2316
+ http: "http";
2317
+ https: "https";
2318
+ mailto: "mailto";
2319
+ }>>;
2320
+ host: z.ZodOptional<z.ZodString>;
2321
+ path: z.ZodOptional<z.ZodString>;
2322
+ pathPattern: z.ZodOptional<z.ZodString>;
2323
+ pathPrefix: z.ZodOptional<z.ZodString>;
2324
+ }, z.core.$strict>;
2325
+ export type ObjectLinkFilter = z.output<typeof objectLinkFilterSchema>;
2326
+ /** Return whether a filter claims a URL. A trailing slash does not count. */
2327
+ export declare function objectLinkFilterMatches(filter: ObjectLinkFilter, url: URL): boolean;
2328
+ /**
2329
+ * Rank how specific a filter is. Compare ranks in order: an exact host
2330
+ * before a wildcard host, an exact path before a pattern before a prefix,
2331
+ * and then the longer match.
2332
+ */
2333
+ export declare function objectLinkFilterSpecificity(filter: ObjectLinkFilter): number[];
2334
+ /** Trusted host context for one link resolution. */
2335
+ export interface ObjectLinkContext extends PluginContext {
2594
2336
  /**
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.
2337
+ * Provider egress as a system Actor. It gets only credentials that the
2338
+ * plugin owns, such as an app or Junior's own account, and never the
2339
+ * viewer's credentials. Check that the viewer may see the object before
2340
+ * you return it.
2600
2341
  */
2601
- describeProposal?(input: TInput): string;
2342
+ egress: PluginEgress;
2343
+ /**
2344
+ * Return the Junior person card of the one known person with this
2345
+ * provider account, or undefined. Return it for a profile link of that
2346
+ * account, so the card shows the person and not only the account.
2347
+ */
2348
+ findPerson(account: {
2349
+ handle: string;
2350
+ provider: string;
2351
+ }): Promise<ObjectAnnotation | undefined>;
2352
+ /** The signed-in person who sees the card. */
2353
+ viewer: User;
2602
2354
  }
2603
2355
  /**
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.
2356
+ * One link type of a plugin. Junior calls `canView` first, and calls
2357
+ * `resolve` only when it returns true. Junior does not save the result.
2616
2358
  */
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;
2359
+ export interface PluginObjectLinkDefinition {
2620
2360
  /**
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.
2361
+ * Return whether `ctx.viewer` may see the object. Junior calls it before
2362
+ * each card read and again on each Attach. Return true for a public
2363
+ * object. Return false when you cannot tell, so the card does not show
2364
+ * that the object exists.
2623
2365
  */
2624
- disabledReason?: string;
2625
- executionMode?: unknown;
2626
- /** Override the host's default tool exposure. */
2627
- exposure?: ToolExposure;
2628
- inputSchema: unknown;
2629
- outputSchema?: unknown;
2366
+ canView(ctx: ObjectLinkContext, url: URL): Promise<boolean>;
2367
+ filters: ObjectLinkFilter[];
2368
+ objectType: ObjectType;
2630
2369
  /**
2631
- * Select result fields that are safe to retain in private traces.
2632
- * Returning `undefined` suppresses private result capture.
2370
+ * Read the card. Junior calls it only after `canView` returns true.
2371
+ * Return nothing for a missing object.
2633
2372
  */
2634
- privateTraceResult?(result: TOutput): unknown;
2635
- prepareArguments?: (args: unknown) => TInput;
2373
+ resolve(ctx: ObjectLinkContext, url: URL): Promise<ObjectAnnotation | undefined>;
2636
2374
  /**
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.
2375
+ * The plugin tool that reads the object live, such as `readGoogleFile`.
2376
+ * When a person attaches the link to a Conversation, its next Turn is told
2377
+ * to read the object with this tool. Omit it when no tool reads the object.
2640
2378
  */
2641
- promptGuidelines?: string[];
2379
+ readTool?: string;
2380
+ }
2381
+ export declare const codeChangeStateSchema: z.ZodEnum<{
2382
+ closed: "closed";
2383
+ merged: "merged";
2384
+ open: "open";
2385
+ }>;
2386
+ export type CodeChangeState = z.output<typeof codeChangeStateSchema>;
2387
+ export declare const codeChangeInputSchema: z.ZodObject<{
2388
+ closedAt: z.ZodOptional<z.ZodDate>;
2389
+ conversationIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
2390
+ draft: z.ZodOptional<z.ZodBoolean>;
2391
+ mergedAt: z.ZodOptional<z.ZodDate>;
2392
+ number: z.ZodNumber;
2393
+ openedAt: z.ZodDate;
2394
+ providerId: z.ZodString;
2395
+ repository: z.ZodObject<{
2396
+ name: z.ZodString;
2397
+ providerId: z.ZodString;
2398
+ url: z.ZodOptional<z.ZodString>;
2399
+ }, z.core.$strict>;
2400
+ state: z.ZodEnum<{
2401
+ closed: "closed";
2402
+ merged: "merged";
2403
+ open: "open";
2404
+ }>;
2405
+ title: z.ZodOptional<z.ZodString>;
2406
+ updatedAt: z.ZodDate;
2407
+ url: z.ZodOptional<z.ZodString>;
2408
+ }, z.core.$strict>;
2409
+ export type CodeChangeInput = z.input<typeof codeChangeInputSchema>;
2410
+ /** Write code changes from a plugin to Junior's code records. */
2411
+ export interface CodeChangePublisher {
2412
+ associateConversations(input: {
2413
+ conversationIds: string[];
2414
+ providerId: string;
2415
+ }): Promise<void>;
2416
+ record(input: CodeChangeInput): Promise<void>;
2642
2417
  /**
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.
2418
+ * Record a push, review, or comment by a person on a code change. Junior
2419
+ * ignores activity on code changes that it did not record.
2646
2420
  */
2647
- promptSnippet?: string;
2648
- execute?: PluginToolExecute<TInput, TExecuteOutput>;
2421
+ recordActivity(input: {
2422
+ at: Date;
2423
+ number: number;
2424
+ repositoryProviderId: string;
2425
+ }): Promise<void>;
2426
+ }
2427
+ export declare const conversationEventIconSchema: z.ZodEnum<{
2428
+ activity: "activity";
2429
+ brain: "brain";
2430
+ calendar: "calendar";
2431
+ check: "check";
2432
+ database: "database";
2433
+ info: "info";
2434
+ key: "key";
2435
+ link: "link";
2436
+ sparkles: "sparkles";
2437
+ warning: "warning";
2438
+ }>;
2439
+ /** Safe, core-rendered presentation for one plugin conversation event. */
2440
+ export declare const conversationEventPresentationSchema: z.ZodObject<{
2441
+ details: z.ZodOptional<z.ZodArray<z.ZodObject<{
2442
+ content: z.ZodOptional<z.ZodString>;
2443
+ description: z.ZodOptional<z.ZodString>;
2444
+ metadata: z.ZodOptional<z.ZodArray<z.ZodString>>;
2445
+ title: z.ZodString;
2446
+ }, z.core.$strict>>>;
2447
+ icon: z.ZodOptional<z.ZodEnum<{
2448
+ activity: "activity";
2449
+ brain: "brain";
2450
+ calendar: "calendar";
2451
+ check: "check";
2452
+ database: "database";
2453
+ info: "info";
2454
+ key: "key";
2455
+ link: "link";
2456
+ sparkles: "sparkles";
2457
+ warning: "warning";
2458
+ }>>;
2459
+ preview: z.ZodOptional<z.ZodString>;
2460
+ title: z.ZodString;
2461
+ }, z.core.$strict>;
2462
+ export type ConversationEventPresentation = z.output<typeof conversationEventPresentationSchema>;
2463
+ /** One validated plugin event value waiting for conversation-bound emission. */
2464
+ export interface PluginConversationEventValue {
2465
+ readonly data: Record<string, unknown>;
2466
+ readonly definition: PluginConversationEventDefinition;
2467
+ }
2468
+ /** Registered schema and optional transcript presentation for one event version. */
2469
+ export interface PluginConversationEventDefinition {
2470
+ readonly eventName: string;
2471
+ readonly version: number;
2472
+ parse(data: unknown): Record<string, unknown>;
2473
+ renderEvent(data: Record<string, unknown>): ConversationEventPresentation | undefined;
2474
+ }
2475
+ /** Typed factory returned while authoring one plugin conversation event. */
2476
+ export interface DefinedConversationEvent<TInput> extends PluginConversationEventDefinition {
2477
+ (data: TInput): PluginConversationEventValue;
2478
+ }
2479
+ /** Define one typed, versioned plugin-owned conversation event. */
2480
+ export declare function defineConversationEvent<TSchema extends z.ZodType<Record<string, unknown>>>(definition: {
2481
+ name: string;
2482
+ version: number;
2483
+ schema: TSchema;
2484
+ renderEvent(event: z.output<TSchema>): z.input<typeof conversationEventPresentationSchema> | undefined;
2485
+ }): DefinedConversationEvent<z.input<TSchema>>;
2486
+ /** Conversation-bound event writer supplied by Junior core. */
2487
+ export interface PluginConversationEvents {
2488
+ emit(event: PluginConversationEventValue): Promise<void>;
2489
+ }
2490
+ export interface PluginConversationEventCostDay {
2491
+ costUsd: number;
2492
+ date: string;
2493
+ events: number;
2494
+ }
2495
+ export interface PluginConversationEventRecord {
2496
+ content: Record<string, unknown>;
2497
+ createdAt: string;
2498
+ /** Position in the Conversation's events. The transcript opens there. */
2499
+ seq: number;
2500
+ /** Turn that emitted the event. Events from outside a Turn have none. */
2501
+ turnId?: string;
2502
+ version: number;
2503
+ }
2504
+ /** Read events owned by the current plugin namespace after Conversation access checks. */
2505
+ export interface PluginConversationEventReader {
2506
+ list(input: {
2507
+ conversationId: string;
2508
+ eventName: string;
2509
+ viewer: User;
2510
+ }): Promise<PluginConversationEventRecord[] | undefined>;
2511
+ }
2512
+ /**
2513
+ * Events that Junior writes in a plugin's namespace for the cost of each
2514
+ * priced `model`, `decider`, `embedder`, or `reranker` call in a
2515
+ * Conversation, by the context that made the call. Junior counts them in
2516
+ * Conversation cost, so plugin events must not repeat that cost. A plugin
2517
+ * cannot register these names. It can read their costs through
2518
+ * `PluginConversationEventStats`.
2519
+ */
2520
+ export declare const pluginModelCostEventNames: {
2521
+ readonly afterToolExecute: "after_tool_execute_model_called";
2522
+ readonly task: "task_model_called";
2523
+ readonly tool: "tool_model_called";
2524
+ readonly userPrompt: "user_prompt_model_called";
2525
+ };
2526
+ /** Whether an event name is one of `pluginModelCostEventNames`. */
2527
+ export declare function isPluginModelCostEventName(eventName: string): boolean;
2528
+ /**
2529
+ * Read aggregate costs for events owned by the current plugin namespace:
2530
+ * registered events and `pluginModelCostEventNames`.
2531
+ */
2532
+ export interface PluginConversationEventStats {
2533
+ costsByDay(input: {
2534
+ days: 7 | 30 | 90;
2535
+ eventName: string;
2536
+ }): Promise<PluginConversationEventCostDay[]>;
2537
+ costsByHour(input: {
2538
+ eventName: string;
2539
+ hours?: number;
2540
+ }): Promise<PluginConversationEventCostDay[]>;
2649
2541
  }
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;
2542
+ export declare const promptMessageSchema: z.ZodObject<{
2543
+ text: z.ZodString;
2544
+ }, z.core.$strict>;
2545
+ /** Small plugin-owned prompt text block rendered by Junior core. */
2546
+ type PromptMessage = z.output<typeof promptMessageSchema>;
2547
+ export declare const promptContextSchema: z.ZodObject<{
2548
+ kind: z.ZodString;
2549
+ version: z.ZodNumber;
2550
+ content: z.ZodRecord<z.ZodString, z.ZodUnknown>;
2551
+ }, z.core.$strict>;
2552
+ /** Structured plugin context retained alongside its model-visible rendering. */
2553
+ type PromptContext = z.output<typeof promptContextSchema>;
2554
+ /** Runtime contribution produced from one validated plugin context value. */
2555
+ interface PromptContextContribution {
2556
+ context: PromptContext;
2557
+ renderPrompt(): string;
2558
+ }
2559
+ /** Define one typed, versioned plugin context contribution. */
2560
+ export declare function definePromptContext<TSchema extends z.ZodType<Record<string, unknown>>>(definition: {
2561
+ kind: string;
2562
+ version: number;
2563
+ schema: TSchema;
2564
+ renderPrompt(content: z.output<TSchema>): string;
2565
+ }): (content: z.input<TSchema>) => PromptContextContribution;
2566
+ /** One request-scoped plugin contribution to the model-visible user prompt. */
2567
+ type UserPromptContribution = PromptMessage | PromptContextContribution;
2568
+ /** Stable platform context for plugin system prompt guidance. */
2569
+ type SystemPromptContext = Pick<PluginContext, "db" | "log" | "plugin"> & {
2570
+ platform: Platform;
2655
2571
  };
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 {
2572
+ /** Runtime facts available while building plugin user prompt context. */
2573
+ type UserPromptContext = Pick<PluginContext, "db" | "log" | "plugin"> & {
2574
+ conversationId?: string;
2575
+ destination: Destination;
2576
+ embedder: PluginEmbedder;
2577
+ /** Conversation-bound event writer when the prompt belongs to a durable turn. */
2578
+ events?: PluginConversationEvents;
2579
+ model: PluginModel;
2580
+ /** Host reranker bound to the configured reranking model. */
2581
+ reranker: PluginReranker;
2662
2582
  /**
2663
- * What Slack tools can do in the Conversation Location.
2664
- * Computed from Location, not from Source or Destination.
2583
+ * Record numeric diagnostics on the host span for this hook. Keys must
2584
+ * start with `app.<plugin name>.`; the host drops other keys and
2585
+ * non-finite values.
2665
2586
  */
2666
- channelCapabilities: {
2667
- canAddReactions: boolean;
2668
- canCreateCanvas: boolean;
2669
- canPostToChannel: boolean;
2587
+ setSpanAttributes(attributes: Record<string, number>): void;
2588
+ /** Location associated with this Conversation. */
2589
+ locationId?: string;
2590
+ actor?: Actor;
2591
+ source: Source;
2592
+ state: PluginState;
2593
+ text: string;
2594
+ users: {
2595
+ /** Resolve the current Actor's Identity and User. */
2596
+ resolveActor(): Promise<{
2597
+ identity: Identity;
2598
+ user?: User;
2599
+ } | undefined>;
2670
2600
  };
2671
- credentialSubject?: Extract<PluginCredentialSubject, {
2672
- allowedWhen: "private-direct-conversation";
2673
- }>;
2601
+ };
2602
+ export type DestinationVisibility = z.output<typeof destinationVisibilitySchema>;
2603
+ export type DispatchOptions = z.output<typeof dispatchOptionsSchema>;
2604
+ /** Compact destination-visible context explaining what produced a reply. */
2605
+ export type ReplyAttribution = z.output<typeof replyAttributionSchema>;
2606
+ export type TaskOutcome = z.output<typeof taskOutcomeSchema>;
2607
+ export interface DispatchResult {
2608
+ id: string;
2609
+ status: "created" | "already_exists";
2674
2610
  }
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>;
2611
+ export interface Dispatch {
2612
+ errorMessage?: string;
2613
+ id: string;
2614
+ resultMessageTs?: string;
2615
+ status: "pending" | "running" | "awaiting_resume" | "completed" | "failed" | "blocked";
2689
2616
  }
2690
- export interface PluginWorkspaceToolContext {
2617
+ type EventMatchField = EventMatchFields[string];
2618
+ /** One reason a selection of events and filters cannot work. */
2619
+ export interface EventTriggerProblem {
2691
2620
  /**
2692
- * Workspace that the current Sandbox started from. Returns undefined for
2693
- * the default Sandbox. `name` is missing when the recipe no longer exists.
2621
+ * - `unknown_resource_type`: the source has no such enabled resource type.
2622
+ * - `unknown_event`: the resource type has no such event.
2623
+ * - `identifier_required`: a trigger with no identifier selects an event
2624
+ * that cannot run for every resource.
2625
+ * - `filter_required`: a trigger with no identifier selects an event whose
2626
+ * reach names filters, and the trigger sets none of them.
2627
+ * - `unknown_field`: the resource type has no such filter. Saved triggers
2628
+ * get this after a plugin renames or removes a filter.
2629
+ * - `field_not_set`: a selected event never sets the filter, so the filter
2630
+ * never matches that event.
2631
+ * - `invalid_value`: the filter value has the wrong type or is not allowed.
2694
2632
  */
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[]>;
2633
+ reason: "unknown_resource_type" | "unknown_event" | "identifier_required" | "filter_required" | "unknown_field" | "field_not_set" | "invalid_value";
2634
+ /** The filter with the problem. Missing for a resource type or event problem. */
2635
+ field?: string;
2636
+ /** Plain words for the person or agent who changes the selection. */
2637
+ message: string;
2703
2638
  }
2704
- interface BaseToolRegistrationHookContext extends PluginContext {
2639
+ /**
2640
+ * The selection to check: one resource type, its events, and its filters.
2641
+ * Leave out the resource type for a trigger with no identifier. It runs for
2642
+ * every resource of the source that its filters match.
2643
+ */
2644
+ export interface EventTriggerSelection {
2645
+ resourceType?: string;
2646
+ events: readonly string[];
2647
+ match?: EventMatch;
2648
+ }
2649
+ /** The enabled resource types of one source, and the reach of each of its events. */
2650
+ export interface EventTriggerSource {
2651
+ resourceTypes: readonly Pick<PluginEventType, "type" | "matchFields" | "supportedEvents">[];
2652
+ events: Readonly<Record<string, {
2653
+ reach: EventReach;
2654
+ }>>;
2705
2655
  /**
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:`.
2656
+ * The filters of every resource type, for a trigger with no identifier.
2657
+ * Merge them once with `anyResourceMatchFields` when the catalog is built,
2658
+ * not for each check.
2710
2659
  */
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;
2660
+ anyResourceFields: EventMatchFields;
2661
+ }
2662
+ /** The events of a source that a trigger with no identifier can select. */
2663
+ export declare function anyResourceEvents(source: EventTriggerSource): string[];
2664
+ /** Return the selected events that never set one filter field. */
2665
+ export declare function eventsWithoutMatchField(field: Pick<EventMatchField, "events">, events: readonly string[]): string[];
2666
+ /**
2667
+ * Return the events and filters that a selection can use: those of its
2668
+ * resource type, or with no resource type, the events whose reach is not
2669
+ * `"resource"`, with the filters of every resource type. Return nothing when the source
2670
+ * has no such resource type or cannot run for every resource.
2671
+ */
2672
+ export declare function eventTriggerChoices(source: EventTriggerSource, selection: Pick<EventTriggerSelection, "resourceType">): {
2673
+ events: readonly string[];
2674
+ fields: EventMatchFields;
2675
+ } | undefined;
2676
+ /**
2677
+ * List why a selection cannot work with the resource types of one source. An
2678
+ * empty list means the resource type exists, every selected event is
2679
+ * supported, and every selected event can match every filter. A filter on a
2680
+ * list field (`list: true`) matches when the event list includes the value.
2681
+ * A selection with no resource type can use only events whose reach is not
2682
+ * `"resource"`, with the filters of every resource type, and must set one of
2683
+ * the filters that the reach of each selected event names.
2684
+ * Set `inputKeys` for the agent, so messages name the snake_case
2685
+ * `match.<key>` input.
2686
+ */
2687
+ export declare function eventTriggerProblems(source: EventTriggerSource, selection: EventTriggerSelection, options?: {
2688
+ inputKeys?: boolean;
2689
+ }): EventTriggerProblem[];
2690
+ /** How people see one Event trigger. Each entry is one line of plain text. */
2691
+ export interface EventTriggerDescription {
2692
+ /** Each selected event in plain words, such as "pull request opened". */
2693
+ events: string[];
2694
+ /** Each filter in plain words. Every filter must match. */
2695
+ filters: string[];
2696
+ /** Why the trigger cannot work as saved. Empty when it can. */
2697
+ problems: string[];
2698
+ }
2699
+ /** Write one event type in plain words: `pull_request.opened` is "pull request opened". */
2700
+ export declare function eventTypeText(eventType: string): string;
2701
+ /**
2702
+ * Write one filter in plain words. A list field (`list: true`) reads
2703
+ * "authors includes alice"; other fields read "repo is api or web".
2704
+ */
2705
+ export declare function eventMatchFilterText(key: string, field: EventMatchField | undefined, value: EventMatch[string]): string;
2706
+ /**
2707
+ * Describe a selection for the dashboard and Slack, so both show the same
2708
+ * words. Pass the selection's source, as for `eventTriggerProblems`. Its
2709
+ * problems are the messages of that check.
2710
+ */
2711
+ export declare function describeEventTrigger(source: EventTriggerSource, selection: EventTriggerSelection): EventTriggerDescription;
2712
+ /** Join filters into one line. Every filter must match, so join with "and". */
2713
+ export declare function eventTriggerFiltersText(filters: readonly string[]): string;
2714
+ /**
2715
+ * Write a whole trigger as one line, for cards and lists:
2716
+ * "Pull request · pull request opened · filters: isDraft is false".
2717
+ */
2718
+ export declare function eventTriggerText(resource: string, description: Pick<EventTriggerDescription, "events" | "filters">): string;
2719
+ /**
2720
+ * Runtime-owned provenance for a transcript message: whether it is a durable
2721
+ * instruction or ambient context, plus the actor identity when known. Missing
2722
+ * provenance on an entry means unattributed context.
2723
+ */
2724
+ export declare const pluginRunTranscriptProvenanceSchema: z.ZodObject<{
2725
+ authority: z.ZodEnum<{
2726
+ context: "context";
2727
+ instruction: "instruction";
2728
+ }>;
2729
+ actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
2730
+ email: z.ZodOptional<z.ZodString>;
2731
+ fullName: z.ZodOptional<z.ZodString>;
2732
+ userId: z.ZodString;
2733
+ userName: z.ZodOptional<z.ZodString>;
2734
+ platform: z.ZodLiteral<"slack">;
2735
+ teamId: z.ZodString;
2736
+ }, z.core.$strict>, z.ZodObject<{
2737
+ email: z.ZodOptional<z.ZodString>;
2738
+ fullName: z.ZodOptional<z.ZodString>;
2739
+ userId: z.ZodString;
2740
+ userName: z.ZodOptional<z.ZodString>;
2741
+ platform: z.ZodLiteral<"local">;
2742
+ }, z.core.$strict>, z.ZodObject<{
2743
+ email: z.ZodOptional<z.ZodString>;
2744
+ fullName: z.ZodOptional<z.ZodString>;
2745
+ userId: z.ZodString;
2746
+ userName: z.ZodOptional<z.ZodString>;
2747
+ platform: z.ZodLiteral<"web">;
2748
+ }, z.core.$strict>, z.ZodObject<{
2749
+ platform: z.ZodLiteral<"system">;
2750
+ name: z.ZodString;
2751
+ }, z.core.$strict>], "platform">>;
2752
+ }, z.core.$strict>;
2753
+ /** One normalized transcript entry from the completed run exposed to plugin tasks. */
2754
+ export declare const pluginRunTranscriptEntrySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
2755
+ type: z.ZodLiteral<"message">;
2756
+ role: z.ZodEnum<{
2757
+ assistant: "assistant";
2758
+ user: "user";
2759
+ }>;
2760
+ text: z.ZodString;
2761
+ provenance: z.ZodOptional<z.ZodObject<{
2762
+ authority: z.ZodEnum<{
2763
+ context: "context";
2764
+ instruction: "instruction";
2765
+ }>;
2766
+ actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
2767
+ email: z.ZodOptional<z.ZodString>;
2768
+ fullName: z.ZodOptional<z.ZodString>;
2769
+ userId: z.ZodString;
2770
+ userName: z.ZodOptional<z.ZodString>;
2771
+ platform: z.ZodLiteral<"slack">;
2772
+ teamId: z.ZodString;
2773
+ }, z.core.$strict>, z.ZodObject<{
2774
+ email: z.ZodOptional<z.ZodString>;
2775
+ fullName: z.ZodOptional<z.ZodString>;
2776
+ userId: z.ZodString;
2777
+ userName: z.ZodOptional<z.ZodString>;
2778
+ platform: z.ZodLiteral<"local">;
2779
+ }, z.core.$strict>, z.ZodObject<{
2780
+ email: z.ZodOptional<z.ZodString>;
2781
+ fullName: z.ZodOptional<z.ZodString>;
2782
+ userId: z.ZodString;
2783
+ userName: z.ZodOptional<z.ZodString>;
2784
+ platform: z.ZodLiteral<"web">;
2785
+ }, z.core.$strict>, z.ZodObject<{
2786
+ platform: z.ZodLiteral<"system">;
2787
+ name: z.ZodString;
2788
+ }, z.core.$strict>], "platform">>;
2789
+ }, z.core.$strict>>;
2790
+ isRunActor: z.ZodOptional<z.ZodBoolean>;
2791
+ }, z.core.$strict>, z.ZodObject<{
2792
+ type: z.ZodLiteral<"toolResult">;
2793
+ toolName: z.ZodString;
2794
+ isError: z.ZodBoolean;
2795
+ text: z.ZodOptional<z.ZodString>;
2796
+ }, z.core.$strict>], "type">;
2797
+ export type PluginRunTranscriptProvenance = z.output<typeof pluginRunTranscriptProvenanceSchema>;
2798
+ /** Runtime-owned completed-run projection exposed to plugin tasks. */
2799
+ export declare const pluginRunContextSchema: z.ZodObject<{
2800
+ actorUserId: z.ZodOptional<z.ZodString>;
2801
+ completedAtMs: z.ZodNumber;
2802
+ conversationId: z.ZodString;
2803
+ destination: z.ZodDiscriminatedUnion<[z.ZodObject<{
2804
+ platform: z.ZodLiteral<"slack">;
2805
+ teamId: z.ZodString;
2806
+ channelId: z.ZodString;
2807
+ threadTs: z.ZodOptional<z.ZodString>;
2808
+ }, z.core.$strict>, z.ZodObject<{
2809
+ platform: z.ZodLiteral<"local">;
2810
+ conversationId: z.ZodString;
2811
+ }, z.core.$strict>], "platform">;
2812
+ locationId: z.ZodOptional<z.ZodString>;
2813
+ actors: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
2814
+ email: z.ZodOptional<z.ZodString>;
2815
+ fullName: z.ZodOptional<z.ZodString>;
2816
+ userId: z.ZodString;
2817
+ userName: z.ZodOptional<z.ZodString>;
2818
+ platform: z.ZodLiteral<"slack">;
2819
+ teamId: z.ZodString;
2820
+ }, z.core.$strict>, z.ZodObject<{
2821
+ email: z.ZodOptional<z.ZodString>;
2822
+ fullName: z.ZodOptional<z.ZodString>;
2823
+ userId: z.ZodString;
2824
+ userName: z.ZodOptional<z.ZodString>;
2825
+ platform: z.ZodLiteral<"local">;
2826
+ }, z.core.$strict>, z.ZodObject<{
2827
+ email: z.ZodOptional<z.ZodString>;
2828
+ fullName: z.ZodOptional<z.ZodString>;
2829
+ userId: z.ZodString;
2830
+ userName: z.ZodOptional<z.ZodString>;
2831
+ platform: z.ZodLiteral<"web">;
2832
+ }, z.core.$strict>, z.ZodObject<{
2833
+ platform: z.ZodLiteral<"system">;
2834
+ name: z.ZodString;
2835
+ }, z.core.$strict>], "platform">>;
2836
+ actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
2837
+ email: z.ZodOptional<z.ZodString>;
2838
+ fullName: z.ZodOptional<z.ZodString>;
2839
+ userId: z.ZodString;
2840
+ userName: z.ZodOptional<z.ZodString>;
2841
+ platform: z.ZodLiteral<"slack">;
2842
+ teamId: z.ZodString;
2843
+ }, z.core.$strict>, z.ZodObject<{
2844
+ email: z.ZodOptional<z.ZodString>;
2845
+ fullName: z.ZodOptional<z.ZodString>;
2846
+ userId: z.ZodString;
2847
+ userName: z.ZodOptional<z.ZodString>;
2848
+ platform: z.ZodLiteral<"local">;
2849
+ }, z.core.$strict>, z.ZodObject<{
2850
+ email: z.ZodOptional<z.ZodString>;
2851
+ fullName: z.ZodOptional<z.ZodString>;
2852
+ userId: z.ZodString;
2853
+ userName: z.ZodOptional<z.ZodString>;
2854
+ platform: z.ZodLiteral<"web">;
2855
+ }, z.core.$strict>, z.ZodObject<{
2856
+ platform: z.ZodLiteral<"system">;
2857
+ name: z.ZodString;
2858
+ }, z.core.$strict>], "platform">>;
2859
+ runId: z.ZodString;
2860
+ source: z.ZodPreprocess<z.ZodDiscriminatedUnion<[z.ZodObject<{
2861
+ kind: z.ZodLiteral<"slack">;
2862
+ teamId: z.ZodString;
2863
+ channelId: z.ZodString;
2864
+ visibility: z.ZodEnum<{
2865
+ private: "private";
2866
+ public: "public";
2867
+ }>;
2868
+ messageTs: z.ZodOptional<z.ZodString>;
2869
+ threadTs: z.ZodOptional<z.ZodString>;
2870
+ }, z.core.$strict>, z.ZodObject<{
2871
+ kind: z.ZodLiteral<"local">;
2872
+ visibility: z.ZodLiteral<"private">;
2873
+ conversationId: z.ZodString;
2874
+ }, z.core.$strict>, z.ZodObject<{
2875
+ kind: z.ZodLiteral<"web">;
2876
+ visibility: z.ZodEnum<{
2877
+ private: "private";
2878
+ public: "public";
2879
+ }>;
2880
+ conversationId: z.ZodString;
2881
+ }, z.core.$strict>, z.ZodObject<{
2882
+ kind: z.ZodLiteral<"event">;
2883
+ eventKey: z.ZodString;
2884
+ eventType: z.ZodString;
2885
+ identifier: z.ZodString;
2886
+ namespace: z.ZodString;
2887
+ }, z.core.$strict>, z.ZodObject<{
2888
+ automationId: z.ZodOptional<z.ZodString>;
2889
+ automationRunId: z.ZodOptional<z.ZodString>;
2890
+ kind: z.ZodLiteral<"scheduled_automation">;
2891
+ }, z.core.$strict>, z.ZodObject<{
2892
+ automationId: z.ZodOptional<z.ZodString>;
2893
+ automationRunId: z.ZodOptional<z.ZodString>;
2894
+ kind: z.ZodLiteral<"event_automation">;
2895
+ }, z.core.$strict>, z.ZodObject<{
2896
+ kind: z.ZodLiteral<"plugin_dispatch">;
2897
+ }, z.core.$strict>, z.ZodObject<{
2898
+ kind: z.ZodLiteral<"agent_invocation">;
2899
+ }, z.core.$strict>], "kind">, unknown>;
2900
+ transcript: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
2901
+ type: z.ZodLiteral<"message">;
2902
+ role: z.ZodEnum<{
2903
+ assistant: "assistant";
2904
+ user: "user";
2905
+ }>;
2906
+ text: z.ZodString;
2907
+ provenance: z.ZodOptional<z.ZodObject<{
2908
+ authority: z.ZodEnum<{
2909
+ context: "context";
2910
+ instruction: "instruction";
2911
+ }>;
2912
+ actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
2913
+ email: z.ZodOptional<z.ZodString>;
2914
+ fullName: z.ZodOptional<z.ZodString>;
2915
+ userId: z.ZodString;
2916
+ userName: z.ZodOptional<z.ZodString>;
2917
+ platform: z.ZodLiteral<"slack">;
2918
+ teamId: z.ZodString;
2919
+ }, z.core.$strict>, z.ZodObject<{
2920
+ email: z.ZodOptional<z.ZodString>;
2921
+ fullName: z.ZodOptional<z.ZodString>;
2922
+ userId: z.ZodString;
2923
+ userName: z.ZodOptional<z.ZodString>;
2924
+ platform: z.ZodLiteral<"local">;
2925
+ }, z.core.$strict>, z.ZodObject<{
2926
+ email: z.ZodOptional<z.ZodString>;
2927
+ fullName: z.ZodOptional<z.ZodString>;
2928
+ userId: z.ZodString;
2929
+ userName: z.ZodOptional<z.ZodString>;
2930
+ platform: z.ZodLiteral<"web">;
2931
+ }, z.core.$strict>, z.ZodObject<{
2932
+ platform: z.ZodLiteral<"system">;
2933
+ name: z.ZodString;
2934
+ }, z.core.$strict>], "platform">>;
2935
+ }, z.core.$strict>>;
2936
+ isRunActor: z.ZodOptional<z.ZodBoolean>;
2937
+ }, z.core.$strict>, z.ZodObject<{
2938
+ type: z.ZodLiteral<"toolResult">;
2939
+ toolName: z.ZodString;
2940
+ isError: z.ZodBoolean;
2941
+ text: z.ZodOptional<z.ZodString>;
2942
+ }, z.core.$strict>], "type">>;
2943
+ }, z.core.$strict>;
2944
+ export type PluginRunTranscriptEntry = z.output<typeof pluginRunTranscriptEntrySchema>;
2945
+ export type PluginRunContext = z.output<typeof pluginRunContextSchema>;
2946
+ /** Runtime context passed to a plugin-owned background task. */
2947
+ export interface PluginTaskContext extends PluginContext {
2723
2948
  embedder: PluginEmbedder;
2724
- egress: PluginEgress;
2725
- mcp?: PluginMcp;
2949
+ events: PluginConversationEvents;
2950
+ id: string;
2726
2951
  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>;
2952
+ name: string;
2953
+ run: {
2954
+ load(): Promise<PluginRunContext>;
2742
2955
  };
2743
- userText?: string;
2744
- workspaces: PluginWorkspaceToolContext;
2956
+ state: PluginState;
2745
2957
  }
2746
- export type ToolRegistrationHookContext = BaseToolRegistrationHookContext & InvocationContext & {
2747
- /** Slack tool details when the Conversation has a Slack Location. */
2748
- slack?: SlackToolRegistrationHookContext;
2749
- };
2958
+ /** Plugin task handler registered by name in a plugin manifest module. */
2959
+ export interface PluginTaskDefinition {
2960
+ run(ctx: PluginTaskContext): Promise<void> | void;
2961
+ }
2962
+ /** Task handlers keyed by the plugin-owned task name. */
2963
+ export type PluginTasks = Record<string, PluginTaskDefinition>;
2750
2964
  /**
2751
2965
  * An item that a plugin puts on the review desk: a notice for information,
2752
2966
  * or an ask that waits on its assignees.
@@ -3001,6 +3215,32 @@ export declare function enforceEgressPolicy(input: {
3001
3215
  export declare function parseShellCommands(text: string): string[][];
3002
3216
  /** Input for a pure Markdown rewrite before destination delivery formatting. */
3003
3217
  export interface FormatMarkdownHookContext {
3218
+ /**
3219
+ * String config values of this plugin for the Conversation's Location, by
3220
+ * short key, over install defaults. Runtime notices get install defaults.
3221
+ */
3222
+ config: Record<string, string>;
3223
+ /**
3224
+ * Return the destination's mention of the one known person who has this
3225
+ * provider account, or undefined. Core resolves the `@handle` words in
3226
+ * `text` before the hook runs. Insert the result as is. Only Slack text
3227
+ * gets mentions: Slack syntax never goes to another place.
3228
+ */
3229
+ mention(account: {
3230
+ provider: string;
3231
+ handle: string;
3232
+ }): string | undefined;
3233
+ /**
3234
+ * Where the text shows: a Slack message, or the dashboard (`web`). The
3235
+ * dashboard shows a bare object link as a card, so keep bare links there.
3236
+ */
3237
+ platform: "slack" | "web";
3238
+ /**
3239
+ * The provider that wrote the text or that it went to, such as `github`
3240
+ * for a GitHub Event or a comment posted to GitHub. In that text, every
3241
+ * `@name` is an account of that provider. Undefined for chat replies.
3242
+ */
3243
+ provider?: string;
3004
3244
  text: string;
3005
3245
  }
3006
3246
  /** First human message of a new Conversation, given before title generation. */
@@ -3353,6 +3593,8 @@ export type PluginRegistrationInput = {
3353
3593
  cli?: PluginCliDefinition;
3354
3594
  conversationEvents?: PluginConversationEventDefinition[];
3355
3595
  hooks?: PluginHooks;
3596
+ /** Images that this plugin serves through the Junior image proxy. */
3597
+ images?: PluginImageSource;
3356
3598
  manifest: PluginManifest;
3357
3599
  model?: PluginModelConfig;
3358
3600
  /** URLs that this plugin shows as object cards. */