@sentry/junior-plugin-api 0.278.0 → 0.280.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
@@ -1,4 +1,5 @@
1
- import { ZodTypeAny, z } from "zod";
1
+ import * as z from "zod";
2
+ import { ZodTypeAny } from "zod";
2
3
  import { Command } from "commander";
3
4
  /**
4
5
  * Verified facts shared by Conversation annotations and Message cards.
@@ -992,6 +993,8 @@ export interface PluginConversationEventCostDay {
992
993
  export interface PluginConversationEventRecord {
993
994
  content: Record<string, unknown>;
994
995
  createdAt: string;
996
+ /** Position in the Conversation's events. The transcript opens there. */
997
+ seq: number;
995
998
  /** Turn that emitted the event. Events from outside a Turn have none. */
996
999
  turnId?: string;
997
1000
  version: number;
@@ -1004,7 +1007,26 @@ export interface PluginConversationEventReader {
1004
1007
  viewer: User;
1005
1008
  }): Promise<PluginConversationEventRecord[] | undefined>;
1006
1009
  }
1007
- /** Read aggregate costs for events owned by the current plugin namespace. */
1010
+ /**
1011
+ * Events that Junior writes in a plugin's namespace for the cost of each
1012
+ * priced `model`, `decider`, `embedder`, or `reranker` call in a
1013
+ * Conversation, by the context that made the call. Junior counts them in
1014
+ * Conversation cost, so plugin events must not repeat that cost. A plugin
1015
+ * cannot register these names. It can read their costs through
1016
+ * `PluginConversationEventStats`.
1017
+ */
1018
+ export declare const pluginModelCostEventNames: {
1019
+ readonly afterToolExecute: "after_tool_execute_model_called";
1020
+ readonly task: "task_model_called";
1021
+ readonly tool: "tool_model_called";
1022
+ readonly userPrompt: "user_prompt_model_called";
1023
+ };
1024
+ /** Whether an event name is one of `pluginModelCostEventNames`. */
1025
+ export declare function isPluginModelCostEventName(eventName: string): boolean;
1026
+ /**
1027
+ * Read aggregate costs for events owned by the current plugin namespace:
1028
+ * registered events and `pluginModelCostEventNames`.
1029
+ */
1008
1030
  export interface PluginConversationEventStats {
1009
1031
  costsByDay(input: {
1010
1032
  days: 7 | 30 | 90;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { z } from "zod";
1
+ 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();
@@ -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.280.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"