@frontmcp/plugin-codecall 1.9.1-rc.3 → 1.9.2
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.plugin.d.ts +8 -1
- package/codecall.plugin.d.ts.map +1 -1
- package/codecall.types.d.ts.map +1 -1
- package/esm/index.mjs +156 -37
- package/esm/package.json +6 -6
- package/index.js +153 -39
- package/package.json +6 -6
- package/security/script-policy.d.ts +12 -0
- package/security/script-policy.d.ts.map +1 -0
- package/services/enclave.service.d.ts.map +1 -1
- package/services/tool-search.service.d.ts.map +1 -1
- package/tools/describe.schema.d.ts +1 -1
- package/tools/describe.schema.d.ts.map +1 -1
- package/tools/describe.tool.d.ts.map +1 -1
- package/tools/execute.schema.d.ts +1 -1
- package/tools/execute.schema.d.ts.map +1 -1
- package/tools/search.schema.d.ts +2 -2
- package/tools/search.schema.d.ts.map +1 -1
package/codecall.plugin.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export default class CodeCallPlugin extends DynamicPlugin<CodeCallPluginOptions,
|
|
|
16
16
|
* Modes:
|
|
17
17
|
* - codecall_only: Hide all tools from list_tools except CodeCall meta-tools.
|
|
18
18
|
* All other tools must be discovered via codecall:search.
|
|
19
|
-
* - codecall_opt_in: Show
|
|
19
|
+
* - codecall_opt_in: Show tools in list_tools unless they set visibleInListTools: false. Tools opt-in to CodeCall via metadata.
|
|
20
20
|
* - metadata_driven: Use per-tool metadata.codecall to control visibility in list_tools.
|
|
21
21
|
*
|
|
22
22
|
* CodeCall meta-tools (codecall:search, codecall:describe, codecall:execute, codecall:invoke)
|
|
@@ -42,6 +42,13 @@ export default class CodeCallPlugin extends DynamicPlugin<CodeCallPluginOptions,
|
|
|
42
42
|
* has no CodeCall plugin of its own.
|
|
43
43
|
*/
|
|
44
44
|
refuseDirectCallOfHiddenTool(flowCtx: FlowCtxOf<'tools:call-tool'>): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Whether a client may call the tool directly: it is listed, and a tool the SDK keeps out of `tools/list`
|
|
47
|
+
* (`visibility: 'hidden'`) also opts in with `visibleInListTools: true`, in every mode.
|
|
48
|
+
*/
|
|
49
|
+
private isDirectlyCallable;
|
|
50
|
+
/** Whether the tool's app is one `appIds` puts under `codecall_only`; every app is, without `appIds`. */
|
|
51
|
+
private managesApp;
|
|
45
52
|
/** Whether this instance's direct-call gate runs for the tool, so the listing hides only what that gate refuses. */
|
|
46
53
|
private judges;
|
|
47
54
|
private tryGetScope;
|
package/codecall.plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codecall.plugin.d.ts","sourceRoot":"","sources":["../src/codecall.plugin.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,aAAa,
|
|
1
|
+
{"version":3,"file":"codecall.plugin.d.ts","sourceRoot":"","sources":["../src/codecall.plugin.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,aAAa,EASb,KAAK,SAAS,EAEd,KAAK,YAAY,EAElB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAGL,KAAK,qBAAqB,EAC1B,KAAK,0BAA0B,EAEhC,MAAM,kBAAkB,CAAC;AAsC1B,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,aAAa,CAAC,qBAAqB,EAAE,0BAA0B,CAAC;IAC1G,OAAO,EAAE,qBAAqB,CAAC;IAC/B,OAAO,CAAC,YAAY,CAAC,CAAiB;IAEtC,OAAO,CAAC,SAAS;gBAOL,OAAO,GAAE,0BAA+B;IAMpD;;;OAGG;WACa,gBAAgB,CAAC,OAAO,EAAE,0BAA0B,GAAG,YAAY,EAAE;IAuDrF;;;;;;;;;;;;;OAaG;IAEG,eAAe,CAAC,OAAO,EAAE,SAAS,CAAC,kBAAkB,CAAC;IAsB5D;;;;;;;;;;;;;;;OAeG;IAEG,4BAA4B,CAAC,OAAO,EAAE,SAAS,CAAC,iBAAiB,CAAC;IAUxE;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAO1B,yGAAyG;IACzG,OAAO,CAAC,UAAU;IAOlB,oHAAoH;IACpH,OAAO,CAAC,MAAM;IAId,OAAO,CAAC,WAAW;IAQnB;;;;;;;;;OASG;IAEH,OAAO,CAAC,qBAAqB;IAyB7B;;;OAGG;IAEH,OAAO,CAAC,cAAc;IAStB;;OAEG;IAEH,OAAO,CAAC,mBAAmB;CAG5B"}
|
package/codecall.types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codecall.types.d.ts","sourceRoot":"","sources":["../src/codecall.types.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,oBAAoB,CAAC;AAIvC;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,2EAA2E;IAC3E,WAAW,CAAC,EAAE,QAAQ,CAAC,6BAA6B,CAAC,CAAC;IACtD,2FAA2F;IAC3F,QAAQ,CAAC,EAAE,QAAQ,CAAC,0BAA0B,CAAC,CAAC;CACjD;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,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OAAO,CAAC,CAAC;CACnC,CAAC;AAIF,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,0BAA0B;QAClC;;;WAGG;QACH,QAAQ,CAAC,EAAE,oBAAoB,CAAC;KACjC;CACF"}
|
package/esm/index.mjs
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
isEntryGatedBy,
|
|
18
18
|
ListToolsHook,
|
|
19
19
|
Plugin,
|
|
20
|
+
resolveToolVisibility,
|
|
20
21
|
ScopeEntry,
|
|
21
22
|
ToolHook,
|
|
22
23
|
ToolNotFoundError
|
|
@@ -47,7 +48,8 @@ var codeCallVmOptionsSchema = z.object({
|
|
|
47
48
|
*/
|
|
48
49
|
timeoutMs: z.number().positive().optional(),
|
|
49
50
|
/**
|
|
50
|
-
* Allow loop
|
|
51
|
+
* Allow `for` loops besides `for-of`; false refuses every loop but `for-of` before the script runs.
|
|
52
|
+
* The sandbox always refuses `while`, `do-while` and `for-in`.
|
|
51
53
|
* Defaults vary by preset
|
|
52
54
|
*/
|
|
53
55
|
allowLoops: z.boolean().optional(),
|
|
@@ -67,8 +69,8 @@ var codeCallVmOptionsSchema = z.object({
|
|
|
67
69
|
*/
|
|
68
70
|
disabledGlobals: z.array(z.string()).optional(),
|
|
69
71
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
+
* @deprecated Has no effect: scripts never get `console`, and one that uses it is refused before it runs.
|
|
73
|
+
* Scripts log with `mcpLog(level, message)`.
|
|
72
74
|
*/
|
|
73
75
|
allowConsole: z.boolean().optional(),
|
|
74
76
|
/**
|
|
@@ -232,15 +234,15 @@ var codeCallPluginOptionsObjectSchema = z.object({
|
|
|
232
234
|
*/
|
|
233
235
|
appIds: z.array(z.string()).optional(),
|
|
234
236
|
/**
|
|
235
|
-
*
|
|
237
|
+
* Search results per query when a `codecall:search` call names no `topK`
|
|
236
238
|
* @default 8
|
|
237
239
|
*/
|
|
238
240
|
topK: z.number().positive().default(8),
|
|
239
241
|
/**
|
|
240
|
-
*
|
|
242
|
+
* Most tool definitions one `codecall:describe` call returns; a call that would describe more is refused
|
|
241
243
|
* @default 8
|
|
242
244
|
*/
|
|
243
|
-
maxDefinitions: z.number().positive().default(8),
|
|
245
|
+
maxDefinitions: z.number().int().positive().default(8),
|
|
244
246
|
/**
|
|
245
247
|
* Optional filter function for including tools.
|
|
246
248
|
* Signature: (tool: IncludeToolsFilterToolInfo) => boolean
|
|
@@ -1525,13 +1527,9 @@ var ToolSearchService = class _ToolSearchService {
|
|
|
1525
1527
|
defaultSimilarityThreshold: this.config.defaultSimilarityThreshold
|
|
1526
1528
|
});
|
|
1527
1529
|
}
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
const synonymConfig = typeof config.synonymExpansion === "object" ? config.synonymExpansion : {};
|
|
1532
|
-
if (synonymConfig.enabled !== false) {
|
|
1533
|
-
this.synonymService = new SynonymExpansionService(synonymConfig);
|
|
1534
|
-
}
|
|
1530
|
+
const synonymExpansion = config.synonymExpansion ?? embeddingOptions.synonymExpansion;
|
|
1531
|
+
if (this.strategy === "tfidf" && synonymExpansion !== false && synonymExpansion?.enabled !== false) {
|
|
1532
|
+
this.synonymService = new SynonymExpansionService(synonymExpansion ?? {});
|
|
1535
1533
|
}
|
|
1536
1534
|
this.subscriptionPromise = new Promise((resolve, reject) => {
|
|
1537
1535
|
this.subscriptionResolve = resolve;
|
|
@@ -1829,6 +1827,99 @@ import {
|
|
|
1829
1827
|
} from "@enclave-vm/core";
|
|
1830
1828
|
import { Provider as Provider3, ProviderScope as ProviderScope3 } from "@frontmcp/sdk";
|
|
1831
1829
|
|
|
1830
|
+
// plugins/plugin-codecall/src/security/script-policy.ts
|
|
1831
|
+
import {
|
|
1832
|
+
ForbiddenLoopRule,
|
|
1833
|
+
JSAstValidator,
|
|
1834
|
+
ValidationSeverity
|
|
1835
|
+
} from "@enclave-vm/ast";
|
|
1836
|
+
var AGENTSCRIPT_PARSE_OPTIONS = {
|
|
1837
|
+
ecmaVersion: "latest",
|
|
1838
|
+
sourceType: "script",
|
|
1839
|
+
allowReturnOutsideFunction: true,
|
|
1840
|
+
allowAwaitOutsideFunction: true
|
|
1841
|
+
};
|
|
1842
|
+
var PARSE_ATTEMPTS = [
|
|
1843
|
+
{ wrap: (code) => code, parseOptions: AGENTSCRIPT_PARSE_OPTIONS, lineOffset: 0 },
|
|
1844
|
+
{ wrap: (code) => code, parseOptions: { ...AGENTSCRIPT_PARSE_OPTIONS, sourceType: "module" }, lineOffset: 0 },
|
|
1845
|
+
{
|
|
1846
|
+
wrap: (code) => `async function __temp__() {
|
|
1847
|
+
${code}
|
|
1848
|
+
}`,
|
|
1849
|
+
parseOptions: AGENTSCRIPT_PARSE_OPTIONS,
|
|
1850
|
+
lineOffset: 1
|
|
1851
|
+
}
|
|
1852
|
+
];
|
|
1853
|
+
var NON_REFERENCE_KEYS = /* @__PURE__ */ new Set(["type", "loc", "start", "end", "range", "label"]);
|
|
1854
|
+
function isAstNode(value) {
|
|
1855
|
+
return typeof value === "object" && value !== null && typeof value.type === "string";
|
|
1856
|
+
}
|
|
1857
|
+
function isPropertyName(parent, key) {
|
|
1858
|
+
if (!parent || parent["computed"]) return false;
|
|
1859
|
+
if (parent.type === "MemberExpression") return key === "property";
|
|
1860
|
+
return key === "key" && ["Property", "MethodDefinition", "PropertyDefinition"].includes(parent.type);
|
|
1861
|
+
}
|
|
1862
|
+
function visitIdentifierReferences(node, visit, parent, key = "") {
|
|
1863
|
+
if (node.type === "Identifier") {
|
|
1864
|
+
if (!isPropertyName(parent, key)) visit(node);
|
|
1865
|
+
return;
|
|
1866
|
+
}
|
|
1867
|
+
for (const [childKey, child] of Object.entries(node)) {
|
|
1868
|
+
if (NON_REFERENCE_KEYS.has(childKey)) continue;
|
|
1869
|
+
const children = Array.isArray(child) ? child : [child];
|
|
1870
|
+
for (const childNode of children) {
|
|
1871
|
+
if (isAstNode(childNode)) visitIdentifierReferences(childNode, visit, node, childKey);
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1874
|
+
}
|
|
1875
|
+
var GlobalConsoleRule = class {
|
|
1876
|
+
name = "codecall-global-console";
|
|
1877
|
+
description = "console is not available in CodeCall scripts";
|
|
1878
|
+
defaultSeverity = ValidationSeverity.ERROR;
|
|
1879
|
+
enabledByDefault = true;
|
|
1880
|
+
validate(context) {
|
|
1881
|
+
visitIdentifierReferences(context.ast, (identifier) => {
|
|
1882
|
+
if (identifier.name !== "console") return;
|
|
1883
|
+
context.report({
|
|
1884
|
+
code: "DISALLOWED_IDENTIFIER",
|
|
1885
|
+
message: "console is not available in CodeCall scripts; use mcpLog(level, message)",
|
|
1886
|
+
location: identifier.loc ? { line: identifier.loc.start.line, column: identifier.loc.start.column } : void 0,
|
|
1887
|
+
data: { identifier: "console" }
|
|
1888
|
+
});
|
|
1889
|
+
});
|
|
1890
|
+
}
|
|
1891
|
+
};
|
|
1892
|
+
function scriptPolicyRules({ allowLoops }) {
|
|
1893
|
+
const rules = [new GlobalConsoleRule()];
|
|
1894
|
+
if (!allowLoops) {
|
|
1895
|
+
rules.push(
|
|
1896
|
+
new ForbiddenLoopRule({
|
|
1897
|
+
allowFor: false,
|
|
1898
|
+
allowForOf: true,
|
|
1899
|
+
allowWhile: false,
|
|
1900
|
+
allowDoWhile: false,
|
|
1901
|
+
allowForIn: false,
|
|
1902
|
+
message: "Only for-of loops are allowed (vm.allowLoops is false)"
|
|
1903
|
+
})
|
|
1904
|
+
);
|
|
1905
|
+
}
|
|
1906
|
+
return rules;
|
|
1907
|
+
}
|
|
1908
|
+
async function findScriptPolicyIssues(code, options) {
|
|
1909
|
+
const validator = new JSAstValidator(scriptPolicyRules(options));
|
|
1910
|
+
for (const attempt of PARSE_ATTEMPTS) {
|
|
1911
|
+
const result = await validator.validate(attempt.wrap(code), {
|
|
1912
|
+
parseOptions: attempt.parseOptions,
|
|
1913
|
+
preScan: { enabled: false }
|
|
1914
|
+
});
|
|
1915
|
+
if (result.parseError) continue;
|
|
1916
|
+
return result.issues.map(
|
|
1917
|
+
(issue) => issue.location && attempt.lineOffset > 0 ? { ...issue, location: { ...issue.location, line: issue.location.line - attempt.lineOffset } } : issue
|
|
1918
|
+
);
|
|
1919
|
+
}
|
|
1920
|
+
return [];
|
|
1921
|
+
}
|
|
1922
|
+
|
|
1832
1923
|
// plugins/plugin-codecall/src/utils/build-tool-namespaces.ts
|
|
1833
1924
|
var IDENT_RE = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
|
|
1834
1925
|
var PROTOTYPE_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
@@ -2133,6 +2224,22 @@ var EnclaveService = class {
|
|
|
2133
2224
|
throw new ScriptTooLargeError(code.length, maxLength);
|
|
2134
2225
|
}
|
|
2135
2226
|
}
|
|
2227
|
+
const policyIssues = await findScriptPolicyIssues(code, this.vmOptions);
|
|
2228
|
+
if (policyIssues.length > 0) {
|
|
2229
|
+
return {
|
|
2230
|
+
success: false,
|
|
2231
|
+
error: {
|
|
2232
|
+
message: `AgentScript validation failed:
|
|
2233
|
+
${policyIssues.map((issue) => `${issue.code}${issue.location ? ` (line ${issue.location.line})` : ""}: ${issue.message}`).join("\n")}`,
|
|
2234
|
+
name: "ValidationError",
|
|
2235
|
+
code: "VALIDATION_ERROR",
|
|
2236
|
+
blockedPatterns: [...new Set(policyIssues.map((issue) => issue.code))]
|
|
2237
|
+
},
|
|
2238
|
+
logs,
|
|
2239
|
+
timedOut: false,
|
|
2240
|
+
stats: { duration: 0, toolCallCount: 0, iterationCount: 0 }
|
|
2241
|
+
};
|
|
2242
|
+
}
|
|
2136
2243
|
const toolFailures = [];
|
|
2137
2244
|
const toolHandler = async (toolName, args) => {
|
|
2138
2245
|
try {
|
|
@@ -2312,7 +2419,7 @@ INPUT:
|
|
|
2312
2419
|
- queries: string[] (required) - atomic action phrases, max 10
|
|
2313
2420
|
- appIds?: string[] - filter by app
|
|
2314
2421
|
- excludeToolNames?: string[] - skip known tools
|
|
2315
|
-
- topK?: number (default
|
|
2422
|
+
- topK?: number (default: the server's topK, 8 unless configured) - results per query
|
|
2316
2423
|
- minRelevanceScore?: number (default 0.3) - minimum match threshold
|
|
2317
2424
|
|
|
2318
2425
|
OUTPUT: Flat deduplicated tool list. relevanceScore: 0.5+=good, 0.7+=strong match.
|
|
@@ -2322,7 +2429,7 @@ var searchToolInputSchema = {
|
|
|
2322
2429
|
queries: z2.array(z2.string().min(2).max(256)).min(1).max(10).describe("Atomic action queries. Split complex requests into simple actions."),
|
|
2323
2430
|
appIds: z2.array(z2.string()).max(10).optional().describe("Filter by app IDs"),
|
|
2324
2431
|
excludeToolNames: z2.array(z2.string()).max(50).optional().describe("Skip already-known tool names"),
|
|
2325
|
-
topK: z2.number().int().positive().max(50).optional().
|
|
2432
|
+
topK: z2.number().int().positive().max(50).optional().describe("Results per query (defaults to the server's CodeCall topK, 8 unless configured)"),
|
|
2326
2433
|
minRelevanceScore: z2.number().min(0).max(1).optional().default(0.1).describe("Minimum relevance threshold (default 0.1)")
|
|
2327
2434
|
};
|
|
2328
2435
|
var searchToolOutputSchema = z2.object({
|
|
@@ -2348,7 +2455,7 @@ var searchToolOutputSchema = z2.object({
|
|
|
2348
2455
|
// plugins/plugin-codecall/src/tools/search.tool.ts
|
|
2349
2456
|
var SearchTool = class extends ToolContext {
|
|
2350
2457
|
async execute(input) {
|
|
2351
|
-
const { queries, appIds, excludeToolNames = [], topK
|
|
2458
|
+
const { queries, appIds, excludeToolNames = [], topK, minRelevanceScore = 0.3 } = input;
|
|
2352
2459
|
const searchService = this.get(ToolSearchService);
|
|
2353
2460
|
const warnings = [];
|
|
2354
2461
|
const audit = this.tryGet(AuditLoggerService);
|
|
@@ -2730,7 +2837,7 @@ SearchKnowledgeTool = __decorateClass([
|
|
|
2730
2837
|
|
|
2731
2838
|
// plugins/plugin-codecall/src/tools/describe.tool.ts
|
|
2732
2839
|
import { toJSONSchema, z as z6, ZodType } from "@frontmcp/lazy-zod";
|
|
2733
|
-
import { getCallSurface as getCallSurface2, Tool as Tool4, ToolContext as ToolContext4 } from "@frontmcp/sdk";
|
|
2840
|
+
import { getCallSurface as getCallSurface2, InvalidInputError, Tool as Tool4, ToolContext as ToolContext4 } from "@frontmcp/sdk";
|
|
2734
2841
|
|
|
2735
2842
|
// plugins/plugin-codecall/src/utils/describe.utils.ts
|
|
2736
2843
|
var INTENT_PATTERNS = {
|
|
@@ -3144,7 +3251,7 @@ import { z as z5 } from "@frontmcp/lazy-zod";
|
|
|
3144
3251
|
import { ToolAnnotationsSchema } from "@frontmcp/protocol";
|
|
3145
3252
|
var describeToolDescription = `Get input/output schemas for tools from search results.
|
|
3146
3253
|
|
|
3147
|
-
INPUT: toolNames: string[] - tool names from search
|
|
3254
|
+
INPUT: toolNames: string[] - tool names from search, at most the server's maxDefinitions (8 unless configured) per call
|
|
3148
3255
|
OUTPUT per tool: inputSchema (JSON Schema), outputSchema (JSON Schema), usageExamples (up to 5 callTool examples)
|
|
3149
3256
|
|
|
3150
3257
|
IMPORTANT: If notFound array is non-empty \u2192 re-search with corrected queries.
|
|
@@ -3198,9 +3305,10 @@ var DescribeTool = class extends ToolContext4 {
|
|
|
3198
3305
|
const audit = this.tryGet(AuditLoggerService);
|
|
3199
3306
|
const executionId = audit ? audit.generateExecutionId() : "";
|
|
3200
3307
|
const startedAt = Date.now();
|
|
3308
|
+
const config = this.get(CodeCallConfig);
|
|
3309
|
+
const maxDefinitions = config.get("maxDefinitions");
|
|
3201
3310
|
const tools = [];
|
|
3202
3311
|
const notFound = [];
|
|
3203
|
-
const config = this.get(CodeCallConfig);
|
|
3204
3312
|
const surface = getCallSurface2();
|
|
3205
3313
|
for (const toolName of toolNames) {
|
|
3206
3314
|
if (isBlockedSelfReference(toolName)) {
|
|
@@ -3214,6 +3322,11 @@ var DescribeTool = class extends ToolContext4 {
|
|
|
3214
3322
|
continue;
|
|
3215
3323
|
}
|
|
3216
3324
|
const tool = access.entry;
|
|
3325
|
+
if (tools.length >= maxDefinitions) {
|
|
3326
|
+
throw new InvalidInputError(
|
|
3327
|
+
`codecall:describe describes at most ${maxDefinitions} tools per call; describe the rest in another call`
|
|
3328
|
+
);
|
|
3329
|
+
}
|
|
3217
3330
|
const appId = this.extractAppId(tool);
|
|
3218
3331
|
const inputSchema = this.getInputSchema(tool);
|
|
3219
3332
|
const outputSchema = this.toJsonSchema(tool.rawOutputSchema ?? tool.outputSchema);
|
|
@@ -3387,8 +3500,8 @@ for (const u of users.items) {
|
|
|
3387
3500
|
}
|
|
3388
3501
|
return results;
|
|
3389
3502
|
|
|
3390
|
-
ALLOWED: for
|
|
3391
|
-
BLOCKED: while, do-while, function decl, eval, require, fetch, setTimeout, process, globalThis
|
|
3503
|
+
ALLOWED: for-of, arrow fn, map/filter/reduce/find, Math.*, JSON.*, if/else, destructuring, spread, template literals
|
|
3504
|
+
BLOCKED: while, do-while, for (unless the server sets vm.allowLoops), console (use mcpLog), function decl, eval, require, fetch, setTimeout, process, globalThis
|
|
3392
3505
|
|
|
3393
3506
|
ERRORS: NOT_FOUND | VALIDATION | EXECUTION | TIMEOUT | ACCESS_DENIED
|
|
3394
3507
|
STATUS: ok | syntax_error | illegal_access | runtime_error | tool_error | timeout
|
|
@@ -3899,6 +4012,7 @@ var CodeCallPlugin = class extends DynamicPlugin {
|
|
|
3899
4012
|
return new ToolSearchService(
|
|
3900
4013
|
{
|
|
3901
4014
|
embeddingOptions: parsedOptions.embedding,
|
|
4015
|
+
defaultTopK: parsedOptions.topK,
|
|
3902
4016
|
mode: parsedOptions.mode,
|
|
3903
4017
|
includeTools: parsedOptions["includeTools"]
|
|
3904
4018
|
},
|
|
@@ -3927,11 +4041,28 @@ var CodeCallPlugin = class extends DynamicPlugin {
|
|
|
3927
4041
|
async refuseDirectCallOfHiddenTool(flowCtx) {
|
|
3928
4042
|
const { tool } = flowCtx.state;
|
|
3929
4043
|
if (!tool || tool.owner?.kind === "scope") return;
|
|
3930
|
-
if (this.
|
|
4044
|
+
if (this.isDirectlyCallable(tool)) return;
|
|
3931
4045
|
if (isInProcessDispatch(callContextOf(flowCtx))) return;
|
|
3932
4046
|
this.getLogger().verbose("refused a direct tools/call of a tool CodeCall hides", { tool: tool.fullName });
|
|
3933
4047
|
throw new ToolNotFoundError(flowCtx.state.input?.name ?? tool.name);
|
|
3934
4048
|
}
|
|
4049
|
+
/**
|
|
4050
|
+
* Whether a client may call the tool directly: it is listed, and a tool the SDK keeps out of `tools/list`
|
|
4051
|
+
* (`visibility: 'hidden'`) also opts in with `visibleInListTools: true`, in every mode.
|
|
4052
|
+
*/
|
|
4053
|
+
isDirectlyCallable(tool) {
|
|
4054
|
+
if (!this.managesApp(tool)) return true;
|
|
4055
|
+
if (!this.shouldShowInListTools(tool, this.options.mode)) return false;
|
|
4056
|
+
if (resolveToolVisibility(tool.metadata) !== "hidden") return true;
|
|
4057
|
+
return this.getCodeCallMetadata(tool)?.visibleInListTools === true;
|
|
4058
|
+
}
|
|
4059
|
+
/** Whether the tool's app is one `appIds` puts under `codecall_only`; every app is, without `appIds`. */
|
|
4060
|
+
managesApp(tool) {
|
|
4061
|
+
const managedAppIds = this.options.appIds;
|
|
4062
|
+
if (this.options.mode !== "codecall_only" || !managedAppIds || managedAppIds.length === 0) return true;
|
|
4063
|
+
const toolOwnerAppId = tool.owner?.kind === "app" ? tool.owner.id : void 0;
|
|
4064
|
+
return toolOwnerAppId !== void 0 && managedAppIds.includes(toolOwnerAppId);
|
|
4065
|
+
}
|
|
3935
4066
|
/** Whether this instance's direct-call gate runs for the tool, so the listing hides only what that gate refuses. */
|
|
3936
4067
|
judges(scope, entry) {
|
|
3937
4068
|
return !scope?.hooks || isEntryGatedBy(scope, entry, this);
|
|
@@ -3959,23 +4090,11 @@ var CodeCallPlugin = class extends DynamicPlugin {
|
|
|
3959
4090
|
}
|
|
3960
4091
|
const codecallMeta = this.getCodeCallMetadata(tool);
|
|
3961
4092
|
switch (mode) {
|
|
3962
|
-
case "codecall_only":
|
|
3963
|
-
|
|
3964
|
-
if (managedAppIds && managedAppIds.length > 0) {
|
|
3965
|
-
const toolOwnerAppId = tool.owner?.kind === "app" ? tool.owner.id : void 0;
|
|
3966
|
-
if (!toolOwnerAppId || !managedAppIds.includes(toolOwnerAppId)) {
|
|
3967
|
-
return true;
|
|
3968
|
-
}
|
|
3969
|
-
}
|
|
3970
|
-
return codecallMeta?.visibleInListTools === true;
|
|
3971
|
-
}
|
|
4093
|
+
case "codecall_only":
|
|
4094
|
+
return !this.managesApp(tool) || codecallMeta?.visibleInListTools === true;
|
|
3972
4095
|
case "codecall_opt_in":
|
|
3973
|
-
return true;
|
|
3974
4096
|
case "metadata_driven":
|
|
3975
|
-
|
|
3976
|
-
return false;
|
|
3977
|
-
}
|
|
3978
|
-
return true;
|
|
4097
|
+
return codecallMeta?.visibleInListTools !== false;
|
|
3979
4098
|
default:
|
|
3980
4099
|
return true;
|
|
3981
4100
|
}
|
package/esm/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontmcp/plugin-codecall",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.2",
|
|
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",
|
|
@@ -50,14 +50,14 @@
|
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@enclave-vm/ast": "^2.16.0",
|
|
52
52
|
"@enclave-vm/core": "^2.16.0",
|
|
53
|
-
"@frontmcp/protocol": "1.9.
|
|
54
|
-
"@frontmcp/sdk": "1.9.
|
|
53
|
+
"@frontmcp/protocol": "1.9.2",
|
|
54
|
+
"@frontmcp/sdk": "1.9.2",
|
|
55
55
|
"acorn": "^8.15.0",
|
|
56
|
-
"vectoriadb": "^2.3.
|
|
56
|
+
"vectoriadb": "^2.3.3"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"@frontmcp/lazy-zod": "1.9.
|
|
60
|
-
"@frontmcp/plugin-cache": "1.9.
|
|
59
|
+
"@frontmcp/lazy-zod": "1.9.2",
|
|
60
|
+
"@frontmcp/plugin-cache": "1.9.2"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"reflect-metadata": "^0.2.2"
|
package/index.js
CHANGED
|
@@ -83,7 +83,8 @@ var codeCallVmOptionsSchema = import_lazy_zod.z.object({
|
|
|
83
83
|
*/
|
|
84
84
|
timeoutMs: import_lazy_zod.z.number().positive().optional(),
|
|
85
85
|
/**
|
|
86
|
-
* Allow loop
|
|
86
|
+
* Allow `for` loops besides `for-of`; false refuses every loop but `for-of` before the script runs.
|
|
87
|
+
* The sandbox always refuses `while`, `do-while` and `for-in`.
|
|
87
88
|
* Defaults vary by preset
|
|
88
89
|
*/
|
|
89
90
|
allowLoops: import_lazy_zod.z.boolean().optional(),
|
|
@@ -103,8 +104,8 @@ var codeCallVmOptionsSchema = import_lazy_zod.z.object({
|
|
|
103
104
|
*/
|
|
104
105
|
disabledGlobals: import_lazy_zod.z.array(import_lazy_zod.z.string()).optional(),
|
|
105
106
|
/**
|
|
106
|
-
*
|
|
107
|
-
*
|
|
107
|
+
* @deprecated Has no effect: scripts never get `console`, and one that uses it is refused before it runs.
|
|
108
|
+
* Scripts log with `mcpLog(level, message)`.
|
|
108
109
|
*/
|
|
109
110
|
allowConsole: import_lazy_zod.z.boolean().optional(),
|
|
110
111
|
/**
|
|
@@ -268,15 +269,15 @@ var codeCallPluginOptionsObjectSchema = import_lazy_zod.z.object({
|
|
|
268
269
|
*/
|
|
269
270
|
appIds: import_lazy_zod.z.array(import_lazy_zod.z.string()).optional(),
|
|
270
271
|
/**
|
|
271
|
-
*
|
|
272
|
+
* Search results per query when a `codecall:search` call names no `topK`
|
|
272
273
|
* @default 8
|
|
273
274
|
*/
|
|
274
275
|
topK: import_lazy_zod.z.number().positive().default(8),
|
|
275
276
|
/**
|
|
276
|
-
*
|
|
277
|
+
* Most tool definitions one `codecall:describe` call returns; a call that would describe more is refused
|
|
277
278
|
* @default 8
|
|
278
279
|
*/
|
|
279
|
-
maxDefinitions: import_lazy_zod.z.number().positive().default(8),
|
|
280
|
+
maxDefinitions: import_lazy_zod.z.number().int().positive().default(8),
|
|
280
281
|
/**
|
|
281
282
|
* Optional filter function for including tools.
|
|
282
283
|
* Signature: (tool: IncludeToolsFilterToolInfo) => boolean
|
|
@@ -1561,13 +1562,9 @@ var ToolSearchService = class _ToolSearchService {
|
|
|
1561
1562
|
defaultSimilarityThreshold: this.config.defaultSimilarityThreshold
|
|
1562
1563
|
});
|
|
1563
1564
|
}
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
const synonymConfig = typeof config.synonymExpansion === "object" ? config.synonymExpansion : {};
|
|
1568
|
-
if (synonymConfig.enabled !== false) {
|
|
1569
|
-
this.synonymService = new SynonymExpansionService(synonymConfig);
|
|
1570
|
-
}
|
|
1565
|
+
const synonymExpansion = config.synonymExpansion ?? embeddingOptions.synonymExpansion;
|
|
1566
|
+
if (this.strategy === "tfidf" && synonymExpansion !== false && synonymExpansion?.enabled !== false) {
|
|
1567
|
+
this.synonymService = new SynonymExpansionService(synonymExpansion ?? {});
|
|
1571
1568
|
}
|
|
1572
1569
|
this.subscriptionPromise = new Promise((resolve, reject) => {
|
|
1573
1570
|
this.subscriptionResolve = resolve;
|
|
@@ -1863,6 +1860,95 @@ var ToolSearchService = class _ToolSearchService {
|
|
|
1863
1860
|
var import_core = require("@enclave-vm/core");
|
|
1864
1861
|
var import_sdk4 = require("@frontmcp/sdk");
|
|
1865
1862
|
|
|
1863
|
+
// plugins/plugin-codecall/src/security/script-policy.ts
|
|
1864
|
+
var import_ast = require("@enclave-vm/ast");
|
|
1865
|
+
var AGENTSCRIPT_PARSE_OPTIONS = {
|
|
1866
|
+
ecmaVersion: "latest",
|
|
1867
|
+
sourceType: "script",
|
|
1868
|
+
allowReturnOutsideFunction: true,
|
|
1869
|
+
allowAwaitOutsideFunction: true
|
|
1870
|
+
};
|
|
1871
|
+
var PARSE_ATTEMPTS = [
|
|
1872
|
+
{ wrap: (code) => code, parseOptions: AGENTSCRIPT_PARSE_OPTIONS, lineOffset: 0 },
|
|
1873
|
+
{ wrap: (code) => code, parseOptions: { ...AGENTSCRIPT_PARSE_OPTIONS, sourceType: "module" }, lineOffset: 0 },
|
|
1874
|
+
{
|
|
1875
|
+
wrap: (code) => `async function __temp__() {
|
|
1876
|
+
${code}
|
|
1877
|
+
}`,
|
|
1878
|
+
parseOptions: AGENTSCRIPT_PARSE_OPTIONS,
|
|
1879
|
+
lineOffset: 1
|
|
1880
|
+
}
|
|
1881
|
+
];
|
|
1882
|
+
var NON_REFERENCE_KEYS = /* @__PURE__ */ new Set(["type", "loc", "start", "end", "range", "label"]);
|
|
1883
|
+
function isAstNode(value) {
|
|
1884
|
+
return typeof value === "object" && value !== null && typeof value.type === "string";
|
|
1885
|
+
}
|
|
1886
|
+
function isPropertyName(parent, key) {
|
|
1887
|
+
if (!parent || parent["computed"]) return false;
|
|
1888
|
+
if (parent.type === "MemberExpression") return key === "property";
|
|
1889
|
+
return key === "key" && ["Property", "MethodDefinition", "PropertyDefinition"].includes(parent.type);
|
|
1890
|
+
}
|
|
1891
|
+
function visitIdentifierReferences(node, visit, parent, key = "") {
|
|
1892
|
+
if (node.type === "Identifier") {
|
|
1893
|
+
if (!isPropertyName(parent, key)) visit(node);
|
|
1894
|
+
return;
|
|
1895
|
+
}
|
|
1896
|
+
for (const [childKey, child] of Object.entries(node)) {
|
|
1897
|
+
if (NON_REFERENCE_KEYS.has(childKey)) continue;
|
|
1898
|
+
const children = Array.isArray(child) ? child : [child];
|
|
1899
|
+
for (const childNode of children) {
|
|
1900
|
+
if (isAstNode(childNode)) visitIdentifierReferences(childNode, visit, node, childKey);
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
var GlobalConsoleRule = class {
|
|
1905
|
+
name = "codecall-global-console";
|
|
1906
|
+
description = "console is not available in CodeCall scripts";
|
|
1907
|
+
defaultSeverity = import_ast.ValidationSeverity.ERROR;
|
|
1908
|
+
enabledByDefault = true;
|
|
1909
|
+
validate(context) {
|
|
1910
|
+
visitIdentifierReferences(context.ast, (identifier) => {
|
|
1911
|
+
if (identifier.name !== "console") return;
|
|
1912
|
+
context.report({
|
|
1913
|
+
code: "DISALLOWED_IDENTIFIER",
|
|
1914
|
+
message: "console is not available in CodeCall scripts; use mcpLog(level, message)",
|
|
1915
|
+
location: identifier.loc ? { line: identifier.loc.start.line, column: identifier.loc.start.column } : void 0,
|
|
1916
|
+
data: { identifier: "console" }
|
|
1917
|
+
});
|
|
1918
|
+
});
|
|
1919
|
+
}
|
|
1920
|
+
};
|
|
1921
|
+
function scriptPolicyRules({ allowLoops }) {
|
|
1922
|
+
const rules = [new GlobalConsoleRule()];
|
|
1923
|
+
if (!allowLoops) {
|
|
1924
|
+
rules.push(
|
|
1925
|
+
new import_ast.ForbiddenLoopRule({
|
|
1926
|
+
allowFor: false,
|
|
1927
|
+
allowForOf: true,
|
|
1928
|
+
allowWhile: false,
|
|
1929
|
+
allowDoWhile: false,
|
|
1930
|
+
allowForIn: false,
|
|
1931
|
+
message: "Only for-of loops are allowed (vm.allowLoops is false)"
|
|
1932
|
+
})
|
|
1933
|
+
);
|
|
1934
|
+
}
|
|
1935
|
+
return rules;
|
|
1936
|
+
}
|
|
1937
|
+
async function findScriptPolicyIssues(code, options) {
|
|
1938
|
+
const validator = new import_ast.JSAstValidator(scriptPolicyRules(options));
|
|
1939
|
+
for (const attempt of PARSE_ATTEMPTS) {
|
|
1940
|
+
const result = await validator.validate(attempt.wrap(code), {
|
|
1941
|
+
parseOptions: attempt.parseOptions,
|
|
1942
|
+
preScan: { enabled: false }
|
|
1943
|
+
});
|
|
1944
|
+
if (result.parseError) continue;
|
|
1945
|
+
return result.issues.map(
|
|
1946
|
+
(issue) => issue.location && attempt.lineOffset > 0 ? { ...issue, location: { ...issue.location, line: issue.location.line - attempt.lineOffset } } : issue
|
|
1947
|
+
);
|
|
1948
|
+
}
|
|
1949
|
+
return [];
|
|
1950
|
+
}
|
|
1951
|
+
|
|
1866
1952
|
// plugins/plugin-codecall/src/utils/build-tool-namespaces.ts
|
|
1867
1953
|
var IDENT_RE = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
|
|
1868
1954
|
var PROTOTYPE_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
@@ -1997,7 +2083,7 @@ function toSandboxToolNamespaces(namespaces, reservedGlobals = []) {
|
|
|
1997
2083
|
}
|
|
1998
2084
|
|
|
1999
2085
|
// plugins/plugin-codecall/src/utils/script-lines.ts
|
|
2000
|
-
var
|
|
2086
|
+
var import_ast2 = require("@enclave-vm/ast");
|
|
2001
2087
|
var acorn = __toESM(require("acorn"));
|
|
2002
2088
|
var PARSE_OPTIONS = { ecmaVersion: "latest", locations: true };
|
|
2003
2089
|
var NON_CHILD_KEYS = /* @__PURE__ */ new Set(["type", "loc", "start", "end", "range"]);
|
|
@@ -2038,8 +2124,8 @@ function parseBody(code, sourceType) {
|
|
|
2038
2124
|
}
|
|
2039
2125
|
function treesOf(script) {
|
|
2040
2126
|
try {
|
|
2041
|
-
const wrap = !(0,
|
|
2042
|
-
const printed = parseBody((0,
|
|
2127
|
+
const wrap = !(0, import_ast2.isWrappedInMain)(script);
|
|
2128
|
+
const printed = parseBody((0, import_ast2.transformAgentScript)(script, { wrapInMain: wrap }), "script");
|
|
2043
2129
|
const { body, offset } = parseScript(script);
|
|
2044
2130
|
if (!wrap) return { printed, script: body, offset };
|
|
2045
2131
|
const main = printed[0]?.["body"];
|
|
@@ -2167,6 +2253,22 @@ var EnclaveService = class {
|
|
|
2167
2253
|
throw new ScriptTooLargeError(code.length, maxLength);
|
|
2168
2254
|
}
|
|
2169
2255
|
}
|
|
2256
|
+
const policyIssues = await findScriptPolicyIssues(code, this.vmOptions);
|
|
2257
|
+
if (policyIssues.length > 0) {
|
|
2258
|
+
return {
|
|
2259
|
+
success: false,
|
|
2260
|
+
error: {
|
|
2261
|
+
message: `AgentScript validation failed:
|
|
2262
|
+
${policyIssues.map((issue) => `${issue.code}${issue.location ? ` (line ${issue.location.line})` : ""}: ${issue.message}`).join("\n")}`,
|
|
2263
|
+
name: "ValidationError",
|
|
2264
|
+
code: "VALIDATION_ERROR",
|
|
2265
|
+
blockedPatterns: [...new Set(policyIssues.map((issue) => issue.code))]
|
|
2266
|
+
},
|
|
2267
|
+
logs,
|
|
2268
|
+
timedOut: false,
|
|
2269
|
+
stats: { duration: 0, toolCallCount: 0, iterationCount: 0 }
|
|
2270
|
+
};
|
|
2271
|
+
}
|
|
2170
2272
|
const toolFailures = [];
|
|
2171
2273
|
const toolHandler = async (toolName, args) => {
|
|
2172
2274
|
try {
|
|
@@ -2346,7 +2448,7 @@ INPUT:
|
|
|
2346
2448
|
- queries: string[] (required) - atomic action phrases, max 10
|
|
2347
2449
|
- appIds?: string[] - filter by app
|
|
2348
2450
|
- excludeToolNames?: string[] - skip known tools
|
|
2349
|
-
- topK?: number (default
|
|
2451
|
+
- topK?: number (default: the server's topK, 8 unless configured) - results per query
|
|
2350
2452
|
- minRelevanceScore?: number (default 0.3) - minimum match threshold
|
|
2351
2453
|
|
|
2352
2454
|
OUTPUT: Flat deduplicated tool list. relevanceScore: 0.5+=good, 0.7+=strong match.
|
|
@@ -2356,7 +2458,7 @@ var searchToolInputSchema = {
|
|
|
2356
2458
|
queries: import_lazy_zod2.z.array(import_lazy_zod2.z.string().min(2).max(256)).min(1).max(10).describe("Atomic action queries. Split complex requests into simple actions."),
|
|
2357
2459
|
appIds: import_lazy_zod2.z.array(import_lazy_zod2.z.string()).max(10).optional().describe("Filter by app IDs"),
|
|
2358
2460
|
excludeToolNames: import_lazy_zod2.z.array(import_lazy_zod2.z.string()).max(50).optional().describe("Skip already-known tool names"),
|
|
2359
|
-
topK: import_lazy_zod2.z.number().int().positive().max(50).optional().
|
|
2461
|
+
topK: import_lazy_zod2.z.number().int().positive().max(50).optional().describe("Results per query (defaults to the server's CodeCall topK, 8 unless configured)"),
|
|
2360
2462
|
minRelevanceScore: import_lazy_zod2.z.number().min(0).max(1).optional().default(0.1).describe("Minimum relevance threshold (default 0.1)")
|
|
2361
2463
|
};
|
|
2362
2464
|
var searchToolOutputSchema = import_lazy_zod2.z.object({
|
|
@@ -2382,7 +2484,7 @@ var searchToolOutputSchema = import_lazy_zod2.z.object({
|
|
|
2382
2484
|
// plugins/plugin-codecall/src/tools/search.tool.ts
|
|
2383
2485
|
var SearchTool = class extends import_sdk5.ToolContext {
|
|
2384
2486
|
async execute(input) {
|
|
2385
|
-
const { queries, appIds, excludeToolNames = [], topK
|
|
2487
|
+
const { queries, appIds, excludeToolNames = [], topK, minRelevanceScore = 0.3 } = input;
|
|
2386
2488
|
const searchService = this.get(ToolSearchService);
|
|
2387
2489
|
const warnings = [];
|
|
2388
2490
|
const audit = this.tryGet(AuditLoggerService);
|
|
@@ -3178,7 +3280,7 @@ var import_lazy_zod5 = require("@frontmcp/lazy-zod");
|
|
|
3178
3280
|
var import_protocol = require("@frontmcp/protocol");
|
|
3179
3281
|
var describeToolDescription = `Get input/output schemas for tools from search results.
|
|
3180
3282
|
|
|
3181
|
-
INPUT: toolNames: string[] - tool names from search
|
|
3283
|
+
INPUT: toolNames: string[] - tool names from search, at most the server's maxDefinitions (8 unless configured) per call
|
|
3182
3284
|
OUTPUT per tool: inputSchema (JSON Schema), outputSchema (JSON Schema), usageExamples (up to 5 callTool examples)
|
|
3183
3285
|
|
|
3184
3286
|
IMPORTANT: If notFound array is non-empty \u2192 re-search with corrected queries.
|
|
@@ -3232,9 +3334,10 @@ var DescribeTool = class extends import_sdk8.ToolContext {
|
|
|
3232
3334
|
const audit = this.tryGet(AuditLoggerService);
|
|
3233
3335
|
const executionId = audit ? audit.generateExecutionId() : "";
|
|
3234
3336
|
const startedAt = Date.now();
|
|
3337
|
+
const config = this.get(CodeCallConfig);
|
|
3338
|
+
const maxDefinitions = config.get("maxDefinitions");
|
|
3235
3339
|
const tools = [];
|
|
3236
3340
|
const notFound = [];
|
|
3237
|
-
const config = this.get(CodeCallConfig);
|
|
3238
3341
|
const surface = (0, import_sdk8.getCallSurface)();
|
|
3239
3342
|
for (const toolName of toolNames) {
|
|
3240
3343
|
if (isBlockedSelfReference(toolName)) {
|
|
@@ -3248,6 +3351,11 @@ var DescribeTool = class extends import_sdk8.ToolContext {
|
|
|
3248
3351
|
continue;
|
|
3249
3352
|
}
|
|
3250
3353
|
const tool = access.entry;
|
|
3354
|
+
if (tools.length >= maxDefinitions) {
|
|
3355
|
+
throw new import_sdk8.InvalidInputError(
|
|
3356
|
+
`codecall:describe describes at most ${maxDefinitions} tools per call; describe the rest in another call`
|
|
3357
|
+
);
|
|
3358
|
+
}
|
|
3251
3359
|
const appId = this.extractAppId(tool);
|
|
3252
3360
|
const inputSchema = this.getInputSchema(tool);
|
|
3253
3361
|
const outputSchema = this.toJsonSchema(tool.rawOutputSchema ?? tool.outputSchema);
|
|
@@ -3421,8 +3529,8 @@ for (const u of users.items) {
|
|
|
3421
3529
|
}
|
|
3422
3530
|
return results;
|
|
3423
3531
|
|
|
3424
|
-
ALLOWED: for
|
|
3425
|
-
BLOCKED: while, do-while, function decl, eval, require, fetch, setTimeout, process, globalThis
|
|
3532
|
+
ALLOWED: for-of, arrow fn, map/filter/reduce/find, Math.*, JSON.*, if/else, destructuring, spread, template literals
|
|
3533
|
+
BLOCKED: while, do-while, for (unless the server sets vm.allowLoops), console (use mcpLog), function decl, eval, require, fetch, setTimeout, process, globalThis
|
|
3426
3534
|
|
|
3427
3535
|
ERRORS: NOT_FOUND | VALIDATION | EXECUTION | TIMEOUT | ACCESS_DENIED
|
|
3428
3536
|
STATUS: ok | syntax_error | illegal_access | runtime_error | tool_error | timeout
|
|
@@ -3933,6 +4041,7 @@ var CodeCallPlugin = class extends import_sdk11.DynamicPlugin {
|
|
|
3933
4041
|
return new ToolSearchService(
|
|
3934
4042
|
{
|
|
3935
4043
|
embeddingOptions: parsedOptions.embedding,
|
|
4044
|
+
defaultTopK: parsedOptions.topK,
|
|
3936
4045
|
mode: parsedOptions.mode,
|
|
3937
4046
|
includeTools: parsedOptions["includeTools"]
|
|
3938
4047
|
},
|
|
@@ -3961,11 +4070,28 @@ var CodeCallPlugin = class extends import_sdk11.DynamicPlugin {
|
|
|
3961
4070
|
async refuseDirectCallOfHiddenTool(flowCtx) {
|
|
3962
4071
|
const { tool } = flowCtx.state;
|
|
3963
4072
|
if (!tool || tool.owner?.kind === "scope") return;
|
|
3964
|
-
if (this.
|
|
4073
|
+
if (this.isDirectlyCallable(tool)) return;
|
|
3965
4074
|
if (isInProcessDispatch(callContextOf(flowCtx))) return;
|
|
3966
4075
|
this.getLogger().verbose("refused a direct tools/call of a tool CodeCall hides", { tool: tool.fullName });
|
|
3967
4076
|
throw new import_sdk11.ToolNotFoundError(flowCtx.state.input?.name ?? tool.name);
|
|
3968
4077
|
}
|
|
4078
|
+
/**
|
|
4079
|
+
* Whether a client may call the tool directly: it is listed, and a tool the SDK keeps out of `tools/list`
|
|
4080
|
+
* (`visibility: 'hidden'`) also opts in with `visibleInListTools: true`, in every mode.
|
|
4081
|
+
*/
|
|
4082
|
+
isDirectlyCallable(tool) {
|
|
4083
|
+
if (!this.managesApp(tool)) return true;
|
|
4084
|
+
if (!this.shouldShowInListTools(tool, this.options.mode)) return false;
|
|
4085
|
+
if ((0, import_sdk11.resolveToolVisibility)(tool.metadata) !== "hidden") return true;
|
|
4086
|
+
return this.getCodeCallMetadata(tool)?.visibleInListTools === true;
|
|
4087
|
+
}
|
|
4088
|
+
/** Whether the tool's app is one `appIds` puts under `codecall_only`; every app is, without `appIds`. */
|
|
4089
|
+
managesApp(tool) {
|
|
4090
|
+
const managedAppIds = this.options.appIds;
|
|
4091
|
+
if (this.options.mode !== "codecall_only" || !managedAppIds || managedAppIds.length === 0) return true;
|
|
4092
|
+
const toolOwnerAppId = tool.owner?.kind === "app" ? tool.owner.id : void 0;
|
|
4093
|
+
return toolOwnerAppId !== void 0 && managedAppIds.includes(toolOwnerAppId);
|
|
4094
|
+
}
|
|
3969
4095
|
/** Whether this instance's direct-call gate runs for the tool, so the listing hides only what that gate refuses. */
|
|
3970
4096
|
judges(scope, entry) {
|
|
3971
4097
|
return !scope?.hooks || (0, import_sdk11.isEntryGatedBy)(scope, entry, this);
|
|
@@ -3993,23 +4119,11 @@ var CodeCallPlugin = class extends import_sdk11.DynamicPlugin {
|
|
|
3993
4119
|
}
|
|
3994
4120
|
const codecallMeta = this.getCodeCallMetadata(tool);
|
|
3995
4121
|
switch (mode) {
|
|
3996
|
-
case "codecall_only":
|
|
3997
|
-
|
|
3998
|
-
if (managedAppIds && managedAppIds.length > 0) {
|
|
3999
|
-
const toolOwnerAppId = tool.owner?.kind === "app" ? tool.owner.id : void 0;
|
|
4000
|
-
if (!toolOwnerAppId || !managedAppIds.includes(toolOwnerAppId)) {
|
|
4001
|
-
return true;
|
|
4002
|
-
}
|
|
4003
|
-
}
|
|
4004
|
-
return codecallMeta?.visibleInListTools === true;
|
|
4005
|
-
}
|
|
4122
|
+
case "codecall_only":
|
|
4123
|
+
return !this.managesApp(tool) || codecallMeta?.visibleInListTools === true;
|
|
4006
4124
|
case "codecall_opt_in":
|
|
4007
|
-
return true;
|
|
4008
4125
|
case "metadata_driven":
|
|
4009
|
-
|
|
4010
|
-
return false;
|
|
4011
|
-
}
|
|
4012
|
-
return true;
|
|
4126
|
+
return codecallMeta?.visibleInListTools !== false;
|
|
4013
4127
|
default:
|
|
4014
4128
|
return true;
|
|
4015
4129
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontmcp/plugin-codecall",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.2",
|
|
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",
|
|
@@ -50,14 +50,14 @@
|
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@enclave-vm/ast": "^2.16.0",
|
|
52
52
|
"@enclave-vm/core": "^2.16.0",
|
|
53
|
-
"@frontmcp/protocol": "1.9.
|
|
54
|
-
"@frontmcp/sdk": "1.9.
|
|
53
|
+
"@frontmcp/protocol": "1.9.2",
|
|
54
|
+
"@frontmcp/sdk": "1.9.2",
|
|
55
55
|
"acorn": "^8.15.0",
|
|
56
|
-
"vectoriadb": "^2.3.
|
|
56
|
+
"vectoriadb": "^2.3.3"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"@frontmcp/lazy-zod": "1.9.
|
|
60
|
-
"@frontmcp/plugin-cache": "1.9.
|
|
59
|
+
"@frontmcp/lazy-zod": "1.9.2",
|
|
60
|
+
"@frontmcp/plugin-cache": "1.9.2"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"reflect-metadata": "^0.2.2"
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ValidationIssue } from '@enclave-vm/ast';
|
|
2
|
+
import type { ResolvedCodeCallVmOptions } from '../codecall.symbol';
|
|
3
|
+
type ScriptPolicyOptions = Pick<ResolvedCodeCallVmOptions, 'allowLoops'>;
|
|
4
|
+
/**
|
|
5
|
+
* The places a script uses a loop `vm.allowLoops: false` turns off, or `console`, which the sandbox
|
|
6
|
+
* never gives a script, in the script's own lines. The sandbox takes no loop option, so CodeCall
|
|
7
|
+
* checks before it runs the script, parsing it the way the sandbox does. A script none of those
|
|
8
|
+
* parses accept is left to the sandbox, which fails on the same parse and reports the syntax error.
|
|
9
|
+
*/
|
|
10
|
+
export declare function findScriptPolicyIssues(code: string, options: ScriptPolicyOptions): Promise<ValidationIssue[]>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=script-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"script-policy.d.ts","sourceRoot":"","sources":["../../src/security/script-policy.ts"],"names":[],"mappings":"AAEA,OAAO,EAKL,KAAK,eAAe,EAErB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAEpE,KAAK,mBAAmB,GAAG,IAAI,CAAC,yBAAyB,EAAE,YAAY,CAAC,CAAC;AAgGzE;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAenH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enclave.service.d.ts","sourceRoot":"","sources":["../../src/services/enclave.service.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,qBAAqB,EAA6B,MAAM,oBAAoB,CAAC;AAE3F,OAAO,KAAK,cAAc,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"enclave.service.d.ts","sourceRoot":"","sources":["../../src/services/enclave.service.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,qBAAqB,EAA6B,MAAM,oBAAoB,CAAC;AAE3F,OAAO,KAAK,cAAc,MAAM,+BAA+B,CAAC;AAKhE;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE;QACN,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,kGAAkG;QAClG,QAAQ,CAAC,EAAE;YAAE,IAAI,EAAE,MAAM,C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AE,MAAM,GAAG,OAAO;IAMpD;;OAEG;IACH,KAAK,IAAI,IAAI;IAMb;;OAEG;IACH,WAAW,IAAI,iBAAiB;IAIhC;;OAEG;IACH,aAAa,IAAI,OAAO;CAGzB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from '@frontmcp/lazy-zod';
|
|
2
|
-
export declare const describeToolDescription = "Get input/output schemas for tools from search results.\n\nINPUT: toolNames: string[] - tool names from search\nOUTPUT per tool: inputSchema (JSON Schema), outputSchema (JSON Schema), usageExamples (up to 5 callTool examples)\n\nIMPORTANT: If notFound array is non-empty \u2192 re-search with corrected queries.\nFLOW: search \u2192 describe \u2192 execute/invoke";
|
|
2
|
+
export declare const describeToolDescription = "Get input/output schemas for tools from search results.\n\nINPUT: toolNames: string[] - tool names from search, at most the server's maxDefinitions (8 unless configured) per call\nOUTPUT per tool: inputSchema (JSON Schema), outputSchema (JSON Schema), usageExamples (up to 5 callTool examples)\n\nIMPORTANT: If notFound array is non-empty \u2192 re-search with corrected queries.\nFLOW: search \u2192 describe \u2192 execute/invoke";
|
|
3
3
|
export declare const describeToolInputSchema: {
|
|
4
4
|
toolNames: import("@frontmcp/lazy-zod").ZodArray<import("@frontmcp/lazy-zod").ZodString>;
|
|
5
5
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"describe.schema.d.ts","sourceRoot":"","sources":["../../src/tools/describe.schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,oBAAoB,CAAC;AAGvC,eAAO,MAAM,uBAAuB,
|
|
1
|
+
{"version":3,"file":"describe.schema.d.ts","sourceRoot":"","sources":["../../src/tools/describe.schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,oBAAoB,CAAC;AAGvC,eAAO,MAAM,uBAAuB,obAMK,CAAC;AAE1C,eAAO,MAAM,uBAAuB;;CAuBnC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,uBAAuB,CAAC,CAAC,CAAC;AAErF,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;gCAoCnC,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"describe.tool.d.ts","sourceRoot":"","sources":["../../src/tools/describe.tool.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"describe.tool.d.ts","sourceRoot":"","sources":["../../src/tools/describe.tool.ts"],"names":[],"mappings":"AAEA,OAAO,EAA2C,WAAW,EAAkB,MAAM,eAAe,CAAC;AAMrG,OAAO,EAIL,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACxB,MAAM,mBAAmB,CAAC;AAuB3B,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,WAAW;IAC7C,OAAO,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAwEpE;;;;;;;;OAQG;IACH,OAAO,CAAC,cAAc;IAuBtB;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IAkDpB;;OAEG;IACH,OAAO,CAAC,YAAY;IA6BpB;;;;;;;;;OASG;IACH,OAAO,CAAC,gBAAgB;CAyBzB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from '@frontmcp/lazy-zod';
|
|
2
|
-
export declare const executeToolDescription = "Execute AgentScript (safe JS subset) for multi-tool orchestration.\n\nAPI: await callTool(name, args, opts?)\n- Default: throws on error\n- Safe mode: { throwOnError: false } \u2192 returns { success, data?, error? }\n\nEXAMPLE:\nconst users = await callTool('users:list', { active: true });\nconst results = [];\nfor (const u of users.items) {\n const orders = await callTool('orders:list', { userId: u.id });\n results.push({ id: u.id, total: orders.items.reduce((s,o) => s + o.amount, 0) });\n}\nreturn results;\n\nALLOWED: for
|
|
2
|
+
export declare const executeToolDescription = "Execute AgentScript (safe JS subset) for multi-tool orchestration.\n\nAPI: await callTool(name, args, opts?)\n- Default: throws on error\n- Safe mode: { throwOnError: false } \u2192 returns { success, data?, error? }\n\nEXAMPLE:\nconst users = await callTool('users:list', { active: true });\nconst results = [];\nfor (const u of users.items) {\n const orders = await callTool('orders:list', { userId: u.id });\n results.push({ id: u.id, total: orders.items.reduce((s,o) => s + o.amount, 0) });\n}\nreturn results;\n\nALLOWED: for-of, arrow fn, map/filter/reduce/find, Math.*, JSON.*, if/else, destructuring, spread, template literals\nBLOCKED: while, do-while, for (unless the server sets vm.allowLoops), console (use mcpLog), function decl, eval, require, fetch, setTimeout, process, globalThis\n\nERRORS: NOT_FOUND | VALIDATION | EXECUTION | TIMEOUT | ACCESS_DENIED\nSTATUS: ok | syntax_error | illegal_access | runtime_error | tool_error | timeout\nLIMITS: 10K iter/loop, 30s timeout, 100 calls max";
|
|
3
3
|
export declare const executeToolInputSchema: {
|
|
4
4
|
script: import("@frontmcp/lazy-zod").ZodString;
|
|
5
5
|
allowedTools: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodArray<import("@frontmcp/lazy-zod").ZodString>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.schema.d.ts","sourceRoot":"","sources":["../../src/tools/execute.schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,oBAAoB,CAAC;AAKvC,eAAO,MAAM,sBAAsB,
|
|
1
|
+
{"version":3,"file":"execute.schema.d.ts","sourceRoot":"","sources":["../../src/tools/execute.schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,oBAAoB,CAAC;AAKvC,eAAO,MAAM,sBAAsB,i/BAoBe,CAAC;AAEnD,eAAO,MAAM,sBAAsB;;;CAclC,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,sBAAsB,CAAC,CAAC,CAAC;AAkDnF;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;gCAIjC,CAAC;AAEH,eAAO,MAAM,+BAA+B;;;;;;;;;gCAG1C,CAAC;AAEH,eAAO,MAAM,iCAAiC;;;;;;gCAG5C,CAAC;AAEH,eAAO,MAAM,gCAAgC;;;;;;;;gCAG3C,CAAC;AAEH,eAAO,MAAM,6BAA6B;;;;;;;;;;gCAGxC,CAAC;AAEH,eAAO,MAAM,2BAA2B;;;;;gCAGtC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4CAOlC,CAAC;AAEH;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AACtE,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AACxF,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAC;AAC5F,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAC;AAC1F,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AACpF,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEhF,MAAM,MAAM,qBAAqB,GAC7B,gBAAgB,GAChB,yBAAyB,GACzB,2BAA2B,GAC3B,0BAA0B,GAC1B,uBAAuB,GACvB,qBAAqB,CAAC"}
|
package/tools/search.schema.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { z } from '@frontmcp/lazy-zod';
|
|
2
|
-
export declare const searchToolDescription = "Find tools by splitting user request into atomic actions.\n\nDECOMPOSE: \"delete users and send email\" \u2192 queries: [\"delete user\", \"send email\"]\nDECOMPOSE: \"get order and refund\" \u2192 queries: [\"get order\", \"calculate refund\"]\n\nAVOID RE-SEARCHING: Use excludeToolNames for already-discovered tools.\nRE-SEARCH WHEN: describe fails (typo?) OR execute returns tool_not_found.\n\nINPUT:\n- queries: string[] (required) - atomic action phrases, max 10\n- appIds?: string[] - filter by app\n- excludeToolNames?: string[] - skip known tools\n- topK?: number (default
|
|
2
|
+
export declare const searchToolDescription = "Find tools by splitting user request into atomic actions.\n\nDECOMPOSE: \"delete users and send email\" \u2192 queries: [\"delete user\", \"send email\"]\nDECOMPOSE: \"get order and refund\" \u2192 queries: [\"get order\", \"calculate refund\"]\n\nAVOID RE-SEARCHING: Use excludeToolNames for already-discovered tools.\nRE-SEARCH WHEN: describe fails (typo?) OR execute returns tool_not_found.\n\nINPUT:\n- queries: string[] (required) - atomic action phrases, max 10\n- appIds?: string[] - filter by app\n- excludeToolNames?: string[] - skip known tools\n- topK?: number (default: the server's topK, 8 unless configured) - results per query\n- minRelevanceScore?: number (default 0.3) - minimum match threshold\n\nOUTPUT: Flat deduplicated tool list. relevanceScore: 0.5+=good, 0.7+=strong match.\n\nFLOW: search \u2192 describe \u2192 execute/invoke";
|
|
3
3
|
export declare const searchToolInputSchema: {
|
|
4
4
|
queries: import("@frontmcp/lazy-zod").ZodArray<import("@frontmcp/lazy-zod").ZodString>;
|
|
5
5
|
appIds: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodArray<import("@frontmcp/lazy-zod").ZodString>>;
|
|
6
6
|
excludeToolNames: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodArray<import("@frontmcp/lazy-zod").ZodString>>;
|
|
7
|
-
topK: import("@frontmcp/lazy-zod").
|
|
7
|
+
topK: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodNumber>;
|
|
8
8
|
minRelevanceScore: import("@frontmcp/lazy-zod").ZodDefault<import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodNumber>>;
|
|
9
9
|
};
|
|
10
10
|
export type SearchToolInput = z.infer<z.ZodObject<typeof searchToolInputSchema>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.schema.d.ts","sourceRoot":"","sources":["../../src/tools/search.schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,oBAAoB,CAAC;AAEvC,eAAO,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"search.schema.d.ts","sourceRoot":"","sources":["../../src/tools/search.schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,oBAAoB,CAAC;AAEvC,eAAO,MAAM,qBAAqB,w1BAiBO,CAAC;AAE1C,eAAO,MAAM,qBAAqB;;;;;;CAsBjC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,qBAAqB,CAAC,CAAC,CAAC;AAEjF,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;gCAsBjC,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
|