@sentry/junior-plugin-api 0.299.0 → 0.300.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.d.ts +1600 -1443
  2. package/dist/index.js +64 -1
  3. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -2,10 +2,14 @@ import * as z from "zod";
2
2
  // src/object-facts.ts
3
3
  const text = z.string().trim().min(1).max(160);
4
4
  const count = z.number().int().nonnegative();
5
+ /** The longest object summary, in UTF-16 code units. */
6
+ const OBJECT_SUMMARY_MAX_LENGTH = 280;
7
+ const summary = z.string().trim().min(1).max(280);
5
8
  /** Small, provider-neutral facts. Missing values mean unknown, not success. */
6
9
  const objectFactsSchema = z.discriminatedUnion("type", [
7
10
  z.strictObject({
8
11
  type: z.literal("code_change"),
12
+ summary: summary.optional(),
9
13
  author: text.optional(),
10
14
  sourceBranch: text.optional(),
11
15
  targetBranch: text.optional(),
@@ -32,6 +36,7 @@ const objectFactsSchema = z.discriminatedUnion("type", [
32
36
  }),
33
37
  z.strictObject({
34
38
  type: z.literal("task"),
39
+ summary: summary.optional(),
35
40
  assignees: z.array(text).max(5).optional(),
36
41
  priority: text.optional(),
37
42
  project: text.optional(),
@@ -41,6 +46,7 @@ const objectFactsSchema = z.discriminatedUnion("type", [
41
46
  }),
42
47
  z.strictObject({
43
48
  type: z.literal("deployment"),
49
+ summary: summary.optional(),
44
50
  project: text.optional(),
45
51
  environment: text.optional(),
46
52
  revision: text.optional(),
@@ -48,28 +54,65 @@ const objectFactsSchema = z.discriminatedUnion("type", [
48
54
  }),
49
55
  z.strictObject({
50
56
  type: z.literal("calendar_event"),
57
+ summary: summary.optional(),
51
58
  when: text.optional(),
52
59
  attendees: z.array(text).max(5).optional()
53
60
  }),
54
61
  z.strictObject({
55
62
  type: z.literal("conversation"),
63
+ summary: summary.optional(),
56
64
  participants: z.array(text).max(5).optional(),
57
65
  lastActivityAt: z.iso.datetime({ offset: true }).optional()
58
66
  }),
67
+ z.strictObject({
68
+ type: z.literal("document"),
69
+ summary: summary.optional(),
70
+ owner: text.optional(),
71
+ modifiedAt: z.iso.datetime({ offset: true }).optional()
72
+ }),
59
73
  z.strictObject({
60
74
  type: z.literal("message"),
75
+ summary: summary.optional(),
61
76
  channel: text.optional(),
62
77
  author: text.optional(),
63
78
  sentAt: z.iso.datetime({ offset: true }).optional()
64
79
  }),
80
+ z.strictObject({
81
+ type: z.literal("web_page"),
82
+ summary: summary.optional(),
83
+ siteName: text.optional(),
84
+ author: text.optional(),
85
+ thumbnailUrl: z.string().max(4e3).regex(/^\/api\/images\/[\w-]+\.[\w-]+\?w=\d+$/).optional()
86
+ }),
65
87
  z.strictObject({
66
88
  type: z.literal("person"),
89
+ summary: summary.optional(),
67
90
  email: text.optional(),
68
91
  slackHandle: text.optional(),
69
92
  githubHandle: z.string().regex(/^[A-Za-z0-9][A-Za-z0-9_-]{0,99}$/).optional(),
70
93
  avatarUrl: z.string().max(500).regex(/^\/api\/people\/avatars\/[^/?#]+(\?v=[\w-]+)?$/).optional()
71
94
  })
72
95
  ]);
96
+ /**
97
+ * Make an object summary from plain text. Join whitespace and cut overlong
98
+ * text at a word, with an ellipsis. Empty text gives no summary.
99
+ */
100
+ function objectSummary(text) {
101
+ const words = text.split(/\s+/).filter(Boolean);
102
+ const joined = words.join(" ");
103
+ if (joined.length <= 280) return joined || void 0;
104
+ let cut = "";
105
+ for (const word of words) {
106
+ const next = cut ? `${cut} ${word}` : word;
107
+ if (next.length >= 280) break;
108
+ cut = next;
109
+ }
110
+ if (!cut) {
111
+ cut = joined.slice(0, 279);
112
+ if (/[\ud800-\udbff]$/.test(cut)) cut = cut.slice(0, -1);
113
+ }
114
+ return `${cut}…`;
115
+ }
73
116
  /** Show at most four card attributes, in priority order, on every surface. */
74
117
  function objectFactFields(facts) {
75
118
  if (!facts) return [];
@@ -112,6 +155,13 @@ function objectFactFields(facts) {
112
155
  timeStyle: "short"
113
156
  }));
114
157
  break;
158
+ case "document":
159
+ add("owner", "Owner", facts.owner);
160
+ add("modifiedAt", "Modified", facts.modifiedAt && new Date(facts.modifiedAt).toLocaleString(void 0, {
161
+ dateStyle: "medium",
162
+ timeStyle: "short"
163
+ }));
164
+ break;
115
165
  case "message":
116
166
  add("channel", "Channel", facts.channel);
117
167
  add("author", "Author", facts.author);
@@ -120,6 +170,10 @@ function objectFactFields(facts) {
120
170
  timeStyle: "short"
121
171
  }));
122
172
  break;
173
+ case "web_page":
174
+ add("siteName", "Site", facts.siteName);
175
+ add("author", "Author", facts.author);
176
+ break;
123
177
  case "person":
124
178
  add("email", "Email", facts.email);
125
179
  add("slackHandle", "Slack", facts.slackHandle && `@${facts.slackHandle}`);
@@ -137,7 +191,9 @@ const objectTypeSchema = z.enum([
137
191
  "calendar_event",
138
192
  "conversation",
139
193
  "person",
194
+ "document",
140
195
  "message",
196
+ "web_page",
141
197
  "item"
142
198
  ]);
143
199
  const objectTypeLabels = {
@@ -148,7 +204,9 @@ const objectTypeLabels = {
148
204
  calendar_event: "Calendar event",
149
205
  conversation: "Conversation",
150
206
  person: "Person",
207
+ document: "Document",
151
208
  message: "Message",
209
+ web_page: "Web page",
152
210
  item: "Item"
153
211
  };
154
212
  /** Resolve identity and state without replacing the type icon with a warning. */
@@ -163,7 +221,9 @@ function objectPresentation(object) {
163
221
  calendar_event: "calendar",
164
222
  conversation: "comment-discussion",
165
223
  person: "person",
224
+ document: "file",
166
225
  message: "comment",
226
+ web_page: "globe",
167
227
  item: "package"
168
228
  }[type];
169
229
  let tone = type === "automation" ? "info" : "neutral";
@@ -270,7 +330,9 @@ const objectIconPaths = {
270
330
  calendar: ["M4.75 0a.75.75 0 0 1 .75.75V2h5V.75a.75.75 0 0 1 1.5 0V2h1.25c.966 0 1.75.784 1.75 1.75v10.5A1.75 1.75 0 0 1 13.25 16H2.75A1.75 1.75 0 0 1 1 14.25V3.75C1 2.784 1.784 2 2.75 2H4V.75A.75.75 0 0 1 4.75 0ZM2.5 7.5v6.75c0 .138.112.25.25.25h10.5a.25.25 0 0 0 .25-.25V7.5Zm10.75-4H2.75a.25.25 0 0 0-.25.25V6h11V3.75a.25.25 0 0 0-.25-.25Z"],
271
331
  "comment-discussion": ["M1.75 1h8.5c.966 0 1.75.784 1.75 1.75v5.5A1.75 1.75 0 0 1 10.25 10H7.061l-2.574 2.573A1.458 1.458 0 0 1 2 11.543V10h-.25A1.75 1.75 0 0 1 0 8.25v-5.5C0 1.784.784 1 1.75 1ZM1.5 2.75v5.5c0 .138.112.25.25.25h1a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h3.5a.25.25 0 0 0 .25-.25v-5.5a.25.25 0 0 0-.25-.25h-8.5a.25.25 0 0 0-.25.25Zm13 2a.25.25 0 0 0-.25-.25h-.5a.75.75 0 0 1 0-1.5h.5c.966 0 1.75.784 1.75 1.75v5.5A1.75 1.75 0 0 1 14.25 12H14v1.543a1.458 1.458 0 0 1-2.487 1.03L9.22 12.28a.749.749 0 0 1 .326-1.275.749.749 0 0 1 .734.215l2.22 2.22v-2.19a.75.75 0 0 1 .75-.75h1a.25.25 0 0 0 .25-.25Z"],
272
332
  person: ["M10.561 8.073a6.005 6.005 0 0 1 3.432 5.142.75.75 0 1 1-1.498.07 4.5 4.5 0 0 0-8.99 0 .75.75 0 0 1-1.498-.07 6.004 6.004 0 0 1 3.431-5.142 3.999 3.999 0 1 1 5.123 0ZM10.5 5a2.5 2.5 0 1 0-5 0 2.5 2.5 0 0 0 5 0Z"],
333
+ file: ["M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"],
273
334
  comment: ["M1 2.75C1 1.784 1.784 1 2.75 1h10.5c.966 0 1.75.784 1.75 1.75v7.5A1.75 1.75 0 0 1 13.25 12H9.06l-2.573 2.573A1.458 1.458 0 0 1 4 13.543V12H2.75A1.75 1.75 0 0 1 1 10.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h4.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"],
335
+ globe: ["M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM5.78 8.75a9.64 9.64 0 0 0 1.363 4.177c.255.426.542.832.857 1.215.245-.296.551-.705.857-1.215A9.64 9.64 0 0 0 10.22 8.75Zm4.44-1.5a9.64 9.64 0 0 0-1.363-4.177c-.307-.51-.612-.919-.857-1.215a9.927 9.927 0 0 0-.857 1.215A9.64 9.64 0 0 0 5.78 7.25Zm-5.944 1.5H1.543a6.507 6.507 0 0 0 4.666 5.5c-.123-.181-.24-.365-.352-.552-.715-1.192-1.437-2.874-1.581-4.948Zm-2.733-1.5h2.733c.144-2.074.866-3.756 1.58-4.948.12-.197.237-.381.353-.552a6.507 6.507 0 0 0-4.666 5.5Zm10.181 1.5c-.144 2.074-.866 3.756-1.58 4.948-.12.197-.237.381-.353.552a6.507 6.507 0 0 0 4.666-5.5Zm2.733-1.5a6.507 6.507 0 0 0-4.666-5.5c.123.181.24.365.353.552.714 1.192 1.436 2.874 1.58 4.948Z"],
274
336
  package: ["m8.878.392 5.25 3.045c.54.314.872.89.872 1.514v6.098a1.75 1.75 0 0 1-.872 1.514l-5.25 3.045a1.75 1.75 0 0 1-1.756 0l-5.25-3.045A1.75 1.75 0 0 1 1 11.049V4.951c0-.624.332-1.201.872-1.514L7.122.392a1.75 1.75 0 0 1 1.756 0ZM7.875 1.69l-4.63 2.685L8 7.133l4.755-2.758-4.63-2.685a.248.248 0 0 0-.25 0ZM2.5 5.677v5.372c0 .09.047.171.125.216l4.625 2.683V8.432Zm6.25 8.271 4.625-2.683a.25.25 0 0 0 .125-.216V5.677L8.75 8.432Z"]
275
337
  };
276
338
  // src/object-links.ts
@@ -1912,6 +1974,7 @@ function defineJuniorPlugin(plugin) {
1912
1974
  if (!parsed.success) throw new Error(`Junior plugin "${name}" events is invalid.`, { cause: parsed.error });
1913
1975
  }
1914
1976
  validateObjectLinks(name, plugin.objectLinks);
1977
+ if (plugin.images !== void 0 && typeof plugin.images.resolve !== "function") throw new Error(`Junior plugin "${name}" images must have a resolve function.`);
1915
1978
  const conversationEventIds = /* @__PURE__ */ new Set();
1916
1979
  for (const event of plugin.conversationEvents ?? []) {
1917
1980
  if (!event || typeof event !== "object" && typeof event !== "function" || typeof event.parse !== "function" || typeof event.renderEvent !== "function") throw new Error(`Junior plugin "${name}" conversation event definitions must be created with defineConversationEvent().`);
@@ -2021,4 +2084,4 @@ const pluginUserPageInputSchema = z.object({
2021
2084
  limit: z.number().int().min(1).max(50),
2022
2085
  query: pluginUserPageQuerySchema
2023
2086
  }).strict();
2024
- 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, PluginToolInputError, REQUIRED_TOOL_ANNOTATION_KEYS, actorSchema, actorUserIdSchema, agentEventKeys, agentEventMatchKey, agentEventMatchSchema, agentInvocationSourceSchema, anyResourceEvents, anyResourceMatchFields, codeChangeInputSchema, codeChangeStateSchema, conversationAnnotationInputSchema, conversationEventIconSchema, conversationEventPresentationSchema, conversationSidebarAnnotationSchema, conversationSidebarIconSchema, createEventSource, createLocalSource, createSlackSource, createWebSource, declaredEventKeys, defineConversationEvent, defineJuniorPlugin, definePluginTool, definePromptContext, describeEventTrigger, destinationSchema, destinationVisibilitySchema, dispatchOptionsSchema, enforceEgressPolicy, eventAutomationSourceSchema, eventDataSchema, eventIdentifierSchema, eventInputSchema, eventMatchFieldSchema, eventMatchFieldsSchema, eventMatchFilterText, eventMatchSchema, eventMatches, eventPersonSchema, eventReachSchema, eventSchema, eventSourceSchema, eventTriggerChoices, eventTriggerFiltersText, eventTriggerProblems, eventTriggerText, eventTypeSchema, eventTypeText, eventsWithoutMatchField, getSourceKey, identitySchema, isPluginModelCostEventName, isPrivateSource, isSlackDestination, localActorSchema, localDestinationSchema, localSourceSchema, locationSchema, mergeEventMatchFields, missingToolAnnotationKeys, nonBlankStringSchema, normalizeEventIdentifier, normalizeEventMatch, objectAnnotationSchema, objectFactFields, objectFactsBytes, objectFactsMatchType, objectFactsSchema, objectIconPath, objectIconPaths, objectLinkFilterMatches, objectLinkFilterSchema, objectLinkFilterSpecificity, objectPresentation, objectTypeSchema, ownedObjectAnnotationSchema, 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, replyAttributionSchema, resourceLinkAnnotationSchema, resourceTypeSchema, scheduledAutomationSourceSchema, slackActorSchema, slackDestinationSchema, slackLocationSchema, slackSourceSchema, sourceSchema, sourceVisibilitySchema, stableEventMatchKey, subscribableResourceSchema, systemActorSchema, taskOutcomeSchema, toolApprovalModeSchema, userSchema, watchResultSchema, webActorSchema, webSourceSchema, zodTool };
2087
+ 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, agentInvocationSourceSchema, anyResourceEvents, anyResourceMatchFields, codeChangeInputSchema, codeChangeStateSchema, conversationAnnotationInputSchema, conversationEventIconSchema, conversationEventPresentationSchema, conversationSidebarAnnotationSchema, conversationSidebarIconSchema, createEventSource, createLocalSource, createSlackSource, createWebSource, declaredEventKeys, defineConversationEvent, defineJuniorPlugin, definePluginTool, definePromptContext, describeEventTrigger, destinationSchema, destinationVisibilitySchema, dispatchOptionsSchema, enforceEgressPolicy, eventAutomationSourceSchema, eventDataSchema, eventIdentifierSchema, eventInputSchema, eventMatchFieldSchema, eventMatchFieldsSchema, eventMatchFilterText, eventMatchSchema, eventMatches, eventPersonSchema, eventReachSchema, eventSchema, eventSourceSchema, eventTriggerChoices, eventTriggerFiltersText, eventTriggerProblems, eventTriggerText, eventTypeSchema, eventTypeText, eventsWithoutMatchField, getSourceKey, identitySchema, isPluginModelCostEventName, isPrivateSource, isSlackDestination, localActorSchema, localDestinationSchema, localSourceSchema, locationSchema, mergeEventMatchFields, missingToolAnnotationKeys, nonBlankStringSchema, normalizeEventIdentifier, normalizeEventMatch, objectAnnotationSchema, objectFactFields, objectFactsBytes, objectFactsMatchType, objectFactsSchema, objectIconPath, objectIconPaths, objectLinkFilterMatches, objectLinkFilterSchema, objectLinkFilterSpecificity, objectPresentation, objectSummary, objectTypeSchema, ownedObjectAnnotationSchema, 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, replyAttributionSchema, resourceLinkAnnotationSchema, resourceTypeSchema, scheduledAutomationSourceSchema, slackActorSchema, slackDestinationSchema, slackLocationSchema, slackSourceSchema, sourceSchema, sourceVisibilitySchema, stableEventMatchKey, subscribableResourceSchema, systemActorSchema, taskOutcomeSchema, toolApprovalModeSchema, userSchema, watchResultSchema, webActorSchema, webSourceSchema, zodTool };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/junior-plugin-api",
3
- "version": "0.299.0",
3
+ "version": "0.300.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -23,7 +23,7 @@
23
23
  ],
24
24
  "dependencies": {
25
25
  "commander": "^14.0.3",
26
- "zod": "^4.5.4"
26
+ "zod": "^4.6.7"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@oxlint/plugins": "1.79.0",