@sentry/junior-scheduler 0.101.0 → 0.102.1
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/README.md +12 -5
- package/dist/index.js +180 -150
- package/dist/store.d.ts +1 -1
- package/dist/tool-support.d.ts +26 -17
- package/dist/tools/create-task.d.ts +3 -2
- package/dist/tools/delete-task.d.ts +2 -2
- package/dist/tools/list-tasks.d.ts +2 -2
- package/dist/tools/run-task-now.d.ts +2 -2
- package/dist/tools/update-task.d.ts +3 -2
- package/dist/types.d.ts +9 -2
- package/migrations/0001_explicit_credential_mode.sql +4 -0
- package/migrations/meta/0001_snapshot.json +251 -0
- package/migrations/meta/_journal.json +7 -0
- package/package.json +2 -2
- package/src/plugin.ts +20 -4
- package/src/store.ts +70 -31
- package/src/tool-support.ts +7 -36
- package/src/tools/create-task.ts +10 -8
- package/src/tools/update-task.ts +24 -1
- package/src/types.ts +8 -6
package/dist/tool-support.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type SlackDestination, type SlackActor, type SlackSource } from "@sentry/junior-plugin-api";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { type SchedulerStore } from "./store";
|
|
4
4
|
import type { ScheduledTask, ScheduledTaskConversationAccess, ScheduledTaskPrincipal, ScheduledTaskRecurrence, ScheduledTaskStatus } from "./types";
|
|
5
5
|
export interface SchedulerToolContext {
|
|
6
|
-
credentialSubject?: PluginCredentialSubject;
|
|
7
6
|
actor?: SlackActor;
|
|
8
7
|
source?: SlackSource;
|
|
9
8
|
store: SchedulerStore;
|
|
@@ -24,7 +23,10 @@ declare const compactTaskResultSchema: z.ZodObject<{
|
|
|
24
23
|
recurrence: z.ZodNullable<z.ZodUnknown>;
|
|
25
24
|
next_run_at: z.ZodNullable<z.ZodString>;
|
|
26
25
|
conversation_access: z.ZodNullable<z.ZodUnknown>;
|
|
27
|
-
|
|
26
|
+
credential_mode: z.ZodEnum<{
|
|
27
|
+
system: "system";
|
|
28
|
+
creator: "creator";
|
|
29
|
+
}>;
|
|
28
30
|
last_run_at: z.ZodNullable<z.ZodString>;
|
|
29
31
|
run_now_at: z.ZodNullable<z.ZodString>;
|
|
30
32
|
}, z.core.$strict>;
|
|
@@ -58,7 +60,10 @@ export declare const scheduleTaskToolResultSchema: z.ZodObject<{
|
|
|
58
60
|
recurrence: z.ZodNullable<z.ZodUnknown>;
|
|
59
61
|
next_run_at: z.ZodNullable<z.ZodString>;
|
|
60
62
|
conversation_access: z.ZodNullable<z.ZodUnknown>;
|
|
61
|
-
|
|
63
|
+
credential_mode: z.ZodEnum<{
|
|
64
|
+
system: "system";
|
|
65
|
+
creator: "creator";
|
|
66
|
+
}>;
|
|
62
67
|
last_run_at: z.ZodNullable<z.ZodString>;
|
|
63
68
|
run_now_at: z.ZodNullable<z.ZodString>;
|
|
64
69
|
}, z.core.$strict>;
|
|
@@ -77,7 +82,10 @@ export declare const scheduleTaskToolResultSchema: z.ZodObject<{
|
|
|
77
82
|
recurrence: z.ZodNullable<z.ZodUnknown>;
|
|
78
83
|
next_run_at: z.ZodNullable<z.ZodString>;
|
|
79
84
|
conversation_access: z.ZodNullable<z.ZodUnknown>;
|
|
80
|
-
|
|
85
|
+
credential_mode: z.ZodEnum<{
|
|
86
|
+
system: "system";
|
|
87
|
+
creator: "creator";
|
|
88
|
+
}>;
|
|
81
89
|
last_run_at: z.ZodNullable<z.ZodString>;
|
|
82
90
|
run_now_at: z.ZodNullable<z.ZodString>;
|
|
83
91
|
}, z.core.$strict>;
|
|
@@ -111,7 +119,10 @@ export declare const scheduleListToolResultSchema: z.ZodObject<{
|
|
|
111
119
|
recurrence: z.ZodNullable<z.ZodUnknown>;
|
|
112
120
|
next_run_at: z.ZodNullable<z.ZodString>;
|
|
113
121
|
conversation_access: z.ZodNullable<z.ZodUnknown>;
|
|
114
|
-
|
|
122
|
+
credential_mode: z.ZodEnum<{
|
|
123
|
+
system: "system";
|
|
124
|
+
creator: "creator";
|
|
125
|
+
}>;
|
|
115
126
|
last_run_at: z.ZodNullable<z.ZodString>;
|
|
116
127
|
run_now_at: z.ZodNullable<z.ZodString>;
|
|
117
128
|
}, z.core.$strict>>;
|
|
@@ -131,7 +142,10 @@ export declare const scheduleListToolResultSchema: z.ZodObject<{
|
|
|
131
142
|
recurrence: z.ZodNullable<z.ZodUnknown>;
|
|
132
143
|
next_run_at: z.ZodNullable<z.ZodString>;
|
|
133
144
|
conversation_access: z.ZodNullable<z.ZodUnknown>;
|
|
134
|
-
|
|
145
|
+
credential_mode: z.ZodEnum<{
|
|
146
|
+
system: "system";
|
|
147
|
+
creator: "creator";
|
|
148
|
+
}>;
|
|
135
149
|
last_run_at: z.ZodNullable<z.ZodString>;
|
|
136
150
|
run_now_at: z.ZodNullable<z.ZodString>;
|
|
137
151
|
}, z.core.$strict>>;
|
|
@@ -143,14 +157,9 @@ export declare function throwToolInputError(error: string): never;
|
|
|
143
157
|
/** Require scheduler mutations to stay scoped to the active Slack conversation. */
|
|
144
158
|
export declare function requireActiveConversation(context: SchedulerToolContext): SlackDestination;
|
|
145
159
|
/** Require a concrete Slack actor before creating scheduler ownership state. */
|
|
146
|
-
export declare function requireActor(context: SchedulerToolContext): ScheduledTaskPrincipal;
|
|
160
|
+
export declare function requireActor(context: SchedulerToolContext, destination: SlackDestination): ScheduledTaskPrincipal;
|
|
147
161
|
/** Preserve destination visibility so scheduled work can replay with matching access. */
|
|
148
162
|
export declare function getConversationAccess(destination: SlackDestination): ScheduledTaskConversationAccess;
|
|
149
|
-
/** Carry private-DM credential authority only when scheduled work is allowed to reuse it. */
|
|
150
|
-
export declare function getCredentialSubject(args: {
|
|
151
|
-
access: ScheduledTaskConversationAccess;
|
|
152
|
-
subject: PluginCredentialSubject | undefined;
|
|
153
|
-
}): PluginCredentialSubject | undefined;
|
|
154
163
|
/** Keep scheduler management operations bound to the task's original Slack destination. */
|
|
155
164
|
export declare function sameDestination(task: ScheduledTask, destination: SlackDestination): boolean;
|
|
156
165
|
/** Look up a mutable task only after enforcing active-conversation ownership. */
|
|
@@ -176,7 +185,7 @@ export declare function scheduleTaskToolResult(target: string, task: CompactTask
|
|
|
176
185
|
recurrence: unknown;
|
|
177
186
|
next_run_at: string | null;
|
|
178
187
|
conversation_access: unknown;
|
|
179
|
-
|
|
188
|
+
credential_mode: "system" | "creator";
|
|
180
189
|
last_run_at: string | null;
|
|
181
190
|
run_now_at: string | null;
|
|
182
191
|
};
|
|
@@ -190,7 +199,7 @@ export declare function scheduleTaskToolResult(target: string, task: CompactTask
|
|
|
190
199
|
recurrence: unknown;
|
|
191
200
|
next_run_at: string | null;
|
|
192
201
|
conversation_access: unknown;
|
|
193
|
-
|
|
202
|
+
credential_mode: "system" | "creator";
|
|
194
203
|
last_run_at: string | null;
|
|
195
204
|
run_now_at: string | null;
|
|
196
205
|
};
|
|
@@ -215,7 +224,7 @@ export declare function scheduleListToolResult(args: {
|
|
|
215
224
|
recurrence: unknown;
|
|
216
225
|
next_run_at: string | null;
|
|
217
226
|
conversation_access: unknown;
|
|
218
|
-
|
|
227
|
+
credential_mode: "system" | "creator";
|
|
219
228
|
last_run_at: string | null;
|
|
220
229
|
run_now_at: string | null;
|
|
221
230
|
}[];
|
|
@@ -230,7 +239,7 @@ export declare function scheduleListToolResult(args: {
|
|
|
230
239
|
recurrence: unknown;
|
|
231
240
|
next_run_at: string | null;
|
|
232
241
|
conversation_access: unknown;
|
|
233
|
-
|
|
242
|
+
credential_mode: "system" | "creator";
|
|
234
243
|
last_run_at: string | null;
|
|
235
244
|
run_now_at: string | null;
|
|
236
245
|
}[];
|
|
@@ -7,6 +7,7 @@ export declare function createSlackScheduleCreateTaskTool(context: SchedulerTool
|
|
|
7
7
|
timezone?: string | undefined;
|
|
8
8
|
next_run_at?: string | undefined;
|
|
9
9
|
recurrence?: "daily" | "weekly" | "monthly" | "yearly" | null | undefined;
|
|
10
|
+
credential_mode?: "system" | "creator" | null | undefined;
|
|
10
11
|
}, {
|
|
11
12
|
[x: string]: unknown;
|
|
12
13
|
ok: true;
|
|
@@ -23,7 +24,7 @@ export declare function createSlackScheduleCreateTaskTool(context: SchedulerTool
|
|
|
23
24
|
recurrence: unknown;
|
|
24
25
|
next_run_at: string | null;
|
|
25
26
|
conversation_access: unknown;
|
|
26
|
-
|
|
27
|
+
credential_mode: "system" | "creator";
|
|
27
28
|
last_run_at: string | null;
|
|
28
29
|
run_now_at: string | null;
|
|
29
30
|
};
|
|
@@ -37,7 +38,7 @@ export declare function createSlackScheduleCreateTaskTool(context: SchedulerTool
|
|
|
37
38
|
recurrence: unknown;
|
|
38
39
|
next_run_at: string | null;
|
|
39
40
|
conversation_access: unknown;
|
|
40
|
-
|
|
41
|
+
credential_mode: "system" | "creator";
|
|
41
42
|
last_run_at: string | null;
|
|
42
43
|
run_now_at: string | null;
|
|
43
44
|
};
|
|
@@ -18,7 +18,7 @@ export declare function createSlackScheduleDeleteTaskTool(context: SchedulerTool
|
|
|
18
18
|
recurrence: unknown;
|
|
19
19
|
next_run_at: string | null;
|
|
20
20
|
conversation_access: unknown;
|
|
21
|
-
|
|
21
|
+
credential_mode: "system" | "creator";
|
|
22
22
|
last_run_at: string | null;
|
|
23
23
|
run_now_at: string | null;
|
|
24
24
|
};
|
|
@@ -32,7 +32,7 @@ export declare function createSlackScheduleDeleteTaskTool(context: SchedulerTool
|
|
|
32
32
|
recurrence: unknown;
|
|
33
33
|
next_run_at: string | null;
|
|
34
34
|
conversation_access: unknown;
|
|
35
|
-
|
|
35
|
+
credential_mode: "system" | "creator";
|
|
36
36
|
last_run_at: string | null;
|
|
37
37
|
run_now_at: string | null;
|
|
38
38
|
};
|
|
@@ -16,7 +16,7 @@ export declare function createSlackScheduleListTasksTool(context: SchedulerToolC
|
|
|
16
16
|
recurrence: unknown;
|
|
17
17
|
next_run_at: string | null;
|
|
18
18
|
conversation_access: unknown;
|
|
19
|
-
|
|
19
|
+
credential_mode: "system" | "creator";
|
|
20
20
|
last_run_at: string | null;
|
|
21
21
|
run_now_at: string | null;
|
|
22
22
|
}[];
|
|
@@ -31,7 +31,7 @@ export declare function createSlackScheduleListTasksTool(context: SchedulerToolC
|
|
|
31
31
|
recurrence: unknown;
|
|
32
32
|
next_run_at: string | null;
|
|
33
33
|
conversation_access: unknown;
|
|
34
|
-
|
|
34
|
+
credential_mode: "system" | "creator";
|
|
35
35
|
last_run_at: string | null;
|
|
36
36
|
run_now_at: string | null;
|
|
37
37
|
}[];
|
|
@@ -18,7 +18,7 @@ export declare function createSlackScheduleRunTaskNowTool(context: SchedulerTool
|
|
|
18
18
|
recurrence: unknown;
|
|
19
19
|
next_run_at: string | null;
|
|
20
20
|
conversation_access: unknown;
|
|
21
|
-
|
|
21
|
+
credential_mode: "system" | "creator";
|
|
22
22
|
last_run_at: string | null;
|
|
23
23
|
run_now_at: string | null;
|
|
24
24
|
};
|
|
@@ -32,7 +32,7 @@ export declare function createSlackScheduleRunTaskNowTool(context: SchedulerTool
|
|
|
32
32
|
recurrence: unknown;
|
|
33
33
|
next_run_at: string | null;
|
|
34
34
|
conversation_access: unknown;
|
|
35
|
-
|
|
35
|
+
credential_mode: "system" | "creator";
|
|
36
36
|
last_run_at: string | null;
|
|
37
37
|
run_now_at: string | null;
|
|
38
38
|
};
|
|
@@ -8,6 +8,7 @@ export declare function createSlackScheduleUpdateTaskTool(context: SchedulerTool
|
|
|
8
8
|
next_run_at?: string | undefined;
|
|
9
9
|
recurrence?: "daily" | "weekly" | "monthly" | "yearly" | null | undefined;
|
|
10
10
|
status?: "blocked" | "active" | "paused" | undefined;
|
|
11
|
+
credential_mode?: "system" | "creator" | null | undefined;
|
|
11
12
|
}, {
|
|
12
13
|
[x: string]: unknown;
|
|
13
14
|
ok: true;
|
|
@@ -24,7 +25,7 @@ export declare function createSlackScheduleUpdateTaskTool(context: SchedulerTool
|
|
|
24
25
|
recurrence: unknown;
|
|
25
26
|
next_run_at: string | null;
|
|
26
27
|
conversation_access: unknown;
|
|
27
|
-
|
|
28
|
+
credential_mode: "system" | "creator";
|
|
28
29
|
last_run_at: string | null;
|
|
29
30
|
run_now_at: string | null;
|
|
30
31
|
};
|
|
@@ -38,7 +39,7 @@ export declare function createSlackScheduleUpdateTaskTool(context: SchedulerTool
|
|
|
38
39
|
recurrence: unknown;
|
|
39
40
|
next_run_at: string | null;
|
|
40
41
|
conversation_access: unknown;
|
|
41
|
-
|
|
42
|
+
credential_mode: "system" | "creator";
|
|
42
43
|
last_run_at: string | null;
|
|
43
44
|
run_now_at: string | null;
|
|
44
45
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SlackDestination, SystemActor } from "@sentry/junior-plugin-api";
|
|
2
|
+
import { z } from "zod";
|
|
2
3
|
export type ScheduledTaskStatus = "active" | "paused" | "blocked" | "deleted";
|
|
4
|
+
export declare const scheduledTaskCredentialModeSchema: z.ZodEnum<{
|
|
5
|
+
system: "system";
|
|
6
|
+
creator: "creator";
|
|
7
|
+
}>;
|
|
8
|
+
export type ScheduledTaskCredentialMode = z.infer<typeof scheduledTaskCredentialModeSchema>;
|
|
3
9
|
export type ScheduledRunStatus = "pending" | "running" | "completed" | "failed" | "blocked" | "skipped";
|
|
4
10
|
export interface ScheduledTaskPrincipal {
|
|
5
11
|
slackUserId: string;
|
|
@@ -43,7 +49,8 @@ export interface ScheduledTask {
|
|
|
43
49
|
createdAtMs: number;
|
|
44
50
|
createdBy: ScheduledTaskPrincipal;
|
|
45
51
|
conversationAccess?: ScheduledTaskConversationAccess;
|
|
46
|
-
|
|
52
|
+
/** Selects system credentials or explicitly delegated creator credentials. */
|
|
53
|
+
credentialMode: ScheduledTaskCredentialMode;
|
|
47
54
|
destination: SlackDestination;
|
|
48
55
|
executionActor?: ScheduledTaskExecutionActor;
|
|
49
56
|
lastRunAtMs?: number;
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "ccd0c14d-8a21-41aa-82b9-69a3d80cdc88",
|
|
3
|
+
"prevId": "fd06fa0f-6037-44df-9c9c-680e14e4be97",
|
|
4
|
+
"version": "7",
|
|
5
|
+
"dialect": "postgresql",
|
|
6
|
+
"tables": {
|
|
7
|
+
"public.junior_scheduler_runs": {
|
|
8
|
+
"name": "junior_scheduler_runs",
|
|
9
|
+
"schema": "",
|
|
10
|
+
"columns": {
|
|
11
|
+
"id": {
|
|
12
|
+
"name": "id",
|
|
13
|
+
"type": "text",
|
|
14
|
+
"primaryKey": true,
|
|
15
|
+
"notNull": true
|
|
16
|
+
},
|
|
17
|
+
"task_id": {
|
|
18
|
+
"name": "task_id",
|
|
19
|
+
"type": "text",
|
|
20
|
+
"primaryKey": false,
|
|
21
|
+
"notNull": true
|
|
22
|
+
},
|
|
23
|
+
"status": {
|
|
24
|
+
"name": "status",
|
|
25
|
+
"type": "text",
|
|
26
|
+
"primaryKey": false,
|
|
27
|
+
"notNull": true
|
|
28
|
+
},
|
|
29
|
+
"scheduled_for_ms": {
|
|
30
|
+
"name": "scheduled_for_ms",
|
|
31
|
+
"type": "bigint",
|
|
32
|
+
"primaryKey": false,
|
|
33
|
+
"notNull": true
|
|
34
|
+
},
|
|
35
|
+
"record": {
|
|
36
|
+
"name": "record",
|
|
37
|
+
"type": "jsonb",
|
|
38
|
+
"primaryKey": false,
|
|
39
|
+
"notNull": true
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"indexes": {
|
|
43
|
+
"junior_scheduler_runs_task_status_idx": {
|
|
44
|
+
"name": "junior_scheduler_runs_task_status_idx",
|
|
45
|
+
"columns": [
|
|
46
|
+
{
|
|
47
|
+
"expression": "task_id",
|
|
48
|
+
"isExpression": false,
|
|
49
|
+
"asc": true,
|
|
50
|
+
"nulls": "last"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"expression": "status",
|
|
54
|
+
"isExpression": false,
|
|
55
|
+
"asc": true,
|
|
56
|
+
"nulls": "last"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"expression": "scheduled_for_ms",
|
|
60
|
+
"isExpression": false,
|
|
61
|
+
"asc": true,
|
|
62
|
+
"nulls": "last"
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
"isUnique": false,
|
|
66
|
+
"with": {},
|
|
67
|
+
"method": "btree",
|
|
68
|
+
"concurrently": false
|
|
69
|
+
},
|
|
70
|
+
"junior_scheduler_runs_status_idx": {
|
|
71
|
+
"name": "junior_scheduler_runs_status_idx",
|
|
72
|
+
"columns": [
|
|
73
|
+
{
|
|
74
|
+
"expression": "status",
|
|
75
|
+
"isExpression": false,
|
|
76
|
+
"asc": true,
|
|
77
|
+
"nulls": "last"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"expression": "scheduled_for_ms",
|
|
81
|
+
"isExpression": false,
|
|
82
|
+
"asc": true,
|
|
83
|
+
"nulls": "last"
|
|
84
|
+
}
|
|
85
|
+
],
|
|
86
|
+
"isUnique": false,
|
|
87
|
+
"with": {},
|
|
88
|
+
"method": "btree",
|
|
89
|
+
"concurrently": false
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
"foreignKeys": {},
|
|
93
|
+
"compositePrimaryKeys": {},
|
|
94
|
+
"uniqueConstraints": {},
|
|
95
|
+
"policies": {},
|
|
96
|
+
"checkConstraints": {},
|
|
97
|
+
"isRLSEnabled": false
|
|
98
|
+
},
|
|
99
|
+
"public.junior_scheduler_tasks": {
|
|
100
|
+
"name": "junior_scheduler_tasks",
|
|
101
|
+
"schema": "",
|
|
102
|
+
"columns": {
|
|
103
|
+
"id": {
|
|
104
|
+
"name": "id",
|
|
105
|
+
"type": "text",
|
|
106
|
+
"primaryKey": true,
|
|
107
|
+
"notNull": true
|
|
108
|
+
},
|
|
109
|
+
"team_id": {
|
|
110
|
+
"name": "team_id",
|
|
111
|
+
"type": "text",
|
|
112
|
+
"primaryKey": false,
|
|
113
|
+
"notNull": true
|
|
114
|
+
},
|
|
115
|
+
"status": {
|
|
116
|
+
"name": "status",
|
|
117
|
+
"type": "text",
|
|
118
|
+
"primaryKey": false,
|
|
119
|
+
"notNull": true
|
|
120
|
+
},
|
|
121
|
+
"next_run_at_ms": {
|
|
122
|
+
"name": "next_run_at_ms",
|
|
123
|
+
"type": "bigint",
|
|
124
|
+
"primaryKey": false,
|
|
125
|
+
"notNull": false
|
|
126
|
+
},
|
|
127
|
+
"run_now_at_ms": {
|
|
128
|
+
"name": "run_now_at_ms",
|
|
129
|
+
"type": "bigint",
|
|
130
|
+
"primaryKey": false,
|
|
131
|
+
"notNull": false
|
|
132
|
+
},
|
|
133
|
+
"created_at_ms": {
|
|
134
|
+
"name": "created_at_ms",
|
|
135
|
+
"type": "bigint",
|
|
136
|
+
"primaryKey": false,
|
|
137
|
+
"notNull": true
|
|
138
|
+
},
|
|
139
|
+
"record": {
|
|
140
|
+
"name": "record",
|
|
141
|
+
"type": "jsonb",
|
|
142
|
+
"primaryKey": false,
|
|
143
|
+
"notNull": true
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
"indexes": {
|
|
147
|
+
"junior_scheduler_tasks_team_status_idx": {
|
|
148
|
+
"name": "junior_scheduler_tasks_team_status_idx",
|
|
149
|
+
"columns": [
|
|
150
|
+
{
|
|
151
|
+
"expression": "team_id",
|
|
152
|
+
"isExpression": false,
|
|
153
|
+
"asc": true,
|
|
154
|
+
"nulls": "last"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"expression": "created_at_ms",
|
|
158
|
+
"isExpression": false,
|
|
159
|
+
"asc": true,
|
|
160
|
+
"nulls": "last"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"expression": "id",
|
|
164
|
+
"isExpression": false,
|
|
165
|
+
"asc": true,
|
|
166
|
+
"nulls": "last"
|
|
167
|
+
}
|
|
168
|
+
],
|
|
169
|
+
"isUnique": false,
|
|
170
|
+
"with": {},
|
|
171
|
+
"method": "btree",
|
|
172
|
+
"where": "\"junior_scheduler_tasks\".\"status\" <> 'deleted'",
|
|
173
|
+
"concurrently": false
|
|
174
|
+
},
|
|
175
|
+
"junior_scheduler_tasks_run_now_due_idx": {
|
|
176
|
+
"name": "junior_scheduler_tasks_run_now_due_idx",
|
|
177
|
+
"columns": [
|
|
178
|
+
{
|
|
179
|
+
"expression": "run_now_at_ms",
|
|
180
|
+
"isExpression": false,
|
|
181
|
+
"asc": true,
|
|
182
|
+
"nulls": "last"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"expression": "created_at_ms",
|
|
186
|
+
"isExpression": false,
|
|
187
|
+
"asc": true,
|
|
188
|
+
"nulls": "last"
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
"expression": "id",
|
|
192
|
+
"isExpression": false,
|
|
193
|
+
"asc": true,
|
|
194
|
+
"nulls": "last"
|
|
195
|
+
}
|
|
196
|
+
],
|
|
197
|
+
"isUnique": false,
|
|
198
|
+
"with": {},
|
|
199
|
+
"method": "btree",
|
|
200
|
+
"where": "\"junior_scheduler_tasks\".\"status\" = 'active' AND \"junior_scheduler_tasks\".\"run_now_at_ms\" IS NOT NULL",
|
|
201
|
+
"concurrently": false
|
|
202
|
+
},
|
|
203
|
+
"junior_scheduler_tasks_next_run_due_idx": {
|
|
204
|
+
"name": "junior_scheduler_tasks_next_run_due_idx",
|
|
205
|
+
"columns": [
|
|
206
|
+
{
|
|
207
|
+
"expression": "next_run_at_ms",
|
|
208
|
+
"isExpression": false,
|
|
209
|
+
"asc": true,
|
|
210
|
+
"nulls": "last"
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
"expression": "created_at_ms",
|
|
214
|
+
"isExpression": false,
|
|
215
|
+
"asc": true,
|
|
216
|
+
"nulls": "last"
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
"expression": "id",
|
|
220
|
+
"isExpression": false,
|
|
221
|
+
"asc": true,
|
|
222
|
+
"nulls": "last"
|
|
223
|
+
}
|
|
224
|
+
],
|
|
225
|
+
"isUnique": false,
|
|
226
|
+
"with": {},
|
|
227
|
+
"method": "btree",
|
|
228
|
+
"where": "\"junior_scheduler_tasks\".\"status\" = 'active' AND \"junior_scheduler_tasks\".\"next_run_at_ms\" IS NOT NULL",
|
|
229
|
+
"concurrently": false
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
"foreignKeys": {},
|
|
233
|
+
"compositePrimaryKeys": {},
|
|
234
|
+
"uniqueConstraints": {},
|
|
235
|
+
"policies": {},
|
|
236
|
+
"checkConstraints": {},
|
|
237
|
+
"isRLSEnabled": false
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
"enums": {},
|
|
241
|
+
"schemas": {},
|
|
242
|
+
"views": {},
|
|
243
|
+
"sequences": {},
|
|
244
|
+
"roles": {},
|
|
245
|
+
"policies": {},
|
|
246
|
+
"_meta": {
|
|
247
|
+
"columns": {},
|
|
248
|
+
"schemas": {},
|
|
249
|
+
"tables": {}
|
|
250
|
+
}
|
|
251
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/junior-scheduler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.102.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"drizzle-orm": "^0.45.2",
|
|
27
27
|
"zod": "^4.4.3",
|
|
28
|
-
"@sentry/junior-plugin-api": "0.
|
|
28
|
+
"@sentry/junior-plugin-api": "0.102.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^25.9.1",
|
package/src/plugin.ts
CHANGED
|
@@ -118,7 +118,6 @@ function createSchedulerToolContext(
|
|
|
118
118
|
ctx: ToolRegistrationHookContext,
|
|
119
119
|
): SchedulerToolContext {
|
|
120
120
|
return {
|
|
121
|
-
credentialSubject: ctx.slack?.credentialSubject,
|
|
122
121
|
source: ctx.source.platform === "slack" ? ctx.source : undefined,
|
|
123
122
|
actor: ctx.actor?.platform === "slack" ? ctx.actor : undefined,
|
|
124
123
|
store: schedulerStore(ctx),
|
|
@@ -426,6 +425,16 @@ export function createSchedulerPlugin() {
|
|
|
426
425
|
},
|
|
427
426
|
packageName: "@sentry/junior-scheduler",
|
|
428
427
|
hooks: {
|
|
428
|
+
systemPrompt(ctx) {
|
|
429
|
+
if (ctx.platform !== "slack") {
|
|
430
|
+
return [];
|
|
431
|
+
}
|
|
432
|
+
return [
|
|
433
|
+
{
|
|
434
|
+
text: "Scheduled tasks use system credentials by default. Use the task creator's connected credentials only when they explicitly authorize future scheduled use. Requests such as 'use my account if needed' are ambiguous, not authorization; ask before creating or enabling creator credentials for the task.",
|
|
435
|
+
},
|
|
436
|
+
];
|
|
437
|
+
},
|
|
429
438
|
tools(ctx) {
|
|
430
439
|
if (
|
|
431
440
|
ctx.source.platform !== "slack" ||
|
|
@@ -522,11 +531,18 @@ export function createSchedulerPlugin() {
|
|
|
522
531
|
}
|
|
523
532
|
let dispatch: Awaited<ReturnType<typeof ctx.agent.dispatch>>;
|
|
524
533
|
try {
|
|
534
|
+
const credentialSubject =
|
|
535
|
+
task.credentialMode === "creator"
|
|
536
|
+
? {
|
|
537
|
+
type: "user" as const,
|
|
538
|
+
userId: task.createdBy.slackUserId,
|
|
539
|
+
allowedWhen: "scheduled-task" as const,
|
|
540
|
+
taskId: task.id,
|
|
541
|
+
}
|
|
542
|
+
: undefined;
|
|
525
543
|
dispatch = await ctx.agent.dispatch({
|
|
526
544
|
idempotencyKey: run.id,
|
|
527
|
-
...(
|
|
528
|
-
? { credentialSubject: task.credentialSubject }
|
|
529
|
-
: {}),
|
|
545
|
+
...(credentialSubject ? { credentialSubject } : {}),
|
|
530
546
|
destination: task.destination,
|
|
531
547
|
input: task.task.text,
|
|
532
548
|
metadata: dispatchMetadata,
|