@oxygen-agent/cli 1.1014.1997 → 1.1014.2040

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 (119) hide show
  1. package/README.md +1 -1
  2. package/dist/command-families/tables/options.d.ts +1 -0
  3. package/dist/command-families/tables/register-automation.js +3 -1
  4. package/dist/commands/observability.js +4 -4
  5. package/dist/commands/table-runs.js +10 -0
  6. package/dist/commands/tags.js +2 -2
  7. package/dist/commands/workflows.js +31 -10
  8. package/dist/http-client.d.ts +1 -1
  9. package/dist/http-client.js +1 -1
  10. package/node_modules/@oxygen/formula/dist/cross-row-function.d.ts +13 -0
  11. package/node_modules/@oxygen/formula/dist/cross-row-function.js +1 -0
  12. package/node_modules/@oxygen/formula/dist/{refactor-internals → cross-row-functions}/novelty-score.d.ts +2 -0
  13. package/node_modules/@oxygen/formula/dist/{refactor-internals → cross-row-functions}/novelty-score.js +1 -0
  14. package/node_modules/@oxygen/formula/dist/cross-row-functions.generated.d.ts +3 -0
  15. package/node_modules/@oxygen/formula/dist/cross-row-functions.generated.js +3 -0
  16. package/node_modules/@oxygen/formula/dist/evaluate.d.ts +12 -1
  17. package/node_modules/@oxygen/formula/dist/evaluate.js +28 -3
  18. package/node_modules/@oxygen/recipe-sdk/dist/index.d.ts +2 -0
  19. package/node_modules/@oxygen/shared/dist/capability-discovery.js +1 -1
  20. package/node_modules/@oxygen/shared/dist/cell-format.js +2 -2
  21. package/node_modules/@oxygen/shared/dist/collab.d.ts +1 -1
  22. package/node_modules/@oxygen/shared/dist/contracts/geo.js +1 -1
  23. package/node_modules/@oxygen/shared/dist/dnc-identities.js +1 -1
  24. package/node_modules/@oxygen/shared/dist/error-redaction.d.ts +1 -1
  25. package/node_modules/@oxygen/shared/dist/error-redaction.js +2 -2
  26. package/node_modules/@oxygen/shared/dist/esp-contract.d.ts +133 -0
  27. package/node_modules/@oxygen/shared/dist/esp-contract.js +121 -0
  28. package/node_modules/@oxygen/shared/dist/{geo.js → geo/geo.js} +2 -2
  29. package/node_modules/@oxygen/shared/dist/index.d.ts +6 -5
  30. package/node_modules/@oxygen/shared/dist/index.js +7 -5
  31. package/node_modules/@oxygen/shared/dist/knowledge-bootstrap.js +1 -1
  32. package/node_modules/@oxygen/shared/dist/linkedin-connection-identity.js +1 -1
  33. package/node_modules/@oxygen/shared/dist/{sending-domain-rollout.js → mailboxes/sending-domain-rollout.js} +1 -1
  34. package/node_modules/@oxygen/shared/dist/mcp-event-contract.js +1 -1
  35. package/node_modules/@oxygen/shared/dist/{social-post-metrics-core.d.ts → posts/metrics-core.d.ts} +1 -1
  36. package/node_modules/@oxygen/shared/dist/{social-post-metrics-linkedin.d.ts → posts/metrics-linkedin.d.ts} +1 -1
  37. package/node_modules/@oxygen/shared/dist/{social-post-metrics-linkedin.js → posts/metrics-linkedin.js} +2 -2
  38. package/node_modules/@oxygen/shared/dist/{social-post-metrics-series.d.ts → posts/metrics-series.d.ts} +1 -1
  39. package/node_modules/@oxygen/shared/dist/{social-post-metrics-series.js → posts/metrics-series.js} +1 -1
  40. package/node_modules/@oxygen/shared/dist/{social-post-metrics-x.d.ts → posts/metrics-x.d.ts} +1 -1
  41. package/node_modules/@oxygen/shared/dist/{social-post-metrics-x.js → posts/metrics-x.js} +2 -2
  42. package/node_modules/@oxygen/shared/dist/{social-post-metrics.d.ts → posts/metrics.d.ts} +3 -3
  43. package/node_modules/@oxygen/shared/dist/{social-post-metrics.js → posts/metrics.js} +3 -3
  44. package/node_modules/@oxygen/shared/dist/recipient-provider.d.ts +2 -10
  45. package/node_modules/@oxygen/shared/dist/recipient-provider.js +1 -9
  46. package/node_modules/@oxygen/shared/dist/sequence-internals/esp-policy.d.ts +2 -118
  47. package/node_modules/@oxygen/shared/dist/sequence-internals/esp-policy.js +2 -107
  48. package/node_modules/@oxygen/shared/dist/sequences.d.ts +0 -1
  49. package/node_modules/@oxygen/shared/dist/sequences.js +0 -2
  50. package/node_modules/@oxygen/shared/dist/{native-chat-discovery.d.ts → support/native-chat-discovery.d.ts} +1 -1
  51. package/node_modules/@oxygen/shared/dist/{native-chat-discovery.js → support/native-chat-discovery.js} +1 -1
  52. package/node_modules/@oxygen/shared/dist/suppression-entries.js +1 -1
  53. package/node_modules/@oxygen/shared/dist/table-field-types.d.ts +1 -1
  54. package/node_modules/@oxygen/shared/dist/table-field-types.js +2 -2
  55. package/node_modules/@oxygen/shared/dist/{column-output-fields.js → tables/column-output-fields.js} +4 -4
  56. package/node_modules/@oxygen/shared/dist/{tags.d.ts → tags/tags.d.ts} +1 -1
  57. package/node_modules/@oxygen/shared/dist/{tags.js → tags/tags.js} +1 -1
  58. package/node_modules/@oxygen/shared/dist/ugc-amplification-identity.js +1 -1
  59. package/node_modules/@oxygen/shared/dist/version.generated.d.ts +1 -1
  60. package/node_modules/@oxygen/shared/dist/version.generated.js +1 -1
  61. package/node_modules/@oxygen/shared/dist/workspace-placement-bulk.d.ts +6 -0
  62. package/node_modules/@oxygen/shared/dist/workspace-placement-bulk.js +9 -2
  63. package/node_modules/@oxygen/shared/dist/workspace-placement-schedule.d.ts +44 -0
  64. package/node_modules/@oxygen/shared/dist/workspace-placement-schedule.js +90 -0
  65. package/node_modules/@oxygen/shared/dist/workspace-placement-view.d.ts +24 -0
  66. package/node_modules/@oxygen/shared/dist/workspace-placement-view.js +5 -4
  67. package/node_modules/@oxygen/shared/dist/workspace-placement.d.ts +4 -0
  68. package/node_modules/@oxygen/shared/dist/workspace-placement.js +7 -1
  69. package/node_modules/@oxygen/shared/package.json +0 -25
  70. package/node_modules/@oxygen/workflows/dist/cron.d.ts +42 -0
  71. package/node_modules/@oxygen/workflows/dist/cron.js +271 -0
  72. package/node_modules/@oxygen/workflows/dist/event-dispatch.d.ts +2 -1
  73. package/node_modules/@oxygen/workflows/dist/graph/condition.d.ts +3 -0
  74. package/node_modules/@oxygen/workflows/dist/graph/condition.js +19 -0
  75. package/node_modules/@oxygen/workflows/dist/graph/expression.d.ts +1 -2
  76. package/node_modules/@oxygen/workflows/dist/graph/expression.js +2 -19
  77. package/node_modules/@oxygen/workflows/dist/graph/types.d.ts +4 -3
  78. package/node_modules/@oxygen/workflows/dist/index.d.ts +8 -985
  79. package/node_modules/@oxygen/workflows/dist/index.js +8 -1221
  80. package/node_modules/@oxygen/workflows/dist/manifest-builders.d.ts +73 -0
  81. package/node_modules/@oxygen/workflows/dist/manifest-builders.js +102 -0
  82. package/node_modules/@oxygen/workflows/dist/manifest-guards.d.ts +16 -0
  83. package/node_modules/@oxygen/workflows/dist/manifest-guards.js +34 -0
  84. package/node_modules/@oxygen/workflows/dist/manifest-hash.d.ts +47 -0
  85. package/node_modules/@oxygen/workflows/dist/manifest-hash.js +102 -0
  86. package/node_modules/@oxygen/workflows/dist/manifest-lint.d.ts +17 -0
  87. package/node_modules/@oxygen/workflows/dist/manifest-lint.js +474 -0
  88. package/node_modules/@oxygen/workflows/dist/manifest-types.d.ts +256 -0
  89. package/node_modules/@oxygen/workflows/dist/manifest-types.js +9 -0
  90. package/node_modules/@oxygen/workflows/dist/pure-function.d.ts +17 -0
  91. package/node_modules/@oxygen/workflows/dist/pure-function.js +130 -0
  92. package/node_modules/@oxygen/workflows/dist/refactor-internals/condition-comparison.d.ts +1 -17
  93. package/node_modules/@oxygen/workflows/dist/refactor-internals/condition-comparison.js +1 -93
  94. package/node_modules/@oxygen/workflows/dist/refactor-internals/condition-pattern.d.ts +16 -0
  95. package/node_modules/@oxygen/workflows/dist/refactor-internals/condition-pattern.js +92 -0
  96. package/node_modules/@oxygen/workflows/dist/workflow-schemas.d.ts +545 -0
  97. package/node_modules/@oxygen/workflows/dist/workflow-schemas.js +135 -0
  98. package/node_modules/@oxygen/workflows/package.json +4 -0
  99. package/package.json +1 -1
  100. /package/node_modules/@oxygen/shared/dist/{geo.d.ts → geo/geo.d.ts} +0 -0
  101. /package/node_modules/@oxygen/shared/dist/{sending-domain-rollout.d.ts → mailboxes/sending-domain-rollout.d.ts} +0 -0
  102. /package/node_modules/@oxygen/shared/dist/{attempt-provenance.d.ts → observability/attempt-provenance.d.ts} +0 -0
  103. /package/node_modules/@oxygen/shared/dist/{attempt-provenance.js → observability/attempt-provenance.js} +0 -0
  104. /package/node_modules/@oxygen/shared/dist/{linkedin-mentions.d.ts → posts/linkedin-mentions.d.ts} +0 -0
  105. /package/node_modules/@oxygen/shared/dist/{linkedin-mentions.js → posts/linkedin-mentions.js} +0 -0
  106. /package/node_modules/@oxygen/shared/dist/{linkedin-post-keywords.d.ts → posts/linkedin-post-keywords.d.ts} +0 -0
  107. /package/node_modules/@oxygen/shared/dist/{linkedin-post-keywords.js → posts/linkedin-post-keywords.js} +0 -0
  108. /package/node_modules/@oxygen/shared/dist/{linkedin-post-url.d.ts → posts/linkedin-post-url.d.ts} +0 -0
  109. /package/node_modules/@oxygen/shared/dist/{linkedin-post-url.js → posts/linkedin-post-url.js} +0 -0
  110. /package/node_modules/@oxygen/shared/dist/{social-post-metrics-core.js → posts/metrics-core.js} +0 -0
  111. /package/node_modules/@oxygen/shared/dist/{native-chat.d.ts → support/native-chat.d.ts} +0 -0
  112. /package/node_modules/@oxygen/shared/dist/{native-chat.js → support/native-chat.js} +0 -0
  113. /package/node_modules/@oxygen/shared/dist/{plain-support-events.d.ts → support/plain-support-events.d.ts} +0 -0
  114. /package/node_modules/@oxygen/shared/dist/{plain-support-events.js → support/plain-support-events.js} +0 -0
  115. /package/node_modules/@oxygen/shared/dist/{column-output-fields.d.ts → tables/column-output-fields.d.ts} +0 -0
  116. /package/node_modules/@oxygen/shared/dist/{linkedin-url.d.ts → tables/linkedin-url.d.ts} +0 -0
  117. /package/node_modules/@oxygen/shared/dist/{linkedin-url.js → tables/linkedin-url.js} +0 -0
  118. /package/node_modules/@oxygen/shared/dist/{select-options.d.ts → tables/select-options.d.ts} +0 -0
  119. /package/node_modules/@oxygen/shared/dist/{select-options.js → tables/select-options.js} +0 -0
@@ -0,0 +1,271 @@
1
+ import { parseCronSchedule } from "./manifest-validation.js";
2
+ import { DEFAULT_WORKFLOW_CRON_TIMEZONE } from "./manifest-types.js";
3
+ /**
4
+ * Cron schedule arithmetic for workflow triggers: next run, minimum-interval runs and the smallest gap.
5
+ */
6
+ // Lookahead window for the next cron run. Must exceed the largest gap a *valid*
7
+ // schedule can have, or legitimate sparse crons get falsely rejected: the worst
8
+ // case is "Feb 29" across a century boundary (e.g. 2096 → 2104, an ~8-year gap,
9
+ // since 2100 is not a leap year). The day-skipping scan below keeps even this
10
+ // wide window cheap (~one zonedDateParts call per non-matching day).
11
+ const MAX_CRON_LOOKAHEAD_DAYS = 366 * 8 + 2;
12
+ export function nextCronRunAfter(input) {
13
+ const schedule = parseCronSchedule(input.cron);
14
+ const timezone = input.timezone?.trim() || DEFAULT_WORKFLOW_CRON_TIMEZONE;
15
+ let candidate = roundUpToNextMinute(input.after ?? new Date());
16
+ const deadline = candidate.getTime() + MAX_CRON_LOOKAHEAD_DAYS * 24 * 60 * 60 * 1000;
17
+ while (candidate.getTime() <= deadline) {
18
+ const parts = zonedDateParts(candidate, timezone);
19
+ if (matchesCronSchedule(schedule, parts)) {
20
+ return candidate;
21
+ }
22
+ // If the calendar date itself can't match, no minute that day matches —
23
+ // jump to the next day instead of scanning all 1440 minutes. This keeps
24
+ // sparse schedules (e.g. "0 9 29 2 *") and unsatisfiable ones fast over the
25
+ // multi-year window. The jump targets ~00:00 of the next day, so a
26
+ // subsequently matching date is scanned from its start (no missed minutes).
27
+ if (!matchesCronDate(schedule, parts)) {
28
+ const minutesToNextDay = Math.max(1, 24 * 60 - (parts.hour * 60 + parts.minute));
29
+ let next = new Date(candidate.getTime() + minutesToNextDay * 60_000);
30
+ // minutesToNextDay is a LOCAL-clock count added to a UTC instant. On a
31
+ // spring-forward day the local day is < 24h, so the jump overshoots the
32
+ // next local midnight and lands at ~01:00 — skipping an early-of-day match
33
+ // (e.g. "0 0 …"), which can push the next run a full year out. If the jump
34
+ // crossed into the next local day but past midnight, pull it back to that
35
+ // midnight. (A fall-back day is > 24h: the jump undershoots and stays on
36
+ // the same date, which the next iteration advances — left as-is.)
37
+ const landed = zonedDateParts(next, timezone);
38
+ const intoNextLocalDay = landed.hour * 60 + landed.minute;
39
+ if (landed.dayOfMonth !== parts.dayOfMonth && intoNextLocalDay > 0) {
40
+ next = new Date(next.getTime() - intoNextLocalDay * 60_000);
41
+ }
42
+ candidate = next;
43
+ }
44
+ else {
45
+ candidate = new Date(candidate.getTime() + 60_000);
46
+ }
47
+ }
48
+ throw new Error(`Cron expression has no matching run time in the next ${MAX_CRON_LOOKAHEAD_DAYS} days.`);
49
+ }
50
+ /**
51
+ * The first slot of `cron` strictly after `after` that is also at least
52
+ * `minIntervalMinutes` after `lastFireAt`. This is how a plan's minimum cron
53
+ * interval (repricing 2026-09, decision L4.2) is enforced at fire time: a
54
+ * schedule that fires closer together than the plan allows keeps running, only
55
+ * slower, and is never deleted (proposal P-47). With no last fire or a minimum
56
+ * of one minute or less it is exactly `nextCronRunAfter`.
57
+ */
58
+ export function nextCronRunAfterMinInterval(input) {
59
+ const minIntervalMs = Math.max(0, input.minIntervalMinutes ?? 0) * 60_000;
60
+ let after = input.after;
61
+ if (input.lastFireAt && minIntervalMs > 60_000) {
62
+ // One millisecond before the earliest allowed instant: nextCronRunAfter
63
+ // returns the first whole-minute slot strictly after it, so a slot exactly
64
+ // `minIntervalMinutes` after the last fire is allowed.
65
+ const earliestAllowed = input.lastFireAt.getTime() + minIntervalMs - 1;
66
+ if (earliestAllowed > after.getTime())
67
+ after = new Date(earliestAllowed);
68
+ }
69
+ return nextCronRunAfter({ cron: input.cron, timezone: input.timezone ?? null, after });
70
+ }
71
+ // How many calendar days minCronGapMinutes scans for two matching days in a
72
+ // row: two leap cycles, so a Feb 29 or a day-of-month/weekday coincidence is
73
+ // always seen.
74
+ const CRON_GAP_DAY_SCAN = 366 * 8 + 2;
75
+ // Real-time simulation around a daylight-saving change covers the day it falls
76
+ // in plus this many whole days either side (so the fire before a long gap that
77
+ // straddles the change is inside the window), and stops after this many fires.
78
+ const CRON_GAP_DST_WINDOW_DAYS = 1;
79
+ const CRON_GAP_DST_MAX_FIRES = 5_000;
80
+ /**
81
+ * The smallest gap in minutes between two consecutive fires of `cron`, which is
82
+ * what a plan's minimum cron interval is checked against (repricing 2026-09,
83
+ * decision L4.2). It is the smallest gap, never the average: `0,5 9 * * *`
84
+ * fires once a day on average but twice five minutes apart, so its gap is 5.
85
+ *
86
+ * Gaps are measured in real time in `timezone`. A daylight-saving change can
87
+ * bring two fires closer than their wall-clock times suggest (01:55 and 03:05
88
+ * are ten minutes apart on the night the clock skips from 02:00 to 03:00, and
89
+ * a repeated hour can fire 01:45 and then 01:00 again), so the fires around
90
+ * each change in the coming year are simulated as well.
91
+ *
92
+ * Returns null when the schedule never fires twice within the scan (for
93
+ * example `0 9 29 2 *` fires once every few years and has no meaningful gap
94
+ * for a minimum to bind). Throws on an unparseable expression, like
95
+ * `nextCronRunAfter`.
96
+ */
97
+ export function minCronGapMinutes(input) {
98
+ const schedule = parseCronSchedule(input.cron);
99
+ const timezone = input.timezone?.trim() || DEFAULT_WORKFLOW_CRON_TIMEZONE;
100
+ const fireMinutes = [...schedule.hours]
101
+ .flatMap((hour) => [...schedule.minutes].map((minute) => hour * 60 + minute))
102
+ .sort((a, b) => a - b);
103
+ let gap = Number.POSITIVE_INFINITY;
104
+ for (let index = 1; index < fireMinutes.length; index += 1) {
105
+ gap = Math.min(gap, (fireMinutes[index] ?? 0) - (fireMinutes[index - 1] ?? 0));
106
+ }
107
+ const dayGap = smallestMatchingDayGap(schedule);
108
+ const firstFire = fireMinutes[0];
109
+ const lastFire = fireMinutes[fireMinutes.length - 1];
110
+ if (dayGap !== null && firstFire !== undefined && lastFire !== undefined) {
111
+ gap = Math.min(gap, dayGap * 24 * 60 + firstFire - lastFire);
112
+ }
113
+ // A one-minute gap is the floor of the cron grammar; daylight saving cannot
114
+ // bring two fires closer than that.
115
+ if (gap > 1) {
116
+ const dstGap = smallestGapAroundDaylightSavingChanges(input.cron, timezone, input.now ?? new Date());
117
+ if (dstGap !== null)
118
+ gap = Math.min(gap, dstGap);
119
+ }
120
+ return Number.isFinite(gap) ? gap : null;
121
+ }
122
+ /** Fewest days between two calendar days the schedule's date fields both match. */
123
+ function smallestMatchingDayGap(schedule) {
124
+ // Calendar arithmetic only (no timezone): day-of-month, month and weekday
125
+ // matching is the same on every clock. A fixed leap-year start covers every
126
+ // weekday/day-of-month combination within the scan.
127
+ const start = Date.UTC(2024, 0, 1);
128
+ let previousMatch = null;
129
+ let smallest = null;
130
+ for (let day = 0; day < CRON_GAP_DAY_SCAN; day += 1) {
131
+ const date = new Date(start + day * 24 * 60 * 60 * 1000);
132
+ const matches = matchesCronDate(schedule, {
133
+ minute: 0,
134
+ hour: 0,
135
+ dayOfMonth: date.getUTCDate(),
136
+ month: date.getUTCMonth() + 1,
137
+ dayOfWeek: date.getUTCDay(),
138
+ });
139
+ if (!matches)
140
+ continue;
141
+ if (previousMatch !== null) {
142
+ const gap = day - previousMatch;
143
+ smallest = smallest === null ? gap : Math.min(smallest, gap);
144
+ if (smallest === 1)
145
+ return 1;
146
+ }
147
+ previousMatch = day;
148
+ }
149
+ return smallest;
150
+ }
151
+ /**
152
+ * The smallest real-time gap between fires in the days around each
153
+ * daylight-saving change in the year after `now`; null when the zone has no
154
+ * change in that year or no two fires fall in any window.
155
+ */
156
+ function smallestGapAroundDaylightSavingChanges(cron, timezone, now) {
157
+ const dayMs = 24 * 60 * 60 * 1000;
158
+ const start = Math.floor(now.getTime() / dayMs) * dayMs;
159
+ let smallest = null;
160
+ let previousOffset = zonedOffsetMinutes(new Date(start), timezone);
161
+ for (let day = 1; day <= 367; day += 1) {
162
+ const offset = zonedOffsetMinutes(new Date(start + day * dayMs), timezone);
163
+ if (offset === previousOffset)
164
+ continue;
165
+ previousOffset = offset;
166
+ const windowStart = new Date(start + (day - 1 - CRON_GAP_DST_WINDOW_DAYS) * dayMs);
167
+ const windowEnd = start + (day + CRON_GAP_DST_WINDOW_DAYS) * dayMs;
168
+ let fire = nextCronRunAfter({ cron, timezone, after: windowStart });
169
+ for (let fires = 0; fires < CRON_GAP_DST_MAX_FIRES && fire.getTime() <= windowEnd; fires += 1) {
170
+ const next = nextCronRunAfter({ cron, timezone, after: fire });
171
+ if (next.getTime() > windowEnd)
172
+ break;
173
+ const gap = Math.round((next.getTime() - fire.getTime()) / 60_000);
174
+ smallest = smallest === null ? gap : Math.min(smallest, gap);
175
+ fire = next;
176
+ }
177
+ }
178
+ return smallest;
179
+ }
180
+ /** Minutes the zone's wall clock is ahead of UTC at `date`. */
181
+ function zonedOffsetMinutes(date, timezone) {
182
+ const formatter = getZonedFormatter(timezone);
183
+ const parts = new Map();
184
+ for (const part of formatter.formatToParts(date)) {
185
+ if (part.type !== "literal")
186
+ parts.set(part.type, part.value);
187
+ }
188
+ const wallClock = Date.UTC(Number(parts.get("year")), Number(parts.get("month")) - 1, Number(parts.get("day")), Number(parts.get("hour")), Number(parts.get("minute")));
189
+ const instant = Math.floor(date.getTime() / 60_000) * 60_000;
190
+ return Math.round((wallClock - instant) / 60_000);
191
+ }
192
+ const zonedFormatters = new Map();
193
+ // Date-only match (month + day-of-month/day-of-week), excluding hour/minute.
194
+ // Lets nextCronRunAfter skip whole non-matching days in one jump.
195
+ function matchesCronDate(schedule, parts) {
196
+ if (!schedule.months.has(parts.month))
197
+ return false;
198
+ const dayOfMonthMatches = schedule.daysOfMonth.has(parts.dayOfMonth);
199
+ const dayOfWeekMatches = schedule.daysOfWeek.has(parts.dayOfWeek);
200
+ if (schedule.dayOfMonthRestricted && schedule.dayOfWeekRestricted) {
201
+ return dayOfMonthMatches || dayOfWeekMatches;
202
+ }
203
+ return dayOfMonthMatches && dayOfWeekMatches;
204
+ }
205
+ function matchesCronSchedule(schedule, parts) {
206
+ if (!schedule.minutes.has(parts.minute))
207
+ return false;
208
+ if (!schedule.hours.has(parts.hour))
209
+ return false;
210
+ return matchesCronDate(schedule, parts);
211
+ }
212
+ function roundUpToNextMinute(value) {
213
+ const result = new Date(value.getTime());
214
+ result.setUTCSeconds(0, 0);
215
+ if (result.getTime() <= value.getTime()) {
216
+ result.setUTCMinutes(result.getUTCMinutes() + 1);
217
+ }
218
+ return result;
219
+ }
220
+ function zonedDateParts(date, timezone) {
221
+ const formatter = getZonedFormatter(timezone);
222
+ const parts = new Map();
223
+ for (const part of formatter.formatToParts(date)) {
224
+ if (part.type !== "literal")
225
+ parts.set(part.type, part.value);
226
+ }
227
+ return {
228
+ minute: Number(parts.get("minute")),
229
+ hour: Number(parts.get("hour")),
230
+ dayOfMonth: Number(parts.get("day")),
231
+ month: Number(parts.get("month")),
232
+ dayOfWeek: weekdayToNumber(parts.get("weekday") ?? ""),
233
+ };
234
+ }
235
+ function getZonedFormatter(timezone) {
236
+ const cached = zonedFormatters.get(timezone);
237
+ if (cached)
238
+ return cached;
239
+ const formatter = new Intl.DateTimeFormat("en-US", {
240
+ timeZone: timezone,
241
+ weekday: "short",
242
+ year: "numeric",
243
+ month: "numeric",
244
+ day: "numeric",
245
+ hour: "numeric",
246
+ minute: "numeric",
247
+ hourCycle: "h23",
248
+ });
249
+ zonedFormatters.set(timezone, formatter);
250
+ return formatter;
251
+ }
252
+ function weekdayToNumber(value) {
253
+ switch (value.toLowerCase()) {
254
+ case "sun":
255
+ return 0;
256
+ case "mon":
257
+ return 1;
258
+ case "tue":
259
+ return 2;
260
+ case "wed":
261
+ return 3;
262
+ case "thu":
263
+ return 4;
264
+ case "fri":
265
+ return 5;
266
+ case "sat":
267
+ return 6;
268
+ default:
269
+ throw new Error(`Unsupported weekday '${value}'.`);
270
+ }
271
+ }
@@ -1,4 +1,5 @@
1
- import type { JsonSchema, JsonSchemaValidationIssue, WorkflowEventFilter } from "./index.js";
1
+ import type { JsonSchema, JsonSchemaValidationIssue } from "./manifest-validation.js";
2
+ import type { WorkflowEventFilter } from "./manifest-types.js";
2
3
  /**
3
4
  * Read a dot-delimited path out of an event payload.
4
5
  *
@@ -0,0 +1,3 @@
1
+ import { type WorkflowRunScope } from "./expression.js";
2
+ import type { WorkflowCondition } from "./types.js";
3
+ export declare function evaluateCondition(condition: WorkflowCondition, scope: WorkflowRunScope): boolean;
@@ -0,0 +1,19 @@
1
+ // Run-time condition evaluation for oxygen-workflows-v2, published as
2
+ // `@oxygen/workflows/condition` and deliberately NOT on the graph barrel: the
3
+ // worker scheduler is its only runtime caller, so an operator change reaches
4
+ // the scheduler instead of every importer of `@oxygen/workflows`. Browser-safe.
5
+ import { compareWorkflowConditionValues } from "../refactor-internals/condition-comparison.js";
6
+ import { resolveValueRef } from "./expression.js";
7
+ export function evaluateCondition(condition, scope) {
8
+ if (condition.type === "group") {
9
+ // An empty group is vacuous: `all` holds, `any` does not — the same identity
10
+ // Array.every / Array.some give, so no special case is needed at run time.
11
+ const result = condition.op === "all"
12
+ ? condition.children.every((child) => evaluateCondition(child, scope))
13
+ : condition.children.some((child) => evaluateCondition(child, scope));
14
+ return condition.not === true ? !result : result;
15
+ }
16
+ const left = resolveValueRef(condition.left, scope);
17
+ const right = condition.right === undefined ? undefined : resolveValueRef(condition.right, scope);
18
+ return compareWorkflowConditionValues(left, condition.op, right);
19
+ }
@@ -1,4 +1,4 @@
1
- export { compileConditionPattern } from "../refactor-internals/condition-comparison.js";
1
+ export { compileConditionPattern } from "../refactor-internals/condition-pattern.js";
2
2
  import type { WorkflowCompareOp, WorkflowCondition, WorkflowValueCoercion, WorkflowValueRef } from "./types.js";
3
3
  /**
4
4
  * The data a v2 run exposes to its value refs.
@@ -77,7 +77,6 @@ export declare function resolveValueRef(ref: WorkflowValueRef, scope: WorkflowRu
77
77
  * boundary so the failure names the mapped path before any provider executes.
78
78
  */
79
79
  export declare function resolveRequiredValueRef(ref: WorkflowValueRef, scope: WorkflowRunScope): unknown;
80
- export declare function evaluateCondition(condition: WorkflowCondition, scope: WorkflowRunScope): boolean;
81
80
  /**
82
81
  * Node ids a ref or condition reads, in first-seen order.
83
82
  *
@@ -3,7 +3,7 @@
3
3
  // scheduler, the linter, and the visual editor's preview pane.
4
4
  //
5
5
  // This module must stay BROWSER-SAFE. Its only imports are @oxygen/formula (itself
6
- // host-free and node-free), condition comparison, and ./types.js — never ../index.js, which pulls
6
+ // host-free and node-free), condition pattern compilation, and ./types.js — never ../index.js, which pulls
7
7
  // node:vm and node:crypto.
8
8
  //
9
9
  // Two invariants hold everywhere below:
@@ -14,8 +14,7 @@
14
14
  // only, and the segments that reach JavaScript object internals
15
15
  // (__proto__ / constructor / prototype) are rejected outright.
16
16
  import { analyzeFormulaDependencies, evaluateFormulaInScope, formulaExpressionError, isRecord, } from "@oxygen/formula";
17
- import { compareWorkflowConditionValues } from "../refactor-internals/condition-comparison.js";
18
- export { compileConditionPattern } from "../refactor-internals/condition-comparison.js";
17
+ export { compileConditionPattern } from "../refactor-internals/condition-pattern.js";
19
18
  /** A deterministic authoring/data error; retrying the same revision cannot repair it. */
20
19
  export class WorkflowValueCoercionError extends Error {
21
20
  coercion;
@@ -645,22 +644,6 @@ function isCoalescibleWorkflowFormulaPath(scope, identifier) {
645
644
  return false;
646
645
  }
647
646
  // ---------------------------------------------------------------------------
648
- // Conditions
649
- // ---------------------------------------------------------------------------
650
- export function evaluateCondition(condition, scope) {
651
- if (condition.type === "group") {
652
- // An empty group is vacuous: `all` holds, `any` does not — the same identity
653
- // Array.every / Array.some give, so no special case is needed at run time.
654
- const result = condition.op === "all"
655
- ? condition.children.every((child) => evaluateCondition(child, scope))
656
- : condition.children.some((child) => evaluateCondition(child, scope));
657
- return condition.not === true ? !result : result;
658
- }
659
- const left = resolveValueRef(condition.left, scope);
660
- const right = condition.right === undefined ? undefined : resolveValueRef(condition.right, scope);
661
- return compareWorkflowConditionValues(left, condition.op, right);
662
- }
663
- // ---------------------------------------------------------------------------
664
647
  // Static analysis
665
648
  // ---------------------------------------------------------------------------
666
649
  /**
@@ -1,6 +1,6 @@
1
- import type { WorkflowCompareOp } from "../refactor-internals/condition-comparison.js";
2
- export type { WorkflowCompareOp } from "../refactor-internals/condition-comparison.js";
3
- import type { JsonSchema, RecipeManifest, WorkflowMode, WorkflowStatus, WorkflowStepEffect, WorkflowTriggerManifest } from "../index.js";
1
+ import type { JsonSchema, WorkflowStatus, WorkflowStepEffect } from "../manifest-validation.js";
2
+ import type { RecipeManifest, WorkflowMode, WorkflowTriggerManifest } from "../manifest-types.js";
3
+ export type WorkflowCompareOp = "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "contains" | "not_contains" | "starts_with" | "ends_with" | "is_empty" | "is_not_empty" | "in" | "not_in" | "matches";
4
4
  export declare const WORKFLOW_GRAPH_MANIFEST_VERSION = 2;
5
5
  export declare const WORKFLOW_GRAPH_COMPILER_VERSION = "oxygen-workflows-v2";
6
6
  export declare const PORTABLE_WORKFLOW_DEFINITION_VERSION = 1;
@@ -490,3 +490,4 @@ export declare function isTriggerNode(node: WorkflowGraphNode): node is Workflow
490
490
  export declare function isToolNode(node: WorkflowGraphNode): node is WorkflowGraphNodeOfKind<"tool">;
491
491
  export declare function isSwitchNode(node: WorkflowGraphNode): node is WorkflowGraphNodeOfKind<"switch">;
492
492
  export declare function isLoopNode(node: WorkflowGraphNode): node is WorkflowGraphNodeOfKind<"loop">;
493
+ export {};