@sentry/junior-scheduler 0.57.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.
@@ -0,0 +1,4 @@
1
+ /** Create Junior's built-in trusted scheduler plugin. */
2
+ export declare function createSchedulerPlugin(): import("@sentry/junior-plugin-api").JuniorPlugin;
3
+ /** Register trusted scheduler runtime hooks for scheduled Junior tasks. */
4
+ export declare const schedulerPlugin: typeof createSchedulerPlugin;
@@ -0,0 +1,7 @@
1
+ import { type ScheduledRun, type ScheduledTask } from "./types";
2
+ /** Build the marker-delimited user prompt for one scheduled task execution. */
3
+ export declare function buildScheduledTaskRunPrompt(args: {
4
+ nowMs: number;
5
+ run: ScheduledRun;
6
+ task: ScheduledTask;
7
+ }): string;
@@ -0,0 +1,25 @@
1
+ import { type AgentPluginRequester, type AgentPluginState, type AgentPluginToolDefinition } from "@sentry/junior-plugin-api";
2
+ export interface SchedulerToolContext {
3
+ channelCapabilities: {
4
+ canAddReactions: boolean;
5
+ canCreateCanvas: boolean;
6
+ canPostToChannel: boolean;
7
+ };
8
+ channelId?: string;
9
+ messageTs?: string;
10
+ requester?: AgentPluginRequester;
11
+ state: AgentPluginState;
12
+ teamId?: string;
13
+ threadTs?: string;
14
+ userText?: string;
15
+ }
16
+ /** Create a tool that stores a scheduled task for the active Slack context. */
17
+ export declare function createSlackScheduleCreateTaskTool(context: SchedulerToolContext): AgentPluginToolDefinition<any>;
18
+ /** Create a tool that lists scheduled tasks for the active Slack destination. */
19
+ export declare function createSlackScheduleListTasksTool(context: SchedulerToolContext): AgentPluginToolDefinition<any>;
20
+ /** Create a tool that edits a scheduled task in the active Slack destination. */
21
+ export declare function createSlackScheduleUpdateTaskTool(context: SchedulerToolContext): AgentPluginToolDefinition<any>;
22
+ /** Create a tool that removes a scheduled task from the active Slack destination. */
23
+ export declare function createSlackScheduleDeleteTaskTool(context: SchedulerToolContext): AgentPluginToolDefinition<any>;
24
+ /** Create a tool that marks an existing scheduled task due immediately. */
25
+ export declare function createSlackScheduleRunTaskNowTool(context: SchedulerToolContext): AgentPluginToolDefinition<any>;
@@ -0,0 +1,49 @@
1
+ import type { AgentPluginState } from "@sentry/junior-plugin-api";
2
+ import type { ScheduledRun, ScheduledTask } from "./types";
3
+ export interface SchedulerStore {
4
+ claimDueRun(args: {
5
+ nowMs: number;
6
+ }): Promise<ScheduledRun | undefined>;
7
+ getRun(runId: string): Promise<ScheduledRun | undefined>;
8
+ getTask(taskId: string): Promise<ScheduledTask | undefined>;
9
+ listIncompleteRuns(): Promise<ScheduledRun[]>;
10
+ listTasksForTeam(teamId: string): Promise<ScheduledTask[]>;
11
+ markRunBlocked(args: {
12
+ completedAtMs: number;
13
+ errorMessage: string;
14
+ runId: string;
15
+ startedAtMs?: number;
16
+ }): Promise<ScheduledRun | undefined>;
17
+ markRunCompleted(args: {
18
+ completedAtMs: number;
19
+ resultMessageTs?: string;
20
+ runId: string;
21
+ startedAtMs: number;
22
+ }): Promise<ScheduledRun | undefined>;
23
+ markRunFailed(args: {
24
+ completedAtMs: number;
25
+ errorMessage: string;
26
+ startedAtMs?: number;
27
+ runId: string;
28
+ }): Promise<ScheduledRun | undefined>;
29
+ markRunSkipped(args: {
30
+ completedAtMs: number;
31
+ errorMessage: string;
32
+ runId: string;
33
+ }): Promise<ScheduledRun | undefined>;
34
+ markRunDispatched(args: {
35
+ claimedAtMs: number;
36
+ dispatchId: string;
37
+ nowMs: number;
38
+ runId: string;
39
+ }): Promise<ScheduledRun | undefined>;
40
+ saveTask(task: ScheduledTask): Promise<void>;
41
+ updateTaskAfterRun(args: {
42
+ errorMessage?: string;
43
+ nowMs: number;
44
+ run: ScheduledRun;
45
+ status: "blocked" | "completed" | "failed";
46
+ }): Promise<void>;
47
+ }
48
+ /** Create a scheduler store backed by this plugin's durable state namespace. */
49
+ export declare function createSchedulerStore(state: AgentPluginState): SchedulerStore;
@@ -0,0 +1,86 @@
1
+ export type ScheduledTaskStatus = "active" | "paused" | "blocked" | "deleted";
2
+ export type ScheduledRunStatus = "pending" | "running" | "completed" | "failed" | "blocked" | "skipped";
3
+ export interface ScheduledTaskPrincipal {
4
+ slackUserId: string;
5
+ fullName?: string;
6
+ userName?: string;
7
+ }
8
+ export interface ScheduledTaskExecutionActor {
9
+ type: "system";
10
+ id: string;
11
+ }
12
+ export declare const SCHEDULED_TASK_SYSTEM_ACTOR: Readonly<{
13
+ type: "system";
14
+ id: string;
15
+ }>;
16
+ export interface ScheduledTaskDestination {
17
+ platform: "slack";
18
+ teamId: string;
19
+ channelId: string;
20
+ }
21
+ export interface ScheduledTaskConversationAccess {
22
+ audience: "direct" | "group" | "channel";
23
+ visibility: "private" | "public" | "unknown";
24
+ }
25
+ export interface ScheduledTaskCredentialSubject {
26
+ type: "user";
27
+ userId: string;
28
+ allowedWhen: "private-direct-conversation";
29
+ }
30
+ export type ScheduledCalendarFrequency = "daily" | "weekly" | "monthly" | "yearly";
31
+ export interface ScheduledLocalTime {
32
+ hour: number;
33
+ minute: number;
34
+ }
35
+ export interface ScheduledTaskRecurrence {
36
+ dayOfMonth?: number;
37
+ frequency: ScheduledCalendarFrequency;
38
+ interval: number;
39
+ month?: number;
40
+ startDate: string;
41
+ time: ScheduledLocalTime;
42
+ weekdays?: number[];
43
+ }
44
+ export interface ScheduledTaskSchedule {
45
+ description: string;
46
+ timezone: string;
47
+ kind: "one_off" | "recurring";
48
+ recurrence?: ScheduledTaskRecurrence;
49
+ }
50
+ export interface ScheduledTaskSpec {
51
+ text: string;
52
+ }
53
+ export interface ScheduledTask {
54
+ id: string;
55
+ createdAtMs: number;
56
+ createdBy: ScheduledTaskPrincipal;
57
+ conversationAccess?: ScheduledTaskConversationAccess;
58
+ credentialSubject?: ScheduledTaskCredentialSubject;
59
+ destination: ScheduledTaskDestination;
60
+ executionActor?: ScheduledTaskExecutionActor;
61
+ lastRunAtMs?: number;
62
+ nextRunAtMs?: number;
63
+ originalRequest?: string;
64
+ runNowAtMs?: number;
65
+ schedule: ScheduledTaskSchedule;
66
+ status: ScheduledTaskStatus;
67
+ statusReason?: string;
68
+ task: ScheduledTaskSpec;
69
+ updatedAtMs: number;
70
+ version: number;
71
+ }
72
+ export interface ScheduledRun {
73
+ id: string;
74
+ attempt: number;
75
+ claimedAtMs: number;
76
+ completedAtMs?: number;
77
+ dispatchId?: string;
78
+ errorMessage?: string;
79
+ idempotencyKey: string;
80
+ resultMessageTs?: string;
81
+ scheduledForMs: number;
82
+ startedAtMs?: number;
83
+ status: ScheduledRunStatus;
84
+ taskId: string;
85
+ taskVersion: number;
86
+ }
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@sentry/junior-scheduler",
3
+ "version": "0.57.0",
4
+ "private": false,
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "type": "module",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/getsentry/junior.git",
12
+ "directory": "packages/junior-scheduler"
13
+ },
14
+ "exports": {
15
+ ".": {
16
+ "types": "./src/index.ts",
17
+ "default": "./dist/index.js"
18
+ }
19
+ },
20
+ "files": [
21
+ "dist",
22
+ "src",
23
+ "plugin.yaml"
24
+ ],
25
+ "dependencies": {
26
+ "@sinclair/typebox": "^0.34.49",
27
+ "@sentry/junior-plugin-api": "0.57.0"
28
+ },
29
+ "devDependencies": {
30
+ "@types/node": "^25.9.1",
31
+ "tsup": "^8.5.1",
32
+ "typescript": "^6.0.3"
33
+ },
34
+ "scripts": {
35
+ "build": "tsup && tsc -p tsconfig.build.json --emitDeclarationOnly",
36
+ "typecheck": "tsc --noEmit"
37
+ }
38
+ }
package/plugin.yaml ADDED
@@ -0,0 +1,2 @@
1
+ name: scheduler
2
+ description: Scheduled Junior task management and heartbeat dispatch