@sentry/junior-plugin-api 0.312.0 → 0.314.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 +132 -19
- package/dist/index.js +76 -9
- 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>;
|
|
@@ -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<{
|
|
@@ -1102,8 +1103,8 @@ export type EventAutomationSource = Extract<Source, {
|
|
|
1102
1103
|
export type PluginDispatchSource = Extract<Source, {
|
|
1103
1104
|
kind: "plugin_dispatch";
|
|
1104
1105
|
}>;
|
|
1105
|
-
export type
|
|
1106
|
-
kind: "
|
|
1106
|
+
export type ParentMessageSource = Extract<Source, {
|
|
1107
|
+
kind: "parent_message";
|
|
1107
1108
|
}>;
|
|
1108
1109
|
export type SourceVisibility = z.output<typeof sourceVisibilitySchema>;
|
|
1109
1110
|
export type Destination = z.output<typeof destinationSchema>;
|
|
@@ -1117,7 +1118,8 @@ export interface PluginMetadata {
|
|
|
1117
1118
|
name: string;
|
|
1118
1119
|
}
|
|
1119
1120
|
export interface PluginLogger {
|
|
1120
|
-
error
|
|
1121
|
+
/** Report an error. `cause` is the caught error, which the report keeps. */
|
|
1122
|
+
error(message: string, metadata?: Record<string, unknown>, cause?: unknown): void;
|
|
1121
1123
|
info(message: string, metadata?: Record<string, unknown>): void;
|
|
1122
1124
|
warn(message: string, metadata?: Record<string, unknown>): void;
|
|
1123
1125
|
}
|
|
@@ -1233,7 +1235,7 @@ export interface EventInvocationContext extends BaseInvocationContext {
|
|
|
1233
1235
|
export type InvocationContext = LocalInvocationContext | SlackInvocationContext | WebInvocationContext | (BaseInvocationContext & {
|
|
1234
1236
|
destination: Destination;
|
|
1235
1237
|
actor?: Actor | undefined;
|
|
1236
|
-
source:
|
|
1238
|
+
source: ParentMessageSource | EventAutomationSource | PluginDispatchSource | EventSource | ScheduledAutomationSource;
|
|
1237
1239
|
});
|
|
1238
1240
|
/** Build a normalized Slack source from runtime-owned Slack coordinates. */
|
|
1239
1241
|
export declare function createSlackSource(input: {
|
|
@@ -3299,7 +3301,6 @@ export declare const codeChangeInputSchema: z.ZodObject<{
|
|
|
3299
3301
|
repository: z.ZodObject<{
|
|
3300
3302
|
name: z.ZodString;
|
|
3301
3303
|
providerId: z.ZodString;
|
|
3302
|
-
url: z.ZodOptional<z.ZodString>;
|
|
3303
3304
|
}, z.core.$strict>;
|
|
3304
3305
|
size: z.ZodOptional<z.ZodObject<{
|
|
3305
3306
|
changedFiles: z.ZodOptional<z.ZodNumber>;
|
|
@@ -3313,7 +3314,6 @@ export declare const codeChangeInputSchema: z.ZodObject<{
|
|
|
3313
3314
|
}>;
|
|
3314
3315
|
title: z.ZodOptional<z.ZodString>;
|
|
3315
3316
|
updatedAt: z.ZodDate;
|
|
3316
|
-
url: z.ZodOptional<z.ZodString>;
|
|
3317
3317
|
}, z.core.$strict>;
|
|
3318
3318
|
export type CodeChangeInput = z.input<typeof codeChangeInputSchema>;
|
|
3319
3319
|
/** Write code changes from a plugin to Junior's code records. */
|
|
@@ -3333,6 +3333,56 @@ export interface CodeChangePublisher {
|
|
|
3333
3333
|
repositoryProviderId: string;
|
|
3334
3334
|
}): Promise<void>;
|
|
3335
3335
|
}
|
|
3336
|
+
/**
|
|
3337
|
+
* Build the web pages of a code plugin's repositories and code changes from
|
|
3338
|
+
* the repository name and the code change number, so Junior does not store
|
|
3339
|
+
* them.
|
|
3340
|
+
*/
|
|
3341
|
+
export interface PluginCodeLinks {
|
|
3342
|
+
change(input: {
|
|
3343
|
+
number: number;
|
|
3344
|
+
repository: string;
|
|
3345
|
+
}): string;
|
|
3346
|
+
repository(name: string): string;
|
|
3347
|
+
}
|
|
3348
|
+
/** Most entries in one batch, annotations and Inbox items together. */
|
|
3349
|
+
export declare const MAX_CONVERSATION_CHANGES = 100;
|
|
3350
|
+
/** Add or replace one annotation of this plugin on a Conversation. */
|
|
3351
|
+
export interface ConversationAnnotationChange {
|
|
3352
|
+
conversationId: string;
|
|
3353
|
+
upsert: ConversationAnnotationInput;
|
|
3354
|
+
}
|
|
3355
|
+
/**
|
|
3356
|
+
* Close the open Inbox item of this plugin with the key. Do nothing when no
|
|
3357
|
+
* item is open, such as after a person dismissed it.
|
|
3358
|
+
*/
|
|
3359
|
+
export interface ConversationInboxItemChange {
|
|
3360
|
+
close: {
|
|
3361
|
+
dedupeKey: string;
|
|
3362
|
+
reason: string;
|
|
3363
|
+
status: "done" | "dismissed";
|
|
3364
|
+
};
|
|
3365
|
+
conversationId: string;
|
|
3366
|
+
}
|
|
3367
|
+
/**
|
|
3368
|
+
* Changes that a plugin makes together, such as a chip that shows a merged
|
|
3369
|
+
* pull request and the close of its ask. It is data, so no provider call can
|
|
3370
|
+
* run while the changes are not saved.
|
|
3371
|
+
*/
|
|
3372
|
+
export interface ConversationChangeBatch {
|
|
3373
|
+
annotations?: ConversationAnnotationChange[];
|
|
3374
|
+
inboxItems?: ConversationInboxItemChange[];
|
|
3375
|
+
}
|
|
3376
|
+
/**
|
|
3377
|
+
* Save annotations and Inbox items of a plugin in one write. Readers see all
|
|
3378
|
+
* the changes of a batch or none of them. Each entry has the checks of the
|
|
3379
|
+
* same `forConversation` call. When one entry fails, no entry is saved and
|
|
3380
|
+
* the call throws. A batch has at most `MAX_CONVERSATION_CHANGES` entries.
|
|
3381
|
+
* Core shows the closed items, such as on their Slack cards, after the write.
|
|
3382
|
+
*/
|
|
3383
|
+
export interface PluginConversationChanges {
|
|
3384
|
+
apply(batch: ConversationChangeBatch): Promise<void>;
|
|
3385
|
+
}
|
|
3336
3386
|
export declare const conversationEventIconSchema: z.ZodEnum<{
|
|
3337
3387
|
activity: "activity";
|
|
3338
3388
|
brain: "brain";
|
|
@@ -3548,7 +3598,17 @@ type UserPromptContext = Pick<PluginContext, "db" | "log" | "plugin"> & {
|
|
|
3548
3598
|
* plugins build every prompt tag here, so all tags fence untrusted text the
|
|
3549
3599
|
* same way, and code reads stored history back with the same rules. Lint
|
|
3550
3600
|
* rules ban tag literals, tag regexes, and entity escapes elsewhere.
|
|
3551
|
-
*
|
|
3601
|
+
*
|
|
3602
|
+
* Escape by the kind of text:
|
|
3603
|
+
* - Runtime IDs, enums, handles, and times use only `[A-Za-z0-9._:@/#+-]`,
|
|
3604
|
+
* so they need no escaping. Any other attribute value is free text.
|
|
3605
|
+
* - Free text in an attribute, such as a name or a title: `&`, `<`, `>`, and
|
|
3606
|
+
* `"`.
|
|
3607
|
+
* - The body of a person's text or untrusted text: `&`, `<`, and `>`. This
|
|
3608
|
+
* also turns copies of our tags into plain text. Quotes stay as written.
|
|
3609
|
+
* - A JSON body: `<`, `>`, and `&` as `\u003c`, `\u003e`, and `\u0026`.
|
|
3610
|
+
* - Raw text, such as the system prompt, a skill, or `AGENTS.md`: only its
|
|
3611
|
+
* closing tag.
|
|
3552
3612
|
*/
|
|
3553
3613
|
/** Attribute values of one tag. An undefined or empty value is left out. */
|
|
3554
3614
|
export type PromptTagAttributes = Record<string, string | number | undefined>;
|
|
@@ -3953,7 +4013,7 @@ export declare const pluginRunContextSchema: z.ZodObject<{
|
|
|
3953
4013
|
}, z.core.$strict>, z.ZodObject<{
|
|
3954
4014
|
kind: z.ZodLiteral<"plugin_dispatch">;
|
|
3955
4015
|
}, z.core.$strict>, z.ZodObject<{
|
|
3956
|
-
kind: z.ZodLiteral<"
|
|
4016
|
+
kind: z.ZodLiteral<"parent_message">;
|
|
3957
4017
|
}, z.core.$strict>], "kind">, unknown>;
|
|
3958
4018
|
transcript: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
3959
4019
|
type: z.ZodLiteral<"message">;
|
|
@@ -4153,6 +4213,8 @@ export interface HeartbeatHookContext extends PluginContext {
|
|
|
4153
4213
|
annotations: PluginConversationAnnotations;
|
|
4154
4214
|
/** Junior's native code index, as from a plugin route. */
|
|
4155
4215
|
codeChanges: CodeChangePublisher;
|
|
4216
|
+
/** Annotation and Inbox item changes in one write, as from a plugin route. */
|
|
4217
|
+
conversationChanges: PluginConversationChanges;
|
|
4156
4218
|
/** Host embedder bound to the configured embedding model. */
|
|
4157
4219
|
embedder: PluginEmbedder;
|
|
4158
4220
|
/** Publish events, as from a plugin route. */
|
|
@@ -4287,6 +4349,8 @@ export interface RouteRegistrationHookContext extends PluginContext {
|
|
|
4287
4349
|
annotations: PluginConversationAnnotations;
|
|
4288
4350
|
/** Provider-neutral write boundary for Junior's native code index. */
|
|
4289
4351
|
codeChanges: CodeChangePublisher;
|
|
4352
|
+
/** Annotation and Inbox item changes that readers must see together. */
|
|
4353
|
+
conversationChanges: PluginConversationChanges;
|
|
4290
4354
|
/** Core-owned delivery boundary for provider webhook events. */
|
|
4291
4355
|
events: EventPublisher;
|
|
4292
4356
|
/** Inbox items that the plugin adds and closes from its events. */
|
|
@@ -4413,7 +4477,7 @@ export interface PluginHooks {
|
|
|
4413
4477
|
/**
|
|
4414
4478
|
* Return static guidance for the system prompt. Return the same text for one
|
|
4415
4479
|
* deployment and platform, so the system prompt stays cacheable. Put text
|
|
4416
|
-
* that changes per request in `userPrompt`.
|
|
4480
|
+
* that changes per request in `userPrompt`.
|
|
4417
4481
|
*/
|
|
4418
4482
|
systemPrompt?(ctx: SystemPromptContext): Promise<PromptMessage[]> | PromptMessage[];
|
|
4419
4483
|
/**
|
|
@@ -4539,7 +4603,11 @@ export interface PluginOAuthConfig {
|
|
|
4539
4603
|
}
|
|
4540
4604
|
export interface PluginOAuthBearerCredentials {
|
|
4541
4605
|
apiHeaders?: Record<string, string>;
|
|
4542
|
-
|
|
4606
|
+
/**
|
|
4607
|
+
* Env var of a host token, and the name of the Sandbox placeholder.
|
|
4608
|
+
* Optional with `oauth`: without it there is no env token fallback.
|
|
4609
|
+
*/
|
|
4610
|
+
authTokenEnv?: string;
|
|
4543
4611
|
authTokenPlaceholder?: string;
|
|
4544
4612
|
domains: string[];
|
|
4545
4613
|
type: "oauth-bearer";
|
|
@@ -4611,8 +4679,8 @@ export interface PluginMcpConfig {
|
|
|
4611
4679
|
* the Actor to connect their own account.
|
|
4612
4680
|
*
|
|
4613
4681
|
* 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
|
|
4682
|
+
* asks an Actor to connect, ignores their own connections, and hides MCP
|
|
4683
|
+
* tools that the service account does not list. Until an Admin connects the
|
|
4616
4684
|
* account, the plugin is not available.
|
|
4617
4685
|
*/
|
|
4618
4686
|
export interface PluginAccountsConfig {
|
|
@@ -4621,11 +4689,21 @@ export interface PluginAccountsConfig {
|
|
|
4621
4689
|
/** Optional service account and what it may use. Omit for none. */
|
|
4622
4690
|
serviceAccount?: PluginServiceAccountConfig;
|
|
4623
4691
|
}
|
|
4624
|
-
/**
|
|
4625
|
-
|
|
4692
|
+
/**
|
|
4693
|
+
* What one plugin's service account may use. An `mcp` plugin lists MCP
|
|
4694
|
+
* tools. A plugin with a top-level `oauth` block lists the `operation`
|
|
4695
|
+
* names that its host code passes to `egress.fetch`. Sandbox commands never
|
|
4696
|
+
* name an operation, so they never get the service account.
|
|
4697
|
+
*/
|
|
4698
|
+
export type PluginServiceAccountConfig = {
|
|
4626
4699
|
/** MCP tools that the account may call. Each must be loaded by `mcp`. */
|
|
4627
4700
|
tools: string[];
|
|
4628
|
-
|
|
4701
|
+
operations?: never;
|
|
4702
|
+
} | {
|
|
4703
|
+
/** `egress.fetch` operations that the account may serve. */
|
|
4704
|
+
operations: string[];
|
|
4705
|
+
tools?: never;
|
|
4706
|
+
};
|
|
4629
4707
|
export interface PluginEnvVarDeclaration {
|
|
4630
4708
|
default?: string;
|
|
4631
4709
|
exposeToCommandEnv?: boolean;
|
|
@@ -4769,6 +4847,8 @@ export interface PluginModelConfig {
|
|
|
4769
4847
|
}
|
|
4770
4848
|
export type PluginRegistrationInput = {
|
|
4771
4849
|
cli?: PluginCliDefinition;
|
|
4850
|
+
/** Web pages of the code changes that this plugin records. */
|
|
4851
|
+
codeLinks?: PluginCodeLinks;
|
|
4772
4852
|
conversationEvents?: PluginConversationEventDefinition[];
|
|
4773
4853
|
hooks?: PluginHooks;
|
|
4774
4854
|
/** Images that this plugin serves through the Junior image proxy. */
|
|
@@ -4785,4 +4865,37 @@ export type PluginRegistrationInput = {
|
|
|
4785
4865
|
export interface PluginRegistration extends PluginRegistrationInput {}
|
|
4786
4866
|
/** Define one Junior plugin registration for app and build-time wiring. */
|
|
4787
4867
|
export declare function defineJuniorPlugin(plugin: PluginRegistrationInput): PluginRegistration;
|
|
4868
|
+
/** One node of a parsed Markdown tree. */
|
|
4869
|
+
export type MarkdownNode = Nodes;
|
|
4870
|
+
/**
|
|
4871
|
+
* Parse GitHub-flavored Markdown. Each node position holds offsets into
|
|
4872
|
+
* `text`, so a caller can slice the source of a node.
|
|
4873
|
+
*/
|
|
4874
|
+
export declare function parseMarkdown(text: string): Root;
|
|
4875
|
+
/**
|
|
4876
|
+
* Return the nodes of the given types in a Markdown tree, in text order. It
|
|
4877
|
+
* does not look inside a node that it returns.
|
|
4878
|
+
*/
|
|
4879
|
+
export declare function markdownNodes<Type extends MarkdownNode["type"]>(tree: MarkdownNode, types: readonly Type[]): Extract<MarkdownNode, {
|
|
4880
|
+
type: Type;
|
|
4881
|
+
}>[];
|
|
4882
|
+
/** What `markdownText` reads from a Markdown tree. */
|
|
4883
|
+
export interface MarkdownTextOptions {
|
|
4884
|
+
/**
|
|
4885
|
+
* Leave out code blocks, images, and HTML, for a place that has room only
|
|
4886
|
+
* for prose. Inline code stays.
|
|
4887
|
+
*/
|
|
4888
|
+
proseOnly?: boolean;
|
|
4889
|
+
}
|
|
4890
|
+
/**
|
|
4891
|
+
* Return the readable text of a Markdown node without its syntax. Inline
|
|
4892
|
+
* parts join with no space, and blocks join with one space. An image gives
|
|
4893
|
+
* its alt text. The whitespace inside text stays as it is.
|
|
4894
|
+
*/
|
|
4895
|
+
export declare function markdownText(node: MarkdownNode, options?: MarkdownTextOptions): string;
|
|
4896
|
+
/**
|
|
4897
|
+
* Return Markdown text as one plain line: the readable text of its tree with
|
|
4898
|
+
* each run of whitespace made one space.
|
|
4899
|
+
*/
|
|
4900
|
+
export declare function markdownPlainText(text: string, options?: MarkdownTextOptions): string;
|
|
4788
4901
|
export type { PromptContext, PromptContextContribution, PromptHistory, PromptHistoryContext, PromptMessage, SystemPromptContext, 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();
|
|
@@ -931,8 +934,7 @@ const codeChangeInputSchema = z.object({
|
|
|
931
934
|
providerId: z.string().min(1),
|
|
932
935
|
repository: z.object({
|
|
933
936
|
name: z.string().min(1),
|
|
934
|
-
providerId: z.string().min(1)
|
|
935
|
-
url: z.string().url().optional()
|
|
937
|
+
providerId: z.string().min(1)
|
|
936
938
|
}).strict(),
|
|
937
939
|
/**
|
|
938
940
|
* The size as the provider counts it now. Junior keeps the stored value
|
|
@@ -941,9 +943,11 @@ const codeChangeInputSchema = z.object({
|
|
|
941
943
|
size: codeChangeSizeSchema.optional(),
|
|
942
944
|
state: codeChangeStateSchema,
|
|
943
945
|
title: z.string().min(1).optional(),
|
|
944
|
-
updatedAt: z.date()
|
|
945
|
-
url: z.string().url().optional()
|
|
946
|
+
updatedAt: z.date()
|
|
946
947
|
}).strict();
|
|
948
|
+
// src/conversation-changes.ts
|
|
949
|
+
/** Most entries in one batch, annotations and Inbox items together. */
|
|
950
|
+
const MAX_CONVERSATION_CHANGES = 100;
|
|
947
951
|
// src/conversation-events.ts
|
|
948
952
|
const conversationEventNameSchema = z.string().trim().min(1).max(64).regex(/^[a-z][a-z0-9_]*$/);
|
|
949
953
|
const conversationEventIconSchema = z.enum([
|
|
@@ -1109,8 +1113,8 @@ const eventAutomationSourceSchema = z.object({
|
|
|
1109
1113
|
}).strict();
|
|
1110
1114
|
/** Runtime-owned Plugin dispatch input Source. */
|
|
1111
1115
|
const pluginDispatchSourceSchema = z.object({ kind: z.literal("plugin_dispatch") }).strict();
|
|
1112
|
-
/** Runtime-owned
|
|
1113
|
-
const
|
|
1116
|
+
/** Runtime-owned Source of a parent agent's task or message to a child agent. */
|
|
1117
|
+
const parentMessageSourceSchema = z.object({ kind: z.literal("parent_message") }).strict();
|
|
1114
1118
|
const currentSourceSchema = z.discriminatedUnion("kind", [
|
|
1115
1119
|
slackSourceSchema,
|
|
1116
1120
|
localSourceSchema,
|
|
@@ -1119,13 +1123,14 @@ const currentSourceSchema = z.discriminatedUnion("kind", [
|
|
|
1119
1123
|
scheduledAutomationSourceSchema,
|
|
1120
1124
|
eventAutomationSourceSchema,
|
|
1121
1125
|
pluginDispatchSourceSchema,
|
|
1122
|
-
|
|
1126
|
+
parentMessageSourceSchema
|
|
1123
1127
|
]);
|
|
1124
1128
|
function normalizeStoredSource(value) {
|
|
1125
1129
|
if (!value || typeof value !== "object" || Array.isArray(value)) return value;
|
|
1126
1130
|
const source = value;
|
|
1127
1131
|
if ("kind" in source) {
|
|
1128
1132
|
const kind = typeof source["kind"] === "string" ? {
|
|
1133
|
+
agent_invocation: "parent_message",
|
|
1129
1134
|
event_task: "event_automation",
|
|
1130
1135
|
resource_event: "event",
|
|
1131
1136
|
scheduled_task: "scheduled_automation"
|
|
@@ -1339,7 +1344,7 @@ function getSourceKey(source) {
|
|
|
1339
1344
|
case "scheduled_automation":
|
|
1340
1345
|
case "event_automation":
|
|
1341
1346
|
case "plugin_dispatch":
|
|
1342
|
-
case "
|
|
1347
|
+
case "parent_message": return;
|
|
1343
1348
|
}
|
|
1344
1349
|
}
|
|
1345
1350
|
/** Narrow a runtime destination to the Slack-specific address shape. */
|
|
@@ -2725,6 +2730,68 @@ function validateObjectLinks(name, links) {
|
|
|
2725
2730
|
}
|
|
2726
2731
|
}
|
|
2727
2732
|
}
|
|
2733
|
+
// src/markdown.ts
|
|
2734
|
+
/**
|
|
2735
|
+
* Parse GitHub-flavored Markdown. Each node position holds offsets into
|
|
2736
|
+
* `text`, so a caller can slice the source of a node.
|
|
2737
|
+
*/
|
|
2738
|
+
function parseMarkdown(text) {
|
|
2739
|
+
return fromMarkdown(text, {
|
|
2740
|
+
extensions: [gfm()],
|
|
2741
|
+
mdastExtensions: [gfmFromMarkdown()]
|
|
2742
|
+
});
|
|
2743
|
+
}
|
|
2744
|
+
/**
|
|
2745
|
+
* Return the nodes of the given types in a Markdown tree, in text order. It
|
|
2746
|
+
* does not look inside a node that it returns.
|
|
2747
|
+
*/
|
|
2748
|
+
function markdownNodes(tree, types) {
|
|
2749
|
+
const found = [];
|
|
2750
|
+
const visit = (node) => {
|
|
2751
|
+
if (isOfType(node, types)) found.push(node);
|
|
2752
|
+
else if ("children" in node) for (const child of node.children) visit(child);
|
|
2753
|
+
};
|
|
2754
|
+
visit(tree);
|
|
2755
|
+
return found;
|
|
2756
|
+
}
|
|
2757
|
+
function isOfType(node, types) {
|
|
2758
|
+
return types.some((type) => type === node.type);
|
|
2759
|
+
}
|
|
2760
|
+
const INLINE_PARENTS = /* @__PURE__ */ new Set([
|
|
2761
|
+
"delete",
|
|
2762
|
+
"emphasis",
|
|
2763
|
+
"heading",
|
|
2764
|
+
"link",
|
|
2765
|
+
"linkReference",
|
|
2766
|
+
"paragraph",
|
|
2767
|
+
"strong",
|
|
2768
|
+
"tableCell"
|
|
2769
|
+
]);
|
|
2770
|
+
const NON_PROSE = /* @__PURE__ */ new Set([
|
|
2771
|
+
"code",
|
|
2772
|
+
"html",
|
|
2773
|
+
"image"
|
|
2774
|
+
]);
|
|
2775
|
+
/**
|
|
2776
|
+
* Return the readable text of a Markdown node without its syntax. Inline
|
|
2777
|
+
* parts join with no space, and blocks join with one space. An image gives
|
|
2778
|
+
* its alt text. The whitespace inside text stays as it is.
|
|
2779
|
+
*/
|
|
2780
|
+
function markdownText(node, options = {}) {
|
|
2781
|
+
if (options.proseOnly && NON_PROSE.has(node.type)) return "";
|
|
2782
|
+
if (node.type === "image") return node.alt ?? "";
|
|
2783
|
+
if (node.type === "break") return " ";
|
|
2784
|
+
if ("value" in node) return node.value;
|
|
2785
|
+
if (!("children" in node)) return "";
|
|
2786
|
+
return node.children.map((child) => markdownText(child, options)).join(INLINE_PARENTS.has(node.type) ? "" : " ");
|
|
2787
|
+
}
|
|
2788
|
+
/**
|
|
2789
|
+
* Return Markdown text as one plain line: the readable text of its tree with
|
|
2790
|
+
* each run of whitespace made one space.
|
|
2791
|
+
*/
|
|
2792
|
+
function markdownPlainText(text, options = {}) {
|
|
2793
|
+
return markdownText(parseMarkdown(text), options).replace(/\s+/g, " ").trim();
|
|
2794
|
+
}
|
|
2728
2795
|
// src/user-pages.ts
|
|
2729
2796
|
/**
|
|
2730
2797
|
* Core-rendered plugin user pages.
|
|
@@ -2808,4 +2875,4 @@ const pluginUserPageInputSchema = z.object({
|
|
|
2808
2875
|
limit: z.number().int().min(1).max(50),
|
|
2809
2876
|
query: pluginUserPageQuerySchema
|
|
2810
2877
|
}).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,
|
|
2878
|
+
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, codeChangeInputSchema, codeChangeSizeSchema, codeChangeStateSchema, 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, 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.314.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": {
|