refactor(tasks): trim registry helper exports · openclaw/openclaw@71645bb
vincentkoc
·
2026-06-17
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -2,7 +2,7 @@
|
2 | 2 | import type { TaskDeliveryState, TaskRecord } from "./task-registry.types.js"; |
3 | 3 | |
4 | 4 | /** Process-local indexes backing task lookup, owner access, and pending delivery scans. */ |
5 | | -export type TaskRegistryProcessState = { |
| 5 | +type TaskRegistryProcessState = { |
6 | 6 | tasks: Map<string, TaskRecord>; |
7 | 7 | taskDeliveryStates: Map<string, TaskDeliveryState>; |
8 | 8 | taskIdsByRunId: Map<string, Set<string>>; |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | // Shares SQLite row mapping helpers between task registry persistence modules. |
2 | | -import { chmodSync, existsSync, mkdirSync } from "node:fs"; |
3 | 2 | import { isRecord } from "../utils.js"; |
4 | 3 | import { normalizeDeliveryContext } from "../utils/delivery-context.shared.js"; |
5 | 4 | import type { DeliveryContext } from "../utils/delivery-context.types.js"; |
6 | 5 | |
7 | | -export const SQLITE_SIDECAR_SUFFIXES = ["", "-shm", "-wal"] as const; |
8 | | - |
9 | | -export function normalizeSqliteNumber(value: number | bigint | null): number | undefined { |
10 | | -if (typeof value === "bigint") { |
11 | | -return Number(value); |
12 | | -} |
13 | | -return typeof value === "number" ? value : undefined; |
14 | | -} |
15 | | - |
16 | 6 | // oxlint-disable-next-line typescript/no-unnecessary-type-parameters -- Persisted JSON columns are typed by the receiving field. |
17 | | -export function parseSqliteJsonValue<T>(raw: string | null): T | undefined { |
| 7 | +function parseSqliteJsonValue<T>(raw: string | null): T | undefined { |
18 | 8 | if (!raw?.trim()) { |
19 | 9 | return undefined; |
20 | 10 | } |
@@ -40,20 +30,3 @@ export function parseDeliveryContextJson(raw: string | null): DeliveryContext |
|
40 | 30 | : undefined, |
41 | 31 | }); |
42 | 32 | } |
43 | | - |
44 | | -export function ensureSqliteStorePermissions(params: { |
45 | | -dir: string; |
46 | | -pathname: string; |
47 | | -dirMode: number; |
48 | | -fileMode: number; |
49 | | -}) { |
50 | | -mkdirSync(params.dir, { recursive: true, mode: params.dirMode }); |
51 | | -chmodSync(params.dir, params.dirMode); |
52 | | -for (const suffix of SQLITE_SIDECAR_SUFFIXES) { |
53 | | -const candidate = `${params.pathname}${suffix}`; |
54 | | -if (!existsSync(candidate)) { |
55 | | -continue; |
56 | | -} |
57 | | -chmodSync(candidate, params.fileMode); |
58 | | -} |
59 | | -} |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -48,7 +48,7 @@ export type TaskRegistryObserverEvent =
|
48 | 48 | previous: TaskRecord; |
49 | 49 | }; |
50 | 50 | |
51 | | -export type TaskRegistryObservers = { |
| 51 | +type TaskRegistryObservers = { |
52 | 52 | // Observers are incremental/best-effort only. Snapshot persistence belongs to TaskRegistryStore. |
53 | 53 | onEvent?: (event: TaskRegistryObserverEvent) => void; |
54 | 54 | }; |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -10,8 +10,8 @@ import type { TaskRecord } from "./task-registry.types.js";
|
10 | 10 | const ACTIVE_TASK_STATUSES = new Set(["queued", "running"]); |
11 | 11 | const FAILURE_TASK_STATUSES = new Set(["failed", "timed_out", "lost"]); |
12 | 12 | /** Window for showing recently completed tasks in compact status output. */ |
13 | | -export const TASK_STATUS_RECENT_WINDOW_MS = 5 * 60_000; |
14 | | -export const TASK_STATUS_TITLE_MAX_CHARS = 80; |
| 13 | +const TASK_STATUS_RECENT_WINDOW_MS = 5 * 60_000; |
| 14 | +const TASK_STATUS_TITLE_MAX_CHARS = 80; |
15 | 15 | export const TASK_STATUS_DETAIL_MAX_CHARS = 120; |
16 | 16 | |
17 | 17 | function isActiveTask(task: TaskRecord): boolean { |
@@ -151,7 +151,7 @@ export function formatTaskStatusDetail(task: TaskRecord): string | undefined {
|
151 | 151 | ); |
152 | 152 | } |
153 | 153 | |
154 | | -export type TaskStatusSnapshot = { |
| 154 | +type TaskStatusSnapshot = { |
155 | 155 | latest?: TaskRecord; |
156 | 156 | focus?: TaskRecord; |
157 | 157 | visible: TaskRecord[]; |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。