@essentialai/cogent-bridge 2.0.2 → 2.0.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"get-history.d.ts","sourceRoot":"","sources":["../../src/tools/get-history.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAMpE,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA4C9D"}
1
+ {"version":3,"file":"get-history.d.ts","sourceRoot":"","sources":["../../src/tools/get-history.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAapE,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA8D9D"}
@@ -2,14 +2,21 @@ import { z } from "zod";
2
2
  import { getBackend } from "../backend/index.js";
3
3
  import { successResult, errorResult } from "../errors.js";
4
4
  import { logger } from "../logger.js";
5
+ /**
6
+ * Maximum total character count for the tool response.
7
+ * Keeps the result safely below Claude Code's MCP result size limit.
8
+ * Older messages are dropped first when the budget is exceeded.
9
+ */
10
+ const MAX_RESULT_CHARS = 50_000;
5
11
  export function registerGetHistoryTool(server) {
6
12
  server.registerTool("cogent_get_history", {
7
13
  title: "Get Message History",
8
14
  description: "Retrieve the message history for the bridge. " +
9
15
  "Optionally filter by a specific peer ID. " +
10
- "Returns messages in chronological order, most recent last. " +
11
- "IMPORTANT: Do NOT pass a small limit always omit the limit parameter to get the full default of 150 messages. " +
12
- "Users need to see their complete conversation history.",
16
+ "Returns the most recent messages that fit within a 50,000-character response budget " +
17
+ "older messages are omitted when AI responses are large (code blocks, long explanations). " +
18
+ "Use peerId to filter to a specific conversation thread for focused context. " +
19
+ "Returns messages in chronological order, most recent last.",
13
20
  inputSchema: {
14
21
  peerId: z
15
22
  .string()
@@ -18,10 +25,9 @@ export function registerGetHistoryTool(server) {
18
25
  limit: z
19
26
  .number()
20
27
  .optional()
21
- .default(150)
22
- .describe("Maximum number of messages to return. Defaults to 150. " +
23
- "Do NOT reduce this users expect to see their full history. " +
24
- "Only set this if the user explicitly asks for fewer messages."),
28
+ .default(30)
29
+ .describe("Maximum number of messages to fetch. Defaults to 30. " +
30
+ "Increase if you need more history context."),
25
31
  },
26
32
  annotations: {
27
33
  readOnlyHint: true,
@@ -33,7 +39,24 @@ export function registerGetHistoryTool(server) {
33
39
  try {
34
40
  const backend = getBackend();
35
41
  const messages = await backend.getHistory(peerId, limit);
36
- return successResult({ messages, count: messages.length });
42
+ // Apply response budget: keep the newest messages that fit within
43
+ // MAX_RESULT_CHARS to avoid exceeding Claude Code's MCP result size limit.
44
+ const trimmed = [];
45
+ let chars = 0;
46
+ for (let i = messages.length - 1; i >= 0; i--) {
47
+ const size = JSON.stringify(messages[i]).length;
48
+ if (chars + size > MAX_RESULT_CHARS)
49
+ break;
50
+ trimmed.unshift(messages[i]);
51
+ chars += size;
52
+ }
53
+ const truncated = trimmed.length < messages.length;
54
+ return successResult({
55
+ messages: trimmed,
56
+ count: trimmed.length,
57
+ truncated,
58
+ totalAvailable: messages.length,
59
+ });
37
60
  }
38
61
  catch (err) {
39
62
  logger.error("get-history failed", { error: err });
@@ -1 +1 @@
1
- {"version":3,"file":"get-history.js","sourceRoot":"","sources":["../../src/tools/get-history.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,MAAM,UAAU,sBAAsB,CAAC,MAAiB;IACtD,MAAM,CAAC,YAAY,CACjB,oBAAoB,EACpB;QACE,KAAK,EAAE,qBAAqB;QAC5B,WAAW,EACT,+CAA+C;YAC/C,2CAA2C;YAC3C,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AAM;gBAC3C,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC7B,KAAK,IAAI,IAAI,CAAC;YAChB,CAAC;YAED,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;YACnD,OAAO,aAAa,CAAC;gBACnB,QAAQ,EAAE,OAAO;gBACjB,KAAK,EAAE,OAAO,CAAC,MAAM;gBACrB,SAAS;gBACT,cAAc,EAAE,QAAQ,CAAC,MAAM;aAChC,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,CAAC,KAAK,CAAC,oBAAoB,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;YACnD,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@essentialai/cogent-bridge",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "description": "MCP server for inter-Claude-Code session communication bridge",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/server.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "name": "io.github.eaisdevelopment/cogent",
4
4
  "title": "Cogent Bridge from Essential AI Solutions (essentialai.uk)",
5
5
  "description": "MCP bridge for inter-session communication between Claude Code instances",
6
- "version": "2.0.2",
6
+ "version": "2.0.3",
7
7
  "repository": {
8
8
  "url": "https://github.com/eaisdevelopment/cogent",
9
9
  "source": "github"
@@ -12,7 +12,7 @@
12
12
  {
13
13
  "registryType": "npm",
14
14
  "identifier": "@essentialai/cogent-bridge",
15
- "version": "2.0.2",
15
+ "version": "2.0.3",
16
16
  "runtimeHint": "npx",
17
17
  "transport": {
18
18
  "type": "stdio"