@monotykamary/localterm-server 2.80.2 → 2.81.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 (70) hide show
  1. package/dist/agent-runner.d.ts +1 -0
  2. package/dist/agent-runner.d.ts.map +1 -1
  3. package/dist/agent-runner.js +203 -151
  4. package/dist/agent-runner.js.map +1 -1
  5. package/dist/automation-dispatcher.d.ts +27 -0
  6. package/dist/automation-dispatcher.d.ts.map +1 -0
  7. package/dist/automation-dispatcher.js +195 -0
  8. package/dist/automation-dispatcher.js.map +1 -0
  9. package/dist/automation-run-tracker.d.ts +1 -1
  10. package/dist/automation-run-tracker.d.ts.map +1 -1
  11. package/dist/automation-run-tracker.js +2 -2
  12. package/dist/automation-run-tracker.js.map +1 -1
  13. package/dist/automation-scheduler.d.ts +7 -4
  14. package/dist/automation-scheduler.d.ts.map +1 -1
  15. package/dist/automation-scheduler.js +59 -39
  16. package/dist/automation-scheduler.js.map +1 -1
  17. package/dist/automation-store.d.ts +1 -0
  18. package/dist/automation-store.d.ts.map +1 -1
  19. package/dist/automation-store.js +59 -23
  20. package/dist/automation-store.js.map +1 -1
  21. package/dist/constants.d.ts +12 -1
  22. package/dist/constants.d.ts.map +1 -1
  23. package/dist/constants.js +13 -1
  24. package/dist/constants.js.map +1 -1
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +195 -213
  27. package/dist/index.js.map +1 -1
  28. package/dist/pi-rpc-client.d.ts +9 -3
  29. package/dist/pi-rpc-client.d.ts.map +1 -1
  30. package/dist/pi-rpc-client.js +133 -32
  31. package/dist/pi-rpc-client.js.map +1 -1
  32. package/dist/protocol.d.ts +2 -0
  33. package/dist/protocol.d.ts.map +1 -1
  34. package/dist/protocol.js +2 -0
  35. package/dist/protocol.js.map +1 -1
  36. package/dist/schemas.d.ts +882 -1
  37. package/dist/schemas.d.ts.map +1 -1
  38. package/dist/schemas.js +57 -8
  39. package/dist/schemas.js.map +1 -1
  40. package/dist/utils/compile-schedule.d.ts +1 -1
  41. package/dist/utils/compile-schedule.d.ts.map +1 -1
  42. package/dist/utils/compile-schedule.js +7 -6
  43. package/dist/utils/compile-schedule.js.map +1 -1
  44. package/dist/utils/compute-next-automation-run-at.d.ts.map +1 -1
  45. package/dist/utils/compute-next-automation-run-at.js +3 -18
  46. package/dist/utils/compute-next-automation-run-at.js.map +1 -1
  47. package/dist/utils/is-active-automation-run.d.ts +3 -0
  48. package/dist/utils/is-active-automation-run.d.ts.map +1 -0
  49. package/dist/utils/is-active-automation-run.js +2 -0
  50. package/dist/utils/is-active-automation-run.js.map +1 -0
  51. package/dist/utils/is-valid-time-zone.d.ts +2 -0
  52. package/dist/utils/is-valid-time-zone.d.ts.map +1 -0
  53. package/dist/utils/is-valid-time-zone.js +14 -0
  54. package/dist/utils/is-valid-time-zone.js.map +1 -0
  55. package/dist/utils/next-schedule-occurrence.d.ts +4 -0
  56. package/dist/utils/next-schedule-occurrence.d.ts.map +1 -0
  57. package/dist/utils/next-schedule-occurrence.js +201 -0
  58. package/dist/utils/next-schedule-occurrence.js.map +1 -0
  59. package/dist/utils/reconcile-downtime.d.ts.map +1 -1
  60. package/dist/utils/reconcile-downtime.js +4 -24
  61. package/dist/utils/reconcile-downtime.js.map +1 -1
  62. package/dist/utils/trim-automation-runs.d.ts +3 -0
  63. package/dist/utils/trim-automation-runs.d.ts.map +1 -0
  64. package/dist/utils/trim-automation-runs.js +7 -0
  65. package/dist/utils/trim-automation-runs.js.map +1 -0
  66. package/package.json +1 -1
  67. package/vendor/node-pty/prebuilds/darwin-arm64/pty.node +0 -0
  68. package/vendor/node-pty/prebuilds/darwin-arm64/spawn-helper +0 -0
  69. package/vendor/node-pty/prebuilds/darwin-x64/pty.node +0 -0
  70. package/vendor/node-pty/prebuilds/darwin-x64/spawn-helper +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"compute-next-automation-run-at.js","sourceRoot":"","sources":["../../src/utils/compute-next-automation-run-at.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEhF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,UAAsB,EAAE,IAAU,EAAiB,EAAE;IAC9F,IAAI,CAAC,UAAU,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IACrC,IAAI,UAAU,CAAC,SAAS,KAAK,UAAU;QAAE,OAAO,IAAI,CAAC;IACrD,8CAA8C;IAC9C,IAAI,UAAU,CAAC,OAAO,CAAC,IAAI,KAAK,UAAU;QAAE,OAAO,IAAI,CAAC;IACxD,6EAA6E;IAC7E,qDAAqD;IACrD,MAAM,UAAU,GAAa,EAAE,CAAC;IAChC,KAAK,MAAM,UAAU,IAAI,kBAAkB,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QACzE,MAAM,MAAM,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC;QAC/C,IAAI,CAAC,MAAM;YAAE,SAAS;QACtB,MAAM,IAAI,GAAG,kBAAkB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC9C,IAAI,IAAI;YAAE,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAChE,CAAC,CAAC"}
1
+ {"version":3,"file":"compute-next-automation-run-at.js","sourceRoot":"","sources":["../../src/utils/compute-next-automation-run-at.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAEvE,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,UAAsB,EAAE,IAAU,EAAiB,EAAE;IAC9F,IAAI,CAAC,UAAU,CAAC,OAAO,IAAI,UAAU,CAAC,SAAS,KAAK,UAAU;QAAE,OAAO,IAAI,CAAC;IAC5E,IAAI,UAAU,CAAC,OAAO,CAAC,IAAI,KAAK,UAAU;QAAE,OAAO,IAAI,CAAC;IACxD,OAAO,sBAAsB,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;AACxF,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { AutomationRunRecord } from "../types.js";
2
+ export declare const isActiveAutomationRun: (run: Pick<AutomationRunRecord, "status">) => boolean;
3
+ //# sourceMappingURL=is-active-automation-run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-active-automation-run.d.ts","sourceRoot":"","sources":["../../src/utils/is-active-automation-run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD,eAAO,MAAM,qBAAqB,QAAS,IAAI,CAAC,mBAAmB,EAAE,QAAQ,CAAC,KAAG,OACC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export const isActiveAutomationRun = (run) => run.status === "queued" || run.status === "launched" || run.status === "running";
2
+ //# sourceMappingURL=is-active-automation-run.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-active-automation-run.js","sourceRoot":"","sources":["../../src/utils/is-active-automation-run.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,GAAwC,EAAW,EAAE,CACzF,GAAG,CAAC,MAAM,KAAK,QAAQ,IAAI,GAAG,CAAC,MAAM,KAAK,UAAU,IAAI,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const isValidTimeZone: (timezone: string) => boolean;
2
+ //# sourceMappingURL=is-valid-time-zone.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-valid-time-zone.d.ts","sourceRoot":"","sources":["../../src/utils/is-valid-time-zone.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,aAAc,MAAM,KAAG,OAUlD,CAAC"}
@@ -0,0 +1,14 @@
1
+ export const isValidTimeZone = (timezone) => {
2
+ // Newer Intl implementations also accept numeric offsets; the contract is a
3
+ // named IANA zone (including UTC and compatibility aliases), not an offset.
4
+ if (!timezone || timezone.trim() !== timezone || /^[+-]/.test(timezone))
5
+ return false;
6
+ try {
7
+ new Intl.DateTimeFormat("en-US", { timeZone: timezone });
8
+ return true;
9
+ }
10
+ catch {
11
+ return false;
12
+ }
13
+ };
14
+ //# sourceMappingURL=is-valid-time-zone.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-valid-time-zone.js","sourceRoot":"","sources":["../../src/utils/is-valid-time-zone.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,QAAgB,EAAW,EAAE;IAC3D,4EAA4E;IAC5E,4EAA4E;IAC5E,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,IAAI,EAAE,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;QAAE,OAAO,KAAK,CAAC;IACtF,IAAI,CAAC;QACH,IAAI,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;QACzD,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { AutomationSchedule } from "../types.js";
2
+ export declare const nextScheduleOccurrence: (schedule: AutomationSchedule, from: Date, timezone?: string) => number | null;
3
+ export declare const recentScheduleOccurrences: (schedule: AutomationSchedule, start: number, end: number, cap: number, timezone?: string) => number[];
4
+ //# sourceMappingURL=next-schedule-occurrence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"next-schedule-occurrence.d.ts","sourceRoot":"","sources":["../../src/utils/next-schedule-occurrence.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AA2KtD,eAAO,MAAM,sBAAsB,aACvB,kBAAkB,QACtB,IAAI,aACC,MAAM,KAChB,MAAM,GAAG,IAeX,CAAC;AAGF,eAAO,MAAM,yBAAyB,aAC1B,kBAAkB,SACrB,MAAM,OACR,MAAM,OACN,MAAM,aACA,MAAM,KAChB,MAAM,EAgBR,CAAC"}
@@ -0,0 +1,201 @@
1
+ import { SCHEDULE_CALENDAR_SCAN_LIMIT_DAYS, MAX_AUTOMATION_INTERVAL, MAX_DATE_EPOCH_MS, SCHEDULE_DAY_MS, SCHEDULE_HOUR_MS, SCHEDULE_MINUTE_MS, SCHEDULE_OFFSET_SAMPLE_MS, SCHEDULE_OFFSET_CACHE_MAX_DAYS, SCHEDULE_TIME_ZONE_CACHE_MAX_ENTRIES, } from "../constants.js";
2
+ import { parseCronExpression } from "../cron-expression.js";
3
+ import { compileScheduleAll } from "./compile-schedule.js";
4
+ import { isValidTimeZone } from "./is-valid-time-zone.js";
5
+ const intervalDuration = (schedule) => {
6
+ if (!Number.isInteger(schedule.every) ||
7
+ schedule.every < 1 ||
8
+ schedule.every > MAX_AUTOMATION_INTERVAL ||
9
+ !Number.isInteger(schedule.anchorAt) ||
10
+ schedule.anchorAt < 0 ||
11
+ schedule.anchorAt > MAX_DATE_EPOCH_MS)
12
+ return NaN;
13
+ switch (schedule.unit) {
14
+ case "minutes":
15
+ return schedule.every * SCHEDULE_MINUTE_MS;
16
+ case "hours":
17
+ return schedule.every * SCHEDULE_HOUR_MS;
18
+ case "days":
19
+ return schedule.every * SCHEDULE_DAY_MS;
20
+ default:
21
+ return NaN;
22
+ }
23
+ };
24
+ const matchesDay = (parsed, day) => {
25
+ if (!parsed.months.has(day.getUTCMonth() + 1))
26
+ return false;
27
+ const monthDay = parsed.daysOfMonth.has(day.getUTCDate());
28
+ const weekDay = parsed.daysOfWeek.has(day.getUTCDay());
29
+ return parsed.isDayOfMonthRestricted && parsed.isDayOfWeekRestricted
30
+ ? monthDay || weekDay
31
+ : monthDay && weekDay;
32
+ };
33
+ // Interpret the formatted wall clock as UTC purely for calendar arithmetic.
34
+ // setUTCFullYear avoids Date.UTC's special handling of years 0 through 99.
35
+ const wallTime = (formatter, instant) => {
36
+ if (Math.abs(instant) > MAX_DATE_EPOCH_MS)
37
+ return NaN;
38
+ const fields = {};
39
+ for (const part of formatter.formatToParts(instant))
40
+ fields[part.type] = part.value;
41
+ const year = Number(fields.year);
42
+ const wall = new Date(0);
43
+ wall.setUTCFullYear(fields.era === "BC" ? 1 - year : year, Number(fields.month) - 1, Number(fields.day));
44
+ wall.setUTCHours(Number(fields.hour), Number(fields.minute), Number(fields.second), 0);
45
+ return wall.getTime();
46
+ };
47
+ const formatters = new Map();
48
+ const offsetCache = new WeakMap();
49
+ const calendarFormatter = (timezone) => {
50
+ if (timezone !== undefined) {
51
+ const cached = formatters.get(timezone);
52
+ if (cached)
53
+ return cached;
54
+ if (!isValidTimeZone(timezone))
55
+ return null;
56
+ }
57
+ const formatter = new Intl.DateTimeFormat("en-US", {
58
+ timeZone: timezone,
59
+ calendar: "gregory",
60
+ numberingSystem: "latn",
61
+ era: "short",
62
+ year: "numeric",
63
+ month: "2-digit",
64
+ day: "2-digit",
65
+ hour: "2-digit",
66
+ minute: "2-digit",
67
+ second: "2-digit",
68
+ hourCycle: "h23",
69
+ });
70
+ // Do not retain the implicit local zone: the host may change its timezone.
71
+ if (timezone !== undefined) {
72
+ if (formatters.size >= SCHEDULE_TIME_ZONE_CACHE_MAX_ENTRIES) {
73
+ const oldest = formatters.keys().next().value;
74
+ if (oldest !== undefined)
75
+ formatters.delete(oldest);
76
+ }
77
+ formatters.set(timezone, formatter);
78
+ }
79
+ return formatter;
80
+ };
81
+ const calendarOffsets = (formatter, day) => {
82
+ const cache = offsetCache.get(formatter) ?? new Map();
83
+ const cached = cache.get(day);
84
+ if (cached)
85
+ return cached;
86
+ const offsets = new Set();
87
+ // Sample both sides of the wall date, not just the current offset.
88
+ // IANA transitions are farther apart than this sampling step; a fold
89
+ // may be 30 minutes or an entire day, not necessarily one hour.
90
+ for (let sample = day - SCHEDULE_DAY_MS; sample <= day + 2 * SCHEDULE_DAY_MS; sample += SCHEDULE_OFFSET_SAMPLE_MS) {
91
+ const offset = wallTime(formatter, sample) - sample;
92
+ if (Number.isFinite(offset))
93
+ offsets.add(offset);
94
+ }
95
+ if (cache.size >= SCHEDULE_OFFSET_CACHE_MAX_DAYS) {
96
+ const oldest = cache.keys().next().value;
97
+ if (oldest !== undefined)
98
+ cache.delete(oldest);
99
+ }
100
+ const result = [...offsets];
101
+ cache.set(day, result);
102
+ offsetCache.set(formatter, cache);
103
+ return result;
104
+ };
105
+ const calendarOccurrences = (schedule, start, end, cap, direction, timezone) => {
106
+ const formatter = calendarFormatter(timezone);
107
+ if (!formatter)
108
+ return [];
109
+ const expressions = compileScheduleAll(schedule)
110
+ .map(parseCronExpression)
111
+ .filter((parsed) => parsed !== null);
112
+ if (expressions.length === 0)
113
+ return [];
114
+ const sort = (a, b) => direction * (a - b);
115
+ let found = [];
116
+ const boundary = direction === 1 ? start : end;
117
+ let day = Math.floor(boundary / SCHEDULE_DAY_MS) * SCHEDULE_DAY_MS - direction * SCHEDULE_DAY_MS;
118
+ // All IANA offsets fit inside a day. The padding also keeps candidate
119
+ // instants correctly ordered across midnight folds and date-line changes.
120
+ while (direction === 1 ? day - SCHEDULE_DAY_MS < end : day + 2 * SCHEDULE_DAY_MS > start) {
121
+ if (found.length === cap) {
122
+ const worst = found[found.length - 1];
123
+ if (direction === 1 ? day - SCHEDULE_DAY_MS >= worst : day + 2 * SCHEDULE_DAY_MS <= worst)
124
+ break;
125
+ }
126
+ const date = new Date(day);
127
+ const walls = new Set();
128
+ for (const parsed of expressions) {
129
+ if (!matchesDay(parsed, date))
130
+ continue;
131
+ for (const hour of parsed.hours) {
132
+ for (const minute of parsed.minutes) {
133
+ walls.add(day + hour * SCHEDULE_HOUR_MS + minute * SCHEDULE_MINUTE_MS);
134
+ }
135
+ }
136
+ }
137
+ if (walls.size > 0) {
138
+ const offsets = calendarOffsets(formatter, day);
139
+ const candidates = new Set();
140
+ for (const wall of walls) {
141
+ for (const offset of offsets) {
142
+ const instant = wall - offset;
143
+ if (instant > start && instant < end)
144
+ candidates.add(instant);
145
+ }
146
+ }
147
+ const matches = [];
148
+ for (const instant of [...candidates].sort(sort)) {
149
+ if (found.length === cap && sort(instant, found[found.length - 1]) >= 0)
150
+ break;
151
+ // Round-tripping rejects nonexistent times; both offsets of a fold
152
+ // survive as distinct instants, without normalizing a gap forward.
153
+ if (walls.has(wallTime(formatter, instant)))
154
+ matches.push(instant);
155
+ if (matches.length === cap)
156
+ break;
157
+ }
158
+ found = [...new Set([...found, ...matches])].sort(sort).slice(0, cap);
159
+ }
160
+ day += direction * SCHEDULE_DAY_MS;
161
+ }
162
+ return found;
163
+ };
164
+ export const nextScheduleOccurrence = (schedule, from, timezone) => {
165
+ const start = from.getTime();
166
+ if (!Number.isFinite(start))
167
+ return null;
168
+ if (schedule.kind === "interval") {
169
+ const duration = intervalDuration(schedule);
170
+ if (!Number.isFinite(duration))
171
+ return null;
172
+ const index = Math.max(0, Math.floor((start - schedule.anchorAt) / duration) + 1);
173
+ const next = schedule.anchorAt + index * duration;
174
+ return next > start && next <= MAX_DATE_EPOCH_MS ? next : null;
175
+ }
176
+ const end = Math.min(MAX_DATE_EPOCH_MS + 1, start + SCHEDULE_CALENDAR_SCAN_LIMIT_DAYS * SCHEDULE_DAY_MS);
177
+ return calendarOccurrences(schedule, start, end, 1, 1, timezone)[0] ?? null;
178
+ };
179
+ // Internal shared reverse search for downtime reconciliation, not protocol API.
180
+ export const recentScheduleOccurrences = (schedule, start, end, cap, timezone) => {
181
+ if (!Number.isFinite(start) || !Number.isFinite(end) || start >= end || cap < 1)
182
+ return [];
183
+ if (schedule.kind === "interval") {
184
+ const duration = intervalDuration(schedule);
185
+ if (!Number.isFinite(duration))
186
+ return [];
187
+ const result = [];
188
+ let index = Math.ceil((end - schedule.anchorAt) / duration) - 1;
189
+ while (index >= 0 && result.length < cap) {
190
+ const instant = schedule.anchorAt + index * duration;
191
+ if (instant <= start)
192
+ break;
193
+ if (instant <= MAX_DATE_EPOCH_MS)
194
+ result.push(instant);
195
+ index -= 1;
196
+ }
197
+ return result.reverse();
198
+ }
199
+ return calendarOccurrences(schedule, start, end, cap, -1, timezone).reverse();
200
+ };
201
+ //# sourceMappingURL=next-schedule-occurrence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"next-schedule-occurrence.js","sourceRoot":"","sources":["../../src/utils/next-schedule-occurrence.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,EACjC,uBAAuB,EACvB,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,yBAAyB,EACzB,8BAA8B,EAC9B,oCAAoC,GACrC,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,mBAAmB,EAA6B,MAAM,uBAAuB,CAAC;AAEvF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,MAAM,gBAAgB,GAAG,CAAC,QAA2D,EAAU,EAAE;IAC/F,IACE,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC;QACjC,QAAQ,CAAC,KAAK,GAAG,CAAC;QAClB,QAAQ,CAAC,KAAK,GAAG,uBAAuB;QACxC,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC;QACpC,QAAQ,CAAC,QAAQ,GAAG,CAAC;QACrB,QAAQ,CAAC,QAAQ,GAAG,iBAAiB;QAErC,OAAO,GAAG,CAAC;IACb,QAAQ,QAAQ,CAAC,IAAI,EAAE,CAAC;QACtB,KAAK,SAAS;YACZ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I,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,GAAG,QAAQ,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;QAChE,OAAO,KAAK,IAAI,CAAC,IAAI,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;YACzC,MAAM,OAAO,GAAG,QAAQ,CAAC,QAAQ,GAAG,KAAK,GAAG,QAAQ,CAAC;YACrD,IAAI,OAAO,IAAI,KAAK;gBAAE,MAAM;YAC5B,IAAI,OAAO,IAAI,iBAAiB;gBAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACvD,KAAK,IAAI,CAAC,CAAC;QACb,CAAC;QACD,OAAO,MAAM,CAAC,OAAO,EAAE,CAAC;IAC1B,CAAC;IACD,OAAO,mBAAmB,CAAC,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,OAAO,EAAE,CAAC;AAChF,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"reconcile-downtime.d.ts","sourceRoot":"","sources":["../../src/utils/reconcile-downtime.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAQ9C,eAAO,MAAM,0BAA0B,eACzB,UAAU,eACT,MAAM,OACd,MAAM,KACV,MAAM,EAkBR,CAAC"}
1
+ {"version":3,"file":"reconcile-downtime.d.ts","sourceRoot":"","sources":["../../src/utils/reconcile-downtime.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAK9C,eAAO,MAAM,0BAA0B,eACzB,UAAU,eACT,MAAM,OACd,MAAM,KACV,MAAM,EASR,CAAC"}
@@ -1,30 +1,10 @@
1
1
  import { AUTOMATION_DOWNTIME_RECONCILE_CAP, AUTOMATION_RECONCILE_LOOKBACK_MS, } from "../constants.js";
2
- import { nextCronOccurrence, parseCronExpression } from "../cron-expression.js";
3
- import { compileScheduleAll } from "./compile-schedule.js";
4
- import { memoBy } from "./memo-by.js";
5
- // The most-recent missed scheduled occurrences (epoch-ms) in the downtime
6
- // window (lastAliveAt, now). Enumeration starts no earlier than a fixed
7
- // lookback so a frequent schedule can't walk forever after a long outage; only
8
- // the most-recent AUTOMATION_DOWNTIME_RECONCILE_CAP are kept regardless.
2
+ import { recentScheduleOccurrences } from "./next-schedule-occurrence.js";
3
+ // Both boundaries are exclusive. Search newest-first so neither memory nor
4
+ // work grows with every missed minute of a long outage.
9
5
  export const enumerateMissedOccurrences = (automation, lastAliveAt, now) => {
10
- // Watch triggers have no scheduled occurrences to reconstruct after downtime.
11
6
  if (automation.trigger.kind !== "schedule")
12
7
  return [];
13
- const effectiveFrom = Math.max(lastAliveAt, now - AUTOMATION_RECONCILE_LOOKBACK_MS);
14
- const fromDate = new Date(effectiveFrom);
15
- const collected = [];
16
- for (const expression of compileScheduleAll(automation.trigger.schedule)) {
17
- const parsed = parseCronExpression(expression);
18
- if (!parsed)
19
- continue;
20
- let cursor = nextCronOccurrence(parsed, fromDate);
21
- while (cursor && cursor.getTime() < now) {
22
- collected.push(cursor.getTime());
23
- cursor = nextCronOccurrence(parsed, cursor);
24
- }
25
- }
26
- return memoBy(collected, (epoch) => epoch)
27
- .sort((a, b) => a - b)
28
- .slice(-AUTOMATION_DOWNTIME_RECONCILE_CAP);
8
+ return recentScheduleOccurrences(automation.trigger.schedule, Math.max(lastAliveAt, now - AUTOMATION_RECONCILE_LOOKBACK_MS), now, AUTOMATION_DOWNTIME_RECONCILE_CAP, automation.timezone);
29
9
  };
30
10
  //# sourceMappingURL=reconcile-downtime.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"reconcile-downtime.js","sourceRoot":"","sources":["../../src/utils/reconcile-downtime.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,EACjC,gCAAgC,GACjC,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAA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;SACrB,KAAK,CAAC,CAAC,iCAAiC,CAAC,CAAC;AAC/C,CAAC,CAAC"}
1
+ {"version":3,"file":"reconcile-downtime.js","sourceRoot":"","sources":["../../src/utils/reconcile-downtime.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,EACjC,gCAAgC,GACjC,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAE1E,2EAA2E;AAC3E,wDAAwD;AACxD,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACxC,UAAsB,EACtB,WAAmB,EACnB,GAAW,EACD,EAAE;IACZ,IAAI,UAAU,CAAC,OAAO,CAAC,IAAI,KAAK,UAAU;QAAE,OAAO,EAAE,CAAC;IACtD,OAAO,yBAAyB,CAC9B,UAAU,CAAC,OAAO,CAAC,QAAQ,EAC3B,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,GAAG,GAAG,gCAAgC,CAAC,EAC7D,GAAG,EACH,iCAAiC,EACjC,UAAU,CAAC,QAAQ,CACpB,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { AutomationRunRecord } from "../types.js";
2
+ export declare const trimAutomationRuns: (runs: AutomationRunRecord[]) => AutomationRunRecord[];
3
+ //# sourceMappingURL=trim-automation-runs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trim-automation-runs.d.ts","sourceRoot":"","sources":["../../src/utils/trim-automation-runs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGvD,eAAO,MAAM,kBAAkB,SAAU,mBAAmB,EAAE,KAAG,mBAAmB,EAMnF,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { AUTOMATION_RUN_HISTORY_CAP } from "../constants.js";
2
+ import { isActiveAutomationRun } from "./is-active-automation-run.js";
3
+ export const trimAutomationRuns = (runs) => {
4
+ let remaining = Math.max(0, AUTOMATION_RUN_HISTORY_CAP - runs.filter(isActiveAutomationRun).length);
5
+ return runs.filter((run) => isActiveAutomationRun(run) || remaining-- > 0);
6
+ };
7
+ //# sourceMappingURL=trim-automation-runs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trim-automation-runs.js","sourceRoot":"","sources":["../../src/utils/trim-automation-runs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAE7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,IAA2B,EAAyB,EAAE;IACvF,IAAI,SAAS,GAAG,IAAI,CAAC,GAAG,CACtB,CAAC,EACD,0BAA0B,GAAG,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC,MAAM,CACvE,CAAC;IACF,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,qBAAqB,CAAC,GAAG,CAAC,IAAI,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC;AAC7E,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monotykamary/localterm-server",
3
- "version": "2.80.2",
3
+ "version": "2.81.0",
4
4
  "description": "PTY-backed HTTP/WebSocket server that powers localterm, built on Hono + node-pty.",
5
5
  "keywords": [
6
6
  "hono",