@sentry/junior-plugin-api 0.313.0 → 0.315.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 +421 -101
- package/dist/index.js +117 -26
- package/package.json +5 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as z from "zod";
|
|
2
2
|
import { ZodTypeAny } from "zod";
|
|
3
3
|
import { Command } from "commander";
|
|
4
|
+
import { Nodes, Root } from "mdast";
|
|
4
5
|
/** A code change's size as its provider counts it. Unknown parts stay unset. */
|
|
5
6
|
export declare const codeChangeSizeSchema: z.ZodObject<{
|
|
6
7
|
changedFiles: z.ZodOptional<z.ZodNumber>;
|
|
@@ -23,12 +24,12 @@ export declare const objectFactsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
23
24
|
changes_requested: "changes_requested";
|
|
24
25
|
required: "required";
|
|
25
26
|
}>>;
|
|
26
|
-
checks: z.ZodOptional<z.ZodObject<{
|
|
27
|
+
checks: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
27
28
|
passed: z.ZodNumber;
|
|
28
29
|
failed: z.ZodNumber;
|
|
29
30
|
pending: z.ZodNumber;
|
|
30
|
-
}, z.core.$strict>>;
|
|
31
|
-
mergeable: z.ZodOptional<z.ZodBoolean
|
|
31
|
+
}, z.core.$strict>, z.ZodLiteral<"pending">]>>;
|
|
32
|
+
mergeable: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"pending">]>>;
|
|
32
33
|
changedFiles: z.ZodOptional<z.ZodNumber>;
|
|
33
34
|
additions: z.ZodOptional<z.ZodNumber>;
|
|
34
35
|
deletions: z.ZodOptional<z.ZodNumber>;
|
|
@@ -317,12 +318,12 @@ export declare const objectAnnotationSchema: z.ZodObject<{
|
|
|
317
318
|
changes_requested: "changes_requested";
|
|
318
319
|
required: "required";
|
|
319
320
|
}>>;
|
|
320
|
-
checks: z.ZodOptional<z.ZodObject<{
|
|
321
|
+
checks: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
321
322
|
passed: z.ZodNumber;
|
|
322
323
|
failed: z.ZodNumber;
|
|
323
324
|
pending: z.ZodNumber;
|
|
324
|
-
}, z.core.$strict>>;
|
|
325
|
-
mergeable: z.ZodOptional<z.ZodBoolean
|
|
325
|
+
}, z.core.$strict>, z.ZodLiteral<"pending">]>>;
|
|
326
|
+
mergeable: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"pending">]>>;
|
|
326
327
|
changedFiles: z.ZodOptional<z.ZodNumber>;
|
|
327
328
|
additions: z.ZodOptional<z.ZodNumber>;
|
|
328
329
|
deletions: z.ZodOptional<z.ZodNumber>;
|
|
@@ -539,12 +540,12 @@ export declare const ownedObjectAnnotationSchema: z.ZodObject<{
|
|
|
539
540
|
changes_requested: "changes_requested";
|
|
540
541
|
required: "required";
|
|
541
542
|
}>>;
|
|
542
|
-
checks: z.ZodOptional<z.ZodObject<{
|
|
543
|
+
checks: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
543
544
|
passed: z.ZodNumber;
|
|
544
545
|
failed: z.ZodNumber;
|
|
545
546
|
pending: z.ZodNumber;
|
|
546
|
-
}, z.core.$strict>>;
|
|
547
|
-
mergeable: z.ZodOptional<z.ZodBoolean
|
|
547
|
+
}, z.core.$strict>, z.ZodLiteral<"pending">]>>;
|
|
548
|
+
mergeable: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"pending">]>>;
|
|
548
549
|
changedFiles: z.ZodOptional<z.ZodNumber>;
|
|
549
550
|
additions: z.ZodOptional<z.ZodNumber>;
|
|
550
551
|
deletions: z.ZodOptional<z.ZodNumber>;
|
|
@@ -858,9 +859,9 @@ export declare const eventAutomationSourceSchema: z.ZodObject<{
|
|
|
858
859
|
export declare const pluginDispatchSourceSchema: z.ZodObject<{
|
|
859
860
|
kind: z.ZodLiteral<"plugin_dispatch">;
|
|
860
861
|
}, z.core.$strict>;
|
|
861
|
-
/** Runtime-owned
|
|
862
|
-
export declare const
|
|
863
|
-
kind: z.ZodLiteral<"
|
|
862
|
+
/** Runtime-owned Source of a parent agent's task or message to a child agent. */
|
|
863
|
+
export declare const parentMessageSourceSchema: z.ZodObject<{
|
|
864
|
+
kind: z.ZodLiteral<"parent_message">;
|
|
864
865
|
}, z.core.$strict>;
|
|
865
866
|
/** Runtime-owned input Source. Stored `platform` and Location fields normalize on read. */
|
|
866
867
|
export declare const sourceSchema: z.ZodPreprocess<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -901,7 +902,7 @@ export declare const sourceSchema: z.ZodPreprocess<z.ZodDiscriminatedUnion<[z.Zo
|
|
|
901
902
|
}, z.core.$strict>, z.ZodObject<{
|
|
902
903
|
kind: z.ZodLiteral<"plugin_dispatch">;
|
|
903
904
|
}, z.core.$strict>, z.ZodObject<{
|
|
904
|
-
kind: z.ZodLiteral<"
|
|
905
|
+
kind: z.ZodLiteral<"parent_message">;
|
|
905
906
|
}, z.core.$strict>], "kind">, unknown>;
|
|
906
907
|
/** Stable user credential subject shape accepted from plugins. */
|
|
907
908
|
export declare const pluginCredentialSubjectSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -1048,6 +1049,12 @@ export declare const dispatchOptionsSchema: z.ZodObject<{
|
|
|
1048
1049
|
export interface CacheEntry<T> {
|
|
1049
1050
|
/** Omit to return the value without caching it, such as for an incomplete response. */
|
|
1050
1051
|
ttlMs?: number;
|
|
1052
|
+
/**
|
|
1053
|
+
* Keep the value for a day after its TTL, and return it when a later load
|
|
1054
|
+
* throws, such as during a provider outage. Never set it on an answer
|
|
1055
|
+
* about access: access must expire with its TTL.
|
|
1056
|
+
*/
|
|
1057
|
+
staleIfError?: boolean;
|
|
1051
1058
|
/** Must survive JSON serialization. */
|
|
1052
1059
|
value: T;
|
|
1053
1060
|
}
|
|
@@ -1060,12 +1067,32 @@ export interface CacheEntry<T> {
|
|
|
1060
1067
|
export interface PluginCache {
|
|
1061
1068
|
/**
|
|
1062
1069
|
* 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
|
|
1070
|
+
* Concurrent callers share one load. A load that throws is not cached,
|
|
1071
|
+
* and it throws to the caller unless a `staleIfError` value is kept.
|
|
1064
1072
|
* `refresh` ignores the cached value and replaces it.
|
|
1065
1073
|
*/
|
|
1074
|
+
/**
|
|
1075
|
+
* Return the fresh cached value of `key`, or `undefined` when there is
|
|
1076
|
+
* none. It never loads, so a caller can find the misses of many keys and
|
|
1077
|
+
* load them in one provider call.
|
|
1078
|
+
*/
|
|
1079
|
+
get<T>(key: string): Promise<T | undefined>;
|
|
1066
1080
|
getOrLoad<T>(key: string, load: () => Promise<CacheEntry<T>>, options?: {
|
|
1067
1081
|
refresh?: boolean;
|
|
1068
1082
|
}): Promise<T>;
|
|
1083
|
+
/**
|
|
1084
|
+
* Replace the cached value of `key` with the entry that `next` returns,
|
|
1085
|
+
* such as when a provider webhook carries the changed object. `next` gets
|
|
1086
|
+
* the cached value, also a stale one, or `undefined` when there is none.
|
|
1087
|
+
* Return nothing to keep the entry as it is. The entry's TTL, and its
|
|
1088
|
+
* `staleIfError` day, start again.
|
|
1089
|
+
*/
|
|
1090
|
+
update<T>(key: string, next: (current: T | undefined) => CacheEntry<T> | undefined): Promise<void>;
|
|
1091
|
+
/**
|
|
1092
|
+
* Drop the cached value of `key`, so the next read loads it, such as when
|
|
1093
|
+
* a provider webhook says that the object moved.
|
|
1094
|
+
*/
|
|
1095
|
+
delete(key: string): Promise<void>;
|
|
1069
1096
|
}
|
|
1070
1097
|
/** Runtime platform name without source or destination coordinates. */
|
|
1071
1098
|
export type Platform = z.output<typeof platformSchema>;
|
|
@@ -1102,8 +1129,8 @@ export type EventAutomationSource = Extract<Source, {
|
|
|
1102
1129
|
export type PluginDispatchSource = Extract<Source, {
|
|
1103
1130
|
kind: "plugin_dispatch";
|
|
1104
1131
|
}>;
|
|
1105
|
-
export type
|
|
1106
|
-
kind: "
|
|
1132
|
+
export type ParentMessageSource = Extract<Source, {
|
|
1133
|
+
kind: "parent_message";
|
|
1107
1134
|
}>;
|
|
1108
1135
|
export type SourceVisibility = z.output<typeof sourceVisibilitySchema>;
|
|
1109
1136
|
export type Destination = z.output<typeof destinationSchema>;
|
|
@@ -1117,7 +1144,8 @@ export interface PluginMetadata {
|
|
|
1117
1144
|
name: string;
|
|
1118
1145
|
}
|
|
1119
1146
|
export interface PluginLogger {
|
|
1120
|
-
error
|
|
1147
|
+
/** Report an error. `cause` is the caught error, which the report keeps. */
|
|
1148
|
+
error(message: string, metadata?: Record<string, unknown>, cause?: unknown): void;
|
|
1121
1149
|
info(message: string, metadata?: Record<string, unknown>): void;
|
|
1122
1150
|
warn(message: string, metadata?: Record<string, unknown>): void;
|
|
1123
1151
|
}
|
|
@@ -1233,7 +1261,7 @@ export interface EventInvocationContext extends BaseInvocationContext {
|
|
|
1233
1261
|
export type InvocationContext = LocalInvocationContext | SlackInvocationContext | WebInvocationContext | (BaseInvocationContext & {
|
|
1234
1262
|
destination: Destination;
|
|
1235
1263
|
actor?: Actor | undefined;
|
|
1236
|
-
source:
|
|
1264
|
+
source: ParentMessageSource | EventAutomationSource | PluginDispatchSource | EventSource | ScheduledAutomationSource;
|
|
1237
1265
|
});
|
|
1238
1266
|
/** Build a normalized Slack source from runtime-owned Slack coordinates. */
|
|
1239
1267
|
export declare function createSlackSource(input: {
|
|
@@ -1671,12 +1699,12 @@ export declare const conversationAnnotationInputSchema: z.ZodDiscriminatedUnion<
|
|
|
1671
1699
|
changes_requested: "changes_requested";
|
|
1672
1700
|
required: "required";
|
|
1673
1701
|
}>>;
|
|
1674
|
-
checks: z.ZodOptional<z.ZodObject<{
|
|
1702
|
+
checks: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
1675
1703
|
passed: z.ZodNumber;
|
|
1676
1704
|
failed: z.ZodNumber;
|
|
1677
1705
|
pending: z.ZodNumber;
|
|
1678
|
-
}, z.core.$strict>>;
|
|
1679
|
-
mergeable: z.ZodOptional<z.ZodBoolean
|
|
1706
|
+
}, z.core.$strict>, z.ZodLiteral<"pending">]>>;
|
|
1707
|
+
mergeable: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"pending">]>>;
|
|
1680
1708
|
changedFiles: z.ZodOptional<z.ZodNumber>;
|
|
1681
1709
|
additions: z.ZodOptional<z.ZodNumber>;
|
|
1682
1710
|
deletions: z.ZodOptional<z.ZodNumber>;
|
|
@@ -1911,11 +1939,6 @@ export declare const conversationSidebarAnnotationSchema: z.ZodObject<{
|
|
|
1911
1939
|
title: z.ZodOptional<z.ZodString>;
|
|
1912
1940
|
url: z.ZodOptional<z.ZodString>;
|
|
1913
1941
|
imageUrl: z.ZodOptional<z.ZodString>;
|
|
1914
|
-
size: z.ZodOptional<z.ZodObject<{
|
|
1915
|
-
changedFiles: z.ZodOptional<z.ZodNumber>;
|
|
1916
|
-
additions: z.ZodOptional<z.ZodNumber>;
|
|
1917
|
-
deletions: z.ZodOptional<z.ZodNumber>;
|
|
1918
|
-
}, z.core.$strict>>;
|
|
1919
1942
|
}, z.core.$strict>;
|
|
1920
1943
|
export type ConversationSidebarAnnotation = z.output<typeof conversationSidebarAnnotationSchema>;
|
|
1921
1944
|
export interface ConversationSidebarHookContext extends PluginContext {
|
|
@@ -1927,6 +1950,113 @@ export interface ConversationSidebarResult {
|
|
|
1927
1950
|
/** Sidebar annotations in display order. Put the newest annotation first. */
|
|
1928
1951
|
annotationsByConversationId: Record<string, ConversationSidebarAnnotation[]>;
|
|
1929
1952
|
}
|
|
1953
|
+
export declare const codeChangeStateSchema: z.ZodEnum<{
|
|
1954
|
+
closed: "closed";
|
|
1955
|
+
merged: "merged";
|
|
1956
|
+
open: "open";
|
|
1957
|
+
}>;
|
|
1958
|
+
export type CodeChangeState = z.output<typeof codeChangeStateSchema>;
|
|
1959
|
+
export declare const codeChangeInputSchema: z.ZodObject<{
|
|
1960
|
+
closedAt: z.ZodOptional<z.ZodDate>;
|
|
1961
|
+
conversationIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
1962
|
+
mergedAt: z.ZodOptional<z.ZodDate>;
|
|
1963
|
+
number: z.ZodNumber;
|
|
1964
|
+
openedAt: z.ZodDate;
|
|
1965
|
+
providerId: z.ZodString;
|
|
1966
|
+
repository: z.ZodObject<{
|
|
1967
|
+
name: z.ZodString;
|
|
1968
|
+
providerId: z.ZodString;
|
|
1969
|
+
}, z.core.$strict>;
|
|
1970
|
+
state: z.ZodEnum<{
|
|
1971
|
+
closed: "closed";
|
|
1972
|
+
merged: "merged";
|
|
1973
|
+
open: "open";
|
|
1974
|
+
}>;
|
|
1975
|
+
title: z.ZodOptional<z.ZodString>;
|
|
1976
|
+
updatedAt: z.ZodDate;
|
|
1977
|
+
}, z.core.$strict>;
|
|
1978
|
+
export type CodeChangeInput = z.input<typeof codeChangeInputSchema>;
|
|
1979
|
+
export declare const codeRepositoryInputSchema: z.ZodObject<{
|
|
1980
|
+
name: z.ZodString;
|
|
1981
|
+
providerId: z.ZodString;
|
|
1982
|
+
updatedAt: z.ZodDate;
|
|
1983
|
+
}, z.core.$strict>;
|
|
1984
|
+
export type CodeRepositoryInput = z.input<typeof codeRepositoryInputSchema>;
|
|
1985
|
+
export declare const codeChangeFilterSchema: z.ZodObject<{
|
|
1986
|
+
conversationIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1987
|
+
repository: z.ZodOptional<z.ZodObject<{
|
|
1988
|
+
name: z.ZodString;
|
|
1989
|
+
numbers: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
1990
|
+
}, z.core.$strict>>;
|
|
1991
|
+
state: z.ZodOptional<z.ZodEnum<{
|
|
1992
|
+
closed: "closed";
|
|
1993
|
+
merged: "merged";
|
|
1994
|
+
open: "open";
|
|
1995
|
+
}>>;
|
|
1996
|
+
updatedBefore: z.ZodOptional<z.ZodDate>;
|
|
1997
|
+
}, z.core.$strict>;
|
|
1998
|
+
export type CodeChangeFilter = z.input<typeof codeChangeFilterSchema>;
|
|
1999
|
+
/** A code change of a plugin, as Junior's code records hold it now. */
|
|
2000
|
+
export interface CodeChange {
|
|
2001
|
+
closedAt: Date | undefined;
|
|
2002
|
+
conversationIds: string[];
|
|
2003
|
+
mergedAt: Date | undefined;
|
|
2004
|
+
number: number;
|
|
2005
|
+
providerId: string;
|
|
2006
|
+
repository: {
|
|
2007
|
+
name: string;
|
|
2008
|
+
providerId: string;
|
|
2009
|
+
};
|
|
2010
|
+
state: CodeChangeState;
|
|
2011
|
+
}
|
|
2012
|
+
/** A plugin's code changes in Junior's code records. */
|
|
2013
|
+
export interface PluginCodeChanges {
|
|
2014
|
+
associateConversations(input: {
|
|
2015
|
+
conversationIds: string[];
|
|
2016
|
+
providerId: string;
|
|
2017
|
+
}): Promise<void>;
|
|
2018
|
+
/**
|
|
2019
|
+
* Credit people as requesters of an existing code change: the person Work
|
|
2020
|
+
* owners of the Turns that opened or changed it. They add to the stored
|
|
2021
|
+
* ones, and a person's code changes include the ones that credit them.
|
|
2022
|
+
*/
|
|
2023
|
+
associateRequesters(input: {
|
|
2024
|
+
identityIds: string[];
|
|
2025
|
+
providerId: string;
|
|
2026
|
+
}): Promise<void>;
|
|
2027
|
+
/**
|
|
2028
|
+
* List the code changes of this plugin that match every part of the
|
|
2029
|
+
* filter, oldest update first, in one read.
|
|
2030
|
+
*/
|
|
2031
|
+
list(filter: CodeChangeFilter): Promise<CodeChange[]>;
|
|
2032
|
+
record(input: CodeChangeInput): Promise<void>;
|
|
2033
|
+
/**
|
|
2034
|
+
* Record the name of a repository that this plugin's code changes are in.
|
|
2035
|
+
* An older update does not move the name back.
|
|
2036
|
+
*/
|
|
2037
|
+
recordRepository(input: CodeRepositoryInput): Promise<void>;
|
|
2038
|
+
/**
|
|
2039
|
+
* Record a push, review, or comment by a person on a code change. Junior
|
|
2040
|
+
* ignores activity on code changes that it did not record.
|
|
2041
|
+
*/
|
|
2042
|
+
recordActivity(input: {
|
|
2043
|
+
at: Date;
|
|
2044
|
+
number: number;
|
|
2045
|
+
repositoryProviderId: string;
|
|
2046
|
+
}): Promise<void>;
|
|
2047
|
+
}
|
|
2048
|
+
/**
|
|
2049
|
+
* Build the web pages of a code plugin's repositories and code changes from
|
|
2050
|
+
* the repository name and the code change number, so Junior does not store
|
|
2051
|
+
* them.
|
|
2052
|
+
*/
|
|
2053
|
+
export interface PluginCodeLinks {
|
|
2054
|
+
change(input: {
|
|
2055
|
+
number: number;
|
|
2056
|
+
repository: string;
|
|
2057
|
+
}): string;
|
|
2058
|
+
repository(name: string): string;
|
|
2059
|
+
}
|
|
1930
2060
|
export declare const EVENT_SUMMARY_MAX_LENGTH = 4000;
|
|
1931
2061
|
export declare const EVENT_TEXT_MAX_LENGTH = 8000;
|
|
1932
2062
|
export declare const EVENT_DATA_MAX_KEYS = 32;
|
|
@@ -2640,12 +2770,12 @@ export declare const pluginToolOutputSchema: z.ZodObject<{
|
|
|
2640
2770
|
changes_requested: "changes_requested";
|
|
2641
2771
|
required: "required";
|
|
2642
2772
|
}>>;
|
|
2643
|
-
checks: z.ZodOptional<z.ZodObject<{
|
|
2773
|
+
checks: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
2644
2774
|
passed: z.ZodNumber;
|
|
2645
2775
|
failed: z.ZodNumber;
|
|
2646
2776
|
pending: z.ZodNumber;
|
|
2647
|
-
}, z.core.$strict>>;
|
|
2648
|
-
mergeable: z.ZodOptional<z.ZodBoolean
|
|
2777
|
+
}, z.core.$strict>, z.ZodLiteral<"pending">]>>;
|
|
2778
|
+
mergeable: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"pending">]>>;
|
|
2649
2779
|
changedFiles: z.ZodOptional<z.ZodNumber>;
|
|
2650
2780
|
additions: z.ZodOptional<z.ZodNumber>;
|
|
2651
2781
|
deletions: z.ZodOptional<z.ZodNumber>;
|
|
@@ -3002,7 +3132,7 @@ export interface PluginConversationMatch {
|
|
|
3002
3132
|
* working. idle: waits for a message. A failed Turn shows as idle.
|
|
3003
3133
|
*/
|
|
3004
3134
|
status: "pending" | "running" | "paused" | "idle";
|
|
3005
|
-
/**
|
|
3135
|
+
/** Conversation summary, when it has one. */
|
|
3006
3136
|
summary?: string;
|
|
3007
3137
|
title?: string;
|
|
3008
3138
|
/** ISO time of the latest activity. */
|
|
@@ -3071,6 +3201,8 @@ interface BaseToolRegistrationHookContext extends PluginContext {
|
|
|
3071
3201
|
* started the root. Returns nothing when nobody did.
|
|
3072
3202
|
*/
|
|
3073
3203
|
resolveWorkOwner(): Promise<PluginWorkOwner | undefined>;
|
|
3204
|
+
/** The plugin's code changes in Junior's code records. */
|
|
3205
|
+
codeChanges: PluginCodeChanges;
|
|
3074
3206
|
/** Host-owned dashboard link to this conversation, when the dashboard is enabled. */
|
|
3075
3207
|
conversationLink?: {
|
|
3076
3208
|
url: string;
|
|
@@ -3199,6 +3331,11 @@ export declare function objectLinkFilterMatches(filter: ObjectLinkFilter, url: U
|
|
|
3199
3331
|
* and then the longer match.
|
|
3200
3332
|
*/
|
|
3201
3333
|
export declare function objectLinkFilterSpecificity(filter: ObjectLinkFilter): number[];
|
|
3334
|
+
/**
|
|
3335
|
+
* What `prefetch` did for one URL. `out_of_time`: the page's time ran out
|
|
3336
|
+
* before the object loaded, so its card shows only what the cache holds.
|
|
3337
|
+
*/
|
|
3338
|
+
export type ObjectLinkPrefetchOutcome = "out_of_time";
|
|
3202
3339
|
/** Trusted host context for one link resolution. */
|
|
3203
3340
|
export interface ObjectLinkContext extends PluginContext {
|
|
3204
3341
|
/**
|
|
@@ -3243,12 +3380,24 @@ export interface ObjectLinkContext extends PluginContext {
|
|
|
3243
3380
|
* MCP.
|
|
3244
3381
|
*/
|
|
3245
3382
|
viewerMcp: PluginViewerMcp;
|
|
3383
|
+
/**
|
|
3384
|
+
* What `prefetch` returned for this URL, in `canView` and `resolve` of
|
|
3385
|
+
* the same page read. Absent in every other read, such as an Attach, so
|
|
3386
|
+
* that read asks the provider as usual.
|
|
3387
|
+
*/
|
|
3388
|
+
prefetchOutcome?: ObjectLinkPrefetchOutcome;
|
|
3246
3389
|
}
|
|
3247
3390
|
/**
|
|
3248
3391
|
* One link type of a plugin. Junior calls `canView` first, and calls
|
|
3249
3392
|
* `resolve` only when it returns true. Junior does not save the result.
|
|
3250
3393
|
*/
|
|
3251
3394
|
export interface PluginObjectLinkDefinition {
|
|
3395
|
+
/**
|
|
3396
|
+
* Set false when `resolve` reads one cache entry per object that your
|
|
3397
|
+
* webhooks keep current. Junior then keeps no card copy per viewer, so a
|
|
3398
|
+
* change shows on the next read. `canView` still runs on each read.
|
|
3399
|
+
*/
|
|
3400
|
+
cacheCards?: false;
|
|
3252
3401
|
/**
|
|
3253
3402
|
* Return whether `ctx.viewer` may see the object. Junior calls it before
|
|
3254
3403
|
* each card read and again on each Attach. Return true for a public
|
|
@@ -3262,6 +3411,16 @@ export interface PluginObjectLinkDefinition {
|
|
|
3262
3411
|
* one type, such as a GitHub issue URL that opens a pull request.
|
|
3263
3412
|
*/
|
|
3264
3413
|
objectTypes: ObjectType[];
|
|
3414
|
+
/**
|
|
3415
|
+
* Load many objects into your cache in one provider call, such as one
|
|
3416
|
+
* query for a page of links. Junior calls it once with every URL of one
|
|
3417
|
+
* resolve that this link type claims, before `canView` and `resolve` run
|
|
3418
|
+
* for each URL as usual. Write only to the cache, and never return data:
|
|
3419
|
+
* the viewer may not see every object. Return the outcome of each URL
|
|
3420
|
+
* that its card read must know about, keyed by `url.href`. Junior passes
|
|
3421
|
+
* it to that URL's `canView` and `resolve` as `ctx.prefetchOutcome`.
|
|
3422
|
+
*/
|
|
3423
|
+
prefetch?(ctx: ObjectLinkContext, urls: URL[]): Promise<ReadonlyMap<string, ObjectLinkPrefetchOutcome> | void>;
|
|
3265
3424
|
/**
|
|
3266
3425
|
* Read the card. Junior calls it only after `canView` returns true.
|
|
3267
3426
|
* Return nothing for a missing object.
|
|
@@ -3282,56 +3441,43 @@ export interface PluginObjectLinkDefinition {
|
|
|
3282
3441
|
*/
|
|
3283
3442
|
readTool?(object: ObjectAnnotation): string | undefined;
|
|
3284
3443
|
}
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
export interface
|
|
3321
|
-
|
|
3322
|
-
conversationIds: string[];
|
|
3323
|
-
providerId: string;
|
|
3324
|
-
}): Promise<void>;
|
|
3325
|
-
record(input: CodeChangeInput): Promise<void>;
|
|
3326
|
-
/**
|
|
3327
|
-
* Record a push, review, or comment by a person on a code change. Junior
|
|
3328
|
-
* ignores activity on code changes that it did not record.
|
|
3329
|
-
*/
|
|
3330
|
-
recordActivity(input: {
|
|
3331
|
-
at: Date;
|
|
3332
|
-
number: number;
|
|
3333
|
-
repositoryProviderId: string;
|
|
3334
|
-
}): Promise<void>;
|
|
3444
|
+
/** Most entries in one batch, annotations and Inbox items together. */
|
|
3445
|
+
export declare const MAX_CONVERSATION_CHANGES = 100;
|
|
3446
|
+
/** Add or replace one annotation of this plugin on a Conversation. */
|
|
3447
|
+
export interface ConversationAnnotationChange {
|
|
3448
|
+
conversationId: string;
|
|
3449
|
+
upsert: ConversationAnnotationInput;
|
|
3450
|
+
}
|
|
3451
|
+
/**
|
|
3452
|
+
* Close the open Inbox item of this plugin with the key. Do nothing when no
|
|
3453
|
+
* item is open, such as after a person dismissed it.
|
|
3454
|
+
*/
|
|
3455
|
+
export interface ConversationInboxItemChange {
|
|
3456
|
+
close: {
|
|
3457
|
+
dedupeKey: string;
|
|
3458
|
+
reason: string;
|
|
3459
|
+
status: "done" | "dismissed";
|
|
3460
|
+
};
|
|
3461
|
+
conversationId: string;
|
|
3462
|
+
}
|
|
3463
|
+
/**
|
|
3464
|
+
* Changes that a plugin makes together, such as a chip that shows a merged
|
|
3465
|
+
* pull request and the close of its ask. It is data, so no provider call can
|
|
3466
|
+
* run while the changes are not saved.
|
|
3467
|
+
*/
|
|
3468
|
+
export interface ConversationChangeBatch {
|
|
3469
|
+
annotations?: ConversationAnnotationChange[];
|
|
3470
|
+
inboxItems?: ConversationInboxItemChange[];
|
|
3471
|
+
}
|
|
3472
|
+
/**
|
|
3473
|
+
* Save annotations and Inbox items of a plugin in one write. Readers see all
|
|
3474
|
+
* the changes of a batch or none of them. Each entry has the checks of the
|
|
3475
|
+
* same `forConversation` call. When one entry fails, no entry is saved and
|
|
3476
|
+
* the call throws. A batch has at most `MAX_CONVERSATION_CHANGES` entries.
|
|
3477
|
+
* Core shows the closed items, such as on their Slack cards, after the write.
|
|
3478
|
+
*/
|
|
3479
|
+
export interface PluginConversationChanges {
|
|
3480
|
+
apply(batch: ConversationChangeBatch): Promise<void>;
|
|
3335
3481
|
}
|
|
3336
3482
|
export declare const conversationEventIconSchema: z.ZodEnum<{
|
|
3337
3483
|
activity: "activity";
|
|
@@ -3483,8 +3629,12 @@ export declare function definePromptContext<TSchema extends z.ZodType<Record<str
|
|
|
3483
3629
|
}): (content: z.input<TSchema>) => PromptContextContribution;
|
|
3484
3630
|
/** One request-scoped plugin contribution to the model-visible user prompt. */
|
|
3485
3631
|
type UserPromptContribution = PromptMessage | PromptContextContribution;
|
|
3486
|
-
/**
|
|
3487
|
-
|
|
3632
|
+
/**
|
|
3633
|
+
* What a plugin `systemPrompt` hook gets: the platform of the system prompts
|
|
3634
|
+
* that it adds to. It has no database or cache. A plugin that needs data does
|
|
3635
|
+
* its own I/O.
|
|
3636
|
+
*/
|
|
3637
|
+
type SystemPromptBuildContext = Pick<PluginContext, "log" | "plugin"> & {
|
|
3488
3638
|
platform: Platform;
|
|
3489
3639
|
};
|
|
3490
3640
|
/** One prompt context that this plugin gave an earlier Turn. */
|
|
@@ -3548,7 +3698,17 @@ type UserPromptContext = Pick<PluginContext, "db" | "log" | "plugin"> & {
|
|
|
3548
3698
|
* plugins build every prompt tag here, so all tags fence untrusted text the
|
|
3549
3699
|
* same way, and code reads stored history back with the same rules. Lint
|
|
3550
3700
|
* rules ban tag literals, tag regexes, and entity escapes elsewhere.
|
|
3551
|
-
*
|
|
3701
|
+
*
|
|
3702
|
+
* Escape by the kind of text:
|
|
3703
|
+
* - Runtime IDs, enums, handles, and times use only `[A-Za-z0-9._:@/#+-]`,
|
|
3704
|
+
* so they need no escaping. Any other attribute value is free text.
|
|
3705
|
+
* - Free text in an attribute, such as a name or a title: `&`, `<`, `>`, and
|
|
3706
|
+
* `"`.
|
|
3707
|
+
* - The body of a person's text or untrusted text: `&`, `<`, and `>`. This
|
|
3708
|
+
* also turns copies of our tags into plain text. Quotes stay as written.
|
|
3709
|
+
* - A JSON body: `<`, `>`, and `&` as `\u003c`, `\u003e`, and `\u0026`.
|
|
3710
|
+
* - Raw text, such as the system prompt, a skill, or `AGENTS.md`: only its
|
|
3711
|
+
* closing tag.
|
|
3552
3712
|
*/
|
|
3553
3713
|
/** Attribute values of one tag. An undefined or empty value is left out. */
|
|
3554
3714
|
export type PromptTagAttributes = Record<string, string | number | undefined>;
|
|
@@ -3953,7 +4113,7 @@ export declare const pluginRunContextSchema: z.ZodObject<{
|
|
|
3953
4113
|
}, z.core.$strict>, z.ZodObject<{
|
|
3954
4114
|
kind: z.ZodLiteral<"plugin_dispatch">;
|
|
3955
4115
|
}, z.core.$strict>, z.ZodObject<{
|
|
3956
|
-
kind: z.ZodLiteral<"
|
|
4116
|
+
kind: z.ZodLiteral<"parent_message">;
|
|
3957
4117
|
}, z.core.$strict>], "kind">, unknown>;
|
|
3958
4118
|
transcript: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
3959
4119
|
type: z.ZodLiteral<"message">;
|
|
@@ -4015,12 +4175,55 @@ export interface PluginTaskContext extends PluginContext {
|
|
|
4015
4175
|
/** Events that this plugin emitted in the completed Turn, oldest first. */
|
|
4016
4176
|
turnEvents: PluginTurnEventReader;
|
|
4017
4177
|
}
|
|
4018
|
-
/**
|
|
4019
|
-
export interface
|
|
4178
|
+
/** Task that Junior runs after each completed session. */
|
|
4179
|
+
export interface PluginSessionTaskDefinition {
|
|
4180
|
+
payload?: undefined;
|
|
4020
4181
|
run(ctx: PluginTaskContext): Promise<void> | void;
|
|
4021
4182
|
}
|
|
4183
|
+
/** Runtime context passed to one attempt of a task that `tasks.start` started. */
|
|
4184
|
+
export interface PluginStartedTaskContext<Payload = unknown> extends PluginContext {
|
|
4185
|
+
annotations: PluginConversationAnnotations;
|
|
4186
|
+
codeChanges: PluginCodeChanges;
|
|
4187
|
+
conversationChanges: PluginConversationChanges;
|
|
4188
|
+
/** Publishes the plugin's Events, as the heartbeat and routes do. */
|
|
4189
|
+
events: EventPublisher;
|
|
4190
|
+
/**
|
|
4191
|
+
* True on the last delivery that Junior makes. An attempt that throws
|
|
4192
|
+
* now is not run again, so a task that waits for a provider can write
|
|
4193
|
+
* its fallback instead.
|
|
4194
|
+
*/
|
|
4195
|
+
lastDelivery: boolean;
|
|
4196
|
+
name: string;
|
|
4197
|
+
/** The payload from `tasks.start`, parsed with the task's `payload` schema. */
|
|
4198
|
+
payload: Payload;
|
|
4199
|
+
state: PluginState;
|
|
4200
|
+
}
|
|
4201
|
+
/**
|
|
4202
|
+
* Task that runs only when the plugin starts it with `tasks.start`. Junior
|
|
4203
|
+
* sends the payload as JSON in the queue message and parses it with
|
|
4204
|
+
* `payload` before each attempt. A failed attempt runs again later, a
|
|
4205
|
+
* bounded number of times.
|
|
4206
|
+
*/
|
|
4207
|
+
export interface PluginStartedTaskDefinition<Schema extends z.ZodType = z.ZodType> {
|
|
4208
|
+
payload: Schema;
|
|
4209
|
+
run(ctx: PluginStartedTaskContext<z.output<Schema>>): Promise<void> | void;
|
|
4210
|
+
}
|
|
4211
|
+
/** Plugin task handler registered by name in a plugin manifest module. */
|
|
4212
|
+
export type PluginTaskDefinition = PluginSessionTaskDefinition | PluginStartedTaskDefinition;
|
|
4022
4213
|
/** Task handlers keyed by the plugin-owned task name. */
|
|
4023
4214
|
export type PluginTasks = Record<string, PluginTaskDefinition>;
|
|
4215
|
+
/** Input of `tasks.start`. */
|
|
4216
|
+
export declare const pluginTaskStartInputSchema: z.ZodObject<{
|
|
4217
|
+
key: z.ZodString;
|
|
4218
|
+
name: z.ZodString;
|
|
4219
|
+
delaySeconds: z.ZodOptional<z.ZodNumber>;
|
|
4220
|
+
payload: z.ZodUnknown;
|
|
4221
|
+
}, z.core.$strict>;
|
|
4222
|
+
export type PluginTaskStartInput = z.output<typeof pluginTaskStartInputSchema>;
|
|
4223
|
+
/** Starts this plugin's tasks on the plugin task queue. */
|
|
4224
|
+
export interface PluginTaskStarter {
|
|
4225
|
+
start(input: PluginTaskStartInput): Promise<void>;
|
|
4226
|
+
}
|
|
4024
4227
|
/**
|
|
4025
4228
|
* A code change title split by Conventional Commits, such as
|
|
4026
4229
|
* `feat(api)!: Add retries`. The plugin that owns the code change parses it,
|
|
@@ -4112,6 +4315,8 @@ export interface PluginConversationInboxItems {
|
|
|
4112
4315
|
export interface InboxItemAnsweredHookContext extends PluginContext {
|
|
4113
4316
|
/** The label of the picked choice. */
|
|
4114
4317
|
choice: string;
|
|
4318
|
+
/** Junior's native code index, as from a plugin route. */
|
|
4319
|
+
codeChanges: PluginCodeChanges;
|
|
4115
4320
|
/** The Conversation that the item belongs to. */
|
|
4116
4321
|
conversationId: string;
|
|
4117
4322
|
/** The plugin's own dedupe key of the item. */
|
|
@@ -4152,7 +4357,9 @@ export interface HeartbeatHookContext extends PluginContext {
|
|
|
4152
4357
|
/** Conversation annotations, as from a plugin route. */
|
|
4153
4358
|
annotations: PluginConversationAnnotations;
|
|
4154
4359
|
/** Junior's native code index, as from a plugin route. */
|
|
4155
|
-
codeChanges:
|
|
4360
|
+
codeChanges: PluginCodeChanges;
|
|
4361
|
+
/** Annotation and Inbox item changes in one write, as from a plugin route. */
|
|
4362
|
+
conversationChanges: PluginConversationChanges;
|
|
4156
4363
|
/** Host embedder bound to the configured embedding model. */
|
|
4157
4364
|
embedder: PluginEmbedder;
|
|
4158
4365
|
/** Publish events, as from a plugin route. */
|
|
@@ -4161,11 +4368,15 @@ export interface HeartbeatHookContext extends PluginContext {
|
|
|
4161
4368
|
/** Inbox items, as from a plugin route. */
|
|
4162
4369
|
inboxItems: PluginConversationInboxItems;
|
|
4163
4370
|
state: PluginState;
|
|
4371
|
+
/** Start this plugin's tasks, as from a plugin route. */
|
|
4372
|
+
tasks: PluginTaskStarter;
|
|
4164
4373
|
}
|
|
4165
4374
|
export interface HeartbeatResult {
|
|
4166
4375
|
dispatchCount?: number;
|
|
4167
4376
|
}
|
|
4168
4377
|
export interface UnfinishedWorkHookContext extends PluginContext {
|
|
4378
|
+
/** Junior's native code index, as from a plugin route. */
|
|
4379
|
+
codeChanges: PluginCodeChanges;
|
|
4169
4380
|
/**
|
|
4170
4381
|
* Bounded conversation candidates selected by the host, with the child
|
|
4171
4382
|
* conversations of candidate roots. Work in a child counts for its root.
|
|
@@ -4285,14 +4496,21 @@ export interface RouteRegistrationHookContext extends PluginContext {
|
|
|
4285
4496
|
dispatchForIdentity(options: IdentityDispatchOptions): Promise<IdentityDispatchResult>;
|
|
4286
4497
|
};
|
|
4287
4498
|
annotations: PluginConversationAnnotations;
|
|
4288
|
-
/** Provider-neutral
|
|
4289
|
-
codeChanges:
|
|
4499
|
+
/** Provider-neutral boundary for Junior's native code index. */
|
|
4500
|
+
codeChanges: PluginCodeChanges;
|
|
4501
|
+
/** Annotation and Inbox item changes that readers must see together. */
|
|
4502
|
+
conversationChanges: PluginConversationChanges;
|
|
4290
4503
|
/** Core-owned delivery boundary for provider webhook events. */
|
|
4291
4504
|
events: EventPublisher;
|
|
4292
4505
|
/** Inbox items that the plugin adds and closes from its events. */
|
|
4293
4506
|
inboxItems: PluginConversationInboxItems;
|
|
4294
4507
|
/** Plugin-namespaced state, the same as in heartbeats. */
|
|
4295
4508
|
state: PluginState;
|
|
4509
|
+
/**
|
|
4510
|
+
* Start a task with a `payload` schema from this plugin's `tasks`. Use it
|
|
4511
|
+
* when a write fails and must run again after the route returns.
|
|
4512
|
+
*/
|
|
4513
|
+
tasks: PluginTaskStarter;
|
|
4296
4514
|
users: {
|
|
4297
4515
|
/**
|
|
4298
4516
|
* Read one stored identity and the user it links to now, with every
|
|
@@ -4411,11 +4629,14 @@ export interface PluginHooks {
|
|
|
4411
4629
|
conversationTitleContext?(ctx: ConversationTitleContextHookContext): Promise<string[] | undefined> | string[] | undefined;
|
|
4412
4630
|
conversationSidebar?(ctx: ConversationSidebarHookContext): Promise<ConversationSidebarResult> | ConversationSidebarResult;
|
|
4413
4631
|
/**
|
|
4414
|
-
* Return static guidance for the system
|
|
4415
|
-
*
|
|
4416
|
-
*
|
|
4632
|
+
* Return static guidance for the system prompts of one platform. Junior
|
|
4633
|
+
* runs this hook once at build for each platform, uses its output in the
|
|
4634
|
+
* system prompt of every Prompt mode on that platform, and freezes it for
|
|
4635
|
+
* the deployment. So every Turn gets the same system prompt, and the model
|
|
4636
|
+
* provider can cache it. The hook may do I/O, but that I/O happens only at
|
|
4637
|
+
* build. Put text that changes per request in `userPrompt`.
|
|
4417
4638
|
*/
|
|
4418
|
-
systemPrompt?(ctx:
|
|
4639
|
+
systemPrompt?(ctx: SystemPromptBuildContext): Promise<PromptMessage[]> | PromptMessage[];
|
|
4419
4640
|
/**
|
|
4420
4641
|
* Return per-request context for a new prompt, such as recalled memories.
|
|
4421
4642
|
* Junior runs this hook at the same time as Turn routing and sandbox setup,
|
|
@@ -4539,12 +4760,66 @@ export interface PluginOAuthConfig {
|
|
|
4539
4760
|
}
|
|
4540
4761
|
export interface PluginOAuthBearerCredentials {
|
|
4541
4762
|
apiHeaders?: Record<string, string>;
|
|
4542
|
-
|
|
4763
|
+
/**
|
|
4764
|
+
* Env var of a host token, and the name of the Sandbox placeholder.
|
|
4765
|
+
* Optional with `oauth`: without it there is no env token fallback.
|
|
4766
|
+
*/
|
|
4767
|
+
authTokenEnv?: string;
|
|
4543
4768
|
authTokenPlaceholder?: string;
|
|
4544
4769
|
domains: string[];
|
|
4545
4770
|
type: "oauth-bearer";
|
|
4546
4771
|
}
|
|
4547
|
-
|
|
4772
|
+
/** Request header that carries a workload identity token. */
|
|
4773
|
+
export type PluginWorkloadIdentityHeader = "Authorization" | "Proxy-Authorization" | "X-Serverless-Authorization";
|
|
4774
|
+
/**
|
|
4775
|
+
* Google Cloud token that Junior mints for one service account.
|
|
4776
|
+
*
|
|
4777
|
+
* `service-account-jwt` signs a JWT with `iss` and `sub` set to the service
|
|
4778
|
+
* account (Identity-Aware Proxy accepts it). `id-token` mints a Google ID
|
|
4779
|
+
* token (Cloud Run accepts it). `access-token` mints an OAuth access token for
|
|
4780
|
+
* Google APIs.
|
|
4781
|
+
*/
|
|
4782
|
+
export type PluginGcpWorkloadIdentityToken = {
|
|
4783
|
+
audience: string;
|
|
4784
|
+
token: "id-token";
|
|
4785
|
+
} | {
|
|
4786
|
+
audience: string;
|
|
4787
|
+
token: "service-account-jwt";
|
|
4788
|
+
} | {
|
|
4789
|
+
scopes: string[];
|
|
4790
|
+
token: "access-token";
|
|
4791
|
+
};
|
|
4792
|
+
/** Google Cloud workload identity federation through one service account. */
|
|
4793
|
+
export type PluginGcpWorkloadIdentityConfig = PluginGcpWorkloadIdentityToken & {
|
|
4794
|
+
/** Service account email that Junior impersonates. */
|
|
4795
|
+
serviceAccount: string;
|
|
4796
|
+
/** `projects/<number>/locations/global/workloadIdentityPools/<pool>/providers/<provider>`. */
|
|
4797
|
+
workloadIdentityProvider: string;
|
|
4798
|
+
};
|
|
4799
|
+
/** Microsoft Entra ID workload identity federation for one app registration. */
|
|
4800
|
+
export interface PluginAzureWorkloadIdentityConfig {
|
|
4801
|
+
clientId: string;
|
|
4802
|
+
/** Token scope, such as `api://<app>/.default`. */
|
|
4803
|
+
scope: string;
|
|
4804
|
+
tenantId: string;
|
|
4805
|
+
}
|
|
4806
|
+
/**
|
|
4807
|
+
* Bot credential that Junior mints on the host from the deployment's Vercel
|
|
4808
|
+
* OIDC token. Set exactly one of `gcp` or `azure`.
|
|
4809
|
+
*/
|
|
4810
|
+
export type PluginWorkloadIdentityCredentials = {
|
|
4811
|
+
domains: string[];
|
|
4812
|
+
/** Defaults to `Authorization`. */
|
|
4813
|
+
header?: PluginWorkloadIdentityHeader;
|
|
4814
|
+
type: "workload-identity";
|
|
4815
|
+
} & ({
|
|
4816
|
+
azure?: never;
|
|
4817
|
+
gcp: PluginGcpWorkloadIdentityConfig;
|
|
4818
|
+
} | {
|
|
4819
|
+
azure: PluginAzureWorkloadIdentityConfig;
|
|
4820
|
+
gcp?: never;
|
|
4821
|
+
});
|
|
4822
|
+
export type PluginCredentials = PluginOAuthBearerCredentials | PluginWorkloadIdentityCredentials;
|
|
4548
4823
|
export interface PluginNpmRuntimeDependency {
|
|
4549
4824
|
package: string;
|
|
4550
4825
|
type: "npm";
|
|
@@ -4611,8 +4886,8 @@ export interface PluginMcpConfig {
|
|
|
4611
4886
|
* the Actor to connect their own account.
|
|
4612
4887
|
*
|
|
4613
4888
|
* With `userOAuth: false`, Junior uses only the service account. It never
|
|
4614
|
-
* asks an Actor to connect, ignores their own connections, and hides
|
|
4615
|
-
* that the service account does not list. Until an Admin connects the
|
|
4889
|
+
* asks an Actor to connect, ignores their own connections, and hides MCP
|
|
4890
|
+
* tools that the service account does not list. Until an Admin connects the
|
|
4616
4891
|
* account, the plugin is not available.
|
|
4617
4892
|
*/
|
|
4618
4893
|
export interface PluginAccountsConfig {
|
|
@@ -4621,11 +4896,21 @@ export interface PluginAccountsConfig {
|
|
|
4621
4896
|
/** Optional service account and what it may use. Omit for none. */
|
|
4622
4897
|
serviceAccount?: PluginServiceAccountConfig;
|
|
4623
4898
|
}
|
|
4624
|
-
/**
|
|
4625
|
-
|
|
4899
|
+
/**
|
|
4900
|
+
* What one plugin's service account may use. An `mcp` plugin lists MCP
|
|
4901
|
+
* tools. A plugin with a top-level `oauth` block lists the `operation`
|
|
4902
|
+
* names that its host code passes to `egress.fetch`. Sandbox commands never
|
|
4903
|
+
* name an operation, so they never get the service account.
|
|
4904
|
+
*/
|
|
4905
|
+
export type PluginServiceAccountConfig = {
|
|
4626
4906
|
/** MCP tools that the account may call. Each must be loaded by `mcp`. */
|
|
4627
4907
|
tools: string[];
|
|
4628
|
-
|
|
4908
|
+
operations?: never;
|
|
4909
|
+
} | {
|
|
4910
|
+
/** `egress.fetch` operations that the account may serve. */
|
|
4911
|
+
operations: string[];
|
|
4912
|
+
tools?: never;
|
|
4913
|
+
};
|
|
4629
4914
|
export interface PluginEnvVarDeclaration {
|
|
4630
4915
|
default?: string;
|
|
4631
4916
|
exposeToCommandEnv?: boolean;
|
|
@@ -4769,6 +5054,8 @@ export interface PluginModelConfig {
|
|
|
4769
5054
|
}
|
|
4770
5055
|
export type PluginRegistrationInput = {
|
|
4771
5056
|
cli?: PluginCliDefinition;
|
|
5057
|
+
/** Web pages of the code changes that this plugin records. */
|
|
5058
|
+
codeLinks?: PluginCodeLinks;
|
|
4772
5059
|
conversationEvents?: PluginConversationEventDefinition[];
|
|
4773
5060
|
hooks?: PluginHooks;
|
|
4774
5061
|
/** Images that this plugin serves through the Junior image proxy. */
|
|
@@ -4785,4 +5072,37 @@ export type PluginRegistrationInput = {
|
|
|
4785
5072
|
export interface PluginRegistration extends PluginRegistrationInput {}
|
|
4786
5073
|
/** Define one Junior plugin registration for app and build-time wiring. */
|
|
4787
5074
|
export declare function defineJuniorPlugin(plugin: PluginRegistrationInput): PluginRegistration;
|
|
4788
|
-
|
|
5075
|
+
/** One node of a parsed Markdown tree. */
|
|
5076
|
+
export type MarkdownNode = Nodes;
|
|
5077
|
+
/**
|
|
5078
|
+
* Parse GitHub-flavored Markdown. Each node position holds offsets into
|
|
5079
|
+
* `text`, so a caller can slice the source of a node.
|
|
5080
|
+
*/
|
|
5081
|
+
export declare function parseMarkdown(text: string): Root;
|
|
5082
|
+
/**
|
|
5083
|
+
* Return the nodes of the given types in a Markdown tree, in text order. It
|
|
5084
|
+
* does not look inside a node that it returns.
|
|
5085
|
+
*/
|
|
5086
|
+
export declare function markdownNodes<Type extends MarkdownNode["type"]>(tree: MarkdownNode, types: readonly Type[]): Extract<MarkdownNode, {
|
|
5087
|
+
type: Type;
|
|
5088
|
+
}>[];
|
|
5089
|
+
/** What `markdownText` reads from a Markdown tree. */
|
|
5090
|
+
export interface MarkdownTextOptions {
|
|
5091
|
+
/**
|
|
5092
|
+
* Leave out code blocks, images, and HTML, for a place that has room only
|
|
5093
|
+
* for prose. Inline code stays.
|
|
5094
|
+
*/
|
|
5095
|
+
proseOnly?: boolean;
|
|
5096
|
+
}
|
|
5097
|
+
/**
|
|
5098
|
+
* Return the readable text of a Markdown node without its syntax. Inline
|
|
5099
|
+
* parts join with no space, and blocks join with one space. An image gives
|
|
5100
|
+
* its alt text. The whitespace inside text stays as it is.
|
|
5101
|
+
*/
|
|
5102
|
+
export declare function markdownText(node: MarkdownNode, options?: MarkdownTextOptions): string;
|
|
5103
|
+
/**
|
|
5104
|
+
* Return Markdown text as one plain line: the readable text of its tree with
|
|
5105
|
+
* each run of whitespace made one space.
|
|
5106
|
+
*/
|
|
5107
|
+
export declare function markdownPlainText(text: string, options?: MarkdownTextOptions): string;
|
|
5108
|
+
export type { PromptContext, PromptContextContribution, PromptHistory, PromptHistoryContext, PromptMessage, SystemPromptBuildContext, UserPromptContext, UserPromptContribution };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import * as z from "zod";
|
|
2
|
+
import { fromMarkdown } from "mdast-util-from-markdown";
|
|
3
|
+
import { gfmFromMarkdown } from "mdast-util-gfm";
|
|
4
|
+
import { gfm } from "micromark-extension-gfm";
|
|
2
5
|
// src/object-facts.ts
|
|
3
6
|
const text = z.string().trim().min(1).max(160);
|
|
4
7
|
const count = z.number().int().nonnegative();
|
|
@@ -31,13 +34,17 @@ const objectFactsSchema = z.discriminatedUnion("type", [
|
|
|
31
34
|
"approved",
|
|
32
35
|
"changes_requested"
|
|
33
36
|
]).optional(),
|
|
34
|
-
checks
|
|
37
|
+
/** `pending` while the provider counts the checks of a new head. */
|
|
38
|
+
checks: z.union([z.strictObject({
|
|
35
39
|
passed: count,
|
|
36
40
|
failed: count,
|
|
37
41
|
pending: count
|
|
38
|
-
}).optional(),
|
|
39
|
-
/**
|
|
40
|
-
|
|
42
|
+
}), z.literal("pending")]).optional(),
|
|
43
|
+
/**
|
|
44
|
+
* False while an open change conflicts with its target branch.
|
|
45
|
+
* `pending` while the provider computes it for a new head.
|
|
46
|
+
*/
|
|
47
|
+
mergeable: z.union([z.boolean(), z.literal("pending")]).optional(),
|
|
41
48
|
changedFiles: count.optional(),
|
|
42
49
|
additions: count.optional(),
|
|
43
50
|
deletions: count.optional(),
|
|
@@ -907,9 +914,7 @@ const conversationSidebarAnnotationSchema = z.object({
|
|
|
907
914
|
label: z.string().trim().min(1).max(256),
|
|
908
915
|
title: z.string().trim().min(1).max(512).optional(),
|
|
909
916
|
url: httpUrlSchema.optional(),
|
|
910
|
-
imageUrl: httpUrlSchema.optional()
|
|
911
|
-
/** A code change's size, so a card can show it without a live read. */
|
|
912
|
-
size: codeChangeSizeSchema.optional()
|
|
917
|
+
imageUrl: httpUrlSchema.optional()
|
|
913
918
|
}).strict();
|
|
914
919
|
// src/code.ts
|
|
915
920
|
const codeChangeStateSchema = z.enum([
|
|
@@ -920,30 +925,39 @@ const codeChangeStateSchema = z.enum([
|
|
|
920
925
|
const codeChangeInputSchema = z.object({
|
|
921
926
|
closedAt: z.date().optional(),
|
|
922
927
|
conversationIds: z.array(z.string().min(1)).default([]),
|
|
923
|
-
/**
|
|
924
|
-
* Whether the code change is a draft. When omitted, Junior keeps the
|
|
925
|
-
* stored value; a new code change is not a draft.
|
|
926
|
-
*/
|
|
927
|
-
draft: z.boolean().optional(),
|
|
928
928
|
mergedAt: z.date().optional(),
|
|
929
929
|
number: z.number().int().positive(),
|
|
930
930
|
openedAt: z.date(),
|
|
931
931
|
providerId: z.string().min(1),
|
|
932
932
|
repository: z.object({
|
|
933
933
|
name: z.string().min(1),
|
|
934
|
-
providerId: z.string().min(1)
|
|
935
|
-
url: z.string().url().optional()
|
|
934
|
+
providerId: z.string().min(1)
|
|
936
935
|
}).strict(),
|
|
937
|
-
/**
|
|
938
|
-
* The size as the provider counts it now. Junior keeps the stored value
|
|
939
|
-
* of each part that is omitted.
|
|
940
|
-
*/
|
|
941
|
-
size: codeChangeSizeSchema.optional(),
|
|
942
936
|
state: codeChangeStateSchema,
|
|
943
937
|
title: z.string().min(1).optional(),
|
|
944
|
-
updatedAt: z.date()
|
|
945
|
-
url: z.string().url().optional()
|
|
938
|
+
updatedAt: z.date()
|
|
946
939
|
}).strict();
|
|
940
|
+
const codeRepositoryInputSchema = z.object({
|
|
941
|
+
name: z.string().min(1),
|
|
942
|
+
providerId: z.string().min(1),
|
|
943
|
+
/** When the provider had this name. */
|
|
944
|
+
updatedAt: z.date()
|
|
945
|
+
}).strict();
|
|
946
|
+
const codeChangeFilterSchema = z.object({
|
|
947
|
+
/** Code changes linked to any of these Conversations. */
|
|
948
|
+
conversationIds: z.array(z.string().min(1)).min(1).optional(),
|
|
949
|
+
repository: z.object({
|
|
950
|
+
/** The repository name. Junior matches it in any case. */
|
|
951
|
+
name: z.string().min(1),
|
|
952
|
+
numbers: z.array(z.number().int().positive()).min(1).optional()
|
|
953
|
+
}).strict().optional(),
|
|
954
|
+
state: codeChangeStateSchema.optional(),
|
|
955
|
+
/** Code changes whose last update is before this time. */
|
|
956
|
+
updatedBefore: z.date().optional()
|
|
957
|
+
}).strict();
|
|
958
|
+
// src/conversation-changes.ts
|
|
959
|
+
/** Most entries in one batch, annotations and Inbox items together. */
|
|
960
|
+
const MAX_CONVERSATION_CHANGES = 100;
|
|
947
961
|
// src/conversation-events.ts
|
|
948
962
|
const conversationEventNameSchema = z.string().trim().min(1).max(64).regex(/^[a-z][a-z0-9_]*$/);
|
|
949
963
|
const conversationEventIconSchema = z.enum([
|
|
@@ -1109,8 +1123,8 @@ const eventAutomationSourceSchema = z.object({
|
|
|
1109
1123
|
}).strict();
|
|
1110
1124
|
/** Runtime-owned Plugin dispatch input Source. */
|
|
1111
1125
|
const pluginDispatchSourceSchema = z.object({ kind: z.literal("plugin_dispatch") }).strict();
|
|
1112
|
-
/** Runtime-owned
|
|
1113
|
-
const
|
|
1126
|
+
/** Runtime-owned Source of a parent agent's task or message to a child agent. */
|
|
1127
|
+
const parentMessageSourceSchema = z.object({ kind: z.literal("parent_message") }).strict();
|
|
1114
1128
|
const currentSourceSchema = z.discriminatedUnion("kind", [
|
|
1115
1129
|
slackSourceSchema,
|
|
1116
1130
|
localSourceSchema,
|
|
@@ -1119,13 +1133,14 @@ const currentSourceSchema = z.discriminatedUnion("kind", [
|
|
|
1119
1133
|
scheduledAutomationSourceSchema,
|
|
1120
1134
|
eventAutomationSourceSchema,
|
|
1121
1135
|
pluginDispatchSourceSchema,
|
|
1122
|
-
|
|
1136
|
+
parentMessageSourceSchema
|
|
1123
1137
|
]);
|
|
1124
1138
|
function normalizeStoredSource(value) {
|
|
1125
1139
|
if (!value || typeof value !== "object" || Array.isArray(value)) return value;
|
|
1126
1140
|
const source = value;
|
|
1127
1141
|
if ("kind" in source) {
|
|
1128
1142
|
const kind = typeof source["kind"] === "string" ? {
|
|
1143
|
+
agent_invocation: "parent_message",
|
|
1129
1144
|
event_task: "event_automation",
|
|
1130
1145
|
resource_event: "event",
|
|
1131
1146
|
scheduled_task: "scheduled_automation"
|
|
@@ -1339,7 +1354,7 @@ function getSourceKey(source) {
|
|
|
1339
1354
|
case "scheduled_automation":
|
|
1340
1355
|
case "event_automation":
|
|
1341
1356
|
case "plugin_dispatch":
|
|
1342
|
-
case "
|
|
1357
|
+
case "parent_message": return;
|
|
1343
1358
|
}
|
|
1344
1359
|
}
|
|
1345
1360
|
/** Narrow a runtime destination to the Slack-specific address shape. */
|
|
@@ -2294,6 +2309,20 @@ const pluginRunContextSchema = z.object({
|
|
|
2294
2309
|
source: sourceSchema,
|
|
2295
2310
|
transcript: z.array(pluginRunTranscriptEntrySchema)
|
|
2296
2311
|
}).strict();
|
|
2312
|
+
/** Input of `tasks.start`. */
|
|
2313
|
+
const pluginTaskStartInputSchema = z.object({
|
|
2314
|
+
/**
|
|
2315
|
+
* One task per plugin and key while the queue keeps the message. A
|
|
2316
|
+
* second start with the key in that time does nothing.
|
|
2317
|
+
*/
|
|
2318
|
+
key: nonBlankStringSchema.max(500),
|
|
2319
|
+
/** Name of a task with a `payload` schema in this plugin's `tasks`. */
|
|
2320
|
+
name: nonBlankStringSchema,
|
|
2321
|
+
/** Seconds before the first attempt. Without it, the task runs soon. */
|
|
2322
|
+
delaySeconds: z.number().int().positive().optional(),
|
|
2323
|
+
/** JSON value that the task's `payload` schema accepts. */
|
|
2324
|
+
payload: z.unknown()
|
|
2325
|
+
}).strict();
|
|
2297
2326
|
// src/tools.ts
|
|
2298
2327
|
/** Thrown when a plugin tool rejects invalid model or user input. */
|
|
2299
2328
|
var PluginToolInputError = class extends Error {
|
|
@@ -2725,6 +2754,68 @@ function validateObjectLinks(name, links) {
|
|
|
2725
2754
|
}
|
|
2726
2755
|
}
|
|
2727
2756
|
}
|
|
2757
|
+
// src/markdown.ts
|
|
2758
|
+
/**
|
|
2759
|
+
* Parse GitHub-flavored Markdown. Each node position holds offsets into
|
|
2760
|
+
* `text`, so a caller can slice the source of a node.
|
|
2761
|
+
*/
|
|
2762
|
+
function parseMarkdown(text) {
|
|
2763
|
+
return fromMarkdown(text, {
|
|
2764
|
+
extensions: [gfm()],
|
|
2765
|
+
mdastExtensions: [gfmFromMarkdown()]
|
|
2766
|
+
});
|
|
2767
|
+
}
|
|
2768
|
+
/**
|
|
2769
|
+
* Return the nodes of the given types in a Markdown tree, in text order. It
|
|
2770
|
+
* does not look inside a node that it returns.
|
|
2771
|
+
*/
|
|
2772
|
+
function markdownNodes(tree, types) {
|
|
2773
|
+
const found = [];
|
|
2774
|
+
const visit = (node) => {
|
|
2775
|
+
if (isOfType(node, types)) found.push(node);
|
|
2776
|
+
else if ("children" in node) for (const child of node.children) visit(child);
|
|
2777
|
+
};
|
|
2778
|
+
visit(tree);
|
|
2779
|
+
return found;
|
|
2780
|
+
}
|
|
2781
|
+
function isOfType(node, types) {
|
|
2782
|
+
return types.some((type) => type === node.type);
|
|
2783
|
+
}
|
|
2784
|
+
const INLINE_PARENTS = /* @__PURE__ */ new Set([
|
|
2785
|
+
"delete",
|
|
2786
|
+
"emphasis",
|
|
2787
|
+
"heading",
|
|
2788
|
+
"link",
|
|
2789
|
+
"linkReference",
|
|
2790
|
+
"paragraph",
|
|
2791
|
+
"strong",
|
|
2792
|
+
"tableCell"
|
|
2793
|
+
]);
|
|
2794
|
+
const NON_PROSE = /* @__PURE__ */ new Set([
|
|
2795
|
+
"code",
|
|
2796
|
+
"html",
|
|
2797
|
+
"image"
|
|
2798
|
+
]);
|
|
2799
|
+
/**
|
|
2800
|
+
* Return the readable text of a Markdown node without its syntax. Inline
|
|
2801
|
+
* parts join with no space, and blocks join with one space. An image gives
|
|
2802
|
+
* its alt text. The whitespace inside text stays as it is.
|
|
2803
|
+
*/
|
|
2804
|
+
function markdownText(node, options = {}) {
|
|
2805
|
+
if (options.proseOnly && NON_PROSE.has(node.type)) return "";
|
|
2806
|
+
if (node.type === "image") return node.alt ?? "";
|
|
2807
|
+
if (node.type === "break") return " ";
|
|
2808
|
+
if ("value" in node) return node.value;
|
|
2809
|
+
if (!("children" in node)) return "";
|
|
2810
|
+
return node.children.map((child) => markdownText(child, options)).join(INLINE_PARENTS.has(node.type) ? "" : " ");
|
|
2811
|
+
}
|
|
2812
|
+
/**
|
|
2813
|
+
* Return Markdown text as one plain line: the readable text of its tree with
|
|
2814
|
+
* each run of whitespace made one space.
|
|
2815
|
+
*/
|
|
2816
|
+
function markdownPlainText(text, options = {}) {
|
|
2817
|
+
return markdownText(parseMarkdown(text), options).replace(/\s+/g, " ").trim();
|
|
2818
|
+
}
|
|
2728
2819
|
// src/user-pages.ts
|
|
2729
2820
|
/**
|
|
2730
2821
|
* Core-rendered plugin user pages.
|
|
@@ -2808,4 +2899,4 @@ const pluginUserPageInputSchema = z.object({
|
|
|
2808
2899
|
limit: z.number().int().min(1).max(50),
|
|
2809
2900
|
query: pluginUserPageQuerySchema
|
|
2810
2901
|
}).strict();
|
|
2811
|
-
export { EVENT_DATA_MAX_JSON_BYTES, EVENT_DATA_MAX_KEYS, EVENT_GUIDANCE_MAX_LENGTH, EVENT_SUMMARY_MAX_LENGTH, EVENT_TEXT_MAX_LENGTH, EgressAuthRequired, EgressPolicyDenied, OBJECT_FACTS_MAX_BYTES, OBJECT_SUMMARY_MAX_LENGTH, PluginToolInputError, REQUIRED_TOOL_ANNOTATION_KEYS, actorSchema, actorUserIdSchema, agentEventKeys, agentEventMatchKey, agentEventMatchSchema,
|
|
2902
|
+
export { EVENT_DATA_MAX_JSON_BYTES, EVENT_DATA_MAX_KEYS, EVENT_GUIDANCE_MAX_LENGTH, EVENT_SUMMARY_MAX_LENGTH, EVENT_TEXT_MAX_LENGTH, EgressAuthRequired, EgressPolicyDenied, MAX_CONVERSATION_CHANGES, OBJECT_FACTS_MAX_BYTES, OBJECT_SUMMARY_MAX_LENGTH, PluginToolInputError, REQUIRED_TOOL_ANNOTATION_KEYS, actorSchema, actorUserIdSchema, agentEventKeys, agentEventMatchKey, agentEventMatchSchema, anyResourceEvents, anyResourceMatchFields, codeChangeFilterSchema, codeChangeInputSchema, codeChangeSizeSchema, codeChangeStateSchema, codeRepositoryInputSchema, conversationAnnotationInputSchema, conversationEventIconSchema, conversationEventPresentationSchema, conversationSidebarAnnotationSchema, conversationSidebarIconSchema, createEventSource, createLocalSource, createSlackSource, createWebSource, declaredEventKeys, decodeObjectImageRef, defineConversationEvent, defineJuniorPlugin, definePluginTool, definePromptContext, describeEventTrigger, destinationSchema, destinationVisibilitySchema, dispatchOptionsSchema, encodeObjectImageRef, enforceEgressPolicy, escapeClosingTag, escapeClosingTags, escapeTagText, escapeTagTextAndQuotes, eventAuthorSchema, eventAutomationSourceSchema, eventDataSchema, eventIdentifierSchema, eventInputSchema, eventMatchFieldSchema, eventMatchFieldsSchema, eventMatchFilterText, eventMatchSchema, eventMatches, eventPersonSchema, eventReachSchema, eventSchema, eventSourceSchema, eventTriggerChoices, eventTriggerFiltersText, eventTriggerProblems, eventTriggerText, eventTypeSchema, eventTypeText, eventsWithoutMatchField, findTag, findTags, formatDuration, getSourceKey, identityDispatchOptionsSchema, identitySchema, indentTagLines, isPluginModelCostEventName, isPrivateSource, isSlackDestination, localActorSchema, localDestinationSchema, localSourceSchema, locationSchema, markdownNodes, markdownPlainText, markdownText, mentionsTag, mergeEventMatchFields, missingToolAnnotationKeys, nonBlankStringSchema, normalizeEventIdentifier, normalizeEventMatch, objectAnnotationSchema, objectFactFields, objectFactsBytes, objectFactsMatchType, objectFactsSchema, objectIconPath, objectIconPaths, objectLinkFilterMatches, objectLinkFilterSchema, objectLinkFilterSpecificity, objectPresentation, objectSummary, objectTypeSchema, openingTag, ownedObjectAnnotationSchema, parentMessageSourceSchema, parseMarkdown, parseShellCommands, platformSchema, pluginApiRouteRequestContextSchema, pluginAuditAttributesSchema, pluginAuthorizationSchema, pluginCredentialHeaderTransformSchema, pluginCredentialLeaseSchema, pluginCredentialResultSchema, pluginCredentialSubjectSchema, pluginDispatchSourceSchema, pluginEventDeclarationSchema, pluginEventTypeSchema, pluginEventsSchema, pluginGrantSchema, pluginModelCostEventNames, pluginProviderAccountSchema, pluginRunContextSchema, pluginRunTranscriptEntrySchema, pluginRunTranscriptProvenanceSchema, pluginStoredTokensSchema, pluginTaskStartInputSchema, pluginToolContentSchema, pluginToolContinuationSchema, pluginToolOutputSchema, pluginToolReplySchema, pluginUserPageContentSchema, pluginUserPageCursorSchema, pluginUserPageFilterSchema, pluginUserPageInputSchema, pluginUserPageLinkSchema, pluginUserPageLinksSchema, pluginUserPageQuerySchema, promptContextSchema, promptMessageSchema, readTag, renderEmptyTag, renderInlineTag, renderTag, replyAttributionSchema, resourceLinkAnnotationSchema, resourceTypeSchema, scheduledAutomationSourceSchema, slackActorSchema, slackDestinationSchema, slackLocationSchema, slackSourceSchema, sourceSchema, sourceVisibilitySchema, stableEventMatchKey, startsWithTag, stripTags, subscribableResourceSchema, systemActorSchema, tagJson, taskOutcomeSchema, toolApprovalModeSchema, unescapeClosingTag, unescapeClosingTags, unescapeTagText, userSchema, watchResultSchema, webActorSchema, webSourceSchema, withToolContext, zodTool };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/junior-plugin-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.315.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -22,7 +22,11 @@
|
|
|
22
22
|
"src/object-icons.LICENSE"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
+
"@types/mdast": "^4.0.4",
|
|
25
26
|
"commander": "^14.0.3",
|
|
27
|
+
"mdast-util-from-markdown": "^2.1.0",
|
|
28
|
+
"mdast-util-gfm": "^3.1.0",
|
|
29
|
+
"micromark-extension-gfm": "^3.0.0",
|
|
26
30
|
"zod": "^4.6.7"
|
|
27
31
|
},
|
|
28
32
|
"devDependencies": {
|