@xiangyixie/dsh-superagent 0.18.4 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -1
- package/lib/client.js +782 -314
- package/lib/console.js +108 -17
- package/lib/goal.js +1 -1
- package/lib/index.js +398 -47
- package/lib/long-goal.js +39 -15
- package/lib/orchestrator.js +25 -15
- package/lib/schedule.js +92 -1
- package/package.json +1 -1
package/lib/long-goal.js
CHANGED
|
@@ -294,8 +294,7 @@ function validatePhaseGraph(phases) {
|
|
|
294
294
|
|
|
295
295
|
function goalPrompt(goal, phase, index, total, dependencySummaries) {
|
|
296
296
|
return [
|
|
297
|
-
`Long-term goal: ${goal.goal}`,
|
|
298
|
-
'',
|
|
297
|
+
...(goal.consoleOwned ? [] : [`Long-term goal: ${goal.goal}`, '']),
|
|
299
298
|
`This run is phase ${index + 1} of ${total}: ${phase.title}`,
|
|
300
299
|
'',
|
|
301
300
|
'Phase objective:',
|
|
@@ -308,9 +307,8 @@ function goalPrompt(goal, phase, index, total, dependencySummaries) {
|
|
|
308
307
|
'',
|
|
309
308
|
]
|
|
310
309
|
: []),
|
|
311
|
-
'Work only on this phase
|
|
312
|
-
'
|
|
313
|
-
'that does not meet them is retried with the exact failure instead of repeating the same work.',
|
|
310
|
+
'Work only on this phase and provide its finished deliverables in the format requested in the objective.',
|
|
311
|
+
'The phase acceptance conditions are checked after every round. If a round falls short, use the exact failure evidence to address it.',
|
|
314
312
|
].join('\n')
|
|
315
313
|
}
|
|
316
314
|
|
|
@@ -333,6 +331,7 @@ function decomposePrompt(goal, maxPhases) {
|
|
|
333
331
|
'Rules:',
|
|
334
332
|
'- Use 2 to ' + maxPhases + ' phases, ordered; ids are p1, p2, ...',
|
|
335
333
|
'- "dependsOn" only when the later phase needs an earlier phase\'s artifact. Independent phases may run at once.',
|
|
334
|
+
'- Write self-contained phase objectives. Carry the user’s relevant inputs, paths, output format and shared constraints into each affected objective. Leave other phases’ deliverables out.',
|
|
336
335
|
'- Every phase needs at least one acceptance condition. Prefer a machine check (file exists, command exits 0);',
|
|
337
336
|
' a condition without a check is judged by an independent acceptance model from the phase report.',
|
|
338
337
|
'- Never create a dependency cycle. Never reference a phase id that is not in the list.',
|
|
@@ -652,7 +651,7 @@ export function createLongGoalManager({
|
|
|
652
651
|
muted: true,
|
|
653
652
|
goalMode: null,
|
|
654
653
|
overrides: { deadlineMinutes: 15, maxSubtasks: 2, maxParallel: 1 },
|
|
655
|
-
origin: { kind: 'long-goal', goalId: goal.id, role: 'decompose', attempt },
|
|
654
|
+
origin: { kind: 'long-goal', goalId: goal.id, role: 'decompose', attempt, dispatchId: `${goal.id}/plan/${attempt}` },
|
|
656
655
|
})
|
|
657
656
|
goal.decomposeRunId = run.id
|
|
658
657
|
event(goal, 'decompose.started', `attempt ${attempt}: run ${run.id}`)
|
|
@@ -965,7 +964,10 @@ export function createLongGoalManager({
|
|
|
965
964
|
...(budget.maxModelCalls ? { maxModelCalls: budget.maxModelCalls } : {}),
|
|
966
965
|
...(budget.maxTokens ? { maxTokens: budget.maxTokens } : {}),
|
|
967
966
|
},
|
|
968
|
-
origin: {
|
|
967
|
+
origin: {
|
|
968
|
+
kind: 'long-goal', goalId: goal.id, phaseId: phase.id, attempt: phase.attempts + 1,
|
|
969
|
+
dispatchId: `${goal.id}/phase/${phase.id}/${(phase.runIds?.length ?? 0) + 1}`,
|
|
970
|
+
},
|
|
969
971
|
})
|
|
970
972
|
phase.attempts += 1
|
|
971
973
|
phase.runIds = Array.isArray(phase.runIds) ? phase.runIds : []
|
|
@@ -1122,7 +1124,15 @@ export function createLongGoalManager({
|
|
|
1122
1124
|
if (!release) return
|
|
1123
1125
|
try {
|
|
1124
1126
|
const goal = await store.read(goalId)
|
|
1125
|
-
if (!goal
|
|
1127
|
+
if (!goal) return
|
|
1128
|
+
if (goal.status === 'paused' && goal.pausedReason === 'owner-unavailable') {
|
|
1129
|
+
if (!await owner(goal)) return
|
|
1130
|
+
goal.status = goal.phases.length ? 'running' : 'planning'
|
|
1131
|
+
goal.pausedReason = null
|
|
1132
|
+
event(goal, 'goal.resumed', 'the owning session is available again')
|
|
1133
|
+
await store.write(goal)
|
|
1134
|
+
}
|
|
1135
|
+
if (!GOAL_TICKABLE.has(goal.status)) return
|
|
1126
1136
|
await refreshUsage(goal)
|
|
1127
1137
|
|
|
1128
1138
|
if (goal.status === 'needs-decision') {
|
|
@@ -1292,7 +1302,7 @@ export function createLongGoalManager({
|
|
|
1292
1302
|
}
|
|
1293
1303
|
}
|
|
1294
1304
|
const after = await store.list()
|
|
1295
|
-
if (after.some(
|
|
1305
|
+
if (after.some(autoResumeFor)) arm()
|
|
1296
1306
|
return processed
|
|
1297
1307
|
})()
|
|
1298
1308
|
try {
|
|
@@ -1312,7 +1322,7 @@ export function createLongGoalManager({
|
|
|
1312
1322
|
if (!goal?.autoResume) return false
|
|
1313
1323
|
if (GOAL_ACTIVE.has(goal.status)) return true
|
|
1314
1324
|
if (watching(goal)) return true
|
|
1315
|
-
return goal.status === 'paused' && goal.pausedReason
|
|
1325
|
+
return goal.status === 'paused' && goal.pausedReason === 'owner-unavailable'
|
|
1316
1326
|
}
|
|
1317
1327
|
|
|
1318
1328
|
/** Load goals and mark work left active by a dead host as resumable, not failed. */
|
|
@@ -1443,6 +1453,7 @@ export function createLongGoalManager({
|
|
|
1443
1453
|
startedAt: phases.length > 0 ? new Date(now()).toISOString() : null,
|
|
1444
1454
|
finishedAt: null,
|
|
1445
1455
|
ownerSessionId: String(input.parentSessionId ?? input.ownerSessionId ?? '').trim() || null,
|
|
1456
|
+
...(input.consoleOwned === true ? { consoleOwned: true } : {}),
|
|
1446
1457
|
cwd,
|
|
1447
1458
|
autoResume: input.autoResume !== false,
|
|
1448
1459
|
...limits,
|
|
@@ -1481,6 +1492,19 @@ export function createLongGoalManager({
|
|
|
1481
1492
|
return goal
|
|
1482
1493
|
}
|
|
1483
1494
|
|
|
1495
|
+
async function changeGoal(goalId, change) {
|
|
1496
|
+
if (!GOAL_ID_PATTERN.test(String(goalId ?? ''))) throw new Error(`unknown long goal ${goalId}`)
|
|
1497
|
+
const release = await acquireFileLock(store.file(goalId).replace(/\.json$/, '.lock'), {
|
|
1498
|
+
staleMs: 60000, now, retries: 20,
|
|
1499
|
+
})
|
|
1500
|
+
if (!release) throw new Error(`goal ${goalId} is being updated; try again shortly`)
|
|
1501
|
+
try {
|
|
1502
|
+
return await change()
|
|
1503
|
+
} finally {
|
|
1504
|
+
await release()
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
|
|
1484
1508
|
async function status(goalId) {
|
|
1485
1509
|
const goal = await get(goalId)
|
|
1486
1510
|
const runs = {}
|
|
@@ -1752,11 +1776,11 @@ export function createLongGoalManager({
|
|
|
1752
1776
|
status,
|
|
1753
1777
|
list,
|
|
1754
1778
|
tick,
|
|
1755
|
-
answer,
|
|
1756
|
-
resume,
|
|
1757
|
-
pause,
|
|
1758
|
-
cancel,
|
|
1759
|
-
retryPhase,
|
|
1779
|
+
answer: (id, ...args) => changeGoal(id, () => answer(id, ...args)),
|
|
1780
|
+
resume: id => changeGoal(id, () => resume(id)),
|
|
1781
|
+
pause: id => changeGoal(id, () => pause(id)),
|
|
1782
|
+
cancel: id => changeGoal(id, () => cancel(id)),
|
|
1783
|
+
retryPhase: (id, phaseId) => changeGoal(id, () => retryPhase(id, phaseId)),
|
|
1760
1784
|
store,
|
|
1761
1785
|
formatStatus,
|
|
1762
1786
|
}
|
package/lib/orchestrator.js
CHANGED
|
@@ -1183,7 +1183,7 @@ function aggregatorPrompt(run, completed, context, carried = [], wantUserMemory
|
|
|
1183
1183
|
function deterministicJoin(run) {
|
|
1184
1184
|
const completed = (run.subtasks ?? []).filter(subtask => subtask.status === 'completed')
|
|
1185
1185
|
if (completed.length === 0) return null
|
|
1186
|
-
const parts = [`# ${run.goal}`, '', `_Deterministic merge of ${completed.length} subtask report(s)._`, '']
|
|
1186
|
+
const parts = run.goalMode ? [] : [`# ${run.goal}`, '', `_Deterministic merge of ${completed.length} subtask report(s)._`, '']
|
|
1187
1187
|
for (const subtask of completed) {
|
|
1188
1188
|
parts.push(`## ${subtask.title}`, '', subtask.result ?? '', '')
|
|
1189
1189
|
}
|
|
@@ -2515,7 +2515,7 @@ export function createOrchestrator(deps) {
|
|
|
2515
2515
|
}
|
|
2516
2516
|
}
|
|
2517
2517
|
let degraded = null
|
|
2518
|
-
if (unsupported && entry.targets.every(target => target.status === 'failed')) {
|
|
2518
|
+
if (options.fallbackToFollowup !== false && unsupported && entry.targets.every(target => target.status === 'failed')) {
|
|
2519
2519
|
// No live channel at all. Do not pretend the instruction was delivered:
|
|
2520
2520
|
// queue it exactly where superagent_followup would, and label the
|
|
2521
2521
|
// receipt as degraded so status cannot read as a live delivery.
|
|
@@ -2708,6 +2708,7 @@ export function createOrchestrator(deps) {
|
|
|
2708
2708
|
for (const subtask of run.subtasks ?? []) {
|
|
2709
2709
|
if (subtask.status === 'running') subtask.status = 'pending'
|
|
2710
2710
|
}
|
|
2711
|
+
markPendingInjectionsMissed(run, 'the host stopped before the worker read the instruction')
|
|
2711
2712
|
// The owner died before it could settle, so publish what is already known
|
|
2712
2713
|
// about the spend: a reclaimed run must not claim its cost is unknown when
|
|
2713
2714
|
// its child logs were readable.
|
|
@@ -2730,6 +2731,19 @@ export function createOrchestrator(deps) {
|
|
|
2730
2731
|
}
|
|
2731
2732
|
}
|
|
2732
2733
|
|
|
2734
|
+
function markPendingInjectionsMissed(run, reason) {
|
|
2735
|
+
let changed = false
|
|
2736
|
+
for (const injection of run.injections ?? []) {
|
|
2737
|
+
for (const target of injection.targets ?? []) {
|
|
2738
|
+
if (target.status !== 'pending') continue
|
|
2739
|
+
stopWatch(run.id, injection.id, target.childId)
|
|
2740
|
+
finishInjectionTarget(run, target, 'missed', { reason })
|
|
2741
|
+
changed = true
|
|
2742
|
+
}
|
|
2743
|
+
}
|
|
2744
|
+
if (changed) refreshInjectionStats(run)
|
|
2745
|
+
}
|
|
2746
|
+
|
|
2733
2747
|
/**
|
|
2734
2748
|
* Claim the exclusive right to schedule a run.
|
|
2735
2749
|
*
|
|
@@ -3813,7 +3827,10 @@ export function createOrchestrator(deps) {
|
|
|
3813
3827
|
// since added an instruction or answered a question: the shortcut would
|
|
3814
3828
|
// return the old text and silently drop the decision.
|
|
3815
3829
|
const hasInstructions = (run.followups ?? []).length > 0
|
|
3816
|
-
if (completed.length === 1 && !hasInstructions)
|
|
3830
|
+
if (completed.length === 1 && !hasInstructions) {
|
|
3831
|
+
const result = completed[0].result ?? ''
|
|
3832
|
+
return run.goalMode ? result.trim() : `# ${run.goal}\n\n${result}`.trim()
|
|
3833
|
+
}
|
|
3817
3834
|
|
|
3818
3835
|
try {
|
|
3819
3836
|
// Instructions that arrived while the workers ran land here, and this is
|
|
@@ -3935,18 +3952,7 @@ export function createOrchestrator(deps) {
|
|
|
3935
3952
|
|
|
3936
3953
|
// A live injection has no boundary of its own: once the run is over, an
|
|
3937
3954
|
// untouched receipt is a miss, and the queue that carried it is gone.
|
|
3938
|
-
|
|
3939
|
-
for (const injection of run.injections ?? []) {
|
|
3940
|
-
for (const target of injection.targets ?? []) {
|
|
3941
|
-
if (target.status !== 'pending') continue
|
|
3942
|
-
stopWatch(run.id, injection.id, target.childId)
|
|
3943
|
-
finishInjectionTarget(run, target, 'missed', {
|
|
3944
|
-
reason: 'the run settled before the child reached another step boundary',
|
|
3945
|
-
})
|
|
3946
|
-
injectionsChanged = true
|
|
3947
|
-
}
|
|
3948
|
-
}
|
|
3949
|
-
if (injectionsChanged) refreshInjectionStats(run)
|
|
3955
|
+
markPendingInjectionsMissed(run, 'the run settled before the child reached another step boundary')
|
|
3950
3956
|
|
|
3951
3957
|
// The aggregator appends a fenced notebook block to its report. Strip it in
|
|
3952
3958
|
// every case so the user never sees plugin syntax, then persist it when the
|
|
@@ -4951,6 +4957,10 @@ export function createOrchestrator(deps) {
|
|
|
4951
4957
|
// The goal claim is held across "list, check, write" so two processes
|
|
4952
4958
|
// sharing a state directory cannot both conclude that nothing is running.
|
|
4953
4959
|
return serialize(() => withGoalGuard(dedupeKey, async () => {
|
|
4960
|
+
if (origin?.kind === 'long-goal' && origin.dispatchId) {
|
|
4961
|
+
const existing = (await store.list()).find(run => run.origin?.dispatchId === origin.dispatchId)
|
|
4962
|
+
if (existing) return existing
|
|
4963
|
+
}
|
|
4954
4964
|
const active = await activeCount()
|
|
4955
4965
|
// The same goal twice is much more often a retry than a second piece of
|
|
4956
4966
|
// work: the caller lost the run id, or a model re-issued the call. Return
|
package/lib/schedule.js
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
import { randomUUID } from 'node:crypto'
|
|
22
22
|
import fsp from 'node:fs/promises'
|
|
23
23
|
import path from 'node:path'
|
|
24
|
-
import { nextCronTime, parseCron, validateTimeZone } from './cron.js'
|
|
24
|
+
import { nextCronTime, parseCron, validateTimeZone, zonedParts } from './cron.js'
|
|
25
25
|
import { normalizeGoalSpec } from './goal.js'
|
|
26
26
|
import { ACTIVE_STATUSES, TERMINAL_STATUSES } from './store.js'
|
|
27
27
|
|
|
@@ -146,6 +146,7 @@ export function normalizeScheduleInput(input = {}, { now }) {
|
|
|
146
146
|
ownerRecovery,
|
|
147
147
|
requiresLiveSession: ownerRecovery === 'none',
|
|
148
148
|
cwd: input.cwd ? path.resolve(String(input.cwd)) : null,
|
|
149
|
+
fallbackReason: input.fallbackReason ? String(input.fallbackReason) : null,
|
|
149
150
|
createdAt,
|
|
150
151
|
updatedAt: createdAt,
|
|
151
152
|
nextRunAt: null,
|
|
@@ -983,6 +984,9 @@ export function formatScheduleList(plans) {
|
|
|
983
984
|
lines.push(
|
|
984
985
|
`- ${plan.id} ${plan.name} — ${state}`,
|
|
985
986
|
` when: ${when}; miss policy ${plan.schedule.missPolicy}; next ${plan.nextRunAt ?? 'not computed'}`,
|
|
987
|
+
` engine: plugin-local timer (fallback: ${plan.fallbackReason ?? 'plan predates host-schedule handoff'}) — `
|
|
988
|
+
+ "runs only while this host process is alive and is not listed in the host's scheduled tasks; "
|
|
989
|
+
+ 'migrate with action="migrate"',
|
|
986
990
|
` last: ${plan.lastStatus ?? 'never'}; failures in a row ${plan.consecutiveFailures}; `
|
|
987
991
|
+ `runs ${plan.totalRuns} (${plan.catchUpRuns ?? 0} catch-up); missed ${plan.missedRuns}; `
|
|
988
992
|
+ `skipped ${plan.skippedRuns ?? 0}`,
|
|
@@ -1011,6 +1015,7 @@ export function formatSchedule(plan) {
|
|
|
1011
1015
|
`schedule ${plan.id} — ${plan.name}`,
|
|
1012
1016
|
`goal: ${oneLine(plan.goal, 300)}${plan.goal.length > 300 ? '…' : ''}`,
|
|
1013
1017
|
`when: ${when}; miss policy ${plan.schedule.missPolicy}`,
|
|
1018
|
+
`engine: plugin-local timer (fallback: ${plan.fallbackReason ?? 'plan predates host-schedule handoff'})`,
|
|
1014
1019
|
`next: ${plan.nextRunAt ?? 'not computed'}; last: ${plan.lastStatus ?? 'never'}`,
|
|
1015
1020
|
`owner: session ${plan.ownerSessionId}; mode ${plan.mode}${plan.goalMode ? '; goal mode on' : ''}`
|
|
1016
1021
|
+ `${plan.ownerRecovery ? `; restart recovery ${plan.ownerRecovery}` : ''}`
|
|
@@ -1029,3 +1034,89 @@ export function formatSchedule(plan) {
|
|
|
1029
1034
|
}
|
|
1030
1035
|
return lines.join('\n')
|
|
1031
1036
|
}
|
|
1037
|
+
|
|
1038
|
+
/**
|
|
1039
|
+
* Map a 5-field cron expression to the RRULE subset the Host Schedule tool
|
|
1040
|
+
* accepts, or null when the conversion would not be lossless.
|
|
1041
|
+
*
|
|
1042
|
+
* The host tool refuses BY parts on MINUTELY and HOURLY and keeps day-of-month
|
|
1043
|
+
* and month work behind MONTHLY/YEARLY, so only the plain shapes below are
|
|
1044
|
+
* converted. Everything else stays on the plugin-local timer on purpose.
|
|
1045
|
+
*
|
|
1046
|
+
* @param {string} expression - normalized 5-field cron.
|
|
1047
|
+
* @returns {string | null} RRULE body, or null when there is no exact mapping.
|
|
1048
|
+
*/
|
|
1049
|
+
export function rruleFromCron(expression) {
|
|
1050
|
+
const fields = String(expression ?? '').trim().split(/\s+/)
|
|
1051
|
+
if (fields.length !== 5) return null
|
|
1052
|
+
const [minute, hour, dom, month, dow] = fields
|
|
1053
|
+
if (dom !== '*' || month !== '*') return null
|
|
1054
|
+
if (minute === '*' && hour === '*' && dow === '*') return 'FREQ=MINUTELY;INTERVAL=1'
|
|
1055
|
+
const step = /^\*\/(\d{1,2})$/.exec(minute)
|
|
1056
|
+
if (step && hour === '*' && dow === '*') {
|
|
1057
|
+
const every = Number(step[1])
|
|
1058
|
+
return every >= 1 && every <= 59 ? `FREQ=MINUTELY;INTERVAL=${every}` : null
|
|
1059
|
+
}
|
|
1060
|
+
const minuteValue = /^\d{1,2}$/.test(minute) ? Number(minute) : null
|
|
1061
|
+
if (minuteValue === null || minuteValue > 59) return null
|
|
1062
|
+
if (dow === '*') {
|
|
1063
|
+
const hourValue = /^\d{1,2}$/.test(hour) ? Number(hour) : null
|
|
1064
|
+
if (hourValue === null || hourValue > 23) return null
|
|
1065
|
+
return `FREQ=DAILY;BYHOUR=${hourValue};BYMINUTE=${minuteValue}`
|
|
1066
|
+
}
|
|
1067
|
+
const hourValue = /^\d{1,2}$/.test(hour) ? Number(hour) : null
|
|
1068
|
+
if (hourValue === null || hourValue > 23) return null
|
|
1069
|
+
const byDay = weekdaysToByDay(dow)
|
|
1070
|
+
if (!byDay) return null
|
|
1071
|
+
return `FREQ=WEEKLY;BYDAY=${byDay};BYHOUR=${hourValue};BYMINUTE=${minuteValue}`
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
const WEEKDAY_NAMES = { SUN: 0, MON: 1, TUE: 2, WED: 3, THU: 4, FRI: 5, SAT: 6 }
|
|
1075
|
+
const WEEKDAY_CODES = ['SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA']
|
|
1076
|
+
|
|
1077
|
+
function weekdayNumber(token) {
|
|
1078
|
+
const text = String(token).trim().toUpperCase()
|
|
1079
|
+
if (Object.hasOwn(WEEKDAY_NAMES, text)) return WEEKDAY_NAMES[text]
|
|
1080
|
+
if (!/^\d$/.test(text)) return null
|
|
1081
|
+
return Number(text) === 7 ? 0 : Number(text)
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
function weekdaysToByDay(field) {
|
|
1085
|
+
const days = []
|
|
1086
|
+
for (const token of String(field).split(',')) {
|
|
1087
|
+
const range = token.split('-')
|
|
1088
|
+
if (range.length === 2) {
|
|
1089
|
+
const from = weekdayNumber(range[0])
|
|
1090
|
+
const to = weekdayNumber(range[1])
|
|
1091
|
+
if (from === null || to === null || from > to) return null
|
|
1092
|
+
for (let day = from; day <= to; day++) days.push(WEEKDAY_CODES[day])
|
|
1093
|
+
continue
|
|
1094
|
+
}
|
|
1095
|
+
if (range.length !== 1) return null
|
|
1096
|
+
const one = weekdayNumber(token)
|
|
1097
|
+
if (one === null) return null
|
|
1098
|
+
days.push(WEEKDAY_CODES[one])
|
|
1099
|
+
}
|
|
1100
|
+
const unique = [...new Set(days)]
|
|
1101
|
+
return unique.length > 0 ? unique.join(',') : null
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
/** RRULE body for a fixed interval plan. */
|
|
1105
|
+
export function rruleForInterval(everyMinutes) {
|
|
1106
|
+
return `FREQ=MINUTELY;INTERVAL=${Number(everyMinutes)}`
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
/**
|
|
1110
|
+
* Prefix an RRULE body with the DTSTART line the Host Schedule tool requires.
|
|
1111
|
+
*
|
|
1112
|
+
* @param {string} rule - RRULE body such as `FREQ=DAILY;BYHOUR=9;BYMINUTE=0`.
|
|
1113
|
+
* @param {string} timeZone - IANA zone the rule is written in.
|
|
1114
|
+
* @param {number} [nowMs] - current epoch milliseconds.
|
|
1115
|
+
* @returns {string} two-line rrule document.
|
|
1116
|
+
*/
|
|
1117
|
+
export function rruleWithStart(rule, timeZone, nowMs = Date.now()) {
|
|
1118
|
+
const at = zonedParts(nowMs, timeZone)
|
|
1119
|
+
const pad = value => String(value).padStart(2, '0')
|
|
1120
|
+
const stamp = `${at.year}${pad(at.month)}${pad(at.day)}T${pad(at.hour)}${pad(at.minute)}${pad(at.second)}`
|
|
1121
|
+
return `DTSTART;TZID=${timeZone}:${stamp}\nRRULE:${rule}`
|
|
1122
|
+
}
|