@sentry/junior-scheduler 0.107.1 → 0.108.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,61 @@
1
+ /**
2
+ * Owns model-facing schedule intent and materializes it against the trusted
3
+ * server clock into the canonical schedule persisted by the scheduler.
4
+ */
5
+ import { z } from "zod";
6
+ import type { ScheduledTaskSchedule } from "./types";
7
+ export declare const scheduleIntentSchema: z.ZodUnion<readonly [z.ZodObject<{
8
+ kind: z.ZodLiteral<"one_off">;
9
+ timezone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
10
+ timing: z.ZodDiscriminatedUnion<[z.ZodObject<{
11
+ type: z.ZodLiteral<"after">;
12
+ value: z.ZodNumber;
13
+ unit: z.ZodEnum<{
14
+ day: "day";
15
+ hour: "hour";
16
+ minute: "minute";
17
+ second: "second";
18
+ week: "week";
19
+ }>;
20
+ }, z.core.$strict>, z.ZodObject<{
21
+ type: z.ZodLiteral<"at">;
22
+ date: z.ZodString;
23
+ time: z.ZodString;
24
+ }, z.core.$strict>], "type">;
25
+ }, z.core.$strict>, z.ZodObject<{
26
+ kind: z.ZodLiteral<"recurring">;
27
+ frequency: z.ZodEnum<{
28
+ daily: "daily";
29
+ weekly: "weekly";
30
+ monthly: "monthly";
31
+ yearly: "yearly";
32
+ }>;
33
+ interval: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
34
+ time: z.ZodString;
35
+ weekdays: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<{
36
+ sunday: "sunday";
37
+ monday: "monday";
38
+ tuesday: "tuesday";
39
+ wednesday: "wednesday";
40
+ thursday: "thursday";
41
+ friday: "friday";
42
+ saturday: "saturday";
43
+ }>>>>;
44
+ day_of_month: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
45
+ month: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
46
+ start_date: z.ZodOptional<z.ZodNullable<z.ZodString>>;
47
+ timezone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
48
+ }, z.core.$strict>]>;
49
+ export type ScheduleIntent = z.infer<typeof scheduleIntentSchema>;
50
+ export interface CompiledScheduleIntent {
51
+ nextRunAtMs: number;
52
+ schedule: ScheduledTaskSchedule;
53
+ }
54
+ export declare class ScheduleIntentError extends Error {
55
+ }
56
+ /** Materialize model-interpreted schedule intent against the trusted server clock. */
57
+ export declare function compileScheduleIntent(args: {
58
+ defaultTimezone: string;
59
+ intent: ScheduleIntent;
60
+ nowMs: number;
61
+ }): CompiledScheduleIntent;
package/dist/store.d.ts CHANGED
@@ -8,6 +8,7 @@ export interface SchedulerStore {
8
8
  claimDueRun(args: {
9
9
  nowMs: number;
10
10
  }): Promise<ScheduledRun | undefined>;
11
+ createTask(task: ScheduledTask): Promise<ScheduledTask>;
11
12
  getRun(runId: string): Promise<ScheduledRun | undefined>;
12
13
  getTask(taskId: string): Promise<ScheduledTask | undefined>;
13
14
  listIncompleteRuns(): Promise<ScheduledRun[]>;
@@ -1,9 +1,10 @@
1
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
- import type { ScheduledTask, ScheduledTaskConversationAccess, ScheduledTaskPrincipal, ScheduledTaskRecurrence, ScheduledTaskStatus } from "./types";
4
+ import type { ScheduledTask, ScheduledTaskConversationAccess, ScheduledTaskPrincipal, ScheduledTaskStatus } from "./types";
5
5
  export interface SchedulerToolContext {
6
6
  actor?: SlackActor;
7
+ now?: () => number;
7
8
  source?: SlackSource;
8
9
  store: SchedulerStore;
9
10
  userText?: string;
@@ -245,40 +246,16 @@ export declare function scheduleListToolResult(args: {
245
246
  }[];
246
247
  readonly truncated: boolean;
247
248
  };
248
- /** Prefix generated scheduler ids so tool results are distinguishable from provider ids. */
249
- export declare function buildTaskId(): string;
249
+ /** Build a retry-stable scheduler id scoped to the creating actor and destination. */
250
+ export declare function buildTaskId(args: {
251
+ actor: ScheduledTaskPrincipal;
252
+ destination: SlackDestination;
253
+ toolCallId: string | undefined;
254
+ }): string;
250
255
  /** Keep concrete scheduler tools coupled to the injected store, not global state. */
251
256
  export declare function schedulerStore(context: SchedulerToolContext): SchedulerStore;
252
257
  /** Accept only persisted scheduler statuses from model-facing update input. */
253
258
  export declare function normalizeStatus(value: string | undefined): ScheduledTaskStatus | undefined;
254
- /** Rebuild recurrence only from validated daily-or-slower schedule requests. */
255
- export declare function buildRecurrence(args: {
256
- existing?: ScheduledTaskRecurrence;
257
- input: {
258
- recurrence?: unknown;
259
- };
260
- nextRunAtMs: number | undefined;
261
- timezone: string;
262
- }): ScheduledTaskRecurrence | undefined;
263
- /** Reject recurrence values that would exceed the scheduler cadence policy. */
264
- export declare function validateRecurringFrequencyLimit(input: {
265
- recurrence?: unknown;
266
- }): void;
267
- /** Force create-tool callers to explicitly choose one-off versus recurring semantics. */
268
- export declare function validateCreateScheduleKind(input: {
269
- recurrence?: unknown;
270
- schedule_kind?: unknown;
271
- }): void;
272
- /** Detect update inputs that affect calendar recurrence materialization. */
273
- export declare function shouldRebuildRecurrence(input: {
274
- next_run_at?: string;
275
- recurrence?: unknown;
276
- timezone?: string;
277
- }): boolean;
278
259
  /** Centralize scheduler timezone defaulting for all concrete tool entry points. */
279
260
  export declare function getDefaultScheduleTimezone(): string;
280
- /** Validate IANA timezone names before persisting scheduler cadence state. */
281
- export declare function isValidTimeZone(timezone: string): boolean;
282
- /** Parse model-supplied timestamps without leaking date parser details to tools. */
283
- export declare function parseNextRunAtMs(nextRunAtIso: string | undefined): number | undefined;
284
261
  export {};
@@ -2,11 +2,29 @@ import { type SchedulerToolContext } from "../tool-support";
2
2
  /** Create a tool that stores a scheduled task for the active Slack context. */
3
3
  export declare function createSlackScheduleCreateTaskTool(context: SchedulerToolContext): import("@sentry/junior-plugin-api").PluginToolDefinition<{
4
4
  task: string;
5
- schedule: string;
6
- schedule_kind: "one_off" | "recurring";
7
- timezone?: string | undefined;
8
- next_run_at?: string | undefined;
9
- recurrence?: "daily" | "weekly" | "monthly" | "yearly" | null | undefined;
5
+ schedule: {
6
+ kind: "recurring";
7
+ frequency: "daily" | "weekly" | "monthly" | "yearly";
8
+ time: string;
9
+ interval?: number | null | undefined;
10
+ weekdays?: ("sunday" | "monday" | "tuesday" | "wednesday" | "thursday" | "friday" | "saturday")[] | null | undefined;
11
+ day_of_month?: number | null | undefined;
12
+ month?: number | null | undefined;
13
+ start_date?: string | null | undefined;
14
+ timezone?: string | null | undefined;
15
+ } | {
16
+ kind: "one_off";
17
+ timing: {
18
+ type: "after";
19
+ value: number;
20
+ unit: "day" | "hour" | "minute" | "second" | "week";
21
+ } | {
22
+ type: "at";
23
+ date: string;
24
+ time: string;
25
+ };
26
+ timezone?: string | null | undefined;
27
+ };
10
28
  credential_mode?: "system" | "creator" | null | undefined;
11
29
  }, {
12
30
  [x: string]: unknown;
@@ -3,10 +3,29 @@ import { type SchedulerToolContext } from "../tool-support";
3
3
  export declare function createSlackScheduleUpdateTaskTool(context: SchedulerToolContext): import("@sentry/junior-plugin-api").PluginToolDefinition<{
4
4
  task_id: string;
5
5
  task?: string | undefined;
6
- schedule?: string | undefined;
7
- timezone?: string | undefined;
8
- next_run_at?: string | undefined;
9
- recurrence?: "daily" | "weekly" | "monthly" | "yearly" | null | undefined;
6
+ schedule?: {
7
+ kind: "recurring";
8
+ frequency: "daily" | "weekly" | "monthly" | "yearly";
9
+ time: string;
10
+ interval?: number | null | undefined;
11
+ weekdays?: ("sunday" | "monday" | "tuesday" | "wednesday" | "thursday" | "friday" | "saturday")[] | null | undefined;
12
+ day_of_month?: number | null | undefined;
13
+ month?: number | null | undefined;
14
+ start_date?: string | null | undefined;
15
+ timezone?: string | null | undefined;
16
+ } | {
17
+ kind: "one_off";
18
+ timing: {
19
+ type: "after";
20
+ value: number;
21
+ unit: "day" | "hour" | "minute" | "second" | "week";
22
+ } | {
23
+ type: "at";
24
+ date: string;
25
+ time: string;
26
+ };
27
+ timezone?: string | null | undefined;
28
+ } | null | undefined;
10
29
  status?: "blocked" | "active" | "paused" | undefined;
11
30
  credential_mode?: "system" | "creator" | null | undefined;
12
31
  }, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/junior-scheduler",
3
- "version": "0.107.1",
3
+ "version": "0.108.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.107.1"
28
+ "@sentry/junior-plugin-api": "0.108.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/node": "^25.9.1",