@tidegap/core 0.20.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/channels/digest.js +3 -3
- package/dist/channels/format.d.ts +11 -0
- package/dist/channels/format.js +26 -8
- package/dist/energy.d.ts +7 -0
- package/dist/energy.js +7 -0
- package/dist/handoff.d.ts +22 -3
- package/dist/handoff.js +69 -17
- package/dist/history.d.ts +15 -0
- package/dist/history.js +11 -0
- package/dist/index.d.ts +17 -13
- package/dist/index.js +12 -10
- package/dist/jobs.d.ts +25 -15
- package/dist/jobs.js +186 -63
- package/dist/notify.d.ts +9 -0
- package/dist/notify.js +17 -3
- package/dist/providers/anthropic.js +8 -6
- package/dist/providers/base.d.ts +40 -9
- package/dist/providers/base.js +29 -4
- package/dist/providers/gemini.d.ts +3 -0
- package/dist/providers/gemini.js +9 -6
- package/dist/providers/http.d.ts +40 -0
- package/dist/providers/http.js +82 -0
- package/dist/providers/index.d.ts +1 -1
- package/dist/providers/index.js +1 -1
- package/dist/providers/ollama.d.ts +3 -0
- package/dist/providers/ollama.js +8 -5
- package/dist/providers/openai.js +7 -5
- package/dist/providers/timeout.d.ts +26 -8
- package/dist/providers/timeout.js +53 -15
- package/dist/readiness.d.ts +39 -3
- package/dist/readiness.js +73 -1
- package/dist/run-limits.d.ts +268 -0
- package/dist/run-limits.js +572 -0
- package/dist/schedule-job.d.ts +23 -0
- package/dist/schedule-job.js +48 -0
- package/dist/scheduler.d.ts +159 -17
- package/dist/scheduler.js +482 -128
- package/dist/storage/sqlite.d.ts +28 -2
- package/dist/storage/sqlite.js +65 -5
- package/dist/task-events.d.ts +19 -4
- package/dist/task-events.js +42 -5
- package/dist/tool-surface.js +38 -7
- package/dist/types.d.ts +31 -10
- package/dist/types.js +1 -3
- package/package.json +5 -2
package/dist/channels/digest.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { localTimeLabel, MORNING_START_H } from "../postpone.js";
|
|
11
11
|
import { problemLine } from "../readiness.js";
|
|
12
|
-
import { messageTitle } from "./format.js";
|
|
12
|
+
import { cutPreview, messageTitle } from "./format.js";
|
|
13
13
|
/**
|
|
14
14
|
* Ledger meta key: ISO-8601 end of the last summary window. An empty day
|
|
15
15
|
* moves it too, so it is not proof of a send; see {@link DIGEST_SENT_META_KEY}.
|
|
@@ -55,14 +55,14 @@ export function digestDue(now, lastIso, at = DEFAULT_DIGEST_AT) {
|
|
|
55
55
|
const due = now.getTime() >= today.getTime() && !(Number.isFinite(last) && last >= midnight);
|
|
56
56
|
return { due, since };
|
|
57
57
|
}
|
|
58
|
-
/**
|
|
58
|
+
/** Most characters (code points, ellipsis included) of a run preview a job line quotes. */
|
|
59
59
|
const JOB_PREVIEW_CHARS = 60;
|
|
60
60
|
/** `Mail triage: ok 03:12, "3 messages need a reply..." - next Fri 02:00` (KTD11). */
|
|
61
61
|
export function jobDigestText(job) {
|
|
62
62
|
const { last } = job;
|
|
63
63
|
const when = last.late ? `ran late at ${last.at}` : `${last.outcome} ${last.at}`;
|
|
64
64
|
const preview = last.preview?.replace(/\s+/g, " ").trim();
|
|
65
|
-
const quoted = preview ? `"${preview
|
|
65
|
+
const quoted = preview ? `"${cutPreview(preview, JOB_PREVIEW_CHARS)}"` : "";
|
|
66
66
|
const next = job.next ? ` - next ${job.next}` : "";
|
|
67
67
|
if (job.runs <= 1) {
|
|
68
68
|
const late = last.late && last.outcome === "failed" ? ` (${last.outcome})` : "";
|
|
@@ -51,6 +51,17 @@ export declare const CALLBACK_ACTIONS: Readonly<Record<string, CallbackActionNam
|
|
|
51
51
|
export declare const CALLBACK_PRESETS: Readonly<Record<string, PostponePreset>>;
|
|
52
52
|
/** True when the task asked for receipt redaction (`redactInReceipt` with patterns): no result text leaves the machine. */
|
|
53
53
|
export declare function isRedactedTask(record: TaskRecord<unknown>): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* The one-line preview of a run, the same on the jobs page and in the
|
|
56
|
+
* digest (KTD6): a failed task's first error line with visible text, a
|
|
57
|
+
* completed task's result text unless it redacts its receipt, else
|
|
58
|
+
* undefined. Default-redacted, control characters removed, whitespace runs
|
|
59
|
+
* joined; a longer text is cut to `maxChars - 1` code points plus "…", so
|
|
60
|
+
* the result never exceeds `maxChars`.
|
|
61
|
+
*/
|
|
62
|
+
export declare function runPreview(record: TaskRecord<unknown>, maxChars: number): string | undefined;
|
|
63
|
+
/** `text` cut to `maxChars - 1` code points plus "…" when longer, so it never exceeds `maxChars` (KTD6). */
|
|
64
|
+
export declare function cutPreview(text: string, maxChars: number): string;
|
|
54
65
|
/** The title a message shows: `displayTitle`, one line, at most 80 characters, else the task id. */
|
|
55
66
|
export declare function messageTitle(record: TaskRecord<unknown>): string;
|
|
56
67
|
/** The title a task event's message shows: the job's title for a job occurrence, else {@link messageTitle}. */
|
package/dist/channels/format.js
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
*/
|
|
21
21
|
import { displayTitle, stripControlChars, taskActions, taskResultText } from "../history.js";
|
|
22
22
|
import { JOB_AUTO_PAUSE_FAILURES, jobAutoPauseReason } from "../jobs.js";
|
|
23
|
-
import { clip } from "../notify.js";
|
|
23
|
+
import { clip, firstErrorLine, oneLine } from "../notify.js";
|
|
24
24
|
import { localTimeLabel } from "../postpone.js";
|
|
25
25
|
import { problemLine, TICKER_CODES } from "../readiness.js";
|
|
26
26
|
import { isValidTimeZone } from "../zone-time.js";
|
|
@@ -62,6 +62,27 @@ export function isRedactedTask(record) {
|
|
|
62
62
|
return false;
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* The one-line preview of a run, the same on the jobs page and in the
|
|
67
|
+
* digest (KTD6): a failed task's first error line with visible text, a
|
|
68
|
+
* completed task's result text unless it redacts its receipt, else
|
|
69
|
+
* undefined. Default-redacted, control characters removed, whitespace runs
|
|
70
|
+
* joined; a longer text is cut to `maxChars - 1` code points plus "…", so
|
|
71
|
+
* the result never exceeds `maxChars`.
|
|
72
|
+
*/
|
|
73
|
+
export function runPreview(record, maxChars) {
|
|
74
|
+
let text;
|
|
75
|
+
if (record.status === "failed")
|
|
76
|
+
text = firstErrorLine(record.error, Infinity);
|
|
77
|
+
else if (record.status === "completed" && !isRedactedTask(record))
|
|
78
|
+
text = oneLine(taskResultText(record) ?? "");
|
|
79
|
+
return text ? cutPreview(text, maxChars) : undefined;
|
|
80
|
+
}
|
|
81
|
+
/** `text` cut to `maxChars - 1` code points plus "…" when longer, so it never exceeds `maxChars` (KTD6). */
|
|
82
|
+
export function cutPreview(text, maxChars) {
|
|
83
|
+
const chars = Array.from(text);
|
|
84
|
+
return chars.length > maxChars ? `${chars.slice(0, maxChars - 1).join("")}…` : text;
|
|
85
|
+
}
|
|
65
86
|
/** The title a message shows: `displayTitle`, one line, at most 80 characters, else the task id. */
|
|
66
87
|
export function messageTitle(record) {
|
|
67
88
|
const t = stripControlChars(displayTitle(record) ?? "").trim();
|
|
@@ -129,11 +150,8 @@ export function taskDoneMessage(record, now = new Date(), jobTitle) {
|
|
|
129
150
|
const buttons = callbackFits(record.taskId) ? [[{ text: "Result", data: encodeCallback("result", record.taskId) }]] : undefined;
|
|
130
151
|
return { text: lines.join("\n"), ...(buttons ? { buttons } : {}) };
|
|
131
152
|
}
|
|
132
|
-
/** The first
|
|
133
|
-
|
|
134
|
-
const line = (error ?? "").split(/\r?\n/).find((l) => l.trim()) ?? "unknown error";
|
|
135
|
-
return clip(stripControlChars(redactPrompt(line, undefined)).trim(), max);
|
|
136
|
-
}
|
|
153
|
+
/** The first error line with visible text (notify's firstErrorLine), at most `max` characters, or "unknown error". */
|
|
154
|
+
const errorLine = (error, max = 300) => firstErrorLine(error, max) ?? "unknown error";
|
|
137
155
|
/**
|
|
138
156
|
* Task failed: title, time, the first error line, the show command. No
|
|
139
157
|
* buttons. A job occurrence (`jobTitle`) leads with `<job title>: failed`.
|
|
@@ -144,14 +162,14 @@ export function taskFailedMessage(record, now = new Date(), jobTitle) {
|
|
|
144
162
|
const at = when(record.completedAt, now);
|
|
145
163
|
if (at)
|
|
146
164
|
lines.push(`Failed ${at}`);
|
|
147
|
-
lines.push(
|
|
165
|
+
lines.push(errorLine(record.error));
|
|
148
166
|
lines.push(`Run \`${showCommand(record)}\`.`);
|
|
149
167
|
return { text: lines.join("\n") };
|
|
150
168
|
}
|
|
151
169
|
/** The first line of an auto-pause notice (jobs KTD10): `job '<title>' paused after 3 failures: <reason>`. */
|
|
152
170
|
export function jobPausedTitle(notice) {
|
|
153
171
|
const title = cleanJobTitle(notice.title) ?? notice.jobId;
|
|
154
|
-
return `job '${title}' paused after ${JOB_AUTO_PAUSE_FAILURES} failures: ${
|
|
172
|
+
return `job '${title}' paused after ${JOB_AUTO_PAUSE_FAILURES} failures: ${errorLine(notice.reason, 200)}`;
|
|
155
173
|
}
|
|
156
174
|
/** The auto-pause notice: the sentence, then how to resume. No buttons. */
|
|
157
175
|
export function jobPausedMessage(notice) {
|
package/dist/energy.d.ts
CHANGED
|
@@ -195,6 +195,13 @@ export interface ModelUsageBill {
|
|
|
195
195
|
/** The receipt's `tokenCounts` over every billed count; absent when each was reported. */
|
|
196
196
|
tokenCounts?: TokenCounts;
|
|
197
197
|
}
|
|
198
|
+
/**
|
|
199
|
+
* The words every surface prints for a receipt's `tokenCounts` (batch 27, R6):
|
|
200
|
+
* `tidegap verify`, the MCP receipt text and the page (`ui/detail.js`, which
|
|
201
|
+
* cannot import the core; a CLI test holds its copy to these).
|
|
202
|
+
*/
|
|
203
|
+
export declare const TOKEN_COUNTS_PARTIAL_TEXT = "partial (a token count was not reported; billed at the typical count)";
|
|
204
|
+
export declare const TOKEN_COUNTS_TYPICAL_TEXT = "typical (no token count reported; billed as a typical call)";
|
|
198
205
|
/** A single-model run's raw counts, as an adapter or a Batch result reports them. */
|
|
199
206
|
export interface RunUsage {
|
|
200
207
|
inputTokens?: unknown;
|
package/dist/energy.js
CHANGED
|
@@ -216,6 +216,13 @@ function counted(u) {
|
|
|
216
216
|
* otherwise undefined, which `estimateEnergyKwh` bills at the typical count.
|
|
217
217
|
*/
|
|
218
218
|
const billedInput = (c) => c.inputTokens ?? (c.partialInputTokens !== undefined ? Math.max(c.partialInputTokens, TYPICAL_INPUT_TOKENS) : undefined);
|
|
219
|
+
/**
|
|
220
|
+
* The words every surface prints for a receipt's `tokenCounts` (batch 27, R6):
|
|
221
|
+
* `tidegap verify`, the MCP receipt text and the page (`ui/detail.js`, which
|
|
222
|
+
* cannot import the core; a CLI test holds its copy to these).
|
|
223
|
+
*/
|
|
224
|
+
export const TOKEN_COUNTS_PARTIAL_TEXT = "partial (a token count was not reported; billed at the typical count)";
|
|
225
|
+
export const TOKEN_COUNTS_TYPICAL_TEXT = "typical (no token count reported; billed as a typical call)";
|
|
219
226
|
/**
|
|
220
227
|
* The receipt's `tokenCounts` over the counts a bill used (KTD1): undefined
|
|
221
228
|
* when every count was reported in full, "typical" when no count and no
|
package/dist/handoff.d.ts
CHANGED
|
@@ -134,6 +134,23 @@ export declare function resultFileText(details: Record<string, unknown> | undefi
|
|
|
134
134
|
export declare function wakeError(wake: unknown, origin: {
|
|
135
135
|
agent?: unknown;
|
|
136
136
|
} | undefined, sessionId: unknown): string | undefined;
|
|
137
|
+
/**
|
|
138
|
+
* The default ledger, `~/.tidegap/queue.db`: the one the CLI, the tick
|
|
139
|
+
* and the plugin's hooks read when no path is given. When only the legacy
|
|
140
|
+
* `~/.ebb/queue.sqlite` exists, that file is returned, so its data stays
|
|
141
|
+
* visible. The MCP server's own default is `queue.db` with no legacy
|
|
142
|
+
* fallback; it creates that file at start, so the two agree from then on.
|
|
143
|
+
*/
|
|
144
|
+
export declare function defaultDbPath(): string;
|
|
145
|
+
/**
|
|
146
|
+
* True when `dbPath` is the default ledger. The session notice and wake
|
|
147
|
+
* markers under `~/.tidegap/sessions` belong to it: the plugin's hooks
|
|
148
|
+
* read that ledger only, so a pass over another ledger must neither
|
|
149
|
+
* create nor remove them, and a wake for a task in another ledger could
|
|
150
|
+
* never fire. Compares real paths; a missing file compares by
|
|
151
|
+
* its folder's real path and its name.
|
|
152
|
+
*/
|
|
153
|
+
export declare function isDefaultLedger(dbPath: string): boolean;
|
|
137
154
|
/** 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). */
|
|
138
155
|
export declare const WAKE_MARKER_MAX_AGE_MS: number;
|
|
139
156
|
/** `~/.tidegap/sessions/wake`: one marker per session with a task to wake it for. */
|
|
@@ -142,9 +159,11 @@ export declare function wakeMarkersDir(home?: string): string;
|
|
|
142
159
|
export declare function wakeMarkerPath(sessionId: string, dir?: string): string | undefined;
|
|
143
160
|
/**
|
|
144
161
|
* Create or refresh a session's wake marker (file `0600`, folder `0700`),
|
|
145
|
-
* so the plugin's Stop hook starts its waiter
|
|
146
|
-
* or undefined. Something other than a regular file at
|
|
147
|
-
* alone and reported.
|
|
162
|
+
* so the plugin's Stop hook starts its waiter; its time is `now`. Returns
|
|
163
|
+
* the error message, or undefined. Something other than a regular file at
|
|
164
|
+
* the path is left alone and reported. A waiter or the sweep may remove
|
|
165
|
+
* or write the marker at the same moment: a refresh that finds it gone
|
|
166
|
+
* creates it, and a create that finds one there refreshes it.
|
|
148
167
|
*/
|
|
149
168
|
export declare function writeWakeMarker(sessionId: string, dir?: string, now?: Date): string | undefined;
|
|
150
169
|
/** Remove a session's wake marker; a missing one is fine. */
|
package/dist/handoff.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* and only Tidegap writes a result file, as a new file, never through a
|
|
10
10
|
* link.
|
|
11
11
|
*/
|
|
12
|
-
import { chmodSync, lstatSync, mkdirSync, realpathSync, statSync, unlinkSync, utimesSync, writeFileSync } from "node:fs";
|
|
12
|
+
import { chmodSync, existsSync, lstatSync, mkdirSync, realpathSync, statSync, unlinkSync, utimesSync, writeFileSync } from "node:fs";
|
|
13
13
|
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";
|
|
@@ -373,6 +373,47 @@ export function wakeError(wake, origin, sessionId) {
|
|
|
373
373
|
}
|
|
374
374
|
return undefined;
|
|
375
375
|
}
|
|
376
|
+
/**
|
|
377
|
+
* The default ledger, `~/.tidegap/queue.db`: the one the CLI, the tick
|
|
378
|
+
* and the plugin's hooks read when no path is given. When only the legacy
|
|
379
|
+
* `~/.ebb/queue.sqlite` exists, that file is returned, so its data stays
|
|
380
|
+
* visible. The MCP server's own default is `queue.db` with no legacy
|
|
381
|
+
* fallback; it creates that file at start, so the two agree from then on.
|
|
382
|
+
*/
|
|
383
|
+
export function defaultDbPath() {
|
|
384
|
+
const newPath = join(resolveTidegapHome(), "queue.db");
|
|
385
|
+
const legacyPath = join(homedir(), ".ebb", "queue.sqlite");
|
|
386
|
+
if (!existsSync(newPath) && existsSync(legacyPath))
|
|
387
|
+
return legacyPath;
|
|
388
|
+
return newPath;
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* True when `dbPath` is the default ledger. The session notice and wake
|
|
392
|
+
* markers under `~/.tidegap/sessions` belong to it: the plugin's hooks
|
|
393
|
+
* read that ledger only, so a pass over another ledger must neither
|
|
394
|
+
* create nor remove them, and a wake for a task in another ledger could
|
|
395
|
+
* never fire. Compares real paths; a missing file compares by
|
|
396
|
+
* its folder's real path and its name.
|
|
397
|
+
*/
|
|
398
|
+
export function isDefaultLedger(dbPath) {
|
|
399
|
+
if (dbPath === ":memory:")
|
|
400
|
+
return false;
|
|
401
|
+
// A missing file resolves through its folder, so a linked home still matches.
|
|
402
|
+
const real = (path) => {
|
|
403
|
+
try {
|
|
404
|
+
return realpathSync.native(path);
|
|
405
|
+
}
|
|
406
|
+
catch {
|
|
407
|
+
try {
|
|
408
|
+
return join(realpathSync.native(dirname(path)), basename(path));
|
|
409
|
+
}
|
|
410
|
+
catch {
|
|
411
|
+
return resolve(path);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
return real(dbPath) === real(defaultDbPath());
|
|
416
|
+
}
|
|
376
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). */
|
|
377
418
|
export const WAKE_MARKER_MAX_AGE_MS = 12 * 3_600_000;
|
|
378
419
|
/** `~/.tidegap/sessions/wake`: one marker per session with a task to wake it for. */
|
|
@@ -385,9 +426,11 @@ export function wakeMarkerPath(sessionId, dir = wakeMarkersDir()) {
|
|
|
385
426
|
}
|
|
386
427
|
/**
|
|
387
428
|
* Create or refresh a session's wake marker (file `0600`, folder `0700`),
|
|
388
|
-
* so the plugin's Stop hook starts its waiter
|
|
389
|
-
* or undefined. Something other than a regular file at
|
|
390
|
-
* alone and reported.
|
|
429
|
+
* so the plugin's Stop hook starts its waiter; its time is `now`. Returns
|
|
430
|
+
* the error message, or undefined. Something other than a regular file at
|
|
431
|
+
* the path is left alone and reported. A waiter or the sweep may remove
|
|
432
|
+
* or write the marker at the same moment: a refresh that finds it gone
|
|
433
|
+
* creates it, and a create that finds one there refreshes it.
|
|
391
434
|
*/
|
|
392
435
|
export function writeWakeMarker(sessionId, dir = wakeMarkersDir(), now = new Date()) {
|
|
393
436
|
const path = wakeMarkerPath(sessionId, dir);
|
|
@@ -396,20 +439,29 @@ export function writeWakeMarker(sessionId, dir = wakeMarkersDir(), now = new Dat
|
|
|
396
439
|
try {
|
|
397
440
|
mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
398
441
|
chmodSync(dir, 0o700);
|
|
399
|
-
let
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
442
|
+
for (let attempt = 0;; attempt++) {
|
|
443
|
+
let there;
|
|
444
|
+
try {
|
|
445
|
+
there = lstatSync(path);
|
|
446
|
+
}
|
|
447
|
+
catch {
|
|
448
|
+
there = undefined;
|
|
449
|
+
}
|
|
450
|
+
if (there && !there.isFile())
|
|
451
|
+
return `${path} is not a regular file`;
|
|
452
|
+
try {
|
|
453
|
+
if (!there)
|
|
454
|
+
writeFileSync(path, `${now.toISOString()}\n`, { mode: 0o600, flag: "wx" });
|
|
455
|
+
utimesSync(path, now, now);
|
|
456
|
+
return undefined;
|
|
457
|
+
}
|
|
458
|
+
catch (err) {
|
|
459
|
+
// Removed or created by another writer since the look: look once more.
|
|
460
|
+
const code = err.code;
|
|
461
|
+
if (attempt > 0 || (code !== "ENOENT" && code !== "EEXIST"))
|
|
462
|
+
throw err;
|
|
463
|
+
}
|
|
405
464
|
}
|
|
406
|
-
if (there && !there.isFile())
|
|
407
|
-
return `${path} is not a regular file`;
|
|
408
|
-
if (there)
|
|
409
|
-
utimesSync(path, now, now);
|
|
410
|
-
else
|
|
411
|
-
writeFileSync(path, `${now.toISOString()}\n`, { mode: 0o600, flag: "wx" });
|
|
412
|
-
return undefined;
|
|
413
465
|
}
|
|
414
466
|
catch (err) {
|
|
415
467
|
return err.message;
|
package/dist/history.d.ts
CHANGED
|
@@ -70,7 +70,22 @@ export interface TaskActions {
|
|
|
70
70
|
reply: boolean;
|
|
71
71
|
/** Finished (completed or failed): mark read or unread. */
|
|
72
72
|
markRead: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Failed provider-call one-off task, a `command` task included: retry it
|
|
75
|
+
* by hand (due on the next tick). A run of a job, and a run that stopped
|
|
76
|
+
* during its Batch submit, are refused.
|
|
77
|
+
*/
|
|
78
|
+
retry: boolean;
|
|
73
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* The error of a row whose Batch submit a forced stop interrupted (batch 25
|
|
82
|
+
* KTD5). The provider may hold a batch for it, so no path runs it again:
|
|
83
|
+
* `retryTask` and the Python `retry_task` refuse it, and the sweep does not
|
|
84
|
+
* retry it. The text is the marker; `test/fixtures/interrupted-batch-submit.json`
|
|
85
|
+
* shares it with the Python core. It lives here, not in `jobs.ts`, so this
|
|
86
|
+
* module imports nothing from `jobs.ts` (which imports `deriveTitle` from here).
|
|
87
|
+
*/
|
|
88
|
+
export declare const BATCH_SUBMIT_INTERRUPTED_ERROR = "interrupted: the tick stopped during the Batch submit; the provider may have accepted the batch, so check the provider's batch list before you enqueue the task again";
|
|
74
89
|
/** True when the task repeats (a stored rule other than `none`). */
|
|
75
90
|
export declare function isRepeating(record: Pick<TaskRecord<unknown>, "repeat">): boolean;
|
|
76
91
|
/** Allowed actions for `record`; see {@link TaskActions}. */
|
package/dist/history.js
CHANGED
|
@@ -130,6 +130,15 @@ export function deadlineKindLabel(record, quota = {}) {
|
|
|
130
130
|
const resetAt = new Date(deadlineMs + schedule.marginH * 3_600_000);
|
|
131
131
|
return `${label}, reset_at ${resetAt.toISOString()}, margin_h ${schedule.marginH}`;
|
|
132
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* The error of a row whose Batch submit a forced stop interrupted (batch 25
|
|
135
|
+
* KTD5). The provider may hold a batch for it, so no path runs it again:
|
|
136
|
+
* `retryTask` and the Python `retry_task` refuse it, and the sweep does not
|
|
137
|
+
* retry it. The text is the marker; `test/fixtures/interrupted-batch-submit.json`
|
|
138
|
+
* shares it with the Python core. It lives here, not in `jobs.ts`, so this
|
|
139
|
+
* module imports nothing from `jobs.ts` (which imports `deriveTitle` from here).
|
|
140
|
+
*/
|
|
141
|
+
export const BATCH_SUBMIT_INTERRUPTED_ERROR = "interrupted: the tick stopped during the Batch submit; the provider may have accepted the batch, so check the provider's batch list before you enqueue the task again";
|
|
133
142
|
const PENDING = new Set(["queued", "scheduled", "submitted", "running"]);
|
|
134
143
|
/** True when the task repeats (a stored rule other than `none`). */
|
|
135
144
|
export function isRepeating(record) {
|
|
@@ -150,6 +159,8 @@ export function taskActions(record) {
|
|
|
150
159
|
// A command job's occurrence has no conversation to continue.
|
|
151
160
|
reply: record.status === "completed" && providerCall && spec?.provider !== "command",
|
|
152
161
|
markRead: record.status === "completed" || record.status === "failed",
|
|
162
|
+
// The same rule as `Scheduler.retryLater` refuses by.
|
|
163
|
+
retry: record.status === "failed" && providerCall && !record.jobId && record.error !== BATCH_SUBMIT_INTERRUPTED_ERROR,
|
|
153
164
|
};
|
|
154
165
|
}
|
|
155
166
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -39,15 +39,15 @@
|
|
|
39
39
|
* plugin, so its `os.environ` fallbacks stay for ergonomics.
|
|
40
40
|
*/
|
|
41
41
|
export { CarbonBudgetExceededError, COMMAND_MAX_CHARS, defer, InvalidDeadlineError, LAST_TICK_META_KEY, pickBestWindow, Scheduler, TaskActionError, } from "./scheduler.js";
|
|
42
|
-
export type { ReplyOptions, RescheduleTarget, SchedulerOptions, ActorOptions, TickAdapters, TickOptions, } from "./scheduler.js";
|
|
42
|
+
export type { ReplyOptions, RescheduleTarget, SchedulerOptions, ActorOptions, RetryResult, TickAdapters, TickDetails, TickOptions, LockedTick, } from "./scheduler.js";
|
|
43
43
|
export { recommendWindow } from "./recommend.js";
|
|
44
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
45
|
export type { TaskActions } from "./history.js";
|
|
46
|
-
export { assessReadiness, 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
|
-
export type { DaemonFact, Readiness, ReadinessCode, ReadinessFacts, ReadinessProblem, RunnerFact, SleepReading, TickRunnersSnapshot, } from "./readiness.js";
|
|
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
|
+
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, 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, 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
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";
|
|
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";
|
|
@@ -55,10 +55,10 @@ export { selectWindow, inDeadlineEntries, TOLERANCE_FLOOR_G, TOLERANCE_FRACTION,
|
|
|
55
55
|
export type { SelectWindowOptions, SelectWindowResult, } from "./select-window.js";
|
|
56
56
|
export { ASSUMED_KWH_PER_CALL, classifyBand, aggregateStats, aggregateByRegion, bandHistogram, achievements, } from "./aggregator.js";
|
|
57
57
|
export type { CarbonStats, RegionStats, BandHistogram, Achievement, } from "./aggregator.js";
|
|
58
|
-
export { NOTIFY_PREVIEW_CHARS, WIN_NOTIFY_BODY_VAR, WIN_NOTIFY_TITLE_VAR, osNotifyCommand, taskNotificationContent, } from "./notify.js";
|
|
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, handoffCwdError, 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, WAKE_MARKER_MAX_AGE_MS, 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";
|
|
@@ -73,27 +73,31 @@ export { DEFAULT_JOB_CAPS } from "./types.js";
|
|
|
73
73
|
export { guaranteeText, isCalendarAnchored, JobScheduleError, MAX_EVERY_HOURS, MIN_EVERY_HOURS, nextOccurrence, parseCadence, parseWindow, 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,
|
|
77
|
-
export type { JobActionOptions, JobHistoryEntry, JobInput, JobPatch, JobSweepResult, JobUpdateOptions } from "./jobs.js";
|
|
78
|
-
export { AnthropicAdapter, OpenAIAdapter, GeminiAdapter, OllamaAdapter, DEFAULT_MODEL_BY_PROVIDER, NonRetryableError, ProviderRefusalError, } from "./providers/index.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";
|
|
78
|
+
export { AnthropicAdapter, OpenAIAdapter, GeminiAdapter, OllamaAdapter, DEFAULT_MODEL_BY_PROVIDER, NonRetryableError, permanentError, ProviderRefusalError, } from "./providers/index.js";
|
|
79
79
|
export { budgetMaxTokens, BudgetExceededError } from "./providers/budget.js";
|
|
80
|
-
export { MAX_TIMER_MS } from "./providers/timeout.js";
|
|
80
|
+
export { MAX_TIMER_MS, withLlmTimeout } from "./providers/timeout.js";
|
|
81
|
+
export type { LlmRequestOptions } from "./providers/timeout.js";
|
|
82
|
+
export { httpFetch, limitDispatcher } from "./providers/http.js";
|
|
81
83
|
export { redactPrompt, SCRUB_MIN_LENGTH, scrubCutEdges, scrubValues } from "./redact.js";
|
|
82
84
|
export { retryWithBackoff } from "./scheduler.js";
|
|
83
85
|
export { ProviderDeferError } from "./providers/defer.js";
|
|
84
86
|
export type { BatchHandle, DispatchOptions, DispatchOrigin, DispatchResult, ModelUsage, ProviderAdapter, RunDetails, } from "./providers/index.js";
|
|
85
87
|
export { SESSION_NOTICE_MAX_AGE_MS, SESSION_NOTICES_SINCE_META_KEY, TaskStore } from "./storage/sqlite.js";
|
|
86
|
-
export { PROGRESS_GAP_MS, PROGRESS_LINE_MAX_CHARS, PROGRESS_MAX_EVENTS, PROGRESS_QUIET_MS, TASK_EVENT_KINDS, cleanProgressText, createProgressRecorder, eventSummary, formatTaskEvent, isTaskEventKind, normalizeActor, progressLine, taskEventJson, } from "./task-events.js";
|
|
88
|
+
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";
|
|
87
89
|
export type { ProgressRecorder, TaskEvent, TaskEventActor, TaskEventInput, TaskEventKind } from "./task-events.js";
|
|
88
90
|
export type { SessionNotice, TaskListFilter, TaskStoreOptions } from "./storage/sqlite.js";
|
|
89
91
|
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";
|
|
90
92
|
export { checkRequestedRegion, regionRequestUrl, regionSettingReader, unknownRegionMessage, } from "./region-host.js";
|
|
91
93
|
export type { RegionSettingReaderOptions } from "./region-host.js";
|
|
92
94
|
export type { RegionApproximation, RegionCatalogEntry, RegionResolution, RegionSource, ResolveRegionInput, } from "./region.js";
|
|
93
|
-
export {
|
|
95
|
+
export { BATCH_LLM_TIMEOUT_NOTE, CAPS_VERSION, DURATION_FORM_ERROR, DURATION_RANGE_ERROR, DURATION_ZERO_ERROR, DurationError, FAILURE_CLASSES, MAX_RETRIES, NO_TIME_LEFT_TEXT, RETRIES_ERROR, RETRY_DELAY_ERROR, RUN_LIMITS, attemptNumber, capValueError, classifyFailure, describeRunLimit, durationSeconds, failureFactsOf, finalFailureError, formatDuration, formatRunLimitValue, isRetryableFailure, isRunLimitCap, loadRunLimitSettings, mayRunAsBatch, parseDuration, parseRetries, parseRetryDelay, parseRunLimitValue, planRetry, resolveRunLimits, resolveTaskRunLimits, retryPolicyOf, retryPolicyText, runLimitDefinition, runLimitSettingsFromValues, runLimitValueError, runLimitsDetails, runLimitsFromDetails, runLimitsText, taskRunLimitsView, timeLimitError, versionedCaps, } from "./run-limits.js";
|
|
96
|
+
export type { DurationValue, FailureClass, FailureFacts, FinalReason, IgnoredRunLimitLine, LoadRunLimitSettingsOptions, ResolvedRunLimit, ResolvedRunLimits, RetryPlan, RunLimitDefinition, RunLimitDetail, RunLimitName, RunLimitSettings, RunLimitsDetails, RunLimitSource, TaskRunLimitsView, } from "./run-limits.js";
|
|
97
|
+
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";
|
|
94
98
|
export type { EnergySourceTier, EnergyResolutionTier, ModelLifecycleStatus, ModelEnergyCoefficients, ModelFamily, ResolvedModelEnergy, EstimateEnergyOpts, } from "./energy.js";
|
|
95
99
|
export { ALL_TOOL_HOSTS, TOOL_SURFACE, getToolDef, getToolDefOrThrow, toolsForHost, descriptionForHost, paramHosts, paramIncludedForHost, paramsForHost, paramOptionalForHost, neutralSurfaceForHost, } from "./tool-surface.js";
|
|
96
|
-
export { commandJobRefusal, QUEUE_ADD_COMMAND_LINE, endJobOfTask, isJobRepeat, JOB_ONLY_PARAMS, JOB_REPEATS, jobParamsRefusal, jobToolsFor, jobToolView, jobUnsupportedRefusal, scheduleJobInput, } from "./schedule-job.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";
|
|
97
101
|
export type { JobRepeat, JobToolView, ScheduleJobArgs } from "./schedule-job.js";
|
|
98
102
|
export type { ToolHost, ToolParamKind, ToolParam, ToolAnnotations, CanonicalToolDef, } from "./tool-surface.js";
|
|
99
103
|
export { canonicalize, defaultSigningKeyPath, loadOrCreateSigningKey, signReceipt, verifyReceipt, } from "./sign.js";
|
package/dist/index.js
CHANGED
|
@@ -43,20 +43,20 @@ export { recommendWindow } from "./recommend.js";
|
|
|
43
43
|
// Task visibility (v0.17): titles, history, display helpers.
|
|
44
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
45
|
// Readiness (coherence KTD1 to KTD3).
|
|
46
|
-
export { assessReadiness, 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";
|
|
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, 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, 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
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";
|
|
54
54
|
export { ASSUMED_KWH_PER_CALL, classifyBand, aggregateStats, aggregateByRegion, bandHistogram, achievements, } from "./aggregator.js";
|
|
55
55
|
// Aggregate carbon-budget alerts (ROADMAP item 4).
|
|
56
56
|
// Desktop notifications (v0.17): pure command builder, hosts spawn it.
|
|
57
|
-
export { NOTIFY_PREVIEW_CHARS, WIN_NOTIFY_BODY_VAR, WIN_NOTIFY_TITLE_VAR, osNotifyCommand, taskNotificationContent, } from "./notify.js";
|
|
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, handoffCwdError, 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, WAKE_MARKER_MAX_AGE_MS, 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).
|
|
@@ -68,21 +68,23 @@ export { guaranteeText, isCalendarAnchored, JobScheduleError, MAX_EVERY_HOURS, M
|
|
|
68
68
|
// IANA zone helpers shared by the quota and job code.
|
|
69
69
|
export { localToUtcMs, systemTimeZone } from "./zone-time.js";
|
|
70
70
|
// 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,
|
|
72
|
-
export { AnthropicAdapter, OpenAIAdapter, GeminiAdapter, OllamaAdapter, DEFAULT_MODEL_BY_PROVIDER, NonRetryableError, ProviderRefusalError, } from "./providers/index.js";
|
|
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";
|
|
72
|
+
export { AnthropicAdapter, OpenAIAdapter, GeminiAdapter, OllamaAdapter, DEFAULT_MODEL_BY_PROVIDER, NonRetryableError, permanentError, ProviderRefusalError, } from "./providers/index.js";
|
|
73
73
|
export { budgetMaxTokens, BudgetExceededError } from "./providers/budget.js";
|
|
74
|
-
export { MAX_TIMER_MS } from "./providers/timeout.js";
|
|
74
|
+
export { MAX_TIMER_MS, withLlmTimeout } from "./providers/timeout.js";
|
|
75
|
+
export { httpFetch, limitDispatcher } from "./providers/http.js";
|
|
75
76
|
export { redactPrompt, SCRUB_MIN_LENGTH, scrubCutEdges, scrubValues } from "./redact.js";
|
|
76
77
|
export { retryWithBackoff } from "./scheduler.js";
|
|
77
78
|
export { ProviderDeferError } from "./providers/defer.js";
|
|
78
79
|
export { SESSION_NOTICE_MAX_AGE_MS, SESSION_NOTICES_SINCE_META_KEY, TaskStore } from "./storage/sqlite.js";
|
|
79
|
-
export { PROGRESS_GAP_MS, PROGRESS_LINE_MAX_CHARS, PROGRESS_MAX_EVENTS, PROGRESS_QUIET_MS, TASK_EVENT_KINDS, cleanProgressText, createProgressRecorder, eventSummary, formatTaskEvent, isTaskEventKind, normalizeActor, progressLine, taskEventJson, } from "./task-events.js";
|
|
80
|
+
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";
|
|
80
81
|
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";
|
|
81
82
|
export { checkRequestedRegion, regionRequestUrl, regionSettingReader, unknownRegionMessage, } from "./region-host.js";
|
|
82
|
-
export {
|
|
83
|
+
export { BATCH_LLM_TIMEOUT_NOTE, CAPS_VERSION, DURATION_FORM_ERROR, DURATION_RANGE_ERROR, DURATION_ZERO_ERROR, DurationError, FAILURE_CLASSES, MAX_RETRIES, NO_TIME_LEFT_TEXT, RETRIES_ERROR, RETRY_DELAY_ERROR, RUN_LIMITS, attemptNumber, capValueError, classifyFailure, describeRunLimit, durationSeconds, failureFactsOf, finalFailureError, formatDuration, formatRunLimitValue, isRetryableFailure, isRunLimitCap, loadRunLimitSettings, mayRunAsBatch, parseDuration, parseRetries, parseRetryDelay, parseRunLimitValue, planRetry, resolveRunLimits, resolveTaskRunLimits, retryPolicyOf, retryPolicyText, runLimitDefinition, runLimitSettingsFromValues, runLimitValueError, runLimitsDetails, runLimitsFromDetails, runLimitsText, taskRunLimitsView, timeLimitError, versionedCaps, } from "./run-limits.js";
|
|
84
|
+
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";
|
|
83
85
|
export { ALL_TOOL_HOSTS, TOOL_SURFACE, getToolDef, getToolDefOrThrow, toolsForHost, descriptionForHost, paramHosts, paramIncludedForHost, paramsForHost, paramOptionalForHost, neutralSurfaceForHost, } from "./tool-surface.js";
|
|
84
86
|
// schedule_task sugar for floating recurring jobs (KTD16), shared by both hosts.
|
|
85
|
-
export { commandJobRefusal, QUEUE_ADD_COMMAND_LINE, endJobOfTask, isJobRepeat, JOB_ONLY_PARAMS, JOB_REPEATS, jobParamsRefusal, jobToolsFor, jobToolView, jobUnsupportedRefusal, scheduleJobInput, } from "./schedule-job.js";
|
|
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";
|
|
86
88
|
export { canonicalize, defaultSigningKeyPath, loadOrCreateSigningKey, signReceipt, verifyReceipt, } from "./sign.js";
|
|
87
89
|
export { TIDEGAP_HOME_DIR, resolveTidegapHome, tidegapPath, } from "./paths.js";
|
|
88
90
|
export { AGENT_HOSTS, AGENTS_BLOCK, agentSnippet, isAgentHost, renderAgentSnippet, } from "./agent-snippet.js";
|
package/dist/jobs.d.ts
CHANGED
|
@@ -10,12 +10,14 @@
|
|
|
10
10
|
* inside `prepareTick`, so every ticker gets it. For each job it reads the
|
|
11
11
|
* tracked occurrence and:
|
|
12
12
|
*
|
|
13
|
-
* - live occurrence: nothing (R17), except a `running` one whose
|
|
14
|
-
* is older than its
|
|
15
|
-
* with a batch id goes back to
|
|
13
|
+
* - live occurrence: nothing (R17), except a `running` one whose tick is
|
|
14
|
+
* gone or whose dispatch is older than its time limits allow, which
|
|
15
|
+
* fails as interrupted (a Batch row with a batch id goes back to
|
|
16
|
+
* `submitted` instead);
|
|
16
17
|
* - finished occurrence: records the outcome (KTD9: ok, a failure with
|
|
17
|
-
*
|
|
18
|
-
* skip), then materializes the next
|
|
18
|
+
* the retries of the job's retry policy per slot and auto-pause after
|
|
19
|
+
* three failed slots, or a skip), then materializes the next
|
|
20
|
+
* occurrence;
|
|
19
21
|
* - no occurrence on an active job: materializes one.
|
|
20
22
|
*
|
|
21
23
|
* Every job write is a compare-and-set on `revision`. Pause, edit and
|
|
@@ -24,8 +26,10 @@
|
|
|
24
26
|
* adopts it on an active job and cancels it otherwise (the stop-flag-first
|
|
25
27
|
* rule). The sweep never throws.
|
|
26
28
|
*/
|
|
29
|
+
import { BATCH_SUBMIT_INTERRUPTED_ERROR } from "./history.js";
|
|
27
30
|
import { type SleepReading } from "./readiness.js";
|
|
28
31
|
import type { Scheduler } from "./scheduler.js";
|
|
32
|
+
import { type ResolvedRunLimits } from "./run-limits.js";
|
|
29
33
|
import { type JobCadence, type JobCaps, type JobNotify, type JobRecord, type JobTemplate, type JobWindow, type TaskRecord, type TaskStatus } from "./types.js";
|
|
30
34
|
/** Why a job action was refused; `code` maps to an HTTP status in the hosts. */
|
|
31
35
|
export declare class JobActionError extends Error {
|
|
@@ -53,7 +57,7 @@ export interface JobInput {
|
|
|
53
57
|
/** IANA zone; default the system zone. */
|
|
54
58
|
timeZone?: string;
|
|
55
59
|
template: JobTemplate;
|
|
56
|
-
caps?:
|
|
60
|
+
caps?: JobCapsPatch;
|
|
57
61
|
/** Default `every_run`. */
|
|
58
62
|
notify?: JobNotify;
|
|
59
63
|
/** `page`, `cli`, `mcp` or `openclaw`. */
|
|
@@ -72,9 +76,19 @@ export interface JobPatch {
|
|
|
72
76
|
window?: JobWindow | null;
|
|
73
77
|
timeZone?: string;
|
|
74
78
|
template?: JobTemplate;
|
|
75
|
-
caps?:
|
|
79
|
+
caps?: JobCapsPatch;
|
|
76
80
|
notify?: JobNotify;
|
|
77
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Caps a caller sets: a value sets the key. `null` removes a time limit, so
|
|
84
|
+
* the setting or the default applies at each run, and puts any other cap
|
|
85
|
+
* back to its default.
|
|
86
|
+
*/
|
|
87
|
+
export type JobCapsPatch = {
|
|
88
|
+
[K in Exclude<keyof JobCaps, "capsVersion">]?: JobCaps[K] | null;
|
|
89
|
+
};
|
|
90
|
+
/** Every caps key a caller may set. */
|
|
91
|
+
export declare const JOB_CAPS_KEYS: ReadonlySet<string>;
|
|
78
92
|
/** Per-call options of the job actions. */
|
|
79
93
|
export interface JobActionOptions {
|
|
80
94
|
/** Who the change is recorded as on occurrence events; default `system`. */
|
|
@@ -118,8 +132,6 @@ export interface JobSweepResult {
|
|
|
118
132
|
}
|
|
119
133
|
/** A job secret name: what the command sees as an environment variable. */
|
|
120
134
|
export declare const JOB_SECRET_NAME: RegExp;
|
|
121
|
-
/** Delay before the one retry of a failed slot. */
|
|
122
|
-
export declare const JOB_RETRY_DELAY_MS: number;
|
|
123
135
|
/** Failed slots in a row that pause a job. */
|
|
124
136
|
export declare const JOB_AUTO_PAUSE_FAILURES = 3;
|
|
125
137
|
/** How `pauseReason` starts when the third failed slot paused the job: `auto: <first error line>`. */
|
|
@@ -127,14 +139,12 @@ export declare const JOB_AUTO_PAUSE_PREFIX = "auto: ";
|
|
|
127
139
|
/** The error line of an auto-pause reason, or undefined when the job was not paused by its failures. */
|
|
128
140
|
export declare function jobAutoPauseReason(pauseReason: string | undefined): string | undefined;
|
|
129
141
|
export declare const JOB_INTERRUPTED_ERROR = "interrupted: the tick stopped during the run";
|
|
142
|
+
export { BATCH_SUBMIT_INTERRUPTED_ERROR };
|
|
130
143
|
/**
|
|
131
|
-
* The
|
|
132
|
-
*
|
|
133
|
-
* `retryTask` and the Python `retry_task` refuse it, and the sweep does not
|
|
134
|
-
* retry it. The text is the marker; `test/fixtures/interrupted-batch-submit.json`
|
|
135
|
-
* shares it with the Python core.
|
|
144
|
+
* The time limits a run of `job` gets if it starts now, with their sources:
|
|
145
|
+
* the scheduler's settings reader, or without one the settings file.
|
|
136
146
|
*/
|
|
137
|
-
export declare
|
|
147
|
+
export declare function jobRunLimits(job: JobRecord, scheduler?: Scheduler): ResolvedRunLimits;
|
|
138
148
|
/**
|
|
139
149
|
* The job sweep (KTD2): for every job, record the outcome of its finished
|
|
140
150
|
* occurrence and keep one live occurrence per active job. Never throws.
|