@keystrokehq/keystroke 1.0.7 → 1.0.9
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/action.cjs +3 -1
- package/dist/action.d.cts +3 -3
- package/dist/action.d.mts +3 -3
- package/dist/action.mjs +2 -2
- package/dist/agent.cjs +21 -10
- package/dist/agent.cjs.map +1 -1
- package/dist/agent.d.cts +2 -2
- package/dist/agent.d.mts +2 -2
- package/dist/agent.mjs +21 -10
- package/dist/agent.mjs.map +1 -1
- package/dist/app.cjs +1 -1
- package/dist/app.d.cts +2 -2
- package/dist/app.d.mts +2 -2
- package/dist/app.mjs +1 -1
- package/dist/client.cjs +13 -7
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts.map +1 -1
- package/dist/client.d.mts.map +1 -1
- package/dist/client.mjs +13 -7
- package/dist/client.mjs.map +1 -1
- package/dist/config.d.cts +1 -1
- package/dist/config.d.mts +1 -1
- package/dist/credentials.cjs +1 -1
- package/dist/credentials.d.cts +1 -1
- package/dist/credentials.d.mts +1 -1
- package/dist/credentials.mjs +1 -1
- package/dist/{dist-DQL6zTI5.cjs → dist-C0fPHFaM.cjs} +20 -11
- package/dist/dist-C0fPHFaM.cjs.map +1 -0
- package/dist/{dist-DqFdFpiB.mjs → dist-CppO7361.mjs} +92 -9
- package/dist/dist-CppO7361.mjs.map +1 -0
- package/dist/{dist-C5otI4u3.cjs → dist-DivFQzKG.cjs} +236 -41
- package/dist/dist-DivFQzKG.cjs.map +1 -0
- package/dist/{dist-DOMwPx7V.cjs → dist-HI6bM6LK.cjs} +103 -8
- package/dist/dist-HI6bM6LK.cjs.map +1 -0
- package/dist/{dist-IUl7Bexl.mjs → dist-UzTnzZem.mjs} +231 -42
- package/dist/dist-UzTnzZem.mjs.map +1 -0
- package/dist/{dist-BpkCqbil.mjs → dist-nvW8vbKn.mjs} +20 -11
- package/dist/dist-nvW8vbKn.mjs.map +1 -0
- package/dist/{index-BMqj40Li.d.cts → index-3P7ec4Vo.d.cts} +4 -2
- package/dist/index-3P7ec4Vo.d.cts.map +1 -0
- package/dist/{index-nUAXCgEe.d.cts → index-BTz2OMAM.d.cts} +13 -3
- package/dist/index-BTz2OMAM.d.cts.map +1 -0
- package/dist/{index-8_UEbXaF.d.mts → index-Cq2F2XdS.d.mts} +13 -3
- package/dist/index-Cq2F2XdS.d.mts.map +1 -0
- package/dist/{index-Dgy9MjuX.d.cts → index-D4dAsbJr.d.cts} +20 -3
- package/dist/index-D4dAsbJr.d.cts.map +1 -0
- package/dist/{index-CWZAGTad.d.mts → index-D7UUmswR.d.mts} +4 -2
- package/dist/index-D7UUmswR.d.mts.map +1 -0
- package/dist/{index-BeBgntxT.d.mts → index-DdAOmbQc.d.mts} +9 -16
- package/dist/index-DdAOmbQc.d.mts.map +1 -0
- package/dist/{index-BY9SPR2h.d.cts → index-Ohwnfidc.d.cts} +9 -16
- package/dist/index-Ohwnfidc.d.cts.map +1 -0
- package/dist/{index-Bl4VEelg.d.mts → index-Sx9T2i0u.d.mts} +20 -3
- package/dist/index-Sx9T2i0u.d.mts.map +1 -0
- package/dist/{index-e9f4pcX4.d.cts → index-WT4ULMiw.d.cts} +14 -3
- package/dist/index-WT4ULMiw.d.cts.map +1 -0
- package/dist/{index-e9f4pcX4.d.mts → index-WT4ULMiw.d.mts} +14 -3
- package/dist/index-WT4ULMiw.d.mts.map +1 -0
- package/dist/{mistral-wOLLEgb9.cjs → mistral-CSlOhLAJ.cjs} +2 -2
- package/dist/{mistral-wOLLEgb9.cjs.map → mistral-CSlOhLAJ.cjs.map} +1 -1
- package/dist/{mistral-CMDejXQt.mjs → mistral-StBMjPiK.mjs} +2 -2
- package/dist/{mistral-CMDejXQt.mjs.map → mistral-StBMjPiK.mjs.map} +1 -1
- package/dist/{sse-DI7TsPKG.mjs → sse-CDOw-yuH.mjs} +2 -2
- package/dist/{sse-DI7TsPKG.mjs.map → sse-CDOw-yuH.mjs.map} +1 -1
- package/dist/{sse-Dzs73rQw.cjs → sse-CZOklzgA.cjs} +2 -2
- package/dist/{sse-Dzs73rQw.cjs.map → sse-CZOklzgA.cjs.map} +1 -1
- package/dist/trigger.cjs +8 -7
- package/dist/trigger.cjs.map +1 -1
- package/dist/trigger.d.cts +3 -3
- package/dist/trigger.d.mts +3 -3
- package/dist/trigger.mjs +8 -7
- package/dist/trigger.mjs.map +1 -1
- package/dist/workflow.cjs +1 -1
- package/dist/workflow.d.cts +2 -2
- package/dist/workflow.d.mts +2 -2
- package/dist/workflow.mjs +1 -1
- package/package.json +1 -1
- package/dist/dist-BpkCqbil.mjs.map +0 -1
- package/dist/dist-C5otI4u3.cjs.map +0 -1
- package/dist/dist-DOMwPx7V.cjs.map +0 -1
- package/dist/dist-DQL6zTI5.cjs.map +0 -1
- package/dist/dist-DqFdFpiB.mjs.map +0 -1
- package/dist/dist-IUl7Bexl.mjs.map +0 -1
- package/dist/index-8_UEbXaF.d.mts.map +0 -1
- package/dist/index-BMqj40Li.d.cts.map +0 -1
- package/dist/index-BY9SPR2h.d.cts.map +0 -1
- package/dist/index-BeBgntxT.d.mts.map +0 -1
- package/dist/index-Bl4VEelg.d.mts.map +0 -1
- package/dist/index-CWZAGTad.d.mts.map +0 -1
- package/dist/index-Dgy9MjuX.d.cts.map +0 -1
- package/dist/index-e9f4pcX4.d.cts.map +0 -1
- package/dist/index-e9f4pcX4.d.mts.map +0 -1
- package/dist/index-nUAXCgEe.d.cts.map +0 -1
package/dist/trigger.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trigger.mjs","names":[],"sources":["../../../node_modules/.pnpm/cron-schedule@6.0.0/node_modules/cron-schedule/dist/utils.js","../../../node_modules/.pnpm/cron-schedule@6.0.0/node_modules/cron-schedule/dist/cron.js","../../../node_modules/.pnpm/cron-schedule@6.0.0/node_modules/cron-schedule/dist/cron-parser.js","../../trigger/dist/index.mjs"],"sourcesContent":["export const TIMEOUT_MAX = 2147483647; // 2^31-1\n/**\n * Creates a new timeout, which can exceed the max timeout limit of 2^31-1.\n * Since multiple timeouts are used internally, the timeoutId used to clear the timeout\n * is returned as a handle (object) and changes whenever the max timeout limit is exceeded.\n * The handle parameter can be ignored, it is used internally for updating the timeoutId\n * in the handle after creating the next timeout.\n */\nexport function longTimeout(fn, timeout, previousHandle) {\n let nextTimeout = timeout;\n let remainingTimeout = 0;\n if (nextTimeout > TIMEOUT_MAX) {\n remainingTimeout = nextTimeout - TIMEOUT_MAX;\n nextTimeout = TIMEOUT_MAX;\n }\n const handle = previousHandle !== null && previousHandle !== void 0 ? previousHandle : {\n timeoutId: undefined,\n };\n handle.timeoutId = setTimeout(() => {\n if (remainingTimeout > 0) {\n longTimeout(fn, remainingTimeout, previousHandle);\n }\n else {\n fn();\n }\n }, nextTimeout);\n return handle;\n}\n/* Extracts second, minute, hour, date, month and the weekday from a date. */\nexport function extractDateElements(date) {\n return {\n second: date.getSeconds(),\n minute: date.getMinutes(),\n hour: date.getHours(),\n day: date.getDate(),\n month: date.getMonth(),\n weekday: date.getDay(),\n year: date.getFullYear(),\n };\n}\n/* Gets the amount of days in the given month (indexed by 0) of the given year. */\nexport function getDaysInMonth(year, month) {\n return new Date(year, month + 1, 0).getDate();\n}\n/* Gets the amount of days from weekday1 to weekday2. */\nexport function getDaysBetweenWeekdays(weekday1, weekday2) {\n if (weekday1 <= weekday2) {\n return weekday2 - weekday1;\n }\n return 6 - weekday1 + weekday2 + 1;\n}\nexport function wrapFunction(fn, errorHandler) {\n return () => {\n try {\n const res = fn();\n if (res instanceof Promise) {\n res.catch((err) => {\n if (errorHandler) {\n errorHandler(err);\n }\n });\n }\n }\n catch (err) {\n if (errorHandler) {\n errorHandler(err);\n }\n }\n };\n}\n//# sourceMappingURL=utils.js.map","import { extractDateElements, getDaysBetweenWeekdays, getDaysInMonth, } from './utils.js';\nexport class Cron {\n constructor({ seconds, minutes, hours, days, months, weekdays, }) {\n // Validate that there are values provided.\n if (!seconds || seconds.size === 0)\n throw new Error('There must be at least one allowed second.');\n if (!minutes || minutes.size === 0)\n throw new Error('There must be at least one allowed minute.');\n if (!hours || hours.size === 0)\n throw new Error('There must be at least one allowed hour.');\n if (!months || months.size === 0)\n throw new Error('There must be at least one allowed month.');\n if ((!weekdays || weekdays.size === 0) && (!days || days.size === 0))\n throw new Error('There must be at least one allowed day or weekday.');\n // Convert set to array and sort in ascending order.\n this.seconds = Array.from(seconds).sort((a, b) => a - b);\n this.minutes = Array.from(minutes).sort((a, b) => a - b);\n this.hours = Array.from(hours).sort((a, b) => a - b);\n this.days = Array.from(days).sort((a, b) => a - b);\n this.months = Array.from(months).sort((a, b) => a - b);\n this.weekdays = Array.from(weekdays).sort((a, b) => a - b);\n // Validate that all values are integers within the constraint.\n const validateData = (name, data, constraint) => {\n if (data.some((x) => typeof x !== 'number' ||\n x % 1 !== 0 ||\n x < constraint.min ||\n x > constraint.max)) {\n throw new Error(`${name} must only consist of integers which are within the range of ${constraint.min} and ${constraint.max}`);\n }\n };\n validateData('seconds', this.seconds, { min: 0, max: 59 });\n validateData('minutes', this.minutes, { min: 0, max: 59 });\n validateData('hours', this.hours, { min: 0, max: 23 });\n validateData('days', this.days, { min: 1, max: 31 });\n validateData('months', this.months, { min: 0, max: 11 });\n validateData('weekdays', this.weekdays, { min: 0, max: 6 });\n // For each element, store a reversed copy in the reversed attribute for finding prev dates.\n this.reversed = {\n seconds: this.seconds.map((x) => x).reverse(),\n minutes: this.minutes.map((x) => x).reverse(),\n hours: this.hours.map((x) => x).reverse(),\n days: this.days.map((x) => x).reverse(),\n months: this.months.map((x) => x).reverse(),\n weekdays: this.weekdays.map((x) => x).reverse(),\n };\n }\n /**\n * Find the next or previous hour, starting from the given start hour that matches the hour constraint.\n * startHour itself might also be allowed.\n */\n findAllowedHour(dir, startHour) {\n return dir === 'next'\n ? this.hours.find((x) => x >= startHour)\n : this.reversed.hours.find((x) => x <= startHour);\n }\n /**\n * Find the next or previous minute, starting from the given start minute that matches the minute constraint.\n * startMinute itself might also be allowed.\n */\n findAllowedMinute(dir, startMinute) {\n return dir === 'next'\n ? this.minutes.find((x) => x >= startMinute)\n : this.reversed.minutes.find((x) => x <= startMinute);\n }\n /**\n * Find the next or previous second, starting from the given start second that matches the second constraint.\n * startSecond itself IS NOT allowed.\n */\n findAllowedSecond(dir, startSecond) {\n return dir === 'next'\n ? this.seconds.find((x) => x > startSecond)\n : this.reversed.seconds.find((x) => x < startSecond);\n }\n /**\n * Find the next or previous time, starting from the given start time that matches the hour, minute\n * and second constraints. startTime itself might also be allowed.\n */\n findAllowedTime(dir, startTime) {\n // Try to find an allowed hour.\n let hour = this.findAllowedHour(dir, startTime.hour);\n if (hour !== undefined) {\n if (hour === startTime.hour) {\n // We found an hour that is the start hour. Try to find an allowed minute.\n let minute = this.findAllowedMinute(dir, startTime.minute);\n if (minute !== undefined) {\n if (minute === startTime.minute) {\n // We found a minute that is the start minute. Try to find an allowed second.\n const second = this.findAllowedSecond(dir, startTime.second);\n if (second !== undefined) {\n // We found a second within the start hour and minute.\n return { hour, minute, second };\n }\n // We did not find a valid second within the start minute. Try to find another minute.\n minute = this.findAllowedMinute(dir, dir === 'next' ? startTime.minute + 1 : startTime.minute - 1);\n if (minute !== undefined) {\n // We found a minute which is not the start minute. Return that minute together with the hour and the first / last allowed second.\n return {\n hour,\n minute,\n second: dir === 'next' ? this.seconds[0] : this.reversed.seconds[0],\n };\n }\n }\n else {\n // We found a minute which is not the start minute. Return that minute together with the hour and the first / last allowed second.\n return {\n hour,\n minute,\n second: dir === 'next' ? this.seconds[0] : this.reversed.seconds[0],\n };\n }\n }\n // We did not find an allowed minute / second combination inside the start hour. Try to find the next / previous allowed hour.\n hour = this.findAllowedHour(dir, dir === 'next' ? startTime.hour + 1 : startTime.hour - 1);\n if (hour !== undefined) {\n // We found an allowed hour which is not the start hour. Return that hour together with the first / last allowed minutes / seconds.\n return {\n hour,\n minute: dir === 'next' ? this.minutes[0] : this.reversed.minutes[0],\n second: dir === 'next' ? this.seconds[0] : this.reversed.seconds[0],\n };\n }\n }\n else {\n // We found an allowed hour which is not the start hour. Return that hour together with the first / last allowed minutes / seconds.\n return {\n hour,\n minute: dir === 'next' ? this.minutes[0] : this.reversed.minutes[0],\n second: dir === 'next' ? this.seconds[0] : this.reversed.seconds[0],\n };\n }\n }\n // No allowed time found.\n return undefined;\n }\n /**\n * Find the next or previous day in the given month, starting from the given startDay\n * that matches either the day or the weekday constraint. startDay itself might also be allowed.\n */\n findAllowedDayInMonth(dir, year, month, startDay) {\n var _a, _b;\n if (startDay < 1)\n throw new Error('startDay must not be smaller than 1.');\n // If only days are restricted: allow day based on day constraint only.\n // If only weekdays are restricted: allow day based on weekday constraint only.\n // If both are restricted: allow day based on both day and weekday constraint. pick day that is closer to startDay.\n // If none are restricted: return the day closest to startDay (respecting dir) that is allowed (or startDay itself).\n const daysInMonth = getDaysInMonth(year, month);\n const daysRestricted = this.days.length !== 31;\n const weekdaysRestricted = this.weekdays.length !== 7;\n if (!daysRestricted && !weekdaysRestricted) {\n if (startDay > daysInMonth) {\n return dir === 'next' ? undefined : daysInMonth;\n }\n return startDay;\n }\n // Try to find a day based on the days constraint.\n let allowedDayByDays;\n if (daysRestricted) {\n allowedDayByDays =\n dir === 'next'\n ? this.days.find((x) => x >= startDay)\n : this.reversed.days.find((x) => x <= startDay);\n // Make sure the day does not exceed the amount of days in month.\n if (allowedDayByDays !== undefined && allowedDayByDays > daysInMonth) {\n allowedDayByDays = undefined;\n }\n }\n // Try to find a day based on the weekday constraint.\n let allowedDayByWeekdays;\n if (weekdaysRestricted) {\n const startWeekday = new Date(year, month, startDay).getDay();\n const nearestAllowedWeekday = dir === 'next'\n ? ((_a = this.weekdays.find((x) => x >= startWeekday)) !== null && _a !== void 0 ? _a : this.weekdays[0])\n : ((_b = this.reversed.weekdays.find((x) => x <= startWeekday)) !== null && _b !== void 0 ? _b : this.reversed.weekdays[0]);\n if (nearestAllowedWeekday !== undefined) {\n const daysBetweenWeekdays = dir === 'next'\n ? getDaysBetweenWeekdays(startWeekday, nearestAllowedWeekday)\n : getDaysBetweenWeekdays(nearestAllowedWeekday, startWeekday);\n allowedDayByWeekdays =\n dir === 'next'\n ? startDay + daysBetweenWeekdays\n : startDay - daysBetweenWeekdays;\n // Make sure the day does not exceed the month boundaries.\n if (allowedDayByWeekdays > daysInMonth || allowedDayByWeekdays < 1) {\n allowedDayByWeekdays = undefined;\n }\n }\n }\n if (allowedDayByDays !== undefined && allowedDayByWeekdays !== undefined) {\n // If a day is found both via the days and the weekdays constraint, pick the day\n // that is closer to start date.\n return dir === 'next'\n ? Math.min(allowedDayByDays, allowedDayByWeekdays)\n : Math.max(allowedDayByDays, allowedDayByWeekdays);\n }\n if (allowedDayByDays !== undefined) {\n return allowedDayByDays;\n }\n if (allowedDayByWeekdays !== undefined) {\n return allowedDayByWeekdays;\n }\n return undefined;\n }\n /** Gets the next date starting from the given start date or now. */\n getNextDate(startDate = new Date()) {\n const startDateElements = extractDateElements(startDate);\n let minYear = startDateElements.year;\n let startIndexMonth = this.months.findIndex((x) => x >= startDateElements.month);\n if (startIndexMonth === -1) {\n startIndexMonth = 0;\n minYear++;\n }\n // We try every month within the next 5 years to make sure that we tried to\n // find a matching date insidde a whole leap year.\n const maxIterations = this.months.length * 5;\n for (let i = 0; i < maxIterations; i++) {\n // Get the next year and month.\n const year = minYear + Math.floor((startIndexMonth + i) / this.months.length);\n const month = this.months[(startIndexMonth + i) % this.months.length];\n const isStartMonth = year === startDateElements.year && month === startDateElements.month;\n // Find the next day.\n let day = this.findAllowedDayInMonth('next', year, month, isStartMonth ? startDateElements.day : 1);\n let isStartDay = isStartMonth && day === startDateElements.day;\n // If we found a day and it is the start day, try to find a valid time beginning from the start date time.\n if (day !== undefined && isStartDay) {\n const nextTime = this.findAllowedTime('next', startDateElements);\n if (nextTime !== undefined) {\n return new Date(year, month, day, nextTime.hour, nextTime.minute, nextTime.second);\n }\n // If no valid time has been found for the start date, try the next day.\n day = this.findAllowedDayInMonth('next', year, month, day + 1);\n isStartDay = false;\n }\n // If we found a next day and it is not the start day, just use the next day with the first allowed values\n // for hours, minutes and seconds.\n if (day !== undefined && !isStartDay) {\n return new Date(year, month, day, this.hours[0], this.minutes[0], this.seconds[0]);\n }\n // No allowed day has been found for this month. Continue to search in next month.\n }\n throw new Error('No valid next date was found.');\n }\n /** Gets the specified amount of future dates starting from the given start date or now. */\n getNextDates(amount, startDate) {\n const dates = [];\n let nextDate;\n for (let i = 0; i < amount; i++) {\n nextDate = this.getNextDate(nextDate !== null && nextDate !== void 0 ? nextDate : startDate);\n dates.push(nextDate);\n }\n return dates;\n }\n /**\n * Get an ES6 compatible iterator which iterates over the next dates starting from startDate or now.\n * The iterator runs until the optional endDate is reached or forever.\n */\n *getNextDatesIterator(startDate, endDate) {\n let nextDate;\n while (true) {\n nextDate = this.getNextDate(nextDate !== null && nextDate !== void 0 ? nextDate : startDate);\n if (endDate && endDate.getTime() < nextDate.getTime()) {\n return;\n }\n yield nextDate;\n }\n }\n /** Gets the previous date starting from the given start date or now. */\n getPrevDate(startDate = new Date()) {\n const startDateElements = extractDateElements(startDate);\n let maxYear = startDateElements.year;\n let startIndexMonth = this.reversed.months.findIndex((x) => x <= startDateElements.month);\n if (startIndexMonth === -1) {\n startIndexMonth = 0;\n maxYear--;\n }\n // We try every month within the past 5 years to make sure that we tried to\n // find a matching date inside a whole leap year.\n const maxIterations = this.reversed.months.length * 5;\n for (let i = 0; i < maxIterations; i++) {\n // Get the next year and month.\n const year = maxYear -\n Math.floor((startIndexMonth + i) / this.reversed.months.length);\n const month = this.reversed.months[(startIndexMonth + i) % this.reversed.months.length];\n const isStartMonth = year === startDateElements.year && month === startDateElements.month;\n // Find the previous day.\n let day = this.findAllowedDayInMonth('prev', year, month, isStartMonth\n ? startDateElements.day\n : // Start searching from the last day of the month.\n getDaysInMonth(year, month));\n let isStartDay = isStartMonth && day === startDateElements.day;\n // If we found a day and it is the start day, try to find a valid time beginning from the start date time.\n if (day !== undefined && isStartDay) {\n const prevTime = this.findAllowedTime('prev', startDateElements);\n if (prevTime !== undefined) {\n return new Date(year, month, day, prevTime.hour, prevTime.minute, prevTime.second);\n }\n // If no valid time has been found for the start date, try the previous day.\n if (day > 1) {\n day = this.findAllowedDayInMonth('prev', year, month, day - 1);\n isStartDay = false;\n }\n }\n // If we found a previous day and it is not the start day, just use the previous day with the first allowed values\n // for hours, minutes and seconds (which will be the latest time due to using the reversed array).\n if (day !== undefined && !isStartDay) {\n return new Date(year, month, day, this.reversed.hours[0], this.reversed.minutes[0], this.reversed.seconds[0]);\n }\n // No allowed day has been found for this month. Continue to search in previous month.\n }\n throw new Error('No valid previous date was found.');\n }\n /** Gets the specified amount of previous dates starting from the given start date or now. */\n getPrevDates(amount, startDate) {\n const dates = [];\n let prevDate;\n for (let i = 0; i < amount; i++) {\n prevDate = this.getPrevDate(prevDate !== null && prevDate !== void 0 ? prevDate : startDate);\n dates.push(prevDate);\n }\n return dates;\n }\n /**\n * Get an ES6 compatible iterator which iterates over the previous dates starting from startDate or now.\n * The iterator runs until the optional endDate is reached or forever.\n */\n *getPrevDatesIterator(startDate, endDate) {\n let prevDate;\n while (true) {\n prevDate = this.getPrevDate(prevDate !== null && prevDate !== void 0 ? prevDate : startDate);\n if (endDate && endDate.getTime() > prevDate.getTime()) {\n return;\n }\n yield prevDate;\n }\n }\n /** Returns true when there is a cron date at the given date. */\n matchDate(date) {\n const { second, minute, hour, day, month, weekday } = extractDateElements(date);\n if (this.seconds.indexOf(second) === -1 ||\n this.minutes.indexOf(minute) === -1 ||\n this.hours.indexOf(hour) === -1 ||\n this.months.indexOf(month) === -1) {\n return false;\n }\n if (this.days.length !== 31 && this.weekdays.length !== 7) {\n return (this.days.indexOf(day) !== -1 || this.weekdays.indexOf(weekday) !== -1);\n }\n return (this.days.indexOf(day) !== -1 && this.weekdays.indexOf(weekday) !== -1);\n }\n}\n//# sourceMappingURL=cron.js.map","import { Cron } from './cron.js';\nconst secondConstraint = {\n min: 0,\n max: 59,\n};\nconst minuteConstraint = {\n min: 0,\n max: 59,\n};\nconst hourConstraint = {\n min: 0,\n max: 23,\n};\nconst dayConstraint = {\n min: 1,\n max: 31,\n};\nconst monthConstraint = {\n min: 1,\n max: 12,\n aliases: {\n jan: '1',\n feb: '2',\n mar: '3',\n apr: '4',\n may: '5',\n jun: '6',\n jul: '7',\n aug: '8',\n sep: '9',\n oct: '10',\n nov: '11',\n dec: '12',\n },\n};\nconst weekdayConstraint = {\n min: 0,\n max: 7,\n aliases: {\n mon: '1',\n tue: '2',\n wed: '3',\n thu: '4',\n fri: '5',\n sat: '6',\n sun: '7',\n },\n};\nconst timeNicknames = {\n '@yearly': '0 0 1 1 *',\n '@annually': '0 0 1 1 *',\n '@monthly': '0 0 1 * *',\n '@weekly': '0 0 * * 0',\n '@daily': '0 0 * * *',\n '@hourly': '0 * * * *',\n '@minutely': '* * * * *',\n};\nfunction parseElement(element, constraint) {\n const result = new Set();\n // If returned set of numbers is empty, the scheduler class interpretes the emtpy set of numbers as all valid values of the constraint\n if (element === '*') {\n for (let i = constraint.min; i <= constraint.max; i = i + 1) {\n result.add(i);\n }\n return result;\n }\n // If the element is a list, parse each element in the list.\n const listElements = element.split(',');\n if (listElements.length > 1) {\n for (const listElement of listElements) {\n const parsedListElement = parseElement(listElement, constraint);\n for (const x of parsedListElement) {\n result.add(x);\n }\n }\n return result;\n }\n // Helper function to parse a single element, which includes checking for alias, valid number and constraint min and max.\n const parseSingleElement = (singleElement) => {\n var _a, _b;\n singleElement =\n (_b = (_a = constraint.aliases) === null || _a === void 0 ? void 0 : _a[singleElement.toLowerCase()]) !== null && _b !== void 0 ? _b : singleElement;\n const parsedElement = Number.parseInt(singleElement, 10);\n if (Number.isNaN(parsedElement)) {\n throw new Error(`Failed to parse ${element}: ${singleElement} is NaN.`);\n }\n if (parsedElement < constraint.min || parsedElement > constraint.max) {\n throw new Error(`Failed to parse ${element}: ${singleElement} is outside of constraint range of ${constraint.min} - ${constraint.max}.`);\n }\n return parsedElement;\n };\n // Detect if the element is a range.\n // Possible range formats: 'start-end', 'start-end/step', '*', '*/step'.\n // Where start and end can be numbers or aliases.\n // Capture groups: 1: start-end, 2: start, 3: end, 4: /step, 5: step.\n const rangeSegments = /^(([0-9a-zA-Z]+)-([0-9a-zA-Z]+)|\\*)(\\/([0-9]+))?$/.exec(element);\n // If not, it must be a single element.\n if (rangeSegments === null) {\n result.add(parseSingleElement(element));\n return result;\n }\n // If it is a range, get start and end of the range.\n let parsedStart = rangeSegments[1] === '*'\n ? constraint.min\n : parseSingleElement(rangeSegments[2]);\n const parsedEnd = rangeSegments[1] === '*'\n ? constraint.max\n : parseSingleElement(rangeSegments[3]);\n // need to catch Sunday, which gets parsed here as 7, but is also legitimate at the start of a range as 0, to avoid the out of order error\n if (constraint === weekdayConstraint &&\n parsedStart === 7 &&\n // this check ensures that sun-sun is not incorrectly parsed as [0,1,2,3,4,5,6]\n parsedEnd !== 7) {\n parsedStart = 0;\n }\n if (parsedStart > parsedEnd) {\n throw new Error(`Failed to parse ${element}: Invalid range (start: ${parsedStart}, end: ${parsedEnd}).`);\n }\n // Check whether there is a custom step defined for the range, defaulting to 1.\n const step = rangeSegments[5];\n let parsedStep = 1;\n if (step !== undefined) {\n parsedStep = Number.parseInt(step, 10);\n if (Number.isNaN(parsedStep)) {\n throw new Error(`Failed to parse step: ${step} is NaN.`);\n }\n if (parsedStep < 1) {\n throw new Error(`Failed to parse step: Expected ${step} to be greater than 0.`);\n }\n }\n // Go from start to end of the range by the given steps.\n for (let i = parsedStart; i <= parsedEnd; i = i + parsedStep) {\n result.add(i);\n }\n return result;\n}\n/** Parses a cron expression into a Cron instance. */\nexport function parseCronExpression(cronExpression) {\n var _a;\n if (typeof cronExpression !== 'string') {\n throw new TypeError('Invalid cron expression: must be of type string.');\n }\n // Convert time nicknames.\n cronExpression = (_a = timeNicknames[cronExpression.toLowerCase()]) !== null && _a !== void 0 ? _a : cronExpression;\n // Split the cron expression into its elements, removing empty elements (extra whitespaces).\n const elements = cronExpression.split(' ').filter((elem) => elem.length > 0);\n if (elements.length < 5 || elements.length > 6) {\n throw new Error('Invalid cron expression: expected 5 or 6 elements.');\n }\n const rawSeconds = elements.length === 6 ? elements[0] : '0';\n const rawMinutes = elements.length === 6 ? elements[1] : elements[0];\n const rawHours = elements.length === 6 ? elements[2] : elements[1];\n const rawDays = elements.length === 6 ? elements[3] : elements[2];\n const rawMonths = elements.length === 6 ? elements[4] : elements[3];\n const rawWeekdays = elements.length === 6 ? elements[5] : elements[4];\n return new Cron({\n seconds: parseElement(rawSeconds, secondConstraint),\n minutes: parseElement(rawMinutes, minuteConstraint),\n hours: parseElement(rawHours, hourConstraint),\n days: parseElement(rawDays, dayConstraint),\n // months in cron are indexed by 1, but Cron expects indexes by 0, so we need to reduce all set values by one.\n months: new Set(Array.from(parseElement(rawMonths, monthConstraint)).map((x) => x - 1)),\n weekdays: new Set(Array.from(parseElement(rawWeekdays, weekdayConstraint)).map((x) => x % 7)),\n });\n}\n//# sourceMappingURL=cron-parser.js.map","import { parseCronExpression } from \"cron-schedule\";\nimport { z } from \"zod\";\nimport { isWorkflow } from \"@keystrokehq/workflow\";\n//#region src/cron/cron-schedule.ts\n/**\n* Validates and brands a cron expression. Accepts anything the `cron-schedule`\n* engine accepts (5/6 fields, named months/weekdays, `@daily`-style nicknames)\n* so authoring validation never rejects a schedule the scheduler can run. The\n* `.brand()` makes `CronSchedule` nominally distinct from a plain `string`, so\n* a raw string can't be passed where a validated schedule is expected.\n*/\nconst cronScheduleSchema = z.string().trim().min(1, \"cron schedule must be a non-empty string\").refine(isParseableCron, \"must be a valid cron expression\").brand();\n/** Parse/validate an arbitrary value into a branded `CronSchedule` (throws on failure). */\nfunction parseCronSchedule(value) {\n\treturn cronScheduleSchema.parse(value);\n}\n/**\n* Resolves the effective schedule for an attachment, applying overrides by\n* precedence: per-attachment override → global override → the authored\n* schedule. Pure string precedence — no cron parsing.\n*/\nfunction resolveCronSchedule(attachmentId, schedule, options) {\n\treturn options.attachmentScheduleOverrides?.[attachmentId] ?? options.cronScheduleOverride ?? schedule;\n}\n/** Parse a schedule into a `cron-schedule` `Cron` instance (throws on invalid input). */\nfunction parseTriggerSchedule(schedule) {\n\treturn toCron(schedule);\n}\n/** The next time the schedule fires at or after `from`. */\nfunction nextTriggerRunAt(schedule, from = /* @__PURE__ */ new Date()) {\n\treturn toCron(schedule).getNextDate(from);\n}\n/**\n* Single touchpoint for the `cron-schedule` library — every parse, validation,\n* and next-run calculation in this package goes through here.\n*/\nfunction toCron(schedule) {\n\treturn parseCronExpression(schedule);\n}\nfunction isParseableCron(value) {\n\ttry {\n\t\ttoCron(value);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n//#endregion\n//#region src/attachment-definition.ts\nconst zodSchema = z.custom((v) => v instanceof z.ZodType, \"must be a Zod schema\");\nconst workflowSchema = z.custom((v) => isWorkflow(v), \"must be defineWorkflow(...)\");\nconst agentSchema = z.custom((v) => typeof v === \"object\" && v !== null && typeof v.slug === \"string\" && v.slug.trim().length > 0 && typeof v.prompt === \"function\", \"must be defineAgent(...)\");\nconst promptSchema = z.union([z.string(), z.function()]);\nconst baseSourceShape = {\n\tkey: z.string().trim().min(1),\n\tattach: z.function()\n};\nconst webhookSourceSchema = z.object({\n\tkind: z.literal(\"webhook\"),\n\t...baseSourceShape,\n\tendpoint: z.string().min(1),\n\trequest: zodSchema,\n\tfilter: zodSchema.optional(),\n\tpasses: z.function()\n});\nconst cronSourceSchema = z.object({\n\tkind: z.literal(\"cron\"),\n\t...baseSourceShape,\n\tschedule: cronScheduleSchema\n});\nconst pollSourceSchema = z.object({\n\tkind: z.literal(\"poll\"),\n\t...baseSourceShape,\n\tid: z.string().optional(),\n\tschedule: cronScheduleSchema,\n\trun: z.function(),\n\tfilters: z.array(z.function()),\n\tpasses: z.function()\n});\n/** Runtime validation for a trigger source (webhook | cron | poll). */\nconst triggerSourceSchema = z.discriminatedUnion(\"kind\", [\n\twebhookSourceSchema,\n\tcronSourceSchema,\n\tpollSourceSchema\n]);\nconst workflowAttachmentSchema = z.object({\n\tkey: z.string().trim().min(1),\n\tsource: triggerSourceSchema,\n\ttarget: z.literal(\"workflow\"),\n\tworkflow: workflowSchema,\n\ttransform: z.function().optional()\n});\nconst agentAttachmentSchema = z.object({\n\tkey: z.string().trim().min(1),\n\tsource: triggerSourceSchema,\n\ttarget: z.literal(\"agent\"),\n\tagent: agentSchema,\n\tprompt: promptSchema\n});\n/** Runtime validation for an unbranded trigger attachment. */\nconst triggerAttachmentCoreSchema = z.discriminatedUnion(\"target\", [workflowAttachmentSchema, agentAttachmentSchema]);\nconst TRIGGER_ATTACHMENT = Symbol.for(\"keystroke.triggerAttachment\");\n/**\n* Validates brand + shape via `triggerAttachmentCoreSchema` so server discovery\n* rejects unbranded or malformed attachments.\n*/\nfunction isTriggerAttachment(value) {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tif (!(TRIGGER_ATTACHMENT in value) || value[TRIGGER_ATTACHMENT] !== true) return false;\n\treturn triggerAttachmentCoreSchema.safeParse(value).success;\n}\nfunction isWorkflowTriggerAttachment(attachment) {\n\treturn attachment.target === \"workflow\";\n}\nfunction isAgentTriggerAttachment(attachment) {\n\treturn attachment.target === \"agent\";\n}\n//#endregion\n//#region src/attachment-key.ts\nfunction workflowKeyFromDefinition(workflow) {\n\tconst slug = workflow.slug?.trim();\n\tif (!slug) throw new Error(\"Workflow definition requires a non-empty slug\");\n\treturn slug;\n}\nfunction agentKeyFromAgent(agent) {\n\tconst slug = agent.slug?.trim();\n\tif (!slug) throw new Error(\"Agent definition requires a non-empty slug\");\n\treturn slug;\n}\nfunction attachmentKeyFrom(triggerKey, targetKey) {\n\treturn `${triggerKey}:${targetKey}`;\n}\n//#endregion\n//#region src/attach-options.ts\nfunction isAgentAttachOptions(options) {\n\treturn \"agent\" in options;\n}\n//#endregion\n//#region src/define-trigger-attachment.ts\n/**\n* Internal helper used by source `.attach()` factories. Validates the\n* attachment shape against `triggerAttachmentCoreSchema` and applies the\n* `TRIGGER_ATTACHMENT` brand.\n*/\nfunction defineTriggerAttachment(input) {\n\tconst result = triggerAttachmentCoreSchema.safeParse(input);\n\tif (!result.success) throw new Error(`Invalid trigger attachment: ${formatIssues(result.error.issues)}`);\n\treturn {\n\t\t...input,\n\t\t[TRIGGER_ATTACHMENT]: true\n\t};\n}\nfunction formatIssues(issues) {\n\treturn issues.map((issue) => {\n\t\treturn `${issue.path.length > 0 ? `${issue.path.join(\".\")}: ` : \"\"}${issue.message}`;\n\t}).join(\"; \");\n}\n//#endregion\n//#region src/attach-from-source.ts\nfunction attachFromSource(source, triggerKey, options) {\n\tif (isAgentAttachOptions(options)) return defineTriggerAttachment({\n\t\tkey: attachmentKeyFrom(triggerKey, agentKeyFromAgent(options.agent)),\n\t\tsource,\n\t\ttarget: \"agent\",\n\t\tagent: options.agent,\n\t\tprompt: options.prompt\n\t});\n\treturn defineTriggerAttachment({\n\t\tkey: attachmentKeyFrom(triggerKey, workflowKeyFromDefinition(options.workflow)),\n\t\tsource,\n\t\ttarget: \"workflow\",\n\t\tworkflow: options.workflow,\n\t\ttransform: options.transform\n\t});\n}\n//#endregion\n//#region src/trigger-match-schema.ts\nfunction matchShapeAndFilter(shape, filter, payload) {\n\tconst shaped = shape.safeParse(payload);\n\tif (!shaped.success) return;\n\tif (filter && !filter.safeParse(shaped.data).success) return;\n\treturn shaped.data;\n}\nfunction passesShapeAndFilter(shape, filter, payload) {\n\treturn matchShapeAndFilter(shape, filter, payload) !== void 0;\n}\nfunction matchWebhookPayload(raw, schemas) {\n\tconst matches = [];\n\tif (typeof z.fromJSONSchema !== \"function\") throw new Error(\"z.fromJSONSchema is required for JSON schema matching\");\n\tfor (const schema of schemas) {\n\t\tconst data = matchShapeAndFilter(z.fromJSONSchema(schema.requestSchema), schema.filterSchema ? z.fromJSONSchema(schema.filterSchema) : void 0, raw);\n\t\tif (data === void 0) continue;\n\t\tmatches.push({\n\t\t\tattachmentKey: schema.attachmentKey,\n\t\t\tdata\n\t\t});\n\t}\n\treturn matches;\n}\n/** Live Zod validation for webhook `request` + optional Zod `filter` (in-process paths). */\nfunction passesTriggerMatch(shape, filter, payload) {\n\treturn passesShapeAndFilter(shape, filter, payload);\n}\n//#endregion\n//#region src/sources/webhook-source.ts\nfunction normalizeWebhookEndpoint(endpoint) {\n\treturn endpoint.replace(/^\\/+|\\/+$/g, \"\").replace(/^triggers\\/?/, \"\");\n}\nfunction webhookFilterSchema(filter) {\n\tif (filter instanceof z.ZodObject) return filter.loose();\n\treturn filter;\n}\n/**\n* Defines a webhook trigger source — fires its attached workflow when a request\n* hits `/triggers/{endpoint}` and satisfies `request` plus any optional `filter`.\n*\n* @param options.key - Stable trigger key; attachment id is `{key}:{workflowKey}`.\n* @param options.endpoint - Shared route suffix under `/triggers/` (e.g. `\"stripe\"`).\n*/\nfunction defineWebhookSource(options) {\n\tconst triggerKey = options.key.trim();\n\tif (!triggerKey) throw new Error(\"defineWebhookSource requires a non-empty key\");\n\tconst endpoint = normalizeWebhookEndpoint(options.endpoint);\n\tif (!endpoint) throw new Error(\"defineWebhookSource requires a non-empty endpoint\");\n\tconst filter = options.filter ? webhookFilterSchema(options.filter) : void 0;\n\tconst source = {\n\t\tkind: \"webhook\",\n\t\tkey: triggerKey,\n\t\tendpoint,\n\t\trequest: options.request,\n\t\tfilter,\n\t\tpasses(payload) {\n\t\t\treturn passesTriggerMatch(options.request, filter, payload);\n\t\t},\n\t\tattach(attachOptions) {\n\t\t\treturn attachFromSource(source, triggerKey, attachOptions);\n\t\t}\n\t};\n\treturn source;\n}\n//#endregion\n//#region src/sources/cron-source.ts\n/**\n* Defines a cron trigger source — fires its attached workflow on a schedule.\n*\n* @param options.key - Stable trigger key; the attachment id is `{key}:{workflowKey}`.\n* @param options.schedule - A cron expression. Pass a 5-field literal (e.g.\n* `\"0 9 * * *\"`) for compile-time shape checking, or wrap with\n* `parseCronSchedule(...)` for 6-field, named (`MON`), or `@daily`-style\n* schedules. Validated at runtime; throws if the expression is invalid.\n* @example\n* defineCronSource({ key: \"morning\", schedule: \"0 9 * * *\" }).attach({ workflow });\n*/\nfunction defineCronSource(options) {\n\tconst triggerKey = options.key.trim();\n\tif (!triggerKey) throw new Error(\"defineCronSource requires a non-empty key\");\n\tconst source = {\n\t\tkind: \"cron\",\n\t\tkey: triggerKey,\n\t\tschedule: parseCronSchedule(options.schedule),\n\t\tattach(attachOptions) {\n\t\t\treturn attachFromSource(source, triggerKey, attachOptions);\n\t\t}\n\t};\n\treturn source;\n}\n//#endregion\n//#region src/sources/poll-source.ts\n/**\n* Defines a poll trigger source — runs `run` on a schedule and, when the result\n* passes any `.filter(...)`, fires the attached workflow with it.\n*\n* @param options.key - Stable trigger key; the attachment id is `{key}:{workflowKey}`.\n* @param options.id - Optional group id; poll sources sharing an id poll together.\n* @param options.schedule - Cron expression for the poll cadence (see `defineCronSource`).\n* @param options.run - Produces the payload checked by `filter` and passed to the workflow.\n* @param options.filter - Source-level predicate; the workflow only fires when it returns true.\n* @example\n* definePollSource({ key: \"inbox\", schedule: \"0 * * * *\", run: fetchInbox })\n* .filter((r) => r.length > 0)\n* .attach({ workflow });\n*/\nfunction definePollSource(options) {\n\tconst triggerKey = options.key.trim();\n\tif (!triggerKey) throw new Error(\"definePollSource requires a non-empty key\");\n\tconst schedule = parseCronSchedule(options.schedule);\n\tconst filters = [];\n\tif (options.filter) filters.push(options.filter);\n\tconst source = {\n\t\tkind: \"poll\",\n\t\tkey: triggerKey,\n\t\tid: options.id,\n\t\tschedule,\n\t\trun: options.run,\n\t\tfilters,\n\t\tpasses(payload) {\n\t\t\treturn source.filters.every((candidate) => candidate(payload));\n\t\t},\n\t\tattach(attachOptions) {\n\t\t\treturn attachFromSource(source, triggerKey, attachOptions);\n\t\t}\n\t};\n\tconst chain = source;\n\tchain.filter = (fn) => {\n\t\tsource.filters.push(fn);\n\t\treturn chain;\n\t};\n\treturn chain;\n}\n//#endregion\n//#region src/ephemeral-match.ts\nfunction emptyObjectSchema() {\n\treturn {\n\t\ttype: \"object\",\n\t\tproperties: {},\n\t\trequired: []\n\t};\n}\nfunction setConstAtPath(schema, path, value) {\n\tconst [head, ...rest] = path;\n\tif (!head) return;\n\tif (!schema.required.includes(head)) schema.required.push(head);\n\tif (rest.length === 0) {\n\t\tschema.properties[head] = { const: value };\n\t\treturn;\n\t}\n\tconst existing = schema.properties[head];\n\tconst child = existing && typeof existing === \"object\" && existing.type === \"object\" ? existing : emptyObjectSchema();\n\tschema.properties[head] = child;\n\tsetConstAtPath(child, rest, value);\n}\n/**\n* Compiles a shallow `match` object into a JSON Schema usable as a stored webhook\n* `requestSchema`. Dots in keys are treated as path separators; an empty match\n* produces a schema that accepts any JSON object payload.\n*/\nfunction matchToJsonSchema(match) {\n\tconst schema = emptyObjectSchema();\n\tfor (const [path, value] of Object.entries(match)) setConstAtPath(schema, path.split(\".\").filter((segment) => segment.length > 0), value);\n\tif (schema.required.length === 0) return { type: \"object\" };\n\treturn schema;\n}\n//#endregion\n//#region src/interpolate-prompt.ts\nfunction resolvePath(payload, path) {\n\tlet current = payload;\n\tfor (const segment of path) {\n\t\tif (current === null || typeof current !== \"object\") return;\n\t\tcurrent = current[segment];\n\t}\n\treturn current;\n}\n/**\n* Resolves `{{path}}` / `{{payload.path}}` dot-path tokens in an ephemeral trigger\n* prompt against the webhook payload. Unresolved tokens are left untouched so the\n* agent can see what failed to bind.\n*/\nfunction interpolatePrompt(template, payload) {\n\treturn template.replace(/\\{\\{\\s*([\\w.$-]+)\\s*\\}\\}/g, (token, rawPath) => {\n\t\tconst segments = rawPath.split(\".\");\n\t\tif (segments[0] === \"payload\") segments.shift();\n\t\tconst value = segments.length === 0 ? payload : resolvePath(payload, segments);\n\t\tif (value === void 0) return token;\n\t\treturn typeof value === \"string\" ? value : JSON.stringify(value);\n\t});\n}\n//#endregion\n//#region src/resolve-agent-prompt.ts\n/** Resolves the agent prompt for a validated trigger payload. */\nfunction resolveAgentPrompt(attachment, payload) {\n\tconst prompt = attachment.prompt;\n\tif (typeof prompt === \"function\") return prompt(payload ?? {});\n\treturn prompt;\n}\n//#endregion\n//#region src/resolve-attachment-input.ts\nfunction applyAttachmentTransform(attachment, payload) {\n\treturn attachment.transform ? attachment.transform(payload) : payload;\n}\n/**\n* Applies attachment `transform` to a payload that already passed source validation.\n* Webhook payloads are matched at ingress via persisted Zod JSON schemas.\n*/\nfunction resolveAttachmentTransform(attachment, payload) {\n\tif (isAgentTriggerAttachment(attachment)) return payload;\n\treturn applyAttachmentTransform(attachment, payload);\n}\n/** Applies poll source filters and attachment `transform`. Webhook ingress already matched Zod schemas. */\nfunction resolveAttachmentInput(attachment, payload) {\n\tconst source = attachment.source;\n\tif (source.kind === \"poll\" && !source.passes(payload)) return;\n\tif (isAgentTriggerAttachment(attachment)) return payload;\n\treturn applyAttachmentTransform(attachment, payload);\n}\n//#endregion\nexport { TRIGGER_ATTACHMENT, cronScheduleSchema, defineCronSource, definePollSource, defineWebhookSource, interpolatePrompt, isAgentTriggerAttachment, isTriggerAttachment, isWorkflowTriggerAttachment, matchToJsonSchema, matchWebhookPayload, nextTriggerRunAt, normalizeWebhookEndpoint, parseCronSchedule, parseTriggerSchedule, resolveAgentPrompt, resolveAttachmentInput, resolveAttachmentTransform, resolveCronSchedule };\n\n//# sourceMappingURL=index.mjs.map"],"x_google_ignoreList":[0,1,2],"mappings":";;;AA6BA,SAAgB,oBAAoB,MAAM;CACtC,OAAO;EACH,QAAQ,KAAK,WAAW;EACxB,QAAQ,KAAK,WAAW;EACxB,MAAM,KAAK,SAAS;EACpB,KAAK,KAAK,QAAQ;EAClB,OAAO,KAAK,SAAS;EACrB,SAAS,KAAK,OAAO;EACrB,MAAM,KAAK,YAAY;CAC3B;AACJ;AAEA,SAAgB,eAAe,MAAM,OAAO;CACxC,OAAO,IAAI,KAAK,MAAM,QAAQ,GAAG,CAAC,EAAE,QAAQ;AAChD;AAEA,SAAgB,uBAAuB,UAAU,UAAU;CACvD,IAAI,YAAY,UACZ,OAAO,WA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AAY,UAAU;EACrD,UAAU,QAAQ;CACnB;CACA,OAAO;AACR;;;;;;AAMA,SAAS,kBAAkB,UAAU,SAAS;CAC7C,OAAO,SAAS,QAAQ,8BAA8B,OAAO,YAAY;EACxE,MAAM,WAAW,QAAQ,MAAM,GAAG;EAClC,IAAI,SAAS,OAAO,WAAW,SAAS,MAAM;EAC9C,MAAM,QAAQ,SAAS,WAAW,IAAI,UAAU,YAAY,SAAS,QAAQ;EAC7E,IAAI,UAAU,KAAK,GAAG,OAAO;EAC7B,OAAO,OAAO,UAAU,WAAW,QAAQ,KAAK,UAAU,KAAK;CAChE,CAAC;AACF;;AAIA,SAAS,mBAAmB,YAAY,SAAS;CAChD,MAAM,SAAS,WAAW;CAC1B,IAAI,OAAO,WAAW,YAAY,OAAO,OAAO,WAAW,CAAC,CAAC;CAC7D,OAAO;AACR;AAGA,SAAS,yBAAyB,YAAY,SAAS;CACtD,OAAO,WAAW,YAAY,WAAW,UAAU,OAAO,IAAI;AAC/D;;;;;AAKA,SAAS,2BAA2B,YAAY,SAAS;CACxD,IAAI,yBAAyB,UAAU,GAAG,OAAO;CACjD,OAAO,yBAAyB,YAAY,OAAO;AACpD;;AAEA,SAAS,uBAAuB,YAAY,SAAS;CACpD,MAAM,SAAS,WAAW;CAC1B,IAAI,OAAO,SAAS,UAAU,CAAC,OAAO,OAAO,OAAO,GAAG;CACvD,IAAI,yBAAyB,UAAU,GAAG,OAAO;CACjD,OAAO,yBAAyB,YAAY,OAAO;AACpD"}
|
|
1
|
+
{"version":3,"file":"trigger.mjs","names":[],"sources":["../../../node_modules/.pnpm/cron-schedule@6.0.0/node_modules/cron-schedule/dist/utils.js","../../../node_modules/.pnpm/cron-schedule@6.0.0/node_modules/cron-schedule/dist/cron.js","../../../node_modules/.pnpm/cron-schedule@6.0.0/node_modules/cron-schedule/dist/cron-parser.js","../../trigger/dist/index.mjs"],"sourcesContent":["export const TIMEOUT_MAX = 2147483647; // 2^31-1\n/**\n * Creates a new timeout, which can exceed the max timeout limit of 2^31-1.\n * Since multiple timeouts are used internally, the timeoutId used to clear the timeout\n * is returned as a handle (object) and changes whenever the max timeout limit is exceeded.\n * The handle parameter can be ignored, it is used internally for updating the timeoutId\n * in the handle after creating the next timeout.\n */\nexport function longTimeout(fn, timeout, previousHandle) {\n let nextTimeout = timeout;\n let remainingTimeout = 0;\n if (nextTimeout > TIMEOUT_MAX) {\n remainingTimeout = nextTimeout - TIMEOUT_MAX;\n nextTimeout = TIMEOUT_MAX;\n }\n const handle = previousHandle !== null && previousHandle !== void 0 ? previousHandle : {\n timeoutId: undefined,\n };\n handle.timeoutId = setTimeout(() => {\n if (remainingTimeout > 0) {\n longTimeout(fn, remainingTimeout, previousHandle);\n }\n else {\n fn();\n }\n }, nextTimeout);\n return handle;\n}\n/* Extracts second, minute, hour, date, month and the weekday from a date. */\nexport function extractDateElements(date) {\n return {\n second: date.getSeconds(),\n minute: date.getMinutes(),\n hour: date.getHours(),\n day: date.getDate(),\n month: date.getMonth(),\n weekday: date.getDay(),\n year: date.getFullYear(),\n };\n}\n/* Gets the amount of days in the given month (indexed by 0) of the given year. */\nexport function getDaysInMonth(year, month) {\n return new Date(year, month + 1, 0).getDate();\n}\n/* Gets the amount of days from weekday1 to weekday2. */\nexport function getDaysBetweenWeekdays(weekday1, weekday2) {\n if (weekday1 <= weekday2) {\n return weekday2 - weekday1;\n }\n return 6 - weekday1 + weekday2 + 1;\n}\nexport function wrapFunction(fn, errorHandler) {\n return () => {\n try {\n const res = fn();\n if (res instanceof Promise) {\n res.catch((err) => {\n if (errorHandler) {\n errorHandler(err);\n }\n });\n }\n }\n catch (err) {\n if (errorHandler) {\n errorHandler(err);\n }\n }\n };\n}\n//# sourceMappingURL=utils.js.map","import { extractDateElements, getDaysBetweenWeekdays, getDaysInMonth, } from './utils.js';\nexport class Cron {\n constructor({ seconds, minutes, hours, days, months, weekdays, }) {\n // Validate that there are values provided.\n if (!seconds || seconds.size === 0)\n throw new Error('There must be at least one allowed second.');\n if (!minutes || minutes.size === 0)\n throw new Error('There must be at least one allowed minute.');\n if (!hours || hours.size === 0)\n throw new Error('There must be at least one allowed hour.');\n if (!months || months.size === 0)\n throw new Error('There must be at least one allowed month.');\n if ((!weekdays || weekdays.size === 0) && (!days || days.size === 0))\n throw new Error('There must be at least one allowed day or weekday.');\n // Convert set to array and sort in ascending order.\n this.seconds = Array.from(seconds).sort((a, b) => a - b);\n this.minutes = Array.from(minutes).sort((a, b) => a - b);\n this.hours = Array.from(hours).sort((a, b) => a - b);\n this.days = Array.from(days).sort((a, b) => a - b);\n this.months = Array.from(months).sort((a, b) => a - b);\n this.weekdays = Array.from(weekdays).sort((a, b) => a - b);\n // Validate that all values are integers within the constraint.\n const validateData = (name, data, constraint) => {\n if (data.some((x) => typeof x !== 'number' ||\n x % 1 !== 0 ||\n x < constraint.min ||\n x > constraint.max)) {\n throw new Error(`${name} must only consist of integers which are within the range of ${constraint.min} and ${constraint.max}`);\n }\n };\n validateData('seconds', this.seconds, { min: 0, max: 59 });\n validateData('minutes', this.minutes, { min: 0, max: 59 });\n validateData('hours', this.hours, { min: 0, max: 23 });\n validateData('days', this.days, { min: 1, max: 31 });\n validateData('months', this.months, { min: 0, max: 11 });\n validateData('weekdays', this.weekdays, { min: 0, max: 6 });\n // For each element, store a reversed copy in the reversed attribute for finding prev dates.\n this.reversed = {\n seconds: this.seconds.map((x) => x).reverse(),\n minutes: this.minutes.map((x) => x).reverse(),\n hours: this.hours.map((x) => x).reverse(),\n days: this.days.map((x) => x).reverse(),\n months: this.months.map((x) => x).reverse(),\n weekdays: this.weekdays.map((x) => x).reverse(),\n };\n }\n /**\n * Find the next or previous hour, starting from the given start hour that matches the hour constraint.\n * startHour itself might also be allowed.\n */\n findAllowedHour(dir, startHour) {\n return dir === 'next'\n ? this.hours.find((x) => x >= startHour)\n : this.reversed.hours.find((x) => x <= startHour);\n }\n /**\n * Find the next or previous minute, starting from the given start minute that matches the minute constraint.\n * startMinute itself might also be allowed.\n */\n findAllowedMinute(dir, startMinute) {\n return dir === 'next'\n ? this.minutes.find((x) => x >= startMinute)\n : this.reversed.minutes.find((x) => x <= startMinute);\n }\n /**\n * Find the next or previous second, starting from the given start second that matches the second constraint.\n * startSecond itself IS NOT allowed.\n */\n findAllowedSecond(dir, startSecond) {\n return dir === 'next'\n ? this.seconds.find((x) => x > startSecond)\n : this.reversed.seconds.find((x) => x < startSecond);\n }\n /**\n * Find the next or previous time, starting from the given start time that matches the hour, minute\n * and second constraints. startTime itself might also be allowed.\n */\n findAllowedTime(dir, startTime) {\n // Try to find an allowed hour.\n let hour = this.findAllowedHour(dir, startTime.hour);\n if (hour !== undefined) {\n if (hour === startTime.hour) {\n // We found an hour that is the start hour. Try to find an allowed minute.\n let minute = this.findAllowedMinute(dir, startTime.minute);\n if (minute !== undefined) {\n if (minute === startTime.minute) {\n // We found a minute that is the start minute. Try to find an allowed second.\n const second = this.findAllowedSecond(dir, startTime.second);\n if (second !== undefined) {\n // We found a second within the start hour and minute.\n return { hour, minute, second };\n }\n // We did not find a valid second within the start minute. Try to find another minute.\n minute = this.findAllowedMinute(dir, dir === 'next' ? startTime.minute + 1 : startTime.minute - 1);\n if (minute !== undefined) {\n // We found a minute which is not the start minute. Return that minute together with the hour and the first / last allowed second.\n return {\n hour,\n minute,\n second: dir === 'next' ? this.seconds[0] : this.reversed.seconds[0],\n };\n }\n }\n else {\n // We found a minute which is not the start minute. Return that minute together with the hour and the first / last allowed second.\n return {\n hour,\n minute,\n second: dir === 'next' ? this.seconds[0] : this.reversed.seconds[0],\n };\n }\n }\n // We did not find an allowed minute / second combination inside the start hour. Try to find the next / previous allowed hour.\n hour = this.findAllowedHour(dir, dir === 'next' ? startTime.hour + 1 : startTime.hour - 1);\n if (hour !== undefined) {\n // We found an allowed hour which is not the start hour. Return that hour together with the first / last allowed minutes / seconds.\n return {\n hour,\n minute: dir === 'next' ? this.minutes[0] : this.reversed.minutes[0],\n second: dir === 'next' ? this.seconds[0] : this.reversed.seconds[0],\n };\n }\n }\n else {\n // We found an allowed hour which is not the start hour. Return that hour together with the first / last allowed minutes / seconds.\n return {\n hour,\n minute: dir === 'next' ? this.minutes[0] : this.reversed.minutes[0],\n second: dir === 'next' ? this.seconds[0] : this.reversed.seconds[0],\n };\n }\n }\n // No allowed time found.\n return undefined;\n }\n /**\n * Find the next or previous day in the given month, starting from the given startDay\n * that matches either the day or the weekday constraint. startDay itself might also be allowed.\n */\n findAllowedDayInMonth(dir, year, month, startDay) {\n var _a, _b;\n if (startDay < 1)\n throw new Error('startDay must not be smaller than 1.');\n // If only days are restricted: allow day based on day constraint only.\n // If only weekdays are restricted: allow day based on weekday constraint only.\n // If both are restricted: allow day based on both day and weekday constraint. pick day that is closer to startDay.\n // If none are restricted: return the day closest to startDay (respecting dir) that is allowed (or startDay itself).\n const daysInMonth = getDaysInMonth(year, month);\n const daysRestricted = this.days.length !== 31;\n const weekdaysRestricted = this.weekdays.length !== 7;\n if (!daysRestricted && !weekdaysRestricted) {\n if (startDay > daysInMonth) {\n return dir === 'next' ? undefined : daysInMonth;\n }\n return startDay;\n }\n // Try to find a day based on the days constraint.\n let allowedDayByDays;\n if (daysRestricted) {\n allowedDayByDays =\n dir === 'next'\n ? this.days.find((x) => x >= startDay)\n : this.reversed.days.find((x) => x <= startDay);\n // Make sure the day does not exceed the amount of days in month.\n if (allowedDayByDays !== undefined && allowedDayByDays > daysInMonth) {\n allowedDayByDays = undefined;\n }\n }\n // Try to find a day based on the weekday constraint.\n let allowedDayByWeekdays;\n if (weekdaysRestricted) {\n const startWeekday = new Date(year, month, startDay).getDay();\n const nearestAllowedWeekday = dir === 'next'\n ? ((_a = this.weekdays.find((x) => x >= startWeekday)) !== null && _a !== void 0 ? _a : this.weekdays[0])\n : ((_b = this.reversed.weekdays.find((x) => x <= startWeekday)) !== null && _b !== void 0 ? _b : this.reversed.weekdays[0]);\n if (nearestAllowedWeekday !== undefined) {\n const daysBetweenWeekdays = dir === 'next'\n ? getDaysBetweenWeekdays(startWeekday, nearestAllowedWeekday)\n : getDaysBetweenWeekdays(nearestAllowedWeekday, startWeekday);\n allowedDayByWeekdays =\n dir === 'next'\n ? startDay + daysBetweenWeekdays\n : startDay - daysBetweenWeekdays;\n // Make sure the day does not exceed the month boundaries.\n if (allowedDayByWeekdays > daysInMonth || allowedDayByWeekdays < 1) {\n allowedDayByWeekdays = undefined;\n }\n }\n }\n if (allowedDayByDays !== undefined && allowedDayByWeekdays !== undefined) {\n // If a day is found both via the days and the weekdays constraint, pick the day\n // that is closer to start date.\n return dir === 'next'\n ? Math.min(allowedDayByDays, allowedDayByWeekdays)\n : Math.max(allowedDayByDays, allowedDayByWeekdays);\n }\n if (allowedDayByDays !== undefined) {\n return allowedDayByDays;\n }\n if (allowedDayByWeekdays !== undefined) {\n return allowedDayByWeekdays;\n }\n return undefined;\n }\n /** Gets the next date starting from the given start date or now. */\n getNextDate(startDate = new Date()) {\n const startDateElements = extractDateElements(startDate);\n let minYear = startDateElements.year;\n let startIndexMonth = this.months.findIndex((x) => x >= startDateElements.month);\n if (startIndexMonth === -1) {\n startIndexMonth = 0;\n minYear++;\n }\n // We try every month within the next 5 years to make sure that we tried to\n // find a matching date insidde a whole leap year.\n const maxIterations = this.months.length * 5;\n for (let i = 0; i < maxIterations; i++) {\n // Get the next year and month.\n const year = minYear + Math.floor((startIndexMonth + i) / this.months.length);\n const month = this.months[(startIndexMonth + i) % this.months.length];\n const isStartMonth = year === startDateElements.year && month === startDateElements.month;\n // Find the next day.\n let day = this.findAllowedDayInMonth('next', year, month, isStartMonth ? startDateElements.day : 1);\n let isStartDay = isStartMonth && day === startDateElements.day;\n // If we found a day and it is the start day, try to find a valid time beginning from the start date time.\n if (day !== undefined && isStartDay) {\n const nextTime = this.findAllowedTime('next', startDateElements);\n if (nextTime !== undefined) {\n return new Date(year, month, day, nextTime.hour, nextTime.minute, nextTime.second);\n }\n // If no valid time has been found for the start date, try the next day.\n day = this.findAllowedDayInMonth('next', year, month, day + 1);\n isStartDay = false;\n }\n // If we found a next day and it is not the start day, just use the next day with the first allowed values\n // for hours, minutes and seconds.\n if (day !== undefined && !isStartDay) {\n return new Date(year, month, day, this.hours[0], this.minutes[0], this.seconds[0]);\n }\n // No allowed day has been found for this month. Continue to search in next month.\n }\n throw new Error('No valid next date was found.');\n }\n /** Gets the specified amount of future dates starting from the given start date or now. */\n getNextDates(amount, startDate) {\n const dates = [];\n let nextDate;\n for (let i = 0; i < amount; i++) {\n nextDate = this.getNextDate(nextDate !== null && nextDate !== void 0 ? nextDate : startDate);\n dates.push(nextDate);\n }\n return dates;\n }\n /**\n * Get an ES6 compatible iterator which iterates over the next dates starting from startDate or now.\n * The iterator runs until the optional endDate is reached or forever.\n */\n *getNextDatesIterator(startDate, endDate) {\n let nextDate;\n while (true) {\n nextDate = this.getNextDate(nextDate !== null && nextDate !== void 0 ? nextDate : startDate);\n if (endDate && endDate.getTime() < nextDate.getTime()) {\n return;\n }\n yield nextDate;\n }\n }\n /** Gets the previous date starting from the given start date or now. */\n getPrevDate(startDate = new Date()) {\n const startDateElements = extractDateElements(startDate);\n let maxYear = startDateElements.year;\n let startIndexMonth = this.reversed.months.findIndex((x) => x <= startDateElements.month);\n if (startIndexMonth === -1) {\n startIndexMonth = 0;\n maxYear--;\n }\n // We try every month within the past 5 years to make sure that we tried to\n // find a matching date inside a whole leap year.\n const maxIterations = this.reversed.months.length * 5;\n for (let i = 0; i < maxIterations; i++) {\n // Get the next year and month.\n const year = maxYear -\n Math.floor((startIndexMonth + i) / this.reversed.months.length);\n const month = this.reversed.months[(startIndexMonth + i) % this.reversed.months.length];\n const isStartMonth = year === startDateElements.year && month === startDateElements.month;\n // Find the previous day.\n let day = this.findAllowedDayInMonth('prev', year, month, isStartMonth\n ? startDateElements.day\n : // Start searching from the last day of the month.\n getDaysInMonth(year, month));\n let isStartDay = isStartMonth && day === startDateElements.day;\n // If we found a day and it is the start day, try to find a valid time beginning from the start date time.\n if (day !== undefined && isStartDay) {\n const prevTime = this.findAllowedTime('prev', startDateElements);\n if (prevTime !== undefined) {\n return new Date(year, month, day, prevTime.hour, prevTime.minute, prevTime.second);\n }\n // If no valid time has been found for the start date, try the previous day.\n if (day > 1) {\n day = this.findAllowedDayInMonth('prev', year, month, day - 1);\n isStartDay = false;\n }\n }\n // If we found a previous day and it is not the start day, just use the previous day with the first allowed values\n // for hours, minutes and seconds (which will be the latest time due to using the reversed array).\n if (day !== undefined && !isStartDay) {\n return new Date(year, month, day, this.reversed.hours[0], this.reversed.minutes[0], this.reversed.seconds[0]);\n }\n // No allowed day has been found for this month. Continue to search in previous month.\n }\n throw new Error('No valid previous date was found.');\n }\n /** Gets the specified amount of previous dates starting from the given start date or now. */\n getPrevDates(amount, startDate) {\n const dates = [];\n let prevDate;\n for (let i = 0; i < amount; i++) {\n prevDate = this.getPrevDate(prevDate !== null && prevDate !== void 0 ? prevDate : startDate);\n dates.push(prevDate);\n }\n return dates;\n }\n /**\n * Get an ES6 compatible iterator which iterates over the previous dates starting from startDate or now.\n * The iterator runs until the optional endDate is reached or forever.\n */\n *getPrevDatesIterator(startDate, endDate) {\n let prevDate;\n while (true) {\n prevDate = this.getPrevDate(prevDate !== null && prevDate !== void 0 ? prevDate : startDate);\n if (endDate && endDate.getTime() > prevDate.getTime()) {\n return;\n }\n yield prevDate;\n }\n }\n /** Returns true when there is a cron date at the given date. */\n matchDate(date) {\n const { second, minute, hour, day, month, weekday } = extractDateElements(date);\n if (this.seconds.indexOf(second) === -1 ||\n this.minutes.indexOf(minute) === -1 ||\n this.hours.indexOf(hour) === -1 ||\n this.months.indexOf(month) === -1) {\n return false;\n }\n if (this.days.length !== 31 && this.weekdays.length !== 7) {\n return (this.days.indexOf(day) !== -1 || this.weekdays.indexOf(weekday) !== -1);\n }\n return (this.days.indexOf(day) !== -1 && this.weekdays.indexOf(weekday) !== -1);\n }\n}\n//# sourceMappingURL=cron.js.map","import { Cron } from './cron.js';\nconst secondConstraint = {\n min: 0,\n max: 59,\n};\nconst minuteConstraint = {\n min: 0,\n max: 59,\n};\nconst hourConstraint = {\n min: 0,\n max: 23,\n};\nconst dayConstraint = {\n min: 1,\n max: 31,\n};\nconst monthConstraint = {\n min: 1,\n max: 12,\n aliases: {\n jan: '1',\n feb: '2',\n mar: '3',\n apr: '4',\n may: '5',\n jun: '6',\n jul: '7',\n aug: '8',\n sep: '9',\n oct: '10',\n nov: '11',\n dec: '12',\n },\n};\nconst weekdayConstraint = {\n min: 0,\n max: 7,\n aliases: {\n mon: '1',\n tue: '2',\n wed: '3',\n thu: '4',\n fri: '5',\n sat: '6',\n sun: '7',\n },\n};\nconst timeNicknames = {\n '@yearly': '0 0 1 1 *',\n '@annually': '0 0 1 1 *',\n '@monthly': '0 0 1 * *',\n '@weekly': '0 0 * * 0',\n '@daily': '0 0 * * *',\n '@hourly': '0 * * * *',\n '@minutely': '* * * * *',\n};\nfunction parseElement(element, constraint) {\n const result = new Set();\n // If returned set of numbers is empty, the scheduler class interpretes the emtpy set of numbers as all valid values of the constraint\n if (element === '*') {\n for (let i = constraint.min; i <= constraint.max; i = i + 1) {\n result.add(i);\n }\n return result;\n }\n // If the element is a list, parse each element in the list.\n const listElements = element.split(',');\n if (listElements.length > 1) {\n for (const listElement of listElements) {\n const parsedListElement = parseElement(listElement, constraint);\n for (const x of parsedListElement) {\n result.add(x);\n }\n }\n return result;\n }\n // Helper function to parse a single element, which includes checking for alias, valid number and constraint min and max.\n const parseSingleElement = (singleElement) => {\n var _a, _b;\n singleElement =\n (_b = (_a = constraint.aliases) === null || _a === void 0 ? void 0 : _a[singleElement.toLowerCase()]) !== null && _b !== void 0 ? _b : singleElement;\n const parsedElement = Number.parseInt(singleElement, 10);\n if (Number.isNaN(parsedElement)) {\n throw new Error(`Failed to parse ${element}: ${singleElement} is NaN.`);\n }\n if (parsedElement < constraint.min || parsedElement > constraint.max) {\n throw new Error(`Failed to parse ${element}: ${singleElement} is outside of constraint range of ${constraint.min} - ${constraint.max}.`);\n }\n return parsedElement;\n };\n // Detect if the element is a range.\n // Possible range formats: 'start-end', 'start-end/step', '*', '*/step'.\n // Where start and end can be numbers or aliases.\n // Capture groups: 1: start-end, 2: start, 3: end, 4: /step, 5: step.\n const rangeSegments = /^(([0-9a-zA-Z]+)-([0-9a-zA-Z]+)|\\*)(\\/([0-9]+))?$/.exec(element);\n // If not, it must be a single element.\n if (rangeSegments === null) {\n result.add(parseSingleElement(element));\n return result;\n }\n // If it is a range, get start and end of the range.\n let parsedStart = rangeSegments[1] === '*'\n ? constraint.min\n : parseSingleElement(rangeSegments[2]);\n const parsedEnd = rangeSegments[1] === '*'\n ? constraint.max\n : parseSingleElement(rangeSegments[3]);\n // need to catch Sunday, which gets parsed here as 7, but is also legitimate at the start of a range as 0, to avoid the out of order error\n if (constraint === weekdayConstraint &&\n parsedStart === 7 &&\n // this check ensures that sun-sun is not incorrectly parsed as [0,1,2,3,4,5,6]\n parsedEnd !== 7) {\n parsedStart = 0;\n }\n if (parsedStart > parsedEnd) {\n throw new Error(`Failed to parse ${element}: Invalid range (start: ${parsedStart}, end: ${parsedEnd}).`);\n }\n // Check whether there is a custom step defined for the range, defaulting to 1.\n const step = rangeSegments[5];\n let parsedStep = 1;\n if (step !== undefined) {\n parsedStep = Number.parseInt(step, 10);\n if (Number.isNaN(parsedStep)) {\n throw new Error(`Failed to parse step: ${step} is NaN.`);\n }\n if (parsedStep < 1) {\n throw new Error(`Failed to parse step: Expected ${step} to be greater than 0.`);\n }\n }\n // Go from start to end of the range by the given steps.\n for (let i = parsedStart; i <= parsedEnd; i = i + parsedStep) {\n result.add(i);\n }\n return result;\n}\n/** Parses a cron expression into a Cron instance. */\nexport function parseCronExpression(cronExpression) {\n var _a;\n if (typeof cronExpression !== 'string') {\n throw new TypeError('Invalid cron expression: must be of type string.');\n }\n // Convert time nicknames.\n cronExpression = (_a = timeNicknames[cronExpression.toLowerCase()]) !== null && _a !== void 0 ? _a : cronExpression;\n // Split the cron expression into its elements, removing empty elements (extra whitespaces).\n const elements = cronExpression.split(' ').filter((elem) => elem.length > 0);\n if (elements.length < 5 || elements.length > 6) {\n throw new Error('Invalid cron expression: expected 5 or 6 elements.');\n }\n const rawSeconds = elements.length === 6 ? elements[0] : '0';\n const rawMinutes = elements.length === 6 ? elements[1] : elements[0];\n const rawHours = elements.length === 6 ? elements[2] : elements[1];\n const rawDays = elements.length === 6 ? elements[3] : elements[2];\n const rawMonths = elements.length === 6 ? elements[4] : elements[3];\n const rawWeekdays = elements.length === 6 ? elements[5] : elements[4];\n return new Cron({\n seconds: parseElement(rawSeconds, secondConstraint),\n minutes: parseElement(rawMinutes, minuteConstraint),\n hours: parseElement(rawHours, hourConstraint),\n days: parseElement(rawDays, dayConstraint),\n // months in cron are indexed by 1, but Cron expects indexes by 0, so we need to reduce all set values by one.\n months: new Set(Array.from(parseElement(rawMonths, monthConstraint)).map((x) => x - 1)),\n weekdays: new Set(Array.from(parseElement(rawWeekdays, weekdayConstraint)).map((x) => x % 7)),\n });\n}\n//# sourceMappingURL=cron-parser.js.map","import { parseCronExpression } from \"cron-schedule\";\nimport { z } from \"zod\";\nimport { isWorkflow } from \"@keystrokehq/workflow\";\n//#region src/cron/cron-schedule.ts\n/**\n* Validates and brands a cron expression. Accepts anything the `cron-schedule`\n* engine accepts (5/6 fields, named months/weekdays, `@daily`-style nicknames)\n* so authoring validation never rejects a schedule the scheduler can run. The\n* `.brand()` makes `CronSchedule` nominally distinct from a plain `string`, so\n* a raw string can't be passed where a validated schedule is expected.\n*/\nconst cronScheduleSchema = z.string().trim().min(1, \"cron schedule must be a non-empty string\").refine(isParseableCron, \"must be a valid cron expression\").brand();\n/** Parse/validate an arbitrary value into a branded `CronSchedule` (throws on failure). */\nfunction parseCronSchedule(value) {\n\treturn cronScheduleSchema.parse(value);\n}\n/**\n* Resolves the effective schedule for an attachment, applying overrides by\n* precedence: per-attachment override → global override → the authored\n* schedule. Pure string precedence — no cron parsing.\n*/\nfunction resolveCronSchedule(attachmentId, schedule, options) {\n\treturn options.attachmentScheduleOverrides?.[attachmentId] ?? options.cronScheduleOverride ?? schedule;\n}\n/** Parse a schedule into a `cron-schedule` `Cron` instance (throws on invalid input). */\nfunction parseTriggerSchedule(schedule) {\n\treturn toCron(schedule);\n}\n/** The next time the schedule fires at or after `from`. */\nfunction nextTriggerRunAt(schedule, from = /* @__PURE__ */ new Date()) {\n\treturn toCron(schedule).getNextDate(from);\n}\n/**\n* Single touchpoint for the `cron-schedule` library — every parse, validation,\n* and next-run calculation in this package goes through here.\n*/\nfunction toCron(schedule) {\n\treturn parseCronExpression(schedule);\n}\nfunction isParseableCron(value) {\n\ttry {\n\t\ttoCron(value);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n//#endregion\n//#region src/attachment-definition.ts\nconst zodSchema = z.custom((v) => v instanceof z.ZodType, \"must be a Zod schema\");\nconst workflowSchema = z.custom((v) => isWorkflow(v), \"must be defineWorkflow(...)\");\nconst agentSchema = z.custom((v) => typeof v === \"object\" && v !== null && typeof v.slug === \"string\" && v.slug.trim().length > 0 && typeof v.prompt === \"function\", \"must be defineAgent(...)\");\nconst promptSchema = z.union([z.string(), z.function()]);\nconst baseSourceShape = {\n\tkey: z.string().trim().min(1),\n\tattach: z.function()\n};\nconst webhookSourceSchema = z.object({\n\tkind: z.literal(\"webhook\"),\n\t...baseSourceShape,\n\tendpoint: z.string().min(1),\n\trequest: zodSchema,\n\tfilter: zodSchema.optional(),\n\tpasses: z.function()\n});\nconst cronSourceSchema = z.object({\n\tkind: z.literal(\"cron\"),\n\t...baseSourceShape,\n\tschedule: cronScheduleSchema\n});\nconst pollSourceSchema = z.object({\n\tkind: z.literal(\"poll\"),\n\t...baseSourceShape,\n\tid: z.string().optional(),\n\tschedule: cronScheduleSchema,\n\trun: z.function(),\n\tfilters: z.array(z.function()),\n\tpasses: z.function()\n});\n/** Runtime validation for a trigger source (webhook | cron | poll). */\nconst triggerSourceSchema = z.discriminatedUnion(\"kind\", [\n\twebhookSourceSchema,\n\tcronSourceSchema,\n\tpollSourceSchema\n]);\nconst workflowAttachmentSchema = z.object({\n\tkey: z.string().trim().min(1),\n\tsource: triggerSourceSchema,\n\ttarget: z.literal(\"workflow\"),\n\tworkflow: workflowSchema,\n\ttransform: z.function().optional()\n});\nconst agentAttachmentSchema = z.object({\n\tkey: z.string().trim().min(1),\n\tsource: triggerSourceSchema,\n\ttarget: z.literal(\"agent\"),\n\tagent: agentSchema,\n\tprompt: promptSchema\n});\n/** Runtime validation for an unbranded trigger attachment. */\nconst triggerAttachmentCoreSchema = z.discriminatedUnion(\"target\", [workflowAttachmentSchema, agentAttachmentSchema]);\nconst TRIGGER_ATTACHMENT = Symbol.for(\"keystroke.triggerAttachment\");\n/**\n* Validates brand + shape via `triggerAttachmentCoreSchema` so server discovery\n* rejects unbranded or malformed attachments.\n*/\nfunction isTriggerAttachment(value) {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tif (!(TRIGGER_ATTACHMENT in value) || value[TRIGGER_ATTACHMENT] !== true) return false;\n\treturn triggerAttachmentCoreSchema.safeParse(value).success;\n}\nfunction isWorkflowTriggerAttachment(attachment) {\n\treturn attachment.target === \"workflow\";\n}\nfunction isAgentTriggerAttachment(attachment) {\n\treturn attachment.target === \"agent\";\n}\n//#endregion\n//#region src/attachment-key.ts\nfunction workflowKeyFromDefinition(workflow) {\n\tconst slug = workflow.slug?.trim();\n\tif (!slug) throw new Error(\"Workflow definition requires a non-empty slug\");\n\treturn slug;\n}\nfunction agentKeyFromAgent(agent) {\n\tconst slug = agent.slug?.trim();\n\tif (!slug) throw new Error(\"Agent definition requires a non-empty slug\");\n\treturn slug;\n}\nfunction attachmentKeyFrom(triggerKey, targetKey) {\n\treturn `${triggerKey}:${targetKey}`;\n}\n//#endregion\n//#region src/attach-options.ts\nfunction isAgentAttachOptions(options) {\n\treturn \"agent\" in options;\n}\n//#endregion\n//#region src/define-trigger-attachment.ts\n/**\n* Internal helper used by source `.attach()` factories. Validates the\n* attachment shape against `triggerAttachmentCoreSchema` and applies the\n* `TRIGGER_ATTACHMENT` brand.\n*/\nfunction defineTriggerAttachment(input) {\n\tconst result = triggerAttachmentCoreSchema.safeParse(input);\n\tif (!result.success) throw new Error(`Invalid trigger attachment: ${formatIssues(result.error.issues)}`);\n\treturn {\n\t\t...input,\n\t\t[TRIGGER_ATTACHMENT]: true\n\t};\n}\nfunction formatIssues(issues) {\n\treturn issues.map((issue) => {\n\t\treturn `${issue.path.length > 0 ? `${issue.path.join(\".\")}: ` : \"\"}${issue.message}`;\n\t}).join(\"; \");\n}\n//#endregion\n//#region src/attach-from-source.ts\nfunction attachFromSource(source, triggerKey, options) {\n\tif (isAgentAttachOptions(options)) return defineTriggerAttachment({\n\t\tkey: attachmentKeyFrom(triggerKey, agentKeyFromAgent(options.agent)),\n\t\tsource,\n\t\ttarget: \"agent\",\n\t\tagent: options.agent,\n\t\tprompt: options.prompt\n\t});\n\treturn defineTriggerAttachment({\n\t\tkey: attachmentKeyFrom(triggerKey, workflowKeyFromDefinition(options.workflow)),\n\t\tsource,\n\t\ttarget: \"workflow\",\n\t\tworkflow: options.workflow,\n\t\ttransform: options.transform\n\t});\n}\n//#endregion\n//#region src/trigger-match-schema.ts\nfunction matchShapeAndFilter(shape, filter, payload) {\n\tconst shaped = shape.safeParse(payload);\n\tif (!shaped.success) return;\n\tif (filter && !filter.safeParse(shaped.data).success) return;\n\treturn shaped.data;\n}\nfunction passesShapeAndFilter(shape, filter, payload) {\n\treturn matchShapeAndFilter(shape, filter, payload) !== void 0;\n}\nfunction matchWebhookPayload(raw, schemas) {\n\tconst matches = [];\n\tif (typeof z.fromJSONSchema !== \"function\") throw new Error(\"z.fromJSONSchema is required for JSON schema matching\");\n\tfor (const schema of schemas) {\n\t\tconst data = matchShapeAndFilter(z.fromJSONSchema(schema.requestSchema), schema.filterSchema ? z.fromJSONSchema(schema.filterSchema) : void 0, raw);\n\t\tif (data === void 0) continue;\n\t\tmatches.push({\n\t\t\tattachmentKey: schema.attachmentKey,\n\t\t\tdata\n\t\t});\n\t}\n\treturn matches;\n}\n/** Live Zod validation for webhook `request` + optional Zod `filter` (in-process paths). */\nfunction passesTriggerMatch(shape, filter, payload) {\n\treturn passesShapeAndFilter(shape, filter, payload);\n}\n//#endregion\n//#region src/sources/webhook-source.ts\nfunction normalizeWebhookEndpoint(endpoint) {\n\treturn endpoint.replace(/^\\/+|\\/+$/g, \"\").replace(/^triggers\\/?/, \"\");\n}\nfunction webhookObjectSchema(schema) {\n\tif (schema instanceof z.ZodObject) return schema.loose();\n\treturn schema;\n}\n/**\n* Defines a webhook trigger source — fires its attached workflow when a request\n* hits `/triggers/{endpoint}` and satisfies `request` plus any optional `filter`.\n*\n* @param options.key - Stable trigger key; attachment id is `{key}:{workflowKey}`.\n* @param options.endpoint - Shared route suffix under `/triggers/` (e.g. `\"stripe\"`).\n*/\nfunction defineWebhookSource(options) {\n\tconst triggerKey = options.key.trim();\n\tif (!triggerKey) throw new Error(\"defineWebhookSource requires a non-empty key\");\n\tconst endpoint = normalizeWebhookEndpoint(options.endpoint);\n\tif (!endpoint) throw new Error(\"defineWebhookSource requires a non-empty endpoint\");\n\tconst request = webhookObjectSchema(options.request);\n\tconst filter = options.filter ? webhookObjectSchema(options.filter) : void 0;\n\tconst source = {\n\t\tkind: \"webhook\",\n\t\tkey: triggerKey,\n\t\tendpoint,\n\t\trequest,\n\t\tfilter,\n\t\tpasses(payload) {\n\t\t\treturn passesTriggerMatch(request, filter, payload);\n\t\t},\n\t\tattach(attachOptions) {\n\t\t\treturn attachFromSource(source, triggerKey, attachOptions);\n\t\t}\n\t};\n\treturn source;\n}\n//#endregion\n//#region src/sources/cron-source.ts\n/**\n* Defines a cron trigger source — fires its attached workflow on a schedule.\n*\n* @param options.key - Stable trigger key; the attachment id is `{key}:{workflowKey}`.\n* @param options.schedule - A cron expression. Pass a 5-field literal (e.g.\n* `\"0 9 * * *\"`) for compile-time shape checking, or wrap with\n* `parseCronSchedule(...)` for 6-field, named (`MON`), or `@daily`-style\n* schedules. Validated at runtime; throws if the expression is invalid.\n* @example\n* defineCronSource({ key: \"morning\", schedule: \"0 9 * * *\" }).attach({ workflow });\n*/\nfunction defineCronSource(options) {\n\tconst triggerKey = options.key.trim();\n\tif (!triggerKey) throw new Error(\"defineCronSource requires a non-empty key\");\n\tconst source = {\n\t\tkind: \"cron\",\n\t\tkey: triggerKey,\n\t\tschedule: parseCronSchedule(options.schedule),\n\t\tattach(attachOptions) {\n\t\t\treturn attachFromSource(source, triggerKey, attachOptions);\n\t\t}\n\t};\n\treturn source;\n}\n//#endregion\n//#region src/sources/poll-source.ts\n/**\n* Defines a poll trigger source — runs `run` on a schedule and, when the result\n* passes any `.filter(...)`, fires the attached workflow with it.\n*\n* @param options.key - Stable trigger key; the attachment id is `{key}:{workflowKey}`.\n* @param options.id - Optional group id; poll sources sharing an id poll together.\n* @param options.schedule - Cron expression for the poll cadence (see `defineCronSource`).\n* @param options.run - Produces the payload checked by `filter` and passed to the workflow.\n* @param options.filter - Source-level predicate; the workflow only fires when it returns true.\n* @example\n* definePollSource({ key: \"inbox\", schedule: \"0 * * * *\", run: fetchInbox })\n* .filter((r) => r.length > 0)\n* .attach({ workflow });\n*/\nfunction definePollSource(options) {\n\tconst triggerKey = options.key.trim();\n\tif (!triggerKey) throw new Error(\"definePollSource requires a non-empty key\");\n\tconst schedule = parseCronSchedule(options.schedule);\n\tconst filters = [];\n\tif (options.filter) filters.push(options.filter);\n\tconst source = {\n\t\tkind: \"poll\",\n\t\tkey: triggerKey,\n\t\tid: options.id,\n\t\tschedule,\n\t\trun: options.run,\n\t\tfilters,\n\t\tpasses(payload) {\n\t\t\treturn source.filters.every((candidate) => candidate(payload));\n\t\t},\n\t\tattach(attachOptions) {\n\t\t\treturn attachFromSource(source, triggerKey, attachOptions);\n\t\t}\n\t};\n\tconst chain = source;\n\tchain.filter = (fn) => {\n\t\tsource.filters.push(fn);\n\t\treturn chain;\n\t};\n\treturn chain;\n}\n//#endregion\n//#region src/ephemeral-match.ts\nfunction emptyObjectSchema() {\n\treturn {\n\t\ttype: \"object\",\n\t\tproperties: {},\n\t\trequired: []\n\t};\n}\nfunction setConstAtPath(schema, path, value) {\n\tconst [head, ...rest] = path;\n\tif (!head) return;\n\tif (!schema.required.includes(head)) schema.required.push(head);\n\tif (rest.length === 0) {\n\t\tschema.properties[head] = { const: value };\n\t\treturn;\n\t}\n\tconst existing = schema.properties[head];\n\tconst child = existing && typeof existing === \"object\" && existing.type === \"object\" ? existing : emptyObjectSchema();\n\tschema.properties[head] = child;\n\tsetConstAtPath(child, rest, value);\n}\n/**\n* Compiles a shallow `match` object into a JSON Schema usable as a stored webhook\n* `requestSchema`. Dots in keys are treated as path separators; an empty match\n* produces a schema that accepts any JSON object payload.\n*/\nfunction matchToJsonSchema(match) {\n\tconst schema = emptyObjectSchema();\n\tfor (const [path, value] of Object.entries(match)) setConstAtPath(schema, path.split(\".\").filter((segment) => segment.length > 0), value);\n\tif (schema.required.length === 0) return { type: \"object\" };\n\treturn schema;\n}\n//#endregion\n//#region src/interpolate-prompt.ts\nfunction resolvePath(payload, path) {\n\tlet current = payload;\n\tfor (const segment of path) {\n\t\tif (current === null || typeof current !== \"object\") return;\n\t\tcurrent = current[segment];\n\t}\n\treturn current;\n}\n/**\n* Resolves `{{path}}` / `{{payload.path}}` dot-path tokens in an ephemeral trigger\n* prompt against the webhook payload. Unresolved tokens are left untouched so the\n* agent can see what failed to bind.\n*/\nfunction interpolatePrompt(template, payload) {\n\treturn template.replace(/\\{\\{\\s*([\\w.$-]+)\\s*\\}\\}/g, (token, rawPath) => {\n\t\tconst segments = rawPath.split(\".\");\n\t\tif (segments[0] === \"payload\") segments.shift();\n\t\tconst value = segments.length === 0 ? payload : resolvePath(payload, segments);\n\t\tif (value === void 0) return token;\n\t\treturn typeof value === \"string\" ? value : JSON.stringify(value);\n\t});\n}\n//#endregion\n//#region src/resolve-agent-prompt.ts\n/** Resolves the agent prompt for a validated trigger payload. */\nfunction resolveAgentPrompt(attachment, payload) {\n\tconst prompt = attachment.prompt;\n\tif (typeof prompt === \"function\") return prompt(payload ?? {});\n\treturn prompt;\n}\n//#endregion\n//#region src/resolve-attachment-input.ts\nfunction applyAttachmentTransform(attachment, payload) {\n\treturn attachment.transform ? attachment.transform(payload) : payload;\n}\n/**\n* Applies attachment `transform` to a payload that already passed source validation.\n* Webhook payloads are matched at ingress via persisted Zod JSON schemas.\n*/\nfunction resolveAttachmentTransform(attachment, payload) {\n\tif (isAgentTriggerAttachment(attachment)) return payload;\n\treturn applyAttachmentTransform(attachment, payload);\n}\n/** Applies poll source filters and attachment `transform`. Webhook ingress already matched Zod schemas. */\nfunction resolveAttachmentInput(attachment, payload) {\n\tconst source = attachment.source;\n\tif (source.kind === \"poll\" && !source.passes(payload)) return;\n\tif (isAgentTriggerAttachment(attachment)) return payload;\n\treturn applyAttachmentTransform(attachment, payload);\n}\n//#endregion\nexport { TRIGGER_ATTACHMENT, cronScheduleSchema, defineCronSource, definePollSource, defineWebhookSource, interpolatePrompt, isAgentTriggerAttachment, isTriggerAttachment, isWorkflowTriggerAttachment, matchToJsonSchema, matchWebhookPayload, nextTriggerRunAt, normalizeWebhookEndpoint, parseCronSchedule, parseTriggerSchedule, resolveAgentPrompt, resolveAttachmentInput, resolveAttachmentTransform, resolveCronSchedule };\n\n//# sourceMappingURL=index.mjs.map"],"x_google_ignoreList":[0,1,2],"mappings":";;;AA6BA,SAAgB,oBAAoB,MAAM;CACtC,OAAO;EACH,QAAQ,KAAK,WAAW;EACxB,QAAQ,KAAK,WAAW;EACxB,MAAM,KAAK,SAAS;EACpB,KAAK,KAAK,QAAQ;EAClB,OAAO,KAAK,SAAS;EACrB,SAAS,KAAK,OAAO;EACrB,MAAM,KAAK,YAAY;CAC3B;AACJ;AAEA,SAAgB,eAAe,MAAM,OAAO;CACxC,OAAO,IAAI,KAAK,MAAM,QAAQ,GAAG,CAAC,EAAE,QAAQ;AAChD;AAEA,SAAgB,uBAAuB,UAAU,UAAU;CACvD,IAAI,YAAY,UACZ,OAAO,WAA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,QAAQ,OAAO,YAAY,UAAU;EACrD,UAAU,QAAQ;CACnB;CACA,OAAO;AACR;;;;;;AAMA,SAAS,kBAAkB,UAAU,SAAS;CAC7C,OAAO,SAAS,QAAQ,8BAA8B,OAAO,YAAY;EACxE,MAAM,WAAW,QAAQ,MAAM,GAAG;EAClC,IAAI,SAAS,OAAO,WAAW,SAAS,MAAM;EAC9C,MAAM,QAAQ,SAAS,WAAW,IAAI,UAAU,YAAY,SAAS,QAAQ;EAC7E,IAAI,UAAU,KAAK,GAAG,OAAO;EAC7B,OAAO,OAAO,UAAU,WAAW,QAAQ,KAAK,UAAU,KAAK;CAChE,CAAC;AACF;;AAIA,SAAS,mBAAmB,YAAY,SAAS;CAChD,MAAM,SAAS,WAAW;CAC1B,IAAI,OAAO,WAAW,YAAY,OAAO,OAAO,WAAW,CAAC,CAAC;CAC7D,OAAO;AACR;AAGA,SAAS,yBAAyB,YAAY,SAAS;CACtD,OAAO,WAAW,YAAY,WAAW,UAAU,OAAO,IAAI;AAC/D;;;;;AAKA,SAAS,2BAA2B,YAAY,SAAS;CACxD,IAAI,yBAAyB,UAAU,GAAG,OAAO;CACjD,OAAO,yBAAyB,YAAY,OAAO;AACpD;;AAEA,SAAS,uBAAuB,YAAY,SAAS;CACpD,MAAM,SAAS,WAAW;CAC1B,IAAI,OAAO,SAAS,UAAU,CAAC,OAAO,OAAO,OAAO,GAAG;CACvD,IAAI,yBAAyB,UAAU,GAAG,OAAO;CACjD,OAAO,yBAAyB,YAAY,OAAO;AACpD"}
|
package/dist/workflow.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_dist = require("./dist-
|
|
2
|
+
const require_dist = require("./dist-C0fPHFaM.cjs");
|
|
3
3
|
exports.MemoryEventLog = require_dist.MemoryEventLog;
|
|
4
4
|
exports.RunCanceledError = require_dist.RunCanceledError;
|
|
5
5
|
exports.defineWorkflow = require_dist.defineWorkflow;
|
package/dist/workflow.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { _ as
|
|
2
|
-
import { C as deserializeWorkflowError, D as promptLlm, E as isWorkflow, O as serializeWorkflowError, S as defineWorkflow, T as isRunCanceledError, _ as SleepPendingItem, a as HookHandle, b as WorkflowRunContext, c as LlmStepExecutor, d as PromptLlmOptions, f as ReplayEvent, g as SleepDuration, h as SerializedWorkflowError, i as ExecuteWorkflowOptions, l as MemoryEventLog, m as RunCanceledError, n as AppendEventInput, o as HookOptions, p as ReplayResult, r as DurableEventLog, s as HookPendingItem, t as AgentStepExecutor, u as PendingItem, v as WorkflowDefinition, w as executeWorkflow, x as WorkflowSleep, y as WorkflowHook } from "./index-
|
|
1
|
+
import { _ as PromptLlmRunOptions, v as PromptLlmThinkingLevel } from "./index-WT4ULMiw.cjs";
|
|
2
|
+
import { C as deserializeWorkflowError, D as promptLlm, E as isWorkflow, O as serializeWorkflowError, S as defineWorkflow, T as isRunCanceledError, _ as SleepPendingItem, a as HookHandle, b as WorkflowRunContext, c as LlmStepExecutor, d as PromptLlmOptions, f as ReplayEvent, g as SleepDuration, h as SerializedWorkflowError, i as ExecuteWorkflowOptions, l as MemoryEventLog, m as RunCanceledError, n as AppendEventInput, o as HookOptions, p as ReplayResult, r as DurableEventLog, s as HookPendingItem, t as AgentStepExecutor, u as PendingItem, v as WorkflowDefinition, w as executeWorkflow, x as WorkflowSleep, y as WorkflowHook } from "./index-3P7ec4Vo.cjs";
|
|
3
3
|
export { type AgentStepExecutor, type AppendEventInput, type DurableEventLog, type ExecuteWorkflowOptions, type HookHandle, type HookOptions, type HookPendingItem, type LlmStepExecutor, MemoryEventLog, type PendingItem, type PromptLlmOptions, type PromptLlmRunOptions, type PromptLlmThinkingLevel, type ReplayEvent, type ReplayResult, RunCanceledError, type SerializedWorkflowError, type SleepDuration, type SleepPendingItem, type WorkflowDefinition, type WorkflowHook, type WorkflowRunContext, type WorkflowSleep, defineWorkflow, deserializeWorkflowError, executeWorkflow, isRunCanceledError, isWorkflow, promptLlm, serializeWorkflowError };
|
package/dist/workflow.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { _ as
|
|
2
|
-
import { C as deserializeWorkflowError, D as promptLlm, E as isWorkflow, O as serializeWorkflowError, S as defineWorkflow, T as isRunCanceledError, _ as SleepPendingItem, a as HookHandle, b as WorkflowRunContext, c as LlmStepExecutor, d as PromptLlmOptions, f as ReplayEvent, g as SleepDuration, h as SerializedWorkflowError, i as ExecuteWorkflowOptions, l as MemoryEventLog, m as RunCanceledError, n as AppendEventInput, o as HookOptions, p as ReplayResult, r as DurableEventLog, s as HookPendingItem, t as AgentStepExecutor, u as PendingItem, v as WorkflowDefinition, w as executeWorkflow, x as WorkflowSleep, y as WorkflowHook } from "./index-
|
|
1
|
+
import { _ as PromptLlmRunOptions, v as PromptLlmThinkingLevel } from "./index-WT4ULMiw.mjs";
|
|
2
|
+
import { C as deserializeWorkflowError, D as promptLlm, E as isWorkflow, O as serializeWorkflowError, S as defineWorkflow, T as isRunCanceledError, _ as SleepPendingItem, a as HookHandle, b as WorkflowRunContext, c as LlmStepExecutor, d as PromptLlmOptions, f as ReplayEvent, g as SleepDuration, h as SerializedWorkflowError, i as ExecuteWorkflowOptions, l as MemoryEventLog, m as RunCanceledError, n as AppendEventInput, o as HookOptions, p as ReplayResult, r as DurableEventLog, s as HookPendingItem, t as AgentStepExecutor, u as PendingItem, v as WorkflowDefinition, w as executeWorkflow, x as WorkflowSleep, y as WorkflowHook } from "./index-D7UUmswR.mjs";
|
|
3
3
|
export { type AgentStepExecutor, type AppendEventInput, type DurableEventLog, type ExecuteWorkflowOptions, type HookHandle, type HookOptions, type HookPendingItem, type LlmStepExecutor, MemoryEventLog, type PendingItem, type PromptLlmOptions, type PromptLlmRunOptions, type PromptLlmThinkingLevel, type ReplayEvent, type ReplayResult, RunCanceledError, type SerializedWorkflowError, type SleepDuration, type SleepPendingItem, type WorkflowDefinition, type WorkflowHook, type WorkflowRunContext, type WorkflowSleep, defineWorkflow, deserializeWorkflowError, executeWorkflow, isRunCanceledError, isWorkflow, promptLlm, serializeWorkflowError };
|
package/dist/workflow.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as executeWorkflow, c as promptLlm, i as deserializeWorkflowError, l as serializeWorkflowError, n as RunCanceledError, o as isRunCanceledError, r as defineWorkflow, s as isWorkflow, t as MemoryEventLog } from "./dist-
|
|
1
|
+
import { a as executeWorkflow, c as promptLlm, i as deserializeWorkflowError, l as serializeWorkflowError, n as RunCanceledError, o as isRunCanceledError, r as defineWorkflow, s as isWorkflow, t as MemoryEventLog } from "./dist-nvW8vbKn.mjs";
|
|
2
2
|
export { MemoryEventLog, RunCanceledError, defineWorkflow, deserializeWorkflowError, executeWorkflow, isRunCanceledError, isWorkflow, promptLlm, serializeWorkflowError };
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dist-BpkCqbil.mjs","names":[],"sources":["../../workflow/dist/index.mjs"],"sourcesContent":["import { z } from \"zod\";\nimport { executeAction, getActionCredentialRequirements, getRunSignal, getWorkflowRunHandle, normalizeCredentialList, registerWorkflowRunGetter } from \"@keystrokehq/action\";\nimport { captureConsole, logSystem, withSpan } from \"@keystrokehq/tracing\";\nimport { resolveActionCredentials } from \"@keystrokehq/credentials\";\nimport { AsyncLocalStorage } from \"node:async_hooks\";\n//#region src/run-canceled-error.ts\nvar RunCanceledError = class extends Error {\n\tconstructor(runId) {\n\t\tsuper(runId ? `Workflow run ${runId} was canceled` : \"Workflow run was canceled\");\n\t\tthis.name = \"RunCanceledError\";\n\t}\n};\nfunction isRunCanceledError(error) {\n\treturn error instanceof RunCanceledError;\n}\n//#endregion\n//#region src/workflow-definition.ts\nconst zodSchema = z.custom((v) => v instanceof z.ZodType, \"must be a Zod schema\");\n/** Runtime validation for an unbranded workflow definition. */\nconst workflowCoreSchema = z.object({\n\tslug: z.string().trim().min(1),\n\tname: z.string().optional(),\n\tdescription: z.string().optional(),\n\tsubscription: z.object({ mode: z.enum([\"system\", \"subscribable\"]).optional() }).optional(),\n\tinput: zodSchema,\n\toutput: zodSchema,\n\trun: z.function()\n});\nconst WORKFLOW = Symbol.for(\"keystroke.workflow\");\n/**\n* Validates brand + shape via `workflowCoreSchema` so discovery and guards\n* reject malformed definitions.\n*/\nfunction isWorkflow(value) {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tif (!(WORKFLOW in value) || value[WORKFLOW] !== true) return false;\n\treturn workflowCoreSchema.safeParse(value).success;\n}\n//#endregion\n//#region src/define-workflow.ts\nfunction defineWorkflow(def) {\n\tconst result = workflowCoreSchema.safeParse(def);\n\tif (!result.success) throw new Error(`Invalid workflow definition: ${formatIssues(result.error.issues)}`);\n\treturn {\n\t\t...result.data,\n\t\t[WORKFLOW]: true\n\t};\n}\nfunction formatIssues(issues) {\n\treturn issues.map((issue) => {\n\t\treturn `${issue.path.length > 0 ? `${issue.path.join(\".\")}: ` : \"\"}${issue.message}`;\n\t}).join(\"; \");\n}\n//#endregion\n//#region src/replay/error.ts\nfunction serializeWorkflowError(error) {\n\tif (error instanceof Error) return {\n\t\tname: error.name,\n\t\tmessage: error.message\n\t};\n\treturn { message: String(error) };\n}\n/** Rebuild an Error from a recorded error so replay re-raises the same failure. */\nfunction deserializeWorkflowError(data) {\n\tconst serialized = data;\n\tconst error = new Error(serialized?.message ?? \"Workflow step failed\");\n\tif (serialized?.name) error.name = serialized.name;\n\treturn error;\n}\n//#endregion\n//#region src/replay/duration.ts\nconst UNIT_MS = {\n\tms: 1,\n\ts: 1e3,\n\tm: 6e4,\n\th: 36e5,\n\td: 864e5\n};\n/** Resolve a sleep duration to an absolute resume time. */\nfunction resolveResumeAt(duration, now = /* @__PURE__ */ new Date()) {\n\tif (duration instanceof Date) return duration;\n\tif (typeof duration === \"number\") return new Date(now.getTime() + Math.max(0, duration));\n\treturn new Date(now.getTime() + parseDurationToMs(duration));\n}\nfunction parseDurationToMs(value) {\n\tconst match = /^(\\d+(?:\\.\\d+)?)\\s*(ms|s|m|h|d)$/.exec(value.trim());\n\tif (!match) throw new Error(`Invalid sleep duration \"${value}\". Use a number of ms, a Date, or a string like \"5s\", \"10m\", \"1h\".`);\n\tconst amount = Number(match[1]);\n\tconst unit = match[2];\n\treturn Math.round(amount * UNIT_MS[unit]);\n}\n//#endregion\n//#region src/replay/events-consumer.ts\n/** Indexes replay events by correlationId for O(1) cache-hit checks during replay. */\nvar EventsConsumer = class {\n\tbyCorrelationId = /* @__PURE__ */ new Map();\n\tconstructor(events) {\n\t\tfor (const event of events) {\n\t\t\tif (!event.correlationId) continue;\n\t\t\tconst list = this.byCorrelationId.get(event.correlationId);\n\t\t\tif (list) list.push(event);\n\t\t\telse this.byCorrelationId.set(event.correlationId, [event]);\n\t\t}\n\t}\n\tevents(correlationId) {\n\t\treturn this.byCorrelationId.get(correlationId) ?? [];\n\t}\n\thasEventType(correlationId, type) {\n\t\treturn this.events(correlationId).some((event) => event.type === type);\n\t}\n\t/**\n\t* Cache lookup for a step. Returns the recorded output on a `step_completed`,\n\t* re-raises the recorded error on a terminal `step_failed` (so a permanently\n\t* failed step is not re-executed), and otherwise reports a miss — including\n\t* when only `step_retrying` events exist (the step re-runs on the next pass).\n\t*/\n\tgetStepResult(correlationId) {\n\t\tconst events = this.events(correlationId);\n\t\tconst failed = events.find((event) => event.type === \"step_failed\");\n\t\tif (failed) throw deserializeWorkflowError(failed.data);\n\t\tconst completed = events.find((event) => event.type === \"step_completed\");\n\t\tif (completed) return {\n\t\t\tcompleted: true,\n\t\t\tresult: completed.data\n\t\t};\n\t\treturn { completed: false };\n\t}\n\t/** Number of prior `step_retrying` events recorded for a step (= failed attempts so far). */\n\tcountRetrying(correlationId) {\n\t\treturn this.events(correlationId).filter((event) => event.type === \"step_retrying\").length;\n\t}\n\tisSleepCompleted(correlationId) {\n\t\treturn this.hasEventType(correlationId, \"sleep_completed\");\n\t}\n\t/** Returns the persisted resumeAt for a scheduled-but-not-completed sleep, if any. */\n\tgetSleepResumeAt(correlationId) {\n\t\tconst scheduled = this.events(correlationId).find((event) => event.type === \"sleep_scheduled\");\n\t\tif (!scheduled) return;\n\t\tconst data = scheduled.data;\n\t\treturn data?.resumeAt ? new Date(data.resumeAt) : void 0;\n\t}\n\tgetHookToken(correlationId) {\n\t\treturn (this.events(correlationId).find((event) => event.type === \"hook_created\")?.data)?.token;\n\t}\n\tgetHookResult(correlationId) {\n\t\tconst resumed = this.events(correlationId).find((event) => event.type === \"hook_resumed\");\n\t\tif (!resumed) return { resolved: false };\n\t\treturn {\n\t\t\tresolved: true,\n\t\t\tpayload: resumed.data?.payload\n\t\t};\n\t}\n};\n//#endregion\n//#region src/replay/suspension.ts\n/** A promise that never settles — returned by a suspending primitive so the body parks. */\nfunction createPendingPromise() {\n\treturn new Promise(() => {});\n}\n/**\n* Collects pending items requested within a single tick and resolves once, so\n* parallel suspensions (e.g. Promise.all of two sleeps) batch into one suspension.\n*/\nvar SuspensionCoordinator = class {\n\titems = /* @__PURE__ */ new Map();\n\tscheduled = false;\n\tresolve;\n\tpromise;\n\tconstructor() {\n\t\tthis.promise = new Promise((resolve) => {\n\t\t\tthis.resolve = resolve;\n\t\t});\n\t}\n\trequest(item) {\n\t\tthis.items.set(item.correlationId, item);\n\t\tif (!this.scheduled) {\n\t\t\tthis.scheduled = true;\n\t\t\tqueueMicrotask(() => {\n\t\t\t\tthis.resolve([...this.items.values()]);\n\t\t\t});\n\t\t}\n\t}\n\twaitForSuspension() {\n\t\treturn this.promise;\n\t}\n};\n//#endregion\n//#region src/replay/replay-context.ts\nfunction createReplayState(params) {\n\treturn {\n\t\trunId: params.runId,\n\t\tconsumer: params.consumer,\n\t\tcoordinator: params.coordinator,\n\t\teventLog: params.eventLog,\n\t\tnewEvents: [],\n\t\tnow: params.now ?? /* @__PURE__ */ new Date(),\n\t\thookBaseUrl: params.hookBaseUrl,\n\t\tsleepCounter: 0,\n\t\thookCounter: 0,\n\t\tstepOccurrences: /* @__PURE__ */ new Map(),\n\t\tstepCorrelationIds: /* @__PURE__ */ new Set()\n\t};\n}\n/**\n* Allocate the correlation id for a step. An explicit `.stepId(x)` maps to\n* `step:x` (and must be unique within a run); otherwise the key is\n* `step:<actionKey>#<occurrence>` so that two calls to the same action get\n* distinct, replay-stable ids and inserting an unrelated call never shifts the\n* ids of later calls (unlike a single global ordinal).\n*/\nfunction nextStepCorrelationId(state, actionKey, explicitId) {\n\tif (explicitId !== void 0) {\n\t\tconst correlationId = `step:${explicitId}`;\n\t\tif (state.stepCorrelationIds.has(correlationId)) throw new Error(`Duplicate step id \"${explicitId}\" in workflow run ${state.runId}`);\n\t\tstate.stepCorrelationIds.add(correlationId);\n\t\treturn correlationId;\n\t}\n\tconst occurrence = state.stepOccurrences.get(actionKey) ?? 0;\n\tstate.stepOccurrences.set(actionKey, occurrence + 1);\n\tconst correlationId = `step:${actionKey}#${occurrence}`;\n\tstate.stepCorrelationIds.add(correlationId);\n\treturn correlationId;\n}\nfunction createSleep(state) {\n\treturn function sleep(duration) {\n\t\tconst correlationId = `sleep#${state.sleepCounter++}`;\n\t\tif (state.consumer.isSleepCompleted(correlationId)) return Promise.resolve();\n\t\tconst scheduledResumeAt = state.consumer.getSleepResumeAt(correlationId);\n\t\tconst resumeAt = scheduledResumeAt ?? resolveResumeAt(duration, state.now);\n\t\tif (scheduledResumeAt && resumeAt.getTime() <= state.now.getTime()) {\n\t\t\tstate.newEvents.push({\n\t\t\t\tid: `sleep_completed:${state.runId}:${correlationId}`,\n\t\t\t\trunId: state.runId,\n\t\t\t\ttype: \"sleep_completed\",\n\t\t\t\tcorrelationId\n\t\t\t});\n\t\t\treturn Promise.resolve();\n\t\t}\n\t\tif (!scheduledResumeAt) state.newEvents.push({\n\t\t\tid: `sleep_scheduled:${state.runId}:${correlationId}`,\n\t\t\trunId: state.runId,\n\t\t\ttype: \"sleep_scheduled\",\n\t\t\tcorrelationId,\n\t\t\tdata: { resumeAt: resumeAt.toISOString() }\n\t\t});\n\t\tstate.coordinator.request({\n\t\t\tkind: \"sleep\",\n\t\t\tcorrelationId,\n\t\t\tresumeAt\n\t\t});\n\t\treturn createPendingPromise();\n\t};\n}\nfunction createHook(state) {\n\treturn function hook(options) {\n\t\tconst correlationId = `hook#${state.hookCounter++}`;\n\t\tconst token = options?.token ?? state.consumer.getHookToken(correlationId) ?? `hook_${crypto.randomUUID()}`;\n\t\treturn {\n\t\t\ttoken,\n\t\t\tresumeUrl: state.hookBaseUrl ? `${state.hookBaseUrl}/hooks/${token}/resume` : `/hooks/${token}/resume`,\n\t\t\tthen(onFulfilled, onRejected) {\n\t\t\t\tconst result = state.consumer.getHookResult(correlationId);\n\t\t\t\tif (result.resolved) {\n\t\t\t\t\tconst payload = options?.schema ? options.schema.parse(result.payload) : result.payload;\n\t\t\t\t\treturn Promise.resolve(payload).then(onFulfilled, onRejected);\n\t\t\t\t}\n\t\t\t\tif (!state.consumer.hasEventType(correlationId, \"hook_created\")) state.newEvents.push({\n\t\t\t\t\tid: `hook_created:${state.runId}:${correlationId}`,\n\t\t\t\t\trunId: state.runId,\n\t\t\t\t\ttype: \"hook_created\",\n\t\t\t\t\tcorrelationId,\n\t\t\t\t\tdata: { token }\n\t\t\t\t});\n\t\t\t\tstate.coordinator.request({\n\t\t\t\t\tkind: \"hook\",\n\t\t\t\t\tcorrelationId,\n\t\t\t\t\ttoken\n\t\t\t\t});\n\t\t\t\treturn createPendingPromise().then(onFulfilled, onRejected);\n\t\t\t}\n\t\t};\n\t};\n}\n//#endregion\n//#region src/run-durable-step.ts\n/**\n* Shared durable-step shell: resolve a stable `correlation_id`, short-circuit\n* from the event log on a cache hit, otherwise execute and append\n* `step_completed` immediately (per-step crash durability). A thrown step\n* appends `step_retrying` (non-fatal, re-run on the next attempt) and\n* rethrows; the terminal `step_failed` is written by the job handler once the\n* queue exhausts retries.\n*/\nasync function runDurableStep(state, options) {\n\tconst { runId, consumer, eventLog } = state;\n\tgetRunSignal().throwIfAborted();\n\tconst correlationId = nextStepCorrelationId(state, options.key, options.id);\n\tconst cached = consumer.getStepResult(correlationId);\n\tconst metadata = {\n\t\trunId,\n\t\t[options.metadataKey]: options.key,\n\t\tcorrelationId\n\t};\n\tif (cached.completed) {\n\t\tawait withSpan({\n\t\t\tkind: options.kind,\n\t\t\tname: options.key,\n\t\t\trefId: `${runId}:${correlationId}`,\n\t\t\tmetadata: {\n\t\t\t\t...metadata,\n\t\t\t\treplayed: true\n\t\t\t}\n\t\t}, async () => {\n\t\t\tawait logSystem(\"info\", options.replayMessage, metadata);\n\t\t});\n\t\treturn options.parseCached ? options.parseCached(cached.result) : cached.result;\n\t}\n\treturn withSpan({\n\t\tkind: options.kind,\n\t\tname: options.key,\n\t\trefId: `${runId}:${correlationId}`,\n\t\tmetadata\n\t}, async () => captureConsole(async () => {\n\t\ttry {\n\t\t\tconst result = await options.execute();\n\t\t\tawait eventLog.append({\n\t\t\t\tid: `step_completed:${runId}:${correlationId}`,\n\t\t\t\trunId,\n\t\t\t\ttype: \"step_completed\",\n\t\t\t\tcorrelationId,\n\t\t\t\tdata: result\n\t\t\t});\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tconst attempt = consumer.countRetrying(correlationId);\n\t\t\tawait eventLog.append({\n\t\t\t\tid: `step_retrying:${runId}:${correlationId}:${attempt}`,\n\t\t\t\trunId,\n\t\t\t\ttype: \"step_retrying\",\n\t\t\t\tcorrelationId,\n\t\t\t\tdata: serializeWorkflowError(error)\n\t\t\t});\n\t\t\tstate.failedCorrelationId = correlationId;\n\t\t\tthrow error;\n\t\t}\n\t}));\n}\n//#endregion\n//#region src/create-action-runner.ts\nfunction withCredentialScopeOverride(requirements, scope) {\n\tif (!requirements || !scope) return requirements;\n\treturn normalizeCredentialList(requirements).map((requirement) => ({\n\t\t...requirement,\n\t\tscope\n\t}));\n}\n/** Builds the per-run action runner; durability lives in {@link runDurableStep}. */\nfunction createActionRunner(state, options = {}) {\n\treturn (action, input, runOptions) => runDurableStep(state, {\n\t\tkind: \"action\",\n\t\tkey: action.slug,\n\t\tid: runOptions?.id,\n\t\tmetadataKey: \"actionKey\",\n\t\treplayMessage: \"action replayed from checkpoint\",\n\t\tparseCached: (cached) => action.output.parse(cached),\n\t\texecute: async () => {\n\t\t\tconst requirements = withCredentialScopeOverride(getActionCredentialRequirements(action), runOptions?.credentialScope);\n\t\t\treturn executeAction(action, input, requirements?.length ? await resolveActionCredentials(requirements, {\n\t\t\t\tresolveCredentials: options.resolveCredentials,\n\t\t\t\tcontext: options.credentialContext,\n\t\t\t\toauthAdapter: options.oauthAdapter,\n\t\t\t\tconsumer: {\n\t\t\t\t\tkind: \"action\",\n\t\t\t\t\tname: action.slug\n\t\t\t\t}\n\t\t\t}) : {});\n\t\t}\n\t});\n}\n//#endregion\n//#region src/create-agent-step-runner.ts\n/**\n* Builds the per-run agent runner: each `agent.prompt()` in a workflow body\n* becomes a durable step keyed `step:<agentKey>#<occurrence>` (same scheme as\n* actions). The actual prompt execution is delegated to `runAgent`, supplied\n* by the host (server) via `executeWorkflow({ runAgent })`.\n*/\nfunction createAgentStepRunner(state, runAgent) {\n\treturn (agent, input, options) => {\n\t\tconst slug = agent.slug;\n\t\treturn runDurableStep(state, {\n\t\t\tkind: \"agent_session\",\n\t\t\tkey: slug,\n\t\t\tid: options?.id,\n\t\t\tmetadataKey: \"agentKey\",\n\t\t\treplayMessage: \"agent step replayed from checkpoint\",\n\t\t\texecute: () => runAgent(agent, input, options?.runPrompt)\n\t\t});\n\t};\n}\n//#endregion\n//#region src/create-llm-step-runner.ts\n/**\n* Builds the per-run LLM runner: each `promptLlm()` in a workflow body becomes a\n* durable step keyed `step:promptLlm#<occurrence>`. The actual LLM call is\n* delegated to `runLlm`, supplied by the host (server) via `executeWorkflow({ runLlm })`.\n*/\nfunction createLlmStepRunner(state, runLlm) {\n\treturn (opts) => runDurableStep(state, {\n\t\tkind: \"llm\",\n\t\tkey: \"promptLlm\",\n\t\tid: opts.stepId,\n\t\tmetadataKey: \"llmKey\",\n\t\treplayMessage: \"llm step replayed from checkpoint\",\n\t\tparseCached: (cached) => opts.outputSchema ? opts.outputSchema.parse(cached) : cached,\n\t\texecute: () => runLlm(opts)\n\t});\n}\n//#endregion\n//#region src/run-context.ts\nconst storage = new AsyncLocalStorage();\nregisterWorkflowRunGetter(() => {\n\tconst store = storage.getStore();\n\tif (!store) return;\n\treturn {\n\t\tactionRunner: store.actionRunner,\n\t\tagentRunner: store.agentRunner,\n\t\tllmRunner: store.llmRunner\n\t};\n});\nfunction runWithWorkflowContext(store, fn) {\n\treturn storage.run(store, fn);\n}\n//#endregion\n//#region src/replay/memory-event-log.ts\n/** In-memory durable log for inline execution and tests. */\nvar MemoryEventLog = class {\n\tevents = [];\n\tids = /* @__PURE__ */ new Set();\n\tasync append(event) {\n\t\tconst id = event.id ?? crypto.randomUUID();\n\t\tif (this.ids.has(id)) return false;\n\t\tthis.ids.add(id);\n\t\tthis.events.push({\n\t\t\tid,\n\t\t\trunId: event.runId,\n\t\t\tseq: this.events.length,\n\t\t\ttype: event.type,\n\t\t\tcorrelationId: event.correlationId ?? null,\n\t\t\tdata: event.data ?? null\n\t\t});\n\t\treturn true;\n\t}\n\tasync listReplay(runId) {\n\t\treturn this.events.filter((event) => event.runId === runId).map((event) => ({ ...event }));\n\t}\n};\n//#endregion\n//#region src/execute-workflow.ts\n/**\n* The single way to run a workflow: replay its event log from the top, execute\n* un-cached primitives, and either complete/fail or suspend at the first\n* un-satisfied sleep/hook. New events (sleep_scheduled/sleep_completed/\n* hook_created/run_completed/run_failed) are flushed before returning.\n*\n* Durability comes entirely from the log — a suspended run resumes by calling\n* this again with the same `runId` and event log once the sleep is due or the\n* hook is resumed.\n*/\nasync function executeWorkflow(workflow, input, options = {}) {\n\tconst runId = options.runId ?? crypto.randomUUID();\n\tconst eventLog = options.eventLog ?? new MemoryEventLog();\n\tconst signal = getRunSignal();\n\tconst consumer = new EventsConsumer(await eventLog.listReplay(runId));\n\tconst coordinator = new SuspensionCoordinator();\n\tconst state = createReplayState({\n\t\trunId,\n\t\tconsumer,\n\t\tcoordinator,\n\t\teventLog,\n\t\thookBaseUrl: options.hookBaseUrl,\n\t\tnow: options.now\n\t});\n\tconst actionRunner = createActionRunner(state, {\n\t\tresolveCredentials: options.resolveCredentials,\n\t\tcredentialContext: options.credentialContext,\n\t\toauthAdapter: options.oauthAdapter\n\t});\n\tconst ctx = {\n\t\trunId,\n\t\tsleep: createSleep(state),\n\t\thook: createHook(state),\n\t\t...options.context\n\t};\n\tconst agentRunner = options.runAgent ? createAgentStepRunner(state, options.runAgent) : void 0;\n\tconst llmRunner = options.runLlm ? createLlmStepRunner(state, options.runLlm) : void 0;\n\tconst validatedInput = workflow.input.parse(input);\n\tconst bodyPromise = runWithWorkflowContext({\n\t\tactionRunner,\n\t\tagentRunner,\n\t\tllmRunner,\n\t\trunId\n\t}, () => captureConsole(async () => workflow.run(validatedInput, ctx)));\n\tlet onAbort;\n\tconst waitForAbort = signal.aborted ? Promise.resolve({ type: \"canceled\" }) : new Promise((resolve) => {\n\t\tonAbort = () => resolve({ type: \"canceled\" });\n\t\tsignal.addEventListener(\"abort\", onAbort, { once: true });\n\t});\n\tconst outcome = await Promise.race([\n\t\tbodyPromise.then((output) => ({\n\t\t\ttype: \"done\",\n\t\t\toutput\n\t\t}), (error) => ({\n\t\t\ttype: \"error\",\n\t\t\terror\n\t\t})),\n\t\tcoordinator.waitForSuspension().then((items) => ({\n\t\t\ttype: \"suspended\",\n\t\t\titems\n\t\t})),\n\t\twaitForAbort\n\t]);\n\tif (onAbort) signal.removeEventListener(\"abort\", onAbort);\n\tlet result;\n\tif (outcome.type === \"suspended\") {\n\t\tbodyPromise.catch(() => {});\n\t\tresult = {\n\t\t\tstatus: \"suspended\",\n\t\t\titems: outcome.items\n\t\t};\n\t} else if (outcome.type === \"done\") {\n\t\tconst output = workflow.output.parse(outcome.output);\n\t\tstate.newEvents.push({\n\t\t\tid: `run_completed:${runId}`,\n\t\t\trunId,\n\t\t\ttype: \"run_completed\",\n\t\t\tdata: { output }\n\t\t});\n\t\tresult = {\n\t\t\tstatus: \"completed\",\n\t\t\toutput\n\t\t};\n\t} else if (outcome.type === \"canceled\" || isRunCanceledError(outcome.error)) {\n\t\tbodyPromise.catch(() => {});\n\t\tstate.newEvents.push({\n\t\t\tid: `run_canceled:${runId}`,\n\t\t\trunId,\n\t\t\ttype: \"run_canceled\"\n\t\t});\n\t\tresult = { status: \"canceled\" };\n\t} else result = {\n\t\tstatus: \"failed\",\n\t\terror: outcome.error,\n\t\tfailedCorrelationId: state.failedCorrelationId\n\t};\n\tfor (const event of state.newEvents) await eventLog.append(event);\n\treturn result;\n}\n//#endregion\n//#region src/prompt-llm.ts\nfunction promptLlm(prompt, opts) {\n\tconst handle = getWorkflowRunHandle();\n\tif (!handle?.llmRunner) throw new Error(\"promptLlm must run inside a workflow with an injected llm executor (executeWorkflow({ runLlm })).\");\n\treturn handle.llmRunner({\n\t\tprompt,\n\t\t...opts\n\t});\n}\n//#endregion\nexport { MemoryEventLog, RunCanceledError, defineWorkflow, deserializeWorkflowError, executeWorkflow, isRunCanceledError, isWorkflow, promptLlm, serializeWorkflowError };\n\n//# sourceMappingURL=index.mjs.map"],"mappings":";;;;;AAMA,IAAI,mBAAmB,cAAc,MAAM;CAC1C,YAAY,OAAO;EAClB,MAAM,QAAQ,gBAAgB,MAAM,iBAAiB,2BAA2B;EAChF,KAAK,OAAO;CACb;AACD;AACA,SAAS,mBAAmB,OAAO;CAClC,OAAO,iBAAiB;AACzB;AAGA,MAAM,YAAY,EAAE,QAAQ,MAAM,aAAa,EAAE,SAAS,sBAAsB;;AAEhF,MAAM,qBAAqB,EAAE,OAAO;CACnC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC;CAC7B,MAAM,EAAE,OAAO,EAAE,SAAS;CAC1B,aAAa,EAAE,OAAO,EAAE,SAAS;CACjC,cAAc,EAAE,OAAO,EAAE,MAA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