refactor(runtime): hide default constants · openclaw/openclaw@0842cb7
vincentkoc
·
2026-06-17
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -5,8 +5,8 @@ import { normalizeOptionalString } from "@openclaw/normalization-core/string-coe
|
5 | 5 | import type { MsgContext } from "../templating.js"; |
6 | 6 | import type { HistoryEntry, HistoryMediaEntry } from "./history.types.js"; |
7 | 7 | |
8 | | -export const RECENT_HISTORY_IMAGE_TTL_MS = 30 * 60_000; |
9 | | -export const RECENT_HISTORY_IMAGE_LIMIT = 4; |
| 8 | +const RECENT_HISTORY_IMAGE_TTL_MS = 30 * 60_000; |
| 9 | +const RECENT_HISTORY_IMAGE_LIMIT = 4; |
10 | 10 | |
11 | 11 | export type RecentInboundHistoryImage = { |
12 | 12 | path: string; |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -3,10 +3,9 @@ import fs from "node:fs/promises";
|
3 | 3 | import os from "node:os"; |
4 | 4 | import path from "node:path"; |
5 | 5 | import { afterEach, beforeEach, describe, expect, it } from "vitest"; |
6 | | -import { |
7 | | -DEFAULT_REPLAY_MAX_MESSAGES, |
8 | | -replayRecentUserAssistantMessages, |
9 | | -} from "./session-transcript-replay.js"; |
| 6 | +import { replayRecentUserAssistantMessages } from "./session-transcript-replay.js"; |
| 7 | + |
| 8 | +const DEFAULT_REPLAY_MAX_MESSAGES = 6; |
10 | 9 | |
11 | 10 | const j = (obj: unknown): string => `${JSON.stringify(obj)}\n`; |
12 | 11 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -5,7 +5,7 @@ import path from "node:path";
|
5 | 5 | import { CURRENT_SESSION_VERSION } from "../../config/sessions/version.js"; |
6 | 6 | |
7 | 7 | /** Tail kept so DM continuity survives silent session rotations. */ |
8 | | -export const DEFAULT_REPLAY_MAX_MESSAGES = 6; |
| 8 | +const DEFAULT_REPLAY_MAX_MESSAGES = 6; |
9 | 9 | |
10 | 10 | type SessionRecord = { |
11 | 11 | type?: unknown; |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -18,7 +18,7 @@ export type TypingModeContext = {
|
18 | 18 | }; |
19 | 19 | |
20 | 20 | /** Group chats default to message-triggered typing to avoid noisy indicators. */ |
21 | | -export const DEFAULT_GROUP_TYPING_MODE: TypingMode = "message"; |
| 21 | +const DEFAULT_GROUP_TYPING_MODE: TypingMode = "message"; |
22 | 22 | |
23 | 23 | /** Resolves the effective typing mode for the current auto-reply turn. */ |
24 | 24 | export function resolveTypingMode({ |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | // Cron store migration tests cover doctor migration of persisted cron stores. |
2 | 2 | import { describe, expect, it } from "vitest"; |
3 | | -import { DEFAULT_TOP_OF_HOUR_STAGGER_MS } from "../../../cron/stagger.js"; |
4 | 3 | import { normalizeStoredCronJobs } from "./store-migration.js"; |
5 | 4 | |
| 5 | +const DEFAULT_TOP_OF_HOUR_STAGGER_MS = 5 * 60 * 1000; |
| 6 | + |
6 | 7 | function makeLegacyJob(overrides: Record<string, unknown>): Record<string, unknown> { |
7 | 8 | return { |
8 | 9 | id: "job-legacy", |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -6,7 +6,7 @@ import type { OpenClawConfig } from "../config/config.js";
|
6 | 6 | // heartbeat delivery limits. |
7 | 7 | const DEFAULT_COMMITMENT_EXTRACTION_DEBOUNCE_MS = 15_000; |
8 | 8 | const DEFAULT_COMMITMENT_BATCH_MAX_ITEMS = 8; |
9 | | -export const DEFAULT_COMMITMENT_EXTRACTION_QUEUE_MAX_ITEMS = 64; |
| 9 | +const DEFAULT_COMMITMENT_EXTRACTION_QUEUE_MAX_ITEMS = 64; |
10 | 10 | const DEFAULT_COMMITMENT_CONFIDENCE_THRESHOLD = 0.72; |
11 | 11 | const DEFAULT_COMMITMENT_CARE_CONFIDENCE_THRESHOLD = 0.86; |
12 | 12 | const DEFAULT_COMMITMENT_EXTRACTION_TIMEOUT_SECONDS = 45; |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -5,7 +5,6 @@ import path from "node:path";
|
5 | 5 | import { afterEach, describe, expect, it, vi } from "vitest"; |
6 | 6 | import type { OpenClawConfig } from "../config/config.js"; |
7 | 7 | import { captureEnv, setTestEnvValue } from "../test-utils/env.js"; |
8 | | -import { DEFAULT_COMMITMENT_EXTRACTION_QUEUE_MAX_ITEMS } from "./config.js"; |
9 | 8 | import { |
10 | 9 | configureCommitmentExtractionRuntime, |
11 | 10 | drainCommitmentExtractionQueue, |
@@ -15,6 +14,8 @@ import {
|
15 | 14 | import { loadCommitmentStore } from "./store.js"; |
16 | 15 | import type { CommitmentExtractionBatchResult, CommitmentExtractionItem } from "./types.js"; |
17 | 16 | |
| 17 | +const DEFAULT_COMMITMENT_EXTRACTION_QUEUE_MAX_ITEMS = 64; |
| 18 | + |
18 | 19 | const runEmbeddedAgentMock = vi.hoisted(() => vi.fn()); |
19 | 20 | const resolveDefaultModelMock = vi.hoisted(() => vi.fn()); |
20 | 21 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -5,7 +5,8 @@ import {
|
5 | 5 | validateCronUpdateParams, |
6 | 6 | } from "../../packages/gateway-protocol/src/index.js"; |
7 | 7 | import { normalizeCronJobCreate, normalizeCronJobPatch } from "./normalize.js"; |
8 | | -import { DEFAULT_TOP_OF_HOUR_STAGGER_MS } from "./stagger.js"; |
| 8 | + |
| 9 | +const DEFAULT_TOP_OF_HOUR_STAGGER_MS = 5 * 60 * 1000; |
9 | 10 | |
10 | 11 | function expectNormalizedAtSchedule(scheduleInput: Record<string, unknown>) { |
11 | 12 | const normalized = normalizeCronJobCreate({ |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -6,15 +6,16 @@ import { describe, expect, it } from "vitest";
|
6 | 6 | import { migrateLegacyCronRunLogsToSqlite } from "../commands/doctor/cron/legacy-run-log-migration.js"; |
7 | 7 | import { |
8 | 8 | appendCronRunLog, |
9 | | -DEFAULT_CRON_RUN_LOG_KEEP_LINES, |
10 | | -DEFAULT_CRON_RUN_LOG_MAX_BYTES, |
11 | 9 | getPendingCronRunLogWriteCountForTests, |
12 | 10 | readCronRunLogEntries, |
13 | 11 | readCronRunLogEntriesPage, |
14 | 12 | readCronRunLogEntriesSync, |
15 | 13 | resolveCronRunLogPruneOptions, |
16 | 14 | } from "./run-log.js"; |
17 | 15 | |
| 16 | +const DEFAULT_CRON_RUN_LOG_MAX_BYTES = 2_000_000; |
| 17 | +const DEFAULT_CRON_RUN_LOG_KEEP_LINES = 2_000; |
| 18 | + |
18 | 19 | describe("cron run log", () => { |
19 | 20 | it("resolves prune options from config with defaults", () => { |
20 | 21 | expect(resolveCronRunLogPruneOptions()).toEqual({ |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -80,9 +80,9 @@ export function isInvalidCronRunLogJobIdError(err: unknown): boolean {
|
80 | 80 | const writesByTarget = new Map<string, Promise<void>>(); |
81 | 81 | |
82 | 82 | /** Legacy byte cap kept for config parsing compatibility with older file-backed run logs. */ |
83 | | -export const DEFAULT_CRON_RUN_LOG_MAX_BYTES = 2_000_000; |
| 83 | +const DEFAULT_CRON_RUN_LOG_MAX_BYTES = 2_000_000; |
84 | 84 | /** Default SQLite row retention per cron job when no explicit keepLines value is configured. */ |
85 | | -export const DEFAULT_CRON_RUN_LOG_KEEP_LINES = 2_000; |
| 85 | +const DEFAULT_CRON_RUN_LOG_KEEP_LINES = 2_000; |
86 | 86 | |
87 | 87 | /** Resolves configured run-log pruning limits while preserving legacy maxBytes parsing. */ |
88 | 88 | export function resolveCronRunLogPruneOptions(cfg?: CronConfig["runLog"]): { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。