@sentry/junior-plugin-api 0.315.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 +584 -424
- 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>;
|
|
@@ -1502,6 +1520,11 @@ export interface PluginEgressRequest {
|
|
|
1502
1520
|
* grant classification.
|
|
1503
1521
|
*/
|
|
1504
1522
|
bodyText?: string;
|
|
1523
|
+
/**
|
|
1524
|
+
* Conversation of a Sandbox request, from its signed credential context.
|
|
1525
|
+
* Use it to limit what one Conversation spends, never to grant access.
|
|
1526
|
+
*/
|
|
1527
|
+
conversationId?: string;
|
|
1505
1528
|
/** Set for every Git `git-receive-pack` POST. */
|
|
1506
1529
|
gitPush?: PluginGitPush;
|
|
1507
1530
|
/** Set for every POST to a URL path that ends in `/graphql`. */
|
|
@@ -1705,6 +1728,12 @@ export declare const conversationAnnotationInputSchema: z.ZodDiscriminatedUnion<
|
|
|
1705
1728
|
pending: z.ZodNumber;
|
|
1706
1729
|
}, z.core.$strict>, z.ZodLiteral<"pending">]>>;
|
|
1707
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>>;
|
|
1708
1737
|
changedFiles: z.ZodOptional<z.ZodNumber>;
|
|
1709
1738
|
additions: z.ZodOptional<z.ZodNumber>;
|
|
1710
1739
|
deletions: z.ZodOptional<z.ZodNumber>;
|
|
@@ -1984,6 +2013,7 @@ export declare const codeRepositoryInputSchema: z.ZodObject<{
|
|
|
1984
2013
|
export type CodeRepositoryInput = z.input<typeof codeRepositoryInputSchema>;
|
|
1985
2014
|
export declare const codeChangeFilterSchema: z.ZodObject<{
|
|
1986
2015
|
conversationIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2016
|
+
providerIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1987
2017
|
repository: z.ZodOptional<z.ZodObject<{
|
|
1988
2018
|
name: z.ZodString;
|
|
1989
2019
|
numbers: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
@@ -2776,6 +2806,12 @@ export declare const pluginToolOutputSchema: z.ZodObject<{
|
|
|
2776
2806
|
pending: z.ZodNumber;
|
|
2777
2807
|
}, z.core.$strict>, z.ZodLiteral<"pending">]>>;
|
|
2778
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>>;
|
|
2779
2815
|
changedFiles: z.ZodOptional<z.ZodNumber>;
|
|
2780
2816
|
additions: z.ZodOptional<z.ZodNumber>;
|
|
2781
2817
|
deletions: z.ZodOptional<z.ZodNumber>;
|
|
@@ -3441,6 +3477,165 @@ export interface PluginObjectLinkDefinition {
|
|
|
3441
3477
|
*/
|
|
3442
3478
|
readTool?(object: ObjectAnnotation): string | undefined;
|
|
3443
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
|
+
}
|
|
3444
3639
|
/** Most entries in one batch, annotations and Inbox items together. */
|
|
3445
3640
|
export declare const MAX_CONVERSATION_CHANGES = 100;
|
|
3446
3641
|
/** Add or replace one annotation of this plugin on a Conversation. */
|
|
@@ -3449,12 +3644,12 @@ export interface ConversationAnnotationChange {
|
|
|
3449
3644
|
upsert: ConversationAnnotationInput;
|
|
3450
3645
|
}
|
|
3451
3646
|
/**
|
|
3452
|
-
* Close the open Inbox item of this plugin with the
|
|
3453
|
-
* 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.
|
|
3454
3649
|
*/
|
|
3455
3650
|
export interface ConversationInboxItemChange {
|
|
3456
3651
|
close: {
|
|
3457
|
-
|
|
3652
|
+
subject: PluginInboxItemSubject;
|
|
3458
3653
|
reason: string;
|
|
3459
3654
|
status: "done" | "dismissed";
|
|
3460
3655
|
};
|
|
@@ -3652,6 +3847,22 @@ interface PromptHistory {
|
|
|
3652
3847
|
/** This plugin's prompt contexts in this history, oldest first. */
|
|
3653
3848
|
contexts: PromptHistoryContext[];
|
|
3654
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
|
+
};
|
|
3655
3866
|
/** Runtime facts available while building plugin user prompt context. */
|
|
3656
3867
|
type UserPromptContext = Pick<PluginContext, "db" | "log" | "plugin"> & {
|
|
3657
3868
|
conversationId?: string;
|
|
@@ -3675,6 +3886,12 @@ type UserPromptContext = Pick<PluginContext, "db" | "log" | "plugin"> & {
|
|
|
3675
3886
|
* that the model still has. Undefined when the prompt has no Conversation.
|
|
3676
3887
|
*/
|
|
3677
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[];
|
|
3678
3895
|
actor?: Actor | undefined;
|
|
3679
3896
|
source: Source;
|
|
3680
3897
|
state: PluginState;
|
|
@@ -3934,415 +4151,24 @@ export declare function eventTriggerFiltersText(filters: readonly string[]): str
|
|
|
3934
4151
|
* "Pull request · pull request opened · filters: isDraft is false".
|
|
3935
4152
|
*/
|
|
3936
4153
|
export declare function eventTriggerText(resource: string, description: Pick<EventTriggerDescription, "events" | "filters">): string;
|
|
3937
|
-
/**
|
|
3938
|
-
|
|
3939
|
-
* instruction or ambient context, plus the actor identity when known. Missing
|
|
3940
|
-
* provenance on an entry means unattributed context.
|
|
3941
|
-
*/
|
|
3942
|
-
export declare const pluginRunTranscriptProvenanceSchema: z.ZodObject<{
|
|
3943
|
-
authority: z.ZodEnum<{
|
|
3944
|
-
context: "context";
|
|
3945
|
-
instruction: "instruction";
|
|
3946
|
-
}>;
|
|
3947
|
-
actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
3948
|
-
email: z.ZodOptional<z.ZodString>;
|
|
3949
|
-
fullName: z.ZodOptional<z.ZodString>;
|
|
3950
|
-
userId: z.ZodString;
|
|
3951
|
-
userName: z.ZodOptional<z.ZodString>;
|
|
3952
|
-
platform: z.ZodLiteral<"slack">;
|
|
3953
|
-
teamId: z.ZodString;
|
|
3954
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
3955
|
-
email: z.ZodOptional<z.ZodString>;
|
|
3956
|
-
fullName: z.ZodOptional<z.ZodString>;
|
|
3957
|
-
userId: z.ZodString;
|
|
3958
|
-
userName: z.ZodOptional<z.ZodString>;
|
|
3959
|
-
platform: z.ZodLiteral<"local">;
|
|
3960
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
3961
|
-
email: z.ZodOptional<z.ZodString>;
|
|
3962
|
-
fullName: z.ZodOptional<z.ZodString>;
|
|
3963
|
-
userId: z.ZodString;
|
|
3964
|
-
userName: z.ZodOptional<z.ZodString>;
|
|
3965
|
-
platform: z.ZodLiteral<"web">;
|
|
3966
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
3967
|
-
platform: z.ZodLiteral<"system">;
|
|
3968
|
-
name: z.ZodString;
|
|
3969
|
-
}, z.core.$strict>], "platform">>;
|
|
3970
|
-
}, z.core.$strict>;
|
|
3971
|
-
/** One normalized transcript entry from the completed run exposed to plugin tasks. */
|
|
3972
|
-
export declare const pluginRunTranscriptEntrySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
3973
|
-
type: z.ZodLiteral<"message">;
|
|
3974
|
-
role: z.ZodEnum<{
|
|
3975
|
-
assistant: "assistant";
|
|
3976
|
-
user: "user";
|
|
3977
|
-
}>;
|
|
3978
|
-
text: z.ZodString;
|
|
3979
|
-
provenance: z.ZodOptional<z.ZodObject<{
|
|
3980
|
-
authority: z.ZodEnum<{
|
|
3981
|
-
context: "context";
|
|
3982
|
-
instruction: "instruction";
|
|
3983
|
-
}>;
|
|
3984
|
-
actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
3985
|
-
email: z.ZodOptional<z.ZodString>;
|
|
3986
|
-
fullName: z.ZodOptional<z.ZodString>;
|
|
3987
|
-
userId: z.ZodString;
|
|
3988
|
-
userName: z.ZodOptional<z.ZodString>;
|
|
3989
|
-
platform: z.ZodLiteral<"slack">;
|
|
3990
|
-
teamId: z.ZodString;
|
|
3991
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
3992
|
-
email: z.ZodOptional<z.ZodString>;
|
|
3993
|
-
fullName: z.ZodOptional<z.ZodString>;
|
|
3994
|
-
userId: z.ZodString;
|
|
3995
|
-
userName: z.ZodOptional<z.ZodString>;
|
|
3996
|
-
platform: z.ZodLiteral<"local">;
|
|
3997
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
3998
|
-
email: z.ZodOptional<z.ZodString>;
|
|
3999
|
-
fullName: z.ZodOptional<z.ZodString>;
|
|
4000
|
-
userId: z.ZodString;
|
|
4001
|
-
userName: z.ZodOptional<z.ZodString>;
|
|
4002
|
-
platform: z.ZodLiteral<"web">;
|
|
4003
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
4004
|
-
platform: z.ZodLiteral<"system">;
|
|
4005
|
-
name: z.ZodString;
|
|
4006
|
-
}, z.core.$strict>], "platform">>;
|
|
4007
|
-
}, z.core.$strict>>;
|
|
4008
|
-
isRunActor: z.ZodOptional<z.ZodBoolean>;
|
|
4009
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
4010
|
-
type: z.ZodLiteral<"toolResult">;
|
|
4011
|
-
toolName: z.ZodString;
|
|
4012
|
-
isError: z.ZodBoolean;
|
|
4013
|
-
text: z.ZodOptional<z.ZodString>;
|
|
4014
|
-
}, z.core.$strict>], "type">;
|
|
4015
|
-
export type PluginRunTranscriptProvenance = z.output<typeof pluginRunTranscriptProvenanceSchema>;
|
|
4016
|
-
/** Runtime-owned completed-run projection exposed to plugin tasks. */
|
|
4017
|
-
export declare const pluginRunContextSchema: z.ZodObject<{
|
|
4018
|
-
actorUserId: z.ZodOptional<z.ZodString>;
|
|
4019
|
-
completedAtMs: z.ZodNumber;
|
|
4020
|
-
conversationId: z.ZodString;
|
|
4021
|
-
destination: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
4022
|
-
platform: z.ZodLiteral<"slack">;
|
|
4023
|
-
teamId: z.ZodString;
|
|
4024
|
-
channelId: z.ZodString;
|
|
4025
|
-
threadTs: z.ZodOptional<z.ZodString>;
|
|
4026
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
4027
|
-
platform: z.ZodLiteral<"local">;
|
|
4028
|
-
conversationId: z.ZodString;
|
|
4029
|
-
}, z.core.$strict>], "platform">;
|
|
4030
|
-
locationId: z.ZodOptional<z.ZodString>;
|
|
4031
|
-
actors: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
4032
|
-
email: z.ZodOptional<z.ZodString>;
|
|
4033
|
-
fullName: z.ZodOptional<z.ZodString>;
|
|
4034
|
-
userId: z.ZodString;
|
|
4035
|
-
userName: z.ZodOptional<z.ZodString>;
|
|
4036
|
-
platform: z.ZodLiteral<"slack">;
|
|
4037
|
-
teamId: z.ZodString;
|
|
4038
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
4039
|
-
email: z.ZodOptional<z.ZodString>;
|
|
4040
|
-
fullName: z.ZodOptional<z.ZodString>;
|
|
4041
|
-
userId: z.ZodString;
|
|
4042
|
-
userName: z.ZodOptional<z.ZodString>;
|
|
4043
|
-
platform: z.ZodLiteral<"local">;
|
|
4044
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
4045
|
-
email: z.ZodOptional<z.ZodString>;
|
|
4046
|
-
fullName: z.ZodOptional<z.ZodString>;
|
|
4047
|
-
userId: z.ZodString;
|
|
4048
|
-
userName: z.ZodOptional<z.ZodString>;
|
|
4049
|
-
platform: z.ZodLiteral<"web">;
|
|
4050
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
4051
|
-
platform: z.ZodLiteral<"system">;
|
|
4052
|
-
name: z.ZodString;
|
|
4053
|
-
}, z.core.$strict>], "platform">>;
|
|
4054
|
-
actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
4055
|
-
email: z.ZodOptional<z.ZodString>;
|
|
4056
|
-
fullName: z.ZodOptional<z.ZodString>;
|
|
4057
|
-
userId: z.ZodString;
|
|
4058
|
-
userName: z.ZodOptional<z.ZodString>;
|
|
4059
|
-
platform: z.ZodLiteral<"slack">;
|
|
4060
|
-
teamId: z.ZodString;
|
|
4061
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
4062
|
-
email: z.ZodOptional<z.ZodString>;
|
|
4063
|
-
fullName: z.ZodOptional<z.ZodString>;
|
|
4064
|
-
userId: z.ZodString;
|
|
4065
|
-
userName: z.ZodOptional<z.ZodString>;
|
|
4066
|
-
platform: z.ZodLiteral<"local">;
|
|
4067
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
4068
|
-
email: z.ZodOptional<z.ZodString>;
|
|
4069
|
-
fullName: z.ZodOptional<z.ZodString>;
|
|
4070
|
-
userId: z.ZodString;
|
|
4071
|
-
userName: z.ZodOptional<z.ZodString>;
|
|
4072
|
-
platform: z.ZodLiteral<"web">;
|
|
4073
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
4074
|
-
platform: z.ZodLiteral<"system">;
|
|
4075
|
-
name: z.ZodString;
|
|
4076
|
-
}, z.core.$strict>], "platform">>;
|
|
4077
|
-
runId: z.ZodString;
|
|
4078
|
-
source: z.ZodPreprocess<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
4079
|
-
kind: z.ZodLiteral<"slack">;
|
|
4080
|
-
teamId: z.ZodString;
|
|
4081
|
-
channelId: z.ZodString;
|
|
4082
|
-
visibility: z.ZodEnum<{
|
|
4083
|
-
private: "private";
|
|
4084
|
-
public: "public";
|
|
4085
|
-
}>;
|
|
4086
|
-
messageTs: z.ZodOptional<z.ZodString>;
|
|
4087
|
-
threadTs: z.ZodOptional<z.ZodString>;
|
|
4088
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
4089
|
-
kind: z.ZodLiteral<"local">;
|
|
4090
|
-
visibility: z.ZodLiteral<"private">;
|
|
4091
|
-
conversationId: z.ZodString;
|
|
4092
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
4093
|
-
kind: z.ZodLiteral<"web">;
|
|
4094
|
-
visibility: z.ZodEnum<{
|
|
4095
|
-
private: "private";
|
|
4096
|
-
public: "public";
|
|
4097
|
-
}>;
|
|
4098
|
-
conversationId: z.ZodString;
|
|
4099
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
4100
|
-
kind: z.ZodLiteral<"event">;
|
|
4101
|
-
eventKey: z.ZodString;
|
|
4102
|
-
eventType: z.ZodString;
|
|
4103
|
-
identifier: z.ZodString;
|
|
4104
|
-
namespace: z.ZodString;
|
|
4105
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
4106
|
-
automationId: z.ZodOptional<z.ZodString>;
|
|
4107
|
-
automationRunId: z.ZodOptional<z.ZodString>;
|
|
4108
|
-
kind: z.ZodLiteral<"scheduled_automation">;
|
|
4109
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
4110
|
-
automationId: z.ZodOptional<z.ZodString>;
|
|
4111
|
-
automationRunId: z.ZodOptional<z.ZodString>;
|
|
4112
|
-
kind: z.ZodLiteral<"event_automation">;
|
|
4113
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
4114
|
-
kind: z.ZodLiteral<"plugin_dispatch">;
|
|
4115
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
4116
|
-
kind: z.ZodLiteral<"parent_message">;
|
|
4117
|
-
}, z.core.$strict>], "kind">, unknown>;
|
|
4118
|
-
transcript: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
4119
|
-
type: z.ZodLiteral<"message">;
|
|
4120
|
-
role: z.ZodEnum<{
|
|
4121
|
-
assistant: "assistant";
|
|
4122
|
-
user: "user";
|
|
4123
|
-
}>;
|
|
4124
|
-
text: z.ZodString;
|
|
4125
|
-
provenance: z.ZodOptional<z.ZodObject<{
|
|
4126
|
-
authority: z.ZodEnum<{
|
|
4127
|
-
context: "context";
|
|
4128
|
-
instruction: "instruction";
|
|
4129
|
-
}>;
|
|
4130
|
-
actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
4131
|
-
email: z.ZodOptional<z.ZodString>;
|
|
4132
|
-
fullName: z.ZodOptional<z.ZodString>;
|
|
4133
|
-
userId: z.ZodString;
|
|
4134
|
-
userName: z.ZodOptional<z.ZodString>;
|
|
4135
|
-
platform: z.ZodLiteral<"slack">;
|
|
4136
|
-
teamId: z.ZodString;
|
|
4137
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
4138
|
-
email: z.ZodOptional<z.ZodString>;
|
|
4139
|
-
fullName: z.ZodOptional<z.ZodString>;
|
|
4140
|
-
userId: z.ZodString;
|
|
4141
|
-
userName: z.ZodOptional<z.ZodString>;
|
|
4142
|
-
platform: z.ZodLiteral<"local">;
|
|
4143
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
4144
|
-
email: z.ZodOptional<z.ZodString>;
|
|
4145
|
-
fullName: z.ZodOptional<z.ZodString>;
|
|
4146
|
-
userId: z.ZodString;
|
|
4147
|
-
userName: z.ZodOptional<z.ZodString>;
|
|
4148
|
-
platform: z.ZodLiteral<"web">;
|
|
4149
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
4150
|
-
platform: z.ZodLiteral<"system">;
|
|
4151
|
-
name: z.ZodString;
|
|
4152
|
-
}, z.core.$strict>], "platform">>;
|
|
4153
|
-
}, z.core.$strict>>;
|
|
4154
|
-
isRunActor: z.ZodOptional<z.ZodBoolean>;
|
|
4155
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
4156
|
-
type: z.ZodLiteral<"toolResult">;
|
|
4157
|
-
toolName: z.ZodString;
|
|
4158
|
-
isError: z.ZodBoolean;
|
|
4159
|
-
text: z.ZodOptional<z.ZodString>;
|
|
4160
|
-
}, z.core.$strict>], "type">>;
|
|
4161
|
-
}, z.core.$strict>;
|
|
4162
|
-
export type PluginRunTranscriptEntry = z.output<typeof pluginRunTranscriptEntrySchema>;
|
|
4163
|
-
export type PluginRunContext = z.output<typeof pluginRunContextSchema>;
|
|
4164
|
-
/** Runtime context passed to a plugin-owned background task. */
|
|
4165
|
-
export interface PluginTaskContext extends PluginContext {
|
|
4166
|
-
embedder: PluginEmbedder;
|
|
4167
|
-
events: PluginConversationEvents;
|
|
4168
|
-
id: string;
|
|
4169
|
-
model: PluginModel;
|
|
4170
|
-
name: string;
|
|
4171
|
-
run: {
|
|
4172
|
-
load(): Promise<PluginRunContext>;
|
|
4173
|
-
};
|
|
4174
|
-
state: PluginState;
|
|
4175
|
-
/** Events that this plugin emitted in the completed Turn, oldest first. */
|
|
4176
|
-
turnEvents: PluginTurnEventReader;
|
|
4177
|
-
}
|
|
4178
|
-
/** Task that Junior runs after each completed session. */
|
|
4179
|
-
export interface PluginSessionTaskDefinition {
|
|
4180
|
-
payload?: undefined;
|
|
4181
|
-
run(ctx: PluginTaskContext): Promise<void> | void;
|
|
4182
|
-
}
|
|
4183
|
-
/** Runtime context passed to one attempt of a task that `tasks.start` started. */
|
|
4184
|
-
export interface PluginStartedTaskContext<Payload = unknown> extends PluginContext {
|
|
4185
|
-
annotations: PluginConversationAnnotations;
|
|
4186
|
-
codeChanges: PluginCodeChanges;
|
|
4187
|
-
conversationChanges: PluginConversationChanges;
|
|
4188
|
-
/** Publishes the plugin's Events, as the heartbeat and routes do. */
|
|
4189
|
-
events: EventPublisher;
|
|
4190
|
-
/**
|
|
4191
|
-
* True on the last delivery that Junior makes. An attempt that throws
|
|
4192
|
-
* now is not run again, so a task that waits for a provider can write
|
|
4193
|
-
* its fallback instead.
|
|
4194
|
-
*/
|
|
4195
|
-
lastDelivery: boolean;
|
|
4196
|
-
name: string;
|
|
4197
|
-
/** The payload from `tasks.start`, parsed with the task's `payload` schema. */
|
|
4198
|
-
payload: Payload;
|
|
4199
|
-
state: PluginState;
|
|
4200
|
-
}
|
|
4201
|
-
/**
|
|
4202
|
-
* Task that runs only when the plugin starts it with `tasks.start`. Junior
|
|
4203
|
-
* sends the payload as JSON in the queue message and parses it with
|
|
4204
|
-
* `payload` before each attempt. A failed attempt runs again later, a
|
|
4205
|
-
* bounded number of times.
|
|
4206
|
-
*/
|
|
4207
|
-
export interface PluginStartedTaskDefinition<Schema extends z.ZodType = z.ZodType> {
|
|
4208
|
-
payload: Schema;
|
|
4209
|
-
run(ctx: PluginStartedTaskContext<z.output<Schema>>): Promise<void> | void;
|
|
4210
|
-
}
|
|
4211
|
-
/** Plugin task handler registered by name in a plugin manifest module. */
|
|
4212
|
-
export type PluginTaskDefinition = PluginSessionTaskDefinition | PluginStartedTaskDefinition;
|
|
4213
|
-
/** Task handlers keyed by the plugin-owned task name. */
|
|
4214
|
-
export type PluginTasks = Record<string, PluginTaskDefinition>;
|
|
4215
|
-
/** Input of `tasks.start`. */
|
|
4216
|
-
export declare const pluginTaskStartInputSchema: z.ZodObject<{
|
|
4217
|
-
key: z.ZodString;
|
|
4218
|
-
name: z.ZodString;
|
|
4219
|
-
delaySeconds: z.ZodOptional<z.ZodNumber>;
|
|
4220
|
-
payload: z.ZodUnknown;
|
|
4221
|
-
}, z.core.$strict>;
|
|
4222
|
-
export type PluginTaskStartInput = z.output<typeof pluginTaskStartInputSchema>;
|
|
4223
|
-
/** Starts this plugin's tasks on the plugin task queue. */
|
|
4224
|
-
export interface PluginTaskStarter {
|
|
4225
|
-
start(input: PluginTaskStartInput): Promise<void>;
|
|
4226
|
-
}
|
|
4227
|
-
/**
|
|
4228
|
-
* A code change title split by Conventional Commits, such as
|
|
4229
|
-
* `feat(api)!: Add retries`. The plugin that owns the code change parses it,
|
|
4230
|
-
* so the Inbox can lead with the words and show the rest as pills.
|
|
4231
|
-
*/
|
|
4232
|
-
export interface InboxItemSubjectTitleParts {
|
|
4233
|
-
/** The title without its type prefix, such as `Add retries`. */
|
|
4234
|
-
text: string;
|
|
4235
|
-
/** The change type as one word, such as `Feature`. Unset when unknown. */
|
|
4236
|
-
type?: string;
|
|
4237
|
-
/** The scope, such as `api`. */
|
|
4238
|
-
scope?: string;
|
|
4239
|
-
/** The title marks a breaking change, such as with `!`. */
|
|
4240
|
-
breaking?: boolean;
|
|
4241
|
-
}
|
|
4242
|
-
/** What a plugin item is about, such as a pull request. */
|
|
4243
|
-
export interface InboxItemSubjectInput {
|
|
4244
|
-
id: string;
|
|
4245
|
-
title?: string;
|
|
4246
|
-
url?: string;
|
|
4247
|
-
/** Set only for a code change whose title follows Conventional Commits. */
|
|
4248
|
-
titleParts?: InboxItemSubjectTitleParts;
|
|
4249
|
-
}
|
|
4250
|
-
/**
|
|
4251
|
-
* An item that a plugin puts in the Inbox: a notice for information,
|
|
4252
|
-
* or an ask that waits on its assignees.
|
|
4253
|
-
*/
|
|
4254
|
-
export interface PluginReviewNotice {
|
|
4255
|
-
/**
|
|
4256
|
-
* Junior assigns the User linked to each Identity, but only when that User
|
|
4257
|
-
* is in the notice's Conversation. It leaves out the others.
|
|
4258
|
-
*/
|
|
4259
|
-
assigneeIdentityIds: string[];
|
|
4260
|
-
/** Markdown details for the person. */
|
|
4261
|
-
body: string;
|
|
4262
|
-
/**
|
|
4263
|
-
* Stable key for what the notice is about. A plugin has at most one open
|
|
4264
|
-
* item for each key.
|
|
4265
|
-
*/
|
|
4266
|
-
dedupeKey: string;
|
|
4267
|
-
/** What the notice is about, such as a pull request. Search matches `id`. */
|
|
4268
|
-
subject?: InboxItemSubjectInput;
|
|
4269
|
-
/**
|
|
4270
|
-
* For an item that waits on its assignees, name their step, such as
|
|
4271
|
-
* `Ready to merge · #946`. It is the reason that the dashboard shows.
|
|
4272
|
-
*/
|
|
4273
|
-
title: string;
|
|
4274
|
-
/**
|
|
4275
|
-
* Buttons that answer the item, in display order, such as `Resume`. An
|
|
4276
|
-
* item with choices waits on its assignees. The first click closes it as
|
|
4277
|
-
* done and calls the plugin's `inboxItemAnswered` hook with the choice.
|
|
4278
|
-
* The answer starts no Turn: the plugin does the work.
|
|
4279
|
-
*/
|
|
4280
|
-
choices?: Array<{
|
|
4281
|
-
label: string;
|
|
4282
|
-
description?: string;
|
|
4283
|
-
}>;
|
|
4284
|
-
/**
|
|
4285
|
-
* The assignees must act, such as merge a pull request that is ready. The
|
|
4286
|
-
* item then waits on them: its Conversation shows in their Needs you, and
|
|
4287
|
-
* it counts in their Inbox. Leave it unset for a notice that is only for
|
|
4288
|
-
* information.
|
|
4289
|
-
*/
|
|
4290
|
-
waitsOnAssignees?: boolean;
|
|
4291
|
-
}
|
|
4292
|
-
/**
|
|
4293
|
-
* Inbox items that a plugin adds and closes from its own events. Each item
|
|
4294
|
-
* belongs to one Conversation. Core owns visibility, assignment rules, and
|
|
4295
|
-
* the Slack cards.
|
|
4296
|
-
*/
|
|
4297
|
-
export interface PluginInboxItems {
|
|
4298
|
-
/** Add an open item, or replace the content of the open one with the key. */
|
|
4299
|
-
upsert(notice: PluginReviewNotice): Promise<void>;
|
|
4154
|
+
/** People that a plugin reads outside a Turn. */
|
|
4155
|
+
export interface PluginUsers {
|
|
4300
4156
|
/**
|
|
4301
|
-
*
|
|
4302
|
-
*
|
|
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.
|
|
4303
4160
|
*/
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
}): Promise<boolean>;
|
|
4309
|
-
}
|
|
4310
|
-
/** Inbox items of a plugin, for the Conversation that each item belongs to. */
|
|
4311
|
-
export interface PluginConversationInboxItems {
|
|
4312
|
-
forConversation(conversationId: string): PluginInboxItems;
|
|
4313
|
-
}
|
|
4314
|
-
/** A person picked one of the `choices` of an item that this plugin added. */
|
|
4315
|
-
export interface InboxItemAnsweredHookContext extends PluginContext {
|
|
4316
|
-
/** The label of the picked choice. */
|
|
4317
|
-
choice: string;
|
|
4318
|
-
/** Junior's native code index, as from a plugin route. */
|
|
4319
|
-
codeChanges: PluginCodeChanges;
|
|
4320
|
-
/** The Conversation that the item belongs to. */
|
|
4321
|
-
conversationId: string;
|
|
4322
|
-
/** The plugin's own dedupe key of the item. */
|
|
4323
|
-
dedupeKey: string;
|
|
4324
|
-
/** Publish events, as from a plugin route. */
|
|
4325
|
-
events: EventPublisher;
|
|
4326
|
-
/** The closed item's id. It is the same on a retry of the same answer. */
|
|
4327
|
-
itemId: string;
|
|
4328
|
-
nowMs: number;
|
|
4329
|
-
/** Inbox items, as from a plugin route. */
|
|
4330
|
-
inboxItems: PluginConversationInboxItems;
|
|
4331
|
-
state: PluginState;
|
|
4332
|
-
/** Watches of the item's Conversation. */
|
|
4333
|
-
watches: PluginConversationWatches;
|
|
4334
|
-
}
|
|
4335
|
-
/** Watches of one Conversation, for a plugin outside a tool call. */
|
|
4336
|
-
export interface PluginConversationWatches extends PluginEventToolContext {
|
|
4161
|
+
readIdentity(identityId: string): Promise<{
|
|
4162
|
+
identity: Identity;
|
|
4163
|
+
user?: User;
|
|
4164
|
+
} | undefined>;
|
|
4337
4165
|
/**
|
|
4338
|
-
*
|
|
4339
|
-
*
|
|
4340
|
-
*
|
|
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.
|
|
4341
4170
|
*/
|
|
4342
|
-
|
|
4343
|
-
eventType: string;
|
|
4344
|
-
identifier: string;
|
|
4345
|
-
}): Promise<boolean>;
|
|
4171
|
+
findLinkedIdentityIds(handles: readonly string[]): Promise<Map<string, string>>;
|
|
4346
4172
|
}
|
|
4347
4173
|
export interface HeartbeatHookContext extends PluginContext {
|
|
4348
4174
|
agent: {
|
|
@@ -4368,6 +4194,8 @@ export interface HeartbeatHookContext extends PluginContext {
|
|
|
4368
4194
|
/** Inbox items, as from a plugin route. */
|
|
4369
4195
|
inboxItems: PluginConversationInboxItems;
|
|
4370
4196
|
state: PluginState;
|
|
4197
|
+
/** People, as from a plugin route. */
|
|
4198
|
+
users: PluginUsers;
|
|
4371
4199
|
/** Start this plugin's tasks, as from a plugin route. */
|
|
4372
4200
|
tasks: PluginTaskStarter;
|
|
4373
4201
|
}
|
|
@@ -4511,21 +4339,11 @@ export interface RouteRegistrationHookContext extends PluginContext {
|
|
|
4511
4339
|
* when a write fails and must run again after the route returns.
|
|
4512
4340
|
*/
|
|
4513
4341
|
tasks: PluginTaskStarter;
|
|
4514
|
-
users:
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
*/
|
|
4520
|
-
readIdentity(identityId: string): Promise<{
|
|
4521
|
-
identity: Identity;
|
|
4522
|
-
user?: User;
|
|
4523
|
-
} | undefined>;
|
|
4524
|
-
};
|
|
4525
|
-
}
|
|
4526
|
-
export interface ApiRouteRegistrationHookContext extends PluginContext {
|
|
4527
|
-
conversationEvents: PluginConversationEventReader;
|
|
4528
|
-
eventStats: PluginConversationEventStats;
|
|
4342
|
+
users: PluginUsers;
|
|
4343
|
+
}
|
|
4344
|
+
export interface ApiRouteRegistrationHookContext extends PluginContext {
|
|
4345
|
+
conversationEvents: PluginConversationEventReader;
|
|
4346
|
+
eventStats: PluginConversationEventStats;
|
|
4529
4347
|
users: {
|
|
4530
4348
|
/** Resolve or create the canonical user for one verified email. */
|
|
4531
4349
|
resolve(email: string): Promise<User | undefined>;
|
|
@@ -4550,6 +4368,305 @@ export interface SlackConversationLink {
|
|
|
4550
4368
|
export interface SlackConversationLinkHookContext extends PluginContext {
|
|
4551
4369
|
conversationId: string;
|
|
4552
4370
|
}
|
|
4371
|
+
/**
|
|
4372
|
+
* Runtime-owned provenance for a transcript message: whether it is a durable
|
|
4373
|
+
* instruction or ambient context, plus the actor identity when known. Missing
|
|
4374
|
+
* provenance on an entry means unattributed context.
|
|
4375
|
+
*/
|
|
4376
|
+
export declare const pluginRunTranscriptProvenanceSchema: z.ZodObject<{
|
|
4377
|
+
authority: z.ZodEnum<{
|
|
4378
|
+
context: "context";
|
|
4379
|
+
instruction: "instruction";
|
|
4380
|
+
}>;
|
|
4381
|
+
actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
4382
|
+
email: z.ZodOptional<z.ZodString>;
|
|
4383
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
4384
|
+
userId: z.ZodString;
|
|
4385
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
4386
|
+
platform: z.ZodLiteral<"slack">;
|
|
4387
|
+
teamId: z.ZodString;
|
|
4388
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
4389
|
+
email: z.ZodOptional<z.ZodString>;
|
|
4390
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
4391
|
+
userId: z.ZodString;
|
|
4392
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
4393
|
+
platform: z.ZodLiteral<"local">;
|
|
4394
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
4395
|
+
email: z.ZodOptional<z.ZodString>;
|
|
4396
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
4397
|
+
userId: z.ZodString;
|
|
4398
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
4399
|
+
platform: z.ZodLiteral<"web">;
|
|
4400
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
4401
|
+
platform: z.ZodLiteral<"system">;
|
|
4402
|
+
name: z.ZodString;
|
|
4403
|
+
}, z.core.$strict>], "platform">>;
|
|
4404
|
+
}, z.core.$strict>;
|
|
4405
|
+
/** One normalized transcript entry from the completed run exposed to plugin tasks. */
|
|
4406
|
+
export declare const pluginRunTranscriptEntrySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
4407
|
+
type: z.ZodLiteral<"message">;
|
|
4408
|
+
role: z.ZodEnum<{
|
|
4409
|
+
assistant: "assistant";
|
|
4410
|
+
user: "user";
|
|
4411
|
+
}>;
|
|
4412
|
+
text: z.ZodString;
|
|
4413
|
+
provenance: z.ZodOptional<z.ZodObject<{
|
|
4414
|
+
authority: z.ZodEnum<{
|
|
4415
|
+
context: "context";
|
|
4416
|
+
instruction: "instruction";
|
|
4417
|
+
}>;
|
|
4418
|
+
actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
4419
|
+
email: z.ZodOptional<z.ZodString>;
|
|
4420
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
4421
|
+
userId: z.ZodString;
|
|
4422
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
4423
|
+
platform: z.ZodLiteral<"slack">;
|
|
4424
|
+
teamId: z.ZodString;
|
|
4425
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
4426
|
+
email: z.ZodOptional<z.ZodString>;
|
|
4427
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
4428
|
+
userId: z.ZodString;
|
|
4429
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
4430
|
+
platform: z.ZodLiteral<"local">;
|
|
4431
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
4432
|
+
email: z.ZodOptional<z.ZodString>;
|
|
4433
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
4434
|
+
userId: z.ZodString;
|
|
4435
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
4436
|
+
platform: z.ZodLiteral<"web">;
|
|
4437
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
4438
|
+
platform: z.ZodLiteral<"system">;
|
|
4439
|
+
name: z.ZodString;
|
|
4440
|
+
}, z.core.$strict>], "platform">>;
|
|
4441
|
+
}, z.core.$strict>>;
|
|
4442
|
+
isRunActor: z.ZodOptional<z.ZodBoolean>;
|
|
4443
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
4444
|
+
type: z.ZodLiteral<"toolResult">;
|
|
4445
|
+
toolName: z.ZodString;
|
|
4446
|
+
isError: z.ZodBoolean;
|
|
4447
|
+
text: z.ZodOptional<z.ZodString>;
|
|
4448
|
+
}, z.core.$strict>], "type">;
|
|
4449
|
+
export type PluginRunTranscriptProvenance = z.output<typeof pluginRunTranscriptProvenanceSchema>;
|
|
4450
|
+
/** Runtime-owned completed-run projection exposed to plugin tasks. */
|
|
4451
|
+
export declare const pluginRunContextSchema: z.ZodObject<{
|
|
4452
|
+
actorUserId: z.ZodOptional<z.ZodString>;
|
|
4453
|
+
completedAtMs: z.ZodNumber;
|
|
4454
|
+
conversationId: z.ZodString;
|
|
4455
|
+
destination: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
4456
|
+
platform: z.ZodLiteral<"slack">;
|
|
4457
|
+
teamId: z.ZodString;
|
|
4458
|
+
channelId: z.ZodString;
|
|
4459
|
+
threadTs: z.ZodOptional<z.ZodString>;
|
|
4460
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
4461
|
+
platform: z.ZodLiteral<"local">;
|
|
4462
|
+
conversationId: z.ZodString;
|
|
4463
|
+
}, z.core.$strict>], "platform">;
|
|
4464
|
+
locationId: z.ZodOptional<z.ZodString>;
|
|
4465
|
+
actors: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
4466
|
+
email: z.ZodOptional<z.ZodString>;
|
|
4467
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
4468
|
+
userId: z.ZodString;
|
|
4469
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
4470
|
+
platform: z.ZodLiteral<"slack">;
|
|
4471
|
+
teamId: z.ZodString;
|
|
4472
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
4473
|
+
email: z.ZodOptional<z.ZodString>;
|
|
4474
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
4475
|
+
userId: z.ZodString;
|
|
4476
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
4477
|
+
platform: z.ZodLiteral<"local">;
|
|
4478
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
4479
|
+
email: z.ZodOptional<z.ZodString>;
|
|
4480
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
4481
|
+
userId: z.ZodString;
|
|
4482
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
4483
|
+
platform: z.ZodLiteral<"web">;
|
|
4484
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
4485
|
+
platform: z.ZodLiteral<"system">;
|
|
4486
|
+
name: z.ZodString;
|
|
4487
|
+
}, z.core.$strict>], "platform">>;
|
|
4488
|
+
actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
4489
|
+
email: z.ZodOptional<z.ZodString>;
|
|
4490
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
4491
|
+
userId: z.ZodString;
|
|
4492
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
4493
|
+
platform: z.ZodLiteral<"slack">;
|
|
4494
|
+
teamId: z.ZodString;
|
|
4495
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
4496
|
+
email: z.ZodOptional<z.ZodString>;
|
|
4497
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
4498
|
+
userId: z.ZodString;
|
|
4499
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
4500
|
+
platform: z.ZodLiteral<"local">;
|
|
4501
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
4502
|
+
email: z.ZodOptional<z.ZodString>;
|
|
4503
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
4504
|
+
userId: z.ZodString;
|
|
4505
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
4506
|
+
platform: z.ZodLiteral<"web">;
|
|
4507
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
4508
|
+
platform: z.ZodLiteral<"system">;
|
|
4509
|
+
name: z.ZodString;
|
|
4510
|
+
}, z.core.$strict>], "platform">>;
|
|
4511
|
+
runId: z.ZodString;
|
|
4512
|
+
source: z.ZodPreprocess<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
4513
|
+
kind: z.ZodLiteral<"slack">;
|
|
4514
|
+
teamId: z.ZodString;
|
|
4515
|
+
channelId: z.ZodString;
|
|
4516
|
+
visibility: z.ZodEnum<{
|
|
4517
|
+
private: "private";
|
|
4518
|
+
public: "public";
|
|
4519
|
+
}>;
|
|
4520
|
+
messageTs: z.ZodOptional<z.ZodString>;
|
|
4521
|
+
threadTs: z.ZodOptional<z.ZodString>;
|
|
4522
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
4523
|
+
kind: z.ZodLiteral<"local">;
|
|
4524
|
+
visibility: z.ZodLiteral<"private">;
|
|
4525
|
+
conversationId: z.ZodString;
|
|
4526
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
4527
|
+
kind: z.ZodLiteral<"web">;
|
|
4528
|
+
visibility: z.ZodEnum<{
|
|
4529
|
+
private: "private";
|
|
4530
|
+
public: "public";
|
|
4531
|
+
}>;
|
|
4532
|
+
conversationId: z.ZodString;
|
|
4533
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
4534
|
+
kind: z.ZodLiteral<"event">;
|
|
4535
|
+
eventKey: z.ZodString;
|
|
4536
|
+
eventType: z.ZodString;
|
|
4537
|
+
identifier: z.ZodString;
|
|
4538
|
+
namespace: z.ZodString;
|
|
4539
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
4540
|
+
automationId: z.ZodOptional<z.ZodString>;
|
|
4541
|
+
automationRunId: z.ZodOptional<z.ZodString>;
|
|
4542
|
+
kind: z.ZodLiteral<"scheduled_automation">;
|
|
4543
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
4544
|
+
automationId: z.ZodOptional<z.ZodString>;
|
|
4545
|
+
automationRunId: z.ZodOptional<z.ZodString>;
|
|
4546
|
+
kind: z.ZodLiteral<"event_automation">;
|
|
4547
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
4548
|
+
kind: z.ZodLiteral<"plugin_dispatch">;
|
|
4549
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
4550
|
+
kind: z.ZodLiteral<"parent_message">;
|
|
4551
|
+
}, z.core.$strict>], "kind">, unknown>;
|
|
4552
|
+
transcript: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
4553
|
+
type: z.ZodLiteral<"message">;
|
|
4554
|
+
role: z.ZodEnum<{
|
|
4555
|
+
assistant: "assistant";
|
|
4556
|
+
user: "user";
|
|
4557
|
+
}>;
|
|
4558
|
+
text: z.ZodString;
|
|
4559
|
+
provenance: z.ZodOptional<z.ZodObject<{
|
|
4560
|
+
authority: z.ZodEnum<{
|
|
4561
|
+
context: "context";
|
|
4562
|
+
instruction: "instruction";
|
|
4563
|
+
}>;
|
|
4564
|
+
actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
4565
|
+
email: z.ZodOptional<z.ZodString>;
|
|
4566
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
4567
|
+
userId: z.ZodString;
|
|
4568
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
4569
|
+
platform: z.ZodLiteral<"slack">;
|
|
4570
|
+
teamId: z.ZodString;
|
|
4571
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
4572
|
+
email: z.ZodOptional<z.ZodString>;
|
|
4573
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
4574
|
+
userId: z.ZodString;
|
|
4575
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
4576
|
+
platform: z.ZodLiteral<"local">;
|
|
4577
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
4578
|
+
email: z.ZodOptional<z.ZodString>;
|
|
4579
|
+
fullName: z.ZodOptional<z.ZodString>;
|
|
4580
|
+
userId: z.ZodString;
|
|
4581
|
+
userName: z.ZodOptional<z.ZodString>;
|
|
4582
|
+
platform: z.ZodLiteral<"web">;
|
|
4583
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
4584
|
+
platform: z.ZodLiteral<"system">;
|
|
4585
|
+
name: z.ZodString;
|
|
4586
|
+
}, z.core.$strict>], "platform">>;
|
|
4587
|
+
}, z.core.$strict>>;
|
|
4588
|
+
isRunActor: z.ZodOptional<z.ZodBoolean>;
|
|
4589
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
4590
|
+
type: z.ZodLiteral<"toolResult">;
|
|
4591
|
+
toolName: z.ZodString;
|
|
4592
|
+
isError: z.ZodBoolean;
|
|
4593
|
+
text: z.ZodOptional<z.ZodString>;
|
|
4594
|
+
}, z.core.$strict>], "type">>;
|
|
4595
|
+
}, z.core.$strict>;
|
|
4596
|
+
export type PluginRunTranscriptEntry = z.output<typeof pluginRunTranscriptEntrySchema>;
|
|
4597
|
+
export type PluginRunContext = z.output<typeof pluginRunContextSchema>;
|
|
4598
|
+
/** Runtime context passed to a plugin-owned background task. */
|
|
4599
|
+
export interface PluginTaskContext extends PluginContext {
|
|
4600
|
+
embedder: PluginEmbedder;
|
|
4601
|
+
events: PluginConversationEvents;
|
|
4602
|
+
id: string;
|
|
4603
|
+
model: PluginModel;
|
|
4604
|
+
name: string;
|
|
4605
|
+
run: {
|
|
4606
|
+
load(): Promise<PluginRunContext>;
|
|
4607
|
+
};
|
|
4608
|
+
state: PluginState;
|
|
4609
|
+
/** Events that this plugin emitted in the completed Turn, oldest first. */
|
|
4610
|
+
turnEvents: PluginTurnEventReader;
|
|
4611
|
+
}
|
|
4612
|
+
/** Task that Junior runs after each completed session. */
|
|
4613
|
+
export interface PluginSessionTaskDefinition {
|
|
4614
|
+
payload?: undefined;
|
|
4615
|
+
run(ctx: PluginTaskContext): Promise<void> | void;
|
|
4616
|
+
}
|
|
4617
|
+
/** Runtime context passed to one attempt of a task that `tasks.start` started. */
|
|
4618
|
+
export interface PluginStartedTaskContext<Payload = unknown> extends PluginContext {
|
|
4619
|
+
annotations: PluginConversationAnnotations;
|
|
4620
|
+
codeChanges: PluginCodeChanges;
|
|
4621
|
+
conversationChanges: PluginConversationChanges;
|
|
4622
|
+
/** Publishes the plugin's Events, as the heartbeat and routes do. */
|
|
4623
|
+
events: EventPublisher;
|
|
4624
|
+
/** Inbox items, as from a plugin route. */
|
|
4625
|
+
inboxItems: PluginConversationInboxItems;
|
|
4626
|
+
/**
|
|
4627
|
+
* True on the last delivery that Junior makes. An attempt that throws
|
|
4628
|
+
* now is not run again, so a task that waits for a provider can write
|
|
4629
|
+
* its fallback instead.
|
|
4630
|
+
*/
|
|
4631
|
+
lastDelivery: boolean;
|
|
4632
|
+
name: string;
|
|
4633
|
+
/** The payload from `tasks.start`, parsed with the task's `payload` schema. */
|
|
4634
|
+
payload: Payload;
|
|
4635
|
+
state: PluginState;
|
|
4636
|
+
/**
|
|
4637
|
+
* Starts this plugin's tasks, as from a plugin route. A task that must
|
|
4638
|
+
* wait longer than its retries cover can start itself again.
|
|
4639
|
+
*/
|
|
4640
|
+
tasks: PluginTaskStarter;
|
|
4641
|
+
/** Stored identities and their users, as from a plugin route. */
|
|
4642
|
+
users: RouteRegistrationHookContext["users"];
|
|
4643
|
+
}
|
|
4644
|
+
/**
|
|
4645
|
+
* Task that runs only when the plugin starts it with `tasks.start`. Junior
|
|
4646
|
+
* sends the payload as JSON in the queue message and parses it with
|
|
4647
|
+
* `payload` before each attempt. A failed attempt runs again later, a
|
|
4648
|
+
* bounded number of times.
|
|
4649
|
+
*/
|
|
4650
|
+
export interface PluginStartedTaskDefinition<Schema extends z.ZodType = z.ZodType> {
|
|
4651
|
+
payload: Schema;
|
|
4652
|
+
run(ctx: PluginStartedTaskContext<z.output<Schema>>): Promise<void> | void;
|
|
4653
|
+
}
|
|
4654
|
+
/** Plugin task handler registered by name in a plugin manifest module. */
|
|
4655
|
+
export type PluginTaskDefinition = PluginSessionTaskDefinition | PluginStartedTaskDefinition;
|
|
4656
|
+
/** Task handlers keyed by the plugin-owned task name. */
|
|
4657
|
+
export type PluginTasks = Record<string, PluginTaskDefinition>;
|
|
4658
|
+
/** Input of `tasks.start`. */
|
|
4659
|
+
export declare const pluginTaskStartInputSchema: z.ZodObject<{
|
|
4660
|
+
key: z.ZodString;
|
|
4661
|
+
name: z.ZodString;
|
|
4662
|
+
delaySeconds: z.ZodOptional<z.ZodNumber>;
|
|
4663
|
+
payload: z.ZodUnknown;
|
|
4664
|
+
}, z.core.$strict>;
|
|
4665
|
+
export type PluginTaskStartInput = z.output<typeof pluginTaskStartInputSchema>;
|
|
4666
|
+
/** Starts this plugin's tasks on the plugin task queue. */
|
|
4667
|
+
export interface PluginTaskStarter {
|
|
4668
|
+
start(input: PluginTaskStartInput): Promise<void>;
|
|
4669
|
+
}
|
|
4553
4670
|
/**
|
|
4554
4671
|
* Deny provider egress when a plugin policy does not allow the request.
|
|
4555
4672
|
*
|
|
@@ -4603,6 +4720,35 @@ export interface FormatMarkdownHookContext {
|
|
|
4603
4720
|
provider?: string;
|
|
4604
4721
|
text: string;
|
|
4605
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
|
+
}
|
|
4606
4752
|
/** First human message of a new Conversation, given before title generation. */
|
|
4607
4753
|
export interface ConversationTitleContextHookContext extends PluginContext {
|
|
4608
4754
|
/**
|
|
@@ -4673,6 +4819,18 @@ export interface PluginHooks {
|
|
|
4673
4819
|
* failure, so it must be safe to repeat.
|
|
4674
4820
|
*/
|
|
4675
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;
|
|
4676
4834
|
heartbeat?(ctx: HeartbeatHookContext): Promise<HeartbeatResult | void> | HeartbeatResult | void;
|
|
4677
4835
|
unfinishedWork?(ctx: UnfinishedWorkHookContext): Promise<UnfinishedWorkResult> | UnfinishedWorkResult;
|
|
4678
4836
|
issueCredential?(ctx: IssueCredentialHookContext): Promise<PluginCredentialResult> | PluginCredentialResult;
|
|
@@ -5060,6 +5218,8 @@ export type PluginRegistrationInput = {
|
|
|
5060
5218
|
hooks?: PluginHooks;
|
|
5061
5219
|
/** Images that this plugin serves through the Junior image proxy. */
|
|
5062
5220
|
images?: PluginImageSource;
|
|
5221
|
+
/** The kinds of Inbox items that this plugin adds. */
|
|
5222
|
+
inboxSubjects?: PluginInboxSubjectKind[];
|
|
5063
5223
|
manifest: PluginManifest;
|
|
5064
5224
|
model?: PluginModelConfig;
|
|
5065
5225
|
/** URLs that this plugin shows as object cards. */
|
|
@@ -5105,4 +5265,4 @@ export declare function markdownText(node: MarkdownNode, options?: MarkdownTextO
|
|
|
5105
5265
|
* each run of whitespace made one space.
|
|
5106
5266
|
*/
|
|
5107
5267
|
export declare function markdownPlainText(text: string, options?: MarkdownTextOptions): string;
|
|
5108
|
-
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
|