@sentry/junior-plugin-api 0.310.0 → 0.311.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,13 @@
1
- import { $ as eventSourceSchema, A as Source, B as createWebSource, C as PluginReranker, D as SlackInvocationContext, E as SlackDestination, F as WebInvocationContext, G as PluginCache, H as isPrivateSource, I as WebSource, J as agentInvocationSourceSchema, K as actorSchema, L as createEventSource, M as SystemActor, N as User, O as SlackLocation, P as WebActor, Q as eventAutomationSourceSchema, R as createLocalSource, S as PluginModel, St as webSourceSchema, T as SlackActor, U as isSlackDestination, V as getSourceKey, W as CacheEntry, X as destinationVisibilitySchema, Y as destinationSchema, Z as dispatchOptionsSchema, _ as PluginDispatchSource, _t as sourceVisibilitySchema, a as EventInvocationContext, at as locationSchema, b as PluginLogger, bt as userSchema, c as InvocationContext, ct as pluginCredentialSubjectSchema, d as LocalInvocationContext, dt as scheduledAutomationSourceSchema, et as identityDispatchOptionsSchema, f as LocalSource, ft as slackActorSchema, g as PluginDecider, gt as sourceSchema, h as PluginContext, ht as slackSourceSchema, i as EventAutomationSource, it as localSourceSchema, j as SourceVisibility, k as SlackSource, l as LocalActor, lt as pluginDispatchSourceSchema, m as Platform, mt as slackLocationSchema, n as AgentInvocationSource, nt as localActorSchema, o as EventSource, ot as nonBlankStringSchema, p as Location, pt as slackDestinationSchema, q as actorUserIdSchema, r as Destination, rt as localDestinationSchema, s as Identity, st as platformSchema, t as Actor, tt as identitySchema, u as LocalDestination, ut as replyAttributionSchema, v as PluginEmbedder, vt as systemActorSchema, w as ScheduledAutomationSource, x as PluginMetadata, xt as webActorSchema, y as PluginEmbeddingInputType, yt as taskOutcomeSchema, z as createSlackSource } from "./context-Buwf8ZyW.js";
2
1
  import * as z from "zod";
3
2
  import { ZodTypeAny } from "zod";
4
3
  import { Command } from "commander";
4
+ /** A code change's size as its provider counts it. Unknown parts stay unset. */
5
+ export declare const codeChangeSizeSchema: z.ZodObject<{
6
+ changedFiles: z.ZodOptional<z.ZodNumber>;
7
+ additions: z.ZodOptional<z.ZodNumber>;
8
+ deletions: z.ZodOptional<z.ZodNumber>;
9
+ }, z.core.$strict>;
10
+ export type CodeChangeSize = z.output<typeof codeChangeSizeSchema>;
5
11
  /** The longest object summary, in UTF-16 code units. */
6
12
  export declare const OBJECT_SUMMARY_MAX_LENGTH = 280;
7
13
  /** Small, provider-neutral facts. Missing values mean unknown, not success. */
@@ -735,6 +741,526 @@ export declare const objectIconPaths: {
735
741
  package: string[];
736
742
  apps: string[];
737
743
  };
744
+ /** Exact non-blank actor user id that rejects the sentinel "unknown". */
745
+ export declare const actorUserIdSchema: z.ZodString;
746
+ export declare const nonBlankStringSchema: z.ZodString;
747
+ /** Complete Slack Location associated with a Conversation. */
748
+ export declare const slackLocationSchema: z.ZodObject<{
749
+ id: z.ZodString;
750
+ provider: z.ZodLiteral<"slack">;
751
+ teamId: z.ZodString;
752
+ channelId: z.ZodString;
753
+ threadTs: z.ZodOptional<z.ZodString>;
754
+ }, z.core.$strict>;
755
+ /** Complete Location types supported by Junior. */
756
+ export declare const locationSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
757
+ id: z.ZodString;
758
+ provider: z.ZodLiteral<"slack">;
759
+ teamId: z.ZodString;
760
+ channelId: z.ZodString;
761
+ threadTs: z.ZodOptional<z.ZodString>;
762
+ }, z.core.$strict>], "provider">;
763
+ /** Runtime platform names supported by plugin public contracts. */
764
+ export declare const platformSchema: z.ZodEnum<{
765
+ local: "local";
766
+ slack: "slack";
767
+ }>;
768
+ /** Runtime source visibility visible to plugins. */
769
+ export declare const sourceVisibilitySchema: z.ZodEnum<{
770
+ private: "private";
771
+ public: "public";
772
+ }>;
773
+ /** Provider-neutral visibility of a routed destination. */
774
+ export declare const destinationVisibilitySchema: z.ZodEnum<{
775
+ private: "private";
776
+ public: "public";
777
+ }>;
778
+ /** Runtime-owned Slack address for routing future work or side effects. */
779
+ export declare const slackDestinationSchema: z.ZodObject<{
780
+ platform: z.ZodLiteral<"slack">;
781
+ teamId: z.ZodString;
782
+ channelId: z.ZodString;
783
+ threadTs: z.ZodOptional<z.ZodString>;
784
+ }, z.core.$strict>;
785
+ /** Runtime-owned local CLI conversation address. */
786
+ export declare const localDestinationSchema: z.ZodObject<{
787
+ platform: z.ZodLiteral<"local">;
788
+ conversationId: z.ZodString;
789
+ }, z.core.$strict>;
790
+ /** Runtime-owned provider-neutral address for routing future work or side effects. */
791
+ export declare const destinationSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
792
+ platform: z.ZodLiteral<"slack">;
793
+ teamId: z.ZodString;
794
+ channelId: z.ZodString;
795
+ threadTs: z.ZodOptional<z.ZodString>;
796
+ }, z.core.$strict>, z.ZodObject<{
797
+ platform: z.ZodLiteral<"local">;
798
+ conversationId: z.ZodString;
799
+ }, z.core.$strict>], "platform">;
800
+ /** One visible effect after successful automated work. */
801
+ export declare const taskOutcomeSchema: z.ZodObject<{
802
+ action: z.ZodLiteral<"send_message">;
803
+ destination: z.ZodObject<{
804
+ platform: z.ZodLiteral<"slack">;
805
+ teamId: z.ZodString;
806
+ channelId: z.ZodString;
807
+ threadTs: z.ZodOptional<z.ZodString>;
808
+ }, z.core.$strict>;
809
+ }, z.core.$strict>;
810
+ /** Runtime-owned Slack input Source. */
811
+ export declare const slackSourceSchema: z.ZodObject<{
812
+ kind: z.ZodLiteral<"slack">;
813
+ teamId: z.ZodString;
814
+ channelId: z.ZodString;
815
+ visibility: z.ZodEnum<{
816
+ private: "private";
817
+ public: "public";
818
+ }>;
819
+ messageTs: z.ZodOptional<z.ZodString>;
820
+ threadTs: z.ZodOptional<z.ZodString>;
821
+ }, z.core.$strict>;
822
+ /** Runtime-owned local CLI input Source. */
823
+ export declare const localSourceSchema: z.ZodObject<{
824
+ kind: z.ZodLiteral<"local">;
825
+ visibility: z.ZodLiteral<"private">;
826
+ conversationId: z.ZodString;
827
+ }, z.core.$strict>;
828
+ /** Runtime-owned dashboard input Source. */
829
+ export declare const webSourceSchema: z.ZodObject<{
830
+ kind: z.ZodLiteral<"web">;
831
+ visibility: z.ZodEnum<{
832
+ private: "private";
833
+ public: "public";
834
+ }>;
835
+ conversationId: z.ZodString;
836
+ }, z.core.$strict>;
837
+ /** Runtime-owned Event input Source. */
838
+ export declare const eventSourceSchema: z.ZodObject<{
839
+ kind: z.ZodLiteral<"event">;
840
+ eventKey: z.ZodString;
841
+ eventType: z.ZodString;
842
+ identifier: z.ZodString;
843
+ namespace: z.ZodString;
844
+ }, z.core.$strict>;
845
+ /** Runtime-owned Scheduled automation input Source. */
846
+ export declare const scheduledAutomationSourceSchema: z.ZodObject<{
847
+ automationId: z.ZodOptional<z.ZodString>;
848
+ automationRunId: z.ZodOptional<z.ZodString>;
849
+ kind: z.ZodLiteral<"scheduled_automation">;
850
+ }, z.core.$strict>;
851
+ /** Runtime-owned Event automation input Source. */
852
+ export declare const eventAutomationSourceSchema: z.ZodObject<{
853
+ automationId: z.ZodOptional<z.ZodString>;
854
+ automationRunId: z.ZodOptional<z.ZodString>;
855
+ kind: z.ZodLiteral<"event_automation">;
856
+ }, z.core.$strict>;
857
+ /** Runtime-owned Plugin dispatch input Source. */
858
+ export declare const pluginDispatchSourceSchema: z.ZodObject<{
859
+ kind: z.ZodLiteral<"plugin_dispatch">;
860
+ }, z.core.$strict>;
861
+ /** Runtime-owned Agent invocation input Source. */
862
+ export declare const agentInvocationSourceSchema: z.ZodObject<{
863
+ kind: z.ZodLiteral<"agent_invocation">;
864
+ }, z.core.$strict>;
865
+ /** Runtime-owned input Source. Stored `platform` and Location fields normalize on read. */
866
+ export declare const sourceSchema: z.ZodPreprocess<z.ZodDiscriminatedUnion<[z.ZodObject<{
867
+ kind: z.ZodLiteral<"slack">;
868
+ teamId: z.ZodString;
869
+ channelId: z.ZodString;
870
+ visibility: z.ZodEnum<{
871
+ private: "private";
872
+ public: "public";
873
+ }>;
874
+ messageTs: z.ZodOptional<z.ZodString>;
875
+ threadTs: z.ZodOptional<z.ZodString>;
876
+ }, z.core.$strict>, z.ZodObject<{
877
+ kind: z.ZodLiteral<"local">;
878
+ visibility: z.ZodLiteral<"private">;
879
+ conversationId: z.ZodString;
880
+ }, z.core.$strict>, z.ZodObject<{
881
+ kind: z.ZodLiteral<"web">;
882
+ visibility: z.ZodEnum<{
883
+ private: "private";
884
+ public: "public";
885
+ }>;
886
+ conversationId: z.ZodString;
887
+ }, z.core.$strict>, z.ZodObject<{
888
+ kind: z.ZodLiteral<"event">;
889
+ eventKey: z.ZodString;
890
+ eventType: z.ZodString;
891
+ identifier: z.ZodString;
892
+ namespace: z.ZodString;
893
+ }, z.core.$strict>, z.ZodObject<{
894
+ automationId: z.ZodOptional<z.ZodString>;
895
+ automationRunId: z.ZodOptional<z.ZodString>;
896
+ kind: z.ZodLiteral<"scheduled_automation">;
897
+ }, z.core.$strict>, z.ZodObject<{
898
+ automationId: z.ZodOptional<z.ZodString>;
899
+ automationRunId: z.ZodOptional<z.ZodString>;
900
+ kind: z.ZodLiteral<"event_automation">;
901
+ }, z.core.$strict>, z.ZodObject<{
902
+ kind: z.ZodLiteral<"plugin_dispatch">;
903
+ }, z.core.$strict>, z.ZodObject<{
904
+ kind: z.ZodLiteral<"agent_invocation">;
905
+ }, z.core.$strict>], "kind">, unknown>;
906
+ /** Stable user credential subject shape accepted from plugins. */
907
+ export declare const pluginCredentialSubjectSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
908
+ type: z.ZodLiteral<"user">;
909
+ userId: z.ZodString;
910
+ allowedWhen: z.ZodLiteral<"private-direct-conversation">;
911
+ }, z.core.$strict>, z.ZodObject<{
912
+ type: z.ZodLiteral<"user">;
913
+ userId: z.ZodString;
914
+ allowedWhen: z.ZodLiteral<"scheduled-automation">;
915
+ taskId: z.ZodString;
916
+ }, z.core.$strict>], "allowedWhen">;
917
+ export declare const slackActorSchema: z.ZodObject<{
918
+ email: z.ZodOptional<z.ZodString>;
919
+ fullName: z.ZodOptional<z.ZodString>;
920
+ userId: z.ZodString;
921
+ userName: z.ZodOptional<z.ZodString>;
922
+ platform: z.ZodLiteral<"slack">;
923
+ teamId: z.ZodString;
924
+ }, z.core.$strict>;
925
+ export declare const localActorSchema: z.ZodObject<{
926
+ email: z.ZodOptional<z.ZodString>;
927
+ fullName: z.ZodOptional<z.ZodString>;
928
+ userId: z.ZodString;
929
+ userName: z.ZodOptional<z.ZodString>;
930
+ platform: z.ZodLiteral<"local">;
931
+ }, z.core.$strict>;
932
+ export declare const webActorSchema: z.ZodObject<{
933
+ email: z.ZodOptional<z.ZodString>;
934
+ fullName: z.ZodOptional<z.ZodString>;
935
+ userId: z.ZodString;
936
+ userName: z.ZodOptional<z.ZodString>;
937
+ platform: z.ZodLiteral<"web">;
938
+ }, z.core.$strict>;
939
+ export declare const systemActorSchema: z.ZodObject<{
940
+ platform: z.ZodLiteral<"system">;
941
+ name: z.ZodString;
942
+ }, z.core.$strict>;
943
+ /** Runtime-provided actor identity visible to plugin hooks. */
944
+ export declare const actorSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
945
+ email: z.ZodOptional<z.ZodString>;
946
+ fullName: z.ZodOptional<z.ZodString>;
947
+ userId: z.ZodString;
948
+ userName: z.ZodOptional<z.ZodString>;
949
+ platform: z.ZodLiteral<"slack">;
950
+ teamId: z.ZodString;
951
+ }, z.core.$strict>, z.ZodObject<{
952
+ email: z.ZodOptional<z.ZodString>;
953
+ fullName: z.ZodOptional<z.ZodString>;
954
+ userId: z.ZodString;
955
+ userName: z.ZodOptional<z.ZodString>;
956
+ platform: z.ZodLiteral<"local">;
957
+ }, z.core.$strict>, z.ZodObject<{
958
+ email: z.ZodOptional<z.ZodString>;
959
+ fullName: z.ZodOptional<z.ZodString>;
960
+ userId: z.ZodString;
961
+ userName: z.ZodOptional<z.ZodString>;
962
+ platform: z.ZodLiteral<"web">;
963
+ }, z.core.$strict>, z.ZodObject<{
964
+ platform: z.ZodLiteral<"system">;
965
+ name: z.ZodString;
966
+ }, z.core.$strict>], "platform">;
967
+ /** Core-owned provider account linked to a user when verified. */
968
+ export declare const identitySchema: z.ZodObject<{
969
+ displayName: z.ZodOptional<z.ZodString>;
970
+ handle: z.ZodOptional<z.ZodString>;
971
+ id: z.ZodString;
972
+ provider: z.ZodString;
973
+ providerSubjectId: z.ZodString;
974
+ providerTenantId: z.ZodOptional<z.ZodString>;
975
+ }, z.core.$strict>;
976
+ /** Core-owned person with every linked provider identity. */
977
+ export declare const userSchema: z.ZodObject<{
978
+ displayName: z.ZodOptional<z.ZodString>;
979
+ email: z.ZodString;
980
+ id: z.ZodString;
981
+ identities: z.ZodArray<z.ZodObject<{
982
+ displayName: z.ZodOptional<z.ZodString>;
983
+ handle: z.ZodOptional<z.ZodString>;
984
+ id: z.ZodString;
985
+ provider: z.ZodString;
986
+ providerSubjectId: z.ZodString;
987
+ providerTenantId: z.ZodOptional<z.ZodString>;
988
+ }, z.core.$strict>>;
989
+ isAdmin: z.ZodOptional<z.ZodLiteral<true>>;
990
+ }, z.core.$strict>;
991
+ /** Compact destination-visible context explaining what produced a reply. */
992
+ export declare const replyAttributionSchema: z.ZodObject<{
993
+ label: z.ZodPipe<z.ZodString, z.ZodString>;
994
+ detail: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodString>>;
995
+ }, z.core.$strict>;
996
+ /**
997
+ * Plugin request to start work for one person. `input` becomes that person's
998
+ * first Message in a new public Conversation, so it must be what they asked
999
+ * for, not text that someone else wrote. Name the person by exactly one of:
1000
+ *
1001
+ * - `subjectId`: the provider account id that the OAuth account-linking flow
1002
+ * stored. Core binds the provider to the calling plugin.
1003
+ * - `verifiedEmail`: an address that the plugin proved this person sent from,
1004
+ * such as the From address of an email that passed DMARC. Never an address
1005
+ * that only appears in content.
1006
+ */
1007
+ export declare const identityDispatchOptionsSchema: z.ZodUnion<readonly [z.ZodObject<{
1008
+ idempotencyKey: z.ZodPipe<z.ZodString, z.ZodString>;
1009
+ input: z.ZodPipe<z.ZodString, z.ZodString>;
1010
+ subjectId: z.ZodPipe<z.ZodString, z.ZodString>;
1011
+ }, z.core.$strict>, z.ZodObject<{
1012
+ idempotencyKey: z.ZodPipe<z.ZodString, z.ZodString>;
1013
+ input: z.ZodPipe<z.ZodString, z.ZodString>;
1014
+ verifiedEmail: z.ZodEmail;
1015
+ }, z.core.$strict>]>;
1016
+ /** Plugin dispatch request accepted by Junior core. */
1017
+ export declare const dispatchOptionsSchema: z.ZodObject<{
1018
+ idempotencyKey: z.ZodPipe<z.ZodString, z.ZodString>;
1019
+ credentialSubject: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
1020
+ type: z.ZodLiteral<"user">;
1021
+ userId: z.ZodString;
1022
+ allowedWhen: z.ZodLiteral<"private-direct-conversation">;
1023
+ }, z.core.$strict>, z.ZodObject<{
1024
+ type: z.ZodLiteral<"user">;
1025
+ userId: z.ZodString;
1026
+ allowedWhen: z.ZodLiteral<"scheduled-automation">;
1027
+ taskId: z.ZodString;
1028
+ }, z.core.$strict>], "allowedWhen">>;
1029
+ destination: z.ZodObject<{
1030
+ platform: z.ZodLiteral<"slack">;
1031
+ teamId: z.ZodString;
1032
+ channelId: z.ZodString;
1033
+ threadTs: z.ZodOptional<z.ZodString>;
1034
+ }, z.core.$strict>;
1035
+ destinationVisibility: z.ZodEnum<{
1036
+ private: "private";
1037
+ public: "public";
1038
+ }>;
1039
+ input: z.ZodPipe<z.ZodString, z.ZodString>;
1040
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1041
+ replyAttribution: z.ZodOptional<z.ZodObject<{
1042
+ label: z.ZodPipe<z.ZodString, z.ZodString>;
1043
+ detail: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodString>>;
1044
+ }, z.core.$strict>>;
1045
+ title: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodString>>;
1046
+ }, z.core.$strict>;
1047
+ /** A loaded value and how long to cache it. */
1048
+ export interface CacheEntry<T> {
1049
+ /** Omit to return the value without caching it, such as for an incomplete response. */
1050
+ ttlMs?: number;
1051
+ /** Must survive JSON serialization. */
1052
+ value: T;
1053
+ }
1054
+ /**
1055
+ * Short-lived copies of values that are slow or costly to load, such as
1056
+ * provider API reads. Junior can drop an entry at any time. A lost entry only
1057
+ * costs a reload, so never keep data here that Junior must not lose. Use
1058
+ * `PluginState` for that.
1059
+ */
1060
+ export interface PluginCache {
1061
+ /**
1062
+ * Return the cached value for `key`, or call `load` and cache its result.
1063
+ * Concurrent callers share one load. A load that throws is not cached.
1064
+ * `refresh` ignores the cached value and replaces it.
1065
+ */
1066
+ getOrLoad<T>(key: string, load: () => Promise<CacheEntry<T>>, options?: {
1067
+ refresh?: boolean;
1068
+ }): Promise<T>;
1069
+ }
1070
+ /** Runtime platform name without source or destination coordinates. */
1071
+ export type Platform = z.output<typeof platformSchema>;
1072
+ export type Actor = z.output<typeof actorSchema>;
1073
+ export type SlackActor = z.output<typeof slackActorSchema>;
1074
+ export type LocalActor = z.output<typeof localActorSchema>;
1075
+ export type WebActor = z.output<typeof webActorSchema>;
1076
+ export type SystemActor = z.output<typeof systemActorSchema>;
1077
+ export type Identity = z.output<typeof identitySchema>;
1078
+ export type User = z.output<typeof userSchema>;
1079
+ export type Source = z.output<typeof sourceSchema>;
1080
+ /** Validated Location associated with a Conversation. */
1081
+ export type Location = z.output<typeof locationSchema>;
1082
+ /** Complete Slack Location associated with a Conversation. */
1083
+ export type SlackLocation = z.output<typeof slackLocationSchema>;
1084
+ export type SlackSource = Extract<Source, {
1085
+ kind: "slack";
1086
+ }>;
1087
+ export type LocalSource = Extract<Source, {
1088
+ kind: "local";
1089
+ }>;
1090
+ export type WebSource = Extract<Source, {
1091
+ kind: "web";
1092
+ }>;
1093
+ export type EventSource = Extract<Source, {
1094
+ kind: "event";
1095
+ }>;
1096
+ export type ScheduledAutomationSource = Extract<Source, {
1097
+ kind: "scheduled_automation";
1098
+ }>;
1099
+ export type EventAutomationSource = Extract<Source, {
1100
+ kind: "event_automation";
1101
+ }>;
1102
+ export type PluginDispatchSource = Extract<Source, {
1103
+ kind: "plugin_dispatch";
1104
+ }>;
1105
+ export type AgentInvocationSource = Extract<Source, {
1106
+ kind: "agent_invocation";
1107
+ }>;
1108
+ export type SourceVisibility = z.output<typeof sourceVisibilitySchema>;
1109
+ export type Destination = z.output<typeof destinationSchema>;
1110
+ export type SlackDestination = Extract<Destination, {
1111
+ platform: "slack";
1112
+ }>;
1113
+ export type LocalDestination = Extract<Destination, {
1114
+ platform: "local";
1115
+ }>;
1116
+ export interface PluginMetadata {
1117
+ name: string;
1118
+ }
1119
+ export interface PluginLogger {
1120
+ error(message: string, metadata?: Record<string, unknown>): void;
1121
+ info(message: string, metadata?: Record<string, unknown>): void;
1122
+ warn(message: string, metadata?: Record<string, unknown>): void;
1123
+ }
1124
+ export interface PluginModel {
1125
+ /** Run a host-owned structured model call without exposing provider credentials. */
1126
+ completeObject<TSchema extends ZodTypeAny>(input: {
1127
+ /** Tokens for the object itself. The host adds room for reasoning. */
1128
+ maxTokens?: number;
1129
+ prompt: string;
1130
+ schema: TSchema;
1131
+ system?: string;
1132
+ }): Promise<{
1133
+ /** Best-effort estimated provider cost for this completion. */
1134
+ costUsd?: number;
1135
+ object: z.infer<TSchema>;
1136
+ }>;
1137
+ }
1138
+ /** Host decision model: a fast classifier for one narrow choice, with no reasoning. */
1139
+ export interface PluginDecider {
1140
+ /**
1141
+ * Pick the choice whose criteria fit `state`. `instructions` say what to
1142
+ * judge. Keep the state as evidence only; it is not instructions.
1143
+ */
1144
+ decide<TChoice extends string>(input: {
1145
+ criteria: Record<TChoice, string>;
1146
+ instructions: string;
1147
+ state: string;
1148
+ }): Promise<{
1149
+ choice: TChoice;
1150
+ /** Best-effort estimated provider cost for this decision. */
1151
+ costUsd?: number;
1152
+ /** Probability of each choice, when the provider returns them. */
1153
+ probabilities?: Partial<Record<TChoice, number>>;
1154
+ }>;
1155
+ }
1156
+ /** How embedded text is used. Some models embed queries and documents differently. */
1157
+ export type PluginEmbeddingInputType = "document" | "query";
1158
+ export interface PluginEmbedder {
1159
+ /** Configured embedding model id; embedTexts() reports the same value. */
1160
+ model: string;
1161
+ /** Provider name that embedTexts() reports. */
1162
+ provider: string;
1163
+ /** Embed plugin-owned text for derived retrieval without exposing provider credentials. */
1164
+ embedTexts(input: {
1165
+ inputType?: PluginEmbeddingInputType;
1166
+ texts: string[];
1167
+ }): Promise<{
1168
+ /** Best-effort estimated provider cost for this embedding call. */
1169
+ costUsd?: number;
1170
+ dimensions: number;
1171
+ model: string;
1172
+ provider: string;
1173
+ vectors: number[][];
1174
+ }>;
1175
+ }
1176
+ export interface PluginReranker {
1177
+ /** Score plugin-owned documents against one query without exposing provider credentials. */
1178
+ rerank(input: {
1179
+ documents: string[];
1180
+ query: string;
1181
+ }): Promise<{
1182
+ /** Best-effort provider cost for this reranking call. */
1183
+ costUsd?: number;
1184
+ /** One relevance score per document, in input order. Higher is more relevant. */
1185
+ scores: number[];
1186
+ }>;
1187
+ }
1188
+ export interface PluginContext {
1189
+ /** Short-lived cache scoped to this plugin. */
1190
+ cache: PluginCache;
1191
+ /** Shared Drizzle database connection for plugin runtime code. */
1192
+ db: unknown;
1193
+ log: PluginLogger;
1194
+ plugin: PluginMetadata;
1195
+ }
1196
+ interface BaseInvocationContext {
1197
+ /**
1198
+ * Opaque Junior conversation/session identity for this invocation.
1199
+ * Interactive Slack turns use `slack:{channelId}:{threadTs}`.
1200
+ */
1201
+ conversationId?: string;
1202
+ /** Location associated with this Conversation. */
1203
+ locationId?: string | undefined;
1204
+ }
1205
+ export interface SlackInvocationContext extends BaseInvocationContext {
1206
+ /** Runtime-owned default outbound destination for this invocation. */
1207
+ destination: SlackDestination;
1208
+ actor?: SlackActor | undefined;
1209
+ /** Runtime-owned source where the invocation came from. */
1210
+ source: SlackSource;
1211
+ }
1212
+ export interface LocalInvocationContext extends BaseInvocationContext {
1213
+ /** Runtime-owned default outbound destination for this invocation. */
1214
+ destination: LocalDestination;
1215
+ actor?: LocalActor | undefined;
1216
+ /** Runtime-owned source where the invocation came from. */
1217
+ source: LocalSource;
1218
+ }
1219
+ export interface WebInvocationContext extends BaseInvocationContext {
1220
+ /** Existing conversation destination used for location and tool context. */
1221
+ destination: Destination;
1222
+ actor?: WebActor | undefined;
1223
+ /** Runtime-owned dashboard/web source for this invocation. */
1224
+ source: WebSource;
1225
+ }
1226
+ export interface EventInvocationContext extends BaseInvocationContext {
1227
+ /** Existing conversation destination used for tool context. */
1228
+ destination: Destination;
1229
+ actor?: Actor;
1230
+ /** Runtime-owned Event Source for this invocation. */
1231
+ source: EventSource;
1232
+ }
1233
+ export type InvocationContext = LocalInvocationContext | SlackInvocationContext | WebInvocationContext | (BaseInvocationContext & {
1234
+ destination: Destination;
1235
+ actor?: Actor | undefined;
1236
+ source: AgentInvocationSource | EventAutomationSource | PluginDispatchSource | EventSource | ScheduledAutomationSource;
1237
+ });
1238
+ /** Build a normalized Slack source from runtime-owned Slack coordinates. */
1239
+ export declare function createSlackSource(input: {
1240
+ channelId: string;
1241
+ messageTs?: string | undefined;
1242
+ teamId: string;
1243
+ threadTs?: string | undefined;
1244
+ /** Runtime-normalized source visibility. */
1245
+ visibility: SourceVisibility;
1246
+ }): SlackSource;
1247
+ /** Build a normalized local source from a local conversation id. */
1248
+ export declare function createLocalSource(conversationId: string): LocalSource;
1249
+ /** Build a normalized web/dashboard source from a conversation id. */
1250
+ export declare function createWebSource(conversationId: string, visibility?: SourceVisibility): WebSource;
1251
+ /** Build a normalized Event Source from one matched event. */
1252
+ export declare function createEventSource(input: {
1253
+ eventKey: string;
1254
+ eventType: string;
1255
+ identifier: string;
1256
+ namespace: string;
1257
+ }): EventSource;
1258
+ /** Return whether a source is private to a person or restricted group. */
1259
+ export declare function isPrivateSource(source: Source): boolean;
1260
+ /** Return the stable source identity used for idempotency and attribution. */
1261
+ export declare function getSourceKey(source: Source): string | undefined;
1262
+ /** Narrow a runtime destination to the Slack-specific address shape. */
1263
+ export declare function isSlackDestination(destination: Destination | undefined): destination is SlackDestination;
738
1264
  declare const pluginGrantAccessSchema: z.ZodUnion<readonly [z.ZodLiteral<"read">, z.ZodLiteral<"write">]>;
739
1265
  /** Runtime schema for provider authorization a plugin may request. */
740
1266
  export declare const pluginAuthorizationSchema: z.ZodObject<{
@@ -1378,6 +1904,11 @@ export declare const conversationSidebarAnnotationSchema: z.ZodObject<{
1378
1904
  title: z.ZodOptional<z.ZodString>;
1379
1905
  url: z.ZodOptional<z.ZodString>;
1380
1906
  imageUrl: z.ZodOptional<z.ZodString>;
1907
+ size: z.ZodOptional<z.ZodObject<{
1908
+ changedFiles: z.ZodOptional<z.ZodNumber>;
1909
+ additions: z.ZodOptional<z.ZodNumber>;
1910
+ deletions: z.ZodOptional<z.ZodNumber>;
1911
+ }, z.core.$strict>>;
1381
1912
  }, z.core.$strict>;
1382
1913
  export type ConversationSidebarAnnotation = z.output<typeof conversationSidebarAnnotationSchema>;
1383
1914
  export interface ConversationSidebarHookContext extends PluginContext {
@@ -1530,6 +2061,7 @@ export declare const pluginEventDeclarationSchema: z.ZodObject<{
1530
2061
  anyOf: z.ZodArray<z.ZodString>;
1531
2062
  }, z.core.$strict>]>;
1532
2063
  guidance: z.ZodOptional<z.ZodString>;
2064
+ phrase: z.ZodOptional<z.ZodString>;
1533
2065
  }, z.core.$strict>;
1534
2066
  export type PluginEventDeclaration = z.output<typeof pluginEventDeclarationSchema>;
1535
2067
  export declare const pluginEventsSchema: z.ZodObject<{
@@ -1562,6 +2094,7 @@ export declare const pluginEventsSchema: z.ZodObject<{
1562
2094
  anyOf: z.ZodArray<z.ZodString>;
1563
2095
  }, z.core.$strict>]>;
1564
2096
  guidance: z.ZodOptional<z.ZodString>;
2097
+ phrase: z.ZodOptional<z.ZodString>;
1565
2098
  }, z.core.$strict>>;
1566
2099
  isEnabled: z.ZodOptional<z.ZodFunction<z.ZodTuple<readonly [], null>, z.ZodBoolean>>;
1567
2100
  normalizeIdentifier: z.ZodOptional<z.ZodFunction<z.ZodTuple<readonly [z.ZodString], null>, z.ZodString>>;
@@ -1569,6 +2102,10 @@ export declare const pluginEventsSchema: z.ZodObject<{
1569
2102
  identifier: z.ZodString;
1570
2103
  resourceType: z.ZodString;
1571
2104
  }, z.core.$strip>], null>, z.ZodOptional<z.ZodString>>>;
2105
+ resourceForUrl: z.ZodOptional<z.ZodFunction<z.ZodTuple<readonly [z.ZodString], null>, z.ZodOptional<z.ZodObject<{
2106
+ identifier: z.ZodString;
2107
+ resourceType: z.ZodString;
2108
+ }, z.core.$strip>>>>;
1572
2109
  }, z.core.$strict>;
1573
2110
  export type PluginEventType = z.output<typeof pluginEventTypeSchema>;
1574
2111
  export type PluginEvents = z.output<typeof pluginEventsSchema>;
@@ -2720,6 +3257,11 @@ export declare const codeChangeInputSchema: z.ZodObject<{
2720
3257
  providerId: z.ZodString;
2721
3258
  url: z.ZodOptional<z.ZodString>;
2722
3259
  }, z.core.$strict>;
3260
+ size: z.ZodOptional<z.ZodObject<{
3261
+ changedFiles: z.ZodOptional<z.ZodNumber>;
3262
+ additions: z.ZodOptional<z.ZodNumber>;
3263
+ deletions: z.ZodOptional<z.ZodNumber>;
3264
+ }, z.core.$strict>>;
2723
3265
  state: z.ZodEnum<{
2724
3266
  closed: "closed";
2725
3267
  merged: "merged";
@@ -2832,6 +3374,15 @@ export interface PluginConversationEventReader {
2832
3374
  viewer: User;
2833
3375
  }): Promise<PluginConversationEventRecord[] | undefined>;
2834
3376
  }
3377
+ /**
3378
+ * Read events that the current plugin emitted in one Turn. The Turn is bound,
3379
+ * so no Conversation access check is needed.
3380
+ */
3381
+ export interface PluginTurnEventReader {
3382
+ list(input: {
3383
+ eventName: string;
3384
+ }): Promise<PluginConversationEventRecord[]>;
3385
+ }
2835
3386
  /**
2836
3387
  * Events that Junior writes in a plugin's namespace for the cost of each
2837
3388
  * priced `model`, `decider`, `embedder`, or `reranker` call in a
@@ -2892,6 +3443,21 @@ type UserPromptContribution = PromptMessage | PromptContextContribution;
2892
3443
  type SystemPromptContext = Pick<PluginContext, "db" | "log" | "plugin"> & {
2893
3444
  platform: Platform;
2894
3445
  };
3446
+ /** One prompt context that this plugin gave an earlier Turn. */
3447
+ type PromptHistoryContext = PromptContext & {
3448
+ /** When the plugin made it. */
3449
+ loadedAtMs: number;
3450
+ };
3451
+ /** What the model history that a new prompt replays holds. */
3452
+ interface PromptHistory {
3453
+ /**
3454
+ * When this history started: the time of the last History replacement.
3455
+ * Undefined when it holds the whole Conversation.
3456
+ */
3457
+ startedAtMs?: number;
3458
+ /** This plugin's prompt contexts in this history, oldest first. */
3459
+ contexts: PromptHistoryContext[];
3460
+ }
2895
3461
  /** Runtime facts available while building plugin user prompt context. */
2896
3462
  type UserPromptContext = Pick<PluginContext, "db" | "log" | "plugin"> & {
2897
3463
  conversationId?: string;
@@ -2910,9 +3476,20 @@ type UserPromptContext = Pick<PluginContext, "db" | "log" | "plugin"> & {
2910
3476
  setSpanAttributes(attributes: Record<string, number>): void;
2911
3477
  /** Location associated with this Conversation. */
2912
3478
  locationId?: string | undefined;
3479
+ /**
3480
+ * Read the model history that this prompt replays, such as to skip context
3481
+ * that the model still has. Undefined when the prompt has no Conversation.
3482
+ */
3483
+ loadHistory?(): Promise<PromptHistory>;
2913
3484
  actor?: Actor | undefined;
2914
3485
  source: Source;
2915
3486
  state: PluginState;
3487
+ /**
3488
+ * The request of this Turn: what a person wrote, the task or message of a
3489
+ * parent agent, or the instructions of an Automation. Runtime text, such as
3490
+ * tags, generic instructions, Events, child agent results, and the question
3491
+ * of a Review item, is not in it. Empty when the Turn has no request.
3492
+ */
2916
3493
  text: string;
2917
3494
  users: {
2918
3495
  /** Resolve the current Actor's Identity and User. */
@@ -3391,6 +3968,8 @@ export interface PluginTaskContext extends PluginContext {
3391
3968
  load(): Promise<PluginRunContext>;
3392
3969
  };
3393
3970
  state: PluginState;
3971
+ /** Events that this plugin emitted in the completed Turn, oldest first. */
3972
+ turnEvents: PluginTurnEventReader;
3394
3973
  }
3395
3974
  /** Plugin task handler registered by name in a plugin manifest module. */
3396
3975
  export interface PluginTaskDefinition {
@@ -3399,7 +3978,7 @@ export interface PluginTaskDefinition {
3399
3978
  /** Task handlers keyed by the plugin-owned task name. */
3400
3979
  export type PluginTasks = Record<string, PluginTaskDefinition>;
3401
3980
  /**
3402
- * An item that a plugin puts on the review desk: a notice for information,
3981
+ * An item that a plugin puts in the Inbox: a notice for information,
3403
3982
  * or an ask that waits on its assignees.
3404
3983
  */
3405
3984
  export interface PluginReviewNotice {
@@ -3426,6 +4005,16 @@ export interface PluginReviewNotice {
3426
4005
  * `Ready to merge · #946`. It is the reason that the dashboard shows.
3427
4006
  */
3428
4007
  title: string;
4008
+ /**
4009
+ * Buttons that answer the item, in display order, such as `Resume`. An
4010
+ * item with choices waits on its assignees. The first click closes it as
4011
+ * done and calls the plugin's `reviewItemAnswered` hook with the choice.
4012
+ * The answer starts no Turn: the plugin does the work.
4013
+ */
4014
+ choices?: Array<{
4015
+ label: string;
4016
+ description?: string;
4017
+ }>;
3429
4018
  /**
3430
4019
  * The assignees must act, such as merge a pull request that is ready. The
3431
4020
  * item then waits on them: its Conversation shows in their Needs you, and
@@ -3453,6 +4042,37 @@ export interface PluginReviewItems {
3453
4042
  export interface PluginConversationReviewItems {
3454
4043
  forConversation(conversationId: string): PluginReviewItems;
3455
4044
  }
4045
+ /** A person picked one of the `choices` of an item that this plugin added. */
4046
+ export interface ReviewItemAnsweredHookContext extends PluginContext {
4047
+ /** The label of the picked choice. */
4048
+ choice: string;
4049
+ /** The Conversation that the item belongs to. */
4050
+ conversationId: string;
4051
+ /** The plugin's own dedupe key of the item. */
4052
+ dedupeKey: string;
4053
+ /** Publish events, as from a plugin route. */
4054
+ events: EventPublisher;
4055
+ /** The closed item's id. It is the same on a retry of the same answer. */
4056
+ itemId: string;
4057
+ nowMs: number;
4058
+ /** Review items in the Inbox, as from a plugin route. */
4059
+ reviewItems: PluginConversationReviewItems;
4060
+ state: PluginState;
4061
+ /** Watches of the item's Conversation. */
4062
+ watches: PluginConversationWatches;
4063
+ }
4064
+ /** Watches of one Conversation, for a plugin outside a tool call. */
4065
+ export interface PluginConversationWatches extends PluginEventToolContext {
4066
+ /**
4067
+ * Whether an active Watch of this Conversation starts a Turn for this
4068
+ * event type on this plugin resource. Watches of other Conversations and
4069
+ * event automations do not count.
4070
+ */
4071
+ watching(input: {
4072
+ eventType: string;
4073
+ identifier: string;
4074
+ }): Promise<boolean>;
4075
+ }
3456
4076
  export interface HeartbeatHookContext extends PluginContext {
3457
4077
  agent: {
3458
4078
  dispatch(options: DispatchOptions): Promise<DispatchResult>;
@@ -3472,7 +4092,7 @@ export interface HeartbeatHookContext extends PluginContext {
3472
4092
  /** Publish events, as from a plugin route. */
3473
4093
  events: EventPublisher;
3474
4094
  nowMs: number;
3475
- /** Review desk items, as from a plugin route. */
4095
+ /** Review items in the Inbox, as from a plugin route. */
3476
4096
  reviewItems: PluginConversationReviewItems;
3477
4097
  state: PluginState;
3478
4098
  }
@@ -3603,7 +4223,7 @@ export interface RouteRegistrationHookContext extends PluginContext {
3603
4223
  codeChanges: CodeChangePublisher;
3604
4224
  /** Core-owned delivery boundary for provider webhook events. */
3605
4225
  events: EventPublisher;
3606
- /** Review desk items that the plugin adds and closes from its events. */
4226
+ /** Review items in the Inbox that the plugin adds and closes from its events. */
3607
4227
  reviewItems: PluginConversationReviewItems;
3608
4228
  /** Plugin-namespaced state, the same as in heartbeats. */
3609
4229
  state: PluginState;
@@ -3760,6 +4380,12 @@ export interface PluginHooks {
3760
4380
  * return undefined to use those credentials for this request.
3761
4381
  */
3762
4382
  grantForEgress?(ctx: EgressHookContext): Promise<PluginGrant | undefined> | PluginGrant | undefined;
4383
+ /**
4384
+ * Do the work that a person asked for with a choice on an item that this
4385
+ * plugin added. Junior calls it again when the person retries after a
4386
+ * failure, so it must be safe to repeat.
4387
+ */
4388
+ reviewItemAnswered?(ctx: ReviewItemAnsweredHookContext): Promise<void> | void;
3763
4389
  heartbeat?(ctx: HeartbeatHookContext): Promise<HeartbeatResult | void> | HeartbeatResult | void;
3764
4390
  unfinishedWork?(ctx: UnfinishedWorkHookContext): Promise<UnfinishedWorkResult> | UnfinishedWorkResult;
3765
4391
  issueCredential?(ctx: IssueCredentialHookContext): Promise<PluginCredentialResult> | PluginCredentialResult;
@@ -4087,4 +4713,4 @@ export type PluginRegistrationInput = {
4087
4713
  export interface PluginRegistration extends PluginRegistrationInput {}
4088
4714
  /** Define one Junior plugin registration for app and build-time wiring. */
4089
4715
  export declare function defineJuniorPlugin(plugin: PluginRegistrationInput): PluginRegistration;
4090
- export { Actor, AgentInvocationSource, CacheEntry, Destination, EventAutomationSource, EventInvocationContext, EventSource, Identity, InvocationContext, LocalActor, LocalDestination, LocalInvocationContext, LocalSource, Location, Platform, PluginCache, PluginContext, PluginDecider, PluginDispatchSource, PluginEmbedder, PluginEmbeddingInputType, PluginLogger, PluginMetadata, PluginModel, PluginReranker, type PromptContext, type PromptContextContribution, type PromptMessage, ScheduledAutomationSource, SlackActor, SlackDestination, SlackInvocationContext, SlackLocation, SlackSource, Source, SourceVisibility, SystemActor, type SystemPromptContext, User, type UserPromptContext, type UserPromptContribution, WebActor, WebInvocationContext, WebSource, actorSchema, actorUserIdSchema, agentInvocationSourceSchema, createEventSource, createLocalSource, createSlackSource, createWebSource, destinationSchema, destinationVisibilitySchema, dispatchOptionsSchema, eventAutomationSourceSchema, eventSourceSchema, getSourceKey, identityDispatchOptionsSchema, identitySchema, isPrivateSource, isSlackDestination, localActorSchema, localDestinationSchema, localSourceSchema, locationSchema, nonBlankStringSchema, platformSchema, pluginCredentialSubjectSchema, pluginDispatchSourceSchema, replyAttributionSchema, scheduledAutomationSourceSchema, slackActorSchema, slackDestinationSchema, slackLocationSchema, slackSourceSchema, sourceSchema, sourceVisibilitySchema, systemActorSchema, taskOutcomeSchema, userSchema, webActorSchema, webSourceSchema };
4716
+ export type { PromptContext, PromptContextContribution, PromptHistory, PromptHistoryContext, PromptMessage, SystemPromptContext, UserPromptContext, UserPromptContribution };