@tidegap/core 0.22.0 → 0.24.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 (40) hide show
  1. package/dist/channels/commands.js +3 -2
  2. package/dist/channels/digest.d.ts +4 -1
  3. package/dist/channels/digest.js +6 -2
  4. package/dist/channels/format.d.ts +44 -19
  5. package/dist/channels/format.js +113 -77
  6. package/dist/channels/index.d.ts +1 -0
  7. package/dist/channels/index.js +1 -0
  8. package/dist/channels/kinds/discord.js +2 -2
  9. package/dist/channels/kinds/email.js +2 -1
  10. package/dist/channels/kinds/ntfy.js +9 -1
  11. package/dist/channels/kinds/pushover.js +4 -3
  12. package/dist/channels/kinds/shared.d.ts +4 -1
  13. package/dist/channels/kinds/shared.js +6 -1
  14. package/dist/channels/kinds/slack.js +2 -2
  15. package/dist/channels/notice.d.ts +42 -0
  16. package/dist/channels/notice.js +142 -0
  17. package/dist/channels/payload.d.ts +3 -0
  18. package/dist/channels/payload.js +16 -5
  19. package/dist/channels/telegram.d.ts +31 -1
  20. package/dist/channels/telegram.js +34 -12
  21. package/dist/history.d.ts +101 -0
  22. package/dist/history.js +95 -0
  23. package/dist/index.d.ts +8 -6
  24. package/dist/index.js +6 -4
  25. package/dist/jobs.d.ts +53 -5
  26. package/dist/jobs.js +279 -42
  27. package/dist/notice-language.d.ts +37 -0
  28. package/dist/notice-language.js +67 -0
  29. package/dist/providers/base.d.ts +7 -0
  30. package/dist/redact.d.ts +3 -2
  31. package/dist/redact.js +8 -2
  32. package/dist/schedule-job.d.ts +3 -2
  33. package/dist/schedule-job.js +6 -5
  34. package/dist/scheduler.d.ts +9 -1
  35. package/dist/scheduler.js +13 -5
  36. package/dist/storage/sqlite.js +7 -3
  37. package/dist/types.d.ts +14 -1
  38. package/dist/zone-time.d.ts +2 -0
  39. package/dist/zone-time.js +11 -0
  40. package/package.json +2 -2
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, taskSummaryError, taskSummaryText, } 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, runVerdict, 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, jobEndedBody, jobEndedMessage, jobEndedTitle, 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, JobEndedNotice, 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, 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";
@@ -72,8 +72,10 @@ export type { DeferOptions, GridFeed, GridForecast, GridForecastEntry, GridSigna
72
72
  export { DEFAULT_JOB_CAPS } from "./types.js";
73
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
- export { localToUtcMs, systemTimeZone } from "./zone-time.js";
76
- export { createJob, getJob, JOB_AUTO_PAUSE_FAILURES, JOB_AUTO_PAUSE_PREFIX, jobAutoPauseReason, jobEndsText, jobEndText, JOB_INTERRUPTED_ERROR, JOB_MAX_COUNT, DEFAULT_SUMMARIZE_PROMPT, JOB_SECRET_NAME, JobActionError, jobHistory, jobRunLimits, jobWakeSession, listJobs, pauseJob, removeJob, resumeJob, runJobNow, sweepJobs, updateJob, } from "./jobs.js";
75
+ export { localToUtcMs, systemTimeZone, zoneTimeLabel } from "./zone-time.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, isExtraRunId, jobHistory, jobLastRun, jobNextRun, jobRunLimits, jobWakeSession, listJobs, pauseJob, removeJob, resumeJob, runJobNow, runNowRefusal, runOutcome, sweepJobs, updateJob, } from "./jobs.js";
77
79
  export type { JobActionOptions, JobCapsPatch, JobHistoryEntry, JobInput, JobPatch, JobSweepResult, JobUpdateOptions, JobWakeInput } from "./jobs.js";
78
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";
79
81
  export type { JobWakeRule, WakeMatch } from "./job-wake.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, taskSummaryError, taskSummaryText, } 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, runVerdict, 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, jobEndedBody, jobEndedMessage, jobEndedTitle, 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, 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";
@@ -66,9 +66,11 @@ export { DEFAULT_JOB_CAPS } from "./types.js";
66
66
  // Floating recurring jobs: cadence, window and anchor math (KTD5).
67
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
- export { localToUtcMs, systemTimeZone } from "./zone-time.js";
69
+ export { localToUtcMs, systemTimeZone, zoneTimeLabel } 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, jobEndsText, jobEndText, JOB_INTERRUPTED_ERROR, JOB_MAX_COUNT, DEFAULT_SUMMARIZE_PROMPT, JOB_SECRET_NAME, JobActionError, jobHistory, jobRunLimits, jobWakeSession, 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, isExtraRunId, jobHistory, jobLastRun, jobNextRun, jobRunLimits, jobWakeSession, listJobs, pauseJob, removeJob, resumeJob, runJobNow, runNowRefusal, runOutcome, sweepJobs, updateJob, } from "./jobs.js";
72
74
  // Wake rules of a job bound to a session (KTD7, KTD9).
73
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";
74
76
  export { AnthropicAdapter, OpenAIAdapter, GeminiAdapter, OllamaAdapter, DEFAULT_MODEL_BY_PROVIDER, NonRetryableError, permanentError, ProviderRefusalError, } from "./providers/index.js";
package/dist/jobs.d.ts CHANGED
@@ -20,6 +20,11 @@
20
20
  * occurrence;
21
21
  * - no occurrence on an active job: materializes one.
22
22
  *
23
+ * Run now adds an extra run beside the tracked occurrence
24
+ * (`<job_id>~<seq>x`, tracked as `extraTaskId`), which the sweep records
25
+ * on its own: it becomes the last run, gets the job's retries, and never
26
+ * moves the schedule, the failure count or the runs left.
27
+ *
23
28
  * Every job write is a compare-and-set on `revision`. Pause, edit and
24
29
  * remove write the job row first, then cancel the tracked occurrence; a
25
30
  * sweep whose job write misses leaves its insert to the next pass, which
@@ -31,6 +36,7 @@ import { type JobWakeRule } from "./job-wake.js";
31
36
  import { type SleepReading } from "./readiness.js";
32
37
  import type { Scheduler } from "./scheduler.js";
33
38
  import { type ResolvedRunLimits } from "./run-limits.js";
39
+ import type { TaskStore } from "./storage/sqlite.js";
34
40
  import { type JobCadence, type JobCaps, type JobEndReason, type JobNotify, type JobRecord, type JobTemplate, type JobWindow, type TaskRecord, type TaskStatus } from "./types.js";
35
41
  /** Why a job action was refused; `code` maps to an HTTP status in the hosts. */
36
42
  export declare class JobActionError extends Error {
@@ -164,10 +170,15 @@ export interface JobSweepResult {
164
170
  export declare const JOB_SECRET_NAME: RegExp;
165
171
  /**
166
172
  * The prompt `tidegap jobs add --summarize` stores when the user gives none.
167
- * It is stored as text on the job, so a later change here leaves existing
168
- * jobs as they are.
173
+ * It is stored as text on the job; a job whose stored text is this or an
174
+ * earlier default runs with the current one ({@link effectiveSummarizePrompt}),
175
+ * and a job's own prompt is never changed.
169
176
  */
170
177
  export declare const DEFAULT_SUMMARIZE_PROMPT: string;
178
+ /** True for the current default summarize prompt and every earlier one, with CRLF line ends or surrounding whitespace too. */
179
+ export declare function isDefaultSummarizePrompt(text: string): boolean;
180
+ /** The prompt a summarize step runs with: the current default for any default text, else the stored prompt. */
181
+ export declare function effectiveSummarizePrompt(stored: string): string;
171
182
  /** The most runs a job's `count` may ask for. */
172
183
  export declare const JOB_MAX_COUNT = 1000;
173
184
  /** Failed slots in a row that pause a job. */
@@ -192,6 +203,8 @@ export declare function jobWakeSession(job: Pick<JobRecord, "wake" | "originSess
192
203
  * the scheduler's settings reader, or without one the settings file.
193
204
  */
194
205
  export declare function jobRunLimits(job: JobRecord, scheduler?: Scheduler): ResolvedRunLimits;
206
+ /** True for an extra run's id (`<job>~<seq>x`, which run now adds) or one of its retries (`...xr`, `...xr2`). */
207
+ export declare function isExtraRunId(taskId: string): boolean;
195
208
  /**
196
209
  * The job sweep (KTD2): for every job, record the outcome of its finished
197
210
  * occurrence and keep one live occurrence per active job. Never throws.
@@ -212,11 +225,46 @@ export declare function pauseJob(scheduler: Scheduler, jobId: string, opts?: Job
212
225
  /** Resume a paused job: counter reset, one occurrence from now, no backfill (R8). */
213
226
  export declare function resumeJob(scheduler: Scheduler, jobId: string, opts?: JobActionOptions): Promise<JobRecord>;
214
227
  /**
215
- * Run a job at the next tick (AS10): its pending occurrence is expedited
216
- * (no second row). Refused while an occurrence runs or the job is paused.
217
- * Returns the expedited occurrence.
228
+ * Run a job once more, now (AS10): an extra run, a new occurrence
229
+ * `<job_id>~<seq>x` of the job's template, due on the next tick, beside the
230
+ * planned occurrence, which keeps its time. Refused on a paused, ended or
231
+ * removed job, and while a run of the job is running or starts within 5
232
+ * minutes ({@link runNowRefusal}). A pending extra run that starts later
233
+ * (the retry of an earlier one) is replaced by this one. An extra run is
234
+ * not a slot: it does not count toward `count`, `until` does not stop it,
235
+ * and it leaves the schedule and the failure count alone; it gets the
236
+ * job's retries. Returns the extra run.
218
237
  */
219
238
  export declare function runJobNow(scheduler: Scheduler, jobId: string, opts?: JobActionOptions): Promise<TaskRecord<unknown>>;
239
+ /**
240
+ * Why run now is refused for an active job at `nowMs`, or undefined: a run
241
+ * of the job (the planned occurrence or an extra run) is running, or starts
242
+ * within 5 minutes; an extra run that has not started always counts as
243
+ * starting.
244
+ */
245
+ export declare function runNowRefusal(store: Pick<TaskStore, "get">, job: JobRecord, nowMs: number): string | undefined;
246
+ /**
247
+ * The job's next run: of its tracked occurrence and its extra run, the live
248
+ * one that runs first (a running one, else the one due first), or undefined.
249
+ */
250
+ export declare function jobNextRun(store: Pick<TaskStore, "get">, job: JobRecord): TaskRecord<unknown> | undefined;
251
+ /** `ok` for an occurrence that completed, `failed` for one that failed; undefined for one that did not run (pending, running or cancelled). */
252
+ export declare function runOutcome(row: Pick<TaskRecord<unknown>, "status">): "ok" | "failed" | undefined;
253
+ /**
254
+ * The job's last run: the occurrence `lastTaskId` names when it ran
255
+ * (completed or failed), else, with `list`, the job's newest completed or
256
+ * failed occurrence (a job row from before this rule can name a cancelled
257
+ * one). A cancelled occurrence is never the last run.
258
+ */
259
+ export declare function jobLastRun(store: {
260
+ get(taskId: string): TaskRecord<unknown> | undefined;
261
+ list?(filter: {
262
+ jobId: string;
263
+ status: readonly TaskStatus[];
264
+ newestFirst: boolean;
265
+ limit: number;
266
+ }): TaskRecord<unknown>[];
267
+ }, job: Pick<JobRecord, "jobId" | "lastTaskId">): TaskRecord<unknown> | undefined;
220
268
  /** Remove a job: it stops and is hidden; its rows and history stay (AS11). */
221
269
  export declare function removeJob(scheduler: Scheduler, jobId: string, opts?: JobActionOptions): Promise<JobRecord>;
222
270
  /** One job, removed ones included; undefined when the id is unknown. */