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

Function isMessageWithInfo

lib/messages/shape.ts:3–25  ·  view source on GitHub ↗
(message: unknown)

Source from the content-addressed store, hash-verified

1import type { WithParts } from "../state"
2
3export function isMessageWithInfo(message: unknown): message is WithParts {
4 if (!message || typeof message !== "object") {
5 return false
6 }
7
8 const info = (message as any).info
9 const parts = (message as any).parts
10 if (!info || typeof info !== "object") {
11 return false
12 }
13
14 return (
15 typeof info.id === "string" &&
16 info.id.length > 0 &&
17 typeof info.sessionID === "string" &&
18 info.sessionID.length > 0 &&
19 (info.role === "user" || info.role === "assistant") &&
20 info.time &&
21 typeof info.time === "object" &&
22 typeof info.time.created === "number" &&
23 Array.isArray(parts)
24 )
25}
26
27export function filterMessages(messages: unknown): WithParts[] {
28 if (!Array.isArray(messages)) {

Callers 8

isMessageCompactedFunction · 0.90
countTurnsFunction · 0.90
getLastUserMessageFunction · 0.90
messageHasCompressFunction · 0.90
isIgnoredUserMessageFunction · 0.90
isProtectedUserMessageFunction · 0.90
filterMessagesInPlaceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected