@tidegap/core 0.19.0 → 0.20.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 (167) hide show
  1. package/README.md +1 -1
  2. package/dist/agent-snippet.d.ts +30 -0
  3. package/dist/agent-snippet.js +120 -0
  4. package/dist/channels/commands.d.ts +137 -0
  5. package/dist/channels/commands.js +377 -0
  6. package/dist/channels/delivery-codes.d.ts +9 -0
  7. package/dist/channels/delivery-codes.js +53 -0
  8. package/dist/channels/digest.d.ts +102 -0
  9. package/dist/channels/digest.js +146 -0
  10. package/dist/channels/format.d.ts +127 -0
  11. package/dist/channels/format.js +407 -0
  12. package/dist/channels/index.d.ts +15 -0
  13. package/dist/channels/index.js +15 -0
  14. package/dist/channels/kinds/command.d.ts +13 -0
  15. package/dist/channels/kinds/command.js +65 -0
  16. package/dist/channels/kinds/discord.d.ts +16 -0
  17. package/dist/channels/kinds/discord.js +67 -0
  18. package/dist/channels/kinds/email.d.ts +20 -0
  19. package/dist/channels/kinds/email.js +162 -0
  20. package/dist/channels/kinds/index.d.ts +8 -0
  21. package/dist/channels/kinds/index.js +17 -0
  22. package/dist/channels/kinds/ntfy.d.ts +25 -0
  23. package/dist/channels/kinds/ntfy.js +163 -0
  24. package/dist/channels/kinds/pushover.d.ts +11 -0
  25. package/dist/channels/kinds/pushover.js +77 -0
  26. package/dist/channels/kinds/shared.d.ts +25 -0
  27. package/dist/channels/kinds/shared.js +39 -0
  28. package/dist/channels/kinds/shortcuts.d.ts +9 -0
  29. package/dist/channels/kinds/shortcuts.js +45 -0
  30. package/dist/channels/kinds/slack.d.ts +8 -0
  31. package/dist/channels/kinds/slack.js +57 -0
  32. package/dist/channels/kinds/telegram.d.ts +4 -0
  33. package/dist/channels/kinds/telegram.js +26 -0
  34. package/dist/channels/kinds/webhook.d.ts +30 -0
  35. package/dist/channels/kinds/webhook.js +177 -0
  36. package/dist/channels/payload.d.ts +36 -0
  37. package/dist/channels/payload.js +61 -0
  38. package/dist/channels/plan.d.ts +24 -0
  39. package/dist/channels/plan.js +66 -0
  40. package/dist/channels/registry.d.ts +191 -0
  41. package/dist/channels/registry.js +125 -0
  42. package/dist/channels/telegram.d.ts +110 -0
  43. package/dist/channels/telegram.js +168 -0
  44. package/dist/channels/types.d.ts +107 -0
  45. package/dist/channels/types.js +26 -0
  46. package/dist/claude-tools.d.ts +29 -0
  47. package/dist/claude-tools.js +49 -0
  48. package/dist/data/tables.generated.d.ts +6 -0
  49. package/dist/data/tables.generated.js +37 -0
  50. package/dist/energy.d.ts +77 -0
  51. package/dist/energy.js +131 -0
  52. package/dist/grid.d.ts +17 -2
  53. package/dist/grid.js +43 -4
  54. package/dist/handoff.d.ts +152 -0
  55. package/dist/handoff.js +430 -0
  56. package/dist/history.d.ts +2 -0
  57. package/dist/history.js +3 -1
  58. package/dist/index.d.ts +43 -13
  59. package/dist/index.js +32 -6
  60. package/dist/job-cadence.d.ts +76 -0
  61. package/dist/job-cadence.js +240 -0
  62. package/dist/jobs.d.ts +173 -0
  63. package/dist/jobs.js +794 -0
  64. package/dist/notify.d.ts +2 -0
  65. package/dist/notify.js +2 -1
  66. package/dist/postpone.d.ts +113 -0
  67. package/dist/postpone.js +185 -0
  68. package/dist/providers/anthropic.js +7 -3
  69. package/dist/providers/base.d.ts +113 -1
  70. package/dist/providers/base.js +15 -0
  71. package/dist/providers/budget.d.ts +25 -0
  72. package/dist/providers/budget.js +57 -0
  73. package/dist/providers/defaults.js +4 -0
  74. package/dist/providers/defer.d.ts +16 -0
  75. package/dist/providers/defer.js +31 -0
  76. package/dist/providers/gemini.d.ts +1 -0
  77. package/dist/providers/gemini.js +27 -20
  78. package/dist/providers/index.d.ts +2 -2
  79. package/dist/providers/index.js +1 -1
  80. package/dist/providers/ollama.d.ts +1 -0
  81. package/dist/providers/ollama.js +26 -22
  82. package/dist/providers/openai.js +5 -5
  83. package/dist/providers/timeout.d.ts +18 -0
  84. package/dist/providers/timeout.js +33 -0
  85. package/dist/quota.d.ts +7 -2
  86. package/dist/quota.js +12 -27
  87. package/dist/readiness.d.ts +169 -0
  88. package/dist/readiness.js +254 -0
  89. package/dist/redact.d.ts +42 -0
  90. package/dist/redact.js +110 -0
  91. package/dist/region-host.d.ts +30 -0
  92. package/dist/region-host.js +69 -0
  93. package/dist/region.d.ts +102 -20
  94. package/dist/region.js +175 -23
  95. package/dist/run-session.d.ts +36 -0
  96. package/dist/run-session.js +72 -0
  97. package/dist/schedule-job.d.ts +95 -0
  98. package/dist/schedule-job.js +195 -0
  99. package/dist/scheduler.d.ts +245 -14
  100. package/dist/scheduler.js +919 -109
  101. package/dist/sign.d.ts +8 -1
  102. package/dist/sign.js +49 -3
  103. package/dist/storage/sqlite.d.ts +157 -5
  104. package/dist/storage/sqlite.js +661 -20
  105. package/dist/task-events.d.ts +102 -0
  106. package/dist/task-events.js +308 -0
  107. package/dist/tool-surface.d.ts +31 -2
  108. package/dist/tool-surface.js +359 -65
  109. package/dist/types.d.ts +246 -3
  110. package/dist/types.js +8 -1
  111. package/dist/zone-time.d.ts +22 -0
  112. package/dist/zone-time.js +76 -0
  113. package/package.json +10 -5
  114. package/dist/aggregator.d.ts.map +0 -1
  115. package/dist/aggregator.js.map +0 -1
  116. package/dist/budget.d.ts.map +0 -1
  117. package/dist/budget.js.map +0 -1
  118. package/dist/data/tables.generated.d.ts.map +0 -1
  119. package/dist/data/tables.generated.js.map +0 -1
  120. package/dist/energy.d.ts.map +0 -1
  121. package/dist/energy.js.map +0 -1
  122. package/dist/grid.d.ts.map +0 -1
  123. package/dist/grid.js.map +0 -1
  124. package/dist/history.d.ts.map +0 -1
  125. package/dist/history.js.map +0 -1
  126. package/dist/index.d.ts.map +0 -1
  127. package/dist/index.js.map +0 -1
  128. package/dist/notify.d.ts.map +0 -1
  129. package/dist/notify.js.map +0 -1
  130. package/dist/paths.d.ts.map +0 -1
  131. package/dist/paths.js.map +0 -1
  132. package/dist/providers/anthropic.d.ts.map +0 -1
  133. package/dist/providers/anthropic.js.map +0 -1
  134. package/dist/providers/base.d.ts.map +0 -1
  135. package/dist/providers/base.js.map +0 -1
  136. package/dist/providers/defaults.d.ts.map +0 -1
  137. package/dist/providers/defaults.js.map +0 -1
  138. package/dist/providers/gemini.d.ts.map +0 -1
  139. package/dist/providers/gemini.js.map +0 -1
  140. package/dist/providers/index.d.ts.map +0 -1
  141. package/dist/providers/index.js.map +0 -1
  142. package/dist/providers/ollama.d.ts.map +0 -1
  143. package/dist/providers/ollama.js.map +0 -1
  144. package/dist/providers/openai.d.ts.map +0 -1
  145. package/dist/providers/openai.js.map +0 -1
  146. package/dist/quota.d.ts.map +0 -1
  147. package/dist/quota.js.map +0 -1
  148. package/dist/recommend.d.ts.map +0 -1
  149. package/dist/recommend.js.map +0 -1
  150. package/dist/redact.d.ts.map +0 -1
  151. package/dist/redact.js.map +0 -1
  152. package/dist/region.d.ts.map +0 -1
  153. package/dist/region.js.map +0 -1
  154. package/dist/routing.d.ts.map +0 -1
  155. package/dist/routing.js.map +0 -1
  156. package/dist/scheduler.d.ts.map +0 -1
  157. package/dist/scheduler.js.map +0 -1
  158. package/dist/select-window.d.ts.map +0 -1
  159. package/dist/select-window.js.map +0 -1
  160. package/dist/sign.d.ts.map +0 -1
  161. package/dist/sign.js.map +0 -1
  162. package/dist/storage/sqlite.d.ts.map +0 -1
  163. package/dist/storage/sqlite.js.map +0 -1
  164. package/dist/tool-surface.d.ts.map +0 -1
  165. package/dist/tool-surface.js.map +0 -1
  166. package/dist/types.d.ts.map +0 -1
  167. package/dist/types.js.map +0 -1
package/dist/sign.d.ts CHANGED
@@ -82,6 +82,12 @@ export declare function loadOrCreateSigningKey(opts?: SigningKeyOptions): Signin
82
82
  * canonical form is total.
83
83
  */
84
84
  export declare function canonicalize(value: unknown): string;
85
+ /**
86
+ * `snake_case` → `camelCase`; already-camel keys pass through unchanged.
87
+ * The ledger reader (`storage/sqlite.ts`) renames a Python receipt's keys
88
+ * by this rule too, so the copy it shows and the payload checked here agree.
89
+ */
90
+ export declare function snakeToCamelKey(key: string): string;
85
91
  /**
86
92
  * The exact canonical byte string a receipt's signature covers:
87
93
  * camelCase-normalized payload minus `signature`/`signerPublicKey`,
@@ -120,7 +126,8 @@ export interface VerifyResult {
120
126
  * (v0.12 form with `signedAt` covered, or the
121
127
  * legacy v0.11 form — the reason says which).
122
128
  * - `tampered` — receipt is signed but the signature matches
123
- * none of the canonical forms of its fields.
129
+ * none of the canonical forms of its fields, or
130
+ * it carries two renderings of one field.
124
131
  * - `key-mismatch` — caller supplied a `trustedPublicKey` that
125
132
  * differs from the one bundled on the receipt.
126
133
  * - `legacy-unsigned` — pre-v0.11 receipt (no signature). The
package/dist/sign.js CHANGED
@@ -161,8 +161,12 @@ const SIGNATURE_FIELDS_ANY_RENDERING = new Set([
161
161
  "signedAt",
162
162
  "signed_at",
163
163
  ]);
164
- /** `snake_case` → `camelCase`; already-camel keys pass through unchanged. */
165
- function snakeToCamelKey(key) {
164
+ /**
165
+ * `snake_case` → `camelCase`; already-camel keys pass through unchanged.
166
+ * The ledger reader (`storage/sqlite.ts`) renames a Python receipt's keys
167
+ * by this rule too, so the copy it shows and the payload checked here agree.
168
+ */
169
+ export function snakeToCamelKey(key) {
166
170
  return key.replace(/_([a-z0-9])/g, (_m, c) => c.toUpperCase());
167
171
  }
168
172
  /**
@@ -186,6 +190,39 @@ function normalizeReceiptKeys(value) {
186
190
  }
187
191
  return value;
188
192
  }
193
+ /**
194
+ * The camelCase name that two keys of one object normalize to, at any
195
+ * depth, or undefined. No signer writes two renderings of one field
196
+ * (`actualCarbonGCo2` and `actual_carbon_g_co2`), and normalization keeps
197
+ * only the last of them, so a receipt that carries both could show one
198
+ * value and verify against the other. Null and undefined values do not
199
+ * count: normalization drops them.
200
+ */
201
+ function duplicateRendering(value) {
202
+ if (Array.isArray(value)) {
203
+ for (const v of value) {
204
+ const name = duplicateRendering(v);
205
+ if (name !== undefined)
206
+ return name;
207
+ }
208
+ return undefined;
209
+ }
210
+ if (value === null || typeof value !== "object")
211
+ return undefined;
212
+ const seen = new Set();
213
+ for (const [k, v] of Object.entries(value)) {
214
+ if (v === undefined || v === null)
215
+ continue;
216
+ const name = snakeToCamelKey(k);
217
+ if (seen.has(name))
218
+ return name;
219
+ seen.add(name);
220
+ const nested = duplicateRendering(v);
221
+ if (nested !== undefined)
222
+ return nested;
223
+ }
224
+ return undefined;
225
+ }
189
226
  /**
190
227
  * The exact canonical byte string a receipt's signature covers:
191
228
  * camelCase-normalized payload minus `signature`/`signerPublicKey`,
@@ -258,7 +295,8 @@ export function signReceipt(receipt, keyPair, now = () => new Date()) {
258
295
  * (v0.12 form with `signedAt` covered, or the
259
296
  * legacy v0.11 form — the reason says which).
260
297
  * - `tampered` — receipt is signed but the signature matches
261
- * none of the canonical forms of its fields.
298
+ * none of the canonical forms of its fields, or
299
+ * it carries two renderings of one field.
262
300
  * - `key-mismatch` — caller supplied a `trustedPublicKey` that
263
301
  * differs from the one bundled on the receipt.
264
302
  * - `legacy-unsigned` — pre-v0.11 receipt (no signature). The
@@ -275,6 +313,14 @@ export function verifyReceipt(receipt, opts = {}) {
275
313
  reason: "receipt has no `signature` / `signerPublicKey` fields (pre-v0.11 or unsigned by configuration)",
276
314
  };
277
315
  }
316
+ const duplicate = duplicateRendering(raw);
317
+ if (duplicate !== undefined) {
318
+ return {
319
+ outcome: "tampered",
320
+ signerPublicKey,
321
+ reason: `receipt carries two renderings of \`${duplicate}\`; no signer writes both, so one was added after signing`,
322
+ };
323
+ }
278
324
  if (opts.trustedPublicKey && opts.trustedPublicKey !== signerPublicKey) {
279
325
  return {
280
326
  outcome: "key-mismatch",
@@ -40,6 +40,12 @@
40
40
  * (nullable = none, ui v2); written at insert and
41
41
  * afterwards only by transitionIf ("stop series")
42
42
  * - not_before ISO-8601 earliest dispatch time (nullable, ui v2)
43
+ * - job_id the job this row is an occurrence of (nullable,
44
+ * written once at insert)
45
+ *
46
+ * The `jobs` table (TS-only; the Python core never reads it) holds floating
47
+ * recurring jobs. Every job write after the insert is a compare-and-set on
48
+ * `revision` (`updateJobIf`).
43
49
  *
44
50
  * Writes from separate processes (the UI server, the CLI, a ticker) use
45
51
  * compare-and-set: `transitionIf` updates a row only while its status is in
@@ -49,7 +55,9 @@
49
55
  * JSON-serializable are stored as `{ "_repr": "<toString>" }` so audit
50
56
  * trails survive odd values without crashing the store.
51
57
  */
52
- import type { DeadlineKind, TaskRecord, TaskStatus } from "../types.js";
58
+ import { type DeadlineKind, type JobRecord, type JobStatus, type TaskRecord, type TaskStatus } from "../types.js";
59
+ import { type Channel } from "../channels/types.js";
60
+ import { type TaskEvent, type TaskEventActor, type TaskEventInput, type TaskEventKind } from "../task-events.js";
53
61
  interface SqliteDatabase {
54
62
  exec(sql: string): void;
55
63
  prepare(sql: string): SqlitePreparedStatement;
@@ -65,31 +73,63 @@ interface SqlitePreparedStatement {
65
73
  }
66
74
  /** Filters for {@link TaskStore.list}; all given filters must match. */
67
75
  export interface TaskListFilter {
68
- status?: TaskStatus;
76
+ /** One status, or any of several. */
77
+ status?: TaskStatus | readonly TaskStatus[];
69
78
  /** Only finished (`completed` / `failed`) tasks with no read marker. */
70
79
  unread?: boolean;
71
80
  /** `absolute` also matches legacy rows with no stored kind. */
72
81
  deadlineKind?: DeadlineKind;
73
82
  /** Only occurrences of this series (ui v2). */
74
83
  seriesId?: string;
84
+ /** Only occurrences of this job. */
85
+ jobId?: string;
86
+ /** Only the tasks queued from this Claude Code session (`origin_session_id`). */
87
+ originSessionId?: string;
88
+ /** Newest first (default oldest first). */
89
+ newestFirst?: boolean;
90
+ /** At most this many rows. */
91
+ limit?: number;
75
92
  }
76
93
  export interface TaskStoreOptions {
77
94
  /** Absolute path to a SQLite file. Use ":memory:" for ephemeral storage (tests). */
78
95
  dbPath: string;
79
96
  /** Inject a pre-opened SQLite database — node:sqlite or better-sqlite3 (useful for tests). */
80
97
  db?: SqliteDatabase;
98
+ /**
99
+ * How long a write waits for another writer before it fails, in ms.
100
+ * Default 5000. A prompt hook passes a short one, so a busy daemon cannot
101
+ * hold the user's prompt.
102
+ */
103
+ busyTimeoutMs?: number;
104
+ }
105
+ /**
106
+ * Ledger meta key: a session notice covers only tasks that finished at or
107
+ * after this ISO time. Set once, by the first notice query, so an upgrade
108
+ * does not replay the history of every session.
109
+ */
110
+ export declare const SESSION_NOTICES_SINCE_META_KEY = "session_notices_since";
111
+ /** A finished task stays a session notice for this long. */
112
+ export declare const SESSION_NOTICE_MAX_AGE_MS: number;
113
+ /** One finished task a Claude Code session has not been told about. */
114
+ export interface SessionNotice {
115
+ record: TaskRecord<unknown>;
116
+ /** The result file the task asked for (`handoff.resultPath` of its body). */
117
+ resultPath?: string;
118
+ /** Details of the newest `result_file` event, when one was recorded. */
119
+ resultFile?: Record<string, unknown>;
81
120
  }
82
121
  export declare class TaskStore {
83
122
  private readonly db;
123
+ private txDepth;
84
124
  constructor(opts: TaskStoreOptions);
85
- upsert(record: TaskRecord<unknown>): void;
125
+ upsert(record: TaskRecord<unknown>, event?: TaskEventInput): void;
86
126
  /**
87
127
  * Insert a row only if no row with this id exists (ui v2). Returns true iff
88
128
  * this call inserted it. Series rollover uses it with a deterministic
89
129
  * successor id, so two dispatchers finishing the same occurrence create
90
130
  * exactly one successor.
91
131
  */
92
- insertIfAbsent(record: TaskRecord<unknown>): boolean;
132
+ insertIfAbsent(record: TaskRecord<unknown>, event?: TaskEventInput): boolean;
93
133
  /**
94
134
  * Compare-and-set write (ui v2): store the mutable columns of `record`, but
95
135
  * only while the row's status is one of `expectedStatuses`. Returns false,
@@ -102,8 +142,98 @@ export declare class TaskStore {
102
142
  * that earlier read: a write computed from a stale read (a forecast fetch
103
143
  * that awaited while the UI ran a task now or pinned it) then misses
104
144
  * instead of overwriting the newer timing.
145
+ *
146
+ * `event`, when given, is written to `task_events` in the same
147
+ * transaction, and only when the update hit.
148
+ */
149
+ transitionIf(record: TaskRecord<unknown>, expectedStatuses: readonly TaskStatus[], unchangedSince?: TaskRecord<unknown>, event?: TaskEventInput): boolean;
150
+ /** Append one event to a task's log in its own transaction. */
151
+ recordEvent(taskId: string, event: TaskEventInput): void;
152
+ /**
153
+ * A task's events, oldest first. `limit` keeps the newest `limit` rows.
154
+ * Rows with an unknown kind (a newer writer) are skipped.
155
+ */
156
+ listTaskEvents(taskId: string, opts?: {
157
+ limit?: number;
158
+ }): TaskEvent[];
159
+ /**
160
+ * Events of every task with `at` in (`since`, `until`], oldest first,
161
+ * optionally of the given kinds only. Rows with an unknown kind are skipped.
162
+ */
163
+ listEventsSince(since: string, until: string, kinds?: readonly TaskEventKind[]): TaskEvent[];
164
+ /**
165
+ * A task's events with an `id` greater than `afterId`, oldest first: the
166
+ * cursor of `queue events --after`, since `id` grows with each insert.
167
+ * Rows with an unknown kind are skipped.
168
+ */
169
+ listTaskEventsAfter(taskId: string, afterId: number): TaskEvent[];
170
+ /**
171
+ * Finished tasks a Claude Code session has not been told about, oldest
172
+ * first: `completed`, `failed` or `cancelled`, queued from `sessionId`
173
+ * (every session when absent) with a checked origin in the body, no
174
+ * `notified` event for this finish (its `completed_at`; a retried task
175
+ * that finishes again is a new notice), and finished at or after
176
+ * {@link SESSION_NOTICES_SINCE_META_KEY} and within
177
+ * {@link SESSION_NOTICE_MAX_AGE_MS}. A completed task that asked for a
178
+ * result file waits until its `result_file` event exists. A person's read
179
+ * marker does not matter here.
105
180
  */
106
- transitionIf(record: TaskRecord<unknown>, expectedStatuses: readonly TaskStatus[], unchangedSince?: TaskRecord<unknown>): boolean;
181
+ listSessionNotices(opts?: {
182
+ sessionId?: string;
183
+ now?: Date;
184
+ }): SessionNotice[];
185
+ /**
186
+ * Record that a session was told about a task's current finish: a
187
+ * `notified` event whose details carry the task's `completed_at`, written
188
+ * only when no `notified` event has that `completed_at` yet. Returns true
189
+ * iff this call wrote it, so the prompt hook, `queue wait` and a wake never
190
+ * claim the same finish twice, and a retried task that finishes again is
191
+ * claimed again. A task that does not exist is never claimed.
192
+ */
193
+ claimNotice(taskId: string, details: {
194
+ via: string;
195
+ session_id: string;
196
+ }, actor?: TaskEventActor): boolean;
197
+ /**
198
+ * Completed tasks that asked for a result file (`handoff.resultPath` in
199
+ * the body) and have no `result_file` event yet, oldest first, whichever
200
+ * core finished them. A body that is not valid JSON is skipped.
201
+ */
202
+ listResultFilesDue(): TaskRecord<unknown>[];
203
+ /**
204
+ * Record the outcome of a task's result file: a `result_file` event
205
+ * (actor `tick`), written only when the task has none yet. Returns true
206
+ * iff this call wrote it.
207
+ */
208
+ recordResultFile(taskId: string, details: Record<string, unknown>): boolean;
209
+ /**
210
+ * Set {@link SESSION_NOTICES_SINCE_META_KEY} to `at` unless it is set. The
211
+ * scheduler calls it when it queues a task from a session, so that task's
212
+ * notice is not lost when the first notice query runs only after it
213
+ * finished. Best-effort: a read-only ledger is left alone.
214
+ */
215
+ startSessionNotices(at?: Date): void;
216
+ /**
217
+ * {@link SESSION_NOTICES_SINCE_META_KEY}, set to `now` on first use; `now`
218
+ * when the ledger cannot be written. Read first, so a set key costs no
219
+ * write lock (the prompt hook runs this on every delivery).
220
+ */
221
+ private noticesSince;
222
+ /** Completed and failed tasks with `completed_at` in (`since`, `until`], oldest first (both cores write `completed_at`). */
223
+ listFinishedSince(since: string, until: string): TaskRecord<unknown>[];
224
+ private insertEvent;
225
+ /**
226
+ * Run `fn` in one write transaction (`BEGIN IMMEDIATE`), rolled back when
227
+ * it throws. Re-entrant: a nested call joins the open transaction.
228
+ */
229
+ private tx;
230
+ /**
231
+ * The receipt of `taskId` exactly as stored, in either key rendering, or
232
+ * undefined. Signature checks read it: a Python receipt signed by v0.11 or
233
+ * older verifies only against its original snake_case keys, which
234
+ * {@link get} renames.
235
+ */
236
+ storedReceipt(taskId: string): Record<string, unknown> | undefined;
107
237
  get(taskId: string): TaskRecord<unknown> | undefined;
108
238
  list(filter?: TaskListFilter): TaskRecord<unknown>[];
109
239
  /**
@@ -123,6 +253,14 @@ export declare class TaskStore {
123
253
  getMeta(key: string): string | undefined;
124
254
  /** Write one ledger-wide meta value. */
125
255
  setMeta(key: string, value: string): void;
256
+ /** Remove one meta value; a missing key is a no-op. */
257
+ deleteMeta(key: string): void;
258
+ /** Every channel row, oldest first; a row with an unknown kind or bad JSON is skipped. */
259
+ listChannels(): Channel[];
260
+ /** Insert or replace a channel row (pairing the same chat again replaces it). */
261
+ insertChannel(channel: Channel): void;
262
+ /** Remove a channel; false when no row had that id. */
263
+ removeChannel(id: string): boolean;
126
264
  /**
127
265
  * Conditional write for the quota sweep: store the columns a reschedule
128
266
  * (or a budget failure) changes, but only while the row is still pending
@@ -163,6 +301,20 @@ export declare class TaskStore {
163
301
  recordBudgetAlert(windowKind: string, windowStart: string, thresholdG: number, actualG: number, taskId: string | undefined, alertedAt: string): boolean;
164
302
  /** True if an alert has already fired for this (windowKind, windowStart, thresholdG). */
165
303
  hasBudgetAlert(windowKind: string, windowStart: string, thresholdG: number): boolean;
304
+ /** Insert a new job row. Throws when the id exists. */
305
+ insertJob(job: JobRecord): void;
306
+ getJob(jobId: string): JobRecord | undefined;
307
+ /** Jobs, oldest first; `status` limits the list to one or several statuses. */
308
+ listJobs(filter?: {
309
+ status?: JobStatus | readonly JobStatus[];
310
+ }): JobRecord[];
311
+ /**
312
+ * Compare-and-set job write: store the mutable columns of `next` only while
313
+ * the row's revision is `expectedRevision`, and add one to the revision.
314
+ * Returns false, writing nothing, when another writer got there first.
315
+ * `job_id`, `created_at`, `created_by` and the origin columns never change.
316
+ */
317
+ updateJobIf(next: JobRecord, expectedRevision: number): boolean;
166
318
  close(): void;
167
319
  }
168
320
  export {};