@frontmcp/plugin-codecall 1.0.4 → 1.1.0
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/codecall.types.d.ts +135 -135
- package/codecall.types.d.ts.map +1 -1
- package/esm/index.mjs +131 -132
- package/esm/package.json +5 -5
- package/index.js +239 -240
- package/package.json +5 -5
- package/tools/describe.schema.d.ts +23 -23
- package/tools/describe.schema.d.ts.map +1 -1
- package/tools/describe.tool.d.ts +1 -1
- package/tools/describe.tool.d.ts.map +1 -1
- package/tools/execute.schema.d.ts +94 -94
- package/tools/execute.schema.d.ts.map +1 -1
- package/tools/invoke.schema.d.ts +81 -81
- package/tools/invoke.schema.d.ts.map +1 -1
- package/tools/search.schema.d.ts +21 -21
- package/tools/search.schema.d.ts.map +1 -1
- package/utils/describe.utils.d.ts +1 -1
- package/utils/describe.utils.d.ts.map +1 -1
package/esm/index.mjs
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
} from "@frontmcp/sdk";
|
|
20
20
|
|
|
21
21
|
// plugins/plugin-codecall/src/codecall.types.ts
|
|
22
|
-
import { z } from "zod";
|
|
22
|
+
import { z } from "@frontmcp/lazy-zod";
|
|
23
23
|
var directCallsFilterSchema = z.custom((val) => typeof val === "function", {
|
|
24
24
|
message: "filter must be a function with signature (tool: DirectCallsFilterToolInfo) => boolean"
|
|
25
25
|
});
|
|
@@ -1349,7 +1349,7 @@ EnclaveService = __decorateClass([
|
|
|
1349
1349
|
import { Tool, ToolContext } from "@frontmcp/sdk";
|
|
1350
1350
|
|
|
1351
1351
|
// plugins/plugin-codecall/src/tools/search.schema.ts
|
|
1352
|
-
import { z as z2 } from "zod";
|
|
1352
|
+
import { z as z2 } from "@frontmcp/lazy-zod";
|
|
1353
1353
|
var searchToolDescription = `Find tools by splitting user request into atomic actions.
|
|
1354
1354
|
|
|
1355
1355
|
DECOMPOSE: "delete users and send email" \u2192 queries: ["delete user", "send email"]
|
|
@@ -1486,61 +1486,86 @@ SearchTool = __decorateClass([
|
|
|
1486
1486
|
], SearchTool);
|
|
1487
1487
|
|
|
1488
1488
|
// plugins/plugin-codecall/src/tools/describe.tool.ts
|
|
1489
|
+
import { toJSONSchema, z as z4, ZodType } from "@frontmcp/lazy-zod";
|
|
1489
1490
|
import { Tool as Tool2, ToolContext as ToolContext2 } from "@frontmcp/sdk";
|
|
1490
|
-
import { toJSONSchema } from "zod/v4";
|
|
1491
|
-
import { z as z4, ZodType } from "zod";
|
|
1492
1491
|
|
|
1493
|
-
// plugins/plugin-codecall/src/
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
IMPORTANT: If notFound array is non-empty \u2192 re-search with corrected queries.
|
|
1502
|
-
FLOW: search \u2192 describe \u2192 execute/invoke`;
|
|
1503
|
-
var describeToolInputSchema = {
|
|
1504
|
-
toolNames: z3.array(z3.string()).min(1).superRefine((toolNames, ctx) => {
|
|
1505
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1506
|
-
const duplicates = /* @__PURE__ */ new Set();
|
|
1507
|
-
for (const name of toolNames) {
|
|
1508
|
-
if (seen.has(name)) {
|
|
1509
|
-
duplicates.add(name);
|
|
1510
|
-
}
|
|
1511
|
-
seen.add(name);
|
|
1512
|
-
}
|
|
1513
|
-
if (duplicates.size > 0) {
|
|
1514
|
-
ctx.addIssue({
|
|
1515
|
-
code: z3.ZodIssueCode.custom,
|
|
1516
|
-
message: `Duplicate tool names are not allowed: ${Array.from(duplicates).join(", ")}`
|
|
1517
|
-
});
|
|
1518
|
-
}
|
|
1519
|
-
}).describe(
|
|
1520
|
-
'Array of unique tool names (from codecall:search results) to fetch their detailed schemas and usage examples. Example: ["users:list", "billing:getInvoice"]'
|
|
1521
|
-
)
|
|
1492
|
+
// plugins/plugin-codecall/src/errors/tool-call.errors.ts
|
|
1493
|
+
var TOOL_CALL_ERROR_CODES = {
|
|
1494
|
+
NOT_FOUND: "NOT_FOUND",
|
|
1495
|
+
VALIDATION: "VALIDATION",
|
|
1496
|
+
EXECUTION: "EXECUTION",
|
|
1497
|
+
TIMEOUT: "TIMEOUT",
|
|
1498
|
+
ACCESS_DENIED: "ACCESS_DENIED",
|
|
1499
|
+
SELF_REFERENCE: "SELF_REFERENCE"
|
|
1522
1500
|
};
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1501
|
+
function createToolCallError(code, toolName, rawMessage) {
|
|
1502
|
+
const sanitizedMessage = getSanitizedMessage(code, toolName, rawMessage);
|
|
1503
|
+
return Object.freeze({
|
|
1504
|
+
code,
|
|
1505
|
+
message: sanitizedMessage,
|
|
1506
|
+
toolName
|
|
1507
|
+
});
|
|
1508
|
+
}
|
|
1509
|
+
function getSanitizedMessage(code, toolName, rawMessage) {
|
|
1510
|
+
switch (code) {
|
|
1511
|
+
case TOOL_CALL_ERROR_CODES.NOT_FOUND:
|
|
1512
|
+
return `Tool "${toolName}" was not found`;
|
|
1513
|
+
case TOOL_CALL_ERROR_CODES.VALIDATION:
|
|
1514
|
+
return rawMessage ? sanitizeValidationMessage(rawMessage) : `Input validation failed for tool "${toolName}"`;
|
|
1515
|
+
case TOOL_CALL_ERROR_CODES.EXECUTION:
|
|
1516
|
+
return `Tool "${toolName}" execution failed`;
|
|
1517
|
+
case TOOL_CALL_ERROR_CODES.TIMEOUT:
|
|
1518
|
+
return `Tool "${toolName}" execution timed out`;
|
|
1519
|
+
case TOOL_CALL_ERROR_CODES.ACCESS_DENIED:
|
|
1520
|
+
return `Access denied for tool "${toolName}"`;
|
|
1521
|
+
case TOOL_CALL_ERROR_CODES.SELF_REFERENCE:
|
|
1522
|
+
return `Cannot call CodeCall tools from within AgentScript`;
|
|
1523
|
+
default:
|
|
1524
|
+
return `An error occurred while calling "${toolName}"`;
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
function sanitizeValidationMessage(message) {
|
|
1528
|
+
let sanitized = message.replace(/(?:\/[\w.-]+)+|(?:[A-Za-z]:\\[\w\\.-]+)+/g, "[path]");
|
|
1529
|
+
sanitized = sanitized.replace(/\bat line \d+/gi, "");
|
|
1530
|
+
sanitized = sanitized.replace(/\bline \d+/gi, "");
|
|
1531
|
+
sanitized = sanitized.replace(/:\d+:\d+/g, "");
|
|
1532
|
+
sanitized = sanitized.replace(/\n\s*at .*/g, "");
|
|
1533
|
+
if (sanitized.length > 200) {
|
|
1534
|
+
sanitized = sanitized.substring(0, 200) + "...";
|
|
1535
|
+
}
|
|
1536
|
+
return sanitized.trim();
|
|
1537
|
+
}
|
|
1538
|
+
var SelfReferenceError = class extends Error {
|
|
1539
|
+
code = TOOL_CALL_ERROR_CODES.SELF_REFERENCE;
|
|
1540
|
+
toolName;
|
|
1541
|
+
constructor(toolName) {
|
|
1542
|
+
super(`Self-reference attack: Attempted to call CodeCall tool "${toolName}" from within AgentScript`);
|
|
1543
|
+
this.name = "SelfReferenceError";
|
|
1544
|
+
this.toolName = toolName;
|
|
1545
|
+
Object.freeze(this);
|
|
1546
|
+
}
|
|
1547
|
+
};
|
|
1548
|
+
|
|
1549
|
+
// plugins/plugin-codecall/src/security/self-reference-guard.ts
|
|
1550
|
+
var CODECALL_TOOL_PREFIX = "codecall:";
|
|
1551
|
+
var BLOCKED_CODECALL_TOOLS = Object.freeze(
|
|
1552
|
+
/* @__PURE__ */ new Set(["codecall:search", "codecall:describe", "codecall:execute", "codecall:invoke"])
|
|
1553
|
+
);
|
|
1554
|
+
function isBlockedSelfReference(toolName) {
|
|
1555
|
+
const normalizedName = toolName.toLowerCase().trim();
|
|
1556
|
+
if (normalizedName.startsWith(CODECALL_TOOL_PREFIX)) {
|
|
1557
|
+
return true;
|
|
1558
|
+
}
|
|
1559
|
+
if (BLOCKED_CODECALL_TOOLS.has(toolName)) {
|
|
1560
|
+
return true;
|
|
1561
|
+
}
|
|
1562
|
+
return false;
|
|
1563
|
+
}
|
|
1564
|
+
function assertNotSelfReference(toolName) {
|
|
1565
|
+
if (isBlockedSelfReference(toolName)) {
|
|
1566
|
+
throw new SelfReferenceError(toolName);
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1544
1569
|
|
|
1545
1570
|
// plugins/plugin-codecall/src/utils/describe.utils.ts
|
|
1546
1571
|
var INTENT_PATTERNS = {
|
|
@@ -1830,83 +1855,57 @@ function extractResultFromCallToolResult(mcpResult) {
|
|
|
1830
1855
|
return content;
|
|
1831
1856
|
}
|
|
1832
1857
|
|
|
1833
|
-
// plugins/plugin-codecall/src/
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
EXECUTION: "EXECUTION",
|
|
1838
|
-
TIMEOUT: "TIMEOUT",
|
|
1839
|
-
ACCESS_DENIED: "ACCESS_DENIED",
|
|
1840
|
-
SELF_REFERENCE: "SELF_REFERENCE"
|
|
1841
|
-
};
|
|
1842
|
-
function createToolCallError(code, toolName, rawMessage) {
|
|
1843
|
-
const sanitizedMessage = getSanitizedMessage(code, toolName, rawMessage);
|
|
1844
|
-
return Object.freeze({
|
|
1845
|
-
code,
|
|
1846
|
-
message: sanitizedMessage,
|
|
1847
|
-
toolName
|
|
1848
|
-
});
|
|
1849
|
-
}
|
|
1850
|
-
function getSanitizedMessage(code, toolName, rawMessage) {
|
|
1851
|
-
switch (code) {
|
|
1852
|
-
case TOOL_CALL_ERROR_CODES.NOT_FOUND:
|
|
1853
|
-
return `Tool "${toolName}" was not found`;
|
|
1854
|
-
case TOOL_CALL_ERROR_CODES.VALIDATION:
|
|
1855
|
-
return rawMessage ? sanitizeValidationMessage(rawMessage) : `Input validation failed for tool "${toolName}"`;
|
|
1856
|
-
case TOOL_CALL_ERROR_CODES.EXECUTION:
|
|
1857
|
-
return `Tool "${toolName}" execution failed`;
|
|
1858
|
-
case TOOL_CALL_ERROR_CODES.TIMEOUT:
|
|
1859
|
-
return `Tool "${toolName}" execution timed out`;
|
|
1860
|
-
case TOOL_CALL_ERROR_CODES.ACCESS_DENIED:
|
|
1861
|
-
return `Access denied for tool "${toolName}"`;
|
|
1862
|
-
case TOOL_CALL_ERROR_CODES.SELF_REFERENCE:
|
|
1863
|
-
return `Cannot call CodeCall tools from within AgentScript`;
|
|
1864
|
-
default:
|
|
1865
|
-
return `An error occurred while calling "${toolName}"`;
|
|
1866
|
-
}
|
|
1867
|
-
}
|
|
1868
|
-
function sanitizeValidationMessage(message) {
|
|
1869
|
-
let sanitized = message.replace(/(?:\/[\w.-]+)+|(?:[A-Za-z]:\\[\w\\.-]+)+/g, "[path]");
|
|
1870
|
-
sanitized = sanitized.replace(/\bat line \d+/gi, "");
|
|
1871
|
-
sanitized = sanitized.replace(/\bline \d+/gi, "");
|
|
1872
|
-
sanitized = sanitized.replace(/:\d+:\d+/g, "");
|
|
1873
|
-
sanitized = sanitized.replace(/\n\s*at .*/g, "");
|
|
1874
|
-
if (sanitized.length > 200) {
|
|
1875
|
-
sanitized = sanitized.substring(0, 200) + "...";
|
|
1876
|
-
}
|
|
1877
|
-
return sanitized.trim();
|
|
1878
|
-
}
|
|
1879
|
-
var SelfReferenceError = class extends Error {
|
|
1880
|
-
code = TOOL_CALL_ERROR_CODES.SELF_REFERENCE;
|
|
1881
|
-
toolName;
|
|
1882
|
-
constructor(toolName) {
|
|
1883
|
-
super(`Self-reference attack: Attempted to call CodeCall tool "${toolName}" from within AgentScript`);
|
|
1884
|
-
this.name = "SelfReferenceError";
|
|
1885
|
-
this.toolName = toolName;
|
|
1886
|
-
Object.freeze(this);
|
|
1887
|
-
}
|
|
1888
|
-
};
|
|
1858
|
+
// plugins/plugin-codecall/src/tools/describe.schema.ts
|
|
1859
|
+
import { z as z3 } from "@frontmcp/lazy-zod";
|
|
1860
|
+
import { ToolAnnotationsSchema } from "@frontmcp/protocol";
|
|
1861
|
+
var describeToolDescription = `Get input/output schemas for tools from search results.
|
|
1889
1862
|
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
}
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
}
|
|
1863
|
+
INPUT: toolNames: string[] - tool names from search
|
|
1864
|
+
OUTPUT per tool: inputSchema (JSON Schema), outputSchema (JSON Schema), usageExamples (up to 5 callTool examples)
|
|
1865
|
+
|
|
1866
|
+
IMPORTANT: If notFound array is non-empty \u2192 re-search with corrected queries.
|
|
1867
|
+
FLOW: search \u2192 describe \u2192 execute/invoke`;
|
|
1868
|
+
var describeToolInputSchema = {
|
|
1869
|
+
toolNames: z3.array(z3.string()).min(1).superRefine((toolNames, ctx) => {
|
|
1870
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1871
|
+
const duplicates = /* @__PURE__ */ new Set();
|
|
1872
|
+
for (const name of toolNames) {
|
|
1873
|
+
if (seen.has(name)) {
|
|
1874
|
+
duplicates.add(name);
|
|
1875
|
+
}
|
|
1876
|
+
seen.add(name);
|
|
1877
|
+
}
|
|
1878
|
+
if (duplicates.size > 0) {
|
|
1879
|
+
ctx.addIssue({
|
|
1880
|
+
code: z3.ZodIssueCode.custom,
|
|
1881
|
+
message: `Duplicate tool names are not allowed: ${Array.from(duplicates).join(", ")}`
|
|
1882
|
+
});
|
|
1883
|
+
}
|
|
1884
|
+
}).describe(
|
|
1885
|
+
'Array of unique tool names (from codecall:search results) to fetch their detailed schemas and usage examples. Example: ["users:list", "billing:getInvoice"]'
|
|
1886
|
+
)
|
|
1887
|
+
};
|
|
1888
|
+
var describeToolOutputSchema = z3.object({
|
|
1889
|
+
tools: z3.array(
|
|
1890
|
+
z3.object({
|
|
1891
|
+
name: z3.string().describe("Tool name to be used in callTool() within codecall:execute scripts"),
|
|
1892
|
+
appId: z3.string().describe("The app ID this tool belongs to"),
|
|
1893
|
+
description: z3.string().describe("Detailed description of what this tool does"),
|
|
1894
|
+
inputSchema: z3.record(z3.string(), z3.unknown()).nullable().describe("JSON Schema object describing the tool input parameters"),
|
|
1895
|
+
outputSchema: z3.record(z3.string(), z3.unknown()).nullable().describe("JSON Schema object describing the tool output structure"),
|
|
1896
|
+
annotations: ToolAnnotationsSchema.optional().describe("MCP tool annotations (metadata)"),
|
|
1897
|
+
usageExamples: z3.array(
|
|
1898
|
+
z3.object({
|
|
1899
|
+
description: z3.string().describe("Description of what this example demonstrates"),
|
|
1900
|
+
code: z3.string().describe(
|
|
1901
|
+
'JavaScript code example showing how to call this tool using callTool(). Format: const result = await callTool("tool:name", { ...params });'
|
|
1902
|
+
)
|
|
1903
|
+
})
|
|
1904
|
+
).max(5).describe("Up to 5 practical examples of how to use this tool in a codecall:execute script")
|
|
1905
|
+
})
|
|
1906
|
+
).describe("Array of tool descriptions with schemas and usage examples"),
|
|
1907
|
+
notFound: z3.array(z3.string()).optional().describe("Tool names that were requested but not found in the index. Check these for typos.")
|
|
1908
|
+
});
|
|
1910
1909
|
|
|
1911
1910
|
// plugins/plugin-codecall/src/tools/describe.tool.ts
|
|
1912
1911
|
var DescribeTool = class extends ToolContext2 {
|
|
@@ -2080,7 +2079,7 @@ DescribeTool = __decorateClass([
|
|
|
2080
2079
|
import { Tool as Tool3, ToolContext as ToolContext3 } from "@frontmcp/sdk";
|
|
2081
2080
|
|
|
2082
2081
|
// plugins/plugin-codecall/src/tools/execute.schema.ts
|
|
2083
|
-
import { z as z5 } from "zod";
|
|
2082
|
+
import { z as z5 } from "@frontmcp/lazy-zod";
|
|
2084
2083
|
var MIN_EXECUTE_SCRIPT_LENGTH = 'return callTool("a",{})'.length;
|
|
2085
2084
|
var executeToolDescription = `Execute AgentScript (safe JS subset) for multi-tool orchestration.
|
|
2086
2085
|
|
|
@@ -2463,7 +2462,7 @@ ExecuteTool = __decorateClass([
|
|
|
2463
2462
|
import { Tool as Tool4, ToolContext as ToolContext4 } from "@frontmcp/sdk";
|
|
2464
2463
|
|
|
2465
2464
|
// plugins/plugin-codecall/src/tools/invoke.schema.ts
|
|
2466
|
-
import { z as z6 } from "zod";
|
|
2465
|
+
import { z as z6 } from "@frontmcp/lazy-zod";
|
|
2467
2466
|
import { CallToolResultSchema } from "@frontmcp/protocol";
|
|
2468
2467
|
var invokeToolDescription = `Call ONE tool directly. Returns standard MCP CallToolResult.
|
|
2469
2468
|
|
package/esm/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontmcp/plugin-codecall",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "CodeCall plugin for FrontMCP - AgentScript-based meta-tools for orchestrating MCP tools",
|
|
5
5
|
"author": "AgentFront <info@agentfront.dev>",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -47,12 +47,12 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@enclave-vm/core": "^2.13.0",
|
|
49
49
|
"vectoriadb": "^2.2.0",
|
|
50
|
-
"@frontmcp/protocol": "1.0
|
|
51
|
-
"@frontmcp/sdk": "1.0
|
|
52
|
-
"zod": "^4.0.0"
|
|
50
|
+
"@frontmcp/protocol": "1.1.0",
|
|
51
|
+
"@frontmcp/sdk": "1.1.0"
|
|
53
52
|
},
|
|
54
53
|
"peerDependencies": {
|
|
55
|
-
"@frontmcp/plugin-cache": "1.0
|
|
54
|
+
"@frontmcp/plugin-cache": "1.1.0",
|
|
55
|
+
"@frontmcp/lazy-zod": "1.1.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"reflect-metadata": "^0.2.2"
|