@sentry/junior-plugin-api 0.318.0 → 0.319.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 +412 -273
  2. package/dist/index.js +122 -40
  3. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -269,20 +269,37 @@ export declare const OBJECT_FACTS_MAX_BYTES = 4096;
269
269
  /** Return the size that the object facts limit counts. */
270
270
  export declare function objectFactsBytes(facts: ObjectFacts): number;
271
271
  /**
272
- * Verified facts shared by Conversation annotations and Message cards.
273
- * Plugins select small facts from responses they already have. Each surface owns
274
- * its layout. Omit unknown facts; do not infer approval or passing checks.
275
- *
276
- * These facts support both compact previews and full details. Each surface
277
- * selects the fields it needs; preview rules must not remove saved facts.
278
- *
279
- * Keep raw responses, diffs, logs, credentials, and comments out of this schema.
280
- * Return only facts that the Conversation audience may see. An annotation
281
- * never grants provider access.
272
+ * The object that an Annotation points to: one of the plugin's registered
273
+ * subject kinds (`inboxSubjects`), such as `issue`, and the provider's id
274
+ * of the object, such as GitHub's id of the issue. Unlike `key`, the id
275
+ * stays the same when the object moves or its repository is renamed. An
276
+ * Inbox item with the same subject is about the same object.
277
+ */
278
+ export declare const objectSubjectSchema: z.ZodObject<{
279
+ kind: z.ZodString;
280
+ id: z.ZodString;
281
+ }, z.core.$strict>;
282
+ export type ObjectSubject = z.output<typeof objectSubjectSchema>;
283
+ /** What a Conversation did to the object of an Annotation. */
284
+ export declare const annotationActionSchema: z.ZodEnum<{
285
+ changed: "changed";
286
+ created: "created";
287
+ }>;
288
+ export type AnnotationAction = z.output<typeof annotationActionSchema>;
289
+ /**
290
+ * The card of an object: verified facts that a link type reads for one
291
+ * viewer, shown on Annotations and Message cards. No Annotation saves it.
292
+ * Omit unknown facts; do not infer approval or passing checks. Leave out
293
+ * raw responses, diffs, logs, credentials, and comments. Return only facts
294
+ * that the audience may see; a card grants no provider access.
282
295
  */
283
296
  export declare const objectAnnotationSchema: z.ZodObject<{
284
297
  kind: z.ZodLiteral<"object">;
285
298
  key: z.ZodString;
299
+ subject: z.ZodOptional<z.ZodObject<{
300
+ kind: z.ZodString;
301
+ id: z.ZodString;
302
+ }, z.core.$strict>>;
286
303
  label: z.ZodString;
287
304
  objectType: z.ZodEnum<{
288
305
  alert: "alert";
@@ -507,10 +524,14 @@ export declare const objectAnnotationSchema: z.ZodObject<{
507
524
  }, z.core.$strict>], "type">>;
508
525
  }, z.core.$strict>;
509
526
  export type ObjectAnnotation = z.output<typeof objectAnnotationSchema>;
510
- /** A saved object snapshot with its trusted owner. */
527
+ /** The card of an object with its trusted owner. */
511
528
  export declare const ownedObjectAnnotationSchema: z.ZodObject<{
512
529
  kind: z.ZodLiteral<"object">;
513
530
  key: z.ZodString;
531
+ subject: z.ZodOptional<z.ZodObject<{
532
+ kind: z.ZodString;
533
+ id: z.ZodString;
534
+ }, z.core.$strict>>;
514
535
  label: z.ZodString;
515
536
  objectType: z.ZodEnum<{
516
537
  alert: "alert";
@@ -733,9 +754,86 @@ export declare const ownedObjectAnnotationSchema: z.ZodObject<{
733
754
  githubHandle: z.ZodOptional<z.ZodString>;
734
755
  avatarUrl: z.ZodOptional<z.ZodString>;
735
756
  }, z.core.$strict>], "type">>;
757
+ fetchedAt: z.ZodOptional<z.ZodISODateTime>;
736
758
  plugin: z.ZodString;
737
759
  }, z.core.$strict>;
738
760
  export type OwnedObjectAnnotation = z.output<typeof ownedObjectAnnotationSchema>;
761
+ /**
762
+ * The object of an Annotation, as Junior stores it: its subject, its type,
763
+ * its title, and its link. Search finds the object by its title and link,
764
+ * and a card shows them when the provider is down. A card reads every other
765
+ * fact of the object live. Set `subject` whenever the provider id is known.
766
+ */
767
+ export declare const savedObjectAnnotationSchema: z.ZodObject<{
768
+ kind: z.ZodLiteral<"object">;
769
+ key: z.ZodString;
770
+ subject: z.ZodOptional<z.ZodObject<{
771
+ kind: z.ZodString;
772
+ id: z.ZodString;
773
+ }, z.core.$strict>>;
774
+ objectType: z.ZodEnum<{
775
+ alert: "alert";
776
+ automation: "automation";
777
+ calendar_event: "calendar_event";
778
+ chart: "chart";
779
+ code_change: "code_change";
780
+ conversation: "conversation";
781
+ dashboard: "dashboard";
782
+ deployment: "deployment";
783
+ document: "document";
784
+ event: "event";
785
+ item: "item";
786
+ message: "message";
787
+ monitor: "monitor";
788
+ person: "person";
789
+ release: "release";
790
+ task: "task";
791
+ trace: "trace";
792
+ web_page: "web_page";
793
+ }>;
794
+ title: z.ZodString;
795
+ url: z.ZodNullable<z.ZodURL>;
796
+ }, z.core.$strict>;
797
+ export type SavedObjectAnnotation = z.output<typeof savedObjectAnnotationSchema>;
798
+ /**
799
+ * One object that a tool or hook created or changed, to save as an
800
+ * Annotation of the Conversation.
801
+ */
802
+ export declare const annotatedObjectSchema: z.ZodObject<{
803
+ kind: z.ZodLiteral<"object">;
804
+ key: z.ZodString;
805
+ subject: z.ZodOptional<z.ZodObject<{
806
+ kind: z.ZodString;
807
+ id: z.ZodString;
808
+ }, z.core.$strict>>;
809
+ objectType: z.ZodEnum<{
810
+ alert: "alert";
811
+ automation: "automation";
812
+ calendar_event: "calendar_event";
813
+ chart: "chart";
814
+ code_change: "code_change";
815
+ conversation: "conversation";
816
+ dashboard: "dashboard";
817
+ deployment: "deployment";
818
+ document: "document";
819
+ event: "event";
820
+ item: "item";
821
+ message: "message";
822
+ monitor: "monitor";
823
+ person: "person";
824
+ release: "release";
825
+ task: "task";
826
+ trace: "trace";
827
+ web_page: "web_page";
828
+ }>;
829
+ title: z.ZodString;
830
+ url: z.ZodNullable<z.ZodURL>;
831
+ action: z.ZodEnum<{
832
+ changed: "changed";
833
+ created: "created";
834
+ }>;
835
+ }, z.core.$strict>;
836
+ export type AnnotatedObject = z.output<typeof annotatedObjectSchema>;
739
837
  /** Original Octicons paths, shared by web and Slack image assets. */
740
838
  export declare const objectIconPaths: {
741
839
  "issue-opened": string[];
@@ -1605,10 +1703,9 @@ export interface IssueCredentialHookContext extends PluginContext {
1605
1703
  tokens: PluginTokenStore;
1606
1704
  }
1607
1705
  /**
1608
- * Link an object to a Conversation when the owner has no typed object preview.
1609
- * Keep a stable key, compact label, source URL, and optional short context or
1610
- * status. Do not fetch a full object merely to save a link. Rich preview intent
1611
- * belongs to objectAnnotationSchema, not a second set of resource-link fields.
1706
+ * Link an object to a Conversation by its link alone, such as a link that a
1707
+ * person attached. Junior stores no title for it: the title would show to
1708
+ * readers who cannot open the object. Its card reads the object live.
1612
1709
  */
1613
1710
  export declare const resourceLinkAnnotationSchema: z.ZodObject<{
1614
1711
  kind: z.ZodLiteral<"resource_link">;
@@ -1633,16 +1730,7 @@ export declare const resourceLinkAnnotationSchema: z.ZodObject<{
1633
1730
  web_page: "web_page";
1634
1731
  }>>;
1635
1732
  key: z.ZodString;
1636
- label: z.ZodString;
1637
1733
  url: z.ZodString;
1638
- description: z.ZodOptional<z.ZodString>;
1639
- status: z.ZodOptional<z.ZodEnum<{
1640
- closed: "closed";
1641
- draft: "draft";
1642
- merged: "merged";
1643
- open: "open";
1644
- warning: "warning";
1645
- }>>;
1646
1734
  }, z.core.$strict>;
1647
1735
  /** Core-known annotation shapes that plugins may attach to a conversation. */
1648
1736
  export declare const conversationAnnotationInputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -1668,19 +1756,80 @@ export declare const conversationAnnotationInputSchema: z.ZodDiscriminatedUnion<
1668
1756
  web_page: "web_page";
1669
1757
  }>>;
1670
1758
  key: z.ZodString;
1671
- label: z.ZodString;
1672
1759
  url: z.ZodString;
1673
- description: z.ZodOptional<z.ZodString>;
1674
- status: z.ZodOptional<z.ZodEnum<{
1675
- closed: "closed";
1676
- draft: "draft";
1677
- merged: "merged";
1678
- open: "open";
1679
- warning: "warning";
1760
+ }, z.core.$strict>, z.ZodObject<{
1761
+ kind: z.ZodLiteral<"object">;
1762
+ key: z.ZodString;
1763
+ subject: z.ZodOptional<z.ZodObject<{
1764
+ kind: z.ZodString;
1765
+ id: z.ZodString;
1766
+ }, z.core.$strict>>;
1767
+ objectType: z.ZodEnum<{
1768
+ alert: "alert";
1769
+ automation: "automation";
1770
+ calendar_event: "calendar_event";
1771
+ chart: "chart";
1772
+ code_change: "code_change";
1773
+ conversation: "conversation";
1774
+ dashboard: "dashboard";
1775
+ deployment: "deployment";
1776
+ document: "document";
1777
+ event: "event";
1778
+ item: "item";
1779
+ message: "message";
1780
+ monitor: "monitor";
1781
+ person: "person";
1782
+ release: "release";
1783
+ task: "task";
1784
+ trace: "trace";
1785
+ web_page: "web_page";
1786
+ }>;
1787
+ title: z.ZodString;
1788
+ url: z.ZodNullable<z.ZodURL>;
1789
+ }, z.core.$strict>], "kind">;
1790
+ export type ConversationAnnotationInput = z.output<typeof conversationAnnotationInputSchema>;
1791
+ export type ConversationAnnotation = ConversationAnnotationInput & {
1792
+ plugin: string;
1793
+ createdAt: string;
1794
+ updatedAt: string;
1795
+ };
1796
+ /**
1797
+ * An Annotation as one viewer sees it: the live card of its object, else
1798
+ * only its label and its link.
1799
+ */
1800
+ export declare const liveAnnotationSchema: z.ZodIntersection<z.ZodDiscriminatedUnion<[z.ZodObject<{
1801
+ kind: z.ZodLiteral<"resource_link">;
1802
+ objectType: z.ZodOptional<z.ZodEnum<{
1803
+ alert: "alert";
1804
+ automation: "automation";
1805
+ calendar_event: "calendar_event";
1806
+ chart: "chart";
1807
+ code_change: "code_change";
1808
+ conversation: "conversation";
1809
+ dashboard: "dashboard";
1810
+ deployment: "deployment";
1811
+ document: "document";
1812
+ event: "event";
1813
+ item: "item";
1814
+ message: "message";
1815
+ monitor: "monitor";
1816
+ person: "person";
1817
+ release: "release";
1818
+ task: "task";
1819
+ trace: "trace";
1820
+ web_page: "web_page";
1680
1821
  }>>;
1822
+ key: z.ZodString;
1823
+ label: z.ZodString;
1824
+ plugin: z.ZodString;
1825
+ url: z.ZodNullable<z.ZodString>;
1681
1826
  }, z.core.$strict>, z.ZodObject<{
1682
1827
  kind: z.ZodLiteral<"object">;
1683
1828
  key: z.ZodString;
1829
+ subject: z.ZodOptional<z.ZodObject<{
1830
+ kind: z.ZodString;
1831
+ id: z.ZodString;
1832
+ }, z.core.$strict>>;
1684
1833
  label: z.ZodString;
1685
1834
  objectType: z.ZodEnum<{
1686
1835
  alert: "alert";
@@ -1903,20 +2052,69 @@ export declare const conversationAnnotationInputSchema: z.ZodDiscriminatedUnion<
1903
2052
  githubHandle: z.ZodOptional<z.ZodString>;
1904
2053
  avatarUrl: z.ZodOptional<z.ZodString>;
1905
2054
  }, z.core.$strict>], "type">>;
1906
- }, z.core.$strict>], "kind">;
1907
- export type ConversationAnnotationInput = z.output<typeof conversationAnnotationInputSchema>;
1908
- export type ConversationAnnotation = ConversationAnnotationInput & {
1909
- plugin: string;
1910
- createdAt: string;
1911
- updatedAt: string;
1912
- };
2055
+ fetchedAt: z.ZodOptional<z.ZodISODateTime>;
2056
+ plugin: z.ZodString;
2057
+ }, z.core.$strict>], "kind">, z.ZodObject<{
2058
+ createdAt: z.ZodString;
2059
+ updatedAt: z.ZodString;
2060
+ }, z.core.$strip>>;
2061
+ export type LiveAnnotation = z.output<typeof liveAnnotationSchema>;
1913
2062
  export interface PluginAnnotations {
1914
2063
  upsert(annotation: ConversationAnnotationInput): Promise<void>;
1915
2064
  remove(kind: ConversationAnnotationInput["kind"], key: string): Promise<void>;
1916
2065
  list(): Promise<ConversationAnnotation[]>;
1917
2066
  }
2067
+ /**
2068
+ * The Annotations of one plugin that share a key. `url` is the link of one
2069
+ * of them, if it has one.
2070
+ */
2071
+ export interface ListedAnnotation {
2072
+ key: string;
2073
+ url: string | null;
2074
+ }
2075
+ /** The start of the keys and the links of a plugin's moved objects. */
2076
+ export interface AnnotationPrefix {
2077
+ key: string;
2078
+ url: string;
2079
+ }
1918
2080
  export interface PluginConversationAnnotations {
1919
2081
  forConversation(conversationId: string): PluginAnnotations;
2082
+ /**
2083
+ * List the keys of this plugin's Annotations in key order after `after`,
2084
+ * at most `limit`. With `named`, list the keys whose Annotations name a
2085
+ * provider id of their object. Else list the keys whose Annotations name
2086
+ * none; once `nameObject` names the object of a key, it is not listed.
2087
+ */
2088
+ listObjects(input: {
2089
+ after?: string | undefined;
2090
+ limit: number;
2091
+ named: boolean;
2092
+ }): Promise<ListedAnnotation[]>;
2093
+ /**
2094
+ * Save the subject and the current link of the object of each Annotation
2095
+ * of this plugin with this key that names no provider id.
2096
+ */
2097
+ nameObject(key: string, object: {
2098
+ subject: ObjectSubject;
2099
+ url: string;
2100
+ }): Promise<void>;
2101
+ /**
2102
+ * Tell Junior that the provider moved objects of this plugin, such as by
2103
+ * a repository rename. A key that starts with `from.key` and a link that
2104
+ * starts with `from.url` (without case) get the `to` prefix. An Annotation
2105
+ * keeps its key when its Conversation already has one with the new key.
2106
+ */
2107
+ objectsMoved(move: {
2108
+ from: AnnotationPrefix;
2109
+ to: AnnotationPrefix;
2110
+ }): Promise<void>;
2111
+ /**
2112
+ * Tell Junior that the provider changed one object, such as a merge.
2113
+ * Junior marks each Conversation that annotates the object as changed, so
2114
+ * an open page reads its live card again. It writes no Annotation. Call
2115
+ * it only when the object changed, not for each event about it.
2116
+ */
2117
+ objectChanged(subject: ObjectSubject): Promise<void>;
1920
2118
  }
1921
2119
  export declare const conversationSidebarIconSchema: z.ZodEnum<{
1922
2120
  "circle-dashed": "circle-dashed";
@@ -1971,8 +2169,11 @@ export declare const conversationSidebarAnnotationSchema: z.ZodObject<{
1971
2169
  }, z.core.$strict>;
1972
2170
  export type ConversationSidebarAnnotation = z.output<typeof conversationSidebarAnnotationSchema>;
1973
2171
  export interface ConversationSidebarHookContext extends PluginContext {
1974
- /** Stored annotations owned by this plugin, keyed by candidate conversation. */
1975
- annotationsByConversationId: Record<string, ConversationAnnotation[]>;
2172
+ /**
2173
+ * The annotations of this plugin as the viewer sees them, keyed by
2174
+ * candidate conversation.
2175
+ */
2176
+ annotationsByConversationId: Record<string, LiveAnnotation[]>;
1976
2177
  conversationIds: string[];
1977
2178
  }
1978
2179
  export interface ConversationSidebarResult {
@@ -2625,7 +2826,7 @@ export type PluginViewerMcpToolResult = PluginMcpToolError | PluginMcpToolSucces
2625
2826
  */
2626
2827
  export interface PluginViewerMcp {
2627
2828
  /**
2628
- * Call one tool of this plugin's `allowedTools` that the provider marks
2829
+ * Call one tool of this plugin's `viewerTools` that the provider marks
2629
2830
  * read-only, with only the viewer's own stored login. It never asks the
2630
2831
  * viewer to sign in: a viewer without a usable login gets
2631
2832
  * `not_connected`. Provider rejections return an error result. Transport
@@ -2759,7 +2960,10 @@ export declare const pluginToolOutputSchema: z.ZodObject<{
2759
2960
  objectAnnotations: z.ZodOptional<z.ZodArray<z.ZodObject<{
2760
2961
  kind: z.ZodLiteral<"object">;
2761
2962
  key: z.ZodString;
2762
- label: z.ZodString;
2963
+ subject: z.ZodOptional<z.ZodObject<{
2964
+ kind: z.ZodString;
2965
+ id: z.ZodString;
2966
+ }, z.core.$strict>>;
2763
2967
  objectType: z.ZodEnum<{
2764
2968
  alert: "alert";
2765
2969
  automation: "automation";
@@ -2782,205 +2986,10 @@ export declare const pluginToolOutputSchema: z.ZodObject<{
2782
2986
  }>;
2783
2987
  title: z.ZodString;
2784
2988
  url: z.ZodNullable<z.ZodURL>;
2785
- description: z.ZodOptional<z.ZodString>;
2786
- status: z.ZodOptional<z.ZodString>;
2787
- trigger: z.ZodOptional<z.ZodString>;
2788
- warning: z.ZodOptional<z.ZodString>;
2789
- displayType: z.ZodOptional<z.ZodString>;
2790
- sourceUpdatedAt: z.ZodOptional<z.ZodISODateTime>;
2791
- facts: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
2792
- type: z.ZodLiteral<"code_change">;
2793
- summary: z.ZodOptional<z.ZodString>;
2794
- author: z.ZodOptional<z.ZodString>;
2795
- sourceBranch: z.ZodOptional<z.ZodString>;
2796
- targetBranch: z.ZodOptional<z.ZodString>;
2797
- reviewers: z.ZodOptional<z.ZodArray<z.ZodString>>;
2798
- review: z.ZodOptional<z.ZodEnum<{
2799
- approved: "approved";
2800
- changes_requested: "changes_requested";
2801
- required: "required";
2802
- }>>;
2803
- checks: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
2804
- passed: z.ZodNumber;
2805
- failed: z.ZodNumber;
2806
- pending: z.ZodNumber;
2807
- }, z.core.$strict>, z.ZodLiteral<"pending">]>>;
2808
- mergeable: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"pending">]>>;
2809
- titleParts: z.ZodOptional<z.ZodObject<{
2810
- breaking: z.ZodOptional<z.ZodBoolean>;
2811
- scope: z.ZodOptional<z.ZodString>;
2812
- text: z.ZodString;
2813
- type: z.ZodOptional<z.ZodString>;
2814
- }, z.core.$strict>>;
2815
- changedFiles: z.ZodOptional<z.ZodNumber>;
2816
- additions: z.ZodOptional<z.ZodNumber>;
2817
- deletions: z.ZodOptional<z.ZodNumber>;
2818
- previewImageUrls: z.ZodOptional<z.ZodArray<z.ZodURL>>;
2819
- }, z.core.$strict>, z.ZodObject<{
2820
- type: z.ZodLiteral<"task">;
2821
- summary: z.ZodOptional<z.ZodString>;
2822
- assignees: z.ZodOptional<z.ZodArray<z.ZodString>>;
2823
- priority: z.ZodOptional<z.ZodString>;
2824
- project: z.ZodOptional<z.ZodString>;
2825
- cycle: z.ZodOptional<z.ZodString>;
2826
- dueDate: z.ZodOptional<z.ZodISODate>;
2827
- labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
2828
- trend: z.ZodOptional<z.ZodObject<{
2829
- label: z.ZodString;
2830
- points: z.ZodArray<z.ZodNumber>;
2831
- }, z.core.$strict>>;
2832
- }, z.core.$strict>, z.ZodObject<{
2833
- type: z.ZodLiteral<"deployment">;
2834
- summary: z.ZodOptional<z.ZodString>;
2835
- project: z.ZodOptional<z.ZodString>;
2836
- environment: z.ZodOptional<z.ZodString>;
2837
- revision: z.ZodOptional<z.ZodString>;
2838
- branch: z.ZodOptional<z.ZodString>;
2839
- }, z.core.$strict>, z.ZodObject<{
2840
- type: z.ZodLiteral<"calendar_event">;
2841
- summary: z.ZodOptional<z.ZodString>;
2842
- when: z.ZodOptional<z.ZodString>;
2843
- attendees: z.ZodOptional<z.ZodArray<z.ZodString>>;
2844
- }, z.core.$strict>, z.ZodObject<{
2845
- type: z.ZodLiteral<"conversation">;
2846
- summary: z.ZodOptional<z.ZodString>;
2847
- participants: z.ZodOptional<z.ZodArray<z.ZodString>>;
2848
- lastActivityAt: z.ZodOptional<z.ZodISODateTime>;
2849
- }, z.core.$strict>, z.ZodObject<{
2850
- type: z.ZodLiteral<"document">;
2851
- summary: z.ZodOptional<z.ZodString>;
2852
- owner: z.ZodOptional<z.ZodString>;
2853
- modifiedAt: z.ZodOptional<z.ZodISODateTime>;
2854
- thumbnailUrl: z.ZodOptional<z.ZodString>;
2855
- }, z.core.$strict>, z.ZodObject<{
2856
- type: z.ZodLiteral<"message">;
2857
- summary: z.ZodOptional<z.ZodString>;
2858
- channel: z.ZodOptional<z.ZodString>;
2859
- author: z.ZodOptional<z.ZodString>;
2860
- sentAt: z.ZodOptional<z.ZodISODateTime>;
2861
- }, z.core.$strict>, z.ZodObject<{
2862
- type: z.ZodLiteral<"web_page">;
2863
- summary: z.ZodOptional<z.ZodString>;
2864
- siteName: z.ZodOptional<z.ZodString>;
2865
- author: z.ZodOptional<z.ZodString>;
2866
- media: z.ZodOptional<z.ZodEnum<{
2867
- image: "image";
2868
- video: "video";
2869
- }>>;
2870
- thumbnailUrl: z.ZodOptional<z.ZodString>;
2871
- }, z.core.$strict>, z.ZodObject<{
2872
- type: z.ZodLiteral<"chart">;
2873
- summary: z.ZodOptional<z.ZodString>;
2874
- display: z.ZodEnum<{
2875
- area: "area";
2876
- bar: "bar";
2877
- line: "line";
2878
- }>;
2879
- yAxis: z.ZodString;
2880
- range: z.ZodString;
2881
- series: z.ZodArray<z.ZodObject<{
2882
- label: z.ZodString;
2883
- points: z.ZodArray<z.ZodNumber>;
2884
- }, z.core.$strict>>;
2885
- }, z.core.$strict>, z.ZodObject<{
2886
- type: z.ZodLiteral<"event">;
2887
- summary: z.ZodOptional<z.ZodString>;
2888
- level: z.ZodOptional<z.ZodString>;
2889
- project: z.ZodOptional<z.ZodString>;
2890
- release: z.ZodOptional<z.ZodString>;
2891
- environment: z.ZodOptional<z.ZodString>;
2892
- occurredAt: z.ZodOptional<z.ZodISODateTime>;
2893
- }, z.core.$strict>, z.ZodObject<{
2894
- type: z.ZodLiteral<"release">;
2895
- summary: z.ZodOptional<z.ZodString>;
2896
- version: z.ZodString;
2897
- projects: z.ZodArray<z.ZodString>;
2898
- newIssues: z.ZodOptional<z.ZodNumber>;
2899
- crashFreeSessions: z.ZodOptional<z.ZodNumber>;
2900
- deployCount: z.ZodOptional<z.ZodNumber>;
2901
- lastDeploy: z.ZodOptional<z.ZodObject<{
2902
- environment: z.ZodString;
2903
- finishedAt: z.ZodOptional<z.ZodISODateTime>;
2904
- }, z.core.$strict>>;
2905
- releasedAt: z.ZodOptional<z.ZodISODateTime>;
2906
- }, z.core.$strict>, z.ZodObject<{
2907
- type: z.ZodLiteral<"monitor">;
2908
- summary: z.ZodOptional<z.ZodString>;
2909
- kind: z.ZodEnum<{
2910
- cron: "cron";
2911
- metric: "metric";
2912
- uptime: "uptime";
2913
- }>;
2914
- state: z.ZodEnum<{
2915
- failing: "failing";
2916
- ok: "ok";
2917
- paused: "paused";
2918
- pending: "pending";
2919
- }>;
2920
- project: z.ZodOptional<z.ZodString>;
2921
- environment: z.ZodOptional<z.ZodString>;
2922
- detail: z.ZodOptional<z.ZodString>;
2923
- lastCheckedAt: z.ZodOptional<z.ZodISODateTime>;
2924
- trend: z.ZodOptional<z.ZodObject<{
2925
- label: z.ZodString;
2926
- points: z.ZodArray<z.ZodNumber>;
2927
- }, z.core.$strict>>;
2928
- }, z.core.$strict>, z.ZodObject<{
2929
- type: z.ZodLiteral<"alert">;
2930
- summary: z.ZodOptional<z.ZodString>;
2931
- enabled: z.ZodBoolean;
2932
- projects: z.ZodArray<z.ZodString>;
2933
- trigger: z.ZodOptional<z.ZodString>;
2934
- notifies: z.ZodArray<z.ZodString>;
2935
- lastTriggeredAt: z.ZodOptional<z.ZodISODateTime>;
2936
- }, z.core.$strict>, z.ZodObject<{
2937
- type: z.ZodLiteral<"trace">;
2938
- summary: z.ZodOptional<z.ZodString>;
2939
- rootOp: z.ZodOptional<z.ZodString>;
2940
- rootName: z.ZodOptional<z.ZodString>;
2941
- durationMs: z.ZodNumber;
2942
- spanCount: z.ZodNumber;
2943
- errorCount: z.ZodNumber;
2944
- performanceIssueCount: z.ZodNumber;
2945
- projects: z.ZodArray<z.ZodString>;
2946
- spans: z.ZodArray<z.ZodObject<{
2947
- op: z.ZodOptional<z.ZodString>;
2948
- name: z.ZodString;
2949
- startMs: z.ZodNumber;
2950
- durationMs: z.ZodNumber;
2951
- issue: z.ZodOptional<z.ZodBoolean>;
2952
- }, z.core.$strict>>;
2953
- }, z.core.$strict>, z.ZodObject<{
2954
- type: z.ZodLiteral<"dashboard">;
2955
- summary: z.ZodOptional<z.ZodString>;
2956
- widgetCount: z.ZodNumber;
2957
- projects: z.ZodArray<z.ZodString>;
2958
- environments: z.ZodArray<z.ZodString>;
2959
- range: z.ZodString;
2960
- widgets: z.ZodArray<z.ZodObject<{
2961
- title: z.ZodString;
2962
- display: z.ZodString;
2963
- }, z.core.$strict>>;
2964
- charts: z.ZodArray<z.ZodObject<{
2965
- title: z.ZodString;
2966
- display: z.ZodEnum<{
2967
- area: "area";
2968
- bar: "bar";
2969
- line: "line";
2970
- }>;
2971
- series: z.ZodArray<z.ZodObject<{
2972
- label: z.ZodString;
2973
- points: z.ZodArray<z.ZodNumber>;
2974
- }, z.core.$strict>>;
2975
- }, z.core.$strict>>;
2976
- }, z.core.$strict>, z.ZodObject<{
2977
- type: z.ZodLiteral<"person">;
2978
- summary: z.ZodOptional<z.ZodString>;
2979
- email: z.ZodOptional<z.ZodString>;
2980
- slackHandle: z.ZodOptional<z.ZodString>;
2981
- githubHandle: z.ZodOptional<z.ZodString>;
2982
- avatarUrl: z.ZodOptional<z.ZodString>;
2983
- }, z.core.$strict>], "type">>;
2989
+ action: z.ZodEnum<{
2990
+ changed: "changed";
2991
+ created: "created";
2992
+ }>;
2984
2993
  }, z.core.$strict>>>;
2985
2994
  reply: z.ZodOptional<z.ZodObject<{
2986
2995
  text: z.ZodString;
@@ -3176,16 +3185,18 @@ export interface PluginConversationMatch {
3176
3185
  }
3177
3186
  export interface PluginConversationToolContext {
3178
3187
  /**
3179
- * Find other Conversations that have an Annotation with `annotation`, or a
3180
- * nested key that continues with `#`. A root does not match for the
3181
- * Annotation of its child agent. Core applies the Conversation access
3182
- * rules, and leaves out archived Conversations and the current tree.
3183
- * Working Conversations (pending, running, paused) first, then newest
3184
- * activity.
3188
+ * Find other Conversations that have an Annotation of one object of this
3189
+ * plugin, by its subject, so a renamed object still matches. A root does
3190
+ * not match for the Annotation of its child agent. Core applies the
3191
+ * Conversation access rules, and leaves out archived Conversations and
3192
+ * the current tree. Working Conversations (pending, running, paused)
3193
+ * first, then newest activity.
3185
3194
  */
3186
3195
  search(input: {
3187
- annotation: string;
3188
3196
  limit?: number;
3197
+ subject: ObjectSubject;
3198
+ /** The object's link, to also match a card saved without its subject. */
3199
+ url?: string;
3189
3200
  }): Promise<PluginConversationMatch[]>;
3190
3201
  }
3191
3202
  /**
@@ -3357,6 +3368,20 @@ export declare const objectLinkFilterSchema: z.ZodObject<{
3357
3368
  path: z.ZodOptional<z.ZodString>;
3358
3369
  pathPattern: z.ZodOptional<z.ZodString>;
3359
3370
  pathPrefix: z.ZodOptional<z.ZodString>;
3371
+ target: z.ZodOptional<z.ZodObject<{
3372
+ param: z.ZodString;
3373
+ filters: z.ZodArray<z.ZodObject<{
3374
+ scheme: z.ZodOptional<z.ZodEnum<{
3375
+ http: "http";
3376
+ https: "https";
3377
+ mailto: "mailto";
3378
+ }>>;
3379
+ host: z.ZodOptional<z.ZodString>;
3380
+ path: z.ZodOptional<z.ZodString>;
3381
+ pathPattern: z.ZodOptional<z.ZodString>;
3382
+ pathPrefix: z.ZodOptional<z.ZodString>;
3383
+ }, z.core.$strict>>;
3384
+ }, z.core.$strict>>;
3360
3385
  }, z.core.$strict>;
3361
3386
  export type ObjectLinkFilter = z.output<typeof objectLinkFilterSchema>;
3362
3387
  /** Return whether a filter claims a URL. A trailing slash does not count. */
@@ -3416,6 +3441,18 @@ export interface ObjectLinkContext extends PluginContext {
3416
3441
  * MCP.
3417
3442
  */
3418
3443
  viewerMcp: PluginViewerMcp;
3444
+ /**
3445
+ * Move the saved Annotations of one of this plugin's subject kinds from
3446
+ * the id `from` to the id `to`, and change nothing else. Call it only
3447
+ * after the viewer's own read named both ids. Set `urlPrefix` when `from`
3448
+ * is unique only in one part of the provider, such as one workspace.
3449
+ */
3450
+ replaceSubjectId(subject: {
3451
+ from: string;
3452
+ kind: string;
3453
+ to: string;
3454
+ urlPrefix?: string;
3455
+ }): Promise<void>;
3419
3456
  /**
3420
3457
  * What `prefetch` returned for this URL, in `canView` and `resolve` of
3421
3458
  * the same page read. Absent in every other read, such as an Attach, so
@@ -3429,11 +3466,12 @@ export interface ObjectLinkContext extends PluginContext {
3429
3466
  */
3430
3467
  export interface PluginObjectLinkDefinition {
3431
3468
  /**
3432
- * Set false when `resolve` reads one cache entry per object that your
3433
- * webhooks keep current. Junior then keeps no card copy per viewer, so a
3434
- * change shows on the next read. `canView` still runs on each read.
3469
+ * Set true when `resolve` reads the provider other than through
3470
+ * `egress` or `viewerEgress`, such as through `viewerMcp`. Junior then
3471
+ * keeps the card for each viewer and URL for one minute, and shows the
3472
+ * last card when a read fails.
3435
3473
  */
3436
- cacheCards?: false;
3474
+ cacheCards?: true;
3437
3475
  /**
3438
3476
  * Return whether `ctx.viewer` may see the object. Junior calls it before
3439
3477
  * each card read and again on each Attach. Return true for a public
@@ -3442,6 +3480,24 @@ export interface PluginObjectLinkDefinition {
3442
3480
  */
3443
3481
  canView(ctx: ObjectLinkContext, url: URL): Promise<boolean>;
3444
3482
  filters: ObjectLinkFilter[];
3483
+ /**
3484
+ * How Junior's HTTP cache keeps the GET responses of `egress` and
3485
+ * `viewerEgress`. Each credential has its own entries. Without it, an
3486
+ * entry serves for one minute, and a failed read gets the last entry.
3487
+ * Set `ttlMs: 0` when your webhooks keep your own cache current: each
3488
+ * read then asks the provider with the entry's validators.
3489
+ */
3490
+ httpCache?: {
3491
+ staleIfError?: false;
3492
+ ttlMs: number;
3493
+ };
3494
+ /**
3495
+ * Name the object from its link alone, such as `owner/repo#12`. A card
3496
+ * shows it when Junior cannot read the object, such as for a viewer who
3497
+ * cannot see it or when the provider is down. Without it, the card shows
3498
+ * the host of the link.
3499
+ */
3500
+ label?(url: URL): string | undefined;
3445
3501
  /**
3446
3502
  * The object types that `resolve` can return. One URL can open more than
3447
3503
  * one type, such as a GitHub issue URL that opens a pull request.
@@ -3492,6 +3548,14 @@ export interface PluginInboxSubjectKind {
3492
3548
  * while the item stays the same, such as from review to merge.
3493
3549
  */
3494
3550
  ask?: (object: ObjectAnnotation, viewer: PluginInboxViewer) => string | undefined;
3551
+ /**
3552
+ * Say what else a dismiss by the person who reads the item changes on
3553
+ * the provider, such as `Also removes you from the reviewers on GitHub.`
3554
+ * The Inbox shows it on Dismiss. `object` is the live card, unset when
3555
+ * the kind has none or its read failed. Return undefined when their
3556
+ * dismiss changes nothing there.
3557
+ */
3558
+ dismissNote?: (object: ObjectAnnotation | undefined, viewer: PluginInboxViewer) => string | undefined;
3495
3559
  /**
3496
3560
  * The subject id is the provider id of a code change that this plugin
3497
3561
  * records (`codeLinks`), such as a GitHub pull request id. Junior then
@@ -3499,14 +3563,20 @@ export interface PluginInboxSubjectKind {
3499
3563
  */
3500
3564
  codeChange?: boolean;
3501
3565
  /**
3502
- * Where the owner Conversation of an item is. Each item belongs to one
3503
- * Conversation, which decides who can see it. Junior finds it in the row
3504
- * of `table` whose `subjectId` column holds the item's subject id, and
3505
- * reads the `conversationId` column of that row. Name a table of this
3506
- * plugin and its columns in snake_case. At most one row can have the
3507
- * subject id and a set Conversation: add a unique index for it.
3566
+ * Where the owner Conversation of an item is, which decides who can see
3567
+ * it. A table maps the subject id to a `conversationId`, with a unique
3568
+ * index (columns in snake_case). `annotation` names the Conversation that
3569
+ * first saved an Annotation of the subject, so register each kind that an
3570
+ * object Annotation uses.
3571
+ */
3572
+ owner: PluginInboxSubjectOwner | "annotation";
3573
+ /**
3574
+ * Each assignee holds a role on the object, such as a GitHub assignee, so
3575
+ * they are on the item without the owner Conversation. Nobody can take it.
3576
+ * A dismiss first calls `inboxItemDismissed` to remove the person's role,
3577
+ * and fails when the hook fails. With nobody left, the item closes.
3508
3578
  */
3509
- owner: PluginInboxSubjectOwner;
3579
+ assigneeRoles?: boolean;
3510
3580
  }
3511
3581
  /** The table and columns that map a subject id to its owner Conversation. */
3512
3582
  export interface PluginInboxSubjectOwner {
@@ -3599,10 +3669,39 @@ export interface PluginInboxItems {
3599
3669
  status: "done" | "dismissed";
3600
3670
  }): Promise<boolean>;
3601
3671
  }
3672
+ /**
3673
+ * A plugin changed an open item through a Conversation that does not own it.
3674
+ * A plugin that picks the owner from provider data, such as a GitHub issue
3675
+ * footer, can catch it when that data is stale.
3676
+ */
3677
+ export declare class PluginInboxItemOwnerError extends Error {
3678
+ constructor(message: string);
3679
+ }
3602
3680
  /** Inbox items of a plugin, for the Conversation that each item belongs to. */
3603
3681
  export interface PluginConversationInboxItems {
3604
3682
  forConversation(conversationId: string): PluginInboxItems;
3605
3683
  }
3684
+ /**
3685
+ * A person dismissed an item of a subject kind with `assigneeRoles`. The
3686
+ * plugin removes them from the object on the provider, such as from a
3687
+ * GitHub issue's assignees.
3688
+ */
3689
+ export interface InboxItemDismissedHookContext extends PluginContext {
3690
+ /** Annotations of the Conversation that the item belongs to. */
3691
+ annotations: PluginAnnotations;
3692
+ /** Junior's native code index, as from a plugin route. */
3693
+ codeChanges: PluginCodeChanges;
3694
+ /** The Conversation that the item belongs to. */
3695
+ conversationId: string;
3696
+ /**
3697
+ * The person's account of the plugin's provider, such as a GitHub login.
3698
+ * Unset when they linked none.
3699
+ */
3700
+ handle?: string;
3701
+ nowMs: number;
3702
+ /** The subject of the item, with the plugin's own kind. */
3703
+ subject: PluginInboxItemSubject;
3704
+ }
3606
3705
  /** A person picked one of the `choices` of an item that this plugin added. */
3607
3706
  export interface InboxItemAnsweredHookContext extends PluginContext {
3608
3707
  /** The label of the picked choice. */
@@ -3636,13 +3735,8 @@ export interface PluginConversationWatches extends PluginEventToolContext {
3636
3735
  identifier: string;
3637
3736
  }): Promise<boolean>;
3638
3737
  }
3639
- /** Most entries in one batch, annotations and Inbox items together. */
3738
+ /** Most entries in one batch. */
3640
3739
  export declare const MAX_CONVERSATION_CHANGES = 100;
3641
- /** Add or replace one annotation of this plugin on a Conversation. */
3642
- export interface ConversationAnnotationChange {
3643
- conversationId: string;
3644
- upsert: ConversationAnnotationInput;
3645
- }
3646
3740
  /**
3647
3741
  * Close the open Inbox item of this plugin with the subject. Do nothing when
3648
3742
  * no item is open, such as after a person dismissed it.
@@ -3656,16 +3750,16 @@ export interface ConversationInboxItemChange {
3656
3750
  conversationId: string;
3657
3751
  }
3658
3752
  /**
3659
- * Changes that a plugin makes together, such as a chip that shows a merged
3660
- * pull request and the close of its ask. It is data, so no provider call can
3661
- * run while the changes are not saved.
3753
+ * Changes that a plugin makes together, such as the close of every ask of a
3754
+ * merged pull request. It is data, so no provider call can run while the
3755
+ * changes are not saved. A change at the provider changes no Annotation:
3756
+ * cards read the object live.
3662
3757
  */
3663
3758
  export interface ConversationChangeBatch {
3664
- annotations?: ConversationAnnotationChange[];
3665
3759
  inboxItems?: ConversationInboxItemChange[];
3666
3760
  }
3667
3761
  /**
3668
- * Save annotations and Inbox items of a plugin in one write. Readers see all
3762
+ * Save Inbox item changes of a plugin in one write. Readers see all
3669
3763
  * the changes of a batch or none of them. Each entry has the checks of the
3670
3764
  * same `forConversation` call. When one entry fails, no entry is saved and
3671
3765
  * the call throws. A batch has at most `MAX_CONVERSATION_CHANGES` entries.
@@ -3798,6 +3892,35 @@ export interface PluginConversationEventStats {
3798
3892
  hours?: number;
3799
3893
  }): Promise<PluginConversationEventCostDay[]>;
3800
3894
  }
3895
+ /** One provider GET that a plugin sends with a credential it holds. */
3896
+ export interface PluginHttpCacheRequest {
3897
+ /**
3898
+ * The credential that `send` uses, such as `installation:123`. An entry
3899
+ * of one scope never serves a request of another scope.
3900
+ */
3901
+ scope: string;
3902
+ /**
3903
+ * How long an entry serves without a request. With `0`, every read asks
3904
+ * the provider, with the entry's `ETag` or `Last-Modified`, so an
3905
+ * unchanged response costs only a `304 Not Modified`.
3906
+ */
3907
+ ttlMs: number;
3908
+ url: string;
3909
+ /** Send the GET with these validator headers added. */
3910
+ send(headers: Record<string, string>): Promise<Response>;
3911
+ }
3912
+ /**
3913
+ * Junior's HTTP cache, for provider reads that do not go through egress,
3914
+ * such as a webhook read with a token that the plugin minted. Egress reads
3915
+ * of object links use the same cache.
3916
+ */
3917
+ export interface PluginHttpCache {
3918
+ /**
3919
+ * Return the response of one GET. A failed read of the cache is a miss,
3920
+ * so it never fails the provider read.
3921
+ */
3922
+ fetch(request: PluginHttpCacheRequest): Promise<Response>;
3923
+ }
3801
3924
  export declare const promptMessageSchema: z.ZodObject<{
3802
3925
  text: z.ZodString;
3803
3926
  }, z.core.$strict>;
@@ -4330,6 +4453,8 @@ export interface RouteRegistrationHookContext extends PluginContext {
4330
4453
  conversationChanges: PluginConversationChanges;
4331
4454
  /** Core-owned delivery boundary for provider webhook events. */
4332
4455
  events: EventPublisher;
4456
+ /** Junior's HTTP cache, for reads with a token that the plugin minted. */
4457
+ httpCache: PluginHttpCache;
4333
4458
  /** Inbox items that the plugin adds and closes from its events. */
4334
4459
  inboxItems: PluginConversationInboxItems;
4335
4460
  /** Plugin-namespaced state, the same as in heartbeats. */
@@ -4802,9 +4927,9 @@ export interface PluginHooks {
4802
4927
  * Do not use it to invent a parallel tool contract for the provider tool.
4803
4928
  */
4804
4929
  afterMcpTool?(ctx: AfterMcpToolHookContext): Promise<{
4805
- objectAnnotations: ObjectAnnotation[];
4930
+ objectAnnotations: AnnotatedObject[];
4806
4931
  } | void> | {
4807
- objectAnnotations: ObjectAnnotation[];
4932
+ objectAnnotations: AnnotatedObject[];
4808
4933
  } | void;
4809
4934
  /**
4810
4935
  * Select the grant for one sandbox egress request.
@@ -4819,6 +4944,13 @@ export interface PluginHooks {
4819
4944
  * failure, so it must be safe to repeat.
4820
4945
  */
4821
4946
  inboxItemAnswered?(ctx: InboxItemAnsweredHookContext): Promise<void> | void;
4947
+ /**
4948
+ * Remove the person who dismissed an item of an `assigneeRoles` subject
4949
+ * kind from the object on the provider. Throw when the provider refuses:
4950
+ * the dismiss then fails, and the person stays on the item. Junior calls
4951
+ * it again when the person retries, so it must be safe to repeat.
4952
+ */
4953
+ inboxItemDismissed?(ctx: InboxItemDismissedHookContext): Promise<void> | void;
4822
4954
  /**
4823
4955
  * Return state that the model must keep when a compaction replaces the
4824
4956
  * history, such as open work. Junior adds it to the compaction summary.
@@ -5029,6 +5161,13 @@ export interface PluginMcpConfig {
5029
5161
  oauthClient?: PluginMcpOAuthClientConfig;
5030
5162
  transport: "http";
5031
5163
  url: string;
5164
+ /**
5165
+ * Provider tools that link cards and their images may call as the viewer
5166
+ * (`viewerMcp`). Omit for none. Each must be loaded: listed in
5167
+ * `allowedTools` or `wrappedTools`, or any tool when `allowedTools` is
5168
+ * unset. The provider must also mark each call read-only.
5169
+ */
5170
+ viewerTools?: string[];
5032
5171
  /** Provider tools hidden from the model and callable only by plugin-owned wrapper tools. */
5033
5172
  wrappedTools?: string[];
5034
5173
  }
package/dist/index.js CHANGED
@@ -703,20 +703,29 @@ function utf8ByteLength(text) {
703
703
  return bytes;
704
704
  }
705
705
  /**
706
- * Verified facts shared by Conversation annotations and Message cards.
707
- * Plugins select small facts from responses they already have. Each surface owns
708
- * its layout. Omit unknown facts; do not infer approval or passing checks.
709
- *
710
- * These facts support both compact previews and full details. Each surface
711
- * selects the fields it needs; preview rules must not remove saved facts.
712
- *
713
- * Keep raw responses, diffs, logs, credentials, and comments out of this schema.
714
- * Return only facts that the Conversation audience may see. An annotation
715
- * never grants provider access.
706
+ * The object that an Annotation points to: one of the plugin's registered
707
+ * subject kinds (`inboxSubjects`), such as `issue`, and the provider's id
708
+ * of the object, such as GitHub's id of the issue. Unlike `key`, the id
709
+ * stays the same when the object moves or its repository is renamed. An
710
+ * Inbox item with the same subject is about the same object.
711
+ */
712
+ const objectSubjectSchema = z.object({
713
+ kind: z.string().trim().min(1).max(100),
714
+ id: z.string().trim().min(1).max(256)
715
+ }).strict();
716
+ /** What a Conversation did to the object of an Annotation. */
717
+ const annotationActionSchema = z.enum(["created", "changed"]);
718
+ /**
719
+ * The card of an object: verified facts that a link type reads for one
720
+ * viewer, shown on Annotations and Message cards. No Annotation saves it.
721
+ * Omit unknown facts; do not infer approval or passing checks. Leave out
722
+ * raw responses, diffs, logs, credentials, and comments. Return only facts
723
+ * that the audience may see; a card grants no provider access.
716
724
  */
717
725
  const objectAnnotationSchema = z.object({
718
726
  kind: z.literal("object"),
719
727
  key: z.string().trim().min(1).max(256),
728
+ subject: objectSubjectSchema.optional(),
720
729
  label: z.string().trim().min(1).max(256),
721
730
  objectType: objectTypeSchema,
722
731
  title: z.string().trim().min(1).max(512),
@@ -729,8 +738,34 @@ const objectAnnotationSchema = z.object({
729
738
  sourceUpdatedAt: z.iso.datetime({ offset: true }).optional(),
730
739
  facts: objectFactsSchema.refine((facts) => objectFactsBytes(facts) <= OBJECT_FACTS_MAX_BYTES, "Object facts must not exceed 4 KiB").optional()
731
740
  }).strict().refine((annotation) => !annotation.facts || objectFactsMatchType(annotation.facts, annotation.objectType), "Object facts must match the object type");
732
- /** A saved object snapshot with its trusted owner. */
733
- const ownedObjectAnnotationSchema = objectAnnotationSchema.safeExtend({ plugin: z.string().min(1) });
741
+ /** The card of an object with its trusted owner. */
742
+ const ownedObjectAnnotationSchema = objectAnnotationSchema.safeExtend({
743
+ /**
744
+ * When the provider last returned the card's data. Junior sets it only
745
+ * on a card that a cache serves after its TTL, because a read failed.
746
+ */
747
+ fetchedAt: z.iso.datetime().optional(),
748
+ plugin: z.string().min(1)
749
+ });
750
+ /**
751
+ * The object of an Annotation, as Junior stores it: its subject, its type,
752
+ * its title, and its link. Search finds the object by its title and link,
753
+ * and a card shows them when the provider is down. A card reads every other
754
+ * fact of the object live. Set `subject` whenever the provider id is known.
755
+ */
756
+ const savedObjectAnnotationSchema = z.object({
757
+ kind: z.literal("object"),
758
+ key: z.string().trim().min(1).max(256),
759
+ subject: objectSubjectSchema.optional(),
760
+ objectType: objectTypeSchema,
761
+ title: z.string().trim().min(1).max(512),
762
+ url: z.url().max(2048).refine((value) => ["http:", "https:"].includes(new URL(value).protocol)).nullable()
763
+ }).strict();
764
+ /**
765
+ * One object that a tool or hook created or changed, to save as an
766
+ * Annotation of the Conversation.
767
+ */
768
+ const annotatedObjectSchema = savedObjectAnnotationSchema.safeExtend({ action: annotationActionSchema });
734
769
  // src/object-icons.ts
735
770
  /** Original Octicons paths, shared by web and Slack image assets. */
736
771
  const objectIconPaths = {
@@ -791,8 +826,7 @@ function decodeObjectImageRef(ref) {
791
826
  const hostSchema = z.string().regex(/^(\*\.)?[a-z0-9-]+(\.[a-z0-9-]+)*(:\d+)?$/, "Use a lowercase host, or `*.` and a lowercase domain.");
792
827
  const pathSchema = z.string().max(500).startsWith("/");
793
828
  const pathPatternSchema = pathSchema.regex(/^(\/([^/*]+|\*))+$/, "Use `/` segments. A `*` segment matches one segment.");
794
- /** Which URLs a link type claims. Give at most one path field. */
795
- const objectLinkFilterSchema = z.strictObject({
829
+ const urlFilterFields = {
796
830
  /** Defaults to `https`. */
797
831
  scheme: z.enum([
798
832
  "https",
@@ -804,11 +838,32 @@ const objectLinkFilterSchema = z.strictObject({
804
838
  path: pathSchema.optional(),
805
839
  pathPattern: pathPatternSchema.optional(),
806
840
  pathPrefix: pathSchema.optional()
807
- }).refine((filter) => [
808
- filter.path,
809
- filter.pathPattern,
810
- filter.pathPrefix
811
- ].filter((value) => value !== void 0).length <= 1, "Give at most one of path, pathPattern, and pathPrefix.").refine((filter) => filter.scheme === "mailto" ? filter.host === void 0 && !hasPathFilter(filter) : filter.host !== void 0, "An http or https filter needs a host. A mailto filter has no host or path.");
841
+ };
842
+ function oneOrNoPath(filter) {
843
+ return [
844
+ filter.path,
845
+ filter.pathPattern,
846
+ filter.pathPrefix
847
+ ].filter((value) => value !== void 0).length <= 1;
848
+ }
849
+ function hostForScheme(filter) {
850
+ return filter.scheme === "mailto" ? filter.host === void 0 && !hasPathFilter(filter) : filter.host !== void 0;
851
+ }
852
+ const ONE_PATH = "Give at most one of path, pathPattern, and pathPrefix.";
853
+ const HOST_FOR_SCHEME = "An http or https filter needs a host. A mailto filter has no host or path.";
854
+ const targetFilterSchema = z.strictObject(urlFilterFields).refine(oneOrNoPath, ONE_PATH).refine(hostForScheme, HOST_FOR_SCHEME);
855
+ /** Which URLs a link type claims. Give at most one path field. */
856
+ const objectLinkFilterSchema = z.strictObject({
857
+ ...urlFilterFields,
858
+ /**
859
+ * Claim the URL only when this query parameter holds a URL that one of
860
+ * these filters claims, such as a sign-in page's `continue` link.
861
+ */
862
+ target: z.strictObject({
863
+ param: z.string().min(1).max(100),
864
+ filters: z.array(targetFilterSchema).min(1).max(20)
865
+ }).optional()
866
+ }).refine(oneOrNoPath, ONE_PATH).refine(hostForScheme, HOST_FOR_SCHEME);
812
867
  function hasPathFilter(filter) {
813
868
  return filter.path !== void 0 || filter.pathPattern !== void 0 || filter.pathPrefix !== void 0;
814
869
  }
@@ -823,7 +878,12 @@ function objectLinkFilterMatches(filter, url) {
823
878
  const host = url.host.toLowerCase();
824
879
  if (!(filter.host.startsWith("*.") ? host.endsWith(filter.host.slice(1)) : host === filter.host)) return false;
825
880
  }
826
- const path = normalizedPath(url);
881
+ if (!pathMatches(filter, normalizedPath(url))) return false;
882
+ if (filter.target === void 0) return true;
883
+ const target = URL.parse(url.searchParams.get(filter.target.param) ?? "");
884
+ return target !== null && filter.target.filters.some((inner) => objectLinkFilterMatches(inner, target));
885
+ }
886
+ function pathMatches(filter, path) {
827
887
  if (filter.path !== void 0) return path === filter.path;
828
888
  if (filter.pathPrefix !== void 0) return path.startsWith(filter.pathPrefix);
829
889
  if (filter.pathPattern !== void 0) {
@@ -880,28 +940,37 @@ function usesHttpProtocol(value) {
880
940
  }
881
941
  const httpUrlSchema = z.string().url().max(2048).refine(usesHttpProtocol, "URL must use HTTP or HTTPS.");
882
942
  /**
883
- * Link an object to a Conversation when the owner has no typed object preview.
884
- * Keep a stable key, compact label, source URL, and optional short context or
885
- * status. Do not fetch a full object merely to save a link. Rich preview intent
886
- * belongs to objectAnnotationSchema, not a second set of resource-link fields.
943
+ * Link an object to a Conversation by its link alone, such as a link that a
944
+ * person attached. Junior stores no title for it: the title would show to
945
+ * readers who cannot open the object. Its card reads the object live.
887
946
  */
888
947
  const resourceLinkAnnotationSchema = z.object({
889
948
  kind: z.literal("resource_link"),
890
949
  objectType: objectTypeSchema.optional(),
891
950
  key: z.string().trim().min(1).max(256),
892
- label: z.string().trim().min(1).max(256),
893
- url: httpUrlSchema,
894
- description: z.string().trim().min(1).max(512).optional(),
895
- status: z.enum([
896
- "open",
897
- "draft",
898
- "closed",
899
- "merged",
900
- "warning"
901
- ]).optional()
951
+ url: httpUrlSchema
902
952
  }).strict();
903
953
  /** Core-known annotation shapes that plugins may attach to a conversation. */
904
- const conversationAnnotationInputSchema = z.discriminatedUnion("kind", [resourceLinkAnnotationSchema, objectAnnotationSchema]);
954
+ const conversationAnnotationInputSchema = z.discriminatedUnion("kind", [resourceLinkAnnotationSchema, savedObjectAnnotationSchema]);
955
+ /**
956
+ * The label and the link of an object that Junior cannot read for the
957
+ * viewer, such as when the viewer has no access or the provider is down.
958
+ * The plugin makes the label from the link. An object without a link, such
959
+ * as an Automation of an install without a dashboard, has no `url`.
960
+ */
961
+ const annotationLabelSchema = resourceLinkAnnotationSchema.extend({
962
+ label: z.string().trim().min(1).max(256),
963
+ plugin: z.string().min(1),
964
+ url: httpUrlSchema.nullable()
965
+ });
966
+ /**
967
+ * An Annotation as one viewer sees it: the live card of its object, else
968
+ * only its label and its link.
969
+ */
970
+ const liveAnnotationSchema = z.discriminatedUnion("kind", [annotationLabelSchema, ownedObjectAnnotationSchema]).and(z.object({
971
+ createdAt: z.string().datetime(),
972
+ updatedAt: z.string().datetime()
973
+ }));
905
974
  const conversationSidebarIconSchema = z.enum([
906
975
  "circle-dot",
907
976
  "circle-dashed",
@@ -969,7 +1038,7 @@ const codeChangeFilterSchema = z.object({
969
1038
  updatedBefore: z.date().optional()
970
1039
  }).strict();
971
1040
  // src/conversation-changes.ts
972
- /** Most entries in one batch, annotations and Inbox items together. */
1041
+ /** Most entries in one batch. */
973
1042
  const MAX_CONVERSATION_CHANGES = 100;
974
1043
  // src/conversation-events.ts
975
1044
  const conversationEventNameSchema = z.string().trim().min(1).max(64).regex(/^[a-z][a-z0-9_]*$/);
@@ -2368,7 +2437,7 @@ const pluginToolOutputSchema = z.object({
2368
2437
  * show with the next reply. Omit for silent updates. Read-only tools
2369
2438
  * (`readOnlyHint: true`) must omit it: core rejects the result.
2370
2439
  */
2371
- objectAnnotations: z.array(objectAnnotationSchema).optional(),
2440
+ objectAnnotations: z.array(annotatedObjectSchema).optional(),
2372
2441
  /**
2373
2442
  * Reply the tool posted for Junior, such as a pull request comment. Core
2374
2443
  * shows it in the transcript as a Junior reply with the plugin's mark,
@@ -2784,15 +2853,28 @@ function validateInboxSubjects(name, kinds) {
2784
2853
  for (const subject of kinds) {
2785
2854
  if (typeof subject?.kind !== "string" || !INBOX_SUBJECT_KIND_RE.test(subject.kind) || typeof subject.label !== "string" || !subject.label.trim() || subject.ask !== void 0 && typeof subject.ask !== "function") throw new Error(`Plugin "${name}" inbox subjects need a snake_case kind and a label.`);
2786
2855
  const owner = subject.owner;
2787
- if (![
2856
+ if (owner !== "annotation" && ![
2788
2857
  owner?.table,
2789
2858
  owner?.subjectId,
2790
2859
  owner?.conversationId
2791
- ].every((identifier) => typeof identifier === "string" && SQL_IDENTIFIER_RE.test(identifier))) throw new Error(`Plugin "${name}" inbox subject "${subject.kind}" needs an owner table, subjectId column, and conversationId column in snake_case.`);
2860
+ ].every((identifier) => typeof identifier === "string" && SQL_IDENTIFIER_RE.test(identifier))) throw new Error(`Plugin "${name}" inbox subject "${subject.kind}" needs an owner: "annotation", or a table, subjectId column, and conversationId column in snake_case.`);
2861
+ if (subject.assigneeRoles !== void 0 && typeof subject.assigneeRoles !== "boolean") throw new Error(`Plugin "${name}" inbox subject "${subject.kind}" assigneeRoles must be a boolean.`);
2792
2862
  if (seen.has(subject.kind)) throw new Error(`Plugin "${name}" has duplicate inbox subject kind "${subject.kind}".`);
2793
2863
  seen.add(subject.kind);
2794
2864
  }
2795
2865
  }
2866
+ // src/inbox-items.ts
2867
+ /**
2868
+ * A plugin changed an open item through a Conversation that does not own it.
2869
+ * A plugin that picks the owner from provider data, such as a GitHub issue
2870
+ * footer, can catch it when that data is stale.
2871
+ */
2872
+ var PluginInboxItemOwnerError = class extends Error {
2873
+ constructor(message) {
2874
+ super(message);
2875
+ this.name = "PluginInboxItemOwnerError";
2876
+ }
2877
+ };
2796
2878
  // src/markdown.ts
2797
2879
  /**
2798
2880
  * Parse GitHub-flavored Markdown. Each node position holds offsets into
@@ -2938,4 +3020,4 @@ const pluginUserPageInputSchema = z.object({
2938
3020
  limit: z.number().int().min(1).max(50),
2939
3021
  query: pluginUserPageQuerySchema
2940
3022
  }).strict();
2941
- 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, codeChangeFilterSchema, codeChangeInputSchema, codeChangeSizeSchema, codeChangeStateSchema, codeRepositoryInputSchema, 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, pluginTaskStartInputSchema, 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 };
3023
+ 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, PluginInboxItemOwnerError, PluginToolInputError, REQUIRED_TOOL_ANNOTATION_KEYS, actorSchema, actorUserIdSchema, agentEventKeys, agentEventMatchKey, agentEventMatchSchema, annotatedObjectSchema, annotationActionSchema, anyResourceEvents, anyResourceMatchFields, codeChangeFilterSchema, codeChangeInputSchema, codeChangeSizeSchema, codeChangeStateSchema, codeRepositoryInputSchema, 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, liveAnnotationSchema, localActorSchema, localDestinationSchema, localSourceSchema, locationSchema, markdownNodes, markdownPlainText, markdownText, mentionsTag, mergeEventMatchFields, missingToolAnnotationKeys, nonBlankStringSchema, normalizeEventIdentifier, normalizeEventMatch, objectAnnotationSchema, objectFactFields, objectFactsBytes, objectFactsMatchType, objectFactsSchema, objectIconPath, objectIconPaths, objectLinkFilterMatches, objectLinkFilterSchema, objectLinkFilterSpecificity, objectPresentation, objectSubjectSchema, 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, pluginTaskStartInputSchema, pluginToolContentSchema, pluginToolContinuationSchema, pluginToolOutputSchema, pluginToolReplySchema, pluginUserPageContentSchema, pluginUserPageCursorSchema, pluginUserPageFilterSchema, pluginUserPageInputSchema, pluginUserPageLinkSchema, pluginUserPageLinksSchema, pluginUserPageQuerySchema, promptContextSchema, promptMessageSchema, readTag, renderEmptyTag, renderInlineTag, renderTag, replyAttributionSchema, resourceLinkAnnotationSchema, resourceTypeSchema, savedObjectAnnotationSchema, 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.318.0",
3
+ "version": "0.319.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"