agentinit 1.3.0 → 1.4.1
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/CHANGELOG.md +23 -0
- package/dist/agentinit-1.4.1.tgz +0 -0
- package/dist/index.js +27 -7
- package/package.json +1 -1
- package/dist/agentinit-1.3.0.tgz +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
1
|
+
## [1.4.1](https://github.com/agentinit/agentinit/compare/v1.4.0...v1.4.1) (2025-09-26)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* context calc ([313f435](https://github.com/agentinit/agentinit/commit/313f435f9e0d34f5df8d50ab34584bb522b9f69e))
|
|
7
|
+
|
|
8
|
+
# [1.4.0](https://github.com/agentinit/agentinit/compare/v1.3.0...v1.4.0) (2025-09-26)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* address comments ([b4a63e7](https://github.com/agentinit/agentinit/commit/b4a63e79b376d059e2403ad396b779912e8ca50e))
|
|
14
|
+
* dirty fix with token calcs ([e7d3ef9](https://github.com/agentinit/agentinit/commit/e7d3ef98ea700937f2ccbd448ff18da02e65d1cd))
|
|
15
|
+
* **mcp:** improve token calculation accuracy for different schema types ([6f85f8b](https://github.com/agentinit/agentinit/commit/6f85f8b8448e8a391029f7bd50f975be5818ff7e))
|
|
16
|
+
* **mcp:** use minified JSON to prevent token inflation ([c5885c2](https://github.com/agentinit/agentinit/commit/c5885c277ac920781919178786386130b04b7633))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Features
|
|
20
|
+
|
|
21
|
+
* improve token calc ([107a8d7](https://github.com/agentinit/agentinit/commit/107a8d7b5b849a7dfc4dd776474c7d0bcd11c179))
|
|
22
|
+
* **mcp:** significantly improve token calculation accuracy ([c7c5137](https://github.com/agentinit/agentinit/commit/c7c51377565e2ab110262c859d05a988a39a80ee))
|
|
23
|
+
|
|
1
24
|
# [1.3.0](https://github.com/agentinit/agentinit/compare/v1.2.1...v1.3.0) (2025-09-24)
|
|
2
25
|
|
|
3
26
|
|
|
Binary file
|
package/dist/index.js
CHANGED
|
@@ -32285,18 +32285,38 @@ class MCPVerifier {
|
|
|
32285
32285
|
return yellow(tokenCount.toString());
|
|
32286
32286
|
return red(tokenCount.toString());
|
|
32287
32287
|
}
|
|
32288
|
-
calculateToolTokens(tools) {
|
|
32288
|
+
calculateToolTokens(tools, serverName) {
|
|
32289
32289
|
const toolTokenCounts = new Map;
|
|
32290
32290
|
let totalToolTokens = 0;
|
|
32291
32291
|
for (const tool of tools) {
|
|
32292
32292
|
try {
|
|
32293
|
+
const rawSchema = tool.inputSchema && typeof tool.inputSchema === "object" ? tool.inputSchema : undefined;
|
|
32294
|
+
const schemaType = rawSchema?.type;
|
|
32295
|
+
const parameters = {
|
|
32296
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
32297
|
+
...rawSchema ?? {}
|
|
32298
|
+
};
|
|
32299
|
+
const hasObjectHints = rawSchema !== undefined && ["properties", "required", "additionalProperties", "patternProperties"].some((key) => (key in rawSchema));
|
|
32300
|
+
const isObjectSchema = rawSchema === undefined || schemaType === "object" || Array.isArray(schemaType) && schemaType.includes("object") || hasObjectHints;
|
|
32301
|
+
if (isObjectSchema) {
|
|
32302
|
+
if (!("type" in parameters))
|
|
32303
|
+
parameters.type = "object";
|
|
32304
|
+
if (!("properties" in parameters))
|
|
32305
|
+
parameters.properties = {};
|
|
32306
|
+
if (!("required" in parameters))
|
|
32307
|
+
parameters.required = [];
|
|
32308
|
+
if (!("additionalProperties" in parameters))
|
|
32309
|
+
parameters.additionalProperties = false;
|
|
32310
|
+
}
|
|
32311
|
+
const prefixedToolName = `mcp__${serverName}__${tool.name}`;
|
|
32293
32312
|
const toolForCounting = {
|
|
32294
|
-
name:
|
|
32295
|
-
description: tool.description
|
|
32296
|
-
|
|
32313
|
+
name: prefixedToolName,
|
|
32314
|
+
...tool.description !== undefined ? { description: tool.description } : {},
|
|
32315
|
+
parameters
|
|
32297
32316
|
};
|
|
32298
|
-
const
|
|
32299
|
-
const
|
|
32317
|
+
const functionDefinition = JSON.stringify(toolForCounting);
|
|
32318
|
+
const claudeToolRepresentation = `<function>${functionDefinition}</function>`;
|
|
32319
|
+
const tokenCount = countTokens(claudeToolRepresentation) * 5;
|
|
32300
32320
|
toolTokenCounts.set(tool.name, tokenCount);
|
|
32301
32321
|
totalToolTokens += tokenCount;
|
|
32302
32322
|
} catch (error) {
|
|
@@ -32489,7 +32509,7 @@ class MCPVerifier {
|
|
|
32489
32509
|
}));
|
|
32490
32510
|
} catch (error) {
|
|
32491
32511
|
}
|
|
32492
|
-
const { toolTokenCounts, totalToolTokens } = this.calculateToolTokens(tools);
|
|
32512
|
+
const { toolTokenCounts, totalToolTokens } = this.calculateToolTokens(tools, server.name);
|
|
32493
32513
|
return {
|
|
32494
32514
|
tools,
|
|
32495
32515
|
resources,
|
package/package.json
CHANGED
package/dist/agentinit-1.3.0.tgz
DELETED
|
Binary file
|