@sentry/junior-scheduler 0.90.0 → 0.92.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.js +15 -15
- package/dist/tool-support.d.ts +4 -4
- package/dist/types.d.ts +4 -7
- package/package.json +2 -2
- package/src/plugin.ts +2 -2
- package/src/store.ts +2 -2
- package/src/tool-support.ts +10 -14
- package/src/tools/create-task.ts +3 -3
- package/src/types.ts +4 -6
package/dist/index.js
CHANGED
|
@@ -462,8 +462,8 @@ var taskRecordSchema = z.object({
|
|
|
462
462
|
credentialSubject: pluginCredentialSubjectSchema.optional(),
|
|
463
463
|
destination: slackDestinationSchema,
|
|
464
464
|
executionActor: z.object({
|
|
465
|
-
|
|
466
|
-
|
|
465
|
+
platform: z.literal("system"),
|
|
466
|
+
name: z.string()
|
|
467
467
|
}).strict().optional(),
|
|
468
468
|
lastRunAtMs: z.number().optional(),
|
|
469
469
|
nextRunAtMs: z.number().optional(),
|
|
@@ -1154,8 +1154,8 @@ import { z as z3 } from "zod";
|
|
|
1154
1154
|
|
|
1155
1155
|
// src/types.ts
|
|
1156
1156
|
var SCHEDULED_TASK_SYSTEM_ACTOR = Object.freeze({
|
|
1157
|
-
|
|
1158
|
-
|
|
1157
|
+
platform: "system",
|
|
1158
|
+
name: "scheduled-task"
|
|
1159
1159
|
});
|
|
1160
1160
|
|
|
1161
1161
|
// src/tool-support.ts
|
|
@@ -1240,18 +1240,18 @@ function requireActiveConversation(context) {
|
|
|
1240
1240
|
channelId: parsed.data.channelId
|
|
1241
1241
|
};
|
|
1242
1242
|
}
|
|
1243
|
-
function
|
|
1244
|
-
if (context.
|
|
1245
|
-
throwToolInputError("No active Slack
|
|
1243
|
+
function requireActor(context) {
|
|
1244
|
+
if (context.actor?.platform !== "slack") {
|
|
1245
|
+
throwToolInputError("No active Slack actor context is available.");
|
|
1246
1246
|
}
|
|
1247
|
-
const userId = context.
|
|
1247
|
+
const userId = context.actor?.userId?.trim();
|
|
1248
1248
|
if (!userId || userId.toLowerCase() === "unknown") {
|
|
1249
|
-
throwToolInputError("No active Slack
|
|
1249
|
+
throwToolInputError("No active Slack actor context is available.");
|
|
1250
1250
|
}
|
|
1251
1251
|
return sanitizeScheduledTaskPrincipal({
|
|
1252
1252
|
slackUserId: userId,
|
|
1253
|
-
...context.
|
|
1254
|
-
...context.
|
|
1253
|
+
...context.actor?.userName ? { userName: context.actor.userName } : {},
|
|
1254
|
+
...context.actor?.fullName ? { fullName: context.actor.fullName } : {}
|
|
1255
1255
|
});
|
|
1256
1256
|
}
|
|
1257
1257
|
function isDmChannel(channelId) {
|
|
@@ -1472,7 +1472,7 @@ function createSlackScheduleCreateTaskTool(context) {
|
|
|
1472
1472
|
outputSchema: scheduleTaskToolResultSchema,
|
|
1473
1473
|
execute: async (input) => {
|
|
1474
1474
|
const destination = requireActiveConversation(context);
|
|
1475
|
-
const
|
|
1475
|
+
const actor = requireActor(context);
|
|
1476
1476
|
const nowMs = Date.now();
|
|
1477
1477
|
const timezone = input.timezone ?? getDefaultScheduleTimezone();
|
|
1478
1478
|
validateCreateScheduleKind(input);
|
|
@@ -1498,7 +1498,7 @@ function createSlackScheduleCreateTaskTool(context) {
|
|
|
1498
1498
|
id: buildTaskId(),
|
|
1499
1499
|
createdAtMs: nowMs,
|
|
1500
1500
|
updatedAtMs: nowMs,
|
|
1501
|
-
createdBy:
|
|
1501
|
+
createdBy: actor,
|
|
1502
1502
|
conversationAccess,
|
|
1503
1503
|
...credentialSubject ? { credentialSubject } : {},
|
|
1504
1504
|
destination,
|
|
@@ -1754,7 +1754,7 @@ function createSchedulerToolContext(ctx) {
|
|
|
1754
1754
|
return {
|
|
1755
1755
|
credentialSubject: ctx.slack?.credentialSubject,
|
|
1756
1756
|
source: ctx.source.platform === "slack" ? ctx.source : void 0,
|
|
1757
|
-
|
|
1757
|
+
actor: ctx.actor?.platform === "slack" ? ctx.actor : void 0,
|
|
1758
1758
|
store: schedulerStore2(ctx),
|
|
1759
1759
|
userText: ctx.userText
|
|
1760
1760
|
};
|
|
@@ -2008,7 +2008,7 @@ function createSchedulerPlugin() {
|
|
|
2008
2008
|
packageName: "@sentry/junior-scheduler",
|
|
2009
2009
|
hooks: {
|
|
2010
2010
|
tools(ctx) {
|
|
2011
|
-
if (ctx.source.platform !== "slack" || ctx.
|
|
2011
|
+
if (ctx.source.platform !== "slack" || ctx.actor?.platform !== "slack") {
|
|
2012
2012
|
return {};
|
|
2013
2013
|
}
|
|
2014
2014
|
const context = createSchedulerToolContext(ctx);
|
package/dist/tool-support.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { type PluginCredentialSubject, type SlackDestination, type
|
|
1
|
+
import { type PluginCredentialSubject, 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
6
|
credentialSubject?: PluginCredentialSubject;
|
|
7
|
-
|
|
7
|
+
actor?: SlackActor;
|
|
8
8
|
source?: SlackSource;
|
|
9
9
|
store: SchedulerStore;
|
|
10
10
|
userText?: string;
|
|
@@ -142,8 +142,8 @@ export type CompactTaskResult = z.output<typeof compactTaskResultSchema>;
|
|
|
142
142
|
export declare function throwToolInputError(error: string): never;
|
|
143
143
|
/** Require scheduler mutations to stay scoped to the active Slack conversation. */
|
|
144
144
|
export declare function requireActiveConversation(context: SchedulerToolContext): SlackDestination;
|
|
145
|
-
/** Require a concrete Slack
|
|
146
|
-
export declare function
|
|
145
|
+
/** Require a concrete Slack actor before creating scheduler ownership state. */
|
|
146
|
+
export declare function requireActor(context: SchedulerToolContext): ScheduledTaskPrincipal;
|
|
147
147
|
/** Preserve destination visibility so scheduled work can replay with matching access. */
|
|
148
148
|
export declare function getConversationAccess(destination: SlackDestination): ScheduledTaskConversationAccess;
|
|
149
149
|
/** Carry private-DM credential authority only when scheduled work is allowed to reuse it. */
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PluginCredentialSubject, SlackDestination } from "@sentry/junior-plugin-api";
|
|
1
|
+
import type { PluginCredentialSubject, SlackDestination, SystemActor } from "@sentry/junior-plugin-api";
|
|
2
2
|
export type ScheduledTaskStatus = "active" | "paused" | "blocked" | "deleted";
|
|
3
3
|
export type ScheduledRunStatus = "pending" | "running" | "completed" | "failed" | "blocked" | "skipped";
|
|
4
4
|
export interface ScheduledTaskPrincipal {
|
|
@@ -6,13 +6,10 @@ export interface ScheduledTaskPrincipal {
|
|
|
6
6
|
fullName?: string;
|
|
7
7
|
userName?: string;
|
|
8
8
|
}
|
|
9
|
-
export
|
|
10
|
-
type: "system";
|
|
11
|
-
id: string;
|
|
12
|
-
}
|
|
9
|
+
export type ScheduledTaskExecutionActor = SystemActor;
|
|
13
10
|
export declare const SCHEDULED_TASK_SYSTEM_ACTOR: Readonly<{
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
platform: "system";
|
|
12
|
+
name: string;
|
|
16
13
|
}>;
|
|
17
14
|
export interface ScheduledTaskConversationAccess {
|
|
18
15
|
audience: "direct" | "group" | "channel";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/junior-scheduler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.92.0",
|
|
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.92.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^25.9.1",
|
package/src/plugin.ts
CHANGED
|
@@ -120,7 +120,7 @@ function createSchedulerToolContext(
|
|
|
120
120
|
return {
|
|
121
121
|
credentialSubject: ctx.slack?.credentialSubject,
|
|
122
122
|
source: ctx.source.platform === "slack" ? ctx.source : undefined,
|
|
123
|
-
|
|
123
|
+
actor: ctx.actor?.platform === "slack" ? ctx.actor : undefined,
|
|
124
124
|
store: schedulerStore(ctx),
|
|
125
125
|
userText: ctx.userText,
|
|
126
126
|
};
|
|
@@ -429,7 +429,7 @@ export function createSchedulerPlugin() {
|
|
|
429
429
|
tools(ctx) {
|
|
430
430
|
if (
|
|
431
431
|
ctx.source.platform !== "slack" ||
|
|
432
|
-
ctx.
|
|
432
|
+
ctx.actor?.platform !== "slack"
|
|
433
433
|
) {
|
|
434
434
|
return {} as Record<string, PluginToolDefinition>;
|
|
435
435
|
}
|
package/src/store.ts
CHANGED
package/src/tool-support.ts
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
sourceSchema,
|
|
7
7
|
type PluginCredentialSubject,
|
|
8
8
|
type SlackDestination,
|
|
9
|
-
type
|
|
9
|
+
type SlackActor,
|
|
10
10
|
type SlackSource,
|
|
11
11
|
} from "@sentry/junior-plugin-api";
|
|
12
12
|
import { z } from "zod";
|
|
@@ -24,7 +24,7 @@ import type {
|
|
|
24
24
|
|
|
25
25
|
export interface SchedulerToolContext {
|
|
26
26
|
credentialSubject?: PluginCredentialSubject;
|
|
27
|
-
|
|
27
|
+
actor?: SlackActor;
|
|
28
28
|
source?: SlackSource;
|
|
29
29
|
store: SchedulerStore;
|
|
30
30
|
userText?: string;
|
|
@@ -129,26 +129,22 @@ export function requireActiveConversation(
|
|
|
129
129
|
};
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
/** Require a concrete Slack
|
|
133
|
-
export function
|
|
132
|
+
/** Require a concrete Slack actor before creating scheduler ownership state. */
|
|
133
|
+
export function requireActor(
|
|
134
134
|
context: SchedulerToolContext,
|
|
135
135
|
): ScheduledTaskPrincipal {
|
|
136
|
-
if (context.
|
|
137
|
-
throwToolInputError("No active Slack
|
|
136
|
+
if (context.actor?.platform !== "slack") {
|
|
137
|
+
throwToolInputError("No active Slack actor context is available.");
|
|
138
138
|
}
|
|
139
|
-
const userId = context.
|
|
139
|
+
const userId = context.actor?.userId?.trim();
|
|
140
140
|
if (!userId || userId.toLowerCase() === "unknown") {
|
|
141
|
-
throwToolInputError("No active Slack
|
|
141
|
+
throwToolInputError("No active Slack actor context is available.");
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
return sanitizeScheduledTaskPrincipal({
|
|
145
145
|
slackUserId: userId,
|
|
146
|
-
...(context.
|
|
147
|
-
|
|
148
|
-
: {}),
|
|
149
|
-
...(context.requester?.fullName
|
|
150
|
-
? { fullName: context.requester.fullName }
|
|
151
|
-
: {}),
|
|
146
|
+
...(context.actor?.userName ? { userName: context.actor.userName } : {}),
|
|
147
|
+
...(context.actor?.fullName ? { fullName: context.actor.fullName } : {}),
|
|
152
148
|
});
|
|
153
149
|
}
|
|
154
150
|
|
package/src/tools/create-task.ts
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
isValidTimeZone,
|
|
13
13
|
parseNextRunAtMs,
|
|
14
14
|
requireActiveConversation,
|
|
15
|
-
|
|
15
|
+
requireActor,
|
|
16
16
|
scheduleTaskToolResult,
|
|
17
17
|
scheduleTaskToolResultSchema,
|
|
18
18
|
schedulerStore,
|
|
@@ -64,7 +64,7 @@ export function createSlackScheduleCreateTaskTool(
|
|
|
64
64
|
outputSchema: scheduleTaskToolResultSchema,
|
|
65
65
|
execute: async (input) => {
|
|
66
66
|
const destination = requireActiveConversation(context);
|
|
67
|
-
const
|
|
67
|
+
const actor = requireActor(context);
|
|
68
68
|
|
|
69
69
|
const nowMs = Date.now();
|
|
70
70
|
const timezone = input.timezone ?? getDefaultScheduleTimezone();
|
|
@@ -92,7 +92,7 @@ export function createSlackScheduleCreateTaskTool(
|
|
|
92
92
|
id: buildTaskId(),
|
|
93
93
|
createdAtMs: nowMs,
|
|
94
94
|
updatedAtMs: nowMs,
|
|
95
|
-
createdBy:
|
|
95
|
+
createdBy: actor,
|
|
96
96
|
conversationAccess,
|
|
97
97
|
...(credentialSubject ? { credentialSubject } : {}),
|
|
98
98
|
destination,
|
package/src/types.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
PluginCredentialSubject,
|
|
3
3
|
SlackDestination,
|
|
4
|
+
SystemActor,
|
|
4
5
|
} from "@sentry/junior-plugin-api";
|
|
5
6
|
|
|
6
7
|
export type ScheduledTaskStatus = "active" | "paused" | "blocked" | "deleted";
|
|
@@ -19,14 +20,11 @@ export interface ScheduledTaskPrincipal {
|
|
|
19
20
|
userName?: string;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
export
|
|
23
|
-
type: "system";
|
|
24
|
-
id: string;
|
|
25
|
-
}
|
|
23
|
+
export type ScheduledTaskExecutionActor = SystemActor;
|
|
26
24
|
|
|
27
25
|
export const SCHEDULED_TASK_SYSTEM_ACTOR = Object.freeze({
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
platform: "system",
|
|
27
|
+
name: "scheduled-task",
|
|
30
28
|
} satisfies ScheduledTaskExecutionActor);
|
|
31
29
|
|
|
32
30
|
export interface ScheduledTaskConversationAccess {
|