|
| 1 | +import { |
| 2 | + normalizeLowercaseStringOrEmpty, |
| 3 | + normalizeOptionalString, |
| 4 | +} from "@openclaw/normalization-core/string-coerce"; |
| 5 | +import type { resolveSessionModelRef } from "../agents/session-model-ref.js"; |
| 6 | +import type { buildSubagentRunReadIndex } from "../agents/subagent-registry-read.js"; |
| 7 | +import type { ThinkLevel, listThinkingLevelOptions } from "../auto-reply/thinking.js"; |
| 8 | +import type { SessionEntry } from "../config/sessions.js"; |
| 9 | +import type { ModelCostConfig } from "../utils/usage-format.js"; |
| 10 | + |
| 11 | +export type SessionListRowContext = { |
| 12 | + subagentRuns: ReturnType<typeof buildSubagentRunReadIndex>; |
| 13 | + storeChildSessionsByKey: Map<string, string[]>; |
| 14 | + selectedModelByOverrideRef: Map<string, ReturnType<typeof resolveSessionModelRef>>; |
| 15 | + thinkingMetadataByModelRef: Map< |
| 16 | + string, |
| 17 | + { |
| 18 | + levels: ReturnType<typeof listThinkingLevelOptions>; |
| 19 | + defaultLevel: ThinkLevel; |
| 20 | + } |
| 21 | + >; |
| 22 | + displayModelIdentityByKey: Map<string, { provider?: string; model?: string }>; |
| 23 | + modelCostConfigByModelRef: Map<string, ModelCostConfig | undefined>; |
| 24 | + userProfileLabelById: Map<string, string | undefined>; |
| 25 | +}; |
| 26 | + |
| 27 | +export type SessionListRowContextProvider = () => SessionListRowContext; |
| 28 | + |
| 29 | +export type GatewaySessionStoreTarget = { |
| 30 | + agentId: string; |
| 31 | + storePath: string; |
| 32 | + canonicalKey: string; |
| 33 | + storeKeys: string[]; |
| 34 | +}; |
| 35 | + |
| 36 | +export type GatewaySessionStoreTargetWithStore = GatewaySessionStoreTarget & { |
| 37 | + store: Record<string, SessionEntry>; |
| 38 | +}; |
| 39 | + |
| 40 | +export function createSessionRowModelCacheKey( |
| 41 | + provider: string | undefined, |
| 42 | + model: string | undefined, |
| 43 | +) { |
| 44 | + return `${normalizeLowercaseStringOrEmpty(provider)}\0${normalizeOptionalString(model) ?? ""}`; |
| 45 | +} |
0 commit comments