dsh-lowtide 0.2.2 → 0.2.5
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/LICENSE +21 -21
- package/README.md +3 -3
- package/lib/client.js +1067 -275
- package/lib/client.js.map +1 -1
- package/lib/index.js +122 -42
- package/lib/types/client/i18n.d.ts +7 -0
- package/lib/types/client/index.d.ts +1 -1
- package/lib/types/client/store.d.ts +2 -1
- package/lib/types/src/runner.d.ts +3 -1
- package/lib/types/src/scheduler.d.ts +13 -7
- package/lib/types/src/store.d.ts +1 -0
- package/package.json +30 -31
package/lib/index.js
CHANGED
|
@@ -5,8 +5,12 @@ import { execFile } from "node:child_process";
|
|
|
5
5
|
import { homedir } from "node:os";
|
|
6
6
|
import { installModelSelection } from "@deepseek-ai/dsh-agent";
|
|
7
7
|
import { ReasoningEffortId, createUserMessage } from "@deepseek-ai/dsh-llm";
|
|
8
|
-
import { SessionId } from "@deepseek-ai/dsh-session";
|
|
8
|
+
import { SessionId, SessionLogOffset } from "@deepseek-ai/dsh-session";
|
|
9
9
|
//#region ../core/src/windows.ts
|
|
10
|
+
/** The effective run-window list: `windows` when non-empty, else `[window]`. */
|
|
11
|
+
function batchWindowList(batch) {
|
|
12
|
+
return batch.windows !== void 0 && batch.windows.length > 0 ? [...batch.windows] : [batch.window];
|
|
13
|
+
}
|
|
10
14
|
const DEFAULT_MULTIPLIER = {
|
|
11
15
|
peak: 2,
|
|
12
16
|
off: 1,
|
|
@@ -145,13 +149,21 @@ function nextOffPeakStart(when, windows, defaultTz = systemTimeZone()) {
|
|
|
145
149
|
}
|
|
146
150
|
return best;
|
|
147
151
|
}
|
|
148
|
-
/**
|
|
152
|
+
/**
|
|
153
|
+
* Next batch start across the configured run window(s) (local time in batch
|
|
154
|
+
* tz). With multiple windows (issue #5) the earliest upcoming start wins —
|
|
155
|
+
* that is the moment the countdown and the confirm gate point at.
|
|
156
|
+
*/
|
|
149
157
|
function nextBatchAt(now, batch, defaultTz = systemTimeZone()) {
|
|
150
|
-
const { start } = parseWindowRange(batch.window);
|
|
151
158
|
const tz = batch.tz ?? defaultTz;
|
|
152
|
-
let
|
|
153
|
-
|
|
154
|
-
|
|
159
|
+
let best = null;
|
|
160
|
+
for (const range of batchWindowList(batch)) {
|
|
161
|
+
const { start } = parseWindowRange(range);
|
|
162
|
+
let target = new Date(dayStartInTz(now, tz).getTime() + start * 6e4);
|
|
163
|
+
if (target.getTime() <= now.getTime()) target = new Date(addDaysInTz(now, tz, 1).getTime() + start * 6e4);
|
|
164
|
+
if (best === null || target.getTime() < best.getTime()) best = target;
|
|
165
|
+
}
|
|
166
|
+
return best;
|
|
155
167
|
}
|
|
156
168
|
/** Minutes from `now` until `at` (floor), 0 when past. */
|
|
157
169
|
function minutesUntil(now, at) {
|
|
@@ -4934,6 +4946,8 @@ const windowSchema = object({
|
|
|
4934
4946
|
});
|
|
4935
4947
|
const batchSchema = object({
|
|
4936
4948
|
window: string(),
|
|
4949
|
+
/** Multi-window list (issue #5); absent in pre-0.2.4 state files = [window]. */
|
|
4950
|
+
windows: array(string()).optional(),
|
|
4937
4951
|
tz: string().optional(),
|
|
4938
4952
|
gateLeadMin: number(),
|
|
4939
4953
|
maxTasksPerNight: number(),
|
|
@@ -4950,6 +4964,7 @@ const strictWindowSchema = windowSchema.extend({
|
|
|
4950
4964
|
});
|
|
4951
4965
|
const strictBatchSchema = batchSchema.extend({
|
|
4952
4966
|
window: string().regex(/^([01]\d|2[0-3]):[0-5]\d-([01]\d|2[0-3]):[0-5]\d$/, "窗口须为 HH:MM-HH:MM"),
|
|
4967
|
+
windows: array(string().regex(/^([01]\d|2[0-3]):[0-5]\d-([01]\d|2[0-3]):[0-5]\d$/, "窗口须为 HH:MM-HH:MM")).min(1, "至少保留一个运行窗口").max(6, "运行窗口最多 6 个").optional(),
|
|
4953
4968
|
tz: string().refine(isIanaTz, "非法时区").optional(),
|
|
4954
4969
|
gateLeadMin: number().min(0).max(120),
|
|
4955
4970
|
maxTasksPerNight: number().int().min(1),
|
|
@@ -4999,6 +5014,28 @@ const configUpdateSchema = object({
|
|
|
4999
5014
|
budgetDailyYuan: number().min(0).optional(),
|
|
5000
5015
|
maxReportHistory: number().int().min(0).optional()
|
|
5001
5016
|
});
|
|
5017
|
+
/**
|
|
5018
|
+
* Keep `batch.window` and `batch.windows` consistent (issue #5): a patch
|
|
5019
|
+
* carrying `windows` is authoritative and mirrors its first entry into the
|
|
5020
|
+
* legacy `window` field (so a downgrade keeps running window #1); a patch
|
|
5021
|
+
* carrying only `window` (single-window client) collapses the list to it.
|
|
5022
|
+
* Patches touching neither leave both untouched.
|
|
5023
|
+
*/
|
|
5024
|
+
function normalizeBatchWindows(merged, patch) {
|
|
5025
|
+
if (patch.windows !== void 0) {
|
|
5026
|
+
const list = [...patch.windows];
|
|
5027
|
+
return {
|
|
5028
|
+
...merged,
|
|
5029
|
+
window: list[0] ?? merged.window,
|
|
5030
|
+
windows: list
|
|
5031
|
+
};
|
|
5032
|
+
}
|
|
5033
|
+
if (patch.window !== void 0) return {
|
|
5034
|
+
...merged,
|
|
5035
|
+
windows: [patch.window]
|
|
5036
|
+
};
|
|
5037
|
+
return merged;
|
|
5038
|
+
}
|
|
5002
5039
|
const stateSchema = object({
|
|
5003
5040
|
version: literal(1),
|
|
5004
5041
|
config: configSchema,
|
|
@@ -5170,10 +5207,10 @@ var LowtideStore = class LowtideStore {
|
|
|
5170
5207
|
...patch.maxReportHistory !== void 0 ? { maxReportHistory: patch.maxReportHistory } : {},
|
|
5171
5208
|
...patch.windows !== void 0 ? { windows: patch.windows } : {},
|
|
5172
5209
|
...patch.prices !== void 0 ? { prices: patch.prices } : {},
|
|
5173
|
-
batch: patch.batch === void 0 ? this.state.config.batch : {
|
|
5210
|
+
batch: patch.batch === void 0 ? this.state.config.batch : normalizeBatchWindows({
|
|
5174
5211
|
...this.state.config.batch,
|
|
5175
5212
|
...patch.batch
|
|
5176
|
-
}
|
|
5213
|
+
}, patch.batch)
|
|
5177
5214
|
};
|
|
5178
5215
|
return this.state.config;
|
|
5179
5216
|
});
|
|
@@ -5736,22 +5773,40 @@ async function executeTurns(ctx, task, nextMessage, timeoutMs, reasoning, resume
|
|
|
5736
5773
|
const reason = error instanceof Error ? error.message : String(error);
|
|
5737
5774
|
console.error(`[lowtide] resume ${resumeSessionId} failed (${reason}) — trying fork-style continuation`);
|
|
5738
5775
|
const live = ctx.sessions.get(SessionId(resumeSessionId));
|
|
5739
|
-
const
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5776
|
+
const liveCompat = live;
|
|
5777
|
+
const newSessionApi = typeof liveCompat?.snapshotEvents === "function";
|
|
5778
|
+
const liveEvents = liveCompat === void 0 ? void 0 : newSessionApi ? liveCompat.snapshotEvents() : liveCompat.events;
|
|
5779
|
+
const cut = liveEvents === void 0 ? null : forkSeedBoundary(liveEvents);
|
|
5780
|
+
if (live !== void 0 && liveEvents !== void 0 && cut !== null) {
|
|
5781
|
+
const seed = liveEvents.slice(0, cut);
|
|
5782
|
+
const sessionId = SessionId(`lt-${task.id}-${Date.now()}`);
|
|
5783
|
+
const agentOptions = {
|
|
5784
|
+
provider: selection.provider,
|
|
5785
|
+
model: selection.model
|
|
5786
|
+
};
|
|
5787
|
+
const preset = live.header.agentPreset !== void 0 ? { agentPreset: live.header.agentPreset } : {};
|
|
5788
|
+
handle = await ctx.agents.create(newSessionApi ? {
|
|
5789
|
+
sessionId,
|
|
5744
5790
|
seed,
|
|
5791
|
+
inheritedEventCount: SessionLogOffset(cut),
|
|
5745
5792
|
meta: {
|
|
5746
5793
|
cwd: workspacePath,
|
|
5747
5794
|
parentSession: SessionId(resumeSessionId),
|
|
5748
|
-
|
|
5749
|
-
...
|
|
5795
|
+
isSeeded: true,
|
|
5796
|
+
...preset
|
|
5750
5797
|
},
|
|
5751
|
-
agentOptions
|
|
5752
|
-
|
|
5753
|
-
|
|
5798
|
+
agentOptions,
|
|
5799
|
+
setup
|
|
5800
|
+
} : {
|
|
5801
|
+
sessionId,
|
|
5802
|
+
seed,
|
|
5803
|
+
meta: {
|
|
5804
|
+
cwd: workspacePath,
|
|
5805
|
+
parentSession: SessionId(resumeSessionId),
|
|
5806
|
+
seedLength: cut,
|
|
5807
|
+
...preset
|
|
5754
5808
|
},
|
|
5809
|
+
agentOptions,
|
|
5755
5810
|
setup
|
|
5756
5811
|
});
|
|
5757
5812
|
forked = true;
|
|
@@ -6661,8 +6716,10 @@ function assembleReportRows(queue, results) {
|
|
|
6661
6716
|
* concurrency (`batch.maxConcurrency`, default 3). Stops launching new tasks
|
|
6662
6717
|
* past windowEndAt but never interrupts a running task (PLAN §7.2). Returns
|
|
6663
6718
|
* null when nothing executed — no empty execution reports (review round 1, B2).
|
|
6719
|
+
* `windowLabel` is the run window that triggered this batch (multi-window,
|
|
6720
|
+
* issue #5); absent = the first configured window, matching legacy reports.
|
|
6664
6721
|
*/
|
|
6665
|
-
async function runBatch(ctx, store, windowEndAt, forced = false) {
|
|
6722
|
+
async function runBatch(ctx, store, windowEndAt, forced = false, windowLabel) {
|
|
6666
6723
|
const startedAt = /* @__PURE__ */ new Date();
|
|
6667
6724
|
const queue = [...store.tasks].filter((t) => t.status === "queued").sort((a, b) => a.priority - b.priority || a.createdAt.localeCompare(b.createdAt)).slice(0, store.config.batch.maxTasksPerNight);
|
|
6668
6725
|
const results = /* @__PURE__ */ new Map();
|
|
@@ -6687,7 +6744,7 @@ async function runBatch(ctx, store, windowEndAt, forced = false) {
|
|
|
6687
6744
|
const report = {
|
|
6688
6745
|
id: `rpt-${Date.now()}`,
|
|
6689
6746
|
date: localDateKey$1(/* @__PURE__ */ new Date()),
|
|
6690
|
-
window: store.config.batch.window,
|
|
6747
|
+
window: windowLabel ?? store.config.batch.window,
|
|
6691
6748
|
startedAt: startedAt.toISOString(),
|
|
6692
6749
|
finishedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6693
6750
|
tasks: rows,
|
|
@@ -7425,6 +7482,18 @@ function validateConfigUpdate(patch) {
|
|
|
7425
7482
|
} catch (error) {
|
|
7426
7483
|
return `运行窗口格式不对:${error instanceof Error ? error.message : String(error)}`;
|
|
7427
7484
|
}
|
|
7485
|
+
if (batch?.windows !== void 0) {
|
|
7486
|
+
const seenRanges = /* @__PURE__ */ new Set();
|
|
7487
|
+
for (const range of batch.windows) {
|
|
7488
|
+
if (seenRanges.has(range)) return `运行窗口重复:${range}`;
|
|
7489
|
+
seenRanges.add(range);
|
|
7490
|
+
try {
|
|
7491
|
+
parseWindowRange(range);
|
|
7492
|
+
} catch (error) {
|
|
7493
|
+
return `运行窗口格式不对(${range}):${error instanceof Error ? error.message : String(error)}`;
|
|
7494
|
+
}
|
|
7495
|
+
}
|
|
7496
|
+
}
|
|
7428
7497
|
if (windows !== void 0) {
|
|
7429
7498
|
const seen = /* @__PURE__ */ new Set();
|
|
7430
7499
|
for (const window of windows) {
|
|
@@ -7468,11 +7537,7 @@ async function statePayload(ctx, routes) {
|
|
|
7468
7537
|
const activeLevel = match?.level ?? "off";
|
|
7469
7538
|
const multiplier = match?.multiplier ?? 1;
|
|
7470
7539
|
const row = rowForLevel(tier, activeLevel, multiplier);
|
|
7471
|
-
const nextBatch = nextBatchAt(now,
|
|
7472
|
-
window: config.batch.window,
|
|
7473
|
-
tz: config.batch.tz,
|
|
7474
|
-
gateLeadMin: config.batch.gateLeadMin
|
|
7475
|
-
});
|
|
7540
|
+
const nextBatch = nextBatchAt(now, config.batch);
|
|
7476
7541
|
const nextOff = nextOffPeakStart(now, windows);
|
|
7477
7542
|
const systemTz = systemTimeZone();
|
|
7478
7543
|
const officialInLocal = windowsInTz(OFFICIAL_PEAK_WINDOWS, systemTz, now);
|
|
@@ -7530,6 +7595,8 @@ async function statePayload(ctx, routes) {
|
|
|
7530
7595
|
priceNotice: priceRouteNotice(modelId, now),
|
|
7531
7596
|
batch: {
|
|
7532
7597
|
window: config.batch.window,
|
|
7598
|
+
/** Effective run-window list (multi-window, issue #5). */
|
|
7599
|
+
windows: batchWindowList(config.batch),
|
|
7533
7600
|
paused: config.batch.paused,
|
|
7534
7601
|
running: scheduler.isRunning(),
|
|
7535
7602
|
startedAt: scheduler.batchStartedAt()?.toISOString() ?? null,
|
|
@@ -7558,17 +7625,24 @@ async function statePayload(ctx, routes) {
|
|
|
7558
7625
|
}
|
|
7559
7626
|
};
|
|
7560
7627
|
}
|
|
7561
|
-
/**
|
|
7562
|
-
function
|
|
7563
|
-
const { start, end } = parseWindowRange(window);
|
|
7628
|
+
/** Ranges covering `now`, in list order (midnight-crossing aware). */
|
|
7629
|
+
function activeWindows(now, windows, tz) {
|
|
7564
7630
|
const { minutes } = localParts(now, tz ?? systemTimeZone());
|
|
7565
|
-
|
|
7566
|
-
|
|
7567
|
-
|
|
7631
|
+
return windows.filter((range) => {
|
|
7632
|
+
const { start, end } = parseWindowRange(range);
|
|
7633
|
+
if (end > start) return minutes >= start && minutes < end;
|
|
7634
|
+
if (end < start) return minutes >= start || minutes < end;
|
|
7635
|
+
return true;
|
|
7636
|
+
});
|
|
7568
7637
|
}
|
|
7569
|
-
/** The batch window
|
|
7638
|
+
/** The end of the ACTIVE batch window as an absolute Date (today's or the
|
|
7639
|
+
* next occurrence). With multiple windows the first covering range wins —
|
|
7640
|
+
* overlapping windows are a user choice the once-per-window latch and the
|
|
7641
|
+
* running guard absorb (documented in README/CHANGELOG). */
|
|
7570
7642
|
function batchWindowEnd(now, window, tz) {
|
|
7571
|
-
const
|
|
7643
|
+
const list = Array.isArray(window) ? window : [window];
|
|
7644
|
+
const active = activeWindows(now, list, tz);
|
|
7645
|
+
const { end } = parseWindowRange(active.length > 0 ? active[0] : list[0]);
|
|
7572
7646
|
const resolvedTz = tz ?? systemTimeZone();
|
|
7573
7647
|
const dayStart = dayStartInTz(now, resolvedTz);
|
|
7574
7648
|
let target = new Date(dayStart.getTime() + end * 6e4);
|
|
@@ -7585,15 +7659,19 @@ function localDateKey(date, tz) {
|
|
|
7585
7659
|
}
|
|
7586
7660
|
/**
|
|
7587
7661
|
* Identity of the batch window currently in progress, keyed by the calendar
|
|
7588
|
-
* day the window STARTED (so a midnight-crossing window cannot run twice)
|
|
7589
|
-
*
|
|
7662
|
+
* day the window STARTED (so a midnight-crossing window cannot run twice)
|
|
7663
|
+
* plus the window's range string — with multiple windows (issue #5) each
|
|
7664
|
+
* window earns its own once-per-occurrence latch. Returns null when `now`
|
|
7665
|
+
* is outside every window.
|
|
7590
7666
|
*/
|
|
7591
7667
|
function currentWindowKey(now, window, tz) {
|
|
7592
|
-
|
|
7668
|
+
const active = activeWindows(now, Array.isArray(window) ? window : [window], tz);
|
|
7669
|
+
if (active.length === 0) return null;
|
|
7670
|
+
const range = active[0];
|
|
7593
7671
|
const resolvedTz = tz ?? systemTimeZone();
|
|
7594
|
-
const { start } = parseWindowRange(
|
|
7672
|
+
const { start } = parseWindowRange(range);
|
|
7595
7673
|
const { minutes } = localParts(now, resolvedTz);
|
|
7596
|
-
return `${localDateKey(minutes >= start ? now : addDaysInTz(now, resolvedTz, -1), resolvedTz)}|${
|
|
7674
|
+
return `${localDateKey(minutes >= start ? now : addDaysInTz(now, resolvedTz, -1), resolvedTz)}|${range}|${resolvedTz}`;
|
|
7597
7675
|
}
|
|
7598
7676
|
/** Window-start recovery for deferred tasks (PLAN §2.1 + review B3). */
|
|
7599
7677
|
function recoverDeferred(store) {
|
|
@@ -7617,11 +7695,13 @@ function startScheduler(ctx, store, tickMs = 3e4) {
|
|
|
7617
7695
|
if (running) return;
|
|
7618
7696
|
if (!forced && store.config.batch.paused) return;
|
|
7619
7697
|
const now = /* @__PURE__ */ new Date();
|
|
7620
|
-
|
|
7698
|
+
const wins = batchWindowList(store.config.batch);
|
|
7699
|
+
const activeRange = forced ? void 0 : activeWindows(now, wins, store.config.batch.tz)[0];
|
|
7700
|
+
if (!forced && activeRange === void 0) {
|
|
7621
7701
|
if (lastWindowKey !== null) lastWindowKey = null;
|
|
7622
7702
|
return;
|
|
7623
7703
|
}
|
|
7624
|
-
const key =
|
|
7704
|
+
const key = activeRange === void 0 ? null : currentWindowKey(now, wins, store.config.batch.tz);
|
|
7625
7705
|
if (!forced) {
|
|
7626
7706
|
if (key !== null && key === lastWindowKey) return;
|
|
7627
7707
|
if (key !== null) lastWindowKey = key;
|
|
@@ -7631,7 +7711,7 @@ function startScheduler(ctx, store, tickMs = 3e4) {
|
|
|
7631
7711
|
running = true;
|
|
7632
7712
|
startedAt = /* @__PURE__ */ new Date();
|
|
7633
7713
|
try {
|
|
7634
|
-
await runBatch(ctx, store, forced ? new Date(Date.now() + 864e5) : batchWindowEnd(/* @__PURE__ */ new Date(),
|
|
7714
|
+
await runBatch(ctx, store, forced ? new Date(Date.now() + 864e5) : batchWindowEnd(/* @__PURE__ */ new Date(), wins, store.config.batch.tz), forced, activeRange ?? wins[0]);
|
|
7635
7715
|
} catch (error) {
|
|
7636
7716
|
ctx.logger("lowtide").warn("batch failed: %s", error instanceof Error ? error.message : String(error));
|
|
7637
7717
|
} finally {
|
|
@@ -7675,7 +7755,7 @@ const inject = [
|
|
|
7675
7755
|
];
|
|
7676
7756
|
function apply(ctx) {
|
|
7677
7757
|
const store = LowtideStore.load(stateFilePath());
|
|
7678
|
-
ctx.logger("lowtide").info("host half loaded (store: %d tasks, batch
|
|
7758
|
+
ctx.logger("lowtide").info("host half loaded (store: %d tasks, batch windows: %s)", store.tasks.length, batchWindowList(store.config.batch).join(", "));
|
|
7679
7759
|
const hasRegistry = ctx.workspaceRegistry !== void 0;
|
|
7680
7760
|
const hasSessions = ctx.sessions !== void 0;
|
|
7681
7761
|
ctx.logger("lowtide").info("services: workspaceRegistry=%s, sessions=%s", hasRegistry, hasSessions);
|
|
@@ -109,6 +109,7 @@ declare const zh: {
|
|
|
109
109
|
'modal.editDesc': string;
|
|
110
110
|
'modal.saveEdit': string;
|
|
111
111
|
'modal.cancel': string;
|
|
112
|
+
'modal.close': string;
|
|
112
113
|
'modal.submit': string;
|
|
113
114
|
'modal.promptPlaceholderSingle': string;
|
|
114
115
|
'modal.promptPlaceholderIterative': string;
|
|
@@ -285,6 +286,12 @@ declare const zh: {
|
|
|
285
286
|
'settings.batchTitle': string;
|
|
286
287
|
'settings.start': string;
|
|
287
288
|
'settings.end': string;
|
|
289
|
+
'settings.batchWindowList': string;
|
|
290
|
+
'settings.addBatchWindow': string;
|
|
291
|
+
'settings.batchWindowsHint': string;
|
|
292
|
+
'settings.batchWindowOverlap': string;
|
|
293
|
+
'settings.batchWindowInvalid': string;
|
|
294
|
+
'settings.batchWindowMin': string;
|
|
288
295
|
'settings.tz': string;
|
|
289
296
|
'settings.gateLeadMin': string;
|
|
290
297
|
'settings.maxTasksPerNight': string;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* the host locale service; every slot entry declares `locale: NS` so the
|
|
10
10
|
* framework injects the typed `t` seat into component props.
|
|
11
11
|
*/
|
|
12
|
-
import type { ClientContext } from '@deepseek-ai/
|
|
12
|
+
import type { Context as ClientContext } from '@deepseek-ai/cordis';
|
|
13
13
|
/** Required services before this client module materializes. */
|
|
14
14
|
export declare const inject: string[];
|
|
15
15
|
export declare function apply(ctx: ClientContext): void;
|
|
@@ -56,6 +56,7 @@ export interface HostState {
|
|
|
56
56
|
officialDrift?: boolean;
|
|
57
57
|
batch: {
|
|
58
58
|
window: string;
|
|
59
|
+
windows?: string[];
|
|
59
60
|
paused: boolean;
|
|
60
61
|
running: boolean;
|
|
61
62
|
startedAt: string | null;
|
|
@@ -204,7 +205,7 @@ export interface ClientUiState {
|
|
|
204
205
|
/** False while the live push is silent/absent and polling carries the UI. */
|
|
205
206
|
sseHealthy: boolean;
|
|
206
207
|
}
|
|
207
|
-
export declare const lowtideStore: import("@deepseek-ai/dsh-client-
|
|
208
|
+
export declare const lowtideStore: import("@deepseek-ai/dsh-client-store").SnapshotStore<ClientUiState>;
|
|
208
209
|
export declare function showToast(text: string): void;
|
|
209
210
|
export declare function clearToast(): void;
|
|
210
211
|
/** Reset the UI slice (plugin unload) — the full field list lives here so a
|
|
@@ -82,8 +82,10 @@ export declare function assembleReportRows(queue: Task[], results: Map<string, R
|
|
|
82
82
|
* concurrency (`batch.maxConcurrency`, default 3). Stops launching new tasks
|
|
83
83
|
* past windowEndAt but never interrupts a running task (PLAN §7.2). Returns
|
|
84
84
|
* null when nothing executed — no empty execution reports (review round 1, B2).
|
|
85
|
+
* `windowLabel` is the run window that triggered this batch (multi-window,
|
|
86
|
+
* issue #5); absent = the first configured window, matching legacy reports.
|
|
85
87
|
*/
|
|
86
|
-
export declare function runBatch(ctx: Context, store: LowtideStore, windowEndAt: Date, forced?: boolean): Promise<MorningReport | null>;
|
|
88
|
+
export declare function runBatch(ctx: Context, store: LowtideStore, windowEndAt: Date, forced?: boolean, windowLabel?: string): Promise<MorningReport | null>;
|
|
87
89
|
/** Helper for the /state aggregate: yesterday-style formatting for the report header. */
|
|
88
90
|
export declare function reportDateLabel(dateIso: string): string;
|
|
89
91
|
export {};
|
|
@@ -22,16 +22,22 @@ export interface Scheduler {
|
|
|
22
22
|
}
|
|
23
23
|
/** Maximum consecutive preflight deferrals before a task is marked failed. */
|
|
24
24
|
export declare const MAX_PREFLIGHT_DEFER = 3;
|
|
25
|
-
/** Whether `now` is inside
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
/** Whether `now` is inside any of the batch windows (local tz). Accepts the
|
|
26
|
+
* legacy single-range string or the multi-window list (issue #5). */
|
|
27
|
+
export declare function inBatchWindow(now: Date, window: string | string[], tz?: string): boolean;
|
|
28
|
+
/** The end of the ACTIVE batch window as an absolute Date (today's or the
|
|
29
|
+
* next occurrence). With multiple windows the first covering range wins —
|
|
30
|
+
* overlapping windows are a user choice the once-per-window latch and the
|
|
31
|
+
* running guard absorb (documented in README/CHANGELOG). */
|
|
32
|
+
export declare function batchWindowEnd(now: Date, window: string | string[], tz?: string): Date;
|
|
29
33
|
/**
|
|
30
34
|
* Identity of the batch window currently in progress, keyed by the calendar
|
|
31
|
-
* day the window STARTED (so a midnight-crossing window cannot run twice)
|
|
32
|
-
*
|
|
35
|
+
* day the window STARTED (so a midnight-crossing window cannot run twice)
|
|
36
|
+
* plus the window's range string — with multiple windows (issue #5) each
|
|
37
|
+
* window earns its own once-per-occurrence latch. Returns null when `now`
|
|
38
|
+
* is outside every window.
|
|
33
39
|
*/
|
|
34
|
-
export declare function currentWindowKey(now: Date, window: string, tz?: string): string | null;
|
|
40
|
+
export declare function currentWindowKey(now: Date, window: string | string[], tz?: string): string | null;
|
|
35
41
|
/** Window-start recovery for deferred tasks (PLAN §2.1 + review B3). */
|
|
36
42
|
export declare function recoverDeferred(store: LowtideStore): void;
|
|
37
43
|
export declare function startScheduler(ctx: Context, store: LowtideStore, tickMs?: number): Scheduler;
|
package/lib/types/src/store.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export declare const configUpdateSchema: z.ZodObject<{
|
|
|
15
15
|
paused: z.ZodOptional<z.ZodBoolean>;
|
|
16
16
|
maxConcurrency: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
17
17
|
window: z.ZodOptional<z.ZodString>;
|
|
18
|
+
windows: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
18
19
|
tz: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
19
20
|
gateLeadMin: z.ZodOptional<z.ZodNumber>;
|
|
20
21
|
maxTasksPerNight: z.ZodOptional<z.ZodNumber>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-lowtide",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "lowtide: human-adjudicated off-peak batch task pipeline for dsh (peak/valley pricing aware)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -23,11 +23,8 @@
|
|
|
23
23
|
"client": {
|
|
24
24
|
"inject": [
|
|
25
25
|
"@deepseek-ai/dsh-client-locale",
|
|
26
|
-
"@deepseek-ai/dsh-client-runtime",
|
|
27
26
|
"@deepseek-ai/dsh-client-ui-conversation",
|
|
28
|
-
"@deepseek-ai/dsh-client-ui-primitives",
|
|
29
27
|
"@deepseek-ai/dsh-client-ui-settings",
|
|
30
|
-
"@deepseek-ai/dsh-client-ui-slots",
|
|
31
28
|
"@deepseek-ai/dsh-client-connection"
|
|
32
29
|
],
|
|
33
30
|
"platform": "web"
|
|
@@ -40,6 +37,13 @@
|
|
|
40
37
|
"lib/types/**/*.d.ts",
|
|
41
38
|
"cordis.patch.yml"
|
|
42
39
|
],
|
|
40
|
+
"scripts": {
|
|
41
|
+
"bundle": "tsdown && tsc -p tsconfig.build.json",
|
|
42
|
+
"watch": "tsdown --watch",
|
|
43
|
+
"typecheck": "tsc --noEmit",
|
|
44
|
+
"test": "vitest run",
|
|
45
|
+
"dev": "npx @deepseek-ai/dsh@0.1.5-rc.1 web --patch ./cordis.dev.yml"
|
|
46
|
+
},
|
|
43
47
|
"license": "MIT",
|
|
44
48
|
"keywords": [
|
|
45
49
|
"dsh-plugin",
|
|
@@ -66,40 +70,35 @@
|
|
|
66
70
|
},
|
|
67
71
|
"devDependencies": {
|
|
68
72
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
69
|
-
"@deepseek-ai/dsh-agent": "^0.1.
|
|
70
|
-
"@deepseek-ai/dsh-agent-default-model": "^0.1.
|
|
71
|
-
"@deepseek-ai/dsh-agent-presets": "0.1.
|
|
72
|
-
"@deepseek-ai/dsh-client-connection": "^0.1.
|
|
73
|
-
"@deepseek-ai/dsh-client-locale": "^0.1.
|
|
74
|
-
"@deepseek-ai/dsh-client-
|
|
75
|
-
"@deepseek-ai/dsh-client-ui-conversation": "^0.1.
|
|
76
|
-
"@deepseek-ai/dsh-client-ui-layout": "0.1.
|
|
77
|
-
"@deepseek-ai/dsh-client-ui-primitives": "^0.1.
|
|
78
|
-
"@deepseek-ai/dsh-client-ui-
|
|
79
|
-
"@deepseek-ai/dsh-client-ui-
|
|
80
|
-
"@deepseek-ai/dsh-
|
|
81
|
-
"@deepseek-ai/dsh-host-webserver": "^0.1.
|
|
82
|
-
"@deepseek-ai/dsh-llm": "^0.1.
|
|
83
|
-
"@deepseek-ai/dsh-permission-presets": "^0.1.
|
|
84
|
-
"@deepseek-ai/dsh-session": "^0.1.
|
|
85
|
-
"@deepseek-ai/dsh-settings": "^0.1.
|
|
86
|
-
"@deepseek-ai/dsh-storage-domain": "^0.1.
|
|
73
|
+
"@deepseek-ai/dsh-agent": "^0.1.5-rc.1",
|
|
74
|
+
"@deepseek-ai/dsh-agent-default-model": "^0.1.5-rc.1",
|
|
75
|
+
"@deepseek-ai/dsh-agent-presets": "^0.1.5-rc.1",
|
|
76
|
+
"@deepseek-ai/dsh-client-connection": "^0.1.5-rc.1",
|
|
77
|
+
"@deepseek-ai/dsh-client-locale": "^0.1.5-rc.1",
|
|
78
|
+
"@deepseek-ai/dsh-client-store": "^0.1.5-rc.1",
|
|
79
|
+
"@deepseek-ai/dsh-client-ui-conversation": "^0.1.5-rc.1",
|
|
80
|
+
"@deepseek-ai/dsh-client-ui-layout": "^0.1.5-rc.1",
|
|
81
|
+
"@deepseek-ai/dsh-client-ui-primitives": "^0.1.5-rc.1",
|
|
82
|
+
"@deepseek-ai/dsh-client-ui-renderer": "^0.1.5-rc.1",
|
|
83
|
+
"@deepseek-ai/dsh-client-ui-settings": "^0.1.5-rc.1",
|
|
84
|
+
"@deepseek-ai/dsh-client-ui-slots": "^0.1.5-rc.1",
|
|
85
|
+
"@deepseek-ai/dsh-host-webserver": "^0.1.5-rc.1",
|
|
86
|
+
"@deepseek-ai/dsh-llm": "^0.1.5-rc.1",
|
|
87
|
+
"@deepseek-ai/dsh-permission-presets": "^0.1.5-rc.1",
|
|
88
|
+
"@deepseek-ai/dsh-session": "^0.1.5-rc.1",
|
|
89
|
+
"@deepseek-ai/dsh-settings": "^0.1.5-rc.1",
|
|
90
|
+
"@deepseek-ai/dsh-storage-domain": "^0.1.5-rc.1",
|
|
87
91
|
"@playwright/test": "^1.62.1",
|
|
88
92
|
"@types/node": "^22.20.0",
|
|
89
93
|
"@types/react": "~18.3.1",
|
|
94
|
+
"immer": "^10.1.1",
|
|
90
95
|
"lightningcss": "^1.32.0",
|
|
96
|
+
"lowtide-core": "workspace:*",
|
|
91
97
|
"react": "^18.2.0",
|
|
92
98
|
"tsdown": "^0.22.2",
|
|
93
99
|
"typescript": "^6.0.3",
|
|
94
100
|
"vitest": "^4.1.8",
|
|
95
101
|
"zod": "^4.4.3",
|
|
96
|
-
"
|
|
97
|
-
},
|
|
98
|
-
"scripts": {
|
|
99
|
-
"bundle": "tsdown && tsc -p tsconfig.build.json",
|
|
100
|
-
"watch": "tsdown --watch",
|
|
101
|
-
"typecheck": "tsc --noEmit",
|
|
102
|
-
"test": "vitest run",
|
|
103
|
-
"dev": "npx @deepseek-ai/dsh@0.1.5-rc.1 web --patch ./cordis.dev.yml"
|
|
102
|
+
"zustand": "~4.4.7"
|
|
104
103
|
}
|
|
105
|
-
}
|
|
104
|
+
}
|