@keystrokehq/keystroke 1.0.14 → 1.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/action.cjs +1 -1
  2. package/dist/action.mjs +1 -1
  3. package/dist/agent.cjs +5 -5
  4. package/dist/agent.cjs.map +1 -1
  5. package/dist/agent.mjs +5 -5
  6. package/dist/agent.mjs.map +1 -1
  7. package/dist/app.cjs +1 -1
  8. package/dist/app.mjs +1 -1
  9. package/dist/client.cjs +1 -1
  10. package/dist/client.mjs +1 -1
  11. package/dist/config.d.cts +2 -2
  12. package/dist/config.d.cts.map +1 -1
  13. package/dist/config.d.mts +2 -2
  14. package/dist/config.d.mts.map +1 -1
  15. package/dist/credentials.cjs +1 -1
  16. package/dist/credentials.mjs +1 -1
  17. package/dist/{dist-DtejauR-.mjs → dist-BWGuF7Bi.mjs} +22 -9
  18. package/dist/dist-BWGuF7Bi.mjs.map +1 -0
  19. package/dist/{dist-C5UmW-zB.cjs → dist-CDMCEgV0.cjs} +22 -9
  20. package/dist/dist-CDMCEgV0.cjs.map +1 -0
  21. package/dist/{dist-D53HZMV9.mjs → dist-CFKSzdSZ.mjs} +9 -3
  22. package/dist/dist-CFKSzdSZ.mjs.map +1 -0
  23. package/dist/{dist-DSbrc1sP.mjs → dist-DtLObwAS.mjs} +3 -3
  24. package/dist/{dist-DSbrc1sP.mjs.map → dist-DtLObwAS.mjs.map} +1 -1
  25. package/dist/{dist-DpZL1LE1.cjs → dist-DvZ4Dj_O.cjs} +9 -3
  26. package/dist/dist-DvZ4Dj_O.cjs.map +1 -0
  27. package/dist/{dist-Zh8nB_45.cjs → dist-sGyB6KsC.cjs} +3 -3
  28. package/dist/{dist-Zh8nB_45.cjs.map → dist-sGyB6KsC.cjs.map} +1 -1
  29. package/dist/index-BTz2OMAM.d.cts.map +1 -1
  30. package/dist/index-Cq2F2XdS.d.mts.map +1 -1
  31. package/dist/index-WT4ULMiw.d.cts.map +1 -1
  32. package/dist/index-WT4ULMiw.d.mts.map +1 -1
  33. package/dist/{mistral-6XMKgah3.cjs → mistral-BUpUX0vh.cjs} +2 -2
  34. package/dist/{mistral-6XMKgah3.cjs.map → mistral-BUpUX0vh.cjs.map} +1 -1
  35. package/dist/{mistral-tahkZ8Hu.mjs → mistral-Cy4OBeve.mjs} +2 -2
  36. package/dist/{mistral-tahkZ8Hu.mjs.map → mistral-Cy4OBeve.mjs.map} +1 -1
  37. package/dist/{sse-CSbz_aIR.mjs → sse-4YoGxYO1.mjs} +2 -2
  38. package/dist/{sse-CSbz_aIR.mjs.map → sse-4YoGxYO1.mjs.map} +1 -1
  39. package/dist/{sse-PotOG2Pc.cjs → sse-C0gnbJhp.cjs} +2 -2
  40. package/dist/{sse-PotOG2Pc.cjs.map → sse-C0gnbJhp.cjs.map} +1 -1
  41. package/dist/trigger.cjs +135 -35
  42. package/dist/trigger.cjs.map +1 -1
  43. package/dist/trigger.d.cts +87 -20
  44. package/dist/trigger.d.cts.map +1 -1
  45. package/dist/trigger.d.mts +87 -20
  46. package/dist/trigger.d.mts.map +1 -1
  47. package/dist/trigger.mjs +122 -36
  48. package/dist/trigger.mjs.map +1 -1
  49. package/dist/workflow.cjs +1 -1
  50. package/dist/workflow.mjs +1 -1
  51. package/package.json +1 -1
  52. package/dist/dist-C5UmW-zB.cjs.map +0 -1
  53. package/dist/dist-D53HZMV9.mjs.map +0 -1
  54. package/dist/dist-DpZL1LE1.cjs.map +0 -1
  55. package/dist/dist-DtejauR-.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"trigger.cjs","names":["z","isWorkflow"],"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,uB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yBAAyB,UAAU,GAAG,OAAO;CACjD,OAAO,yBAAyB,YAAY,OAAO;AACpD"}
1
+ {"version":3,"file":"trigger.cjs","names":["z","isWorkflow"],"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()]);\n/** backwards-compat: normalize legacy `key` fields to canonical `slug` before validation. */\nfunction normalizeLegacySlugFields(value) {\n\tif (typeof value !== \"object\" || value === null) return value;\n\tconst next = { ...value };\n\tif (typeof next.slug !== \"string\" && typeof next.key === \"string\") next.slug = next.key;\n\tdelete next.key;\n\tif (typeof next.source === \"object\" && next.source !== null) next.source = normalizeLegacySlugFields(next.source);\n\treturn next;\n}\nconst slugField = z.string().trim().min(1);\nconst optionalTextField = z.string().optional();\nconst baseSourceShape = {\n\tslug: slugField,\n\tname: optionalTextField,\n\tdescription: optionalTextField,\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.preprocess(normalizeLegacySlugFields, z.discriminatedUnion(\"kind\", [\n\twebhookSourceSchema,\n\tcronSourceSchema,\n\tpollSourceSchema\n]));\nconst workflowAttachmentSchema = z.object({\n\tslug: slugField,\n\tname: optionalTextField,\n\tdescription: optionalTextField,\n\tsource: triggerSourceSchema,\n\ttarget: z.literal(\"workflow\"),\n\tworkflow: workflowSchema,\n\ttransform: z.function().optional()\n});\nconst agentAttachmentSchema = z.object({\n\tslug: slugField,\n\tname: optionalTextField,\n\tdescription: optionalTextField,\n\tsource: triggerSourceSchema,\n\ttarget: z.literal(\"agent\"),\n\tagent: agentSchema,\n\tprompt: promptSchema\n});\nconst triggerAttachmentCoreSchemaBase = z.discriminatedUnion(\"target\", [workflowAttachmentSchema, agentAttachmentSchema]);\n/** Runtime validation for an unbranded trigger attachment. */\nconst triggerAttachmentCoreSchema = z.preprocess(normalizeLegacySlugFields, triggerAttachmentCoreSchemaBase);\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/trigger-slug.ts\n/** Resolve slug from authoring options (`slug` preferred, `key` fallback). */\nfunction resolveAuthoringSlug(input, label = \"trigger\") {\n\tconst slug = input.slug?.trim() || input.key?.trim();\n\tif (!slug) throw new Error(`${label} requires a non-empty slug`);\n\treturn slug;\n}\n/** Composite attachment slug `{sourceSlug}:{targetSlug}`. */\nfunction attachmentSlugFrom(sourceSlug, targetSlug) {\n\treturn `${sourceSlug}:${targetSlug}`;\n}\n/** Read slug from a trigger source (`slug` preferred, legacy `key` fallback). */\nfunction sourceSlugFrom(source) {\n\tconst slug = source.slug?.trim() || source.key?.trim();\n\tif (!slug) throw new Error(\"Trigger source requires slug or legacy key\");\n\treturn slug;\n}\n/** Read slug from a trigger attachment (`slug` preferred, legacy `key` fallback). */\nfunction attachmentSlugFromRecord(attachment) {\n\tconst slug = attachment.slug?.trim() || attachment.key?.trim();\n\tif (!slug) throw new Error(\"Trigger attachment requires slug or legacy key\");\n\treturn slug;\n}\n/** Source slug prefix from a composite attachment slug. */\nfunction triggerSourceSlugFromAttachmentSlug(attachmentSlug) {\n\tconst separator = attachmentSlug.indexOf(\":\");\n\treturn separator === -1 ? attachmentSlug : attachmentSlug.slice(0, separator);\n}\n/** Target slug suffix from a composite attachment slug. */\nfunction triggerTargetSlugFromAttachmentSlug(attachmentSlug) {\n\tconst separator = attachmentSlug.indexOf(\":\");\n\treturn separator === -1 ? attachmentSlug : attachmentSlug.slice(separator + 1);\n}\n//#endregion\n//#region src/attachment-slug.ts\nfunction workflowSlugFromDefinition(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 agentSlugFromAgent(agent) {\n\tconst slug = agent.slug?.trim();\n\tif (!slug) throw new Error(\"Agent definition requires a non-empty slug\");\n\treturn slug;\n}\n/** @deprecated Use {@link attachmentSlugFrom}. */\nconst attachmentKeyFrom = attachmentSlugFrom;\n/** @deprecated Use {@link workflowSlugFromDefinition}. */\nconst workflowKeyFromDefinition = workflowSlugFromDefinition;\n/** @deprecated Use {@link agentSlugFromAgent}. */\nconst agentKeyFromAgent = agentSlugFromAgent;\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...result.data,\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/trigger-meta.ts\nfunction triggerMetaFromSource(source) {\n\treturn {\n\t\t...source.name !== void 0 ? { name: source.name } : {},\n\t\t...source.description !== void 0 ? { description: source.description } : {}\n\t};\n}\nfunction triggerMetaFromAttachment(attachment) {\n\tconst name = attachment.name ?? attachment.source.name;\n\tconst description = attachment.description ?? attachment.source.description;\n\treturn {\n\t\t...name !== void 0 ? { name } : {},\n\t\t...description !== void 0 ? { description } : {}\n\t};\n}\nfunction triggerMetaRecordFromAttachment(attachment) {\n\tconst meta = triggerMetaFromAttachment(attachment);\n\treturn {\n\t\tname: meta.name ?? null,\n\t\tdescription: meta.description ?? null\n\t};\n}\n//#endregion\n//#region src/attach-from-source.ts\nfunction attachFromSource(source, sourceSlug, options) {\n\tconst meta = triggerMetaFromSource(source);\n\tif (isAgentAttachOptions(options)) return defineTriggerAttachment({\n\t\tslug: attachmentSlugFrom(sourceSlug, agentSlugFromAgent(options.agent)),\n\t\t...meta,\n\t\tsource,\n\t\ttarget: \"agent\",\n\t\tagent: options.agent,\n\t\tprompt: options.prompt\n\t});\n\treturn defineTriggerAttachment({\n\t\tslug: attachmentSlugFrom(sourceSlug, workflowSlugFromDefinition(options.workflow)),\n\t\t...meta,\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\tattachmentSlug: schema.attachmentSlug,\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.slug - Stable trigger source slug; attachment slug is `{slug}:{targetSlug}`.\n* @param options.key - **Deprecated.** Accepted for backwards-compatible definitions.\n* @param options.endpoint - Shared route suffix under `/triggers/` (e.g. `\"stripe\"`).\n*/\nfunction defineWebhookSource(options) {\n\tconst sourceSlug = resolveAuthoringSlug(options, \"defineWebhookSource\");\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\tslug: sourceSlug,\n\t\t...options.name !== void 0 ? { name: options.name } : {},\n\t\t...options.description !== void 0 ? { description: options.description } : {},\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, sourceSlug, 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.slug - Stable trigger source slug; attachment slug is `{slug}:{targetSlug}`.\n* @param options.key - **Deprecated.** Accepted for backwards-compatible definitions.\n* @param options.name - Optional human-readable name shown in the platform.\n* @param options.description - Optional short description shown in the platform.\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({ slug: \"morning\", schedule: \"0 9 * * *\" }).attach({ workflow });\n*/\nfunction defineCronSource(options) {\n\tconst sourceSlug = resolveAuthoringSlug(options, \"defineCronSource\");\n\tconst schedule = parseCronSchedule(options.schedule);\n\tconst source = {\n\t\tkind: \"cron\",\n\t\tslug: sourceSlug,\n\t\t...options.name !== void 0 ? { name: options.name } : {},\n\t\t...options.description !== void 0 ? { description: options.description } : {},\n\t\tschedule,\n\t\tattach(attachOptions) {\n\t\t\treturn attachFromSource(source, sourceSlug, 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.slug - Stable trigger source slug; attachment slug is `{slug}:{targetSlug}`.\n* @param options.key - **Deprecated.** Accepted for backwards-compatible definitions.\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({ slug: \"inbox\", schedule: \"0 * * * *\", run: fetchInbox })\n* .filter((r) => r.length > 0)\n* .attach({ workflow });\n*/\nfunction definePollSource(options) {\n\tconst sourceSlug = resolveAuthoringSlug(options, \"definePollSource\");\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\tslug: sourceSlug,\n\t\t...options.name !== void 0 ? { name: options.name } : {},\n\t\t...options.description !== void 0 ? { description: options.description } : {},\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, sourceSlug, 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, agentKeyFromAgent, agentSlugFromAgent, attachmentKeyFrom, attachmentSlugFrom, attachmentSlugFromRecord, cronScheduleSchema, defineCronSource, definePollSource, defineWebhookSource, interpolatePrompt, isAgentTriggerAttachment, isTriggerAttachment, isWorkflowTriggerAttachment, matchToJsonSchema, matchWebhookPayload, nextTriggerRunAt, normalizeWebhookEndpoint, parseCronSchedule, parseTriggerSchedule, resolveAgentPrompt, resolveAttachmentInput, resolveAttachmentTransform, resolveAuthoringSlug, resolveCronSchedule, sourceSlugFrom, triggerMetaFromAttachment, triggerMetaFromSource, triggerMetaRecordFromAttachment, triggerSourceSlugFromAttachmentSlug, triggerTargetSlugFromAttachmentSlug, workflowKeyFromDefinition, workflowSlugFromDef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;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"}
@@ -144,32 +144,71 @@ type AgentAttachOptions = {
144
144
  prompt: string | ((payload: unknown) => string);
145
145
  };
146
146
  type AttachOptions<TInput = unknown, TOutput = unknown> = WorkflowAttachOptions<TInput, TOutput> | AgentAttachOptions; //#endregion
147
+ //#region src/trigger-slug.d.ts
148
+ /** Optional human-facing metadata (same as agents/workflows). */
149
+ type TriggerMetaInput = {
150
+ name?: string;
151
+ description?: string;
152
+ };
153
+ /** Authoring input: `slug` is canonical; `key` is legacy. */
154
+ type TriggerAuthoringSlugInput = {
155
+ slug?: string; /** @deprecated Use `slug`. Accepted for backwards-compatible trigger definitions. */
156
+ key?: string;
157
+ };
158
+ /** Authoring options shared by all `define*Source` factories. */
159
+ type TriggerSourceAuthoringInput = TriggerAuthoringSlugInput & TriggerMetaInput;
160
+ /** Resolve slug from authoring options (`slug` preferred, `key` fallback). */
161
+ declare function resolveAuthoringSlug(input: TriggerAuthoringSlugInput, label?: string): string;
162
+ /** Composite attachment slug `{sourceSlug}:{targetSlug}`. */
163
+ declare function attachmentSlugFrom(sourceSlug: string, targetSlug: string): string;
164
+ /** Read slug from a trigger source (`slug` preferred, legacy `key` fallback). */
165
+ declare function sourceSlugFrom(source: {
166
+ slug?: string;
167
+ key?: string;
168
+ }): string;
169
+ /** Read slug from a trigger attachment (`slug` preferred, legacy `key` fallback). */
170
+ declare function attachmentSlugFromRecord(attachment: {
171
+ slug?: string;
172
+ key?: string;
173
+ }): string;
174
+ /** Source slug prefix from a composite attachment slug. */
175
+ declare function triggerSourceSlugFromAttachmentSlug(attachmentSlug: string): string;
176
+ /** Target slug suffix from a composite attachment slug. */
177
+ declare function triggerTargetSlugFromAttachmentSlug(attachmentSlug: string): string; //#endregion
147
178
  //#region src/sources/cron-source.d.ts
148
- type CronSource = {
179
+ type CronSource = TriggerSourceBase & {
149
180
  kind: "cron";
150
- key: string;
151
181
  schedule: CronSchedule;
152
182
  attach<TInput, TOutput>(options: AttachOptions<TInput, TOutput>): TriggerAttachment;
153
183
  };
184
+ type TriggerSourceBase = {
185
+ slug: string;
186
+ name?: string;
187
+ description?: string;
188
+ };
154
189
  /**
155
190
  * Defines a cron trigger source — fires its attached workflow on a schedule.
156
191
  *
157
- * @param options.key - Stable trigger key; the attachment id is `{key}:{workflowKey}`.
192
+ * @param options.slug - Stable trigger source slug; attachment slug is `{slug}:{targetSlug}`.
193
+ * @param options.key - **Deprecated.** Accepted for backwards-compatible definitions.
194
+ * @param options.name - Optional human-readable name shown in the platform.
195
+ * @param options.description - Optional short description shown in the platform.
158
196
  * @param options.schedule - A cron expression. Pass a 5-field literal (e.g.
159
197
  * `"0 9 * * *"`) for compile-time shape checking, or wrap with
160
198
  * `parseCronSchedule(...)` for 6-field, named (`MON`), or `@daily`-style
161
199
  * schedules. Validated at runtime; throws if the expression is invalid.
162
200
  * @example
163
- * defineCronSource({ key: "morning", schedule: "0 9 * * *" }).attach({ workflow });
201
+ * defineCronSource({ slug: "morning", schedule: "0 9 * * *" }).attach({ workflow });
164
202
  */
165
- declare function defineCronSource(options: {
166
- key: string;
203
+ declare function defineCronSource(options: TriggerSourceAuthoringInput & {
167
204
  schedule: CronScheduleInput;
168
205
  }): CronSource; //#endregion
169
206
  //#region src/sources/poll-source.d.ts
170
207
  type PollSource<TResult = unknown> = {
171
208
  kind: "poll";
172
- key: string;
209
+ slug: string;
210
+ name?: string;
211
+ description?: string;
173
212
  id?: string;
174
213
  schedule: CronSchedule;
175
214
  run: () => TResult | Promise<TResult>;
@@ -184,18 +223,18 @@ type PollSourceChain<TResult> = PollSource<TResult> & {
184
223
  * Defines a poll trigger source — runs `run` on a schedule and, when the result
185
224
  * passes any `.filter(...)`, fires the attached workflow with it.
186
225
  *
187
- * @param options.key - Stable trigger key; the attachment id is `{key}:{workflowKey}`.
226
+ * @param options.slug - Stable trigger source slug; attachment slug is `{slug}:{targetSlug}`.
227
+ * @param options.key - **Deprecated.** Accepted for backwards-compatible definitions.
188
228
  * @param options.id - Optional group id; poll sources sharing an id poll together.
189
229
  * @param options.schedule - Cron expression for the poll cadence (see `defineCronSource`).
190
230
  * @param options.run - Produces the payload checked by `filter` and passed to the workflow.
191
231
  * @param options.filter - Source-level predicate; the workflow only fires when it returns true.
192
232
  * @example
193
- * definePollSource({ key: "inbox", schedule: "0 * * * *", run: fetchInbox })
233
+ * definePollSource({ slug: "inbox", schedule: "0 * * * *", run: fetchInbox })
194
234
  * .filter((r) => r.length > 0)
195
235
  * .attach({ workflow });
196
236
  */
197
- declare function definePollSource<TResult>(options: {
198
- key: string;
237
+ declare function definePollSource<TResult>(options: TriggerSourceAuthoringInput & {
199
238
  id?: string;
200
239
  schedule: CronScheduleInput;
201
240
  run: () => TResult | Promise<TResult>;
@@ -206,7 +245,9 @@ declare const TRIGGER_ATTACHMENT: unique symbol;
206
245
  /** Trigger source as seen from outside the source factories. */
207
246
  type TriggerSource = WebhookSource | CronSource | PollSource;
208
247
  type WorkflowTriggerAttachment = {
209
- key: string;
248
+ slug: string;
249
+ name?: string;
250
+ description?: string;
210
251
  source: TriggerSource;
211
252
  target: "workflow";
212
253
  workflow: WorkflowDefinition<any, any>;
@@ -214,7 +255,9 @@ type WorkflowTriggerAttachment = {
214
255
  readonly [TRIGGER_ATTACHMENT]: true;
215
256
  };
216
257
  type AgentTriggerAttachment = {
217
- key: string;
258
+ slug: string;
259
+ name?: string;
260
+ description?: string;
218
261
  source: TriggerSource;
219
262
  target: "agent";
220
263
  agent: Agent;
@@ -237,7 +280,9 @@ declare function isAgentTriggerAttachment(attachment: TriggerAttachment): attach
237
280
  declare function normalizeWebhookEndpoint(endpoint: string): string;
238
281
  type WebhookSource = {
239
282
  kind: "webhook";
240
- key: string;
283
+ slug: string;
284
+ name?: string;
285
+ description?: string;
241
286
  endpoint: string;
242
287
  request: z.ZodType;
243
288
  filter?: z.ZodType;
@@ -248,23 +293,23 @@ type WebhookSource = {
248
293
  * Defines a webhook trigger source — fires its attached workflow when a request
249
294
  * hits `/triggers/{endpoint}` and satisfies `request` plus any optional `filter`.
250
295
  *
251
- * @param options.key - Stable trigger key; attachment id is `{key}:{workflowKey}`.
296
+ * @param options.slug - Stable trigger source slug; attachment slug is `{slug}:{targetSlug}`.
297
+ * @param options.key - **Deprecated.** Accepted for backwards-compatible definitions.
252
298
  * @param options.endpoint - Shared route suffix under `/triggers/` (e.g. `"stripe"`).
253
299
  */
254
- declare function defineWebhookSource<TRequestSchema extends z.ZodType, TFilterSchema extends z.ZodType | undefined = undefined>(options: {
255
- key: string;
300
+ declare function defineWebhookSource<TRequestSchema extends z.ZodType, TFilterSchema extends z.ZodType | undefined = undefined>(options: TriggerSourceAuthoringInput & {
256
301
  endpoint: string;
257
302
  request: TRequestSchema;
258
303
  filter?: TFilterSchema;
259
304
  }): WebhookSource; //#endregion
260
305
  //#region src/trigger-match-schema.d.ts
261
306
  type WebhookAttachmentSchema = {
262
- attachmentKey: string;
307
+ attachmentSlug: string;
263
308
  requestSchema: Record<string, unknown>;
264
309
  filterSchema?: Record<string, unknown>;
265
310
  };
266
311
  type WebhookPayloadMatch = {
267
- attachmentKey: string;
312
+ attachmentSlug: string;
268
313
  data: unknown;
269
314
  };
270
315
  declare function matchWebhookPayload(raw: unknown, schemas: WebhookAttachmentSchema[]): WebhookPayloadMatch[]; //#endregion
@@ -313,6 +358,28 @@ type PollSkipResponse = {
313
358
  ok: true;
314
359
  skipped: true;
315
360
  }; //#endregion
361
+ //#region src/trigger-meta.d.ts
362
+ declare function triggerMetaFromSource(source: TriggerSource): {
363
+ name?: string;
364
+ description?: string;
365
+ };
366
+ declare function triggerMetaFromAttachment(attachment: TriggerAttachment): {
367
+ name?: string;
368
+ description?: string;
369
+ };
370
+ declare function triggerMetaRecordFromAttachment(attachment: TriggerAttachment): {
371
+ name: string | null;
372
+ description: string | null;
373
+ }; //#endregion
374
+ //#region src/attachment-slug.d.ts
375
+ declare function workflowSlugFromDefinition(workflow: WorkflowDefinition<unknown, unknown>): string;
376
+ declare function agentSlugFromAgent(agent: Agent): string;
377
+ /** @deprecated Use {@link attachmentSlugFrom}. */
378
+ declare const attachmentKeyFrom: typeof attachmentSlugFrom;
379
+ /** @deprecated Use {@link workflowSlugFromDefinition}. */
380
+ declare const workflowKeyFromDefinition: typeof workflowSlugFromDefinition;
381
+ /** @deprecated Use {@link agentSlugFromAgent}. */
382
+ declare const agentKeyFromAgent: typeof agentSlugFromAgent; //#endregion
316
383
  //#endregion
317
- export { type AgentAttachOptions, type AgentTriggerAttachment, type AttachOptions, type CronExpression, type CronSchedule, type CronScheduleInput, type CronSource, type EphemeralWebhookMatch, type PollSkipResponse, type PollSource, type RunContext, TRIGGER_ATTACHMENT, type TriggerAttachment, type TriggerSource, type WebhookAttachmentSchema, type WebhookPayloadMatch, type WebhookSkipResponse, type WebhookSource, type WorkflowAttachOptions, type WorkflowTriggerAttachment, cronScheduleSchema, defineCronSource, definePollSource, defineWebhookSource, interpolatePrompt, isAgentTriggerAttachment, isTriggerAttachment, isWorkflowTriggerAttachment, matchToJsonSchema, matchWebhookPayload, nextTriggerRunAt, normalizeWebhookEndpoint, parseCronSchedule, parseTriggerSchedule, resolveAgentPrompt, resolveAttachmentInput, resolveAttachmentTransform, resolveCronSchedule };
384
+ export { type AgentAttachOptions, type AgentTriggerAttachment, type AttachOptions, type CronExpression, type CronSchedule, type CronScheduleInput, type CronSource, type EphemeralWebhookMatch, type PollSkipResponse, type PollSource, type RunContext, TRIGGER_ATTACHMENT, type TriggerAttachment, type TriggerAuthoringSlugInput, type TriggerMetaInput, type TriggerSource, type TriggerSourceAuthoringInput, type WebhookAttachmentSchema, type WebhookPayloadMatch, type WebhookSkipResponse, type WebhookSource, type WorkflowAttachOptions, type WorkflowTriggerAttachment, agentKeyFromAgent, agentSlugFromAgent, attachmentKeyFrom, attachmentSlugFrom, attachmentSlugFromRecord, cronScheduleSchema, defineCronSource, definePollSource, defineWebhookSource, interpolatePrompt, isAgentTriggerAttachment, isTriggerAttachment, isWorkflowTriggerAttachment, matchToJsonSchema, matchWebhookPayload, nextTriggerRunAt, normalizeWebhookEndpoint, parseCronSchedule, parseTriggerSchedule, resolveAgentPrompt, resolveAttachmentInput, resolveAttachmentTransform, resolveAuthoringSlug, resolveCronSchedule, sourceSlugFrom, triggerMetaFromAttachment, triggerMetaFromSource, triggerMetaRecordFromAttachment, triggerSourceSlugFromAttachmentSlug, triggerTargetSlugFromAttachmentSlug, workflowKeyFromDefinition, workflowSlugFromDefinition };
318
385
  //# sourceMappingURL=trigger.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"trigger.d.cts","names":["ICronDefinition","Set","seconds","minutes","hours","days","months","weekdays","Cron","ReadonlyArray","Date","Generator","reversed","constructor","findAllowedHour","findAllowedMinute","findAllowedSecond","findAllowedTime","findAllowedDayInMonth","getNextDate","startDate","getNextDates","amount","getNextDatesIterator","endDate","getPrevDate","getPrevDates","getPrevDatesIterator","matchDate","date","Cron","z","WorkflowDefinition","Agent","CredentialRunContext","CronField","CronExpression","cronScheduleSchema","ZodString","core","$ZodBranded","CronSchedule","infer","CronScheduleInput","parseCronSchedule","value","resolveCronSchedule","Record","attachmentId","schedule","cronScheduleOverride","attachmentScheduleOverrides","options","parseTriggerSchedule","nextTriggerRunAt","Date","from","WorkflowAttachOptions","TInput","TOutput","workflow","transform","payload","AgentAttachOptions","agent","prompt","AttachOptions","CronSource","TriggerAttachment","kind","key","attach","defineCronSource","PollSource","TResult","Promise","Array","id","run","filters","passes","PollSourceChain","filter","fn","definePollSource","TRIGGER_ATTACHMENT","TriggerSource","WebhookSource","WorkflowTriggerAttachment","source","target","AgentTriggerAttachment","isTriggerAttachment","isWorkflowTriggerAttachment","attachment","isAgentTriggerAttachment","normalizeWebhookEndpoint","endpoint","ZodType","request","defineWebhookSource","TRequestSchema","TFilterSchema","WebhookAttachmentSchema","attachmentKey","requestSchema","filterSchema","WebhookPayloadMatch","data","matchWebhookPayload","raw","schemas","EphemeralWebhookMatch","matchToJsonSchema","match","interpolatePrompt","template","resolveAgentPrompt","resolveAttachmentTransform","resolveAttachmentInput","RunContext","trigger","triggeredAt","credentials","WebhookSkipResponse","ok","skipped","PollSkipResponse"],"sources":["../../../node_modules/.pnpm/cron-schedule@6.0.0/node_modules/cron-schedule/dist/cron.d.ts","../../trigger/dist/index.d.mts"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;UAIiBA,eAAAA;EAAAA,SACJE,OAAAA,EAASD,GAAAA;EAAAA,SACTE,OAAAA,EAASF,GAAAA;EAAAA,SACTG,KAAAA,EAAOH,GAAAA;EAAAA,SACPI,IAAAA,EAAMJ,GAAAA;EAAAA,SACNK,MAAAA,EAAQL,GAAAA;EAAAA,SACRM,QAAAA,EAAUN,GAAAA;AAAAA;AAAAA,cAEFO,IAAAA;EAAAA,SACRN,OAAAA,EAASO,aAAAA;EAAAA,SACTN,OAAAA,EAASM,aAAAA;EAAAA,SACTL,KAAAA,EAAOK,aAAAA;EAAAA,SACPJ,IAAAA,EAAMI,aAAAA;EAAAA,SACNH,MAAAA,EAAQG,aAAAA;EAAAA,SACRF,QAAAA,EAAUE,aAAAA;EAAAA,SACVG,QAAAA;IACLV,OAAAA,EAASO,aAAAA;IACTN,OAAAA,EAASM,aAAAA;IACTL,KAAAA,EAAOK,aAAAA;IACPJ,IAAAA,EAAMI,aAAAA;IACNH,MAAAA,EAAQG,aAAAA;IACRF,QAAAA,EAAUE,aAAAA;EAAAA;EAEdI,WAAAA,CAAAA;IAAcX,OAAAA;IAASC,OAAAA;IAASC,KAAAA;IAAOC,IAAAA;IAAMC,MAAAA;IAAQC;EAAAA,GAAaP,eAAAA;EAjBzDO;;;AAAa;EAAbA,QAsBDO,eAAAA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AAA;EACHF,EAAAA;EACAC,OAAO;AAAA"}
1
+ {"version":3,"file":"trigger.d.cts","names":["ICronDefinition","Set","seconds","minutes","hours","days","months","weekdays","Cron","ReadonlyArray","Date","Generator","reversed","constructor","findAllowedHour","findAllowedMinute","findAllowedSecond","findAllowedTime","findAllowedDayInMonth","getNextDate","startDate","getNextDates","amount","getNextDatesIterator","endDate","getPrevDate","getPrevDates","getPrevDatesIterator","matchDate","date","Cron","z","WorkflowDefinition","Agent","CredentialRunContext","CronField","CronExpression","cronScheduleSchema","ZodString","core","$ZodBranded","CronSchedule","infer","CronScheduleInput","parseCronSchedule","value","resolveCronSchedule","Record","attachmentId","schedule","cronScheduleOverride","attachmentScheduleOverrides","options","parseTriggerSchedule","nextTriggerRunAt","Date","from","WorkflowAttachOptions","TInput","TOutput","workflow","transform","payload","AgentAttachOptions","agent","prompt","AttachOptions","TriggerMetaInput","name","description","TriggerAuthoringSlugInput","slug","key","TriggerSourceAuthoringInput","resolveAuthoringSlug","input","label","attachmentSlugFrom","sourceSlug","targetSlug","sourceSlugFrom","source","attachmentSlugFromRecord","attachment","triggerSourceSlugFromAttachmentSlug","attachmentSlug","triggerTargetSlugFromAttachmentSlug","CronSource","TriggerSourceBase","TriggerAttachment","kind","attach","defineCronSource","PollSource","TResult","Promise","Array","id","run","filters","passes","PollSourceChain","filter","fn","definePollSource","TRIGGER_ATTACHMENT","TriggerSource","WebhookSource","WorkflowTriggerAttachment","target","AgentTriggerAttachment","isTriggerAttachment","isWorkflowTriggerAttachment","isAgentTriggerAttachment","normalizeWebhookEndpoint","endpoint","ZodType","request","defineWebhookSource","TRequestSchema","TFilterSchema","WebhookAttachmentSchema","requestSchema","filterSchema","WebhookPayloadMatch","data","matchWebhookPayload","raw","schemas","EphemeralWebhookMatch","matchToJsonSchema","match","interpolatePrompt","template","resolveAgentPrompt","resolveAttachmentTransform","resolveAttachmentInput","RunContext","trigger","triggeredAt","credentials","WebhookSkipResponse","ok","skipped","PollSkipResponse","triggerMetaFromSource","triggerMetaFromAttachment","triggerMetaRecordFromAttachment","workflowSlugFromDefinition","agentSlugFromAgent","attachmentKeyFrom","workflowKeyFromDefinition","agentKeyFromAgent"],"sources":["../../../node_modules/.pnpm/cron-schedule@6.0.0/node_modules/cron-schedule/dist/cron.d.ts","../../trigger/dist/index.d.mts"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;UAIiBA,eAAAA;EAAAA,SACJE,OAAAA,EAASD,GAAAA;EAAAA,SACTE,OAAAA,EAASF,GAAAA;EAAAA,SACTG,KAAAA,EAAOH,GAAAA;EAAAA,SACPI,IAAAA,EAAMJ,GAAAA;EAAAA,SACNK,MAAAA,EAAQL,GAAAA;EAAAA,SACRM,QAAAA,EAAUN,GAAAA;AAAAA;AAAAA,cAEFO,IAAAA;EAAAA,SACRN,OAAAA,EAASO,aAAAA;EAAAA,SACTN,OAAAA,EAASM,aAAAA;EAAAA,SACTL,KAAAA,EAAOK,aAAAA;EAAAA,SACPJ,IAAAA,EAAMI,aAAAA;EAAAA,SACNH,MAAAA,EAAQG,aAAAA;EAAAA,SACRF,QAAAA,EAAUE,aAAAA;EAAAA,SACVG,QAAAA;IACLV,OAAAA,EAASO,aAAAA;IACTN,OAAAA,EAASM,aAAAA;IACTL,KAAAA,EAAOK,aAAAA;IACPJ,IAAAA,EAAMI,aAAAA;IACNH,MAAAA,EAAQG,aAAAA;IACRF,QAAAA,EAAUE,aAAAA;EAAAA;EAEdI,WAAAA,CAAAA;IAAcX,OAAAA;IAASC,OAAAA;IAASC,KAAAA;IAAOC,IAAAA;IAAMC,MAAAA;IAAQC;EAAAA,GAAaP,eAAAA;EAjBzDO;;;AAAa;EAAbA,QAsBDO,eAAAA;EApBa;;;;EAAA,QAyBbC,iBAAAA;EArBON;;;;EAAAA,QA0BPO,iBAAAA;EApBGP;;;;EAAAA,QAyBHQ,eAAAA;EApBed;;;;EAAAA,QAyBfe,qBAAAA;EAzB0DlB;EA2BlEmB,WAAAA,CAAYC,SAAAA,G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