Политика размеров: MCP read_full_text для обрезанных данных, аудит без скрытого ограничения
All checks were successful
ci / test (push) Successful in 55s
ci / deploy (push) Successful in 3m13s

- fulltext.ts: хранилище полных текстов, clipForAgent (пометка ОБРЕЗАНО + ref), MCP-сервер khb_fulltext (POST /mcp/fulltext, read_full_text с offset/length)
- cli-runner: набор инструментов fulltext (--mcp-config, --strict-mcp-config, allowedTools только read_full_text)
- audit.ts: фрагмент 1500 символов, полный текст сообщения читается по ref; промт получает раздел «Доступ к полному тексту»
- убраны скрытые обрезки: reminder_history (текст, ответ), API истории агента, обращение в ИТ в Slack
- khb-sql: подсказка при лимите строк объясняет чтение по частям
- known-issues.md: политика размеров

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-04 22:10:26 +03:00
parent b331d145da
commit fd9fc8fa71
13 changed files with 222 additions and 12 deletions

View File

@@ -1,8 +1,10 @@
import { spawn } from "node:child_process";
import { FULLTEXT_TOOL } from "../fulltext.js";
import { mkdirSync } from "node:fs";
import { parseUsage, type TokenUsage } from "../usage.js";
export type ToolSet = "none" | "chat";
/** none - без инструментов; chat - инструменты шага 4; fulltext - без инструментов, кроме MCP read_full_text (чтение полного текста обрезанных данных, fulltext.ts). */
export type ToolSet = "none" | "chat" | "fulltext";
export interface ClaudeCall {
prompt: string;
@@ -56,6 +58,8 @@ export interface CliRunnerOptions {
bin: string;
timeoutMs: number;
model?: string;
/** Адрес и токен сервиса для MCP «полный текст» (ToolSet "fulltext"). */
fulltext?: { url: string; token: string };
}
/** Инструменты шага 4: Bash (ffmpeg, whisper, exiftool, khb-sql, khb-drive), ToolSearch и запросы JobTread через коннектор claude.ai. */
@@ -68,7 +72,11 @@ export function createCliRunner(opts: CliRunnerOptions): ClaudeRunner {
mkdirSync(call.cwd, { recursive: true });
const args = ["-p", "--output-format", "json", call.resume ? "--resume" : "--session-id", call.sessionId];
if (opts.model) args.push("--model", opts.model);
args.push(...(call.tools === "chat" ? CHAT_TOOLS : ["--tools", ""]));
if (call.tools === "fulltext") {
if (!opts.fulltext) return reject(new ClaudeError("ToolSet fulltext: не задан адрес сервиса для MCP", "failed"));
const mcp = { mcpServers: { khb_fulltext: { type: "http", url: `${opts.fulltext.url}/mcp/fulltext`, headers: { Authorization: `Bearer ${opts.fulltext.token}` } } } };
args.push("--tools", "", "--strict-mcp-config", "--mcp-config", JSON.stringify(mcp), "--allowedTools", FULLTEXT_TOOL);
} else args.push(...(call.tools === "chat" ? CHAT_TOOLS : ["--tools", ""]));
const child = spawn(opts.bin, args, { cwd: call.cwd, stdio: ["pipe", "pipe", "pipe"], env: { ...process.env, ANTHROPIC_API_KEY: "", ...call.env } });
const tStart = Date.now();
let out = "";

View File

@@ -131,7 +131,7 @@ export async function saveProblems(ctx: AgentContext, managerId: string, step: "
const same = (a: string, b: string) => a.replace(/\s+/g, " ").trim() === b.replace(/\s+/g, " ").trim();
if (!prev || !same(prev, itReq)) {
await ctx.pool.query("insert into agent_problem_log (manager_person_id, step, severity, body) values ($1,$2,'it_request',$3)", [managerId, step, itReq]);
await ctx.notifyIt(`${prev ? ":arrows_counterclockwise: ОБНОВЛЕНИЕ обращения агента в ИТ (заменяет предыдущее" : ":sos: Обращение агента в ИТ ("}${prev ? ", " : ""}${step}, менеджер ${managerId}): ${itReq.slice(0, 1500)}`);
await ctx.notifyIt(`${prev ? ":arrows_counterclockwise: ОБНОВЛЕНИЕ обращения агента в ИТ (заменяет предыдущее" : ":sos: Обращение агента в ИТ ("}${prev ? ", " : ""}${step}, менеджер ${managerId}): ${itReq}`);
}
}
if (log && !/^(нет|-|\(пусто\))\.?$/i.test(log))