@sentry/junior-plugin-api 0.316.0 → 0.317.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 +276 -130
- package/dist/index.js +39 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -30,6 +30,12 @@ export declare const objectFactsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
30
30
|
pending: z.ZodNumber;
|
|
31
31
|
}, z.core.$strict>, z.ZodLiteral<"pending">]>>;
|
|
32
32
|
mergeable: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"pending">]>>;
|
|
33
|
+
titleParts: z.ZodOptional<z.ZodObject<{
|
|
34
|
+
breaking: z.ZodOptional<z.ZodBoolean>;
|
|
35
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
36
|
+
text: z.ZodString;
|
|
37
|
+
type: z.ZodOptional<z.ZodString>;
|
|
38
|
+
}, z.core.$strict>>;
|
|
33
39
|
changedFiles: z.ZodOptional<z.ZodNumber>;
|
|
34
40
|
additions: z.ZodOptional<z.ZodNumber>;
|
|
35
41
|
deletions: z.ZodOptional<z.ZodNumber>;
|
|
@@ -324,6 +330,12 @@ export declare const objectAnnotationSchema: z.ZodObject<{
|
|
|
324
330
|
pending: z.ZodNumber;
|
|
325
331
|
}, z.core.$strict>, z.ZodLiteral<"pending">]>>;
|
|
326
332
|
mergeable: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"pending">]>>;
|
|
333
|
+
titleParts: z.ZodOptional<z.ZodObject<{
|
|
334
|
+
breaking: z.ZodOptional<z.ZodBoolean>;
|
|
335
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
336
|
+
text: z.ZodString;
|
|
337
|
+
type: z.ZodOptional<z.ZodString>;
|
|
338
|
+
}, z.core.$strict>>;
|
|
327
339
|
changedFiles: z.ZodOptional<z.ZodNumber>;
|
|
328
340
|
additions: z.ZodOptional<z.ZodNumber>;
|
|
329
341
|
deletions: z.ZodOptional<z.ZodNumber>;
|
|
@@ -546,6 +558,12 @@ export declare const ownedObjectAnnotationSchema: z.ZodObject<{
|
|
|
546
558
|
pending: z.ZodNumber;
|
|
547
559
|
}, z.core.$strict>, z.ZodLiteral<"pending">]>>;
|
|
548
560
|
mergeable: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"pending">]>>;
|
|
561
|
+
titleParts: z.ZodOptional<z.ZodObject<{
|
|
562
|
+
breaking: z.ZodOptional<z.ZodBoolean>;
|
|
563
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
564
|
+
text: z.ZodString;
|
|
565
|
+
type: z.ZodOptional<z.ZodString>;
|
|
566
|
+
}, z.core.$strict>>;
|
|
549
567
|
changedFiles: z.ZodOptional<z.ZodNumber>;
|
|
550
568
|
additions: z.ZodOptional<z.ZodNumber>;
|
|
551
569
|
deletions: z.ZodOptional<z.ZodNumber>;
|
|
@@ -1710,6 +1728,12 @@ export declare const conversationAnnotationInputSchema: z.ZodDiscriminatedUnion<
|
|
|
1710
1728
|
pending: z.ZodNumber;
|
|
1711
1729
|
}, z.core.$strict>, z.ZodLiteral<"pending">]>>;
|
|
1712
1730
|
mergeable: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"pending">]>>;
|
|
1731
|
+
titleParts: z.ZodOptional<z.ZodObject<{
|
|
1732
|
+
breaking: z.ZodOptional<z.ZodBoolean>;
|
|
1733
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
1734
|
+
text: z.ZodString;
|
|
1735
|
+
type: z.ZodOptional<z.ZodString>;
|
|
1736
|
+
}, z.core.$strict>>;
|
|
1713
1737
|
changedFiles: z.ZodOptional<z.ZodNumber>;
|
|
1714
1738
|
additions: z.ZodOptional<z.ZodNumber>;
|
|
1715
1739
|
deletions: z.ZodOptional<z.ZodNumber>;
|
|
@@ -1989,6 +2013,7 @@ export declare const codeRepositoryInputSchema: z.ZodObject<{
|
|
|
1989
2013
|
export type CodeRepositoryInput = z.input<typeof codeRepositoryInputSchema>;
|
|
1990
2014
|
export declare const codeChangeFilterSchema: z.ZodObject<{
|
|
1991
2015
|
conversationIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2016
|
+
providerIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1992
2017
|
repository: z.ZodOptional<z.ZodObject<{
|
|
1993
2018
|
name: z.ZodString;
|
|
1994
2019
|
numbers: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
@@ -2781,6 +2806,12 @@ export declare const pluginToolOutputSchema: z.ZodObject<{
|
|
|
2781
2806
|
pending: z.ZodNumber;
|
|
2782
2807
|
}, z.core.$strict>, z.ZodLiteral<"pending">]>>;
|
|
2783
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>>;
|
|
2784
2815
|
changedFiles: z.ZodOptional<z.ZodNumber>;
|
|
2785
2816
|
additions: z.ZodOptional<z.ZodNumber>;
|
|
2786
2817
|
deletions: z.ZodOptional<z.ZodNumber>;
|
|
@@ -3446,6 +3477,165 @@ export interface PluginObjectLinkDefinition {
|
|
|
3446
3477
|
*/
|
|
3447
3478
|
readTool?(object: ObjectAnnotation): string | undefined;
|
|
3448
3479
|
}
|
|
3480
|
+
/**
|
|
3481
|
+
* One kind of Inbox item that a plugin adds, such as `pull_request`. Junior
|
|
3482
|
+
* stores it as `<plugin>:<kind>`, so each kind is unique. `label` names the
|
|
3483
|
+
* kind in the Inbox when the object's card cannot say more.
|
|
3484
|
+
*/
|
|
3485
|
+
export interface PluginInboxSubjectKind {
|
|
3486
|
+
kind: string;
|
|
3487
|
+
label: string;
|
|
3488
|
+
/**
|
|
3489
|
+
* Name the ask of the person who reads the item, from the object's live
|
|
3490
|
+
* card, such as `Review requested` for a reviewer and `Ready to merge`
|
|
3491
|
+
* for the author. Return undefined to show `label`. The ask can change
|
|
3492
|
+
* while the item stays the same, such as from review to merge.
|
|
3493
|
+
*/
|
|
3494
|
+
ask?: (object: ObjectAnnotation, viewer: PluginInboxViewer) => string | undefined;
|
|
3495
|
+
/**
|
|
3496
|
+
* The subject id is the provider id of a code change that this plugin
|
|
3497
|
+
* records (`codeLinks`), such as a GitHub pull request id. Junior then
|
|
3498
|
+
* reads the item's link and its search title from the code change.
|
|
3499
|
+
*/
|
|
3500
|
+
codeChange?: boolean;
|
|
3501
|
+
/**
|
|
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.
|
|
3508
|
+
*/
|
|
3509
|
+
owner: PluginInboxSubjectOwner;
|
|
3510
|
+
}
|
|
3511
|
+
/** The table and columns that map a subject id to its owner Conversation. */
|
|
3512
|
+
export interface PluginInboxSubjectOwner {
|
|
3513
|
+
conversationId: string;
|
|
3514
|
+
subjectId: string;
|
|
3515
|
+
table: string;
|
|
3516
|
+
}
|
|
3517
|
+
/**
|
|
3518
|
+
* The person who reads an item. `handle` is their account of the plugin's
|
|
3519
|
+
* provider, such as a GitHub login, when they linked one.
|
|
3520
|
+
*/
|
|
3521
|
+
export interface PluginInboxViewer {
|
|
3522
|
+
handle?: string;
|
|
3523
|
+
}
|
|
3524
|
+
/**
|
|
3525
|
+
* What a plugin item is about: one of the plugin's registered `kind`s and
|
|
3526
|
+
* the id of the object, such as a pull request. The pair names one item: a
|
|
3527
|
+
* plugin has at most one open item for each pair. Junior reads the
|
|
3528
|
+
* object's title, state, and link from the object, and does not store them.
|
|
3529
|
+
*/
|
|
3530
|
+
export interface PluginInboxItemSubject {
|
|
3531
|
+
id: string;
|
|
3532
|
+
kind: string;
|
|
3533
|
+
}
|
|
3534
|
+
/**
|
|
3535
|
+
* An item that a plugin puts in the Inbox: a notice for information,
|
|
3536
|
+
* or an ask that waits on its assignees.
|
|
3537
|
+
*/
|
|
3538
|
+
export interface PluginReviewNotice {
|
|
3539
|
+
/**
|
|
3540
|
+
* Everyone who has an ask on the object now. Junior assigns the User
|
|
3541
|
+
* linked to each Identity, but only when that User is in the notice's
|
|
3542
|
+
* Conversation. A person who is on the open item and not in this list
|
|
3543
|
+
* leaves it: Junior cancels their snooze and clears their push. When
|
|
3544
|
+
* nobody is left, the item closes.
|
|
3545
|
+
*/
|
|
3546
|
+
assigneeIdentityIds: string[];
|
|
3547
|
+
/**
|
|
3548
|
+
* The people in `assigneeIdentityIds` whose ask the event behind this
|
|
3549
|
+
* upsert gave, such as a review request. Only they join the item, and
|
|
3550
|
+
* Junior pushes it to them. The others stay only when they are on the
|
|
3551
|
+
* open item already, so a person who left comes back only with a new ask.
|
|
3552
|
+
*/
|
|
3553
|
+
askedIdentityIds: string[];
|
|
3554
|
+
/** Markdown details for the person. */
|
|
3555
|
+
body: string;
|
|
3556
|
+
/**
|
|
3557
|
+
* What the notice is about, such as a pull request. An upsert with the
|
|
3558
|
+
* subject of an open item changes that item.
|
|
3559
|
+
*/
|
|
3560
|
+
subject: PluginInboxItemSubject;
|
|
3561
|
+
/**
|
|
3562
|
+
* For an item that waits on its assignees, name their step, such as
|
|
3563
|
+
* `Ready to merge · #946`. It is the reason that the dashboard shows.
|
|
3564
|
+
*/
|
|
3565
|
+
title: string;
|
|
3566
|
+
/**
|
|
3567
|
+
* Buttons that answer the item, in display order, such as `Resume`. An
|
|
3568
|
+
* item with choices waits on its assignees. The first click closes it as
|
|
3569
|
+
* done and calls the plugin's `inboxItemAnswered` hook with the choice.
|
|
3570
|
+
* The answer starts no Turn: the plugin does the work.
|
|
3571
|
+
*/
|
|
3572
|
+
choices?: Array<{
|
|
3573
|
+
label: string;
|
|
3574
|
+
description?: string;
|
|
3575
|
+
}>;
|
|
3576
|
+
/**
|
|
3577
|
+
* The assignees must act, such as merge a pull request that is ready. The
|
|
3578
|
+
* item then waits on them: its Conversation shows in their Needs you, and
|
|
3579
|
+
* it counts in their Inbox. Leave it unset for a notice that is only for
|
|
3580
|
+
* information.
|
|
3581
|
+
*/
|
|
3582
|
+
waitsOnAssignees?: boolean;
|
|
3583
|
+
}
|
|
3584
|
+
/**
|
|
3585
|
+
* Inbox items that a plugin adds and closes from its own events. Each item
|
|
3586
|
+
* belongs to one Conversation. Core owns visibility, assignment rules, and
|
|
3587
|
+
* the Slack cards.
|
|
3588
|
+
*/
|
|
3589
|
+
export interface PluginInboxItems {
|
|
3590
|
+
/** Add an open item, or change the open one of the subject. */
|
|
3591
|
+
upsert(notice: PluginReviewNotice): Promise<void>;
|
|
3592
|
+
/**
|
|
3593
|
+
* Close the open item of the subject. Do nothing when no item is open,
|
|
3594
|
+
* such as after a person dismissed it. Return whether an open item closed.
|
|
3595
|
+
*/
|
|
3596
|
+
close(input: {
|
|
3597
|
+
subject: PluginInboxItemSubject;
|
|
3598
|
+
reason: string;
|
|
3599
|
+
status: "done" | "dismissed";
|
|
3600
|
+
}): Promise<boolean>;
|
|
3601
|
+
}
|
|
3602
|
+
/** Inbox items of a plugin, for the Conversation that each item belongs to. */
|
|
3603
|
+
export interface PluginConversationInboxItems {
|
|
3604
|
+
forConversation(conversationId: string): PluginInboxItems;
|
|
3605
|
+
}
|
|
3606
|
+
/** A person picked one of the `choices` of an item that this plugin added. */
|
|
3607
|
+
export interface InboxItemAnsweredHookContext extends PluginContext {
|
|
3608
|
+
/** The label of the picked choice. */
|
|
3609
|
+
choice: string;
|
|
3610
|
+
/** Junior's native code index, as from a plugin route. */
|
|
3611
|
+
codeChanges: PluginCodeChanges;
|
|
3612
|
+
/** The Conversation that the item belongs to. */
|
|
3613
|
+
conversationId: string;
|
|
3614
|
+
/** The subject of the item, with the plugin's own kind. */
|
|
3615
|
+
subject: PluginInboxItemSubject;
|
|
3616
|
+
/** Publish events, as from a plugin route. */
|
|
3617
|
+
events: EventPublisher;
|
|
3618
|
+
/** The closed item's id. It is the same on a retry of the same answer. */
|
|
3619
|
+
itemId: string;
|
|
3620
|
+
nowMs: number;
|
|
3621
|
+
/** Inbox items, as from a plugin route. */
|
|
3622
|
+
inboxItems: PluginConversationInboxItems;
|
|
3623
|
+
state: PluginState;
|
|
3624
|
+
/** Watches of the item's Conversation. */
|
|
3625
|
+
watches: PluginConversationWatches;
|
|
3626
|
+
}
|
|
3627
|
+
/** Watches of one Conversation, for a plugin outside a tool call. */
|
|
3628
|
+
export interface PluginConversationWatches extends PluginEventToolContext {
|
|
3629
|
+
/**
|
|
3630
|
+
* Whether an active Watch of this Conversation starts a Turn for this
|
|
3631
|
+
* event type on this plugin resource. Watches of other Conversations and
|
|
3632
|
+
* event automations do not count.
|
|
3633
|
+
*/
|
|
3634
|
+
watching(input: {
|
|
3635
|
+
eventType: string;
|
|
3636
|
+
identifier: string;
|
|
3637
|
+
}): Promise<boolean>;
|
|
3638
|
+
}
|
|
3449
3639
|
/** Most entries in one batch, annotations and Inbox items together. */
|
|
3450
3640
|
export declare const MAX_CONVERSATION_CHANGES = 100;
|
|
3451
3641
|
/** Add or replace one annotation of this plugin on a Conversation. */
|
|
@@ -3454,12 +3644,12 @@ export interface ConversationAnnotationChange {
|
|
|
3454
3644
|
upsert: ConversationAnnotationInput;
|
|
3455
3645
|
}
|
|
3456
3646
|
/**
|
|
3457
|
-
* Close the open Inbox item of this plugin with the
|
|
3458
|
-
* item is open, such as after a person dismissed it.
|
|
3647
|
+
* Close the open Inbox item of this plugin with the subject. Do nothing when
|
|
3648
|
+
* no item is open, such as after a person dismissed it.
|
|
3459
3649
|
*/
|
|
3460
3650
|
export interface ConversationInboxItemChange {
|
|
3461
3651
|
close: {
|
|
3462
|
-
|
|
3652
|
+
subject: PluginInboxItemSubject;
|
|
3463
3653
|
reason: string;
|
|
3464
3654
|
status: "done" | "dismissed";
|
|
3465
3655
|
};
|
|
@@ -3657,6 +3847,22 @@ interface PromptHistory {
|
|
|
3657
3847
|
/** This plugin's prompt contexts in this history, oldest first. */
|
|
3658
3848
|
contexts: PromptHistoryContext[];
|
|
3659
3849
|
}
|
|
3850
|
+
/**
|
|
3851
|
+
* One message of the model history that a new prompt replays, oldest first,
|
|
3852
|
+
* without its content. `context` is a Turn context and `summary` is a
|
|
3853
|
+
* compaction summary; `contributions` holds the text of this plugin's
|
|
3854
|
+
* contributions in it, as the plugin wrote it.
|
|
3855
|
+
*/
|
|
3856
|
+
type PromptHistoryMessage = {
|
|
3857
|
+
type: "input";
|
|
3858
|
+
} | {
|
|
3859
|
+
type: "context" | "summary";
|
|
3860
|
+
contributions: string[];
|
|
3861
|
+
} | {
|
|
3862
|
+
type: "tool_result";
|
|
3863
|
+
tool_name: string;
|
|
3864
|
+
is_error: boolean;
|
|
3865
|
+
};
|
|
3660
3866
|
/** Runtime facts available while building plugin user prompt context. */
|
|
3661
3867
|
type UserPromptContext = Pick<PluginContext, "db" | "log" | "plugin"> & {
|
|
3662
3868
|
conversationId?: string;
|
|
@@ -3680,6 +3886,12 @@ type UserPromptContext = Pick<PluginContext, "db" | "log" | "plugin"> & {
|
|
|
3680
3886
|
* that the model still has. Undefined when the prompt has no Conversation.
|
|
3681
3887
|
*/
|
|
3682
3888
|
loadHistory?(): Promise<PromptHistory>;
|
|
3889
|
+
/**
|
|
3890
|
+
* Read the messages of the model history that this prompt replays, such as
|
|
3891
|
+
* to find what this plugin's contributions and tools already showed.
|
|
3892
|
+
* Undefined when the host has no history for the prompt.
|
|
3893
|
+
*/
|
|
3894
|
+
historyMessages?(): PromptHistoryMessage[];
|
|
3683
3895
|
actor?: Actor | undefined;
|
|
3684
3896
|
source: Source;
|
|
3685
3897
|
state: PluginState;
|
|
@@ -3939,125 +4151,24 @@ export declare function eventTriggerFiltersText(filters: readonly string[]): str
|
|
|
3939
4151
|
* "Pull request · pull request opened · filters: isDraft is false".
|
|
3940
4152
|
*/
|
|
3941
4153
|
export declare function eventTriggerText(resource: string, description: Pick<EventTriggerDescription, "events" | "filters">): string;
|
|
3942
|
-
/**
|
|
3943
|
-
|
|
3944
|
-
* `feat(api)!: Add retries`. The plugin that owns the code change parses it,
|
|
3945
|
-
* so the Inbox can lead with the words and show the rest as pills.
|
|
3946
|
-
*/
|
|
3947
|
-
export interface InboxItemSubjectTitleParts {
|
|
3948
|
-
/** The title without its type prefix, such as `Add retries`. */
|
|
3949
|
-
text: string;
|
|
3950
|
-
/** The change type as one word, such as `Feature`. Unset when unknown. */
|
|
3951
|
-
type?: string;
|
|
3952
|
-
/** The scope, such as `api`. */
|
|
3953
|
-
scope?: string;
|
|
3954
|
-
/** The title marks a breaking change, such as with `!`. */
|
|
3955
|
-
breaking?: boolean;
|
|
3956
|
-
}
|
|
3957
|
-
/** What a plugin item is about, such as a pull request. */
|
|
3958
|
-
export interface InboxItemSubjectInput {
|
|
3959
|
-
id: string;
|
|
3960
|
-
title?: string;
|
|
3961
|
-
url?: string;
|
|
3962
|
-
/** Set only for a code change whose title follows Conventional Commits. */
|
|
3963
|
-
titleParts?: InboxItemSubjectTitleParts;
|
|
3964
|
-
}
|
|
3965
|
-
/**
|
|
3966
|
-
* An item that a plugin puts in the Inbox: a notice for information,
|
|
3967
|
-
* or an ask that waits on its assignees.
|
|
3968
|
-
*/
|
|
3969
|
-
export interface PluginReviewNotice {
|
|
4154
|
+
/** People that a plugin reads outside a Turn. */
|
|
4155
|
+
export interface PluginUsers {
|
|
3970
4156
|
/**
|
|
3971
|
-
*
|
|
3972
|
-
*
|
|
4157
|
+
* Read one stored identity and the user it links to now, with every
|
|
4158
|
+
* identity of that user. A plugin that saved an identity id uses this to
|
|
4159
|
+
* find the person's other linked accounts later.
|
|
3973
4160
|
*/
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
* Stable key for what the notice is about. A plugin has at most one open
|
|
3979
|
-
* item for each key.
|
|
3980
|
-
*/
|
|
3981
|
-
dedupeKey: string;
|
|
3982
|
-
/** What the notice is about, such as a pull request. Search matches `id`. */
|
|
3983
|
-
subject?: InboxItemSubjectInput;
|
|
3984
|
-
/**
|
|
3985
|
-
* For an item that waits on its assignees, name their step, such as
|
|
3986
|
-
* `Ready to merge · #946`. It is the reason that the dashboard shows.
|
|
3987
|
-
*/
|
|
3988
|
-
title: string;
|
|
3989
|
-
/**
|
|
3990
|
-
* Buttons that answer the item, in display order, such as `Resume`. An
|
|
3991
|
-
* item with choices waits on its assignees. The first click closes it as
|
|
3992
|
-
* done and calls the plugin's `inboxItemAnswered` hook with the choice.
|
|
3993
|
-
* The answer starts no Turn: the plugin does the work.
|
|
3994
|
-
*/
|
|
3995
|
-
choices?: Array<{
|
|
3996
|
-
label: string;
|
|
3997
|
-
description?: string;
|
|
3998
|
-
}>;
|
|
3999
|
-
/**
|
|
4000
|
-
* The assignees must act, such as merge a pull request that is ready. The
|
|
4001
|
-
* item then waits on them: its Conversation shows in their Needs you, and
|
|
4002
|
-
* it counts in their Inbox. Leave it unset for a notice that is only for
|
|
4003
|
-
* information.
|
|
4004
|
-
*/
|
|
4005
|
-
waitsOnAssignees?: boolean;
|
|
4006
|
-
}
|
|
4007
|
-
/**
|
|
4008
|
-
* Inbox items that a plugin adds and closes from its own events. Each item
|
|
4009
|
-
* belongs to one Conversation. Core owns visibility, assignment rules, and
|
|
4010
|
-
* the Slack cards.
|
|
4011
|
-
*/
|
|
4012
|
-
export interface PluginInboxItems {
|
|
4013
|
-
/** Add an open item, or replace the content of the open one with the key. */
|
|
4014
|
-
upsert(notice: PluginReviewNotice): Promise<void>;
|
|
4015
|
-
/**
|
|
4016
|
-
* Close the open item with the key. Do nothing when no item is open, such
|
|
4017
|
-
* as after a person dismissed it. Return whether an open item closed.
|
|
4018
|
-
*/
|
|
4019
|
-
close(input: {
|
|
4020
|
-
dedupeKey: string;
|
|
4021
|
-
reason: string;
|
|
4022
|
-
status: "done" | "dismissed";
|
|
4023
|
-
}): Promise<boolean>;
|
|
4024
|
-
}
|
|
4025
|
-
/** Inbox items of a plugin, for the Conversation that each item belongs to. */
|
|
4026
|
-
export interface PluginConversationInboxItems {
|
|
4027
|
-
forConversation(conversationId: string): PluginInboxItems;
|
|
4028
|
-
}
|
|
4029
|
-
/** A person picked one of the `choices` of an item that this plugin added. */
|
|
4030
|
-
export interface InboxItemAnsweredHookContext extends PluginContext {
|
|
4031
|
-
/** The label of the picked choice. */
|
|
4032
|
-
choice: string;
|
|
4033
|
-
/** Junior's native code index, as from a plugin route. */
|
|
4034
|
-
codeChanges: PluginCodeChanges;
|
|
4035
|
-
/** The Conversation that the item belongs to. */
|
|
4036
|
-
conversationId: string;
|
|
4037
|
-
/** The plugin's own dedupe key of the item. */
|
|
4038
|
-
dedupeKey: string;
|
|
4039
|
-
/** Publish events, as from a plugin route. */
|
|
4040
|
-
events: EventPublisher;
|
|
4041
|
-
/** The closed item's id. It is the same on a retry of the same answer. */
|
|
4042
|
-
itemId: string;
|
|
4043
|
-
nowMs: number;
|
|
4044
|
-
/** Inbox items, as from a plugin route. */
|
|
4045
|
-
inboxItems: PluginConversationInboxItems;
|
|
4046
|
-
state: PluginState;
|
|
4047
|
-
/** Watches of the item's Conversation. */
|
|
4048
|
-
watches: PluginConversationWatches;
|
|
4049
|
-
}
|
|
4050
|
-
/** Watches of one Conversation, for a plugin outside a tool call. */
|
|
4051
|
-
export interface PluginConversationWatches extends PluginEventToolContext {
|
|
4161
|
+
readIdentity(identityId: string): Promise<{
|
|
4162
|
+
identity: Identity;
|
|
4163
|
+
user?: User;
|
|
4164
|
+
} | undefined>;
|
|
4052
4165
|
/**
|
|
4053
|
-
*
|
|
4054
|
-
*
|
|
4055
|
-
*
|
|
4166
|
+
* Find the people who linked these accounts of the plugin's provider,
|
|
4167
|
+
* such as GitHub logins, through account linking. Return each handle in
|
|
4168
|
+
* lower case with the id of the one user Identity that linked it. Leave
|
|
4169
|
+
* out a handle that nobody linked, or that two people linked.
|
|
4056
4170
|
*/
|
|
4057
|
-
|
|
4058
|
-
eventType: string;
|
|
4059
|
-
identifier: string;
|
|
4060
|
-
}): Promise<boolean>;
|
|
4171
|
+
findLinkedIdentityIds(handles: readonly string[]): Promise<Map<string, string>>;
|
|
4061
4172
|
}
|
|
4062
4173
|
export interface HeartbeatHookContext extends PluginContext {
|
|
4063
4174
|
agent: {
|
|
@@ -4083,6 +4194,8 @@ export interface HeartbeatHookContext extends PluginContext {
|
|
|
4083
4194
|
/** Inbox items, as from a plugin route. */
|
|
4084
4195
|
inboxItems: PluginConversationInboxItems;
|
|
4085
4196
|
state: PluginState;
|
|
4197
|
+
/** People, as from a plugin route. */
|
|
4198
|
+
users: PluginUsers;
|
|
4086
4199
|
/** Start this plugin's tasks, as from a plugin route. */
|
|
4087
4200
|
tasks: PluginTaskStarter;
|
|
4088
4201
|
}
|
|
@@ -4226,17 +4339,7 @@ export interface RouteRegistrationHookContext extends PluginContext {
|
|
|
4226
4339
|
* when a write fails and must run again after the route returns.
|
|
4227
4340
|
*/
|
|
4228
4341
|
tasks: PluginTaskStarter;
|
|
4229
|
-
users:
|
|
4230
|
-
/**
|
|
4231
|
-
* Read one stored identity and the user it links to now, with every
|
|
4232
|
-
* identity of that user. A plugin that saved an identity id uses this to
|
|
4233
|
-
* find the person's other linked accounts later.
|
|
4234
|
-
*/
|
|
4235
|
-
readIdentity(identityId: string): Promise<{
|
|
4236
|
-
identity: Identity;
|
|
4237
|
-
user?: User;
|
|
4238
|
-
} | undefined>;
|
|
4239
|
-
};
|
|
4342
|
+
users: PluginUsers;
|
|
4240
4343
|
}
|
|
4241
4344
|
export interface ApiRouteRegistrationHookContext extends PluginContext {
|
|
4242
4345
|
conversationEvents: PluginConversationEventReader;
|
|
@@ -4617,6 +4720,35 @@ export interface FormatMarkdownHookContext {
|
|
|
4617
4720
|
provider?: string;
|
|
4618
4721
|
text: string;
|
|
4619
4722
|
}
|
|
4723
|
+
/** One Conversation whose history a compaction replaces. */
|
|
4724
|
+
export type CompactionContextHookContext = Pick<PluginContext, "db" | "log" | "plugin"> & {
|
|
4725
|
+
conversationId: string;
|
|
4726
|
+
};
|
|
4727
|
+
/**
|
|
4728
|
+
* Conversations whose transcripts Junior purges. `db` is the purge
|
|
4729
|
+
* transaction, so content that the hook deletes goes with the transcript.
|
|
4730
|
+
*/
|
|
4731
|
+
export type PurgeConversationsHookContext = Pick<PluginContext, "db" | "log" | "plugin"> & {
|
|
4732
|
+
conversationIds: string[];
|
|
4733
|
+
};
|
|
4734
|
+
/** The child agent that lists its team, and its parent. */
|
|
4735
|
+
export type ParentAgentFieldContext = Pick<PluginContext, "db" | "log" | "plugin"> & {
|
|
4736
|
+
/** The child agent's Conversation. */
|
|
4737
|
+
conversationId: string;
|
|
4738
|
+
parentConversationId: string;
|
|
4739
|
+
};
|
|
4740
|
+
/**
|
|
4741
|
+
* A field that this plugin adds to the parent's entry when a child agent
|
|
4742
|
+
* lists its team. The field has the plugin's name.
|
|
4743
|
+
*/
|
|
4744
|
+
export interface ParentAgentField {
|
|
4745
|
+
/** What the field shows, such as "the parent's open tasks". */
|
|
4746
|
+
description: string;
|
|
4747
|
+
/** Output schema of the field. Describe it for the model. */
|
|
4748
|
+
schema: z.ZodType;
|
|
4749
|
+
/** Read the field value, or undefined to leave the field out. */
|
|
4750
|
+
load(ctx: ParentAgentFieldContext): Promise<unknown>;
|
|
4751
|
+
}
|
|
4620
4752
|
/** First human message of a new Conversation, given before title generation. */
|
|
4621
4753
|
export interface ConversationTitleContextHookContext extends PluginContext {
|
|
4622
4754
|
/**
|
|
@@ -4687,6 +4819,18 @@ export interface PluginHooks {
|
|
|
4687
4819
|
* failure, so it must be safe to repeat.
|
|
4688
4820
|
*/
|
|
4689
4821
|
inboxItemAnswered?(ctx: InboxItemAnsweredHookContext): Promise<void> | void;
|
|
4822
|
+
/**
|
|
4823
|
+
* Return state that the model must keep when a compaction replaces the
|
|
4824
|
+
* history, such as open work. Junior adds it to the compaction summary.
|
|
4825
|
+
*/
|
|
4826
|
+
compactionContext?(ctx: CompactionContextHookContext): Promise<PromptMessage[] | undefined> | PromptMessage[] | undefined;
|
|
4827
|
+
/**
|
|
4828
|
+
* Delete this plugin's content of Conversations whose transcripts Junior
|
|
4829
|
+
* purges, such as text that came from the transcript.
|
|
4830
|
+
*/
|
|
4831
|
+
purgeConversations?(ctx: PurgeConversationsHookContext): Promise<void>;
|
|
4832
|
+
/** Return the field that this plugin adds to a child agent's parent entry. */
|
|
4833
|
+
parentAgentField?(): ParentAgentField;
|
|
4690
4834
|
heartbeat?(ctx: HeartbeatHookContext): Promise<HeartbeatResult | void> | HeartbeatResult | void;
|
|
4691
4835
|
unfinishedWork?(ctx: UnfinishedWorkHookContext): Promise<UnfinishedWorkResult> | UnfinishedWorkResult;
|
|
4692
4836
|
issueCredential?(ctx: IssueCredentialHookContext): Promise<PluginCredentialResult> | PluginCredentialResult;
|
|
@@ -5074,6 +5218,8 @@ export type PluginRegistrationInput = {
|
|
|
5074
5218
|
hooks?: PluginHooks;
|
|
5075
5219
|
/** Images that this plugin serves through the Junior image proxy. */
|
|
5076
5220
|
images?: PluginImageSource;
|
|
5221
|
+
/** The kinds of Inbox items that this plugin adds. */
|
|
5222
|
+
inboxSubjects?: PluginInboxSubjectKind[];
|
|
5077
5223
|
manifest: PluginManifest;
|
|
5078
5224
|
model?: PluginModelConfig;
|
|
5079
5225
|
/** URLs that this plugin shows as object cards. */
|
|
@@ -5119,4 +5265,4 @@ export declare function markdownText(node: MarkdownNode, options?: MarkdownTextO
|
|
|
5119
5265
|
* each run of whitespace made one space.
|
|
5120
5266
|
*/
|
|
5121
5267
|
export declare function markdownPlainText(text: string, options?: MarkdownTextOptions): string;
|
|
5122
|
-
export type { PromptContext, PromptContextContribution, PromptHistory, PromptHistoryContext, PromptMessage, SystemPromptBuildContext, UserPromptContext, UserPromptContribution };
|
|
5268
|
+
export type { PromptContext, PromptContextContribution, PromptHistory, PromptHistoryContext, PromptHistoryMessage, PromptMessage, SystemPromptBuildContext, UserPromptContext, UserPromptContribution };
|
package/dist/index.js
CHANGED
|
@@ -45,6 +45,17 @@ const objectFactsSchema = z.discriminatedUnion("type", [
|
|
|
45
45
|
* `pending` while the provider computes it for a new head.
|
|
46
46
|
*/
|
|
47
47
|
mergeable: z.union([z.boolean(), z.literal("pending")]).optional(),
|
|
48
|
+
/**
|
|
49
|
+
* The title split by its change type, such as `feat(api)!: Add retries`,
|
|
50
|
+
* with the categories of the repository's release notes. Unset when the
|
|
51
|
+
* title names no change type.
|
|
52
|
+
*/
|
|
53
|
+
titleParts: z.strictObject({
|
|
54
|
+
breaking: z.boolean().optional(),
|
|
55
|
+
scope: text.optional(),
|
|
56
|
+
text: z.string().trim().min(1).max(512),
|
|
57
|
+
type: text.optional()
|
|
58
|
+
}).optional(),
|
|
48
59
|
changedFiles: count.optional(),
|
|
49
60
|
additions: count.optional(),
|
|
50
61
|
deletions: count.optional(),
|
|
@@ -946,6 +957,8 @@ const codeRepositoryInputSchema = z.object({
|
|
|
946
957
|
const codeChangeFilterSchema = z.object({
|
|
947
958
|
/** Code changes linked to any of these Conversations. */
|
|
948
959
|
conversationIds: z.array(z.string().min(1)).min(1).optional(),
|
|
960
|
+
/** Code changes with any of these provider ids. */
|
|
961
|
+
providerIds: z.array(z.string().min(1)).min(1).optional(),
|
|
949
962
|
repository: z.object({
|
|
950
963
|
/** The repository name. Junior matches it in any case. */
|
|
951
964
|
name: z.string().min(1),
|
|
@@ -2702,6 +2715,14 @@ function skipHeredocBody(text, newlineIndex, heredoc) {
|
|
|
2702
2715
|
}
|
|
2703
2716
|
// src/registration.ts
|
|
2704
2717
|
const PLUGIN_NAME_RE = /^[a-z][a-z0-9-]*$/;
|
|
2718
|
+
const INBOX_SUBJECT_KIND_RE = /^[a-z][a-z0-9_]*$/;
|
|
2719
|
+
const SQL_IDENTIFIER_RE = /^[a-z][a-z0-9_]{0,62}$/;
|
|
2720
|
+
const CORE_INBOX_SUBJECT_NAMESPACES = /* @__PURE__ */ new Set([
|
|
2721
|
+
"automation",
|
|
2722
|
+
"question",
|
|
2723
|
+
"reply",
|
|
2724
|
+
"todo"
|
|
2725
|
+
]);
|
|
2705
2726
|
const USER_PAGE_ID_RE = /^[a-z][a-z0-9-]*$/;
|
|
2706
2727
|
/** Define one Junior plugin registration for app and build-time wiring. */
|
|
2707
2728
|
function defineJuniorPlugin(plugin) {
|
|
@@ -2713,6 +2734,7 @@ function defineJuniorPlugin(plugin) {
|
|
|
2713
2734
|
if (!name) throw new Error("Plugin manifest.name is required.");
|
|
2714
2735
|
if (!PLUGIN_NAME_RE.test(name)) throw new Error(`Plugin registration name "${name}" must be a lowercase plugin identifier.`);
|
|
2715
2736
|
if (name === "junior") throw new Error("Plugin registration name \"junior\" is reserved for native host events.");
|
|
2737
|
+
if (CORE_INBOX_SUBJECT_NAMESPACES.has(name)) throw new Error(`Plugin registration name "${name}" is reserved for core Inbox items.`);
|
|
2716
2738
|
if (typeof manifest.displayName !== "string" || !manifest.displayName.trim()) throw new Error(`Plugin "${name}" manifest.displayName is required.`);
|
|
2717
2739
|
if (typeof manifest.description !== "string" || !manifest.description.trim()) throw new Error(`Plugin "${name}" manifest.description is required.`);
|
|
2718
2740
|
if (plugin.userPages !== void 0 && !Array.isArray(plugin.userPages)) throw new Error(`Plugin "${name}" userPages must be an array.`);
|
|
@@ -2722,6 +2744,7 @@ function defineJuniorPlugin(plugin) {
|
|
|
2722
2744
|
if (!parsed.success) throw new Error(`Plugin "${name}" events is invalid.`, { cause: parsed.error });
|
|
2723
2745
|
}
|
|
2724
2746
|
validateObjectLinks(name, plugin.objectLinks);
|
|
2747
|
+
validateInboxSubjects(name, plugin.inboxSubjects);
|
|
2725
2748
|
if (plugin.images !== void 0 && typeof plugin.images.resolve !== "function") throw new Error(`Plugin "${name}" images must have a resolve function.`);
|
|
2726
2749
|
const conversationEventIds = /* @__PURE__ */ new Set();
|
|
2727
2750
|
for (const event of plugin.conversationEvents ?? []) {
|
|
@@ -2754,6 +2777,22 @@ function validateObjectLinks(name, links) {
|
|
|
2754
2777
|
}
|
|
2755
2778
|
}
|
|
2756
2779
|
}
|
|
2780
|
+
function validateInboxSubjects(name, kinds) {
|
|
2781
|
+
if (kinds === void 0) return;
|
|
2782
|
+
if (!Array.isArray(kinds)) throw new Error(`Plugin "${name}" inboxSubjects must be an array.`);
|
|
2783
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2784
|
+
for (const subject of kinds) {
|
|
2785
|
+
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
|
+
const owner = subject.owner;
|
|
2787
|
+
if (![
|
|
2788
|
+
owner?.table,
|
|
2789
|
+
owner?.subjectId,
|
|
2790
|
+
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.`);
|
|
2792
|
+
if (seen.has(subject.kind)) throw new Error(`Plugin "${name}" has duplicate inbox subject kind "${subject.kind}".`);
|
|
2793
|
+
seen.add(subject.kind);
|
|
2794
|
+
}
|
|
2795
|
+
}
|
|
2757
2796
|
// src/markdown.ts
|
|
2758
2797
|
/**
|
|
2759
2798
|
* Parse GitHub-flavored Markdown. Each node position holds offsets into
|