@decocms/bindings 1.4.3 → 1.4.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/bindings",
3
- "version": "1.4.3",
3
+ "version": "1.4.4",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "check": "tsc --noEmit",
@@ -20,25 +20,6 @@ type Tool = {
20
20
 
21
21
  const toolsMap = new Map<string, Promise<Array<Tool>>>();
22
22
 
23
- // Memoize JSON-schema → Zod conversion by schema content. Zod v4 schemas carry
24
- // their methods per-instance, so a freshly-converted schema is ~18 Function/
25
- // AsyncFunction nodes; `mapTool` runs on EVERY `asCallableTools()`/`asTool()`
26
- // call, so without this an MCP server's whole tool set was re-minted into a new
27
- // Zod graph per call and retained by whatever held the result — a dominant
28
- // heap-leak vector server-side (runtime/workflows/sandbox hit this path). The
29
- // conversion is pure and Zod schemas are immutable after build, so sharing one
30
- // instance per distinct schema is safe. Distinct schema contents are bounded by
31
- // the tool catalogue, so no eviction is needed (mirrors sharedJsonSchemaValidator).
32
- const zodSchemaCache = new Map<string, unknown>();
33
- const cachedConvertJsonSchemaToZod = (schema: any) => {
34
- const key = JSON.stringify(schema);
35
- const hit = zodSchemaCache.get(key);
36
- if (hit !== undefined) return hit;
37
- const zod = convertJsonSchemaToZod(schema);
38
- zodSchemaCache.set(key, zod);
39
- return zod;
40
- };
41
-
42
23
  const mapTool = (
43
24
  tool: Tool,
44
25
  callToolFn: (input: any, toolName?: string) => Promise<any>,
@@ -47,10 +28,10 @@ const mapTool = (
47
28
  ...tool,
48
29
  id: tool.name,
49
30
  inputSchema: tool.inputSchema
50
- ? cachedConvertJsonSchemaToZod(tool.inputSchema)
31
+ ? convertJsonSchemaToZod(tool.inputSchema)
51
32
  : undefined,
52
33
  outputSchema: tool.outputSchema
53
- ? cachedConvertJsonSchemaToZod(tool.outputSchema)
34
+ ? convertJsonSchemaToZod(tool.outputSchema)
54
35
  : undefined,
55
36
  execute: (input: any) => {
56
37
  return callToolFn(input.context, tool.name);