MCPcopy Index your code
hub / github.com/Opencode-DCP/opencode-dynamic-context-pruning / getCurrentParams

Function getCurrentParams

lib/token-utils.ts:40–67  ·  view source on GitHub ↗
(
    state: SessionState,
    messages: WithParts[],
    logger: Logger,
)

Source from the content-addressed store, hash-verified

38}
39
40export function getCurrentParams(
41 state: SessionState,
42 messages: WithParts[],
43 logger: Logger,
44): {
45 providerId: string | undefined
46 modelId: string | undefined
47 agent: string | undefined
48 variant: string | undefined
49} {
50 const userMsg = getLastUserMessage(messages)
51 if (!userMsg) {
52 logger.debug("No user message found when determining current params")
53 return {
54 providerId: undefined,
55 modelId: undefined,
56 agent: undefined,
57 variant: undefined,
58 }
59 }
60 const userInfo = userMsg.info as UserMessage
61 const agent: string = userInfo.agent
62 const providerId: string | undefined = userInfo.model.providerID
63 const modelId: string | undefined = userInfo.model.modelID
64 const variant: string | undefined = userInfo.model.variant
65
66 return { providerId, modelId, agent, variant }
67}
68
69export function countTokens(text: string): number {
70 if (!text) return 0

Callers 8

handleStatsCommandFunction · 0.90
handleSweepCommandFunction · 0.90
handleContextCommandFunction · 0.90
handleHelpCommandFunction · 0.90
handleRecompressCommandFunction · 0.90
handleDecompressCommandFunction · 0.90
finalizeSessionFunction · 0.90

Calls 2

getLastUserMessageFunction · 0.90
debugMethod · 0.80

Tested by

no test coverage detected