@tidegap/core 0.21.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/channels/digest.d.ts +4 -1
  2. package/dist/channels/digest.js +7 -3
  3. package/dist/channels/format.d.ts +61 -19
  4. package/dist/channels/format.js +181 -51
  5. package/dist/channels/index.d.ts +1 -0
  6. package/dist/channels/index.js +1 -0
  7. package/dist/channels/kinds/discord.js +2 -2
  8. package/dist/channels/kinds/email.js +2 -1
  9. package/dist/channels/kinds/ntfy.js +9 -1
  10. package/dist/channels/kinds/pushover.js +4 -3
  11. package/dist/channels/kinds/shared.d.ts +4 -1
  12. package/dist/channels/kinds/shared.js +6 -1
  13. package/dist/channels/kinds/slack.js +2 -2
  14. package/dist/channels/notice.d.ts +42 -0
  15. package/dist/channels/notice.js +142 -0
  16. package/dist/channels/payload.d.ts +3 -0
  17. package/dist/channels/payload.js +19 -6
  18. package/dist/channels/plan.js +3 -2
  19. package/dist/channels/telegram.d.ts +18 -0
  20. package/dist/channels/telegram.js +23 -9
  21. package/dist/channels/types.d.ts +17 -1
  22. package/dist/grid.d.ts +10 -2
  23. package/dist/grid.js +14 -5
  24. package/dist/handoff.d.ts +66 -3
  25. package/dist/handoff.js +108 -3
  26. package/dist/history.d.ts +105 -0
  27. package/dist/history.js +108 -1
  28. package/dist/index.d.ts +15 -11
  29. package/dist/index.js +10 -6
  30. package/dist/job-cadence.d.ts +10 -0
  31. package/dist/job-cadence.js +34 -0
  32. package/dist/job-wake.d.ts +55 -0
  33. package/dist/job-wake.js +91 -0
  34. package/dist/jobs.d.ts +54 -2
  35. package/dist/jobs.js +258 -14
  36. package/dist/notice-language.d.ts +37 -0
  37. package/dist/notice-language.js +67 -0
  38. package/dist/providers/base.d.ts +14 -0
  39. package/dist/schedule-job.d.ts +18 -2
  40. package/dist/schedule-job.js +22 -2
  41. package/dist/scheduler.d.ts +2 -0
  42. package/dist/scheduler.js +5 -1
  43. package/dist/storage/sqlite.d.ts +24 -3
  44. package/dist/storage/sqlite.js +135 -28
  45. package/dist/task-events.d.ts +1 -1
  46. package/dist/task-events.js +9 -0
  47. package/dist/tool-surface.js +25 -1
  48. package/dist/types.d.ts +41 -1
  49. package/package.json +2 -2
package/dist/handoff.js CHANGED
@@ -14,6 +14,7 @@ import { homedir, tmpdir } from "node:os";
14
14
  import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
15
15
  import { isValidSessionId } from "./history.js";
16
16
  import { resolveTidegapHome } from "./paths.js";
17
+ import { SESSION_NOTICE_MAX_AGE_MS } from "./storage/sqlite.js";
17
18
  export const HANDOFF_PROFILES = ["read", "web", "none"];
18
19
  /** The tools of each profile. `read` is scoped to the run's folder by the adapter. */
19
20
  export const PROFILE_TOOLS = {
@@ -339,8 +340,12 @@ export function taskWorkShape(record) {
339
340
  const resultPath = str(spec?.handoff?.resultPath);
340
341
  if (resultPath)
341
342
  out.resultPath = resultPath;
342
- if (spec?.handoff?.wake === true)
343
+ // A run of a bound job is a wake task too; the job sweep decides whether it wakes (KTD10).
344
+ if (spec?.handoff?.wake === true || typeof spec?.jobWake?.session === "string")
343
345
  out.wake = true;
346
+ const rule = typeof spec?.jobWake?.session === "string" ? spec.jobWake.on : undefined;
347
+ if (rule === "failures" || rule === "match")
348
+ out.wakeRule = rule;
344
349
  const command = oneOff ? str(spec.command?.run) : undefined;
345
350
  if (command)
346
351
  out.command = command;
@@ -387,6 +392,20 @@ export function defaultDbPath() {
387
392
  return legacyPath;
388
393
  return newPath;
389
394
  }
395
+ /**
396
+ * The `wake:` line of a task's work shape, or undefined when it does not
397
+ * wake: a one-off wake task wakes when it finishes; a run of a bound job
398
+ * says the job's rule, since most of its runs do not wake.
399
+ */
400
+ export function wakeShapeText(shape) {
401
+ if (!shape.wake)
402
+ return undefined;
403
+ if (shape.wakeRule === "failures")
404
+ return "failures (wakes its idle session only if the run fails after its retries)";
405
+ if (shape.wakeRule === "match")
406
+ return "match (wakes its idle session only if the run's output matches the job's pattern)";
407
+ return "on (wakes its idle session when it finishes)";
408
+ }
390
409
  /**
391
410
  * True when `dbPath` is the default ledger. The session notice and wake
392
411
  * markers under `~/.tidegap/sessions` belong to it: the plugin's hooks
@@ -414,8 +433,6 @@ export function isDefaultLedger(dbPath) {
414
433
  };
415
434
  return real(dbPath) === real(defaultDbPath());
416
435
  }
417
- /** A wake marker with no wake task left to wait for goes this long after its last refresh (the waiter refreshes it at every Stop). */
418
- export const WAKE_MARKER_MAX_AGE_MS = 12 * 3_600_000;
419
436
  /** `~/.tidegap/sessions/wake`: one marker per session with a task to wake it for. */
420
437
  export function wakeMarkersDir(home = resolveTidegapHome()) {
421
438
  return join(home, "sessions", "wake");
@@ -479,4 +496,92 @@ export function removeWakeMarker(sessionId, dir = wakeMarkersDir()) {
479
496
  // already gone
480
497
  }
481
498
  }
499
+ /** Statuses of a task that may still finish. */
500
+ const OPEN = ["queued", "scheduled", "running", "submitted"];
501
+ /** True for a task queued with wake, and for a run of a job bound to a session. */
502
+ export function isWakeTask(record) {
503
+ return taskWorkShape(record).wake === true;
504
+ }
505
+ /**
506
+ * True when a session notice wakes its session: a run of a bound job when
507
+ * the job sweep's decision says so, any other completed or failed wake
508
+ * task. A cancel is someone's own act: it never spends a turn.
509
+ */
510
+ export function noticeWakes(n) {
511
+ return n.jobNotice ? n.jobNotice.wake : isWakeTask(n.record) && n.record.status !== "cancelled";
512
+ }
513
+ /**
514
+ * The wake tasks still to come of one session, or of every session when
515
+ * `sessionId` is undefined: not finished yet, or completed and waiting for
516
+ * its result file (its notice comes once the file is). A row that completed
517
+ * more than {@link SESSION_NOTICE_MAX_AGE_MS} ago no longer counts: it can
518
+ * never be a notice.
519
+ */
520
+ export function wakeTasksToCome(store, sessionId, now) {
521
+ const oldest = now.getTime() - SESSION_NOTICE_MAX_AGE_MS;
522
+ return [
523
+ ...store.list({ ...(sessionId === undefined ? {} : { originSessionId: sessionId }), status: OPEN }),
524
+ ...store
525
+ .listResultFilesDue()
526
+ .filter((r) => (sessionId === undefined || r.originSessionId === sessionId) && Date.parse(r.completedAt ?? "") >= oldest),
527
+ ].filter(isWakeTask);
528
+ }
529
+ /**
530
+ * True when a session has something left to wait for (KTD11): an open wake
531
+ * task, a wake task waiting for its result file, an unclaimed notice that
532
+ * wakes, or an active job bound to it. The bound job counts so a waiter
533
+ * does not stop between a run's finish and the sweep's decision. With
534
+ * `since`, only a task queued after it and a job bound after it count (a
535
+ * second look after a removal); a run of a bound job counts through its
536
+ * job's bind time only, since every run is a fresh row and would keep the
537
+ * 7-day rule from ever ending the marker. An unclaimed wake notice counts
538
+ * whatever its time. The reads go against the job sweep's write order
539
+ * (run, then notice, then job): the job first, so a run that finishes
540
+ * between two reads is seen by one of them. `notices` is the session's
541
+ * notice list when the caller has just read it. Throws when the ledger
542
+ * cannot be read.
543
+ */
544
+ export function sessionHasWaitWork(store, sessionId, now = new Date(), opts = {}) {
545
+ const { since } = opts;
546
+ const after = (at) => since === undefined || Date.parse(at ?? "") > since;
547
+ if (store.listJobs({ status: "active" }).some((j) => j.wake && j.originSessionId === sessionId && after(j.wake.boundAt)))
548
+ return true;
549
+ if ((opts.notices ?? store.listSessionNotices({ sessionId, now })).some(noticeWakes))
550
+ return true;
551
+ return wakeTasksToCome(store, sessionId, now).some((t) => since === undefined || (t.jobId === undefined && after(t.enqueuedAt)));
552
+ }
553
+ /**
554
+ * Remove a session's wake marker, then look once more
555
+ * ({@link sessionHasWaitWork}, from `since` when given), and write the
556
+ * marker again when the session has something left or the read fails. A
557
+ * writer commits its row (or job) before it writes the marker, so work
558
+ * added while the caller decided is either seen here or writes its marker
559
+ * after the removal. Returns "removed", "kept" or "unread" (the read
560
+ * failed). Never throws.
561
+ */
562
+ export function removeWakeMarkerUnlessPending(store, sessionId, dir = wakeMarkersDir(), now = new Date(), since) {
563
+ removeWakeMarker(sessionId, dir);
564
+ let left;
565
+ try {
566
+ left = sessionHasWaitWork(store, sessionId, now, { since }) ? "kept" : "removed";
567
+ }
568
+ catch {
569
+ left = "unread";
570
+ }
571
+ // An unread ledger keeps the marker's old time, so the sweep's 7-day rule still counts from it.
572
+ if (left !== "removed")
573
+ writeWakeMarker(sessionId, dir, left === "unread" && since !== undefined ? new Date(since) : now);
574
+ return left;
575
+ }
576
+ /**
577
+ * The agent's own act ended something a session waited for (a cancel, a
578
+ * job removed, paused or unbound): drop the session's marker now unless
579
+ * it has something left (KTD12). Only on the default ledger, whose markers
580
+ * these are; `sessionId` undefined does nothing. Never throws.
581
+ */
582
+ export function releaseWakeMarker(store, dbPath, sessionId) {
583
+ if (!store || !sessionId || !isValidSessionId(sessionId) || !dbPath || !isDefaultLedger(dbPath))
584
+ return;
585
+ removeWakeMarkerUnlessPending(store, sessionId);
586
+ }
482
587
  //# sourceMappingURL=handoff.js.map
package/dist/history.d.ts CHANGED
@@ -26,6 +26,10 @@ export declare function deriveTitle(text: string, redactPatterns?: string[]): st
26
26
  export declare function taskPrompt(record: TaskRecord<unknown>): string | undefined;
27
27
  /** The model's reply text of a completed provider-call task, when present. */
28
28
  export declare function taskResultText(record: TaskRecord<unknown>): string | undefined;
29
+ /** A command job's summary (the reply of its summarize step), when the run has one. */
30
+ export declare function taskSummaryText(record: TaskRecord<unknown>): string | undefined;
31
+ /** Why a command job's summarize step gave no summary, when it failed. */
32
+ export declare function taskSummaryError(record: TaskRecord<unknown>): string | undefined;
29
33
  /**
30
34
  * The task's full conversation, oldest first: prior turns stored in
31
35
  * `body_json.messages`, then the prompt as the user turn, then the result
@@ -112,4 +116,105 @@ export declare function shellQuote(word: string): string;
112
116
  * session id is valid.
113
117
  */
114
118
  export declare function resumeCommand(record: Pick<TaskRecord<unknown>, "originCwd" | "originSessionId">): string | undefined;
119
+ /** True when the task asked for receipt redaction (`redactInReceipt` with patterns): no result text and no attachment leaves the machine. */
120
+ export declare function isRedactedTask(record: TaskRecord<unknown>): boolean;
121
+ /**
122
+ * The file types a command run can attach: the stored extension, a label for
123
+ * people, whether Telegram takes it as a photo, and whether the page shows
124
+ * it inline (an SVG can hold script, so it is a download).
125
+ */
126
+ export declare const ATTACHMENT_TYPES: {
127
+ readonly "image/png": {
128
+ readonly ext: "png";
129
+ readonly label: "PNG image";
130
+ readonly photo: true;
131
+ readonly inline: true;
132
+ };
133
+ readonly "image/jpeg": {
134
+ readonly ext: "jpg";
135
+ readonly label: "JPEG image";
136
+ readonly photo: true;
137
+ readonly inline: true;
138
+ };
139
+ readonly "image/webp": {
140
+ readonly ext: "webp";
141
+ readonly label: "WebP image";
142
+ readonly photo: true;
143
+ readonly inline: true;
144
+ };
145
+ readonly "image/gif": {
146
+ readonly ext: "gif";
147
+ readonly label: "GIF image";
148
+ readonly photo: false;
149
+ readonly inline: true;
150
+ };
151
+ readonly "application/pdf": {
152
+ readonly ext: "pdf";
153
+ readonly label: "PDF";
154
+ readonly photo: false;
155
+ readonly inline: false;
156
+ };
157
+ readonly "text/csv": {
158
+ readonly ext: "csv";
159
+ readonly label: "CSV";
160
+ readonly photo: false;
161
+ readonly inline: false;
162
+ };
163
+ readonly "text/plain": {
164
+ readonly ext: "txt";
165
+ readonly label: "text";
166
+ readonly photo: false;
167
+ readonly inline: false;
168
+ };
169
+ readonly "application/json": {
170
+ readonly ext: "json";
171
+ readonly label: "JSON";
172
+ readonly photo: false;
173
+ readonly inline: false;
174
+ };
175
+ readonly "image/svg+xml": {
176
+ readonly ext: "svg";
177
+ readonly label: "SVG image";
178
+ readonly photo: false;
179
+ readonly inline: false;
180
+ };
181
+ };
182
+ export type AttachmentType = keyof typeof ATTACHMENT_TYPES;
183
+ /** One stored attachment of a run, as the result JSON holds it: `file` is `<n>.<ext>` in the task's attachment folder. */
184
+ export interface StoredAttachment {
185
+ name: string;
186
+ type: AttachmentType;
187
+ bytes: number;
188
+ file: string;
189
+ }
190
+ /** A file the command wrote that was not attached, and why. */
191
+ export interface SkippedAttachment {
192
+ name: string;
193
+ reason: string;
194
+ }
195
+ /** A stored attachment as a reader sees it: its 1-based index, and `expired` when its file is gone. */
196
+ export interface TaskAttachment extends StoredAttachment {
197
+ index: number;
198
+ expired?: boolean;
199
+ }
200
+ /** A file name for people: one line, no control, bidirectional or zero-width characters, whitespace runs joined, at most 80 characters; "" when nothing is left. */
201
+ export declare function attachmentDisplayName(name: string): string;
202
+ /**
203
+ * The stored attachments of a completed run, in order. An entry whose shape
204
+ * is wrong is left out; its `file` must be `<index>.<ext>` of its type, so
205
+ * a reader never builds a path from anything else. With `exists` (whether
206
+ * a `file` is still in the task's attachment folder), a file that is gone is
207
+ * marked `expired`.
208
+ */
209
+ export declare function taskAttachments(record: TaskRecord<unknown>, exists?: (file: string) => boolean): TaskAttachment[];
210
+ /** The files a completed run wrote that were not attached, with the reason. */
211
+ export declare function taskAttachmentsSkipped(record: TaskRecord<unknown>): SkippedAttachment[];
212
+ /**
213
+ * The attachments a channel may send: none for a task that redacts its
214
+ * receipt, else the stored ones whose file is still there (with `exists`).
215
+ * Every path that sends a file takes its list from here.
216
+ */
217
+ export declare function sendableAttachments(record: TaskRecord<unknown>, exists?: (file: string) => boolean): TaskAttachment[];
218
+ /** A size for people: `512 B`, `48 KB`, `14 MB`, `1.5 MB`. */
219
+ export declare function formatBytes(bytes: number): string;
115
220
  //# sourceMappingURL=history.d.ts.map
package/dist/history.js CHANGED
@@ -2,6 +2,7 @@
2
2
  * Task-visibility helpers (v0.17): title derivation, message history and
3
3
  * display text. Pure functions; no I/O.
4
4
  */
5
+ import { cutPreview, stripBidiControls } from "./channels/notice.js";
5
6
  import { redactPrompt } from "./redact.js";
6
7
  /** Maximum stored title length, in characters. */
7
8
  export const TITLE_MAX_CHARS = 80;
@@ -59,8 +60,20 @@ export function taskPrompt(record) {
59
60
  }
60
61
  /** The model's reply text of a completed provider-call task, when present. */
61
62
  export function taskResultText(record) {
63
+ return resultString(record, "text");
64
+ }
65
+ /** A command job's summary (the reply of its summarize step), when the run has one. */
66
+ export function taskSummaryText(record) {
67
+ return resultString(record, "summary");
68
+ }
69
+ /** Why a command job's summarize step gave no summary, when it failed. */
70
+ export function taskSummaryError(record) {
71
+ return resultString(record, "summaryError");
72
+ }
73
+ function resultString(record, key) {
62
74
  const r = record.result;
63
- return r && typeof r === "object" && typeof r.text === "string" ? r.text : undefined;
75
+ const v = r && typeof r === "object" ? r[key] : undefined;
76
+ return typeof v === "string" ? v : undefined;
64
77
  }
65
78
  /**
66
79
  * The task's full conversation, oldest first: prior turns stored in
@@ -203,4 +216,98 @@ export function resumeCommand(record) {
203
216
  const cwd = stripControlChars(record.originCwd);
204
217
  return `cd ${shellQuote(cwd)} && claude --resume ${record.originSessionId}`;
205
218
  }
219
+ /** True when the task asked for receipt redaction (`redactInReceipt` with patterns): no result text and no attachment leaves the machine. */
220
+ export function isRedactedTask(record) {
221
+ const spec = parseSpec(record.bodyJson);
222
+ return Array.isArray(spec?.redactInReceipt) && spec.redactInReceipt.length > 0;
223
+ }
224
+ /**
225
+ * The file types a command run can attach: the stored extension, a label for
226
+ * people, whether Telegram takes it as a photo, and whether the page shows
227
+ * it inline (an SVG can hold script, so it is a download).
228
+ */
229
+ export const ATTACHMENT_TYPES = {
230
+ "image/png": { ext: "png", label: "PNG image", photo: true, inline: true },
231
+ "image/jpeg": { ext: "jpg", label: "JPEG image", photo: true, inline: true },
232
+ "image/webp": { ext: "webp", label: "WebP image", photo: true, inline: true },
233
+ "image/gif": { ext: "gif", label: "GIF image", photo: false, inline: true },
234
+ "application/pdf": { ext: "pdf", label: "PDF", photo: false, inline: false },
235
+ "text/csv": { ext: "csv", label: "CSV", photo: false, inline: false },
236
+ "text/plain": { ext: "txt", label: "text", photo: false, inline: false },
237
+ "application/json": { ext: "json", label: "JSON", photo: false, inline: false },
238
+ "image/svg+xml": { ext: "svg", label: "SVG image", photo: false, inline: false },
239
+ };
240
+ /** Zero-width characters: a name that holds them can pass for another. */
241
+ const ZERO_WIDTH = /[\u200B-\u200D\u2060\uFEFF]/g;
242
+ /** A file name for people: one line, no control, bidirectional or zero-width characters, whitespace runs joined, at most 80 characters; "" when nothing is left. */
243
+ export function attachmentDisplayName(name) {
244
+ return cutPreview(stripBidiControls(stripControlChars(name)).replace(ZERO_WIDTH, "").replace(/\s+/g, " ").trim(), TITLE_MAX_CHARS);
245
+ }
246
+ function attachmentName(value) {
247
+ return typeof value === "string" ? attachmentDisplayName(value) || undefined : undefined;
248
+ }
249
+ function resultList(record, key) {
250
+ const r = record.result;
251
+ const v = r && typeof r === "object" ? r[key] : undefined;
252
+ return Array.isArray(v) ? v : [];
253
+ }
254
+ /**
255
+ * The stored attachments of a completed run, in order. An entry whose shape
256
+ * is wrong is left out; its `file` must be `<index>.<ext>` of its type, so
257
+ * a reader never builds a path from anything else. With `exists` (whether
258
+ * a `file` is still in the task's attachment folder), a file that is gone is
259
+ * marked `expired`.
260
+ */
261
+ export function taskAttachments(record, exists) {
262
+ if (record.status !== "completed")
263
+ return [];
264
+ const out = [];
265
+ resultList(record, "attachments").forEach((raw, i) => {
266
+ const a = raw;
267
+ const name = attachmentName(a?.name);
268
+ const type = a?.type;
269
+ if (!a || !name || typeof type !== "string" || !Object.hasOwn(ATTACHMENT_TYPES, type))
270
+ return;
271
+ const index = i + 1;
272
+ const file = `${index}.${ATTACHMENT_TYPES[type].ext}`;
273
+ if (a.file !== file || typeof a.bytes !== "number" || !Number.isSafeInteger(a.bytes) || a.bytes < 0)
274
+ return;
275
+ const expired = exists !== undefined && !exists(file);
276
+ out.push({ name, type: type, bytes: a.bytes, file, index, ...(expired ? { expired: true } : {}) });
277
+ });
278
+ return out;
279
+ }
280
+ /** The files a completed run wrote that were not attached, with the reason. */
281
+ export function taskAttachmentsSkipped(record) {
282
+ if (record.status !== "completed")
283
+ return [];
284
+ const out = [];
285
+ for (const raw of resultList(record, "attachmentsSkipped")) {
286
+ const s = raw;
287
+ const name = attachmentName(s?.name);
288
+ const reason = attachmentName(s?.reason);
289
+ if (name && reason)
290
+ out.push({ name, reason });
291
+ }
292
+ return out;
293
+ }
294
+ /**
295
+ * The attachments a channel may send: none for a task that redacts its
296
+ * receipt, else the stored ones whose file is still there (with `exists`).
297
+ * Every path that sends a file takes its list from here.
298
+ */
299
+ export function sendableAttachments(record, exists) {
300
+ if (isRedactedTask(record))
301
+ return [];
302
+ return taskAttachments(record, exists).filter((a) => !a.expired);
303
+ }
304
+ /** A size for people: `512 B`, `48 KB`, `14 MB`, `1.5 MB`. */
305
+ export function formatBytes(bytes) {
306
+ if (bytes < 1024)
307
+ return `${bytes} B`;
308
+ // Below 1 MB but rounding to 1024 KB reads as `1 MB`.
309
+ if (Math.round(bytes / 1024) < 1024)
310
+ return `${Math.round(bytes / 1024)} KB`;
311
+ return `${(Math.round((bytes / (1024 * 1024)) * 10) / 10).toString()} MB`;
312
+ }
206
313
  //# sourceMappingURL=history.js.map
package/dist/index.d.ts CHANGED
@@ -41,14 +41,14 @@
41
41
  export { CarbonBudgetExceededError, COMMAND_MAX_CHARS, defer, InvalidDeadlineError, LAST_TICK_META_KEY, pickBestWindow, Scheduler, TaskActionError, } from "./scheduler.js";
42
42
  export type { ReplyOptions, RescheduleTarget, SchedulerOptions, ActorOptions, RetryResult, TickAdapters, TickDetails, TickOptions, LockedTick, } from "./scheduler.js";
43
43
  export { recommendWindow } from "./recommend.js";
44
- export { TITLE_MAX_CHARS, deadlineKindLabel, deriveTitle, displayTitle, isRepeating, isValidSessionId, resumeCommand, SESSION_ID_PATTERN, shellQuote, taskActions, stripControlChars, capHistory, HISTORY_MAX_CHARS, taskHistory, taskPrompt, taskResultText, } from "./history.js";
45
- export type { TaskActions } from "./history.js";
44
+ export { TITLE_MAX_CHARS, deadlineKindLabel, deriveTitle, displayTitle, isRepeating, isValidSessionId, resumeCommand, SESSION_ID_PATTERN, shellQuote, taskActions, stripControlChars, capHistory, HISTORY_MAX_CHARS, taskHistory, taskPrompt, taskResultText, taskSummaryError, taskSummaryText, ATTACHMENT_TYPES, attachmentDisplayName, formatBytes, isRedactedTask, sendableAttachments, taskAttachments, taskAttachmentsSkipped, } from "./history.js";
45
+ export type { AttachmentType, SkippedAttachment, StoredAttachment, TaskAttachment, TaskActions } from "./history.js";
46
46
  export { assessReadiness, oldestTickRun, pendingProvidersFromStore, problemLine, readTickRunners, readTickSleep, sleepReadNeeded, runnersFromSnapshot, sleptBetween, snapshotIsFresh, TICKER_CODES, tickIntervalFor, TICK_RUNNERS_META_KEY, TICK_BY_META_KEY, TICK_SLEEP_META_KEY, writeTickRunners, writeTickSleep, } from "./readiness.js";
47
47
  export type { DaemonFact, OldestRun, Readiness, ReadinessCode, ReadinessFacts, ReadinessProblem, RunnerFact, SleepReading, TickRunnersSnapshot, } from "./readiness.js";
48
48
  export { LIMIT_RESET_HINT_META_KEY, NEEDS_RESET_TIME, POSTPONE_LABELS, POSTPONE_PRESETS, localTimeLabel, MORNING_START_H, plannedStart, postponeOptions, readLimitResetHint, resolveLimitReset, resolvePostpone, taskProvider, TONIGHT_START_H, writeLimitResetHint, } from "./postpone.js";
49
49
  export type { LimitReset, LimitResetSource, PostponeOption, PostponePreset, PostponeTarget, ResolvedPostpone, } from "./postpone.js";
50
- export { CALLBACK_ACTIONS, CALLBACK_PRESETS, cleanWindowMessage, commandContextFor, callbackFits, encodeCallback, CHANNEL_KINDS, channelQuiet, DELIVERY_CODES, descriptorData, EVENT_KINDS, keepsSecret, eventMessage, isChannelKind, isQuietTime, KIND_DESCRIPTORS, payloadFor, testPayload, TEST_MESSAGE_TEXT, validateFields, WEBHOOK_BODY_VERSION, webhookBody, PUSHOVER_MESSAGES_PATH, isLoopbackSmtpHost, HELP_TEXT, telegramCommands, isLoopbackApiBase, isRedactedTask, runPreview, LATER_GRAMMAR, laterMenuMessage, laterTarget, LISTING_TTL_MS, messageTitle, nextClockTime, notReadyMessage, osChannel, parseCallback, parseCommand, planNotifications, foldIntoDigest, buildDigest, digestAt, digestDue, parseDigestAt, DEFAULT_DIGEST_AT, DIGEST_AT_META_KEY, DIGEST_LAST_META_KEY, DIGEST_LIST_MAX, DIGEST_SENT_META_KEY, DIGEST_MAX_WINDOW_MS, QUEUE_LIST_MAX, QueueListing, queueMessage, RESULT_MAX_PARTS, resultMessages, runCallback, runCommand, splitMessage, taskDoneMessage, taskFailedMessage, eventTitle, jobDigestText, jobNextLabel, jobPausedMessage, jobPausedTitle, jobTitle, zoneTimeLabel, telegramChatId, TELEGRAM_API_BASE, TELEGRAM_CALL_TIMEOUT_MS, TELEGRAM_CALLBACK_MAX_BYTES, TELEGRAM_MESSAGE_MAX, TELEGRAM_PREVIEW_CHARS, TelegramClient, TelegramError, } from "./channels/index.js";
51
- export type { CallbackAction, CallbackActionName, CallbackOutcome, Channel, ChannelCommand, ChannelEvent, ChannelKind, CleanWindowEvent, DeliveryCode, DeliverySpec, DigestCovers, DigestEvent, DigestInput, JobDigestLine, JobPausedNotice, FieldErrorCode, FieldInput, FieldOption, FieldValidation, FieldValues, KindDescriptor, KindDescriptorData, KindErrorText, KindField, KindPreset, KindStep, NotificationLevel, NotificationPayload, PayloadEvent, QuietMode, RegistryKind, CommandContext, EventKind, InlineButton, InlineKeyboard, LaterArg, OutgoingMessage, SendJob, TaskRef, TelegramCallbackQuery, TelegramChannelConfig, TelegramChat, TelegramClientOptions, TelegramErrorKind, TelegramMessage, TelegramUpdate, TelegramUser, } from "./channels/index.js";
50
+ export { CALLBACK_ACTIONS, CALLBACK_PRESETS, cleanWindowMessage, commandContextFor, callbackFits, encodeCallback, CHANNEL_KINDS, channelQuiet, DELIVERY_CODES, descriptorData, EVENT_KINDS, keepsSecret, eventMessage, isChannelKind, isQuietTime, KIND_DESCRIPTORS, payloadFor, testPayload, TEST_MESSAGE_TEXT, validateFields, WEBHOOK_BODY_VERSION, webhookBody, PUSHOVER_MESSAGES_PATH, isLoopbackSmtpHost, HELP_TEXT, telegramCommands, isLoopbackApiBase, runPreview, runVerdict, NOTICE_EMOJI, noticeStatus, runSummary, structureSummary, LATER_GRAMMAR, laterMenuMessage, laterTarget, LISTING_TTL_MS, messageTitle, nextClockTime, notReadyMessage, osChannel, parseCallback, parseCommand, planNotifications, foldIntoDigest, buildDigest, digestAt, digestDue, parseDigestAt, DEFAULT_DIGEST_AT, DIGEST_AT_META_KEY, DIGEST_LAST_META_KEY, DIGEST_LIST_MAX, DIGEST_SENT_META_KEY, DIGEST_MAX_WINDOW_MS, QUEUE_LIST_MAX, QueueListing, queueMessage, RESULT_MAX_PARTS, resultMessages, attachmentLine, ATTACHMENT_LINE_CHARS, runCallback, runCommand, splitMessage, taskDoneMessage, taskFailedMessage, eventTitle, jobDigestText, jobNextLabel, jobEndedBody, jobEndedMessage, jobEndedTitle, jobPausedMessage, jobPausedTitle, jobTitle, zoneTimeLabel, telegramChatId, TELEGRAM_API_BASE, TELEGRAM_CALL_TIMEOUT_MS, TELEGRAM_UPLOAD_TIMEOUT_MS, TELEGRAM_CALLBACK_MAX_BYTES, TELEGRAM_MESSAGE_MAX, TELEGRAM_PREVIEW_CHARS, TelegramClient, TelegramError, } from "./channels/index.js";
51
+ export type { CallbackAction, CallbackActionName, CallbackOutcome, Channel, ChannelCommand, ChannelEvent, ChannelKind, CleanWindowEvent, DeliveryCode, DeliverySpec, DigestCovers, DigestEvent, DigestInput, JobDigestLine, NoticeStatus, StructuredSummary, JobEndedNotice, JobPausedNotice, FieldErrorCode, FieldInput, FieldOption, FieldValidation, FieldValues, KindDescriptor, KindDescriptorData, KindErrorText, KindField, KindPreset, KindStep, NotificationLevel, NotificationPayload, PayloadEvent, QuietMode, RegistryKind, CommandContext, EventKind, InlineButton, InlineKeyboard, LaterArg, OutgoingFiles, OutgoingMessage, TelegramFileMethod, TelegramUpload, SendJob, TaskRef, TelegramCallbackQuery, TelegramChannelConfig, TelegramChat, TelegramClientOptions, TelegramErrorKind, TelegramMessage, TelegramUpdate, TelegramUser, } from "./channels/index.js";
52
52
  export { scoreCandidates, previewRouting, parseCandidate, parseCandidates, candidateId, normalizeRouteWeights, priceForModel, DEFAULT_ROUTE_WEIGHTS, ROUTING_PREVIEW_DISCLOSURE, SCORE_TIE_EPSILON, InvalidCandidateError, InvalidRouteWeightsError, MissingPriceError, } from "./routing.js";
53
53
  export type { RouteWeights, RoutingCandidate, RoutingDecision, RoutingPreview, ScoredCandidate, LatencyClass, ModelPrice, ScoreCandidatesOptions, } from "./routing.js";
54
54
  export { selectWindow, inDeadlineEntries, TOLERANCE_FLOOR_G, TOLERANCE_FRACTION, } from "./select-window.js";
@@ -58,7 +58,7 @@ export type { CarbonStats, RegionStats, BandHistogram, Achievement, } from "./ag
58
58
  export { NOTIFY_PREVIEW_CHARS, WIN_NOTIFY_BODY_VAR, WIN_NOTIFY_TITLE_VAR, firstErrorLine, osNotifyCommand, taskNotificationContent, } from "./notify.js";
59
59
  export type { OsNotifyCommand, OsNotifyOptions } from "./notify.js";
60
60
  export { CLAUDE_CODE_TOOL_ALLOWLIST, DEFAULT_CLAUDE_CODE_TOOLS, DEFAULT_ORIGIN_TOOLS, claudeCodeToolsError, includesFileTool, includesWebTool, } from "./claude-tools.js";
61
- export { HANDOFF_PATH_MAX_CHARS, HANDOFF_PROFILES, PROFILE_TOOLS, defaultDbPath, handoffCwdError, isDefaultLedger, latestResultFile, nodeHandoffFs, outputPathError, profileTools, PROTECTED_HOME_DIRS, resultFileText, resultPathError, removeWakeMarker, sameTools, taskWorkShape, WAKE_MARKER_MAX_AGE_MS, wakeError, wakeMarkerPath, wakeMarkersDir, writeWakeMarker, } from "./handoff.js";
61
+ export { HANDOFF_PATH_MAX_CHARS, HANDOFF_PROFILES, PROFILE_TOOLS, defaultDbPath, handoffCwdError, isDefaultLedger, latestResultFile, nodeHandoffFs, outputPathError, profileTools, PROTECTED_HOME_DIRS, resultFileText, resultPathError, removeWakeMarker, sameTools, taskWorkShape, wakeShapeText, isWakeTask, noticeWakes, releaseWakeMarker, removeWakeMarkerUnlessPending, sessionHasWaitWork, wakeTasksToCome, wakeError, wakeMarkerPath, wakeMarkersDir, writeWakeMarker, } from "./handoff.js";
62
62
  export type { HandoffFs, HandoffFsEntry, HandoffPathContext, HandoffProfile, HandoffSpec, ProfileChoice, TaskWorkShape, } from "./handoff.js";
63
63
  export { forkCommand, freshReasonText, runSessionSummary, shortSessionId, taskOrigin, tokensLabel } from "./run-session.js";
64
64
  export type { FreshReason, RunSession, RunSessionMode } from "./run-session.js";
@@ -68,13 +68,17 @@ export { DEFAULT_QUOTA_MARGIN_H, loadQuotaResetConfig, nextQuotaReset, prepareTi
68
68
  export type { LoadQuotaResetOptions, QuotaResetConfig, QuotaResetSchedule, ResolveQuotaProviderResult, } from "./quota.js";
69
69
  export { mockGridFeed, electricityMapsFeed, ukCarbonIntensityFeed, eiaFeed, entsoeFeed, wattTimeFeed, multiSourceGridFeed, buildDefaultGridFeed, regionDataSource, } from "./grid.js";
70
70
  export type { GridFeedCredentials, RegionDataSource } from "./grid.js";
71
- export type { DeferOptions, GridFeed, GridForecast, GridForecastEntry, GridSignalType, CarbonReceipt, ReceiptModelEntry, TokenCounts, DeadlineKind, ProviderCallOrigin, ProviderCallSpec, ProviderName, RecommendAlternative, RecommendOptions, RecommendResult, RepeatRule, TaskRecord, TaskMessage, TaskOriginHost, TaskStatus, TickResult, TickResultEntry, JobCadence, JobCaps, JobNotify, JobOutcome, JobRecord, JobStatus, JobTemplate, JobTools, JobWindow, Occurrence, Weekday, } from "./types.js";
71
+ export type { DeferOptions, GridFeed, GridForecast, GridForecastEntry, GridSignalType, CarbonReceipt, ReceiptModelEntry, TokenCounts, DeadlineKind, ProviderCallOrigin, ProviderCallSpec, ProviderName, RecommendAlternative, RecommendOptions, RecommendResult, RepeatRule, TaskRecord, TaskMessage, TaskOriginHost, TaskStatus, TickResult, TickResultEntry, JobCadence, JobCaps, JobNotify, JobOutcome, JobRecord, JobStatus, JobEndReason, JobNoticeReason, JobWake, JobTemplate, JobTools, JobWindow, Occurrence, Weekday, } from "./types.js";
72
72
  export { DEFAULT_JOB_CAPS } from "./types.js";
73
- export { guaranteeText, isCalendarAnchored, JobScheduleError, MAX_EVERY_HOURS, MIN_EVERY_HOURS, nextOccurrence, parseCadence, parseWindow, validateJobSchedule, } from "./job-cadence.js";
73
+ export { guaranteeText, isCalendarAnchored, JobScheduleError, MAX_EVERY_HOURS, MIN_EVERY_HOURS, nextOccurrence, parseCadence, parseWindow, untilBoundMs, untilText, validateJobSchedule, } from "./job-cadence.js";
74
74
  export type { JobSchedule, NextOccurrenceInput } from "./job-cadence.js";
75
75
  export { localToUtcMs, systemTimeZone } from "./zone-time.js";
76
- export { createJob, getJob, JOB_AUTO_PAUSE_FAILURES, JOB_AUTO_PAUSE_PREFIX, jobAutoPauseReason, JOB_INTERRUPTED_ERROR, JOB_SECRET_NAME, JobActionError, jobHistory, jobRunLimits, listJobs, pauseJob, removeJob, resumeJob, runJobNow, sweepJobs, updateJob, } from "./jobs.js";
77
- export type { JobActionOptions, JobCapsPatch, JobHistoryEntry, JobInput, JobPatch, JobSweepResult, JobUpdateOptions } from "./jobs.js";
76
+ export { loadNoticeLanguage, NOTICE_LANGUAGE_KEY, NoticeLanguageError, parseNoticeLanguage } from "./notice-language.js";
77
+ export type { NoticeLanguage, NoticeLanguageSetting } from "./notice-language.js";
78
+ export { createJob, getJob, JOB_AUTO_PAUSE_FAILURES, JOB_AUTO_PAUSE_PREFIX, jobAutoPauseReason, jobEndsText, jobEndText, JOB_INTERRUPTED_ERROR, JOB_MAX_COUNT, DEFAULT_SUMMARIZE_PROMPT, effectiveSummarizePrompt, isDefaultSummarizePrompt, JOB_SECRET_NAME, JobActionError, jobHistory, jobRunLimits, jobWakeSession, listJobs, pauseJob, removeJob, resumeJob, runJobNow, sweepJobs, updateJob, } from "./jobs.js";
79
+ export type { JobActionOptions, JobCapsPatch, JobHistoryEntry, JobInput, JobPatch, JobSweepResult, JobUpdateOptions, JobWakeInput } from "./jobs.js";
80
+ export { JOB_WAKE_FORMS, JOB_WAKE_MATCH_TIMEOUT_MS, JOB_WAKE_PATTERN_MAX_CHARS, JOB_WAKE_TEXT_MAX_CHARS, JobWakeError, matchWake, parseWakeRule, wakePatternError, } from "./job-wake.js";
81
+ export type { JobWakeRule, WakeMatch } from "./job-wake.js";
78
82
  export { AnthropicAdapter, OpenAIAdapter, GeminiAdapter, OllamaAdapter, DEFAULT_MODEL_BY_PROVIDER, NonRetryableError, permanentError, ProviderRefusalError, } from "./providers/index.js";
79
83
  export { budgetMaxTokens, BudgetExceededError } from "./providers/budget.js";
80
84
  export { MAX_TIMER_MS, withLlmTimeout } from "./providers/timeout.js";
@@ -87,7 +91,7 @@ export type { BatchHandle, DispatchOptions, DispatchOrigin, DispatchResult, Mode
87
91
  export { SESSION_NOTICE_MAX_AGE_MS, SESSION_NOTICES_SINCE_META_KEY, TaskStore } from "./storage/sqlite.js";
88
92
  export { PROGRESS_BUSY_MS, PROGRESS_GAP_MS, PROGRESS_LINE_MAX_CHARS, PROGRESS_MAX_EVENTS, PROGRESS_QUIET_MS, TASK_EVENT_KINDS, cleanProgressText, createProgressRecorder, attemptLines, eventSummary, formatTaskEvent, isTaskEventKind, normalizeActor, progressLine, taskEventJson, } from "./task-events.js";
89
93
  export type { ProgressRecorder, TaskEvent, TaskEventActor, TaskEventInput, TaskEventKind } from "./task-events.js";
90
- export type { SessionNotice, TaskListFilter, TaskStoreOptions } from "./storage/sqlite.js";
94
+ export type { JobNotice, SessionNotice, TaskListFilter, TaskStoreOptions } from "./storage/sqlite.js";
91
95
  export { FALLBACK_REGION, REGION_SETTING_KEY, REGION_CATALOG, TIMEZONE_REGION, APPROXIMATE_TIMEZONE_REGION, catalogZone, closestRegions, COUNTRY_ALIASES, regionForTimezone, guessRegionFromTimeZone, hostTimeZone, detectRegionFromTimezone, ignoredRegionMessage, loadRegionSetting, resolveRegion, } from "./region.js";
92
96
  export { checkRequestedRegion, regionRequestUrl, regionSettingReader, unknownRegionMessage, } from "./region-host.js";
93
97
  export type { RegionSettingReaderOptions } from "./region-host.js";
@@ -97,7 +101,7 @@ export type { DurationValue, FailureClass, FailureFacts, FinalReason, IgnoredRun
97
101
  export { DEFAULT_PUE, LEGACY_KWH_PER_TASK, MODEL_ENERGY_COEFFICIENTS, MODEL_FAMILIES, ENERGY_SOURCES, normalizeModelName, lookupModelEnergy, resolveModelEnergy, estimateEnergyKwh, gramsForIntensity, TOKEN_COUNTS_PARTIAL_TEXT, TOKEN_COUNTS_TYPICAL_TEXT, } from "./energy.js";
98
102
  export type { EnergySourceTier, EnergyResolutionTier, ModelLifecycleStatus, ModelEnergyCoefficients, ModelFamily, ResolvedModelEnergy, EstimateEnergyOpts, } from "./energy.js";
99
103
  export { ALL_TOOL_HOSTS, TOOL_SURFACE, getToolDef, getToolDefOrThrow, toolsForHost, descriptionForHost, paramHosts, paramIncludedForHost, paramsForHost, paramOptionalForHost, neutralSurfaceForHost, } from "./tool-surface.js";
100
- export { commandJobRefusal, QUEUE_ADD_COMMAND_LINE, endJobOfTask, isJobRepeat, JOB_ONLY_PARAMS, JOB_REPEATS, jobParamsRefusal, jobToolsFor, jobToolView, jobUnsupportedRefusal, llmTimeoutArg, retryCapsArgs, scheduleJobInput, } from "./schedule-job.js";
104
+ export { commandJobRefusal, QUEUE_ADD_COMMAND_LINE, endJobOfTask, isJobRepeat, JOB_ONLY_PARAMS, JOB_REPEATS, jobParamsRefusal, jobToolsFor, jobToolView, jobUnsupportedRefusal, jobWakeArgs, llmTimeoutArg, retryCapsArgs, scheduleJobInput, } from "./schedule-job.js";
101
105
  export type { JobRepeat, JobToolView, ScheduleJobArgs } from "./schedule-job.js";
102
106
  export type { ToolHost, ToolParamKind, ToolParam, ToolAnnotations, CanonicalToolDef, } from "./tool-surface.js";
103
107
  export { canonicalize, defaultSigningKeyPath, loadOrCreateSigningKey, signReceipt, verifyReceipt, } from "./sign.js";
package/dist/index.js CHANGED
@@ -41,13 +41,13 @@
41
41
  export { CarbonBudgetExceededError, COMMAND_MAX_CHARS, defer, InvalidDeadlineError, LAST_TICK_META_KEY, pickBestWindow, Scheduler, TaskActionError, } from "./scheduler.js";
42
42
  export { recommendWindow } from "./recommend.js";
43
43
  // Task visibility (v0.17): titles, history, display helpers.
44
- export { TITLE_MAX_CHARS, deadlineKindLabel, deriveTitle, displayTitle, isRepeating, isValidSessionId, resumeCommand, SESSION_ID_PATTERN, shellQuote, taskActions, stripControlChars, capHistory, HISTORY_MAX_CHARS, taskHistory, taskPrompt, taskResultText, } from "./history.js";
44
+ export { TITLE_MAX_CHARS, deadlineKindLabel, deriveTitle, displayTitle, isRepeating, isValidSessionId, resumeCommand, SESSION_ID_PATTERN, shellQuote, taskActions, stripControlChars, capHistory, HISTORY_MAX_CHARS, taskHistory, taskPrompt, taskResultText, taskSummaryError, taskSummaryText, ATTACHMENT_TYPES, attachmentDisplayName, formatBytes, isRedactedTask, sendableAttachments, taskAttachments, taskAttachmentsSkipped, } from "./history.js";
45
45
  // Readiness (coherence KTD1 to KTD3).
46
46
  export { assessReadiness, oldestTickRun, pendingProvidersFromStore, problemLine, readTickRunners, readTickSleep, sleepReadNeeded, runnersFromSnapshot, sleptBetween, snapshotIsFresh, TICKER_CODES, tickIntervalFor, TICK_RUNNERS_META_KEY, TICK_BY_META_KEY, TICK_SLEEP_META_KEY, writeTickRunners, writeTickSleep, } from "./readiness.js";
47
47
  // "Later" presets (coherence KTD4 to KTD6).
48
48
  export { LIMIT_RESET_HINT_META_KEY, NEEDS_RESET_TIME, POSTPONE_LABELS, POSTPONE_PRESETS, localTimeLabel, MORNING_START_H, plannedStart, postponeOptions, readLimitResetHint, resolveLimitReset, resolvePostpone, taskProvider, TONIGHT_START_H, writeLimitResetHint, } from "./postpone.js";
49
49
  // Channels: registry, Telegram client, bot commands and texts (coherence KTD10 to KTD15).
50
- export { CALLBACK_ACTIONS, CALLBACK_PRESETS, cleanWindowMessage, commandContextFor, callbackFits, encodeCallback, CHANNEL_KINDS, channelQuiet, DELIVERY_CODES, descriptorData, EVENT_KINDS, keepsSecret, eventMessage, isChannelKind, isQuietTime, KIND_DESCRIPTORS, payloadFor, testPayload, TEST_MESSAGE_TEXT, validateFields, WEBHOOK_BODY_VERSION, webhookBody, PUSHOVER_MESSAGES_PATH, isLoopbackSmtpHost, HELP_TEXT, telegramCommands, isLoopbackApiBase, isRedactedTask, runPreview, LATER_GRAMMAR, laterMenuMessage, laterTarget, LISTING_TTL_MS, messageTitle, nextClockTime, notReadyMessage, osChannel, parseCallback, parseCommand, planNotifications, foldIntoDigest, buildDigest, digestAt, digestDue, parseDigestAt, DEFAULT_DIGEST_AT, DIGEST_AT_META_KEY, DIGEST_LAST_META_KEY, DIGEST_LIST_MAX, DIGEST_SENT_META_KEY, DIGEST_MAX_WINDOW_MS, QUEUE_LIST_MAX, QueueListing, queueMessage, RESULT_MAX_PARTS, resultMessages, runCallback, runCommand, splitMessage, taskDoneMessage, taskFailedMessage, eventTitle, jobDigestText, jobNextLabel, jobPausedMessage, jobPausedTitle, jobTitle, zoneTimeLabel, telegramChatId, TELEGRAM_API_BASE, TELEGRAM_CALL_TIMEOUT_MS, TELEGRAM_CALLBACK_MAX_BYTES, TELEGRAM_MESSAGE_MAX, TELEGRAM_PREVIEW_CHARS, TelegramClient, TelegramError, } from "./channels/index.js";
50
+ export { CALLBACK_ACTIONS, CALLBACK_PRESETS, cleanWindowMessage, commandContextFor, callbackFits, encodeCallback, CHANNEL_KINDS, channelQuiet, DELIVERY_CODES, descriptorData, EVENT_KINDS, keepsSecret, eventMessage, isChannelKind, isQuietTime, KIND_DESCRIPTORS, payloadFor, testPayload, TEST_MESSAGE_TEXT, validateFields, WEBHOOK_BODY_VERSION, webhookBody, PUSHOVER_MESSAGES_PATH, isLoopbackSmtpHost, HELP_TEXT, telegramCommands, isLoopbackApiBase, runPreview, runVerdict, NOTICE_EMOJI, noticeStatus, runSummary, structureSummary, LATER_GRAMMAR, laterMenuMessage, laterTarget, LISTING_TTL_MS, messageTitle, nextClockTime, notReadyMessage, osChannel, parseCallback, parseCommand, planNotifications, foldIntoDigest, buildDigest, digestAt, digestDue, parseDigestAt, DEFAULT_DIGEST_AT, DIGEST_AT_META_KEY, DIGEST_LAST_META_KEY, DIGEST_LIST_MAX, DIGEST_SENT_META_KEY, DIGEST_MAX_WINDOW_MS, QUEUE_LIST_MAX, QueueListing, queueMessage, RESULT_MAX_PARTS, resultMessages, attachmentLine, ATTACHMENT_LINE_CHARS, runCallback, runCommand, splitMessage, taskDoneMessage, taskFailedMessage, eventTitle, jobDigestText, jobNextLabel, jobEndedBody, jobEndedMessage, jobEndedTitle, jobPausedMessage, jobPausedTitle, jobTitle, zoneTimeLabel, telegramChatId, TELEGRAM_API_BASE, TELEGRAM_CALL_TIMEOUT_MS, TELEGRAM_UPLOAD_TIMEOUT_MS, TELEGRAM_CALLBACK_MAX_BYTES, TELEGRAM_MESSAGE_MAX, TELEGRAM_PREVIEW_CHARS, TelegramClient, TelegramError, } from "./channels/index.js";
51
51
  // Cross-provider routing (ROADMAP item 1).
52
52
  export { scoreCandidates, previewRouting, parseCandidate, parseCandidates, candidateId, normalizeRouteWeights, priceForModel, DEFAULT_ROUTE_WEIGHTS, ROUTING_PREVIEW_DISCLOSURE, SCORE_TIE_EPSILON, InvalidCandidateError, InvalidRouteWeightsError, MissingPriceError, } from "./routing.js";
53
53
  export { selectWindow, inDeadlineEntries, TOLERANCE_FLOOR_G, TOLERANCE_FRACTION, } from "./select-window.js";
@@ -56,7 +56,7 @@ export { ASSUMED_KWH_PER_CALL, classifyBand, aggregateStats, aggregateByRegion,
56
56
  // Desktop notifications (v0.17): pure command builder, hosts spawn it.
57
57
  export { NOTIFY_PREVIEW_CHARS, WIN_NOTIFY_BODY_VAR, WIN_NOTIFY_TITLE_VAR, firstErrorLine, osNotifyCommand, taskNotificationContent, } from "./notify.js";
58
58
  export { CLAUDE_CODE_TOOL_ALLOWLIST, DEFAULT_CLAUDE_CODE_TOOLS, DEFAULT_ORIGIN_TOOLS, claudeCodeToolsError, includesFileTool, includesWebTool, } from "./claude-tools.js";
59
- export { HANDOFF_PATH_MAX_CHARS, HANDOFF_PROFILES, PROFILE_TOOLS, defaultDbPath, handoffCwdError, isDefaultLedger, latestResultFile, nodeHandoffFs, outputPathError, profileTools, PROTECTED_HOME_DIRS, resultFileText, resultPathError, removeWakeMarker, sameTools, taskWorkShape, WAKE_MARKER_MAX_AGE_MS, wakeError, wakeMarkerPath, wakeMarkersDir, writeWakeMarker, } from "./handoff.js";
59
+ export { HANDOFF_PATH_MAX_CHARS, HANDOFF_PROFILES, PROFILE_TOOLS, defaultDbPath, handoffCwdError, isDefaultLedger, latestResultFile, nodeHandoffFs, outputPathError, profileTools, PROTECTED_HOME_DIRS, resultFileText, resultPathError, removeWakeMarker, sameTools, taskWorkShape, wakeShapeText, isWakeTask, noticeWakes, releaseWakeMarker, removeWakeMarkerUnlessPending, sessionHasWaitWork, wakeTasksToCome, wakeError, wakeMarkerPath, wakeMarkersDir, writeWakeMarker, } from "./handoff.js";
60
60
  export { forkCommand, freshReasonText, runSessionSummary, shortSessionId, taskOrigin, tokensLabel } from "./run-session.js";
61
61
  export { carbonBudgetConfigPath, carbonBudgetStatus, carbonBudgetUsage, loadCarbonBudgetConfig, parseKeyValues, KEY_PREFIX, receiptCarbonG, windowBounds, } from "./budget.js";
62
62
  // Quota-reset deadlines and the shared pre-tick step (v0.17).
@@ -64,11 +64,15 @@ export { DEFAULT_QUOTA_MARGIN_H, loadQuotaResetConfig, nextQuotaReset, prepareTi
64
64
  export { mockGridFeed, electricityMapsFeed, ukCarbonIntensityFeed, eiaFeed, entsoeFeed, wattTimeFeed, multiSourceGridFeed, buildDefaultGridFeed, regionDataSource, } from "./grid.js";
65
65
  export { DEFAULT_JOB_CAPS } from "./types.js";
66
66
  // Floating recurring jobs: cadence, window and anchor math (KTD5).
67
- export { guaranteeText, isCalendarAnchored, JobScheduleError, MAX_EVERY_HOURS, MIN_EVERY_HOURS, nextOccurrence, parseCadence, parseWindow, validateJobSchedule, } from "./job-cadence.js";
67
+ export { guaranteeText, isCalendarAnchored, JobScheduleError, MAX_EVERY_HOURS, MIN_EVERY_HOURS, nextOccurrence, parseCadence, parseWindow, untilBoundMs, untilText, validateJobSchedule, } from "./job-cadence.js";
68
68
  // IANA zone helpers shared by the quota and job code.
69
69
  export { localToUtcMs, systemTimeZone } from "./zone-time.js";
70
+ // The notice language a job's summarize step writes in (`tidegap language`).
71
+ export { loadNoticeLanguage, NOTICE_LANGUAGE_KEY, NoticeLanguageError, parseNoticeLanguage } from "./notice-language.js";
70
72
  // Floating recurring jobs: actions and the job sweep (KTD2, KTD9).
71
- export { createJob, getJob, JOB_AUTO_PAUSE_FAILURES, JOB_AUTO_PAUSE_PREFIX, jobAutoPauseReason, JOB_INTERRUPTED_ERROR, JOB_SECRET_NAME, JobActionError, jobHistory, jobRunLimits, listJobs, pauseJob, removeJob, resumeJob, runJobNow, sweepJobs, updateJob, } from "./jobs.js";
73
+ export { createJob, getJob, JOB_AUTO_PAUSE_FAILURES, JOB_AUTO_PAUSE_PREFIX, jobAutoPauseReason, jobEndsText, jobEndText, JOB_INTERRUPTED_ERROR, JOB_MAX_COUNT, DEFAULT_SUMMARIZE_PROMPT, effectiveSummarizePrompt, isDefaultSummarizePrompt, JOB_SECRET_NAME, JobActionError, jobHistory, jobRunLimits, jobWakeSession, listJobs, pauseJob, removeJob, resumeJob, runJobNow, sweepJobs, updateJob, } from "./jobs.js";
74
+ // Wake rules of a job bound to a session (KTD7, KTD9).
75
+ export { JOB_WAKE_FORMS, JOB_WAKE_MATCH_TIMEOUT_MS, JOB_WAKE_PATTERN_MAX_CHARS, JOB_WAKE_TEXT_MAX_CHARS, JobWakeError, matchWake, parseWakeRule, wakePatternError, } from "./job-wake.js";
72
76
  export { AnthropicAdapter, OpenAIAdapter, GeminiAdapter, OllamaAdapter, DEFAULT_MODEL_BY_PROVIDER, NonRetryableError, permanentError, ProviderRefusalError, } from "./providers/index.js";
73
77
  export { budgetMaxTokens, BudgetExceededError } from "./providers/budget.js";
74
78
  export { MAX_TIMER_MS, withLlmTimeout } from "./providers/timeout.js";
@@ -84,7 +88,7 @@ export { BATCH_LLM_TIMEOUT_NOTE, CAPS_VERSION, DURATION_FORM_ERROR, DURATION_RAN
84
88
  export { DEFAULT_PUE, LEGACY_KWH_PER_TASK, MODEL_ENERGY_COEFFICIENTS, MODEL_FAMILIES, ENERGY_SOURCES, normalizeModelName, lookupModelEnergy, resolveModelEnergy, estimateEnergyKwh, gramsForIntensity, TOKEN_COUNTS_PARTIAL_TEXT, TOKEN_COUNTS_TYPICAL_TEXT, } from "./energy.js";
85
89
  export { ALL_TOOL_HOSTS, TOOL_SURFACE, getToolDef, getToolDefOrThrow, toolsForHost, descriptionForHost, paramHosts, paramIncludedForHost, paramsForHost, paramOptionalForHost, neutralSurfaceForHost, } from "./tool-surface.js";
86
90
  // schedule_task sugar for floating recurring jobs (KTD16), shared by both hosts.
87
- export { commandJobRefusal, QUEUE_ADD_COMMAND_LINE, endJobOfTask, isJobRepeat, JOB_ONLY_PARAMS, JOB_REPEATS, jobParamsRefusal, jobToolsFor, jobToolView, jobUnsupportedRefusal, llmTimeoutArg, retryCapsArgs, scheduleJobInput, } from "./schedule-job.js";
91
+ export { commandJobRefusal, QUEUE_ADD_COMMAND_LINE, endJobOfTask, isJobRepeat, JOB_ONLY_PARAMS, JOB_REPEATS, jobParamsRefusal, jobToolsFor, jobToolView, jobUnsupportedRefusal, jobWakeArgs, llmTimeoutArg, retryCapsArgs, scheduleJobInput, } from "./schedule-job.js";
88
92
  export { canonicalize, defaultSigningKeyPath, loadOrCreateSigningKey, signReceipt, verifyReceipt, } from "./sign.js";
89
93
  export { TIDEGAP_HOME_DIR, resolveTidegapHome, tidegapPath, } from "./paths.js";
90
94
  export { AGENT_HOSTS, AGENTS_BLOCK, agentSnippet, isAgentHost, renderAgentSnippet, } from "./agent-snippet.js";
@@ -73,4 +73,14 @@ export declare function isCalendarAnchored(schedule: JobSchedule): boolean;
73
73
  export declare function nextOccurrence(schedule: JobSchedule, input: NextOccurrenceInput): Occurrence;
74
74
  /** The guarantee a schedule gives, as one sentence (R4). */
75
75
  export declare function guaranteeText(schedule: JobSchedule): string;
76
+ /**
77
+ * The end bound of a job's `until`, in ms: a slot must start before it.
78
+ * `YYYY-MM-DD` is the last local day in `timeZone` on which a slot may
79
+ * start, so the bound is the next local midnight; an ISO instant with `Z`
80
+ * or an offset is the bound itself. Throws {@link JobScheduleError} on any
81
+ * other text, a day that does not exist (`2026-02-30`) included.
82
+ */
83
+ export declare function untilBoundMs(until: string, timeZone: string): number;
84
+ /** A job's end date in words: `after 2026-11-17 (Europe/Berlin)` for a day, `before <instant>` for an instant. */
85
+ export declare function untilText(until: string, timeZone: string): string;
76
86
  //# sourceMappingURL=job-cadence.d.ts.map
@@ -237,4 +237,38 @@ export function guaranteeText(schedule) {
237
237
  const days = c.kind === "weekly" ? `every ${dayList(c.days)}` : c.kind === "weekdays" ? "every weekday (Mon-Fri)" : "every day";
238
238
  return s.window ? `runs ${days} between ${s.window.start} and ${s.window.end}` : `runs once ${days}, any time of day`;
239
239
  }
240
+ const UNTIL_DAY = /^(\d{4})-(\d{2})-(\d{2})$/;
241
+ const UNTIL_INSTANT = /^(\d{4}-\d{2}-\d{2})T(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d{1,3})?)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;
242
+ /** `[year, month (1-12), day]` of a real calendar day `YYYY-MM-DD`, or undefined. */
243
+ function calendarDay(text) {
244
+ const m = UNTIL_DAY.exec(text);
245
+ if (!m)
246
+ return undefined;
247
+ const [y, mo, d] = [Number(m[1]), Number(m[2]), Number(m[3])];
248
+ const check = new Date(Date.UTC(y, mo - 1, d));
249
+ return check.getUTCFullYear() === y && check.getUTCMonth() === mo - 1 && check.getUTCDate() === d ? [y, mo, d] : undefined;
250
+ }
251
+ /**
252
+ * The end bound of a job's `until`, in ms: a slot must start before it.
253
+ * `YYYY-MM-DD` is the last local day in `timeZone` on which a slot may
254
+ * start, so the bound is the next local midnight; an ISO instant with `Z`
255
+ * or an offset is the bound itself. Throws {@link JobScheduleError} on any
256
+ * other text, a day that does not exist (`2026-02-30`) included.
257
+ */
258
+ export function untilBoundMs(until, timeZone) {
259
+ const day = calendarDay(until);
260
+ if (day)
261
+ return localToUtcMs(day[0], day[1] - 1, day[2] + 1, 0, 0, timeZone);
262
+ const instant = UNTIL_INSTANT.exec(until);
263
+ if (instant && calendarDay(instant[1])) {
264
+ const ms = Date.parse(until);
265
+ if (Number.isFinite(ms))
266
+ return ms;
267
+ }
268
+ throw new JobScheduleError(`until "${until}" must be a day YYYY-MM-DD or an ISO instant with Z or an offset`);
269
+ }
270
+ /** A job's end date in words: `after 2026-11-17 (Europe/Berlin)` for a day, `before <instant>` for an instant. */
271
+ export function untilText(until, timeZone) {
272
+ return UNTIL_DAY.test(until) ? `after ${until} (${timeZone})` : `before ${until}`;
273
+ }
240
274
  //# sourceMappingURL=job-cadence.js.map