@frontmcp/plugins 0.5.1 → 0.6.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontmcp/plugins",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "FrontMCP plugins to extend the SDK",
|
|
5
5
|
"author": "AgentFront <info@agentfront.dev>",
|
|
6
6
|
"homepage": "https://docs.agentfront.dev",
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"ioredis": "^5.8.0",
|
|
36
|
-
"@frontmcp/sdk": "0.
|
|
37
|
-
"ast-guard": "^1.1.1",
|
|
36
|
+
"@frontmcp/sdk": "0.6.0",
|
|
38
37
|
"enclave-vm": "^1.0.3",
|
|
39
38
|
"vectoriadb": "^2.0.1",
|
|
40
|
-
"
|
|
39
|
+
"zod": "^4.0.0",
|
|
40
|
+
"@modelcontextprotocol/sdk": "1.24.3"
|
|
41
41
|
},
|
|
42
42
|
"type": "commonjs"
|
|
43
43
|
}
|
|
@@ -66,21 +66,42 @@ export declare const synonymExpansionConfigSchema: z.ZodDefault<z.ZodObject<{
|
|
|
66
66
|
replaceDefaults: z.ZodDefault<z.ZodBoolean>;
|
|
67
67
|
maxExpansionsPerTerm: z.ZodDefault<z.ZodNumber>;
|
|
68
68
|
}, z.core.$strip>>;
|
|
69
|
-
export declare const codeCallEmbeddingOptionsSchema: z.
|
|
70
|
-
strategy: z.ZodDefault<z.ZodEnum<{
|
|
69
|
+
export declare const codeCallEmbeddingOptionsSchema: z.ZodPipe<z.ZodOptional<z.ZodObject<{
|
|
70
|
+
strategy: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
|
|
71
71
|
tfidf: "tfidf";
|
|
72
72
|
ml: "ml";
|
|
73
|
-
}
|
|
74
|
-
modelName: z.
|
|
75
|
-
cacheDir: z.
|
|
76
|
-
useHNSW: z.
|
|
77
|
-
synonymExpansion: z.
|
|
73
|
+
}>>>;
|
|
74
|
+
modelName: z.ZodOptional<z.ZodString>;
|
|
75
|
+
cacheDir: z.ZodOptional<z.ZodString>;
|
|
76
|
+
useHNSW: z.ZodOptional<z.ZodBoolean>;
|
|
77
|
+
synonymExpansion: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodDefault<z.ZodObject<{
|
|
78
78
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
79
79
|
additionalSynonyms: z.ZodOptional<z.ZodArray<z.ZodArray<z.ZodString>>>;
|
|
80
80
|
replaceDefaults: z.ZodDefault<z.ZodBoolean>;
|
|
81
81
|
maxExpansionsPerTerm: z.ZodDefault<z.ZodNumber>;
|
|
82
|
-
}, z.core.$strip>>]
|
|
83
|
-
}, z.core.$strip
|
|
82
|
+
}, z.core.$strip>>]>>;
|
|
83
|
+
}, z.core.$strip>>, z.ZodTransform<{
|
|
84
|
+
strategy: "tfidf" | "ml";
|
|
85
|
+
modelName: string;
|
|
86
|
+
cacheDir: string;
|
|
87
|
+
useHNSW: boolean;
|
|
88
|
+
synonymExpansion: false | {
|
|
89
|
+
enabled: boolean;
|
|
90
|
+
replaceDefaults: boolean;
|
|
91
|
+
maxExpansionsPerTerm: number;
|
|
92
|
+
};
|
|
93
|
+
}, {
|
|
94
|
+
strategy?: "tfidf" | "ml" | undefined;
|
|
95
|
+
modelName?: string | undefined;
|
|
96
|
+
cacheDir?: string | undefined;
|
|
97
|
+
useHNSW?: boolean | undefined;
|
|
98
|
+
synonymExpansion?: false | {
|
|
99
|
+
enabled: boolean;
|
|
100
|
+
replaceDefaults: boolean;
|
|
101
|
+
maxExpansionsPerTerm: number;
|
|
102
|
+
additionalSynonyms?: string[][] | undefined;
|
|
103
|
+
} | undefined;
|
|
104
|
+
} | undefined>>;
|
|
84
105
|
export declare const codeCallSidecarOptionsSchema: z.ZodDefault<z.ZodObject<{
|
|
85
106
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
86
107
|
maxTotalSize: z.ZodOptional<z.ZodNumber>;
|
|
@@ -118,21 +139,42 @@ declare const codeCallPluginOptionsObjectSchema: z.ZodObject<{
|
|
|
118
139
|
disabledGlobals: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
119
140
|
allowConsole: z.ZodOptional<z.ZodBoolean>;
|
|
120
141
|
}, z.core.$strip>>;
|
|
121
|
-
embedding: z.
|
|
122
|
-
strategy: z.ZodDefault<z.ZodEnum<{
|
|
142
|
+
embedding: z.ZodPipe<z.ZodOptional<z.ZodObject<{
|
|
143
|
+
strategy: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
|
|
123
144
|
tfidf: "tfidf";
|
|
124
145
|
ml: "ml";
|
|
125
|
-
}
|
|
126
|
-
modelName: z.
|
|
127
|
-
cacheDir: z.
|
|
128
|
-
useHNSW: z.
|
|
129
|
-
synonymExpansion: z.
|
|
146
|
+
}>>>;
|
|
147
|
+
modelName: z.ZodOptional<z.ZodString>;
|
|
148
|
+
cacheDir: z.ZodOptional<z.ZodString>;
|
|
149
|
+
useHNSW: z.ZodOptional<z.ZodBoolean>;
|
|
150
|
+
synonymExpansion: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodDefault<z.ZodObject<{
|
|
130
151
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
131
152
|
additionalSynonyms: z.ZodOptional<z.ZodArray<z.ZodArray<z.ZodString>>>;
|
|
132
153
|
replaceDefaults: z.ZodDefault<z.ZodBoolean>;
|
|
133
154
|
maxExpansionsPerTerm: z.ZodDefault<z.ZodNumber>;
|
|
134
|
-
}, z.core.$strip>>]
|
|
135
|
-
}, z.core.$strip
|
|
155
|
+
}, z.core.$strip>>]>>;
|
|
156
|
+
}, z.core.$strip>>, z.ZodTransform<{
|
|
157
|
+
strategy: "tfidf" | "ml";
|
|
158
|
+
modelName: string;
|
|
159
|
+
cacheDir: string;
|
|
160
|
+
useHNSW: boolean;
|
|
161
|
+
synonymExpansion: false | {
|
|
162
|
+
enabled: boolean;
|
|
163
|
+
replaceDefaults: boolean;
|
|
164
|
+
maxExpansionsPerTerm: number;
|
|
165
|
+
};
|
|
166
|
+
}, {
|
|
167
|
+
strategy?: "tfidf" | "ml" | undefined;
|
|
168
|
+
modelName?: string | undefined;
|
|
169
|
+
cacheDir?: string | undefined;
|
|
170
|
+
useHNSW?: boolean | undefined;
|
|
171
|
+
synonymExpansion?: false | {
|
|
172
|
+
enabled: boolean;
|
|
173
|
+
replaceDefaults: boolean;
|
|
174
|
+
maxExpansionsPerTerm: number;
|
|
175
|
+
additionalSynonyms?: string[][] | undefined;
|
|
176
|
+
} | undefined;
|
|
177
|
+
} | undefined>>;
|
|
136
178
|
sidecar: z.ZodDefault<z.ZodObject<{
|
|
137
179
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
138
180
|
maxTotalSize: z.ZodOptional<z.ZodNumber>;
|
|
@@ -171,21 +213,42 @@ export declare const codeCallPluginOptionsSchema: z.ZodPrefault<z.ZodObject<{
|
|
|
171
213
|
disabledGlobals: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
172
214
|
allowConsole: z.ZodOptional<z.ZodBoolean>;
|
|
173
215
|
}, z.core.$strip>>;
|
|
174
|
-
embedding: z.
|
|
175
|
-
strategy: z.ZodDefault<z.ZodEnum<{
|
|
216
|
+
embedding: z.ZodPipe<z.ZodOptional<z.ZodObject<{
|
|
217
|
+
strategy: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
|
|
176
218
|
tfidf: "tfidf";
|
|
177
219
|
ml: "ml";
|
|
178
|
-
}
|
|
179
|
-
modelName: z.
|
|
180
|
-
cacheDir: z.
|
|
181
|
-
useHNSW: z.
|
|
182
|
-
synonymExpansion: z.
|
|
220
|
+
}>>>;
|
|
221
|
+
modelName: z.ZodOptional<z.ZodString>;
|
|
222
|
+
cacheDir: z.ZodOptional<z.ZodString>;
|
|
223
|
+
useHNSW: z.ZodOptional<z.ZodBoolean>;
|
|
224
|
+
synonymExpansion: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodDefault<z.ZodObject<{
|
|
183
225
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
184
226
|
additionalSynonyms: z.ZodOptional<z.ZodArray<z.ZodArray<z.ZodString>>>;
|
|
185
227
|
replaceDefaults: z.ZodDefault<z.ZodBoolean>;
|
|
186
228
|
maxExpansionsPerTerm: z.ZodDefault<z.ZodNumber>;
|
|
187
|
-
}, z.core.$strip>>]
|
|
188
|
-
}, z.core.$strip
|
|
229
|
+
}, z.core.$strip>>]>>;
|
|
230
|
+
}, z.core.$strip>>, z.ZodTransform<{
|
|
231
|
+
strategy: "tfidf" | "ml";
|
|
232
|
+
modelName: string;
|
|
233
|
+
cacheDir: string;
|
|
234
|
+
useHNSW: boolean;
|
|
235
|
+
synonymExpansion: false | {
|
|
236
|
+
enabled: boolean;
|
|
237
|
+
replaceDefaults: boolean;
|
|
238
|
+
maxExpansionsPerTerm: number;
|
|
239
|
+
};
|
|
240
|
+
}, {
|
|
241
|
+
strategy?: "tfidf" | "ml" | undefined;
|
|
242
|
+
modelName?: string | undefined;
|
|
243
|
+
cacheDir?: string | undefined;
|
|
244
|
+
useHNSW?: boolean | undefined;
|
|
245
|
+
synonymExpansion?: false | {
|
|
246
|
+
enabled: boolean;
|
|
247
|
+
replaceDefaults: boolean;
|
|
248
|
+
maxExpansionsPerTerm: number;
|
|
249
|
+
additionalSynonyms?: string[][] | undefined;
|
|
250
|
+
} | undefined;
|
|
251
|
+
} | undefined>>;
|
|
189
252
|
sidecar: z.ZodDefault<z.ZodObject<{
|
|
190
253
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
191
254
|
maxTotalSize: z.ZodOptional<z.ZodNumber>;
|
|
@@ -119,23 +119,23 @@ exports.codeCallEmbeddingOptionsSchema = zod_1.z
|
|
|
119
119
|
* - 'ml': ML-based semantic search using transformers.js (better quality, requires model download)
|
|
120
120
|
* @default 'tfidf'
|
|
121
121
|
*/
|
|
122
|
-
strategy: exports.embeddingStrategySchema,
|
|
122
|
+
strategy: exports.embeddingStrategySchema.optional(),
|
|
123
123
|
/**
|
|
124
124
|
* Model name for ML-based embeddings (only used when strategy='ml')
|
|
125
125
|
* @default 'Xenova/all-MiniLM-L6-v2'
|
|
126
126
|
*/
|
|
127
|
-
modelName: zod_1.z.string().
|
|
127
|
+
modelName: zod_1.z.string().optional(),
|
|
128
128
|
/**
|
|
129
129
|
* Cache directory for ML models (only used when strategy='ml')
|
|
130
130
|
* @default './.cache/transformers'
|
|
131
131
|
*/
|
|
132
|
-
cacheDir: zod_1.z.string().
|
|
132
|
+
cacheDir: zod_1.z.string().optional(),
|
|
133
133
|
/**
|
|
134
134
|
* Enable HNSW index for faster search (only used when strategy='ml')
|
|
135
135
|
* When enabled, provides O(log n) search instead of O(n) brute-force
|
|
136
136
|
* @default false
|
|
137
137
|
*/
|
|
138
|
-
useHNSW: zod_1.z.boolean().
|
|
138
|
+
useHNSW: zod_1.z.boolean().optional(),
|
|
139
139
|
/**
|
|
140
140
|
* Synonym expansion configuration for TF-IDF search.
|
|
141
141
|
* When enabled, queries like "add user" will match tools for "create user".
|
|
@@ -143,12 +143,16 @@ exports.codeCallEmbeddingOptionsSchema = zod_1.z
|
|
|
143
143
|
* Set to false to disable, or provide a config object to customize.
|
|
144
144
|
* @default { enabled: true }
|
|
145
145
|
*/
|
|
146
|
-
synonymExpansion: zod_1.z
|
|
147
|
-
.union([zod_1.z.literal(false), exports.synonymExpansionConfigSchema])
|
|
148
|
-
.optional()
|
|
149
|
-
.default({ enabled: true, replaceDefaults: false, maxExpansionsPerTerm: 5 }),
|
|
146
|
+
synonymExpansion: zod_1.z.union([zod_1.z.literal(false), exports.synonymExpansionConfigSchema]).optional(),
|
|
150
147
|
})
|
|
151
|
-
.
|
|
148
|
+
.optional()
|
|
149
|
+
.transform((opts) => ({
|
|
150
|
+
strategy: opts?.strategy ?? DEFAULT_EMBEDDING_OPTIONS.strategy,
|
|
151
|
+
modelName: opts?.modelName ?? DEFAULT_EMBEDDING_OPTIONS.modelName,
|
|
152
|
+
cacheDir: opts?.cacheDir ?? DEFAULT_EMBEDDING_OPTIONS.cacheDir,
|
|
153
|
+
useHNSW: opts?.useHNSW ?? DEFAULT_EMBEDDING_OPTIONS.useHNSW,
|
|
154
|
+
synonymExpansion: opts?.synonymExpansion ?? DEFAULT_EMBEDDING_OPTIONS.synonymExpansion,
|
|
155
|
+
}));
|
|
152
156
|
exports.codeCallSidecarOptionsSchema = zod_1.z
|
|
153
157
|
.object({
|
|
154
158
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codecall.types.js","sourceRoot":"","sources":["../../../src/codecall/codecall.types.ts"],"names":[],"mappings":";AAAA,oDAAoD;;;AAEpD,6BAAwB;AAmCxB,8DAA8D;AAC9D,MAAM,uBAAuB,GAAG,OAAC,CAAC,MAAM,CAAsB,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,GAAG,KAAK,UAAU,EAAE;IAChG,OAAO,EAAE,uFAAuF;CACjG,CAAC,CAAC;AAEH,MAAM,wBAAwB,GAAG,OAAC,CAAC,MAAM,CAAuB,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,GAAG,KAAK,UAAU,EAAE;IAClG,OAAO,EAAE,8FAA8F;CACxG,CAAC,CAAC;AAEH,wCAAwC;AAE3B,QAAA,kBAAkB,GAAG,OAAC;KAChC,IAAI,CAAC,CAAC,eAAe,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;KAC7D,OAAO,CAAC,eAAe,CAAC,CAAC;AAEf,QAAA,sBAAsB,GAAG,OAAC,CAAC,IAAI,CAAC,CAAC,aAAa,EAAE,QAAQ,EAAE,UAAU,EAAE,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEtH,gCAAgC;AAChC,MAAM,kBAAkB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AGG;IACH,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEtC;;;OAGG;IACH,cAAc,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEhD;;;OAGG;IACH,YAAY,EAAE,wBAAwB,CAAC,QAAQ,EAAE;IAEjD;;OAEG;IACH,WAAW,EAAE,wCAAgC,CAAC,QAAQ,EAAE;IAExD;;OAEG;IACH,EAAE,EAAE,+BAAuB;IAE3B;;OAEG;IACH,SAAS,EAAE,sCAA8B;IAEzC;;;OAGG;IACH,OAAO,EAAE,oCAA4B;CACtC,CAAC,CAAC;AAEH,oCAAoC;AACpC,MAAM,sBAAsB,GAAG;IAC7B,IAAI,EAAE,eAAwB;IAC9B,IAAI,EAAE,CAAC;IACP,cAAc,EAAE,CAAC;IACjB,EAAE,EAAE,kBAAkB;IACtB,SAAS,EAAE,yBAAyB;IACpC,OAAO,EAAE;QACP,OAAO,EAAE,KAAK;QACd,2BAA2B,EAAE,EAAE,GAAG,IAAI;KACvC;CACF,CAAC;AAEF,8CAA8C;AACjC,QAAA,2BAA2B,GAAG,iCAAiC,CAAC,QAAQ,CAAC,sBAAsB,CAAC,CAAC","sourcesContent":["// file: libs/plugins/src/codecall/codecall.types.ts\n\nimport { z } from 'zod';\n\n// ===== Filter Function Types =====\n\n/**\n * Tool info passed to the directCalls filter function\n */\nexport interface DirectCallsFilterToolInfo {\n name: string;\n appId?: string;\n source?: string;\n tags?: string[];\n}\n\n/**\n * Tool info passed to the includeTools filter function\n */\nexport interface IncludeToolsFilterToolInfo {\n name: string;\n appId?: string;\n source?: string;\n description?: string;\n tags?: string[];\n}\n\n/**\n * Function type for directCalls filter\n */\nexport type DirectCallsFilterFn = (tool: DirectCallsFilterToolInfo) => boolean;\n\n/**\n * Function type for includeTools filter\n */\nexport type IncludeToolsFilterFn = (tool: IncludeToolsFilterToolInfo) => boolean;\n\n// Helper schemas for filter functions with runtime validation\nconst directCallsFilterSchema = z.custom<DirectCallsFilterFn>((val) => typeof val === 'function', {\n message: 'filter must be a function with signature (tool: DirectCallsFilterToolInfo) => boolean',\n});\n\nconst includeToolsFilterSchema = z.custom<IncludeToolsFilterFn>((val) => typeof val === 'function', {\n message: 'includeTools must be a function with signature (tool: IncludeToolsFilterToolInfo) => boolean',\n});\n\n// ===== Zod Schemas with Defaults =====\n\nexport const codeCallModeSchema = z\n .enum(['codecall_only', 'codecall_opt_in', 'metadata_driven'])\n .default('codecall_only');\n\nexport const codeCallVmPresetSchema = z.enum(['locked_down', 'secure', 'balanced', 'experimental']).default('secure');\n\n// Default values for VM options\nconst DEFAULT_VM_OPTIONS = {\n preset: 'secure' as const,\n};\n\nexport const codeCallVmOptionsSchema = z\n .object({\n /**\n * CSP-like preset; see README.\n * @default 'secure'\n */\n preset: codeCallVmPresetSchema,\n\n /**\n * Timeout for script execution in milliseconds\n * Defaults vary by preset\n */\n timeoutMs: z.number().positive().optional(),\n\n /**\n * Allow loop constructs (for, while, do-while)\n * Defaults vary by preset\n */\n allowLoops: z.boolean().optional(),\n\n /**\n * Maximum number of steps (if applicable)\n * Defaults vary by preset\n */\n maxSteps: z.number().positive().optional(),\n\n /**\n * List of disabled builtin functions\n * Defaults vary by preset\n */\n disabledBuiltins: z.array(z.string()).optional(),\n\n /**\n * List of disabled global variables\n * Defaults vary by preset\n */\n disabledGlobals: z.array(z.string()).optional(),\n\n /**\n * Allow console.log/warn/error\n * Defaults vary by preset\n */\n allowConsole: z.boolean().optional(),\n })\n .default(() => DEFAULT_VM_OPTIONS);\n\nexport const codeCallDirectCallsOptionsSchema = z.object({\n /**\n * Enable/disable the `codecall.invoke` meta-tool.\n */\n enabled: z.boolean(),\n\n /**\n * Optional allowlist of tool names.\n */\n allowedTools: z.array(z.string()).optional(),\n\n /**\n * Optional advanced filter function.\n * Signature: (tool: DirectCallsFilterToolInfo) => boolean\n */\n filter: directCallsFilterSchema.optional(),\n});\n\nexport const embeddingStrategySchema = z.enum(['tfidf', 'ml']).default('tfidf');\n\n// Synonym expansion configuration schema\nexport const synonymExpansionConfigSchema = z\n .object({\n /**\n * Enable/disable synonym expansion for TF-IDF search.\n * When enabled, queries are expanded with synonyms to improve relevance.\n * For example, \"add user\" will also match tools containing \"create user\".\n * @default true\n */\n enabled: z.boolean().default(true),\n\n /**\n * Additional synonym groups beyond the defaults.\n * Each group is an array of related terms that should be treated as equivalent.\n * @example [['customer', 'client', 'buyer'], ['order', 'purchase', 'transaction']]\n */\n additionalSynonyms: z.array(z.array(z.string())).optional(),\n\n /**\n * Replace default synonyms entirely with additionalSynonyms.\n * @default false\n */\n replaceDefaults: z.boolean().default(false),\n\n /**\n * Maximum number of synonym expansions per term.\n * Prevents query explosion for terms with many synonyms.\n * @default 5\n */\n maxExpansionsPerTerm: z.number().positive().default(5),\n })\n .default({ enabled: true, replaceDefaults: false, maxExpansionsPerTerm: 5 });\n\n// Default values for embedding options\nconst DEFAULT_EMBEDDING_OPTIONS = {\n strategy: 'tfidf' as const,\n modelName: 'Xenova/all-MiniLM-L6-v2',\n cacheDir: './.cache/transformers',\n useHNSW: false,\n synonymExpansion: { enabled: true, replaceDefaults: false, maxExpansionsPerTerm: 5 },\n};\n\nexport const codeCallEmbeddingOptionsSchema = z\n .object({\n /**\n * Embedding strategy to use for tool search\n * - 'tfidf': Lightweight, synchronous TF-IDF based search (no ML models required)\n * - 'ml': ML-based semantic search using transformers.js (better quality, requires model download)\n * @default 'tfidf'\n */\n strategy: embeddingStrategySchema,\n\n /**\n * Model name for ML-based embeddings (only used when strategy='ml')\n * @default 'Xenova/all-MiniLM-L6-v2'\n */\n modelName: z.string().default('Xenova/all-MiniLM-L6-v2'),\n\n /**\n * Cache directory for ML models (only used when strategy='ml')\n * @default './.cache/transformers'\n */\n cacheDir: z.string().default('./.cache/transformers'),\n\n /**\n * Enable HNSW index for faster search (only used when strategy='ml')\n * When enabled, provides O(log n) search instead of O(n) brute-force\n * @default false\n */\n useHNSW: z.boolean().default(false),\n\n /**\n * Synonym expansion configuration for TF-IDF search.\n * When enabled, queries like \"add user\" will match tools for \"create user\".\n * Only applies when strategy is 'tfidf' (ML already handles semantic similarity).\n * Set to false to disable, or provide a config object to customize.\n * @default { enabled: true }\n */\n synonymExpansion: z\n .union([z.literal(false), synonymExpansionConfigSchema])\n .optional()\n .default({ enabled: true, replaceDefaults: false, maxExpansionsPerTerm: 5 }),\n })\n .default(DEFAULT_EMBEDDING_OPTIONS);\n\nexport const codeCallSidecarOptionsSchema = z\n .object({\n /**\n * Enable pass-by-reference support via sidecar\n * When enabled, large strings are automatically lifted to a sidecar\n * and resolved at the callTool boundary\n * @default false\n */\n enabled: z.boolean().default(false),\n\n /**\n * Maximum total size of all stored references in bytes\n * @default 16MB (from security level)\n */\n maxTotalSize: z.number().positive().optional(),\n\n /**\n * Maximum size of a single reference in bytes\n * @default 4MB (from security level)\n */\n maxReferenceSize: z.number().positive().optional(),\n\n /**\n * Threshold in bytes to trigger extraction from source code\n * Strings larger than this are lifted to the sidecar\n * @default 64KB (from security level)\n */\n extractionThreshold: z.number().positive().optional(),\n\n /**\n * Maximum expanded size when resolving references for tool calls\n * @default 8MB (from security level)\n */\n maxResolvedSize: z.number().positive().optional(),\n\n /**\n * Whether to allow composite handles from string concatenation\n * If false, concatenating references throws an error\n * @default false (strict mode)\n */\n allowComposites: z.boolean().optional(),\n\n /**\n * Maximum script length (in characters) when sidecar is disabled\n * Prevents large inline data from being embedded in script\n * If null, no limit is enforced\n * @default 64KB\n */\n maxScriptLengthWhenDisabled: z\n .number()\n .positive()\n .nullable()\n .default(64 * 1024),\n })\n .default(() => ({\n enabled: false,\n maxScriptLengthWhenDisabled: 64 * 1024,\n }));\n\n// Inner schema without the outer .default() - used for extracting input type\nconst codeCallPluginOptionsObjectSchema = z.object({\n /**\n * CodeCall mode\n * @default 'codecall_only'\n */\n mode: codeCallModeSchema,\n\n /**\n * Default number of tools to return in search results\n * @default 8\n */\n topK: z.number().positive().default(8),\n\n /**\n * Maximum number of tool definitions to include\n * @default 8\n */\n maxDefinitions: z.number().positive().default(8),\n\n /**\n * Optional filter function for including tools.\n * Signature: (tool: IncludeToolsFilterToolInfo) => boolean\n */\n includeTools: includeToolsFilterSchema.optional(),\n\n /**\n * Direct calls configuration\n */\n directCalls: codeCallDirectCallsOptionsSchema.optional(),\n\n /**\n * VM execution options\n */\n vm: codeCallVmOptionsSchema,\n\n /**\n * Embedding configuration for tool search\n */\n embedding: codeCallEmbeddingOptionsSchema,\n\n /**\n * Sidecar (pass-by-reference) configuration\n * When enabled, large data is stored outside the sandbox and resolved at callTool boundary\n */\n sidecar: codeCallSidecarOptionsSchema,\n});\n\n// Default values for plugin options\nconst DEFAULT_PLUGIN_OPTIONS = {\n mode: 'codecall_only' as const,\n topK: 8,\n maxDefinitions: 8,\n vm: DEFAULT_VM_OPTIONS,\n embedding: DEFAULT_EMBEDDING_OPTIONS,\n sidecar: {\n enabled: false,\n maxScriptLengthWhenDisabled: 64 * 1024,\n },\n};\n\n// Full schema with default - used for parsing\nexport const codeCallPluginOptionsSchema = codeCallPluginOptionsObjectSchema.prefault(DEFAULT_PLUGIN_OPTIONS);\n\n// ===== TypeScript Types =====\n\n// Output types (after parsing, with defaults applied) - use for internal plugin logic\nexport type CodeCallMode = z.infer<typeof codeCallModeSchema>;\nexport type CodeCallVmPreset = z.infer<typeof codeCallVmPresetSchema>;\nexport type CodeCallVmOptions = z.infer<typeof codeCallVmOptionsSchema>;\nexport type CodeCallDirectCallsOptions = z.infer<typeof codeCallDirectCallsOptionsSchema>;\nexport type EmbeddingStrategy = z.infer<typeof embeddingStrategySchema>;\nexport type SynonymExpansionConfig = z.infer<typeof synonymExpansionConfigSchema>;\nexport type CodeCallSidecarOptions = z.infer<typeof codeCallSidecarOptionsSchema>;\n\nexport type CodeCallEmbeddingOptions = z.infer<typeof codeCallEmbeddingOptionsSchema>;\nexport type CodeCallEmbeddingOptionsInput = z.input<typeof codeCallEmbeddingOptionsSchema>;\n\n/**\n * Resolved options type (after parsing with defaults applied).\n * Use this for internal plugin logic where all defaults are guaranteed.\n */\nexport type CodeCallPluginOptions = z.infer<typeof codeCallPluginOptionsSchema>;\n\n/**\n * Input options type (what users provide to init()).\n * All fields with defaults are optional.\n */\nexport type CodeCallPluginOptionsInput = z.input<typeof codeCallPluginOptionsObjectSchema>;\n\n/**\n * Per-tool metadata used by CodeCall.\n * This maps to `metadata.codecall` on tools.\n */\nexport interface CodeCallToolMetadata {\n /**\n * If true, this tool stays visible in `list_tools`\n * even when CodeCall is hiding most tools.\n */\n visibleInListTools?: boolean;\n\n /**\n * Whether this tool can be used via CodeCall.\n * Semantics depend on CodeCallMode (see README).\n */\n enabledInCodeCall?: boolean;\n\n /** Optional extra indexing hints */\n appId?: string;\n source?: string;\n tags?: string[];\n}\n\n// ----- meta-tool contracts -----\n\nexport type CodeCallSearchInput = {\n query: string;\n topK?: number;\n filter?: {\n appIds?: string[];\n tags?: string[];\n includeOpenApi?: boolean;\n includeInline?: boolean;\n };\n};\n\nexport type CodeCallSearchResult = {\n tools: {\n name: string;\n description: string;\n appId?: string;\n source?: string;\n score: number;\n }[];\n};\n\nexport type CodeCallDescribeInput = {\n tools: string[];\n max?: number;\n};\n\nexport type CodeCallDescribeResult = {\n tools: {\n name: string;\n description: string;\n inputSchema: unknown;\n outputSchema?: unknown | null;\n examples?: {\n input: unknown;\n output?: unknown;\n }[];\n }[];\n};\n\nexport type CodeCallExecuteInput = {\n script: string;\n /**\n * Arbitrary, readonly context exposed as `codecallContext`.\n */\n context?: Record<string, unknown>;\n};\n\n// ---- global FrontMCP metadata extension ----\n\ndeclare global {\n interface ExtendFrontMcpToolMetadata {\n /**\n * CodeCall-specific metadata, attached via `@Tool({ metadata: { codecall: ... } })`\n * or whatever your decorator mapping is.\n */\n codecall?: CodeCallToolMetadata;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"codecall.types.js","sourceRoot":"","s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YAAY,EAAE,wBAAwB,CAAC,QAAQ,EAAE;IAEjD;;OAEG;IACH,WAAW,EAAE,wCAAgC,CAAC,QAAQ,EAAE;IAExD;;OAEG;IACH,EAAE,EAAE,+BAAuB;IAE3B;;OAEG;IACH,SAAS,EAAE,sCAA8B;IAEzC;;;OAGG;IACH,OAAO,EAAE,oCAA4B;CACtC,CAAC,CAAC;AAEH,oCAAoC;AACpC,MAAM,sBAAsB,GAAG;IAC7B,IAAI,EAAE,eAAwB;IAC9B,IAAI,EAAE,CAAC;IACP,cAAc,EAAE,CAAC;IACjB,EAAE,EAAE,kBAAkB;IACtB,SAAS,EAAE,yBAAyB;IACpC,OAAO,EAAE;QACP,OAAO,EAAE,KAAK;QACd,2BAA2B,EAAE,EAAE,GAAG,IAAI;KACvC;CACF,CAAC;AAEF,8CAA8C;AACjC,QAAA,2BAA2B,GAAG,iCAAiC,CAAC,QAAQ,CAAC,sBAAsB,CAAC,CAAC","sourcesContent":["// file: libs/plugins/src/codecall/codecall.types.ts\n\nimport { z } from 'zod';\n\n// ===== Filter Function Types =====\n\n/**\n * Tool info passed to the directCalls filter function\n */\nexport interface DirectCallsFilterToolInfo {\n name: string;\n appId?: string;\n source?: string;\n tags?: string[];\n}\n\n/**\n * Tool info passed to the includeTools filter function\n */\nexport interface IncludeToolsFilterToolInfo {\n name: string;\n appId?: string;\n source?: string;\n description?: string;\n tags?: string[];\n}\n\n/**\n * Function type for directCalls filter\n */\nexport type DirectCallsFilterFn = (tool: DirectCallsFilterToolInfo) => boolean;\n\n/**\n * Function type for includeTools filter\n */\nexport type IncludeToolsFilterFn = (tool: IncludeToolsFilterToolInfo) => boolean;\n\n// Helper schemas for filter functions with runtime validation\nconst directCallsFilterSchema = z.custom<DirectCallsFilterFn>((val) => typeof val === 'function', {\n message: 'filter must be a function with signature (tool: DirectCallsFilterToolInfo) => boolean',\n});\n\nconst includeToolsFilterSchema = z.custom<IncludeToolsFilterFn>((val) => typeof val === 'function', {\n message: 'includeTools must be a function with signature (tool: IncludeToolsFilterToolInfo) => boolean',\n});\n\n// ===== Zod Schemas with Defaults =====\n\nexport const codeCallModeSchema = z\n .enum(['codecall_only', 'codecall_opt_in', 'metadata_driven'])\n .default('codecall_only');\n\nexport const codeCallVmPresetSchema = z.enum(['locked_down', 'secure', 'balanced', 'experimental']).default('secure');\n\n// Default values for VM options\nconst DEFAULT_VM_OPTIONS = {\n preset: 'secure' as const,\n};\n\nexport const codeCallVmOptionsSchema = z\n .object({\n /**\n * CSP-like preset; see README.\n * @default 'secure'\n */\n preset: codeCallVmPresetSchema,\n\n /**\n * Timeout for script execution in milliseconds\n * Defaults vary by preset\n */\n timeoutMs: z.number().positive().optional(),\n\n /**\n * Allow loop constructs (for, while, do-while)\n * Defaults vary by preset\n */\n allowLoops: z.boolean().optional(),\n\n /**\n * Maximum number of steps (if applicable)\n * Defaults vary by preset\n */\n maxSteps: z.number().positive().optional(),\n\n /**\n * List of disabled builtin functions\n * Defaults vary by preset\n */\n disabledBuiltins: z.array(z.string()).optional(),\n\n /**\n * List of disabled global variables\n * Defaults vary by preset\n */\n disabledGlobals: z.array(z.string()).optional(),\n\n /**\n * Allow console.log/warn/error\n * Defaults vary by preset\n */\n allowConsole: z.boolean().optional(),\n })\n .default(() => DEFAULT_VM_OPTIONS);\n\nexport const codeCallDirectCallsOptionsSchema = z.object({\n /**\n * Enable/disable the `codecall.invoke` meta-tool.\n */\n enabled: z.boolean(),\n\n /**\n * Optional allowlist of tool names.\n */\n allowedTools: z.array(z.string()).optional(),\n\n /**\n * Optional advanced filter function.\n * Signature: (tool: DirectCallsFilterToolInfo) => boolean\n */\n filter: directCallsFilterSchema.optional(),\n});\n\nexport const embeddingStrategySchema = z.enum(['tfidf', 'ml']).default('tfidf');\n\n// Synonym expansion configuration schema\nexport const synonymExpansionConfigSchema = z\n .object({\n /**\n * Enable/disable synonym expansion for TF-IDF search.\n * When enabled, queries are expanded with synonyms to improve relevance.\n * For example, \"add user\" will also match tools containing \"create user\".\n * @default true\n */\n enabled: z.boolean().default(true),\n\n /**\n * Additional synonym groups beyond the defaults.\n * Each group is an array of related terms that should be treated as equivalent.\n * @example [['customer', 'client', 'buyer'], ['order', 'purchase', 'transaction']]\n */\n additionalSynonyms: z.array(z.array(z.string())).optional(),\n\n /**\n * Replace default synonyms entirely with additionalSynonyms.\n * @default false\n */\n replaceDefaults: z.boolean().default(false),\n\n /**\n * Maximum number of synonym expansions per term.\n * Prevents query explosion for terms with many synonyms.\n * @default 5\n */\n maxExpansionsPerTerm: z.number().positive().default(5),\n })\n .default({ enabled: true, replaceDefaults: false, maxExpansionsPerTerm: 5 });\n\n// Default values for embedding options\nconst DEFAULT_EMBEDDING_OPTIONS = {\n strategy: 'tfidf' as const,\n modelName: 'Xenova/all-MiniLM-L6-v2',\n cacheDir: './.cache/transformers',\n useHNSW: false,\n synonymExpansion: { enabled: true, replaceDefaults: false, maxExpansionsPerTerm: 5 },\n};\n\nexport const codeCallEmbeddingOptionsSchema = z\n .object({\n /**\n * Embedding strategy to use for tool search\n * - 'tfidf': Lightweight, synchronous TF-IDF based search (no ML models required)\n * - 'ml': ML-based semantic search using transformers.js (better quality, requires model download)\n * @default 'tfidf'\n */\n strategy: embeddingStrategySchema.optional(),\n\n /**\n * Model name for ML-based embeddings (only used when strategy='ml')\n * @default 'Xenova/all-MiniLM-L6-v2'\n */\n modelName: z.string().optional(),\n\n /**\n * Cache directory for ML models (only used when strategy='ml')\n * @default './.cache/transformers'\n */\n cacheDir: z.string().optional(),\n\n /**\n * Enable HNSW index for faster search (only used when strategy='ml')\n * When enabled, provides O(log n) search instead of O(n) brute-force\n * @default false\n */\n useHNSW: z.boolean().optional(),\n\n /**\n * Synonym expansion configuration for TF-IDF search.\n * When enabled, queries like \"add user\" will match tools for \"create user\".\n * Only applies when strategy is 'tfidf' (ML already handles semantic similarity).\n * Set to false to disable, or provide a config object to customize.\n * @default { enabled: true }\n */\n synonymExpansion: z.union([z.literal(false), synonymExpansionConfigSchema]).optional(),\n })\n .optional()\n .transform((opts) => ({\n strategy: opts?.strategy ?? DEFAULT_EMBEDDING_OPTIONS.strategy,\n modelName: opts?.modelName ?? DEFAULT_EMBEDDING_OPTIONS.modelName,\n cacheDir: opts?.cacheDir ?? DEFAULT_EMBEDDING_OPTIONS.cacheDir,\n useHNSW: opts?.useHNSW ?? DEFAULT_EMBEDDING_OPTIONS.useHNSW,\n synonymExpansion: opts?.synonymExpansion ?? DEFAULT_EMBEDDING_OPTIONS.synonymExpansion,\n }));\n\nexport const codeCallSidecarOptionsSchema = z\n .object({\n /**\n * Enable pass-by-reference support via sidecar\n * When enabled, large strings are automatically lifted to a sidecar\n * and resolved at the callTool boundary\n * @default false\n */\n enabled: z.boolean().default(false),\n\n /**\n * Maximum total size of all stored references in bytes\n * @default 16MB (from security level)\n */\n maxTotalSize: z.number().positive().optional(),\n\n /**\n * Maximum size of a single reference in bytes\n * @default 4MB (from security level)\n */\n maxReferenceSize: z.number().positive().optional(),\n\n /**\n * Threshold in bytes to trigger extraction from source code\n * Strings larger than this are lifted to the sidecar\n * @default 64KB (from security level)\n */\n extractionThreshold: z.number().positive().optional(),\n\n /**\n * Maximum expanded size when resolving references for tool calls\n * @default 8MB (from security level)\n */\n maxResolvedSize: z.number().positive().optional(),\n\n /**\n * Whether to allow composite handles from string concatenation\n * If false, concatenating references throws an error\n * @default false (strict mode)\n */\n allowComposites: z.boolean().optional(),\n\n /**\n * Maximum script length (in characters) when sidecar is disabled\n * Prevents large inline data from being embedded in script\n * If null, no limit is enforced\n * @default 64KB\n */\n maxScriptLengthWhenDisabled: z\n .number()\n .positive()\n .nullable()\n .default(64 * 1024),\n })\n .default(() => ({\n enabled: false,\n maxScriptLengthWhenDisabled: 64 * 1024,\n }));\n\n// Inner schema without the outer .default() - used for extracting input type\nconst codeCallPluginOptionsObjectSchema = z.object({\n /**\n * CodeCall mode\n * @default 'codecall_only'\n */\n mode: codeCallModeSchema,\n\n /**\n * Default number of tools to return in search results\n * @default 8\n */\n topK: z.number().positive().default(8),\n\n /**\n * Maximum number of tool definitions to include\n * @default 8\n */\n maxDefinitions: z.number().positive().default(8),\n\n /**\n * Optional filter function for including tools.\n * Signature: (tool: IncludeToolsFilterToolInfo) => boolean\n */\n includeTools: includeToolsFilterSchema.optional(),\n\n /**\n * Direct calls configuration\n */\n directCalls: codeCallDirectCallsOptionsSchema.optional(),\n\n /**\n * VM execution options\n */\n vm: codeCallVmOptionsSchema,\n\n /**\n * Embedding configuration for tool search\n */\n embedding: codeCallEmbeddingOptionsSchema,\n\n /**\n * Sidecar (pass-by-reference) configuration\n * When enabled, large data is stored outside the sandbox and resolved at callTool boundary\n */\n sidecar: codeCallSidecarOptionsSchema,\n});\n\n// Default values for plugin options\nconst DEFAULT_PLUGIN_OPTIONS = {\n mode: 'codecall_only' as const,\n topK: 8,\n maxDefinitions: 8,\n vm: DEFAULT_VM_OPTIONS,\n embedding: DEFAULT_EMBEDDING_OPTIONS,\n sidecar: {\n enabled: false,\n maxScriptLengthWhenDisabled: 64 * 1024,\n },\n};\n\n// Full schema with default - used for parsing\nexport const codeCallPluginOptionsSchema = codeCallPluginOptionsObjectSchema.prefault(DEFAULT_PLUGIN_OPTIONS);\n\n// ===== TypeScript Types =====\n\n// Output types (after parsing, with defaults applied) - use for internal plugin logic\nexport type CodeCallMode = z.infer<typeof codeCallModeSchema>;\nexport type CodeCallVmPreset = z.infer<typeof codeCallVmPresetSchema>;\nexport type CodeCallVmOptions = z.infer<typeof codeCallVmOptionsSchema>;\nexport type CodeCallDirectCallsOptions = z.infer<typeof codeCallDirectCallsOptionsSchema>;\nexport type EmbeddingStrategy = z.infer<typeof embeddingStrategySchema>;\nexport type SynonymExpansionConfig = z.infer<typeof synonymExpansionConfigSchema>;\nexport type CodeCallSidecarOptions = z.infer<typeof codeCallSidecarOptionsSchema>;\n\nexport type CodeCallEmbeddingOptions = z.infer<typeof codeCallEmbeddingOptionsSchema>;\nexport type CodeCallEmbeddingOptionsInput = z.input<typeof codeCallEmbeddingOptionsSchema>;\n\n/**\n * Resolved options type (after parsing with defaults applied).\n * Use this for internal plugin logic where all defaults are guaranteed.\n */\nexport type CodeCallPluginOptions = z.infer<typeof codeCallPluginOptionsSchema>;\n\n/**\n * Input options type (what users provide to init()).\n * All fields with defaults are optional.\n */\nexport type CodeCallPluginOptionsInput = z.input<typeof codeCallPluginOptionsObjectSchema>;\n\n/**\n * Per-tool metadata used by CodeCall.\n * This maps to `metadata.codecall` on tools.\n */\nexport interface CodeCallToolMetadata {\n /**\n * If true, this tool stays visible in `list_tools`\n * even when CodeCall is hiding most tools.\n */\n visibleInListTools?: boolean;\n\n /**\n * Whether this tool can be used via CodeCall.\n * Semantics depend on CodeCallMode (see README).\n */\n enabledInCodeCall?: boolean;\n\n /** Optional extra indexing hints */\n appId?: string;\n source?: string;\n tags?: string[];\n}\n\n// ----- meta-tool contracts -----\n\nexport type CodeCallSearchInput = {\n query: string;\n topK?: number;\n filter?: {\n appIds?: string[];\n tags?: string[];\n includeOpenApi?: boolean;\n includeInline?: boolean;\n };\n};\n\nexport type CodeCallSearchResult = {\n tools: {\n name: string;\n description: string;\n appId?: string;\n source?: string;\n score: number;\n }[];\n};\n\nexport type CodeCallDescribeInput = {\n tools: string[];\n max?: number;\n};\n\nexport type CodeCallDescribeResult = {\n tools: {\n name: string;\n description: string;\n inputSchema: unknown;\n outputSchema?: unknown | null;\n examples?: {\n input: unknown;\n output?: unknown;\n }[];\n }[];\n};\n\nexport type CodeCallExecuteInput = {\n script: string;\n /**\n * Arbitrary, readonly context exposed as `codecallContext`.\n */\n context?: Record<string, unknown>;\n};\n\n// ---- global FrontMCP metadata extension ----\n\ndeclare global {\n interface ExtendFrontMcpToolMetadata {\n /**\n * CodeCall-specific metadata, attached via `@Tool({ metadata: { codecall: ... } })`\n * or whatever your decorator mapping is.\n */\n codecall?: CodeCallToolMetadata;\n }\n}\n"]}
|