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

Function validateArgs

lib/compress/range-utils.ts:14–39  ·  view source on GitHub ↗
(args: CompressRangeToolArgs)

Source from the content-addressed store, hash-verified

12const BLOCK_PLACEHOLDER_REGEX = /\(b(\d+)\)|\{block_(\d+)\}/gi
13
14export function validateArgs(args: CompressRangeToolArgs): void {
15 if (typeof args.topic !== "string" || args.topic.trim().length === 0) {
16 throw new Error("topic is required and must be a non-empty string")
17 }
18
19 if (!Array.isArray(args.content) || args.content.length === 0) {
20 throw new Error("content is required and must be a non-empty array")
21 }
22
23 for (let index = 0; index < args.content.length; index++) {
24 const entry = args.content[index]
25 const prefix = `content[${index}]`
26
27 if (typeof entry?.startId !== "string" || entry.startId.trim().length === 0) {
28 throw new Error(`${prefix}.startId is required and must be a non-empty string`)
29 }
30
31 if (typeof entry?.endId !== "string" || entry.endId.trim().length === 0) {
32 throw new Error(`${prefix}.endId is required and must be a non-empty string`)
33 }
34
35 if (typeof entry?.summary !== "string" || entry.summary.trim().length === 0) {
36 throw new Error(`${prefix}.summary is required and must be a non-empty string`)
37 }
38 }
39}
40
41export function resolveRanges(
42 args: CompressRangeToolArgs,

Callers 1

executeFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected