@sentry/junior 0.239.0 → 0.241.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.
Files changed (64) hide show
  1. package/dist/{admin-Cc-iA6z9.js → admin-CJkjl-aN.js} +1 -1
  2. package/dist/{agent-hooks-DzfA5m3R.js → agent-hooks-C5zYOaJk.js} +1972 -1866
  3. package/dist/{agent-runner--1wC26S6.js → agent-runner-CMZ6lFQe.js} +377 -1227
  4. package/dist/api/schema.d.ts +9 -0
  5. package/dist/api/schema.js +2 -2
  6. package/dist/api.d.ts +1 -1
  7. package/dist/api.js +22 -21
  8. package/dist/{app-FB2hmHpZ.d.ts → app-MEd7wbF0.d.ts} +1 -1
  9. package/dist/app.d.ts +1 -1
  10. package/dist/app.js +105 -31
  11. package/dist/{automation-CrQGQ2MT.js → automation-gznOMaQ2.js} +13 -255
  12. package/dist/{briefs-DGc2Thua.js → briefs-CsQbFjRi.js} +2 -2
  13. package/dist/cadence-D00SCzT1.js +256 -0
  14. package/dist/{catalog-runtime-DpB_hG_I.js → catalog-runtime-Tz0O2MZe.js} +1 -1
  15. package/dist/cli/chat.js +12 -12
  16. package/dist/cli/check.js +3 -3
  17. package/dist/cli/main.js +2 -2
  18. package/dist/cli/plugins.js +4 -4
  19. package/dist/cli/snapshot-create.js +3 -3
  20. package/dist/cli/upgrade.d.ts +1 -1
  21. package/dist/cli/upgrade.js +3 -3
  22. package/dist/{client-DNf-sJmM.js → client-CRZ-i1tH.js} +2 -2
  23. package/dist/{config-B8QN-04U.js → config-CCI82OTD.js} +2 -2
  24. package/dist/{conversation-privacy-CrYizZM3.js → conversation-privacy-D5Byl5eC.js} +1 -1
  25. package/dist/{credential-sync-BG_Yvja8.js → credential-sync-DUpSxUum.js} +14 -14
  26. package/dist/{db-CWZP77Ex.d.ts → db-Ca9Nt5ci.d.ts} +1 -1
  27. package/dist/{executor-BQV1Zc1z.js → executor-CewKi7EG.js} +4 -2
  28. package/dist/{images-C_0iwPsW.js → images-DY6Pxq4w.js} +2 -2
  29. package/dist/instrumentation.js +2 -2
  30. package/dist/{job-queue-D82gksYM.js → job-queue-C6o2aJQ6.js} +1 -1
  31. package/dist/{logging-Crg0e1jb.js → logging-LQnLlPf8.js} +1 -1
  32. package/dist/nitro.d.ts +1 -1
  33. package/dist/nitro.js +3 -3
  34. package/dist/{oauth-authorization-Bdu39G-H.js → oauth-authorization-Clzkm-Ts.js} +1 -1
  35. package/dist/{oauth-callback-server-eJfI6skP.js → oauth-callback-server-DcYAJSEz.js} +2 -2
  36. package/dist/{pending-auth-DauOaies.js → pending-auth-CT3ojhKe.js} +2 -2
  37. package/dist/{profile-XzHSfIah.js → profile-mWuVZ8ht.js} +4 -4
  38. package/dist/{registry-BJME30oR.js → registry-DPDH6s5G.js} +1 -1
  39. package/dist/{resolve-ZKXfsZuZ.js → resolve-BAN8BSGy.js} +2 -2
  40. package/dist/{runner-DkHL8vRA.js → runner-CqXZJfzk.js} +9 -9
  41. package/dist/{sandbox-egress-signals-BEQsK7ym.js → sandbox-egress-signals-DFUUokws.js} +1 -1
  42. package/dist/{schema-CxWAN2zq.js → schema-Cabm4jcj.js} +1 -1
  43. package/dist/{skills-CMl248J3.js → skills-BtHhSATy.js} +2 -2
  44. package/dist/{spawn-DrvZYrTQ.js → spawn-BszkFJKJ.js} +2 -2
  45. package/dist/{store-BxxbxBlm.d.ts → store-DoewL5mG.d.ts} +0 -7
  46. package/dist/{task-queue-BMzTARMo.js → task-queue-1LP6benz.js} +3 -3
  47. package/dist/{task-runner-CXTpWSmw.js → task-runner-kLN3HC-_.js} +54 -12
  48. package/dist/{checkpoint-CN7yMfSo.js → tasks-CO52vLkI.js} +1064 -18
  49. package/dist/{thread-state-BM1sLptE.js → thread-state-CaFRG5Mh.js} +6 -6
  50. package/dist/{turn-failure-response-ISrbka5I.js → turn-failure-response-Dmovuiq1.js} +9 -8
  51. package/dist/{turn-lifecycle-f7TPxQsc.js → turn-lifecycle-DGqZgU6J.js} +1 -1
  52. package/dist/{turn-session-routing-BcAD7onh.js → turn-session-routing-B_v8Wbn4.js} +1 -1
  53. package/dist/{validation-Bo6BHmig.js → validation-B4L2Rmiw.js} +1 -1
  54. package/dist/{version-Cv__n5ue.js → version-DiR36OaN.js} +1 -1
  55. package/dist/version.js +1 -1
  56. package/dist/{viewer-EftpWXcF.js → viewer-D6stAU7h.js} +9 -11
  57. package/dist/{web-authorization-BLDXKk2u.js → web-authorization-DLMBx2nL.js} +6 -6
  58. package/dist/{web-input-DSa6geKr.js → web-input---xuox1t.js} +136 -147
  59. package/dist/{work-WOk5DovU.js → work-G-HdoOSF.js} +7 -7
  60. package/dist/{worker-B7rtMFzw.js → worker-CDUDfL9P.js} +5 -5
  61. package/migrations/0049_event_automation_status_reason.sql +1 -0
  62. package/migrations/meta/0049_snapshot.json +3581 -0
  63. package/migrations/meta/_journal.json +8 -1
  64. package/package.json +5 -5
@@ -1,3 +1,4 @@
1
+ import { a as resolveLocalScheduleAtMs, i as isValidTimeZone, r as getZonedDateTimeParts, t as getFirstRunAtMs } from "./cadence-D00SCzT1.js";
1
2
  import { z } from "zod";
2
3
  import { actorUserIdSchema, destinationVisibilitySchema, eventMatchSchema, eventTypeSchema, pluginEventTypeSchema, slackDestinationSchema, taskOutcomeSchema } from "@sentry/junior-plugin-api";
3
4
  //#region src/chat/task-outcomes-schema.ts
@@ -8,249 +9,6 @@ const taskOutcomeInputSchema = z.object({
8
9
  destination: taskMessageDestinationInputSchema
9
10
  }).strict();
10
11
  //#endregion
11
- //#region src/chat/scheduled-automations/cadence.ts
12
- const FORMATTERS = /* @__PURE__ */ new Map();
13
- function getFormatter(timezone) {
14
- const existing = FORMATTERS.get(timezone);
15
- if (existing) return existing;
16
- const formatter = new Intl.DateTimeFormat("en-US", {
17
- timeZone: timezone,
18
- hour12: false,
19
- year: "numeric",
20
- month: "2-digit",
21
- day: "2-digit",
22
- hour: "2-digit",
23
- minute: "2-digit",
24
- second: "2-digit"
25
- });
26
- FORMATTERS.set(timezone, formatter);
27
- return formatter;
28
- }
29
- function normalizeHour(hour) {
30
- return hour === 24 ? 0 : hour;
31
- }
32
- function getLocalDateWeekday(date) {
33
- return new Date(Date.UTC(date.year, date.month - 1, date.day)).getUTCDay();
34
- }
35
- function getWeekStart(date) {
36
- return addDays(date, -((getLocalDateWeekday(date) + 6) % 7));
37
- }
38
- /** Resolve a UTC timestamp into calendar parts for a named time zone. */
39
- function getZonedDateTimeParts(timestampMs, timezone) {
40
- const parts = getFormatter(timezone).formatToParts(new Date(timestampMs));
41
- const values = new Map(parts.map((part) => [part.type, part.value]));
42
- const year = Number(values.get("year"));
43
- const month = Number(values.get("month"));
44
- const day = Number(values.get("day"));
45
- return {
46
- year,
47
- month,
48
- day,
49
- hour: normalizeHour(Number(values.get("hour"))),
50
- minute: Number(values.get("minute")),
51
- second: Number(values.get("second")),
52
- weekday: getLocalDateWeekday({
53
- year,
54
- month,
55
- day
56
- })
57
- };
58
- }
59
- function getTimeZoneOffsetMs(timestampMs, timezone) {
60
- const parts = getZonedDateTimeParts(timestampMs, timezone);
61
- return Date.UTC(parts.year, parts.month - 1, parts.day, parts.hour, parts.minute, parts.second) - timestampMs;
62
- }
63
- function localDateTimeToTimestampMs(args) {
64
- const localAsUtcMs = Date.UTC(args.date.year, args.date.month - 1, args.date.day, args.time.hour, args.time.minute, 0);
65
- const offsets = /* @__PURE__ */ new Set();
66
- for (const probeDeltaMs of [
67
- -1296e5,
68
- -432e5,
69
- 0,
70
- 432e5,
71
- 1296e5
72
- ]) offsets.add(getTimeZoneOffsetMs(localAsUtcMs + probeDeltaMs, args.timezone));
73
- const matches = [...offsets].map((offsetMs) => localAsUtcMs - offsetMs).filter((timestampMs) => {
74
- const parts = getZonedDateTimeParts(timestampMs, args.timezone);
75
- return parts.year === args.date.year && parts.month === args.date.month && parts.day === args.date.day && parts.hour === args.time.hour && parts.minute === args.time.minute;
76
- });
77
- if (matches.length === 0) return;
78
- return Math.min(...matches);
79
- }
80
- /** Resolve local time, rejecting DST gaps and choosing the earlier instant in a fold. */
81
- function resolveLocalScheduleAtMs(args) {
82
- const date = parseLocalDate(args.date);
83
- if (!date) return;
84
- return localDateTimeToTimestampMs({
85
- date,
86
- time: args.time,
87
- timezone: args.timezone
88
- });
89
- }
90
- function daysBetween(left, right) {
91
- return Math.floor((Date.UTC(right.year, right.month - 1, right.day) - Date.UTC(left.year, left.month - 1, left.day)) / 864e5);
92
- }
93
- function weeklyRecurrenceMatchesDate(date, start, recurrence) {
94
- if (compareDate(date, start) < 0) return false;
95
- return normalizeWeekdays(recurrence.weekdays).includes(getLocalDateWeekday(date)) && Math.floor(daysBetween(getWeekStart(start), getWeekStart(date)) / 7) % recurrence.interval === 0;
96
- }
97
- function greatestCommonDivisor(left, right) {
98
- let a = Math.abs(left);
99
- let b = Math.abs(right);
100
- while (b !== 0) [a, b] = [b, a % b];
101
- return a;
102
- }
103
- function findNextRunAtMs(args) {
104
- const start = parseLocalDate(args.recurrence.startDate);
105
- const interval = args.recurrence.interval;
106
- if (!start || !Number.isInteger(interval) || interval <= 0) return;
107
- const searchFrom = compareDate(args.searchFrom, start) < 0 ? start : args.searchFrom;
108
- if (args.recurrence.frequency === "daily") {
109
- const offsetDays = daysBetween(start, searchFrom);
110
- let candidateDate = addDays(start, Math.ceil(offsetDays / interval) * interval);
111
- const gregorianCycleDays = 146097;
112
- const candidateCount = gregorianCycleDays / greatestCommonDivisor(gregorianCycleDays, interval);
113
- for (let attempts = 0; attempts < candidateCount; attempts += 1) {
114
- const candidate = buildCandidate({
115
- date: candidateDate,
116
- recurrence: args.recurrence,
117
- timezone: args.timezone
118
- });
119
- if (candidate !== void 0 && candidate > args.afterMs) return candidate;
120
- candidateDate = addDays(candidateDate, interval);
121
- }
122
- return;
123
- }
124
- if (args.recurrence.frequency === "weekly") {
125
- if (normalizeWeekdays(args.recurrence.weekdays).length === 0) return;
126
- let candidateDate = searchFrom;
127
- const gregorianCycleDays = 146097;
128
- const cadenceDays = interval * 7;
129
- const searchDays = gregorianCycleDays * cadenceDays / greatestCommonDivisor(gregorianCycleDays, cadenceDays);
130
- for (let attempts = 0; attempts < searchDays; attempts += 1) {
131
- if (weeklyRecurrenceMatchesDate(candidateDate, start, args.recurrence)) {
132
- const candidate = buildCandidate({
133
- date: candidateDate,
134
- recurrence: args.recurrence,
135
- timezone: args.timezone
136
- });
137
- if (candidate !== void 0 && candidate > args.afterMs) return candidate;
138
- }
139
- candidateDate = addDays(candidateDate, 1);
140
- }
141
- return;
142
- }
143
- if (args.recurrence.frequency === "monthly") {
144
- const startMonth = start.year * 12 + start.month - 1;
145
- const searchMonth = searchFrom.year * 12 + searchFrom.month - 1;
146
- let candidateMonth = startMonth + Math.ceil((searchMonth - startMonth) / interval) * interval;
147
- const gregorianCycleMonths = 4800;
148
- const candidateCount = gregorianCycleMonths / greatestCommonDivisor(gregorianCycleMonths, interval);
149
- for (let attempts = 0; attempts < candidateCount; attempts += 1) {
150
- const candidateDate = {
151
- year: Math.floor(candidateMonth / 12),
152
- month: candidateMonth % 12 + 1,
153
- day: args.recurrence.dayOfMonth ?? 0
154
- };
155
- if (compareDate(candidateDate, searchFrom) >= 0) {
156
- const candidate = buildCandidate({
157
- date: candidateDate,
158
- recurrence: args.recurrence,
159
- timezone: args.timezone
160
- });
161
- if (candidate !== void 0 && candidate > args.afterMs) return candidate;
162
- }
163
- candidateMonth += interval;
164
- }
165
- return;
166
- }
167
- let candidateYear = start.year + Math.ceil((searchFrom.year - start.year) / interval) * interval;
168
- const candidateCount = 400 / greatestCommonDivisor(400, interval);
169
- for (let attempts = 0; attempts < candidateCount; attempts += 1) {
170
- const candidateDate = {
171
- year: candidateYear,
172
- month: args.recurrence.month ?? 0,
173
- day: args.recurrence.dayOfMonth ?? 0
174
- };
175
- if (compareDate(candidateDate, searchFrom) >= 0) {
176
- const candidate = buildCandidate({
177
- date: candidateDate,
178
- recurrence: args.recurrence,
179
- timezone: args.timezone
180
- });
181
- if (candidate !== void 0 && candidate > args.afterMs) return candidate;
182
- }
183
- candidateYear += interval;
184
- }
185
- }
186
- /** Compute the first recurring calendar occurrence strictly after a timestamp. */
187
- function getFirstRunAtMs(args) {
188
- return findNextRunAtMs({
189
- ...args,
190
- searchFrom: getLocalDate(args.afterMs, args.timezone)
191
- });
192
- }
193
- function compareDate(left, right) {
194
- return Date.UTC(left.year, left.month - 1, left.day) - Date.UTC(right.year, right.month - 1, right.day);
195
- }
196
- function addDays(date, days) {
197
- const next = new Date(Date.UTC(date.year, date.month - 1, date.day + days));
198
- return {
199
- year: next.getUTCFullYear(),
200
- month: next.getUTCMonth() + 1,
201
- day: next.getUTCDate()
202
- };
203
- }
204
- function daysInMonth(year, month) {
205
- return new Date(Date.UTC(year, month, 0)).getUTCDate();
206
- }
207
- function parseLocalDate(value) {
208
- const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
209
- if (!match) return;
210
- const year = Number(match[1]);
211
- const month = Number(match[2]);
212
- const day = Number(match[3]);
213
- if (!Number.isInteger(year) || !Number.isInteger(month) || !Number.isInteger(day) || month < 1 || month > 12 || day < 1 || day > daysInMonth(year, month)) return;
214
- return {
215
- year,
216
- month,
217
- day
218
- };
219
- }
220
- function getLocalDate(timestampMs, timezone) {
221
- const parts = getZonedDateTimeParts(timestampMs, timezone);
222
- return {
223
- year: parts.year,
224
- month: parts.month,
225
- day: parts.day
226
- };
227
- }
228
- function normalizeWeekdays(values) {
229
- return [...new Set((values ?? []).filter((value) => value >= 0 && value <= 6))].sort((a, b) => a - b);
230
- }
231
- function buildCandidate(args) {
232
- return localDateTimeToTimestampMs({
233
- date: args.date,
234
- time: args.recurrence.time,
235
- timezone: args.timezone
236
- });
237
- }
238
- /** Return the next fire time after a completed run, when the task recurs. */
239
- function getNextRunAtMs(task, scheduledForMs, afterMs = scheduledForMs) {
240
- if (task.schedule.kind !== "recurring") return;
241
- const recurrence = task.schedule.recurrence;
242
- if (!recurrence || !Number.isFinite(recurrence.interval) || recurrence.interval <= 0) return;
243
- const timezone = task.schedule.timezone;
244
- const afterDate = getLocalDate(afterMs, timezone);
245
- const nextScheduledDate = addDays(getLocalDate(scheduledForMs, timezone), 1);
246
- return findNextRunAtMs({
247
- afterMs,
248
- recurrence,
249
- searchFrom: compareDate(afterDate, nextScheduledDate) < 0 ? nextScheduledDate : afterDate,
250
- timezone
251
- });
252
- }
253
- //#endregion
254
12
  //#region src/chat/scheduled-automations/schedule-intent.ts
255
13
  /**
256
14
  * Owns model-facing schedule intent and materializes it against the trusted
@@ -367,15 +125,6 @@ function localDateAt(timestampMs, timezone) {
367
125
  parts.day
368
126
  ].map((value, index) => index === 0 ? String(value).padStart(4, "0") : String(value).padStart(2, "0")).join("-");
369
127
  }
370
- /** Whether the runtime accepts this IANA timezone name. */
371
- function isValidTimeZone(timezone) {
372
- try {
373
- new Intl.DateTimeFormat("en-US", { timeZone: timezone }).format();
374
- return true;
375
- } catch {
376
- return false;
377
- }
378
- }
379
128
  function plural(value, unit) {
380
129
  return value === 1 ? unit : `${unit}s`;
381
130
  }
@@ -682,7 +431,12 @@ const eventAutomationSummarySchema = automationSummaryBaseSchema.extend({
682
431
  resource: z.string().min(1),
683
432
  source: z.string().min(1),
684
433
  triggerAvailable: z.boolean(),
685
- status: z.enum(["active", "paused"])
434
+ statusReason: z.string().optional(),
435
+ status: z.enum([
436
+ "active",
437
+ "blocked",
438
+ "paused"
439
+ ])
686
440
  }).strict();
687
441
  const automationSummarySchema = z.discriminatedUnion("kind", [scheduledAutomationSummarySchema, eventAutomationSummarySchema]);
688
442
  /** UTC day (`YYYY-MM-DD`) or hour (`YYYY-MM-DDTHH`) execution bucket key. */
@@ -866,7 +620,11 @@ const automationEditSchema = z.discriminatedUnion("kind", [automationEditBaseSch
866
620
  kind: z.literal("event"),
867
621
  trigger: eventAutomationTriggerSchema,
868
622
  triggerAvailable: z.boolean(),
869
- status: z.enum(["active", "paused"])
623
+ status: z.enum([
624
+ "active",
625
+ "blocked",
626
+ "paused"
627
+ ])
870
628
  }).strict()]);
871
629
  /** Partial edits require the revision returned by the edit read. */
872
630
  const automationUpdateSchema = z.discriminatedUnion("kind", [scheduledAutomationEditSchema.omit({ status: true }).extend({
@@ -890,4 +648,4 @@ const automationEventCatalogSchema = z.array(pluginEventTypeSchema.safeExtend({
890
648
  const automationScheduleIntentSchema = scheduleIntentSchema;
891
649
  const automationSchedulePreviewSchema = scheduledAutomationSchema.pick({ schedule: true }).extend({ nextRunAtMs: z.number() }).strict();
892
650
  //#endregion
893
- export { eventAutomationSchema as A, eventAutomationSummarySchema as C, scheduledRunSchema as D, scheduledAutomationSchema as E, weekdaySchema as F, getFirstRunAtMs as I, getNextRunAtMs as L, compileScheduleIntent as M, isValidTimeZone as N, automationInstructionToolSchema as O, scheduleIntentSchema as P, getZonedDateTimeParts as R, automationVersionSchema as S, SCHEDULED_AUTOMATION_SYSTEM_ACTOR as T, automationSummarySchema as _, automationExecutionSchema as a, automationVersionListSchema as b, automationLifecycleSchema as c, automationParamsSchema as d, automationRunListSchema as f, automationSchedulePreviewSchema as g, automationScheduleIntentSchema as h, automationExecutionListSchema as i, ScheduleIntentError as j, automationTitleSchema as k, automationListQuerySchema as l, automationRunWindowsSchema as m, automationEditSchema as n, automationExecutionStatusDaySchema as o, automationRunSchema as p, automationEventCatalogSchema as r, automationExecutionStatusSchema as s, automationEditErrorSchema as t, automationListSchema as u, automationUpdateSchema as v, scheduledAutomationSummarySchema as w, automationVersionParamsSchema as x, automationVersionActivateSchema as y, taskOutcomeInputSchema as z };
651
+ export { eventAutomationSchema as A, eventAutomationSummarySchema as C, scheduledRunSchema as D, scheduledAutomationSchema as E, taskOutcomeInputSchema as F, compileScheduleIntent as M, scheduleIntentSchema as N, automationInstructionToolSchema as O, weekdaySchema as P, automationVersionSchema as S, SCHEDULED_AUTOMATION_SYSTEM_ACTOR as T, automationSummarySchema as _, automationExecutionSchema as a, automationVersionListSchema as b, automationLifecycleSchema as c, automationParamsSchema as d, automationRunListSchema as f, automationSchedulePreviewSchema as g, automationScheduleIntentSchema as h, automationExecutionListSchema as i, ScheduleIntentError as j, automationTitleSchema as k, automationListQuerySchema as l, automationRunWindowsSchema as m, automationEditSchema as n, automationExecutionStatusDaySchema as o, automationRunSchema as p, automationEventCatalogSchema as r, automationExecutionStatusSchema as s, automationEditErrorSchema as t, automationListSchema as u, automationUpdateSchema as v, scheduledAutomationSummarySchema as w, automationVersionParamsSchema as x, automationVersionActivateSchema as y };
@@ -1,4 +1,4 @@
1
- import { r as completeObject } from "./client-DNf-sJmM.js";
1
+ import { r as completeObject } from "./client-CRZ-i1tH.js";
2
2
  import { r as defaultModelId } from "./model-profile-BwU8mqwD.js";
3
3
  import { B as parseBriefInput, I as briefCodeChangeSchema, d as conversationDetailReportSchema, p as conversationEventPageSchema } from "./conversation-DwD-vquD.js";
4
4
  import { n as briefEntriesFromReportEvents, s as generateBrief, t as BRIEF_PROMPT } from "./prompt-CMU-B4FA.js";
@@ -269,7 +269,7 @@ async function parseRunOptions(argv) {
269
269
  * `DATABASE_URL` at import, and `briefs pull` must work with only a token.
270
270
  */
271
271
  async function configuredDefaultModelId() {
272
- const { botConfig } = await import("./config-B8QN-04U.js").then((n) => n.r);
272
+ const { botConfig } = await import("./config-CCI82OTD.js").then((n) => n.r);
273
273
  return defaultModelId(botConfig);
274
274
  }
275
275
  function apiUrl(baseUrl, pathname) {
@@ -0,0 +1,256 @@
1
+ //#region src/chat/scheduled-automations/cadence.ts
2
+ const FORMATTERS = /* @__PURE__ */ new Map();
3
+ function getFormatter(timezone) {
4
+ const existing = FORMATTERS.get(timezone);
5
+ if (existing) return existing;
6
+ const formatter = new Intl.DateTimeFormat("en-US", {
7
+ timeZone: timezone,
8
+ hour12: false,
9
+ year: "numeric",
10
+ month: "2-digit",
11
+ day: "2-digit",
12
+ hour: "2-digit",
13
+ minute: "2-digit",
14
+ second: "2-digit"
15
+ });
16
+ FORMATTERS.set(timezone, formatter);
17
+ return formatter;
18
+ }
19
+ function normalizeHour(hour) {
20
+ return hour === 24 ? 0 : hour;
21
+ }
22
+ function getLocalDateWeekday(date) {
23
+ return new Date(Date.UTC(date.year, date.month - 1, date.day)).getUTCDay();
24
+ }
25
+ function getWeekStart(date) {
26
+ return addDays(date, -((getLocalDateWeekday(date) + 6) % 7));
27
+ }
28
+ /**
29
+ * Check that a value is an IANA time zone that this runtime knows. This module
30
+ * has no runtime imports, so the dashboard client bundle can use it.
31
+ */
32
+ function isValidTimeZone(timezone) {
33
+ try {
34
+ new Intl.DateTimeFormat("en-US", { timeZone: timezone }).format();
35
+ return true;
36
+ } catch {
37
+ return false;
38
+ }
39
+ }
40
+ /** Resolve a UTC timestamp into calendar parts for a named time zone. */
41
+ function getZonedDateTimeParts(timestampMs, timezone) {
42
+ const parts = getFormatter(timezone).formatToParts(new Date(timestampMs));
43
+ const values = new Map(parts.map((part) => [part.type, part.value]));
44
+ const year = Number(values.get("year"));
45
+ const month = Number(values.get("month"));
46
+ const day = Number(values.get("day"));
47
+ return {
48
+ year,
49
+ month,
50
+ day,
51
+ hour: normalizeHour(Number(values.get("hour"))),
52
+ minute: Number(values.get("minute")),
53
+ second: Number(values.get("second")),
54
+ weekday: getLocalDateWeekday({
55
+ year,
56
+ month,
57
+ day
58
+ })
59
+ };
60
+ }
61
+ function getTimeZoneOffsetMs(timestampMs, timezone) {
62
+ const parts = getZonedDateTimeParts(timestampMs, timezone);
63
+ return Date.UTC(parts.year, parts.month - 1, parts.day, parts.hour, parts.minute, parts.second) - timestampMs;
64
+ }
65
+ function localDateTimeToTimestampMs(args) {
66
+ const localAsUtcMs = Date.UTC(args.date.year, args.date.month - 1, args.date.day, args.time.hour, args.time.minute, 0);
67
+ const offsets = /* @__PURE__ */ new Set();
68
+ for (const probeDeltaMs of [
69
+ -1296e5,
70
+ -432e5,
71
+ 0,
72
+ 432e5,
73
+ 1296e5
74
+ ]) offsets.add(getTimeZoneOffsetMs(localAsUtcMs + probeDeltaMs, args.timezone));
75
+ const matches = [...offsets].map((offsetMs) => localAsUtcMs - offsetMs).filter((timestampMs) => {
76
+ const parts = getZonedDateTimeParts(timestampMs, args.timezone);
77
+ return parts.year === args.date.year && parts.month === args.date.month && parts.day === args.date.day && parts.hour === args.time.hour && parts.minute === args.time.minute;
78
+ });
79
+ if (matches.length === 0) return;
80
+ return Math.min(...matches);
81
+ }
82
+ /** Resolve local time, rejecting DST gaps and choosing the earlier instant in a fold. */
83
+ function resolveLocalScheduleAtMs(args) {
84
+ const date = parseLocalDate(args.date);
85
+ if (!date) return;
86
+ return localDateTimeToTimestampMs({
87
+ date,
88
+ time: args.time,
89
+ timezone: args.timezone
90
+ });
91
+ }
92
+ function daysBetween(left, right) {
93
+ return Math.floor((Date.UTC(right.year, right.month - 1, right.day) - Date.UTC(left.year, left.month - 1, left.day)) / 864e5);
94
+ }
95
+ function weeklyRecurrenceMatchesDate(date, start, recurrence) {
96
+ if (compareDate(date, start) < 0) return false;
97
+ return normalizeWeekdays(recurrence.weekdays).includes(getLocalDateWeekday(date)) && Math.floor(daysBetween(getWeekStart(start), getWeekStart(date)) / 7) % recurrence.interval === 0;
98
+ }
99
+ function greatestCommonDivisor(left, right) {
100
+ let a = Math.abs(left);
101
+ let b = Math.abs(right);
102
+ while (b !== 0) [a, b] = [b, a % b];
103
+ return a;
104
+ }
105
+ function findNextRunAtMs(args) {
106
+ const start = parseLocalDate(args.recurrence.startDate);
107
+ const interval = args.recurrence.interval;
108
+ if (!start || !Number.isInteger(interval) || interval <= 0) return;
109
+ const searchFrom = compareDate(args.searchFrom, start) < 0 ? start : args.searchFrom;
110
+ if (args.recurrence.frequency === "daily") {
111
+ const offsetDays = daysBetween(start, searchFrom);
112
+ let candidateDate = addDays(start, Math.ceil(offsetDays / interval) * interval);
113
+ const gregorianCycleDays = 146097;
114
+ const candidateCount = gregorianCycleDays / greatestCommonDivisor(gregorianCycleDays, interval);
115
+ for (let attempts = 0; attempts < candidateCount; attempts += 1) {
116
+ const candidate = buildCandidate({
117
+ date: candidateDate,
118
+ recurrence: args.recurrence,
119
+ timezone: args.timezone
120
+ });
121
+ if (candidate !== void 0 && candidate > args.afterMs) return candidate;
122
+ candidateDate = addDays(candidateDate, interval);
123
+ }
124
+ return;
125
+ }
126
+ if (args.recurrence.frequency === "weekly") {
127
+ if (normalizeWeekdays(args.recurrence.weekdays).length === 0) return;
128
+ let candidateDate = searchFrom;
129
+ const gregorianCycleDays = 146097;
130
+ const cadenceDays = interval * 7;
131
+ const searchDays = gregorianCycleDays * cadenceDays / greatestCommonDivisor(gregorianCycleDays, cadenceDays);
132
+ for (let attempts = 0; attempts < searchDays; attempts += 1) {
133
+ if (weeklyRecurrenceMatchesDate(candidateDate, start, args.recurrence)) {
134
+ const candidate = buildCandidate({
135
+ date: candidateDate,
136
+ recurrence: args.recurrence,
137
+ timezone: args.timezone
138
+ });
139
+ if (candidate !== void 0 && candidate > args.afterMs) return candidate;
140
+ }
141
+ candidateDate = addDays(candidateDate, 1);
142
+ }
143
+ return;
144
+ }
145
+ if (args.recurrence.frequency === "monthly") {
146
+ const startMonth = start.year * 12 + start.month - 1;
147
+ const searchMonth = searchFrom.year * 12 + searchFrom.month - 1;
148
+ let candidateMonth = startMonth + Math.ceil((searchMonth - startMonth) / interval) * interval;
149
+ const gregorianCycleMonths = 4800;
150
+ const candidateCount = gregorianCycleMonths / greatestCommonDivisor(gregorianCycleMonths, interval);
151
+ for (let attempts = 0; attempts < candidateCount; attempts += 1) {
152
+ const candidateDate = {
153
+ year: Math.floor(candidateMonth / 12),
154
+ month: candidateMonth % 12 + 1,
155
+ day: args.recurrence.dayOfMonth ?? 0
156
+ };
157
+ if (compareDate(candidateDate, searchFrom) >= 0) {
158
+ const candidate = buildCandidate({
159
+ date: candidateDate,
160
+ recurrence: args.recurrence,
161
+ timezone: args.timezone
162
+ });
163
+ if (candidate !== void 0 && candidate > args.afterMs) return candidate;
164
+ }
165
+ candidateMonth += interval;
166
+ }
167
+ return;
168
+ }
169
+ let candidateYear = start.year + Math.ceil((searchFrom.year - start.year) / interval) * interval;
170
+ const candidateCount = 400 / greatestCommonDivisor(400, interval);
171
+ for (let attempts = 0; attempts < candidateCount; attempts += 1) {
172
+ const candidateDate = {
173
+ year: candidateYear,
174
+ month: args.recurrence.month ?? 0,
175
+ day: args.recurrence.dayOfMonth ?? 0
176
+ };
177
+ if (compareDate(candidateDate, searchFrom) >= 0) {
178
+ const candidate = buildCandidate({
179
+ date: candidateDate,
180
+ recurrence: args.recurrence,
181
+ timezone: args.timezone
182
+ });
183
+ if (candidate !== void 0 && candidate > args.afterMs) return candidate;
184
+ }
185
+ candidateYear += interval;
186
+ }
187
+ }
188
+ /** Compute the first recurring calendar occurrence strictly after a timestamp. */
189
+ function getFirstRunAtMs(args) {
190
+ return findNextRunAtMs({
191
+ ...args,
192
+ searchFrom: getLocalDate(args.afterMs, args.timezone)
193
+ });
194
+ }
195
+ function compareDate(left, right) {
196
+ return Date.UTC(left.year, left.month - 1, left.day) - Date.UTC(right.year, right.month - 1, right.day);
197
+ }
198
+ function addDays(date, days) {
199
+ const next = new Date(Date.UTC(date.year, date.month - 1, date.day + days));
200
+ return {
201
+ year: next.getUTCFullYear(),
202
+ month: next.getUTCMonth() + 1,
203
+ day: next.getUTCDate()
204
+ };
205
+ }
206
+ function daysInMonth(year, month) {
207
+ return new Date(Date.UTC(year, month, 0)).getUTCDate();
208
+ }
209
+ function parseLocalDate(value) {
210
+ const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
211
+ if (!match) return;
212
+ const year = Number(match[1]);
213
+ const month = Number(match[2]);
214
+ const day = Number(match[3]);
215
+ if (!Number.isInteger(year) || !Number.isInteger(month) || !Number.isInteger(day) || month < 1 || month > 12 || day < 1 || day > daysInMonth(year, month)) return;
216
+ return {
217
+ year,
218
+ month,
219
+ day
220
+ };
221
+ }
222
+ function getLocalDate(timestampMs, timezone) {
223
+ const parts = getZonedDateTimeParts(timestampMs, timezone);
224
+ return {
225
+ year: parts.year,
226
+ month: parts.month,
227
+ day: parts.day
228
+ };
229
+ }
230
+ function normalizeWeekdays(values) {
231
+ return [...new Set((values ?? []).filter((value) => value >= 0 && value <= 6))].sort((a, b) => a - b);
232
+ }
233
+ function buildCandidate(args) {
234
+ return localDateTimeToTimestampMs({
235
+ date: args.date,
236
+ time: args.recurrence.time,
237
+ timezone: args.timezone
238
+ });
239
+ }
240
+ /** Return the next fire time after a completed run, when the task recurs. */
241
+ function getNextRunAtMs(task, scheduledForMs, afterMs = scheduledForMs) {
242
+ if (task.schedule.kind !== "recurring") return;
243
+ const recurrence = task.schedule.recurrence;
244
+ if (!recurrence || !Number.isFinite(recurrence.interval) || recurrence.interval <= 0) return;
245
+ const timezone = task.schedule.timezone;
246
+ const afterDate = getLocalDate(afterMs, timezone);
247
+ const nextScheduledDate = addDays(getLocalDate(scheduledForMs, timezone), 1);
248
+ return findNextRunAtMs({
249
+ afterMs,
250
+ recurrence,
251
+ searchFrom: compareDate(afterDate, nextScheduledDate) < 0 ? nextScheduledDate : afterDate,
252
+ timezone
253
+ });
254
+ }
255
+ //#endregion
256
+ export { resolveLocalScheduleAtMs as a, isValidTimeZone as i, getNextRunAtMs as n, getZonedDateTimeParts as r, getFirstRunAtMs as t };
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
2
- import { t as createPluginCatalogRuntime } from "./registry-BJME30oR.js";
2
+ import { t as createPluginCatalogRuntime } from "./registry-DPDH6s5G.js";
3
3
  //#region src/chat/plugins/catalog-runtime.ts
4
4
  var catalog_runtime_exports = /* @__PURE__ */ __exportAll({ pluginCatalogRuntime: () => pluginCatalogRuntime });
5
5
  const pluginCatalogRuntime = createPluginCatalogRuntime();
package/dist/cli/chat.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as executeAgentRun, t as createAgentRunner } from "../agent-runner--1wC26S6.js";
1
+ import { n as executeAgentRun, t as createAgentRunner } from "../agent-runner-CMZ6lFQe.js";
2
2
  import { t as loadAppPluginSet } from "../plugin-module-CVvEUSMH.js";
3
3
  import path from "node:path";
4
4
  import { createHash, randomUUID } from "node:crypto";
@@ -100,10 +100,10 @@ async function loadLocalPluginSet() {
100
100
  async function configureLocalChatPlugins(pluginSet) {
101
101
  const [pluginsModule, agentHooksModule, catalogRuntimeModule, validationModule, databaseModule] = await Promise.all([
102
102
  import("../plugins-egKWjgue.js").then((n) => n.o),
103
- import("../agent-hooks-DzfA5m3R.js").then((n) => n.t),
104
- import("../catalog-runtime-DpB_hG_I.js").then((n) => n.t),
105
- import("../validation-Bo6BHmig.js").then((n) => n.r),
106
- import("../viewer-EftpWXcF.js").then((n) => n.s)
103
+ import("../agent-hooks-C5zYOaJk.js").then((n) => n.t),
104
+ import("../catalog-runtime-Tz0O2MZe.js").then((n) => n.t),
105
+ import("../validation-B4L2Rmiw.js").then((n) => n.r),
106
+ import("../viewer-D6stAU7h.js").then((n) => n.s)
107
107
  ]);
108
108
  const resolvedPluginSet = pluginSet === void 0 ? await loadLocalPluginSet() : pluginSet ?? void 0;
109
109
  const plugins = pluginsModule.pluginRuntimeRegistrationsFromPluginSet(resolvedPluginSet);
@@ -155,16 +155,16 @@ async function prepareLocalChatRun(io, pluginSet) {
155
155
  await configureLocalChatPlugins(pluginSet);
156
156
  const { setExperimentalFeatures } = await import("../experimental-Qn9rKLgx.js").then((n) => n.t);
157
157
  setExperimentalFeatures({ subagents: true });
158
- const { setBriefsConfig } = await import("../agent-hooks-DzfA5m3R.js").then((n) => n.m);
158
+ const { setBriefsConfig } = await import("../agent-hooks-C5zYOaJk.js").then((n) => n.m);
159
159
  setBriefsConfig({ enabled: true });
160
- const { runLocalAgentTurn } = await import("../runner-DkHL8vRA.js");
161
- const { startLocalOAuthCallbackServer } = await import("../oauth-callback-server-eJfI6skP.js");
160
+ const { runLocalAgentTurn } = await import("../runner-CqXZJfzk.js");
161
+ const { startLocalOAuthCallbackServer } = await import("../oauth-callback-server-DcYAJSEz.js");
162
162
  const { createLocalOAuthState } = await import("../oauth-relay-CdCnu80W.js").then((n) => n.t);
163
- const { createLocalSandboxEgressSignalTransport } = await import("../sandbox-egress-signals-BEQsK7ym.js");
164
- const { bindSpawnAgent } = await import("../spawn-DrvZYrTQ.js").then((n) => n.n);
165
- const { createAgentInvocationWorker, routeAgentInvocationWork } = await import("../work-WOk5DovU.js").then((n) => n.a);
163
+ const { createLocalSandboxEgressSignalTransport } = await import("../sandbox-egress-signals-DFUUokws.js");
164
+ const { bindSpawnAgent } = await import("../spawn-BszkFJKJ.js").then((n) => n.n);
165
+ const { createAgentInvocationWorker, routeAgentInvocationWork } = await import("../work-G-HdoOSF.js").then((n) => n.a);
166
166
  const { createLocalConversationWork } = await import("../conversation-work-C6y3T5Hx.js");
167
- const { processConversationWork } = await import("../worker-B7rtMFzw.js").then((n) => n.n);
167
+ const { processConversationWork } = await import("../worker-CDUDfL9P.js").then((n) => n.n);
168
168
  let agentRunner;
169
169
  const localConversationWork = createLocalConversationWork(async (message) => {
170
170
  if (!agentRunner) throw new Error("Local agent runner is not ready");
package/dist/cli/check.js CHANGED
@@ -1,6 +1,6 @@
1
- import { D as JUNIOR_HEARTBEAT_ROUTE, M as LEGACY_JUNIOR_CONVERSATION_WORK_FUNCTION, T as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE } from "../logging-Crg0e1jb.js";
2
- import { _ as parsePluginManifest, g as parseInlinePluginManifest } from "../registry-BJME30oR.js";
3
- import { i as parseSkillFile } from "../skills-CMl248J3.js";
1
+ import { D as JUNIOR_HEARTBEAT_ROUTE, M as LEGACY_JUNIOR_CONVERSATION_WORK_FUNCTION, T as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE } from "../logging-LQnLlPf8.js";
2
+ import { _ as parsePluginManifest, g as parseInlinePluginManifest } from "../registry-DPDH6s5G.js";
3
+ import { i as parseSkillFile } from "../skills-BtHhSATy.js";
4
4
  import path from "node:path";
5
5
  import fs from "node:fs/promises";
6
6
  import { pathToFileURL } from "node:url";
package/dist/cli/main.js CHANGED
@@ -25,10 +25,10 @@ async function runChat(argv, pluginSet) {
25
25
  return await (await import("./chat.js")).runChat(argv, void 0, { pluginSet });
26
26
  }
27
27
  async function runAdmin(argv) {
28
- return await (await import("../admin-Cc-iA6z9.js")).runAdmin(argv);
28
+ return await (await import("../admin-CJkjl-aN.js")).runAdmin(argv);
29
29
  }
30
30
  async function runBriefs(argv) {
31
- return await (await import("../briefs-DGc2Thua.js")).runBriefs(argv);
31
+ return await (await import("../briefs-CsQbFjRi.js")).runBriefs(argv);
32
32
  }
33
33
  function topLevelCommand(argv) {
34
34
  return (argv[0] === "--" ? argv.slice(1) : argv)[0];
@@ -1,7 +1,7 @@
1
- import { d as getDb } from "../viewer-EftpWXcF.js";
2
- import { n as pluginCatalogRuntime } from "../catalog-runtime-DpB_hG_I.js";
3
- import { d as setPlugins, f as validatePlugins, xt as createPluginLogger } from "../agent-hooks-DzfA5m3R.js";
4
- import { n as validatePluginRegistrations, t as validatePluginEgressCredentialHooks } from "../validation-Bo6BHmig.js";
1
+ import { d as getDb } from "../viewer-D6stAU7h.js";
2
+ import { n as pluginCatalogRuntime } from "../catalog-runtime-Tz0O2MZe.js";
3
+ import { d as setPlugins, f as validatePlugins, lt as createPluginLogger } from "../agent-hooks-C5zYOaJk.js";
4
+ import { n as validatePluginRegistrations, t as validatePluginEgressCredentialHooks } from "../validation-B4L2Rmiw.js";
5
5
  import { a as pluginRuntimeRegistrationsFromPluginSet, i as pluginCliRegistrationsFromPluginSet, r as pluginCatalogConfigFromPluginSet } from "../plugins-egKWjgue.js";
6
6
  import { t as loadAppPluginSet } from "../plugin-module-CVvEUSMH.js";
7
7
  import { stderr, stdout } from "node:process";
@@ -1,6 +1,6 @@
1
- import { n as pluginCatalogRuntime } from "../catalog-runtime-DpB_hG_I.js";
2
- import { S as disconnectStateAdapter, t as create } from "../profile-XzHSfIah.js";
3
- import { r as resolve } from "../resolve-ZKXfsZuZ.js";
1
+ import { n as pluginCatalogRuntime } from "../catalog-runtime-Tz0O2MZe.js";
2
+ import { S as disconnectStateAdapter, t as create } from "../profile-mWuVZ8ht.js";
3
+ import { r as resolve } from "../resolve-BAN8BSGy.js";
4
4
  //#region src/cli/snapshot-create.ts
5
5
  const DEFAULT_RUNTIME = "node22";
6
6
  const DEFAULT_TIMEOUT_MS = 6e5;