@sentry/junior-plugin-api 0.278.0 → 0.279.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1004,7 +1004,26 @@ export interface PluginConversationEventReader {
1004
1004
  viewer: User;
1005
1005
  }): Promise<PluginConversationEventRecord[] | undefined>;
1006
1006
  }
1007
- /** Read aggregate costs for events owned by the current plugin namespace. */
1007
+ /**
1008
+ * Events that Junior writes in a plugin's namespace for the cost of each
1009
+ * priced `model`, `decider`, `embedder`, or `reranker` call in a
1010
+ * Conversation, by the context that made the call. Junior counts them in
1011
+ * Conversation cost, so plugin events must not repeat that cost. A plugin
1012
+ * cannot register these names. It can read their costs through
1013
+ * `PluginConversationEventStats`.
1014
+ */
1015
+ export declare const pluginModelCostEventNames: {
1016
+ readonly afterToolExecute: "after_tool_execute_model_called";
1017
+ readonly task: "task_model_called";
1018
+ readonly tool: "tool_model_called";
1019
+ readonly userPrompt: "user_prompt_model_called";
1020
+ };
1021
+ /** Whether an event name is one of `pluginModelCostEventNames`. */
1022
+ export declare function isPluginModelCostEventName(eventName: string): boolean;
1023
+ /**
1024
+ * Read aggregate costs for events owned by the current plugin namespace:
1025
+ * registered events and `pluginModelCostEventNames`.
1026
+ */
1008
1027
  export interface PluginConversationEventStats {
1009
1028
  costsByDay(input: {
1010
1029
  days: 7 | 30 | 90;
package/dist/index.js CHANGED
@@ -316,6 +316,24 @@ function defineConversationEvent(definition) {
316
316
  });
317
317
  return eventDefinition;
318
318
  }
319
+ /**
320
+ * Events that Junior writes in a plugin's namespace for the cost of each
321
+ * priced `model`, `decider`, `embedder`, or `reranker` call in a
322
+ * Conversation, by the context that made the call. Junior counts them in
323
+ * Conversation cost, so plugin events must not repeat that cost. A plugin
324
+ * cannot register these names. It can read their costs through
325
+ * `PluginConversationEventStats`.
326
+ */
327
+ const pluginModelCostEventNames = {
328
+ afterToolExecute: "after_tool_execute_model_called",
329
+ task: "task_model_called",
330
+ tool: "tool_model_called",
331
+ userPrompt: "user_prompt_model_called"
332
+ };
333
+ /** Whether an event name is one of `pluginModelCostEventNames`. */
334
+ function isPluginModelCostEventName(eventName) {
335
+ return Object.values(pluginModelCostEventNames).includes(eventName);
336
+ }
319
337
  // src/schemas.ts
320
338
  const slackTeamIdSchema = z.string().regex(/^T[A-Z0-9]+$/);
321
339
  const slackConversationIdSchema = z.string().regex(/^(C|G|D)[A-Z0-9]+$/);
@@ -1693,6 +1711,7 @@ function defineJuniorPlugin(plugin) {
1693
1711
  const conversationEventIds = /* @__PURE__ */ new Set();
1694
1712
  for (const event of plugin.conversationEvents ?? []) {
1695
1713
  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().`);
1714
+ if (isPluginModelCostEventName(event.eventName)) throw new Error(`Junior plugin "${name}" cannot register host-owned conversation event "${event.eventName}".`);
1696
1715
  const id = `${event.eventName}@${event.version}`;
1697
1716
  if (conversationEventIds.has(id)) throw new Error(`Junior plugin "${name}" has duplicate conversation event "${id}".`);
1698
1717
  conversationEventIds.add(id);
@@ -1787,4 +1806,4 @@ const pluginUserPageInputSchema = z.object({
1787
1806
  limit: z.number().int().min(1).max(50),
1788
1807
  query: pluginUserPageQuerySchema
1789
1808
  }).strict();
1790
- export { EVENT_DATA_MAX_JSON_BYTES, EVENT_DATA_MAX_KEYS, EVENT_GUIDANCE_MAX_LENGTH, EVENT_SUMMARY_MAX_LENGTH, EVENT_TEXT_MAX_LENGTH, EgressAuthRequired, EgressPolicyDenied, 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, isPrivateSource, isSlackDestination, localActorSchema, localDestinationSchema, localSourceSchema, locationSchema, mergeEventMatchFields, missingToolAnnotationKeys, nonBlankStringSchema, normalizeEventIdentifier, normalizeEventMatch, objectAnnotationSchema, objectFactFields, objectFactsSchema, objectIconPath, objectIconPaths, objectPresentation, objectTypeSchema, ownedObjectAnnotationSchema, parseShellCommands, platformSchema, pluginApiRouteRequestContextSchema, pluginAuthorizationSchema, pluginCredentialHeaderTransformSchema, pluginCredentialLeaseSchema, pluginCredentialResultSchema, pluginCredentialSubjectSchema, pluginDispatchSourceSchema, pluginEventDeclarationSchema, pluginEventTypeSchema, pluginEventsSchema, pluginGrantSchema, pluginProviderAccountSchema, pluginRunContextSchema, pluginRunTranscriptEntrySchema, pluginRunTranscriptProvenanceSchema, pluginStoredTokensSchema, pluginToolContentSchema, pluginToolContinuationSchema, pluginToolOutputSchema, 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 };
1809
+ export { EVENT_DATA_MAX_JSON_BYTES, EVENT_DATA_MAX_KEYS, EVENT_GUIDANCE_MAX_LENGTH, EVENT_SUMMARY_MAX_LENGTH, EVENT_TEXT_MAX_LENGTH, EgressAuthRequired, EgressPolicyDenied, 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, objectFactsSchema, objectIconPath, objectIconPaths, objectPresentation, objectTypeSchema, ownedObjectAnnotationSchema, parseShellCommands, platformSchema, pluginApiRouteRequestContextSchema, pluginAuthorizationSchema, pluginCredentialHeaderTransformSchema, pluginCredentialLeaseSchema, pluginCredentialResultSchema, pluginCredentialSubjectSchema, pluginDispatchSourceSchema, pluginEventDeclarationSchema, pluginEventTypeSchema, pluginEventsSchema, pluginGrantSchema, pluginModelCostEventNames, pluginProviderAccountSchema, pluginRunContextSchema, pluginRunTranscriptEntrySchema, pluginRunTranscriptProvenanceSchema, pluginStoredTokensSchema, pluginToolContentSchema, pluginToolContinuationSchema, pluginToolOutputSchema, 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.278.0",
3
+ "version": "0.279.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"