Lines 51-91javascript
51exports.resultCharBudget = resultCharBudget;
52exports.distillToolFact = distillToolFact;
53exports.webSearch = webSearch;
54exports.binaryExtCheck = binaryExtCheck;
55exports.pickBestModel = pickBestModel;
56exports.checkBashCommandSafety = checkBashCommandSafety;
57exports.toolsProvider = toolsProvider;
58exports.headBudgetChars = headBudgetChars;
59exports.buildContextSpine = buildContextSpine;
60exports.preprocessMessage = preprocessMessage;
61const sdk_1 = require("@lmstudio/sdk");
62const zod_1 = require("zod");
63const promises_1 = require("fs/promises");
64const fs_1 = require("fs");
65const path_1 = require("path");
66const os_1 = require("os");
67const crypto_1 = require("crypto");
68const math = __importStar(require("mathjs"));
69const sessionLog_1 = require("./sessionLog");
70const config_1 = require("./config");
71const toolSettings_1 = require("./toolSettings");
72const LMSTUDIO_API_PORT = process.env.LMSTUDIO_API_PORT || "1234";
73const API_BASE = `http://localhost:${LMSTUDIO_API_PORT}`;
74// Persistent runtime data lives under extensions/data, NOT extensions/plugins — `lms dev --install`
MediumInstall Persistence
Source writes installer persistence such as shell profile or service configuration.
dist/toolsProvider.jsView on unpkg · L71 75// wipes the plugin install directory on every deploy, which would otherwise destroy this data.
76// VIBE_LM_DATA_DIR lets tests point this at an isolated directory instead of the real user install.
77const DATA_DIR = process.env.VIBE_LM_DATA_DIR || (0, path_1.resolve)((0, os_1.homedir)(), ".lmstudio", "extensions", "data", "drunkktoys", "vibe-lm");
78const CONFIG_PATH = (0, path_1.resolve)(DATA_DIR, "config.json");
79const RUNTIME_STATE_PATH = (0, path_1.resolve)(DATA_DIR, "runtime-state.json");
80const JSONL_CACHE_PATH = (0, path_1.resolve)(DATA_DIR, "session-log.jsonl");
81const DEFAULT_CONTEXT_WINDOW = 8192;
82const PROMPT_BUDGET_RATIO = 0.50;
83const MAX_TOOL_RESULT_CHARS = 500;
84const MAX_NON_CODE_RESULT_CHARS = 300;
85// Importance tiers for how much of a tool result is kept verbatim on the turn log. Flat truncation
86// treated a 2 KB file read the same as a one-line failed probe; tiering keeps more of what carries
87// information (reads/searches) and less of the noise we already distil into a fact (failures).
88const TOOL_RESULT_CHARS_HIGH = 1500;
89const TOOL_RESULT_CHARS_LOW = 300;
90const HIGH_VALUE_RESULT_TOOLS = new Set([
91 "read_file", "search_files", "list_files", "explore_workspace", "web_search",