@sentry/junior-plugin-api 0.160.0 → 0.161.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/README.md +4 -0
- package/dist/annotations.d.ts +28 -0
- package/dist/conversation-events.d.ts +2 -2
- package/dist/hooks.d.ts +14 -1
- package/dist/index.js +14 -0
- package/dist/operations.d.ts +9 -0
- package/package.json +1 -1
- package/src/annotations.ts +33 -0
- package/src/hooks.ts +25 -0
- package/src/operations.ts +10 -0
package/README.md
CHANGED
|
@@ -44,6 +44,7 @@ reports, and other typed hook surfaces exported by this package.
|
|
|
44
44
|
database, logging, and only the host capabilities required by that hook.
|
|
45
45
|
- Prompt hooks return bounded structured prompt messages rather than mutate the
|
|
46
46
|
core prompt.
|
|
47
|
+
- `formatMarkdown` is a pure text rewrite into ordinary Markdown before delivery.
|
|
47
48
|
- User prompt hooks for durable turns may emit registered structured events
|
|
48
49
|
through `ctx.events` for auxiliary work completed while building context.
|
|
49
50
|
- Tool hooks return model-visible schemas aligned with their executor inputs.
|
|
@@ -58,6 +59,9 @@ reports, and other typed hook surfaces exported by this package.
|
|
|
58
59
|
binds the plugin namespace and owns access to the conversation event log.
|
|
59
60
|
Event `costUsd` is additive operation cost and must not duplicate cost
|
|
60
61
|
already recorded in the conversation's agent model usage.
|
|
62
|
+
- Profile report hooks return the same bounded operational report content for
|
|
63
|
+
one subject user on a person profile. Core owns viewer authorization,
|
|
64
|
+
collection, sanitization, and browser rendering.
|
|
61
65
|
- Tool hooks may lazily resolve the active actor's canonical identity and linked
|
|
62
66
|
user through `ctx.users.resolveActor()`.
|
|
63
67
|
- Authenticated API route hooks receive `ctx.users.resolve(email)` for lazy
|
package/dist/annotations.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import type { PluginContext } from "./context";
|
|
2
3
|
export declare const resourceLinkAnnotationSchema: z.ZodObject<{
|
|
3
4
|
kind: z.ZodLiteral<"resource_link">;
|
|
4
5
|
key: z.ZodString;
|
|
@@ -42,3 +43,30 @@ export interface PluginAnnotations {
|
|
|
42
43
|
export interface PluginConversationAnnotations {
|
|
43
44
|
forConversation(conversationId: string): PluginAnnotations;
|
|
44
45
|
}
|
|
46
|
+
export declare const conversationSidebarIconSchema: z.ZodEnum<{
|
|
47
|
+
"circle-dot": "circle-dot";
|
|
48
|
+
"circle-dashed": "circle-dashed";
|
|
49
|
+
"circle-x": "circle-x";
|
|
50
|
+
"git-merge": "git-merge";
|
|
51
|
+
"triangle-alert": "triangle-alert";
|
|
52
|
+
}>;
|
|
53
|
+
export declare const conversationSidebarAnnotationSchema: z.ZodObject<{
|
|
54
|
+
icon: z.ZodOptional<z.ZodEnum<{
|
|
55
|
+
"circle-dot": "circle-dot";
|
|
56
|
+
"circle-dashed": "circle-dashed";
|
|
57
|
+
"circle-x": "circle-x";
|
|
58
|
+
"git-merge": "git-merge";
|
|
59
|
+
"triangle-alert": "triangle-alert";
|
|
60
|
+
}>>;
|
|
61
|
+
key: z.ZodString;
|
|
62
|
+
label: z.ZodString;
|
|
63
|
+
}, z.core.$strict>;
|
|
64
|
+
export type ConversationSidebarAnnotation = z.output<typeof conversationSidebarAnnotationSchema>;
|
|
65
|
+
export interface ConversationSidebarHookContext extends PluginContext {
|
|
66
|
+
/** Stored annotations owned by this plugin, keyed by candidate conversation. */
|
|
67
|
+
annotationsByConversationId: Record<string, ConversationAnnotation[]>;
|
|
68
|
+
conversationIds: string[];
|
|
69
|
+
}
|
|
70
|
+
export interface ConversationSidebarResult {
|
|
71
|
+
annotationsByConversationId: Record<string, ConversationSidebarAnnotation[]>;
|
|
72
|
+
}
|
|
@@ -2,8 +2,8 @@ import { z } from "zod";
|
|
|
2
2
|
export declare const conversationEventIconSchema: z.ZodEnum<{
|
|
3
3
|
check: "check";
|
|
4
4
|
key: "key";
|
|
5
|
-
warning: "warning";
|
|
6
5
|
link: "link";
|
|
6
|
+
warning: "warning";
|
|
7
7
|
activity: "activity";
|
|
8
8
|
brain: "brain";
|
|
9
9
|
calendar: "calendar";
|
|
@@ -22,8 +22,8 @@ export declare const conversationEventPresentationSchema: z.ZodObject<{
|
|
|
22
22
|
icon: z.ZodOptional<z.ZodEnum<{
|
|
23
23
|
check: "check";
|
|
24
24
|
key: "key";
|
|
25
|
-
warning: "warning";
|
|
26
25
|
link: "link";
|
|
26
|
+
warning: "warning";
|
|
27
27
|
activity: "activity";
|
|
28
28
|
brain: "brain";
|
|
29
29
|
calendar: "calendar";
|
package/dist/hooks.d.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
import type { ConversationSidebarHookContext, ConversationSidebarResult } from "./annotations";
|
|
1
2
|
import type { EgressHookContext, EgressResponseHookContext, IssueCredentialHookContext, PluginCredentialResult, PluginGrant, PluginProviderAccount, ResolveOAuthAccountHookContext } from "./credentials";
|
|
2
|
-
import type { HeartbeatHookContext, HeartbeatResult, OperationalReportHookContext, ApiRouteRegistrationHookContext, PluginOperationalReportContent, PluginRoute, PluginRouteApp, RouteRegistrationHookContext, SlackConversationLink, SlackConversationLinkHookContext, UnfinishedWorkHookContext, UnfinishedWorkResult } from "./operations";
|
|
3
|
+
import type { HeartbeatHookContext, HeartbeatResult, OperationalReportHookContext, ProfileReportHookContext, ApiRouteRegistrationHookContext, PluginOperationalReportContent, PluginRoute, PluginRouteApp, RouteRegistrationHookContext, SlackConversationLink, SlackConversationLinkHookContext, UnfinishedWorkHookContext, UnfinishedWorkResult } from "./operations";
|
|
3
4
|
import type { AfterMcpToolHookContext, BeforeToolExecuteHookContext, PluginToolDefinition, SandboxPrepareHookContext, ToolRegistrationHookContext } from "./tools";
|
|
4
5
|
import type { PromptMessage, SystemPromptContext, UserPromptContext, UserPromptContribution } from "./prompt";
|
|
6
|
+
/** Input for a pure Markdown rewrite before destination delivery formatting. */
|
|
7
|
+
export interface FormatMarkdownHookContext {
|
|
8
|
+
text: string;
|
|
9
|
+
}
|
|
5
10
|
export interface PluginHooks {
|
|
11
|
+
conversationSidebar?(ctx: ConversationSidebarHookContext): Promise<ConversationSidebarResult> | ConversationSidebarResult;
|
|
6
12
|
systemPrompt?(ctx: SystemPromptContext): Promise<PromptMessage[]> | PromptMessage[];
|
|
7
13
|
userPrompt?(ctx: UserPromptContext): Promise<UserPromptContribution[] | undefined> | UserPromptContribution[] | undefined;
|
|
8
14
|
beforeToolExecute?(ctx: BeforeToolExecuteHookContext): Promise<void> | void;
|
|
@@ -19,11 +25,18 @@ export interface PluginHooks {
|
|
|
19
25
|
issueCredential?(ctx: IssueCredentialHookContext): Promise<PluginCredentialResult> | PluginCredentialResult;
|
|
20
26
|
onEgressResponse?(ctx: EgressResponseHookContext): Promise<void> | void;
|
|
21
27
|
operationalReport?(ctx: OperationalReportHookContext): Promise<PluginOperationalReportContent | undefined> | PluginOperationalReportContent | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Return one person-scoped operational report for a profile page.
|
|
30
|
+
* Omit or return undefined when the plugin has nothing to show for the subject.
|
|
31
|
+
*/
|
|
32
|
+
profileReport?(ctx: ProfileReportHookContext): Promise<PluginOperationalReportContent | undefined> | PluginOperationalReportContent | undefined;
|
|
22
33
|
/** Return plugin-owned product API routes mounted under Junior's authenticated plugin namespace. */
|
|
23
34
|
apiRoutes?(ctx: ApiRouteRegistrationHookContext): PluginRouteApp | undefined;
|
|
24
35
|
resolveOAuthAccount?(ctx: ResolveOAuthAccountHookContext): Promise<PluginProviderAccount | undefined> | PluginProviderAccount | undefined;
|
|
25
36
|
routes?(ctx: RouteRegistrationHookContext): PluginRoute[];
|
|
26
37
|
sandboxPrepare?(ctx: SandboxPrepareHookContext): Promise<void> | void;
|
|
27
38
|
slackConversationLink?(ctx: SlackConversationLinkHookContext): SlackConversationLink | undefined;
|
|
39
|
+
/** Pure Markdown rewrite. Emit ordinary Markdown only. */
|
|
40
|
+
formatMarkdown?(ctx: FormatMarkdownHookContext): string;
|
|
28
41
|
tools?(ctx: ToolRegistrationHookContext): Record<string, PluginToolDefinition>;
|
|
29
42
|
}
|
package/dist/index.js
CHANGED
|
@@ -19,6 +19,18 @@ var resourceLinkAnnotationSchema = z.object({
|
|
|
19
19
|
var conversationAnnotationInputSchema = z.discriminatedUnion("kind", [
|
|
20
20
|
resourceLinkAnnotationSchema
|
|
21
21
|
]);
|
|
22
|
+
var conversationSidebarIconSchema = z.enum([
|
|
23
|
+
"circle-dot",
|
|
24
|
+
"circle-dashed",
|
|
25
|
+
"circle-x",
|
|
26
|
+
"git-merge",
|
|
27
|
+
"triangle-alert"
|
|
28
|
+
]);
|
|
29
|
+
var conversationSidebarAnnotationSchema = z.object({
|
|
30
|
+
icon: conversationSidebarIconSchema.optional(),
|
|
31
|
+
key: z.string().trim().min(1).max(256),
|
|
32
|
+
label: z.string().trim().min(1).max(256)
|
|
33
|
+
}).strict();
|
|
22
34
|
|
|
23
35
|
// src/conversation-events.ts
|
|
24
36
|
import { z as z2 } from "zod";
|
|
@@ -849,6 +861,8 @@ export {
|
|
|
849
861
|
conversationAnnotationInputSchema,
|
|
850
862
|
conversationEventIconSchema,
|
|
851
863
|
conversationEventPresentationSchema,
|
|
864
|
+
conversationSidebarAnnotationSchema,
|
|
865
|
+
conversationSidebarIconSchema,
|
|
852
866
|
createLocalSource,
|
|
853
867
|
createSlackSource,
|
|
854
868
|
createWebSource,
|
package/dist/operations.d.ts
CHANGED
|
@@ -96,6 +96,15 @@ export interface OperationalReportHookContext extends PluginContext {
|
|
|
96
96
|
nowMs: number;
|
|
97
97
|
state: PluginReadState;
|
|
98
98
|
}
|
|
99
|
+
/** Read-only context for one person-scoped plugin report on a profile page. */
|
|
100
|
+
export interface ProfileReportHookContext extends PluginContext {
|
|
101
|
+
nowMs: number;
|
|
102
|
+
state: PluginReadState;
|
|
103
|
+
/** Canonical user for the profile being viewed. */
|
|
104
|
+
subject: User;
|
|
105
|
+
/** Canonical user for the authenticated viewer. */
|
|
106
|
+
viewer: User;
|
|
107
|
+
}
|
|
99
108
|
export type PluginRouteMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS" | "ALL";
|
|
100
109
|
export type PluginRouteHandler = {
|
|
101
110
|
bivarianceHack(request: Request): Promise<Response> | Response;
|
package/package.json
CHANGED
package/src/annotations.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import type { PluginContext } from "./context";
|
|
2
3
|
|
|
3
4
|
function usesHttpProtocol(value: string): boolean {
|
|
4
5
|
try {
|
|
@@ -44,3 +45,35 @@ export interface PluginAnnotations {
|
|
|
44
45
|
export interface PluginConversationAnnotations {
|
|
45
46
|
forConversation(conversationId: string): PluginAnnotations;
|
|
46
47
|
}
|
|
48
|
+
|
|
49
|
+
export const conversationSidebarIconSchema = z.enum([
|
|
50
|
+
"circle-dot",
|
|
51
|
+
"circle-dashed",
|
|
52
|
+
"circle-x",
|
|
53
|
+
"git-merge",
|
|
54
|
+
"triangle-alert",
|
|
55
|
+
]);
|
|
56
|
+
|
|
57
|
+
export const conversationSidebarAnnotationSchema = z
|
|
58
|
+
.object({
|
|
59
|
+
icon: conversationSidebarIconSchema.optional(),
|
|
60
|
+
key: z.string().trim().min(1).max(256),
|
|
61
|
+
label: z.string().trim().min(1).max(256),
|
|
62
|
+
})
|
|
63
|
+
.strict();
|
|
64
|
+
export type ConversationSidebarAnnotation = z.output<
|
|
65
|
+
typeof conversationSidebarAnnotationSchema
|
|
66
|
+
>;
|
|
67
|
+
|
|
68
|
+
export interface ConversationSidebarHookContext extends PluginContext {
|
|
69
|
+
/** Stored annotations owned by this plugin, keyed by candidate conversation. */
|
|
70
|
+
annotationsByConversationId: Record<string, ConversationAnnotation[]>;
|
|
71
|
+
conversationIds: string[];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface ConversationSidebarResult {
|
|
75
|
+
annotationsByConversationId: Record<
|
|
76
|
+
string,
|
|
77
|
+
ConversationSidebarAnnotation[]
|
|
78
|
+
>;
|
|
79
|
+
}
|
package/src/hooks.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ConversationSidebarHookContext,
|
|
3
|
+
ConversationSidebarResult,
|
|
4
|
+
} from "./annotations";
|
|
1
5
|
import type {
|
|
2
6
|
EgressHookContext,
|
|
3
7
|
EgressResponseHookContext,
|
|
@@ -11,6 +15,7 @@ import type {
|
|
|
11
15
|
HeartbeatHookContext,
|
|
12
16
|
HeartbeatResult,
|
|
13
17
|
OperationalReportHookContext,
|
|
18
|
+
ProfileReportHookContext,
|
|
14
19
|
ApiRouteRegistrationHookContext,
|
|
15
20
|
PluginOperationalReportContent,
|
|
16
21
|
PluginRoute,
|
|
@@ -35,7 +40,15 @@ import type {
|
|
|
35
40
|
UserPromptContribution,
|
|
36
41
|
} from "./prompt";
|
|
37
42
|
|
|
43
|
+
/** Input for a pure Markdown rewrite before destination delivery formatting. */
|
|
44
|
+
export interface FormatMarkdownHookContext {
|
|
45
|
+
text: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
38
48
|
export interface PluginHooks {
|
|
49
|
+
conversationSidebar?(
|
|
50
|
+
ctx: ConversationSidebarHookContext,
|
|
51
|
+
): Promise<ConversationSidebarResult> | ConversationSidebarResult;
|
|
39
52
|
systemPrompt?(
|
|
40
53
|
ctx: SystemPromptContext,
|
|
41
54
|
): Promise<PromptMessage[]> | PromptMessage[];
|
|
@@ -72,6 +85,16 @@ export interface PluginHooks {
|
|
|
72
85
|
| Promise<PluginOperationalReportContent | undefined>
|
|
73
86
|
| PluginOperationalReportContent
|
|
74
87
|
| undefined;
|
|
88
|
+
/**
|
|
89
|
+
* Return one person-scoped operational report for a profile page.
|
|
90
|
+
* Omit or return undefined when the plugin has nothing to show for the subject.
|
|
91
|
+
*/
|
|
92
|
+
profileReport?(
|
|
93
|
+
ctx: ProfileReportHookContext,
|
|
94
|
+
):
|
|
95
|
+
| Promise<PluginOperationalReportContent | undefined>
|
|
96
|
+
| PluginOperationalReportContent
|
|
97
|
+
| undefined;
|
|
75
98
|
/** Return plugin-owned product API routes mounted under Junior's authenticated plugin namespace. */
|
|
76
99
|
apiRoutes?(ctx: ApiRouteRegistrationHookContext): PluginRouteApp | undefined;
|
|
77
100
|
resolveOAuthAccount?(
|
|
@@ -85,6 +108,8 @@ export interface PluginHooks {
|
|
|
85
108
|
slackConversationLink?(
|
|
86
109
|
ctx: SlackConversationLinkHookContext,
|
|
87
110
|
): SlackConversationLink | undefined;
|
|
111
|
+
/** Pure Markdown rewrite. Emit ordinary Markdown only. */
|
|
112
|
+
formatMarkdown?(ctx: FormatMarkdownHookContext): string;
|
|
88
113
|
tools?(
|
|
89
114
|
ctx: ToolRegistrationHookContext,
|
|
90
115
|
): Record<string, PluginToolDefinition>;
|
package/src/operations.ts
CHANGED
|
@@ -113,6 +113,16 @@ export interface OperationalReportHookContext extends PluginContext {
|
|
|
113
113
|
state: PluginReadState;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
+
/** Read-only context for one person-scoped plugin report on a profile page. */
|
|
117
|
+
export interface ProfileReportHookContext extends PluginContext {
|
|
118
|
+
nowMs: number;
|
|
119
|
+
state: PluginReadState;
|
|
120
|
+
/** Canonical user for the profile being viewed. */
|
|
121
|
+
subject: User;
|
|
122
|
+
/** Canonical user for the authenticated viewer. */
|
|
123
|
+
viewer: User;
|
|
124
|
+
}
|
|
125
|
+
|
|
116
126
|
export type PluginRouteMethod =
|
|
117
127
|
| "GET"
|
|
118
128
|
| "POST"
|