Skip to content

Commit be815ae

Browse files
authored
refactor(gateway): split session utilities (#113118)
* refactor(gateway): split session utilities * fix(gateway): privatize thinking row projection
1 parent 2e4df03 commit be815ae

11 files changed

Lines changed: 3225 additions & 3039 deletions

‎config/max-lines-baseline.txt‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,6 @@ src/gateway/session-utils.fs.test.ts
855855
src/gateway/session-utils.fs.ts
856856
src/gateway/session-utils.subagent.test.ts
857857
src/gateway/session-utils.test.ts
858-
src/gateway/session-utils.ts
859858
src/gateway/sessions-history-http.test.ts
860859
src/gateway/sessions-patch.test.ts
861860
src/gateway/talk-realtime-relay.test.ts
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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

Comments
 (0)