integram-mcp 0.7.154 → 0.7.156

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -15,7 +15,7 @@ claude mcp add integram \
15
15
  -e INTEGRAM_URL=https://ai2o.online \
16
16
  -e INTEGRAM_EMAIL=you@example.com \
17
17
  -e INTEGRAM_PASSWORD=secret \
18
- -- npx -y integram-mcp@0.7.154
18
+ -- npx -y integram-mcp@0.7.156
19
19
  ```
20
20
 
21
21
  Ставить ничего не нужно: `npx` скачает пакет сам.
@@ -49,7 +49,7 @@ claude mcp add integram \
49
49
  -e INTEGRAM_URL=http://localhost:8081 \
50
50
  -e INTEGRAM_EMAIL=you@example.com \
51
51
  -e INTEGRAM_PASSWORD=secret \
52
- -- npx -y integram-mcp@0.7.154
52
+ -- npx -y integram-mcp@0.7.156
53
53
  ```
54
54
 
55
55
  Удалить: `claude mcp remove integram`
@@ -63,7 +63,7 @@ claude mcp add integram \
63
63
  "mcpServers": {
64
64
  "integram": {
65
65
  "command": "npx",
66
- "args": ["-y", "integram-mcp@0.7.154"],
66
+ "args": ["-y", "integram-mcp@0.7.156"],
67
67
  "env": {
68
68
  "INTEGRAM_URL": "https://ai2o.online",
69
69
  "INTEGRAM_EMAIL": "you@example.com",
@@ -83,7 +83,7 @@ claude mcp add integram \
83
83
  "mcpServers": {
84
84
  "integram": {
85
85
  "command": "npx",
86
- "args": ["-y", "integram-mcp@0.7.154"],
86
+ "args": ["-y", "integram-mcp@0.7.156"],
87
87
  "env": {
88
88
  "INTEGRAM_URL": "https://ai2o.online",
89
89
  "INTEGRAM_EMAIL": "you@example.com",
package/index.js CHANGED
@@ -26,7 +26,7 @@ import { createRequire } from 'module';
26
26
  import { rememberActivation as rememberActivationIn, applyActivation, forgetActivation } from './activation-memory.js';
27
27
  import { startOrphanWatchdog } from './orphan-watchdog.js';
28
28
  import { enqueuePending, takePending } from './pending-hitl.js';
29
- import { compactToolResult } from './output-cap.js';
29
+ import { compactToolResult, compactErrorDetails } from './output-cap.js';
30
30
  import { extractRefreshToken, pickAccessToken } from './auth-token.js';
31
31
 
32
32
  // Own identity — read from package.json, never hardcoded: a hardcoded copy drifts
@@ -80,7 +80,7 @@ async function apiFetch(path, opts = {}, _retried = false) {
80
80
  export function toolErrorResult(err) {
81
81
  const be = err?.body?.error;
82
82
  const text = be
83
- ? `Error: ${be.message || err.message}${be.details ? '\n\n' + JSON.stringify(be.details, null, 2) : ''}${be.hint ? '\n\nHint: ' + be.hint : ''}`
83
+ ? `Error: ${be.message || err.message}${be.details ? '\n\n' + JSON.stringify(compactErrorDetails(be.details), null, 2) : ''}${be.hint ? '\n\nHint: ' + be.hint : ''}`
84
84
  : `Error: ${err?.message}`;
85
85
  return { content: [{ type: 'text', text }], isError: true };
86
86
  }
@@ -1632,7 +1632,7 @@ async function dispatchTool(request) {
1632
1632
  // с исходной версией, новый baseCommit, признак повторяемости.
1633
1633
  // Без него вызывающий видит только текст и вынужден гадать.
1634
1634
  const text = result.details
1635
- ? `Error: ${result.message}\n\n${JSON.stringify(result.details, null, 2)}`
1635
+ ? `Error: ${result.message}\n\n${JSON.stringify(compactErrorDetails(result.details), null, 2)}`
1636
1636
  : `Error: ${result.message}`;
1637
1637
  return { content: [{ type: 'text', text }], isError: true };
1638
1638
  }
package/output-cap.js CHANGED
@@ -163,10 +163,11 @@ export function compactToolResult(toolName, result) {
163
163
  }
164
164
 
165
165
  if (!fields) {
166
+ const partial = fitPartial(raw, OUTPUT_MAX_CHARS - 2000);
166
167
  fields = {
167
- _compacted: `Показана часть: ${fmtKb(OUTPUT_MAX_CHARS - 2000)} из ${fmtKb(raw.length)}. Это НЕ полный ответ.`,
168
+ _compacted: `Показана часть: ${fmtKb(partial.length)} из ${fmtKb(raw.length)}. Это НЕ полный ответ.`,
168
169
  ...promoted,
169
- partial: fitPartial(raw, OUTPUT_MAX_CHARS - 2000),
170
+ partial,
170
171
  _howToContinue: howToContinue(toolName, result),
171
172
  };
172
173
  }
@@ -176,12 +177,65 @@ export function compactToolResult(toolName, result) {
176
177
  // бюджет partial урезается на размер promoted, чтобы и здесь влезть.
177
178
  if (out.length > OUTPUT_MAX_CHARS) {
178
179
  const promotedJson = JSON.stringify(promoted);
180
+ const partial = fitPartial(raw, Math.max(OUTPUT_MAX_CHARS - 2000 - promotedJson.length, 500));
179
181
  out = JSON.stringify(envelope(toolName, {
180
- _compacted: `Показана часть: ${fmtKb(OUTPUT_MAX_CHARS - 2000)} из ${fmtKb(raw.length)}. Это НЕ полный ответ.`,
182
+ _compacted: `Показана часть: ${fmtKb(partial.length)} из ${fmtKb(raw.length)}. Это НЕ полный ответ.`,
181
183
  ...promoted,
182
- partial: fitPartial(raw, Math.max(OUTPUT_MAX_CHARS - 2000 - promotedJson.length, 500)),
184
+ partial,
183
185
  _howToContinue: howToContinue(toolName, result),
184
186
  }, raw.length));
185
187
  }
186
188
  return out;
187
189
  }
190
+
191
+ // ── Кэп details ОШИБКИ ──
192
+ // Стратегия «мелкое выживает»: служебные поля (baseCommit, hint, счётчики) —
193
+ // это forensic passport ошибки, без которого агент не может продолжить
194
+ // (канон Anthropic: усечение рулит текстом). Громоздкие блоки (конфликты
195
+ // мержа, дампы) режутся, выброшенные ключи честно перечисляются.
196
+ const ERROR_DETAILS_BUDGET = 20000;
197
+ const SMALL_VALUE_CHARS = 1000;
198
+
199
+ export function compactErrorDetails(details, budget = ERROR_DETAILS_BUDGET) {
200
+ if (details == null || typeof details !== 'object') return details;
201
+ if (Array.isArray(details)) {
202
+ // Массив — форма ошибки, не словарь: форму сохраняем, бюджету подчиняем
203
+ // (одиночный срез по соотношению размеров, с доводкой — эскейп-тяжёлые
204
+ // элементы могут надуть сериализацию после среза).
205
+ let arr = details;
206
+ for (let i = 0; i < 20 && arr.length > 1 && JSON.stringify(arr, null, 2).length > budget; i++) {
207
+ arr = arr.slice(0, Math.max(1, Math.floor(arr.length * budget / JSON.stringify(arr, null, 2).length)));
208
+ }
209
+ return arr;
210
+ }
211
+ // 'undefined' вместо падения: JSON.stringify(undefined) === undefined —
212
+ // живой объект (не из JSON.parse) не должен ломать весь error-путь.
213
+ const size = (v) => (JSON.stringify(v, null, 2) ?? 'undefined').length;
214
+ const entries = Object.entries(details);
215
+ const small = entries.filter(([, v]) => size(v) <= SMALL_VALUE_CHARS);
216
+ const big = entries.filter(([, v]) => size(v) > SMALL_VALUE_CHARS);
217
+ const out = {};
218
+ const dropped = [];
219
+ let used = 2;
220
+ // Сначала всё мелкое (пока влезает) — служебные поля важнее громоздких.
221
+ for (const [k, v] of small) {
222
+ const s = size(v);
223
+ if (used + s > budget) { dropped.push(k); continue; }
224
+ out[k] = v;
225
+ used += s + k.length + 6;
226
+ }
227
+ // Потом крупные — по остаточному бюджету.
228
+ for (const [k, v] of big) {
229
+ const s = size(v);
230
+ if (used + s > budget) { dropped.push(k); continue; }
231
+ out[k] = v;
232
+ used += s + k.length + 6;
233
+ }
234
+ if (dropped.length) {
235
+ // Наши ключи — последними: данные details не могут подделать сигнал
236
+ // (собственный _droppedDetails/_hint из details затирается здесь).
237
+ out._droppedDetails = dropped;
238
+ out._hint = `Часть деталей ошибки урезана по размеру: ${dropped.join(', ')}. Мелкие служебные поля (baseCommit и т.п.) сохранены — без них продолжение невозможно.`;
239
+ }
240
+ return out;
241
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "integram-mcp",
3
- "version": "0.7.154",
3
+ "version": "0.7.156",
4
4
  "type": "module",
5
5
  "description": "MCP server for Integram — connect AI assistants to your workspace via Model Context Protocol",
6
6
  "mcpName": "io.github.judas-priest/integram",