-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprobe-tokens.ts
More file actions
30 lines (27 loc) · 835 Bytes
/
Copy pathprobe-tokens.ts
File metadata and controls
30 lines (27 loc) · 835 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import type { RecipeParamValue } from "../../src/application/recipe-params";
import { estimateTokens, jsonCharLength } from "./metrics";
/** Probe-mode token budget: prompt + payload chars, then chars/4 (plan L.4). */
export function estimateProbeTokens(
prompt: string,
payloadChars: number,
): number {
return estimateTokens(Buffer.byteLength(prompt, "utf-8") + payloadChars);
}
export function mcpOnPayloadChars(
sql: string,
rows: unknown[],
bindValues: RecipeParamValue[] = [],
): number {
return (
Buffer.byteLength(sql, "utf-8") +
jsonCharLength(bindValues) +
jsonCharLength(rows)
);
}
/** MCP-off reads full file bodies; grep hits are a small JSON tail. */
export function mcpOffPayloadChars(
bytesRead: number,
results: unknown[],
): number {
return bytesRead + jsonCharLength(results);
}