@execbox/core 0.5.0 → 0.7.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/README.md +34 -15
- package/dist/{errors-DlbJQYs7.d.ts → errors-BIWv-QIC.d.ts} +2 -2
- package/dist/{errors-DlbJQYs7.d.ts.map → errors-BIWv-QIC.d.ts.map} +1 -1
- package/dist/{errors-wS8yjQhS.js → errors-DdWVEGU8.js} +1 -1
- package/dist/{errors-wS8yjQhS.js.map → errors-DdWVEGU8.js.map} +1 -1
- package/dist/{errors-B9ADBuDH.d.cts → errors-y4C-EIWT.d.cts} +2 -2
- package/dist/{errors-B9ADBuDH.d.cts.map → errors-y4C-EIWT.d.cts.map} +1 -1
- package/dist/{executor-B7q7K_27.d.ts → executor-BOTd9xNK.d.ts} +2 -2
- package/dist/{executor-B7q7K_27.d.ts.map → executor-BOTd9xNK.d.ts.map} +1 -1
- package/dist/{executor-BsE5nF-j.d.cts → executor-CtbrvTQ_.d.cts} +2 -2
- package/dist/{executor-BsE5nF-j.d.cts.map → executor-CtbrvTQ_.d.cts.map} +1 -1
- package/dist/index.cjs +2 -10
- package/dist/index.d.cts +4 -38
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +4 -38
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/mcp/index.cjs +101 -34
- package/dist/mcp/index.cjs.map +1 -1
- package/dist/mcp/index.d.cts +24 -4
- package/dist/mcp/index.d.cts.map +1 -1
- package/dist/mcp/index.d.ts +24 -4
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +102 -35
- package/dist/mcp/index.js.map +1 -1
- package/dist/protocol/index.cjs +7 -3
- package/dist/protocol/index.cjs.map +1 -1
- package/dist/protocol/index.d.cts +4 -4
- package/dist/protocol/index.d.cts.map +1 -1
- package/dist/protocol/index.d.ts +4 -4
- package/dist/protocol/index.d.ts.map +1 -1
- package/dist/protocol/index.js +8 -4
- package/dist/protocol/index.js.map +1 -1
- package/dist/{resolveProvider-UqQxdF4j.js → resolveProvider-CMrXPuTx.js} +14 -3
- package/dist/resolveProvider-CMrXPuTx.js.map +1 -0
- package/dist/{resolveProvider-BZYSw8Qk.cjs → resolveProvider-DFAg6No5.cjs} +12 -43
- package/dist/resolveProvider-DFAg6No5.cjs.map +1 -0
- package/dist/{runner-CsrfDub-.cjs → runner-BEY9nWc7.cjs} +2 -1
- package/dist/runner-BEY9nWc7.cjs.map +1 -0
- package/dist/{runner-6GMM-5ur.js → runner-BWAVLBi6.js} +3 -2
- package/dist/runner-BWAVLBi6.js.map +1 -0
- package/dist/{runner-ClFrFnz9.d.ts → runner-Cy18Z0u0.d.cts} +26 -2
- package/dist/runner-Cy18Z0u0.d.cts.map +1 -0
- package/dist/{runner-DSgvu6Ad.d.cts → runner-DXLu0eJV.d.ts} +26 -2
- package/dist/runner-DXLu0eJV.d.ts.map +1 -0
- package/dist/runtime.cjs +2 -2
- package/dist/runtime.d.cts +4 -4
- package/dist/runtime.d.ts +4 -4
- package/dist/runtime.js +2 -2
- package/package.json +1 -1
- package/dist/resolveProvider-BZYSw8Qk.cjs.map +0 -1
- package/dist/resolveProvider-UqQxdF4j.js.map +0 -1
- package/dist/runner-6GMM-5ur.js.map +0 -1
- package/dist/runner-ClFrFnz9.d.ts.map +0 -1
- package/dist/runner-CsrfDub-.cjs.map +0 -1
- package/dist/runner-DSgvu6Ad.d.cts.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as isExecuteFailure, r as isJsonSerializable, t as ExecuteFailure } from "./errors-
|
|
1
|
+
import { n as isExecuteFailure, r as isJsonSerializable, t as ExecuteFailure } from "./errors-DdWVEGU8.js";
|
|
2
2
|
import Ajv from "ajv";
|
|
3
3
|
import * as zod from "zod";
|
|
4
4
|
|
|
@@ -213,6 +213,16 @@ const DEFAULT_PROVIDER_NAME = "codemode";
|
|
|
213
213
|
function assertValidNamespace(name) {
|
|
214
214
|
assertValidIdentifier(name, "provider namespace");
|
|
215
215
|
}
|
|
216
|
+
function cloneToolAnnotations(annotations) {
|
|
217
|
+
if (!annotations) return;
|
|
218
|
+
const clone = {};
|
|
219
|
+
if (annotations.title !== void 0) clone.title = annotations.title;
|
|
220
|
+
if (annotations.readOnlyHint !== void 0) clone.readOnlyHint = annotations.readOnlyHint;
|
|
221
|
+
if (annotations.destructiveHint !== void 0) clone.destructiveHint = annotations.destructiveHint;
|
|
222
|
+
if (annotations.idempotentHint !== void 0) clone.idempotentHint = annotations.idempotentHint;
|
|
223
|
+
if (annotations.openWorldHint !== void 0) clone.openWorldHint = annotations.openWorldHint;
|
|
224
|
+
return Object.keys(clone).length === 0 ? void 0 : clone;
|
|
225
|
+
}
|
|
216
226
|
function compileValidator(ajv, schema) {
|
|
217
227
|
return schema ? ajv.compile(schema) : void 0;
|
|
218
228
|
}
|
|
@@ -250,6 +260,7 @@ function resolveProvider(provider) {
|
|
|
250
260
|
const inputValidator = compileValidator(ajv, inputSchema);
|
|
251
261
|
const outputValidator = compileValidator(ajv, outputSchema);
|
|
252
262
|
resolvedTools[safeName] = {
|
|
263
|
+
annotations: cloneToolAnnotations(descriptor.annotations),
|
|
253
264
|
description: descriptor.description,
|
|
254
265
|
execute: async (input, context) => {
|
|
255
266
|
if (inputValidator && !inputValidator(input)) throw new ExecuteFailure("validation_error", formatValidationMessage(ajv, "input", originalName, inputValidator));
|
|
@@ -284,5 +295,5 @@ function resolveProvider(provider) {
|
|
|
284
295
|
}
|
|
285
296
|
|
|
286
297
|
//#endregion
|
|
287
|
-
export { renderNamespaceDeclaration as
|
|
288
|
-
//# sourceMappingURL=resolveProvider-
|
|
298
|
+
export { renderNamespaceDeclaration as i, schemaToType as n, renderDocComment as r, resolveProvider as t };
|
|
299
|
+
//# sourceMappingURL=resolveProvider-CMrXPuTx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveProvider-CMrXPuTx.js","names":["isRecord","lines: string[]","clone: ToolAnnotations","originalToSafeName: Record<string, string>","safeToOriginalName: Record<string, string>","resolvedTools: Record<string, ResolvedToolDescriptor>","typegenTools: Record<string, TypegenToolDescriptor>"],"sources":["../src/identifier.ts","../src/sanitize.ts","../src/schema/normalizeSchema.ts","../src/typegen/render.ts","../src/typegen/jsonSchema.ts","../src/provider/resolveProvider.ts"],"sourcesContent":["const RESERVED_WORDS = new Set([\n \"await\",\n \"break\",\n \"case\",\n \"catch\",\n \"class\",\n \"const\",\n \"continue\",\n \"debugger\",\n \"default\",\n \"delete\",\n \"do\",\n \"else\",\n \"enum\",\n \"export\",\n \"extends\",\n \"false\",\n \"finally\",\n \"for\",\n \"function\",\n \"if\",\n \"import\",\n \"in\",\n \"instanceof\",\n \"new\",\n \"null\",\n \"return\",\n \"super\",\n \"switch\",\n \"this\",\n \"throw\",\n \"true\",\n \"try\",\n \"typeof\",\n \"var\",\n \"void\",\n \"while\",\n \"with\",\n \"yield\",\n]);\n\nconst UNDERSCORE_CHAR_CODE = 95;\n\nfunction trimEdgeUnderscores(value: string): string {\n let start = 0;\n let end = value.length;\n\n while (start < end && value.charCodeAt(start) === UNDERSCORE_CHAR_CODE) {\n start += 1;\n }\n\n while (end > start && value.charCodeAt(end - 1) === UNDERSCORE_CHAR_CODE) {\n end -= 1;\n }\n\n return value.slice(start, end);\n}\n\n/**\n * Returns whether the value is a valid JavaScript identifier.\n */\nexport function isValidIdentifier(value: string): boolean {\n return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(value);\n}\n\n/**\n * Returns whether the identifier is reserved in JavaScript source.\n */\nexport function isReservedWord(value: string): boolean {\n return RESERVED_WORDS.has(value);\n}\n\n/**\n * Throws when the value cannot be used as a bare JavaScript identifier.\n */\nexport function assertValidIdentifier(\n value: string,\n label = \"identifier\",\n): void {\n if (!isValidIdentifier(value) || isReservedWord(value)) {\n throw new Error(`Invalid ${label}: ${value}`);\n }\n}\n\n/**\n * Converts a raw identifier-like value into a safe JavaScript identifier.\n */\nexport function sanitizeIdentifier(value: string): string {\n const sanitized = value.trim().replace(/[^A-Za-z0-9_$]+/g, \"_\");\n\n const trimmed = trimEdgeUnderscores(sanitized);\n\n let safeName = trimmed.length > 0 ? trimmed : \"_\";\n\n if (/^[0-9]/.test(safeName)) {\n safeName = `_${safeName}`;\n }\n\n if (isReservedWord(safeName)) {\n safeName = `${safeName}_`;\n }\n\n return safeName;\n}\n\n/**\n * Renders the name as a bare identifier when possible, otherwise as a string literal.\n */\nexport function serializePropertyName(name: string): string {\n return isValidIdentifier(name) ? name : JSON.stringify(name);\n}\n","import { sanitizeIdentifier } from \"./identifier\";\n\n/**\n * Converts a raw tool name into a safe JavaScript identifier.\n */\nexport function sanitizeToolName(name: string): string {\n return sanitizeIdentifier(name);\n}\n","import * as zod from \"zod\";\nimport type { ZodRawShape, ZodTypeAny } from \"zod\";\n\nimport type { JsonSchema, ToolSchema } from \"../types\";\n\nconst z = \"z\" in zod && typeof zod.z === \"object\" ? zod.z : zod;\nconst toJsonSchema =\n (\"toJSONSchema\" in zod ? zod.toJSONSchema : undefined) ??\n (\"toJSONSchema\" in z ? z.toJSONSchema : undefined);\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n\nfunction isZodSchema(value: unknown): value is ZodTypeAny {\n return isRecord(value) && typeof value.safeParse === \"function\";\n}\n\nfunction isZodRawShape(value: unknown): value is ZodRawShape {\n return (\n isRecord(value) &&\n Object.keys(value).length > 0 &&\n Object.values(value).every(isZodSchema)\n );\n}\n\nfunction normalizeZodSchema(schema: ZodTypeAny): JsonSchema {\n if (typeof toJsonSchema !== \"function\") {\n throw new Error(\"Installed zod package does not expose toJSONSchema\");\n }\n\n const jsonSchema = toJsonSchema(schema) as JsonSchema & {\n $schema?: string;\n };\n\n if (\"$schema\" in jsonSchema) {\n const { $schema: _ignored, ...rest } = jsonSchema;\n return rest;\n }\n\n return jsonSchema;\n}\n\n/**\n * Normalizes supported tool schema inputs to the JSON Schema form used internally.\n */\nexport function normalizeToolSchema(\n schema: ToolSchema | undefined,\n phase: \"input\" | \"output\",\n toolName: string,\n): JsonSchema | undefined {\n if (schema === undefined) {\n return undefined;\n }\n\n if (isZodSchema(schema)) {\n return normalizeZodSchema(schema);\n }\n\n if (isZodRawShape(schema)) {\n return normalizeZodSchema(z.object(schema));\n }\n\n if (isRecord(schema)) {\n return schema;\n }\n\n throw new Error(\n `Unsupported ${phase} schema for tool ${toolName}. Expected JSON Schema, a Zod schema, or an MCP-style Zod shape.`,\n );\n}\n","/**\n * Indents each line of the given string by a specified number of levels.\n */\nexport function indent(value: string, level = 1): string {\n return value\n .split(\"\\n\")\n .map((line) => `${\" \".repeat(level)}${line}`)\n .join(\"\\n\");\n}\n\n/**\n * Renders a short TSDoc-style block when documentation is available.\n */\nexport function renderDocComment(lines: string[]): string {\n if (lines.length === 0) {\n return \"\";\n }\n\n return [\"/**\", ...lines.map((line) => ` * ${line}`), \" */\"].join(\"\\n\");\n}\n\n/**\n * Renders a namespace declaration with optional members.\n */\nexport function renderNamespaceDeclaration(\n name: string,\n members: string[],\n): string {\n if (members.length === 0) {\n return `declare namespace ${name} {}`;\n }\n\n return `declare namespace ${name} {\\n${indent(members.join(\"\\n\\n\"))}\\n}`;\n}\n","import { isValidIdentifier, serializePropertyName } from \"../identifier\";\nimport type { JsonSchema, TypegenToolDescriptor } from \"../types\";\nimport { indent, renderDocComment, renderNamespaceDeclaration } from \"./render\";\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n\nexport { indent } from \"./render\";\n\n/**\n * Converts a supported JSON Schema fragment into a TypeScript type expression.\n */\nexport function schemaToType(\n schema: JsonSchema | undefined,\n level = 0,\n): string {\n if (!schema) {\n return \"unknown\";\n }\n\n if (\n \"allOf\" in schema ||\n \"anyOf\" in schema ||\n \"oneOf\" in schema ||\n \"$ref\" in schema ||\n Array.isArray(schema.type)\n ) {\n return \"unknown\";\n }\n\n switch (schema.type) {\n case \"string\":\n return \"string\";\n case \"number\":\n case \"integer\":\n return \"number\";\n case \"boolean\":\n return \"boolean\";\n case \"null\":\n return \"null\";\n case \"array\": {\n const itemType = schemaToType(\n isRecord(schema.items) ? (schema.items as JsonSchema) : undefined,\n level + 1,\n );\n\n if (isValidIdentifier(itemType)) {\n return `${itemType}[]`;\n }\n\n return `Array<${itemType}>`;\n }\n case \"object\": {\n const properties = isRecord(schema.properties) ? schema.properties : {};\n const required = new Set(\n Array.isArray(schema.required)\n ? schema.required.filter(\n (value): value is string => typeof value === \"string\",\n )\n : [],\n );\n const entries = Object.entries(properties);\n\n if (entries.length === 0) {\n return \"Record<string, unknown>\";\n }\n\n const lines = entries.map(([name, propertySchema]) => {\n const propertyType = schemaToType(\n isRecord(propertySchema) ? (propertySchema as JsonSchema) : undefined,\n level + 1,\n );\n const optionalToken = required.has(name) ? \"\" : \"?\";\n return `${serializePropertyName(name)}${optionalToken}: ${propertyType};`;\n });\n\n return `{\\n${indent(lines.join(\"\\n\"), level + 1)}\\n${\" \".repeat(level)}}`;\n }\n default:\n return \"unknown\";\n }\n}\n\nfunction formatToolDeclaration(\n name: string,\n tool: TypegenToolDescriptor,\n): string {\n const lines: string[] = [];\n const comment = tool.description ? renderDocComment([tool.description]) : \"\";\n if (comment) {\n lines.push(comment);\n }\n\n const inputType = schemaToType(tool.inputSchema);\n const outputType = schemaToType(tool.outputSchema);\n lines.push(`function ${name}(input: ${inputType}): Promise<${outputType}>;`);\n\n return lines.join(\"\\n\");\n}\n\n/**\n * Generates a namespace declaration for a provider's tool schemas.\n */\nexport function generateTypesFromJsonSchema(\n providerName: string,\n tools: Record<string, TypegenToolDescriptor>,\n): string {\n return renderNamespaceDeclaration(\n providerName,\n Object.entries(tools).map(([name, tool]) =>\n formatToolDeclaration(name, tool),\n ),\n );\n}\n","import Ajv from \"ajv\";\n\nimport {\n ExecuteFailure,\n isExecuteFailure,\n isJsonSerializable,\n} from \"../errors\";\nimport { assertValidIdentifier } from \"../identifier\";\nimport { sanitizeToolName } from \"../sanitize\";\nimport { normalizeToolSchema } from \"../schema/normalizeSchema\";\nimport { generateTypesFromJsonSchema } from \"../typegen/jsonSchema\";\nimport type {\n JsonSchema,\n ResolvedToolDescriptor,\n ResolvedToolProvider,\n ToolAnnotations,\n ToolExecutionContext,\n ToolProvider,\n TypegenToolDescriptor,\n} from \"../types\";\n\nconst DEFAULT_PROVIDER_NAME = \"codemode\";\ntype AjvInstance = InstanceType<typeof Ajv>;\ntype AjvValidateFunction = ReturnType<AjvInstance[\"compile\"]>;\n\nfunction assertValidNamespace(name: string): void {\n assertValidIdentifier(name, \"provider namespace\");\n}\n\nfunction cloneToolAnnotations(\n annotations: ToolAnnotations | undefined,\n): ToolAnnotations | undefined {\n if (!annotations) {\n return undefined;\n }\n\n const clone: ToolAnnotations = {};\n\n if (annotations.title !== undefined) {\n clone.title = annotations.title;\n }\n\n if (annotations.readOnlyHint !== undefined) {\n clone.readOnlyHint = annotations.readOnlyHint;\n }\n\n if (annotations.destructiveHint !== undefined) {\n clone.destructiveHint = annotations.destructiveHint;\n }\n\n if (annotations.idempotentHint !== undefined) {\n clone.idempotentHint = annotations.idempotentHint;\n }\n\n if (annotations.openWorldHint !== undefined) {\n clone.openWorldHint = annotations.openWorldHint;\n }\n\n return Object.keys(clone).length === 0 ? undefined : clone;\n}\n\nfunction compileValidator(\n ajv: AjvInstance,\n schema: JsonSchema | undefined,\n): AjvValidateFunction | undefined {\n return schema ? ajv.compile(schema as object) : undefined;\n}\n\nfunction formatValidationMessage(\n ajv: AjvInstance,\n phase: \"input\" | \"output\",\n toolName: string,\n validator: AjvValidateFunction,\n): string {\n return `Invalid ${phase} for tool ${toolName}: ${ajv.errorsText(validator.errors)}`;\n}\n\n/**\n * Resolves a tool provider into the validated, sanitized shape consumed by executors.\n */\nexport function resolveProvider(provider: ToolProvider): ResolvedToolProvider {\n const name = provider.name ?? DEFAULT_PROVIDER_NAME;\n assertValidNamespace(name);\n\n // Keep provider schemas permissive for generated schemas and extension keywords.\n const ajv = new Ajv({\n allErrors: true,\n strict: false,\n });\n\n const originalToSafeName: Record<string, string> = {};\n const safeToOriginalName: Record<string, string> = {};\n const usedSafeNames = new Set<string>();\n const resolvedTools: Record<string, ResolvedToolDescriptor> = {};\n const typegenTools: Record<string, TypegenToolDescriptor> = {};\n\n for (const [originalName, descriptor] of Object.entries(provider.tools)) {\n const baseSafeName = sanitizeToolName(originalName);\n let safeName = baseSafeName;\n let suffix = 2;\n\n while (usedSafeNames.has(safeName)) {\n safeName = `${baseSafeName}__${suffix}`;\n suffix += 1;\n }\n\n usedSafeNames.add(safeName);\n originalToSafeName[originalName] = safeName;\n safeToOriginalName[safeName] = originalName;\n\n const inputSchema = normalizeToolSchema(\n descriptor.inputSchema,\n \"input\",\n originalName,\n );\n const outputSchema = normalizeToolSchema(\n descriptor.outputSchema,\n \"output\",\n originalName,\n );\n const inputValidator = compileValidator(ajv, inputSchema);\n const outputValidator = compileValidator(ajv, outputSchema);\n\n resolvedTools[safeName] = {\n annotations: cloneToolAnnotations(descriptor.annotations),\n description: descriptor.description,\n execute: async (\n input: unknown,\n context: ToolExecutionContext,\n ): Promise<unknown> => {\n if (inputValidator && !inputValidator(input)) {\n throw new ExecuteFailure(\n \"validation_error\",\n formatValidationMessage(ajv, \"input\", originalName, inputValidator),\n );\n }\n\n try {\n const result = await descriptor.execute(input, context);\n\n if (!isJsonSerializable(result)) {\n throw new ExecuteFailure(\n \"serialization_error\",\n `Tool ${originalName} returned a non-serializable value`,\n );\n }\n\n if (outputValidator && !outputValidator(result)) {\n throw new ExecuteFailure(\n \"validation_error\",\n formatValidationMessage(\n ajv,\n \"output\",\n originalName,\n outputValidator,\n ),\n );\n }\n\n return result;\n } catch (error) {\n if (isExecuteFailure(error)) {\n throw error;\n }\n\n throw new ExecuteFailure(\n \"tool_error\",\n error instanceof Error\n ? error.message\n : `Tool ${originalName} failed`,\n );\n }\n },\n inputSchema,\n originalName,\n outputSchema,\n safeName,\n };\n\n typegenTools[safeName] = {\n description: descriptor.description,\n inputSchema,\n outputSchema,\n };\n }\n\n return {\n name,\n originalToSafeName,\n safeToOriginalName,\n tools: resolvedTools,\n types: provider.types ?? generateTypesFromJsonSchema(name, typegenTools),\n };\n}\n"],"mappings":";;;;;AAAA,MAAM,iBAAiB,IAAI,IAAI;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAEF,MAAM,uBAAuB;AAE7B,SAAS,oBAAoB,OAAuB;CAClD,IAAI,QAAQ;CACZ,IAAI,MAAM,MAAM;AAEhB,QAAO,QAAQ,OAAO,MAAM,WAAW,MAAM,KAAK,qBAChD,UAAS;AAGX,QAAO,MAAM,SAAS,MAAM,WAAW,MAAM,EAAE,KAAK,qBAClD,QAAO;AAGT,QAAO,MAAM,MAAM,OAAO,IAAI;;;;;AAMhC,SAAgB,kBAAkB,OAAwB;AACxD,QAAO,6BAA6B,KAAK,MAAM;;;;;AAMjD,SAAgB,eAAe,OAAwB;AACrD,QAAO,eAAe,IAAI,MAAM;;;;;AAMlC,SAAgB,sBACd,OACA,QAAQ,cACF;AACN,KAAI,CAAC,kBAAkB,MAAM,IAAI,eAAe,MAAM,CACpD,OAAM,IAAI,MAAM,WAAW,MAAM,IAAI,QAAQ;;;;;AAOjD,SAAgB,mBAAmB,OAAuB;CAGxD,MAAM,UAAU,oBAFE,MAAM,MAAM,CAAC,QAAQ,oBAAoB,IAAI,CAEjB;CAE9C,IAAI,WAAW,QAAQ,SAAS,IAAI,UAAU;AAE9C,KAAI,SAAS,KAAK,SAAS,CACzB,YAAW,IAAI;AAGjB,KAAI,eAAe,SAAS,CAC1B,YAAW,GAAG,SAAS;AAGzB,QAAO;;;;;AAMT,SAAgB,sBAAsB,MAAsB;AAC1D,Q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I,eACR,oBACA,wBACE,KACA,UACA,cACA,gBACD,CACF;AAGH,YAAO;aACA,OAAO;AACd,SAAI,iBAAiB,MAAM,CACzB,OAAM;AAGR,WAAM,IAAI,eACR,cACA,iBAAiB,QACb,MAAM,UACN,QAAQ,aAAa,SAC1B;;;GAGL;GACA;GACA;GACA;GACD;AAED,eAAa,YAAY;GACvB,aAAa,WAAW;GACxB;GACA;GACD;;AAGH,QAAO;EACL;EACA;EACA;EACA,OAAO;EACP,OAAO,SAAS,SAAS,4BAA4B,MAAM,aAAa;EACzE"}
|
|
@@ -242,6 +242,16 @@ const DEFAULT_PROVIDER_NAME = "codemode";
|
|
|
242
242
|
function assertValidNamespace(name) {
|
|
243
243
|
assertValidIdentifier(name, "provider namespace");
|
|
244
244
|
}
|
|
245
|
+
function cloneToolAnnotations(annotations) {
|
|
246
|
+
if (!annotations) return;
|
|
247
|
+
const clone = {};
|
|
248
|
+
if (annotations.title !== void 0) clone.title = annotations.title;
|
|
249
|
+
if (annotations.readOnlyHint !== void 0) clone.readOnlyHint = annotations.readOnlyHint;
|
|
250
|
+
if (annotations.destructiveHint !== void 0) clone.destructiveHint = annotations.destructiveHint;
|
|
251
|
+
if (annotations.idempotentHint !== void 0) clone.idempotentHint = annotations.idempotentHint;
|
|
252
|
+
if (annotations.openWorldHint !== void 0) clone.openWorldHint = annotations.openWorldHint;
|
|
253
|
+
return Object.keys(clone).length === 0 ? void 0 : clone;
|
|
254
|
+
}
|
|
245
255
|
function compileValidator(ajv$1, schema) {
|
|
246
256
|
return schema ? ajv$1.compile(schema) : void 0;
|
|
247
257
|
}
|
|
@@ -279,6 +289,7 @@ function resolveProvider(provider) {
|
|
|
279
289
|
const inputValidator = compileValidator(ajv$1, inputSchema);
|
|
280
290
|
const outputValidator = compileValidator(ajv$1, outputSchema);
|
|
281
291
|
resolvedTools[safeName] = {
|
|
292
|
+
annotations: cloneToolAnnotations(descriptor.annotations),
|
|
282
293
|
description: descriptor.description,
|
|
283
294
|
execute: async (input, context) => {
|
|
284
295
|
if (inputValidator && !inputValidator(input)) throw new require_errors.ExecuteFailure("validation_error", formatValidationMessage(ajv$1, "input", originalName, inputValidator));
|
|
@@ -319,30 +330,6 @@ Object.defineProperty(exports, '__toESM', {
|
|
|
319
330
|
return __toESM;
|
|
320
331
|
}
|
|
321
332
|
});
|
|
322
|
-
Object.defineProperty(exports, 'assertValidIdentifier', {
|
|
323
|
-
enumerable: true,
|
|
324
|
-
get: function () {
|
|
325
|
-
return assertValidIdentifier;
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
Object.defineProperty(exports, 'generateTypesFromJsonSchema', {
|
|
329
|
-
enumerable: true,
|
|
330
|
-
get: function () {
|
|
331
|
-
return generateTypesFromJsonSchema;
|
|
332
|
-
}
|
|
333
|
-
});
|
|
334
|
-
Object.defineProperty(exports, 'isReservedWord', {
|
|
335
|
-
enumerable: true,
|
|
336
|
-
get: function () {
|
|
337
|
-
return isReservedWord;
|
|
338
|
-
}
|
|
339
|
-
});
|
|
340
|
-
Object.defineProperty(exports, 'isValidIdentifier', {
|
|
341
|
-
enumerable: true,
|
|
342
|
-
get: function () {
|
|
343
|
-
return isValidIdentifier;
|
|
344
|
-
}
|
|
345
|
-
});
|
|
346
333
|
Object.defineProperty(exports, 'renderDocComment', {
|
|
347
334
|
enumerable: true,
|
|
348
335
|
get: function () {
|
|
@@ -361,28 +348,10 @@ Object.defineProperty(exports, 'resolveProvider', {
|
|
|
361
348
|
return resolveProvider;
|
|
362
349
|
}
|
|
363
350
|
});
|
|
364
|
-
Object.defineProperty(exports, 'sanitizeIdentifier', {
|
|
365
|
-
enumerable: true,
|
|
366
|
-
get: function () {
|
|
367
|
-
return sanitizeIdentifier;
|
|
368
|
-
}
|
|
369
|
-
});
|
|
370
|
-
Object.defineProperty(exports, 'sanitizeToolName', {
|
|
371
|
-
enumerable: true,
|
|
372
|
-
get: function () {
|
|
373
|
-
return sanitizeToolName;
|
|
374
|
-
}
|
|
375
|
-
});
|
|
376
351
|
Object.defineProperty(exports, 'schemaToType', {
|
|
377
352
|
enumerable: true,
|
|
378
353
|
get: function () {
|
|
379
354
|
return schemaToType;
|
|
380
355
|
}
|
|
381
356
|
});
|
|
382
|
-
|
|
383
|
-
enumerable: true,
|
|
384
|
-
get: function () {
|
|
385
|
-
return serializePropertyName;
|
|
386
|
-
}
|
|
387
|
-
});
|
|
388
|
-
//# sourceMappingURL=resolveProvider-BZYSw8Qk.cjs.map
|
|
357
|
+
//# sourceMappingURL=resolveProvider-DFAg6No5.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveProvider-DFAg6No5.cjs","names":["isRecord","lines: string[]","clone: ToolAnnotations","ajv","Ajv","originalToSafeName: Record<string, string>","safeToOriginalName: Record<string, string>","resolvedTools: Record<string, ResolvedToolDescriptor>","typegenTools: Record<string, TypegenToolDescriptor>","ExecuteFailure","isJsonSerializable","isExecuteFailure"],"sources":["../src/identifier.ts","../src/sanitize.ts","../src/schema/normalizeSchema.ts","../src/typegen/render.ts","../src/typegen/jsonSchema.ts","../src/provider/resolveProvider.ts"],"sourcesContent":["const RESERVED_WORDS = new Set([\n \"await\",\n \"break\",\n \"case\",\n \"catch\",\n \"class\",\n \"const\",\n \"continue\",\n \"debugger\",\n \"default\",\n \"delete\",\n \"do\",\n \"else\",\n \"enum\",\n \"export\",\n \"extends\",\n \"false\",\n \"finally\",\n \"for\",\n \"function\",\n \"if\",\n \"import\",\n \"in\",\n \"instanceof\",\n \"new\",\n \"null\",\n \"return\",\n \"super\",\n \"switch\",\n \"this\",\n \"throw\",\n \"true\",\n \"try\",\n \"typeof\",\n \"var\",\n \"void\",\n \"while\",\n \"with\",\n \"yield\",\n]);\n\nconst UNDERSCORE_CHAR_CODE = 95;\n\nfunction trimEdgeUnderscores(value: string): string {\n let start = 0;\n let end = value.length;\n\n while (start < end && value.charCodeAt(start) === UNDERSCORE_CHAR_CODE) {\n start += 1;\n }\n\n while (end > start && value.charCodeAt(end - 1) === UNDERSCORE_CHAR_CODE) {\n end -= 1;\n }\n\n return value.slice(start, end);\n}\n\n/**\n * Returns whether the value is a valid JavaScript identifier.\n */\nexport function isValidIdentifier(value: string): boolean {\n return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(value);\n}\n\n/**\n * Returns whether the identifier is reserved in JavaScript source.\n */\nexport function isReservedWord(value: string): boolean {\n return RESERVED_WORDS.has(value);\n}\n\n/**\n * Throws when the value cannot be used as a bare JavaScript identifier.\n */\nexport function assertValidIdentifier(\n value: string,\n label = \"identifier\",\n): void {\n if (!isValidIdentifier(value) || isReservedWord(value)) {\n throw new Error(`Invalid ${label}: ${value}`);\n }\n}\n\n/**\n * Converts a raw identifier-like value into a safe JavaScript identifier.\n */\nexport function sanitizeIdentifier(value: string): string {\n const sanitized = value.trim().replace(/[^A-Za-z0-9_$]+/g, \"_\");\n\n const trimmed = trimEdgeUnderscores(sanitized);\n\n let safeName = trimmed.length > 0 ? trimmed : \"_\";\n\n if (/^[0-9]/.test(safeName)) {\n safeName = `_${safeName}`;\n }\n\n if (isReservedWord(safeName)) {\n safeName = `${safeName}_`;\n }\n\n return safeName;\n}\n\n/**\n * Renders the name as a bare identifier when possible, otherwise as a string literal.\n */\nexport function serializePropertyName(name: string): string {\n return isValidIdentifier(name) ? name : JSON.stringify(name);\n}\n","import { sanitizeIdentifier } from \"./identifier\";\n\n/**\n * Converts a raw tool name into a safe JavaScript identifier.\n */\nexport function sanitizeToolName(name: string): string {\n return sanitizeIdentifier(name);\n}\n","import * as zod from \"zod\";\nimport type { ZodRawShape, ZodTypeAny } from \"zod\";\n\nimport type { JsonSchema, ToolSchema } from \"../types\";\n\nconst z = \"z\" in zod && typeof zod.z === \"object\" ? zod.z : zod;\nconst toJsonSchema =\n (\"toJSONSchema\" in zod ? zod.toJSONSchema : undefined) ??\n (\"toJSONSchema\" in z ? z.toJSONSchema : undefined);\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n\nfunction isZodSchema(value: unknown): value is ZodTypeAny {\n return isRecord(value) && typeof value.safeParse === \"function\";\n}\n\nfunction isZodRawShape(value: unknown): value is ZodRawShape {\n return (\n isRecord(value) &&\n Object.keys(value).length > 0 &&\n Object.values(value).every(isZodSchema)\n );\n}\n\nfunction normalizeZodSchema(schema: ZodTypeAny): JsonSchema {\n if (typeof toJsonSchema !== \"function\") {\n throw new Error(\"Installed zod package does not expose toJSONSchema\");\n }\n\n const jsonSchema = toJsonSchema(schema) as JsonSchema & {\n $schema?: string;\n };\n\n if (\"$schema\" in jsonSchema) {\n const { $schema: _ignored, ...rest } = jsonSchema;\n return rest;\n }\n\n return jsonSchema;\n}\n\n/**\n * Normalizes supported tool schema inputs to the JSON Schema form used internally.\n */\nexport function normalizeToolSchema(\n schema: ToolSchema | undefined,\n phase: \"input\" | \"output\",\n toolName: string,\n): JsonSchema | undefined {\n if (schema === undefined) {\n return undefined;\n }\n\n if (isZodSchema(schema)) {\n return normalizeZodSchema(schema);\n }\n\n if (isZodRawShape(schema)) {\n return normalizeZodSchema(z.object(schema));\n }\n\n if (isRecord(schema)) {\n return schema;\n }\n\n throw new Error(\n `Unsupported ${phase} schema for tool ${toolName}. Expected JSON Schema, a Zod schema, or an MCP-style Zod shape.`,\n );\n}\n","/**\n * Indents each line of the given string by a specified number of levels.\n */\nexport function indent(value: string, level = 1): string {\n return value\n .split(\"\\n\")\n .map((line) => `${\" \".repeat(level)}${line}`)\n .join(\"\\n\");\n}\n\n/**\n * Renders a short TSDoc-style block when documentation is available.\n */\nexport function renderDocComment(lines: string[]): string {\n if (lines.length === 0) {\n return \"\";\n }\n\n return [\"/**\", ...lines.map((line) => ` * ${line}`), \" */\"].join(\"\\n\");\n}\n\n/**\n * Renders a namespace declaration with optional members.\n */\nexport function renderNamespaceDeclaration(\n name: string,\n members: string[],\n): string {\n if (members.length === 0) {\n return `declare namespace ${name} {}`;\n }\n\n return `declare namespace ${name} {\\n${indent(members.join(\"\\n\\n\"))}\\n}`;\n}\n","import { isValidIdentifier, serializePropertyName } from \"../identifier\";\nimport type { JsonSchema, TypegenToolDescriptor } from \"../types\";\nimport { indent, renderDocComment, renderNamespaceDeclaration } from \"./render\";\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n\nexport { indent } from \"./render\";\n\n/**\n * Converts a supported JSON Schema fragment into a TypeScript type expression.\n */\nexport function schemaToType(\n schema: JsonSchema | undefined,\n level = 0,\n): string {\n if (!schema) {\n return \"unknown\";\n }\n\n if (\n \"allOf\" in schema ||\n \"anyOf\" in schema ||\n \"oneOf\" in schema ||\n \"$ref\" in schema ||\n Array.isArray(schema.type)\n ) {\n return \"unknown\";\n }\n\n switch (schema.type) {\n case \"string\":\n return \"string\";\n case \"number\":\n case \"integer\":\n return \"number\";\n case \"boolean\":\n return \"boolean\";\n case \"null\":\n return \"null\";\n case \"array\": {\n const itemType = schemaToType(\n isRecord(schema.items) ? (schema.items as JsonSchema) : undefined,\n level + 1,\n );\n\n if (isValidIdentifier(itemType)) {\n return `${itemType}[]`;\n }\n\n return `Array<${itemType}>`;\n }\n case \"object\": {\n const properties = isRecord(schema.properties) ? schema.properties : {};\n const required = new Set(\n Array.isArray(schema.required)\n ? schema.required.filter(\n (value): value is string => typeof value === \"string\",\n )\n : [],\n );\n const entries = Object.entries(properties);\n\n if (entries.length === 0) {\n return \"Record<string, unknown>\";\n }\n\n const lines = entries.map(([name, propertySchema]) => {\n const propertyType = schemaToType(\n isRecord(propertySchema) ? (propertySchema as JsonSchema) : undefined,\n level + 1,\n );\n const optionalToken = required.has(name) ? \"\" : \"?\";\n return `${serializePropertyName(name)}${optionalToken}: ${propertyType};`;\n });\n\n return `{\\n${indent(lines.join(\"\\n\"), level + 1)}\\n${\" \".repeat(level)}}`;\n }\n default:\n return \"unknown\";\n }\n}\n\nfunction formatToolDeclaration(\n name: string,\n tool: TypegenToolDescriptor,\n): string {\n const lines: string[] = [];\n const comment = tool.description ? renderDocComment([tool.description]) : \"\";\n if (comment) {\n lines.push(comment);\n }\n\n const inputType = schemaToType(tool.inputSchema);\n const outputType = schemaToType(tool.outputSchema);\n lines.push(`function ${name}(input: ${inputType}): Promise<${outputType}>;`);\n\n return lines.join(\"\\n\");\n}\n\n/**\n * Generates a namespace declaration for a provider's tool schemas.\n */\nexport function generateTypesFromJsonSchema(\n providerName: string,\n tools: Record<string, TypegenToolDescriptor>,\n): string {\n return renderNamespaceDeclaration(\n providerName,\n Object.entries(tools).map(([name, tool]) =>\n formatToolDeclaration(name, tool),\n ),\n );\n}\n","import Ajv from \"ajv\";\n\nimport {\n ExecuteFailure,\n isExecuteFailure,\n isJsonSerializable,\n} from \"../errors\";\nimport { assertValidIdentifier } from \"../identifier\";\nimport { sanitizeToolName } from \"../sanitize\";\nimport { normalizeToolSchema } from \"../schema/normalizeSchema\";\nimport { generateTypesFromJsonSchema } from \"../typegen/jsonSchema\";\nimport type {\n JsonSchema,\n ResolvedToolDescriptor,\n ResolvedToolProvider,\n ToolAnnotations,\n ToolExecutionContext,\n ToolProvider,\n TypegenToolDescriptor,\n} from \"../types\";\n\nconst DEFAULT_PROVIDER_NAME = \"codemode\";\ntype AjvInstance = InstanceType<typeof Ajv>;\ntype AjvValidateFunction = ReturnType<AjvInstance[\"compile\"]>;\n\nfunction assertValidNamespace(name: string): void {\n assertValidIdentifier(name, \"provider namespace\");\n}\n\nfunction cloneToolAnnotations(\n annotations: ToolAnnotations | undefined,\n): ToolAnnotations | undefined {\n if (!annotations) {\n return undefined;\n }\n\n const clone: ToolAnnotations = {};\n\n if (annotations.title !== undefined) {\n clone.title = annotations.title;\n }\n\n if (annotations.readOnlyHint !== undefined) {\n clone.readOnlyHint = annotations.readOnlyHint;\n }\n\n if (annotations.destructiveHint !== undefined) {\n clone.destructiveHint = annotations.destructiveHint;\n }\n\n if (annotations.idempotentHint !== undefined) {\n clone.idempotentHint = annotations.idempotentHint;\n }\n\n if (annotations.openWorldHint !== undefined) {\n clone.openWorldHint = annotations.openWorldHint;\n }\n\n return Object.keys(clone).length === 0 ? undefined : clone;\n}\n\nfunction compileValidator(\n ajv: AjvInstance,\n schema: JsonSchema | undefined,\n): AjvValidateFunction | undefined {\n return schema ? ajv.compile(schema as object) : undefined;\n}\n\nfunction formatValidationMessage(\n ajv: AjvInstance,\n phase: \"input\" | \"output\",\n toolName: string,\n validator: AjvValidateFunction,\n): string {\n return `Invalid ${phase} for tool ${toolName}: ${ajv.errorsText(validator.errors)}`;\n}\n\n/**\n * Resolves a tool provider into the validated, sanitized shape consumed by executors.\n */\nexport function resolveProvider(provider: ToolProvider): ResolvedToolProvider {\n const name = provider.name ?? DEFAULT_PROVIDER_NAME;\n assertValidNamespace(name);\n\n // Keep provider schemas permissive for generated schemas and extension keywords.\n const ajv = new Ajv({\n allErrors: true,\n strict: false,\n });\n\n const originalToSafeName: Record<string, string> = {};\n const safeToOriginalName: Record<string, string> = {};\n const usedSafeNames = new Set<string>();\n const resolvedTools: Record<string, ResolvedToolDescriptor> = {};\n const typegenTools: Record<string, TypegenToolDescriptor> = {};\n\n for (const [originalName, descriptor] of Object.entries(provider.tools)) {\n const baseSafeName = sanitizeToolName(originalName);\n let safeName = baseSafeName;\n let suffix = 2;\n\n while (usedSafeNames.has(safeName)) {\n safeName = `${baseSafeName}__${suffix}`;\n suffix += 1;\n }\n\n usedSafeNames.add(safeName);\n originalToSafeName[originalName] = safeName;\n safeToOriginalName[safeName] = originalName;\n\n const inputSchema = normalizeToolSchema(\n descriptor.inputSchema,\n \"input\",\n originalName,\n );\n const outputSchema = normalizeToolSchema(\n descriptor.outputSchema,\n \"output\",\n originalName,\n );\n const inputValidator = compileValidator(ajv, inputSchema);\n const outputValidator = compileValidator(ajv, outputSchema);\n\n resolvedTools[safeName] = {\n annotations: cloneToolAnnotations(descriptor.annotations),\n description: descriptor.description,\n execute: async (\n input: unknown,\n context: ToolExecutionContext,\n ): Promise<unknown> => {\n if (inputValidator && !inputValidator(input)) {\n throw new ExecuteFailure(\n \"validation_error\",\n formatValidationMessage(ajv, \"input\", originalName, inputValidator),\n );\n }\n\n try {\n const result = await descriptor.execute(input, context);\n\n if (!isJsonSerializable(result)) {\n throw new ExecuteFailure(\n \"serialization_error\",\n `Tool ${originalName} returned a non-serializable value`,\n );\n }\n\n if (outputValidator && !outputValidator(result)) {\n throw new ExecuteFailure(\n \"validation_error\",\n formatValidationMessage(\n ajv,\n \"output\",\n originalName,\n outputValidator,\n ),\n );\n }\n\n return result;\n } catch (error) {\n if (isExecuteFailure(error)) {\n throw error;\n }\n\n throw new ExecuteFailure(\n \"tool_error\",\n error instanceof Error\n ? error.message\n : `Tool ${originalName} failed`,\n );\n }\n },\n inputSchema,\n originalName,\n outputSchema,\n safeName,\n };\n\n typegenTools[safeName] = {\n description: descriptor.description,\n inputSchema,\n outputSchema,\n };\n }\n\n return {\n name,\n originalToSafeName,\n safeToOriginalName,\n tools: resolvedTools,\n types: provider.types ?? generateTypesFromJsonSchema(name, typegenTools),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAM,iBAAiB,IAAI,IAAI;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAEF,MAAM,uBAAuB;AAE7B,SAAS,oBAAoB,OAAuB;CAClD,IAAI,QAAQ;CACZ,IAAI,MAAM,MAAM;AAEhB,QAAO,QAAQ,OAAO,MAAM,WAAW,MAAM,KAAK,qBAChD,UAAS;AAGX,QAAO,MAAM,SAAS,MAAM,WAAW,MAAM,EAAE,KAAK,qBAClD,QAAO;AAGT,QAAO,MAAM,MAAM,OAAO,IAAI;;;;;AAMhC,SAAgB,kBAAkB,OAAwB;AACxD,QAAO,6BAA6B,KAAK,MAAM;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ACnB,WAAW,cACX,UACA,aACD;EACD,MAAM,iBAAiB,iBAAiBL,OAAK,YAAY;EACzD,MAAM,kBAAkB,iBAAiBA,OAAK,aAAa;AAE3D,gBAAc,YAAY;GACxB,aAAa,qBAAqB,WAAW,YAAY;GACzD,aAAa,WAAW;GACxB,SAAS,OACP,OACA,YACqB;AACrB,QAAI,kBAAkB,CAAC,eAAe,MAAM,CAC1C,OAAM,IAAIM,8BACR,oBACA,wBAAwBN,OAAK,SAAS,cAAc,eAAe,CACpE;AAGH,QAAI;KACF,MAAM,SAAS,MAAM,WAAW,QAAQ,OAAO,QAAQ;AAEvD,SAAI,CAACO,kCAAmB,OAAO,CAC7B,OAAM,IAAID,8BACR,uBACA,QAAQ,aAAa,oCACtB;AAGH,SAAI,mBAAmB,CAAC,gBAAgB,OAAO,CAC7C,OAAM,IAAIA,8BACR,oBACA,wBACEN,OACA,UACA,cACA,gBACD,CACF;AAGH,YAAO;aACA,OAAO;AACd,SAAIQ,gCAAiB,MAAM,CACzB,OAAM;AAGR,WAAM,IAAIF,8BACR,cACA,iBAAiB,QACb,MAAM,UACN,QAAQ,aAAa,SAC1B;;;GAGL;GACA;GACA;GACA;GACD;AAED,eAAa,YAAY;GACvB,aAAa,WAAW;GACxB;GACA;GACD;;AAGH,QAAO;EACL;EACA;EACA;EACA,OAAO;EACP,OAAO,SAAS,SAAS,4BAA4B,MAAM,aAAa;EACzE"}
|
|
@@ -126,6 +126,7 @@ function extractProviderManifests(providers) {
|
|
|
126
126
|
return providers.map((provider) => ({
|
|
127
127
|
name: provider.name,
|
|
128
128
|
tools: Object.fromEntries(Object.entries(provider.tools).map(([safeToolName, descriptor]) => [safeToolName, {
|
|
129
|
+
annotations: descriptor.annotations,
|
|
129
130
|
description: descriptor.description,
|
|
130
131
|
originalName: descriptor.originalName,
|
|
131
132
|
safeName: descriptor.safeName
|
|
@@ -232,4 +233,4 @@ Object.defineProperty(exports, 'truncateLogs', {
|
|
|
232
233
|
return truncateLogs;
|
|
233
234
|
}
|
|
234
235
|
});
|
|
235
|
-
//# sourceMappingURL=runner-
|
|
236
|
+
//# sourceMappingURL=runner-BEY9nWc7.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner-BEY9nWc7.cjs","names":["truncated: string[]","isExecuteFailure","isJsonSerializable","ExecuteFailure"],"sources":["../src/executor/shared.ts","../src/runner.ts"],"sourcesContent":["import type {\n ExecuteError,\n ExecuteErrorCode,\n ExecuteResult,\n ToolExecutionContext,\n} from \"../types\";\n\nconst EXECUTION_TIMEOUT_MESSAGE = \"Execution timed out\";\n\n/**\n * Canonical error codes that may safely cross trusted executor boundaries.\n */\nconst KNOWN_EXECUTE_ERROR_CODES = new Set<ExecuteErrorCode>([\n \"timeout\",\n \"memory_limit\",\n \"validation_error\",\n \"tool_error\",\n \"runtime_error\",\n \"serialization_error\",\n \"internal_error\",\n]);\n\n/**\n * Returns whether the value is one of execbox's stable execution error codes.\n */\nexport function isKnownExecuteErrorCode(\n value: unknown,\n): value is ExecuteErrorCode {\n return KNOWN_EXECUTE_ERROR_CODES.has(value as ExecuteErrorCode);\n}\n\n/**\n * Returns the stable timeout message used across executor implementations.\n */\nexport function getExecutionTimeoutMessage(): string {\n return EXECUTION_TIMEOUT_MESSAGE;\n}\n\n/**\n * Creates the canonical timeout failure result used for preflight cancellation.\n */\nexport function createTimeoutExecuteResult(durationMs = 0): ExecuteResult {\n return {\n durationMs,\n error: {\n code: \"timeout\",\n message: getExecutionTimeoutMessage(),\n } satisfies ExecuteError,\n logs: [],\n ok: false,\n };\n}\n\n/**\n * Normalizes an unknown thrown value into a human-readable message.\n */\nexport function normalizeThrownMessage(error: unknown): string {\n if (error instanceof Error) {\n return error.message;\n }\n\n if (typeof error === \"object\" && error !== null && \"message\" in error) {\n const message = (error as { message?: unknown }).message;\n if (typeof message === \"string\") {\n return message;\n }\n }\n\n return String(error);\n}\n\n/**\n * Returns the thrown error name when one is available.\n */\nexport function normalizeThrownName(error: unknown): string | undefined {\n if (error instanceof Error) {\n return error.name;\n }\n\n if (typeof error === \"object\" && error !== null && \"name\" in error) {\n const name = (error as { name?: unknown }).name;\n if (typeof name === \"string\") {\n return name;\n }\n }\n\n return undefined;\n}\n\n/**\n * Builds the standard tool execution context passed to resolved tool wrappers.\n */\nexport function createExecutionContext(\n signal: AbortSignal,\n providerName: string,\n safeToolName: string,\n originalToolName: string,\n): ToolExecutionContext {\n return {\n originalToolName,\n providerName,\n safeToolName,\n signal,\n };\n}\n\n/**\n * Truncates captured logs to the configured line and character limits.\n */\nexport function truncateLogs(\n logs: string[],\n maxLogLines: number,\n maxLogChars: number,\n): string[] {\n const limitedLines = logs.slice(0, maxLogLines);\n let remainingChars = maxLogChars;\n const truncated: string[] = [];\n\n for (const line of limitedLines) {\n if (remainingChars <= 0) {\n break;\n }\n\n if (line.length <= remainingChars) {\n truncated.push(line);\n remainingChars -= line.length;\n continue;\n }\n\n truncated.push(line.slice(0, remainingChars));\n break;\n }\n\n return truncated;\n}\n\nfunction formatLogValue(value: unknown): string {\n if (typeof value === \"string\") {\n return value;\n }\n\n if (value === undefined) {\n return \"undefined\";\n }\n\n try {\n return JSON.stringify(value);\n } catch {\n return String(value);\n }\n}\n\n/**\n * Formats guest console arguments into a single host-side log line.\n */\nexport function formatConsoleLine(values: unknown[]): string {\n return values.map((value) => formatLogValue(value)).join(\" \");\n}\n","import {\n createExecutionContext,\n getExecutionTimeoutMessage,\n normalizeThrownMessage,\n} from \"./executor/shared.ts\";\nimport {\n ExecuteFailure,\n isExecuteFailure,\n isJsonSerializable,\n} from \"./errors.ts\";\nimport type {\n ExecuteError,\n ResolvedToolProvider,\n ToolAnnotations,\n} from \"./types.ts\";\n\n/**\n * Transport-safe metadata for one exposed tool.\n */\nexport interface ProviderToolManifest {\n /** Optional MCP-compatible behavior hints used by discovery surfaces. */\n annotations?: ToolAnnotations;\n description?: string;\n originalName: string;\n safeName: string;\n}\n\n/**\n * Namespace manifest shared with runner implementations.\n */\nexport interface ProviderManifest {\n name: string;\n tools: Record<string, ProviderToolManifest>;\n types: string;\n}\n\n/**\n * Execution limits forwarded to runner implementations.\n */\nexport interface ExecutorRuntimeOptions {\n maxLogChars?: number;\n maxLogLines?: number;\n memoryLimitBytes?: number;\n timeoutMs?: number;\n}\n\n/**\n * Public execution options accepted by executors per call.\n */\nexport interface ExecutionOptions extends ExecutorRuntimeOptions {\n signal?: AbortSignal;\n}\n\n/**\n * Tool invocation request emitted from a runner.\n */\nexport interface ToolCall {\n input: unknown;\n providerName: string;\n safeToolName: string;\n}\n\n/**\n * Trusted host response to a tool invocation request.\n */\nexport type ToolCallResult =\n | {\n ok: true;\n result: unknown;\n }\n | {\n error: ExecuteError;\n ok: false;\n };\n\nfunction toTrustedExecuteError(error: unknown): ExecuteError {\n if (isExecuteFailure(error)) {\n return {\n code: error.code,\n message: error.message,\n };\n }\n\n return {\n code: \"tool_error\",\n message: normalizeThrownMessage(error),\n };\n}\n\n/**\n * Converts resolved providers into manifest metadata that reveals only namespace details.\n */\nexport function extractProviderManifests(\n providers: ResolvedToolProvider[],\n): ProviderManifest[] {\n return providers.map((provider) => ({\n name: provider.name,\n tools: Object.fromEntries(\n Object.entries(provider.tools).map(([safeToolName, descriptor]) => [\n safeToolName,\n {\n annotations: descriptor.annotations,\n description: descriptor.description,\n originalName: descriptor.originalName,\n safeName: descriptor.safeName,\n },\n ]),\n ),\n types: provider.types,\n }));\n}\n\n/**\n * Creates a host-side dispatcher for runner-emitted tool calls.\n */\nexport function createToolCallDispatcher(\n providers: ResolvedToolProvider[],\n signal: AbortSignal,\n): (call: ToolCall) => Promise<ToolCallResult> {\n const providerMap = new Map(\n providers.map((provider) => [provider.name, provider] as const),\n );\n\n return async (call) => {\n const provider = providerMap.get(call.providerName);\n const descriptor = provider?.tools[call.safeToolName];\n\n if (!provider || !descriptor) {\n return {\n error: {\n code: \"internal_error\",\n message: `Unknown tool ${call.providerName}.${call.safeToolName}`,\n },\n ok: false,\n };\n }\n\n try {\n if (signal.aborted) {\n return {\n error: {\n code: \"timeout\",\n message: getExecutionTimeoutMessage(),\n },\n ok: false,\n };\n }\n\n const result = await descriptor.execute(\n call.input,\n createExecutionContext(\n signal,\n provider.name,\n descriptor.safeName,\n descriptor.originalName,\n ),\n );\n\n if (result !== undefined && !isJsonSerializable(result)) {\n throw new ExecuteFailure(\n \"serialization_error\",\n \"Host value is not JSON-serializable\",\n );\n }\n\n return {\n ok: true,\n result,\n };\n } catch (error) {\n return {\n error: toTrustedExecuteError(error),\n ok: false,\n };\n }\n };\n}\n"],"mappings":";;;AAOA,MAAM,4BAA4B;;;;AAKlC,MAAM,4BAA4B,IAAI,IAAsB;CAC1D;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;;;;AAKF,SAAgB,wBACd,OAC2B;AAC3B,QAAO,0BAA0B,IAAI,MAA0B;;;;;AAMjE,SAAgB,6BAAqC;AACnD,QAAO;;;;;AAMT,SAAgB,2BAA2B,aAAa,GAAkB;AACxE,QAAO;EACL;EACA,OAAO;GACL,MAAM;GACN,SAAS,4BAA4B;GACtC;EACD,MAAM,EAAE;EACR,IAAI;EACL;;;;;AAMH,SAAgB,uBAAuB,OAAwB;AAC7D,KAAI,iBAAiB,MACnB,QAAO,MAAM;AAGf,KAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,aAAa,OAAO;EACrE,MAAM,UAAW,MAAgC;AACjD,MAAI,OAAO,YAAY,SACrB,QAAO;;AAIX,QAAO,OAAO,MAAM;;;;;AAMtB,SAAgB,oBAAoB,OAAoC;AACtE,KAAI,iBAAiB,MACnB,QAAO,MAAM;AAGf,KAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU,OAAO;EAClE,MAAM,OAAQ,MAA6B;AAC3C,MAAI,OAAO,SAAS,SAClB,QAAO;;;;;;AAUb,SAAgB,uBACd,QACA,cACA,cACA,kBACsB;AACtB,QAAO;EACL;EACA;EACA;EACA;EACD;;;;;AAMH,SAAgB,aACd,MACA,aACA,aACU;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a,UAAU,MAAM,KAAK;AAExC,MAAI,CAAC,YAAY,CAAC,WAChB,QAAO;GACL,OAAO;IACL,MAAM;IACN,SAAS,gBAAgB,KAAK,aAAa,GAAG,KAAK;IACpD;GACD,IAAI;GACL;AAGH,MAAI;AACF,OAAI,OAAO,QACT,QAAO;IACL,OAAO;KACL,MAAM;KACN,SAAS,4BAA4B;KACtC;IACD,IAAI;IACL;GAGH,MAAM,SAAS,MAAM,WAAW,QAC9B,KAAK,OACL,uBACE,QACA,SAAS,MACT,WAAW,UACX,WAAW,aACZ,CACF;AAED,OAAI,WAAW,UAAa,CAACC,kCAAmB,OAAO,CACrD,OAAM,IAAIC,8BACR,uBACA,sCACD;AAGH,UAAO;IACL,IAAI;IACJ;IACD;WACM,OAAO;AACd,UAAO;IACL,OAAO,sBAAsB,MAAM;IACnC,IAAI;IACL"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as isExecuteFailure, r as isJsonSerializable, t as ExecuteFailure } from "./errors-
|
|
1
|
+
import { n as isExecuteFailure, r as isJsonSerializable, t as ExecuteFailure } from "./errors-DdWVEGU8.js";
|
|
2
2
|
|
|
3
3
|
//#region src/executor/shared.ts
|
|
4
4
|
const EXECUTION_TIMEOUT_MESSAGE = "Execution timed out";
|
|
@@ -126,6 +126,7 @@ function extractProviderManifests(providers) {
|
|
|
126
126
|
return providers.map((provider) => ({
|
|
127
127
|
name: provider.name,
|
|
128
128
|
tools: Object.fromEntries(Object.entries(provider.tools).map(([safeToolName, descriptor]) => [safeToolName, {
|
|
129
|
+
annotations: descriptor.annotations,
|
|
129
130
|
description: descriptor.description,
|
|
130
131
|
originalName: descriptor.originalName,
|
|
131
132
|
safeName: descriptor.safeName
|
|
@@ -173,4 +174,4 @@ function createToolCallDispatcher(providers, signal) {
|
|
|
173
174
|
|
|
174
175
|
//#endregion
|
|
175
176
|
export { formatConsoleLine as a, normalizeThrownMessage as c, createTimeoutExecuteResult as i, normalizeThrownName as l, extractProviderManifests as n, getExecutionTimeoutMessage as o, createExecutionContext as r, isKnownExecuteErrorCode as s, createToolCallDispatcher as t, truncateLogs as u };
|
|
176
|
-
//# sourceMappingURL=runner-
|
|
177
|
+
//# sourceMappingURL=runner-BWAVLBi6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner-BWAVLBi6.js","names":["truncated: string[]"],"sources":["../src/executor/shared.ts","../src/runner.ts"],"sourcesContent":["import type {\n ExecuteError,\n ExecuteErrorCode,\n ExecuteResult,\n ToolExecutionContext,\n} from \"../types\";\n\nconst EXECUTION_TIMEOUT_MESSAGE = \"Execution timed out\";\n\n/**\n * Canonical error codes that may safely cross trusted executor boundaries.\n */\nconst KNOWN_EXECUTE_ERROR_CODES = new Set<ExecuteErrorCode>([\n \"timeout\",\n \"memory_limit\",\n \"validation_error\",\n \"tool_error\",\n \"runtime_error\",\n \"serialization_error\",\n \"internal_error\",\n]);\n\n/**\n * Returns whether the value is one of execbox's stable execution error codes.\n */\nexport function isKnownExecuteErrorCode(\n value: unknown,\n): value is ExecuteErrorCode {\n return KNOWN_EXECUTE_ERROR_CODES.has(value as ExecuteErrorCode);\n}\n\n/**\n * Returns the stable timeout message used across executor implementations.\n */\nexport function getExecutionTimeoutMessage(): string {\n return EXECUTION_TIMEOUT_MESSAGE;\n}\n\n/**\n * Creates the canonical timeout failure result used for preflight cancellation.\n */\nexport function createTimeoutExecuteResult(durationMs = 0): ExecuteResult {\n return {\n durationMs,\n error: {\n code: \"timeout\",\n message: getExecutionTimeoutMessage(),\n } satisfies ExecuteError,\n logs: [],\n ok: false,\n };\n}\n\n/**\n * Normalizes an unknown thrown value into a human-readable message.\n */\nexport function normalizeThrownMessage(error: unknown): string {\n if (error instanceof Error) {\n return error.message;\n }\n\n if (typeof error === \"object\" && error !== null && \"message\" in error) {\n const message = (error as { message?: unknown }).message;\n if (typeof message === \"string\") {\n return message;\n }\n }\n\n return String(error);\n}\n\n/**\n * Returns the thrown error name when one is available.\n */\nexport function normalizeThrownName(error: unknown): string | undefined {\n if (error instanceof Error) {\n return error.name;\n }\n\n if (typeof error === \"object\" && error !== null && \"name\" in error) {\n const name = (error as { name?: unknown }).name;\n if (typeof name === \"string\") {\n return name;\n }\n }\n\n return undefined;\n}\n\n/**\n * Builds the standard tool execution context passed to resolved tool wrappers.\n */\nexport function createExecutionContext(\n signal: AbortSignal,\n providerName: string,\n safeToolName: string,\n originalToolName: string,\n): ToolExecutionContext {\n return {\n originalToolName,\n providerName,\n safeToolName,\n signal,\n };\n}\n\n/**\n * Truncates captured logs to the configured line and character limits.\n */\nexport function truncateLogs(\n logs: string[],\n maxLogLines: number,\n maxLogChars: number,\n): string[] {\n const limitedLines = logs.slice(0, maxLogLines);\n let remainingChars = maxLogChars;\n const truncated: string[] = [];\n\n for (const line of limitedLines) {\n if (remainingChars <= 0) {\n break;\n }\n\n if (line.length <= remainingChars) {\n truncated.push(line);\n remainingChars -= line.length;\n continue;\n }\n\n truncated.push(line.slice(0, remainingChars));\n break;\n }\n\n return truncated;\n}\n\nfunction formatLogValue(value: unknown): string {\n if (typeof value === \"string\") {\n return value;\n }\n\n if (value === undefined) {\n return \"undefined\";\n }\n\n try {\n return JSON.stringify(value);\n } catch {\n return String(value);\n }\n}\n\n/**\n * Formats guest console arguments into a single host-side log line.\n */\nexport function formatConsoleLine(values: unknown[]): string {\n return values.map((value) => formatLogValue(value)).join(\" \");\n}\n","import {\n createExecutionContext,\n getExecutionTimeoutMessage,\n normalizeThrownMessage,\n} from \"./executor/shared.ts\";\nimport {\n ExecuteFailure,\n isExecuteFailure,\n isJsonSerializable,\n} from \"./errors.ts\";\nimport type {\n ExecuteError,\n ResolvedToolProvider,\n ToolAnnotations,\n} from \"./types.ts\";\n\n/**\n * Transport-safe metadata for one exposed tool.\n */\nexport interface ProviderToolManifest {\n /** Optional MCP-compatible behavior hints used by discovery surfaces. */\n annotations?: ToolAnnotations;\n description?: string;\n originalName: string;\n safeName: string;\n}\n\n/**\n * Namespace manifest shared with runner implementations.\n */\nexport interface ProviderManifest {\n name: string;\n tools: Record<string, ProviderToolManifest>;\n types: string;\n}\n\n/**\n * Execution limits forwarded to runner implementations.\n */\nexport interface ExecutorRuntimeOptions {\n maxLogChars?: number;\n maxLogLines?: number;\n memoryLimitBytes?: number;\n timeoutMs?: number;\n}\n\n/**\n * Public execution options accepted by executors per call.\n */\nexport interface ExecutionOptions extends ExecutorRuntimeOptions {\n signal?: AbortSignal;\n}\n\n/**\n * Tool invocation request emitted from a runner.\n */\nexport interface ToolCall {\n input: unknown;\n providerName: string;\n safeToolName: string;\n}\n\n/**\n * Trusted host response to a tool invocation request.\n */\nexport type ToolCallResult =\n | {\n ok: true;\n result: unknown;\n }\n | {\n error: ExecuteError;\n ok: false;\n };\n\nfunction toTrustedExecuteError(error: unknown): ExecuteError {\n if (isExecuteFailure(error)) {\n return {\n code: error.code,\n message: error.message,\n };\n }\n\n return {\n code: \"tool_error\",\n message: normalizeThrownMessage(error),\n };\n}\n\n/**\n * Converts resolved providers into manifest metadata that reveals only namespace details.\n */\nexport function extractProviderManifests(\n providers: ResolvedToolProvider[],\n): ProviderManifest[] {\n return providers.map((provider) => ({\n name: provider.name,\n tools: Object.fromEntries(\n Object.entries(provider.tools).map(([safeToolName, descriptor]) => [\n safeToolName,\n {\n annotations: descriptor.annotations,\n description: descriptor.description,\n originalName: descriptor.originalName,\n safeName: descriptor.safeName,\n },\n ]),\n ),\n types: provider.types,\n }));\n}\n\n/**\n * Creates a host-side dispatcher for runner-emitted tool calls.\n */\nexport function createToolCallDispatcher(\n providers: ResolvedToolProvider[],\n signal: AbortSignal,\n): (call: ToolCall) => Promise<ToolCallResult> {\n const providerMap = new Map(\n providers.map((provider) => [provider.name, provider] as const),\n );\n\n return async (call) => {\n const provider = providerMap.get(call.providerName);\n const descriptor = provider?.tools[call.safeToolName];\n\n if (!provider || !descriptor) {\n return {\n error: {\n code: \"internal_error\",\n message: `Unknown tool ${call.providerName}.${call.safeToolName}`,\n },\n ok: false,\n };\n }\n\n try {\n if (signal.aborted) {\n return {\n error: {\n code: \"timeout\",\n message: getExecutionTimeoutMessage(),\n },\n ok: false,\n };\n }\n\n const result = await descriptor.execute(\n call.input,\n createExecutionContext(\n signal,\n provider.name,\n descriptor.safeName,\n descriptor.originalName,\n ),\n );\n\n if (result !== undefined && !isJsonSerializable(result)) {\n throw new ExecuteFailure(\n \"serialization_error\",\n \"Host value is not JSON-serializable\",\n );\n }\n\n return {\n ok: true,\n result,\n };\n } catch (error) {\n return {\n error: toTrustedExecuteError(error),\n ok: false,\n };\n }\n };\n}\n"],"mappings":";;;AAOA,MAAM,4BAA4B;;;;AAKlC,MAAM,4BAA4B,IAAI,IAAsB;CAC1D;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;;;;AAKF,SAAgB,wBACd,OAC2B;AAC3B,QAAO,0BAA0B,IAAI,MAA0B;;;;;AAMjE,SAAgB,6BAAqC;AACnD,QAAO;;;;;AAMT,SAAgB,2BAA2B,aAAa,GAAkB;AACxE,QAAO;EACL;EACA,OAAO;GACL,MAAM;GACN,SAAS,4BAA4B;GACtC;EACD,MAAM,EAAE;EACR,IAAI;EACL;;;;;AAMH,SAAgB,uBAAuB,OAAwB;AAC7D,KAAI,iBAAiB,MACnB,QAAO,MAAM;AAGf,KAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,aAAa,OAAO;EACrE,MAAM,UAAW,MAAgC;AACjD,MAAI,OAAO,YAAY,SACrB,QAAO;;AAIX,QAAO,OAAO,MAAM;;;;;AAMtB,SAAgB,oBAAoB,OAAoC;AACtE,KAAI,iBAAiB,MACnB,QAAO,MAAM;AAGf,KAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU,OAAO;EAClE,MAAM,OAAQ,MAA6B;AAC3C,MAAI,OAAO,SAAS,SAClB,QAAO;;;;;;AAUb,SAAgB,uBACd,QACA,cACA,cACA,kBACsB;AACtB,QAAO;EACL;EACA;EACA;EACA;EACD;;;;;AAMH,SAAgB,aACd,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nD,MAAM,aAAa,UAAU,MAAM,KAAK;AAExC,MAAI,CAAC,YAAY,CAAC,WAChB,QAAO;GACL,OAAO;IACL,MAAM;IACN,SAAS,gBAAgB,KAAK,aAAa,GAAG,KAAK;IACpD;GACD,IAAI;GACL;AAGH,MAAI;AACF,OAAI,OAAO,QACT,QAAO;IACL,OAAO;KACL,MAAM;KACN,SAAS,4BAA4B;KACtC;IACD,IAAI;IACL;GAGH,MAAM,SAAS,MAAM,WAAW,QAC9B,KAAK,OACL,uBACE,QACA,SAAS,MACT,WAAW,UACX,WAAW,aACZ,CACF;AAED,OAAI,WAAW,UAAa,CAAC,mBAAmB,OAAO,CACrD,OAAM,IAAI,eACR,uBACA,sCACD;AAGH,UAAO;IACL,IAAI;IACJ;IACD;WACM,OAAO;AACd,UAAO;IACL,OAAO,sBAAsB,MAAM;IACnC,IAAI;IACL"}
|
|
@@ -41,6 +41,24 @@ type ExecuteResult<T = unknown> = {
|
|
|
41
41
|
logs: string[];
|
|
42
42
|
ok: false;
|
|
43
43
|
};
|
|
44
|
+
/**
|
|
45
|
+
* MCP-compatible behavior hints for a tool.
|
|
46
|
+
*
|
|
47
|
+
* These values are advisory metadata for clients and models. They are not
|
|
48
|
+
* enforced by execbox and must not be treated as a security boundary.
|
|
49
|
+
*/
|
|
50
|
+
interface ToolAnnotations {
|
|
51
|
+
/** Human-readable title for UI display. */
|
|
52
|
+
title?: string;
|
|
53
|
+
/** If true, the tool does not modify its environment. */
|
|
54
|
+
readOnlyHint?: boolean;
|
|
55
|
+
/** If true, the tool may perform destructive updates to its environment. */
|
|
56
|
+
destructiveHint?: boolean;
|
|
57
|
+
/** If true, repeated calls with the same arguments have no additional effect. */
|
|
58
|
+
idempotentHint?: boolean;
|
|
59
|
+
/** If true, the tool may interact with external entities outside a closed domain. */
|
|
60
|
+
openWorldHint?: boolean;
|
|
61
|
+
}
|
|
44
62
|
/**
|
|
45
63
|
* Context passed to every tool execution.
|
|
46
64
|
*/
|
|
@@ -58,6 +76,8 @@ interface ToolExecutionContext {
|
|
|
58
76
|
* Host-side tool definition before provider resolution.
|
|
59
77
|
*/
|
|
60
78
|
interface ToolDescriptor {
|
|
79
|
+
/** Optional MCP-compatible behavior hints used by discovery surfaces. */
|
|
80
|
+
annotations?: ToolAnnotations;
|
|
61
81
|
/** Optional human-readable description used in generated types and docs. */
|
|
62
82
|
description?: string;
|
|
63
83
|
/** Optional input schema validated before the tool is invoked. */
|
|
@@ -82,6 +102,8 @@ interface ToolProvider {
|
|
|
82
102
|
* Tool descriptor after validation, sanitization, and execution wrapping.
|
|
83
103
|
*/
|
|
84
104
|
interface ResolvedToolDescriptor {
|
|
105
|
+
/** Optional MCP-compatible behavior hints used by discovery surfaces. */
|
|
106
|
+
annotations?: ToolAnnotations;
|
|
85
107
|
/** Optional human-readable description used in generated types and docs. */
|
|
86
108
|
description?: string;
|
|
87
109
|
/** Normalized JSON Schema validated before the tool is invoked. */
|
|
@@ -120,6 +142,8 @@ type TypegenToolDescriptor = Pick<ResolvedToolDescriptor, "description" | "input
|
|
|
120
142
|
* Transport-safe metadata for one exposed tool.
|
|
121
143
|
*/
|
|
122
144
|
interface ProviderToolManifest {
|
|
145
|
+
/** Optional MCP-compatible behavior hints used by discovery surfaces. */
|
|
146
|
+
annotations?: ToolAnnotations;
|
|
123
147
|
description?: string;
|
|
124
148
|
originalName: string;
|
|
125
149
|
safeName: string;
|
|
@@ -174,5 +198,5 @@ declare function extractProviderManifests(providers: ResolvedToolProvider[]): Pr
|
|
|
174
198
|
*/
|
|
175
199
|
declare function createToolCallDispatcher(providers: ResolvedToolProvider[], signal: AbortSignal): (call: ToolCall) => Promise<ToolCallResult>;
|
|
176
200
|
//#endregion
|
|
177
|
-
export {
|
|
178
|
-
//# sourceMappingURL=runner-
|
|
201
|
+
export { ToolExecutionContext as _, ToolCall as a, TypegenToolDescriptor as b, extractProviderManifests as c, ExecuteResult as d, JsonSchema as f, ToolDescriptor as g, ToolAnnotations as h, ProviderToolManifest as i, ExecuteError as l, ResolvedToolProvider as m, ExecutorRuntimeOptions as n, ToolCallResult as o, ResolvedToolDescriptor as p, ProviderManifest as r, createToolCallDispatcher as s, ExecutionOptions as t, ExecuteErrorCode as u, ToolProvider as v, ToolSchema as y };
|
|
202
|
+
//# sourceMappingURL=runner-Cy18Z0u0.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner-Cy18Z0u0.d.cts","names":[],"sources":["../src/types.ts","../src/runner.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;AAKA,CAAA,CAAA;AAKY,IAAA,CALA,UAAA,CAAA,CAAA,CAAa,MAKH,CAAA,MAAA,CAAA,CAAA,OAAA,CAAA;;;;AAAwC,IAAA,CAAlD,UAAA,CAAA,CAAA,CAAa,UAAqC,CAAA,CAAA,CAAxB,UAAwB,CAAA,CAAA,CAAX,WAAW;AAK9D,CAAA,CAAA;AAYA,CAAA,CAAA,CAAA,MAAA,CAAA,KAAA,CAAA,KAAA,CAAA,QAAA,CAAA,EAAA,CAAA,SAAA,CAAA,GAAA,CAAA,OAAA,CAAA,IAAA,CAAA,KAAA;AAUA,CAAA,CAAA;AAoBiB,IAAA,CA1CL,gBAAA,CAAA,CAAA,CA0CoB,CAAA,OAAA,CAAA,CAAA,CAAA,CAAA,CAAA,YAAA,CAAA,CAAA,CAAA,CAAA,CAAA,gBAAA,CAAA,CAAA,CAAA,CAAA,CAAA,UAAA,CAAA,CAAA,CAAA,CAAA,CAAA,aAAA,CAAA,CAAA,CAAA,CAAA,CAAA,mBAAA,CAAA,CAAA,CAAA,CAAA,CAAA,cAAA,CAAA;AAgBhC,CAAA,CAAA;AAcA,CAAA,CAAA,CAAA,UAAA,CAAA,SAAA,CAAA,OAAA,CAAA,QAAA,CAAA,EAAA,CAAA,CAAA,CAAA,IAAA,CAAA,aAAA,CAAA;;AAMgB,SAAA,CAlEC,YAAA,CAkED;EAEC,CAAA,CAAA,CAAA,CAAA,OAAA,CAAA,QAAA,CAAA,K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M,wBAAA,YACH,gCACH,qBACA,aAAa,QAAQ"}
|
|
@@ -41,6 +41,24 @@ type ExecuteResult<T = unknown> = {
|
|
|
41
41
|
logs: string[];
|
|
42
42
|
ok: false;
|
|
43
43
|
};
|
|
44
|
+
/**
|
|
45
|
+
* MCP-compatible behavior hints for a tool.
|
|
46
|
+
*
|
|
47
|
+
* These values are advisory metadata for clients and models. They are not
|
|
48
|
+
* enforced by execbox and must not be treated as a security boundary.
|
|
49
|
+
*/
|
|
50
|
+
interface ToolAnnotations {
|
|
51
|
+
/** Human-readable title for UI display. */
|
|
52
|
+
title?: string;
|
|
53
|
+
/** If true, the tool does not modify its environment. */
|
|
54
|
+
readOnlyHint?: boolean;
|
|
55
|
+
/** If true, the tool may perform destructive updates to its environment. */
|
|
56
|
+
destructiveHint?: boolean;
|
|
57
|
+
/** If true, repeated calls with the same arguments have no additional effect. */
|
|
58
|
+
idempotentHint?: boolean;
|
|
59
|
+
/** If true, the tool may interact with external entities outside a closed domain. */
|
|
60
|
+
openWorldHint?: boolean;
|
|
61
|
+
}
|
|
44
62
|
/**
|
|
45
63
|
* Context passed to every tool execution.
|
|
46
64
|
*/
|
|
@@ -58,6 +76,8 @@ interface ToolExecutionContext {
|
|
|
58
76
|
* Host-side tool definition before provider resolution.
|
|
59
77
|
*/
|
|
60
78
|
interface ToolDescriptor {
|
|
79
|
+
/** Optional MCP-compatible behavior hints used by discovery surfaces. */
|
|
80
|
+
annotations?: ToolAnnotations;
|
|
61
81
|
/** Optional human-readable description used in generated types and docs. */
|
|
62
82
|
description?: string;
|
|
63
83
|
/** Optional input schema validated before the tool is invoked. */
|
|
@@ -82,6 +102,8 @@ interface ToolProvider {
|
|
|
82
102
|
* Tool descriptor after validation, sanitization, and execution wrapping.
|
|
83
103
|
*/
|
|
84
104
|
interface ResolvedToolDescriptor {
|
|
105
|
+
/** Optional MCP-compatible behavior hints used by discovery surfaces. */
|
|
106
|
+
annotations?: ToolAnnotations;
|
|
85
107
|
/** Optional human-readable description used in generated types and docs. */
|
|
86
108
|
description?: string;
|
|
87
109
|
/** Normalized JSON Schema validated before the tool is invoked. */
|
|
@@ -120,6 +142,8 @@ type TypegenToolDescriptor = Pick<ResolvedToolDescriptor, "description" | "input
|
|
|
120
142
|
* Transport-safe metadata for one exposed tool.
|
|
121
143
|
*/
|
|
122
144
|
interface ProviderToolManifest {
|
|
145
|
+
/** Optional MCP-compatible behavior hints used by discovery surfaces. */
|
|
146
|
+
annotations?: ToolAnnotations;
|
|
123
147
|
description?: string;
|
|
124
148
|
originalName: string;
|
|
125
149
|
safeName: string;
|
|
@@ -174,5 +198,5 @@ declare function extractProviderManifests(providers: ResolvedToolProvider[]): Pr
|
|
|
174
198
|
*/
|
|
175
199
|
declare function createToolCallDispatcher(providers: ResolvedToolProvider[], signal: AbortSignal): (call: ToolCall) => Promise<ToolCallResult>;
|
|
176
200
|
//#endregion
|
|
177
|
-
export {
|
|
178
|
-
//# sourceMappingURL=runner-
|
|
201
|
+
export { ToolExecutionContext as _, ToolCall as a, TypegenToolDescriptor as b, extractProviderManifests as c, ExecuteResult as d, JsonSchema as f, ToolDescriptor as g, ToolAnnotations as h, ProviderToolManifest as i, ExecuteError as l, ResolvedToolProvider as m, ExecutorRuntimeOptions as n, ToolCallResult as o, ResolvedToolDescriptor as p, ProviderManifest as r, createToolCallDispatcher as s, ExecutionOptions as t, ExecuteErrorCode as u, ToolProvider as v, ToolSchema as y };
|
|
202
|
+
//# sourceMappingURL=runner-DXLu0eJV.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner-DXLu0eJV.d.ts","names":[],"sources":["../src/types.ts","../src/runner.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;AAKA,CAAA,CAAA;AAKY,IAAA,CALA,UAAA,CAAA,CAAA,CAAa,MAKH,CAAA,MAAA,CAAA,CAAA,OAAA,CAAA;;;;AAAwC,IAAA,CAAlD,UAAA,CAAA,CAAA,CAAa,UAAqC,CAAA,CAAA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AA,GAAA,CAAA,IAAA;;AAMsB,SAAA,CC/FL,gBAAA,CAAA,OAAA,CAAyB,sBD+FpB,CAAA;EAEE,MAAA,CAAA,CAAA,CChGb,WDgGa;;;AAQxB,CAAA,CAAA,CAAA,IAAA,CAAA,UAAA,CAAA,OAAA,CAAA,OAAA,CAAA,IAAA,CAAA,CAAA,CAAA,MAAA;;AAAoC,SAAA,CClGnB,QAAA,CDkGmB;EAIrB,KAAA,CAAA,CAAA,OAAA;EAAL,YAAA,CAAA,CAAA,MAAA;EAAR,YAAA,CAAA,CAAA,MAAA;;;;;AC3Ie,IAAA,CA8CL,cAAA,CAAA,CAAA,CA9CyB;EAWpB,EAAA,CAAA,CAAA,IAAA;EASA,MAAA,CAAA,CAAA,OAAA;AAUjB,CAAA,CAAA,CAAA,CAAiB;EAOA,KAAA,CAAA,CAeJ,YAfY;EASb,EAAA,CAAA,CAAA,KAAA;AA2BZ,CAAA;AAuBA,CAAA,CAAA;;;AAGU,OAAA,CAAA,QAAA,CA1BM,wBAAA,CA0BN,SAAA,CAAA,CAzBG,oBAyBH,CAAA,CAAA,CAAA,CAAA,CAxBP,gBAwBO,CAAA,CAAA;;;;iBAHM,wBAAA,YACH,gCACH,qBACA,aAAa,QAAQ"}
|
package/dist/runtime.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const require_resolveProvider = require('./resolveProvider-
|
|
1
|
+
const require_resolveProvider = require('./resolveProvider-DFAg6No5.cjs');
|
|
2
2
|
const require_errors = require('./errors-xD8r6fCf.cjs');
|
|
3
|
-
const require_runner = require('./runner-
|
|
3
|
+
const require_runner = require('./runner-BEY9nWc7.cjs');
|
|
4
4
|
let acorn = require("acorn");
|
|
5
5
|
|
|
6
6
|
//#region src/normalize.ts
|
package/dist/runtime.d.cts
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* @packageDocumentation
|
|
3
3
|
* Public TypeScript declarations for this package entrypoint.
|
|
4
4
|
*/
|
|
5
|
-
import { _ as
|
|
6
|
-
import { t as Executor } from "./executor-
|
|
7
|
-
import { n as isExecuteFailure, r as isJsonSerializable, t as ExecuteFailure } from "./errors-
|
|
5
|
+
import { _ as ToolExecutionContext, a as ToolCall, b as TypegenToolDescriptor, c as extractProviderManifests, d as ExecuteResult, f as JsonSchema, g as ToolDescriptor, h as ToolAnnotations, i as ProviderToolManifest, l as ExecuteError, m as ResolvedToolProvider, n as ExecutorRuntimeOptions, o as ToolCallResult, p as ResolvedToolDescriptor, r as ProviderManifest, s as createToolCallDispatcher, t as ExecutionOptions, u as ExecuteErrorCode, v as ToolProvider, y as ToolSchema } from "./runner-Cy18Z0u0.cjs";
|
|
6
|
+
import { t as Executor } from "./executor-CtbrvTQ_.cjs";
|
|
7
|
+
import { n as isExecuteFailure, r as isJsonSerializable, t as ExecuteFailure } from "./errors-y4C-EIWT.cjs";
|
|
8
8
|
|
|
9
9
|
//#region src/executor/shared.d.ts
|
|
10
10
|
/**
|
|
@@ -61,5 +61,5 @@ declare const DEFAULT_EXECUTOR_RUNTIME_OPTIONS: ResolvedExecutorRuntimeOptions;
|
|
|
61
61
|
*/
|
|
62
62
|
declare function resolveExecutorRuntimeOptions(options?: ExecutorRuntimeOptions, overrides?: ExecutorRuntimeOptions): Required<ExecutorRuntimeOptions>;
|
|
63
63
|
//#endregion
|
|
64
|
-
export { DEFAULT_EXECUTOR_RUNTIME_OPTIONS, type ExecuteError, type ExecuteErrorCode, ExecuteFailure, type ExecuteResult, type ExecutionOptions, type Executor, type ExecutorRuntimeOptions, type JsonSchema, type ProviderManifest, type ProviderToolManifest, type ResolvedExecutorRuntimeOptions, type ResolvedToolDescriptor, type ResolvedToolProvider, type ToolCall, type ToolCallResult, type ToolDescriptor, type ToolExecutionContext, type ToolProvider, type ToolSchema, type TypegenToolDescriptor, createExecutionContext, createTimeoutExecuteResult, createToolCallDispatcher, extractProviderManifests, formatConsoleLine, getExecutionTimeoutMessage, isExecuteFailure, isJsonSerializable, isKnownExecuteErrorCode, normalizeCode, normalizeThrownMessage, normalizeThrownName, resolveExecutorRuntimeOptions, truncateLogs };
|
|
64
|
+
export { DEFAULT_EXECUTOR_RUNTIME_OPTIONS, type ExecuteError, type ExecuteErrorCode, ExecuteFailure, type ExecuteResult, type ExecutionOptions, type Executor, type ExecutorRuntimeOptions, type JsonSchema, type ProviderManifest, type ProviderToolManifest, type ResolvedExecutorRuntimeOptions, type ResolvedToolDescriptor, type ResolvedToolProvider, type ToolAnnotations, type ToolCall, type ToolCallResult, type ToolDescriptor, type ToolExecutionContext, type ToolProvider, type ToolSchema, type TypegenToolDescriptor, createExecutionContext, createTimeoutExecuteResult, createToolCallDispatcher, extractProviderManifests, formatConsoleLine, getExecutionTimeoutMessage, isExecuteFailure, isJsonSerializable, isKnownExecuteErrorCode, normalizeCode, normalizeThrownMessage, normalizeThrownName, resolveExecutorRuntimeOptions, truncateLogs };
|
|
65
65
|
//# sourceMappingURL=runtime.d.cts.map
|
package/dist/runtime.d.ts
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* @packageDocumentation
|
|
3
3
|
* Public TypeScript declarations for this package entrypoint.
|
|
4
4
|
*/
|
|
5
|
-
import { _ as
|
|
6
|
-
import { t as Executor } from "./executor-
|
|
7
|
-
import { n as isExecuteFailure, r as isJsonSerializable, t as ExecuteFailure } from "./errors-
|
|
5
|
+
import { _ as ToolExecutionContext, a as ToolCall, b as TypegenToolDescriptor, c as extractProviderManifests, d as ExecuteResult, f as JsonSchema, g as ToolDescriptor, h as ToolAnnotations, i as ProviderToolManifest, l as ExecuteError, m as ResolvedToolProvider, n as ExecutorRuntimeOptions, o as ToolCallResult, p as ResolvedToolDescriptor, r as ProviderManifest, s as createToolCallDispatcher, t as ExecutionOptions, u as ExecuteErrorCode, v as ToolProvider, y as ToolSchema } from "./runner-DXLu0eJV.js";
|
|
6
|
+
import { t as Executor } from "./executor-BOTd9xNK.js";
|
|
7
|
+
import { n as isExecuteFailure, r as isJsonSerializable, t as ExecuteFailure } from "./errors-BIWv-QIC.js";
|
|
8
8
|
|
|
9
9
|
//#region src/executor/shared.d.ts
|
|
10
10
|
/**
|
|
@@ -61,5 +61,5 @@ declare const DEFAULT_EXECUTOR_RUNTIME_OPTIONS: ResolvedExecutorRuntimeOptions;
|
|
|
61
61
|
*/
|
|
62
62
|
declare function resolveExecutorRuntimeOptions(options?: ExecutorRuntimeOptions, overrides?: ExecutorRuntimeOptions): Required<ExecutorRuntimeOptions>;
|
|
63
63
|
//#endregion
|
|
64
|
-
export { DEFAULT_EXECUTOR_RUNTIME_OPTIONS, type ExecuteError, type ExecuteErrorCode, ExecuteFailure, type ExecuteResult, type ExecutionOptions, type Executor, type ExecutorRuntimeOptions, type JsonSchema, type ProviderManifest, type ProviderToolManifest, type ResolvedExecutorRuntimeOptions, type ResolvedToolDescriptor, type ResolvedToolProvider, type ToolCall, type ToolCallResult, type ToolDescriptor, type ToolExecutionContext, type ToolProvider, type ToolSchema, type TypegenToolDescriptor, createExecutionContext, createTimeoutExecuteResult, createToolCallDispatcher, extractProviderManifests, formatConsoleLine, getExecutionTimeoutMessage, isExecuteFailure, isJsonSerializable, isKnownExecuteErrorCode, normalizeCode, normalizeThrownMessage, normalizeThrownName, resolveExecutorRuntimeOptions, truncateLogs };
|
|
64
|
+
export { DEFAULT_EXECUTOR_RUNTIME_OPTIONS, type ExecuteError, type ExecuteErrorCode, ExecuteFailure, type ExecuteResult, type ExecutionOptions, type Executor, type ExecutorRuntimeOptions, type JsonSchema, type ProviderManifest, type ProviderToolManifest, type ResolvedExecutorRuntimeOptions, type ResolvedToolDescriptor, type ResolvedToolProvider, type ToolAnnotations, type ToolCall, type ToolCallResult, type ToolDescriptor, type ToolExecutionContext, type ToolProvider, type ToolSchema, type TypegenToolDescriptor, createExecutionContext, createTimeoutExecuteResult, createToolCallDispatcher, extractProviderManifests, formatConsoleLine, getExecutionTimeoutMessage, isExecuteFailure, isJsonSerializable, isKnownExecuteErrorCode, normalizeCode, normalizeThrownMessage, normalizeThrownName, resolveExecutorRuntimeOptions, truncateLogs };
|
|
65
65
|
//# sourceMappingURL=runtime.d.ts.map
|
package/dist/runtime.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as isExecuteFailure, r as isJsonSerializable, t as ExecuteFailure } from "./errors-
|
|
2
|
-
import { a as formatConsoleLine, c as normalizeThrownMessage, i as createTimeoutExecuteResult, l as normalizeThrownName, n as extractProviderManifests, o as getExecutionTimeoutMessage, r as createExecutionContext, s as isKnownExecuteErrorCode, t as createToolCallDispatcher, u as truncateLogs } from "./runner-
|
|
1
|
+
import { n as isExecuteFailure, r as isJsonSerializable, t as ExecuteFailure } from "./errors-DdWVEGU8.js";
|
|
2
|
+
import { a as formatConsoleLine, c as normalizeThrownMessage, i as createTimeoutExecuteResult, l as normalizeThrownName, n as extractProviderManifests, o as getExecutionTimeoutMessage, r as createExecutionContext, s as isKnownExecuteErrorCode, t as createToolCallDispatcher, u as truncateLogs } from "./runner-BWAVLBi6.js";
|
|
3
3
|
import { parse } from "acorn";
|
|
4
4
|
|
|
5
5
|
//#region src/normalize.ts
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolveProvider-BZYSw8Qk.cjs","names":["isRecord","lines: string[]","ajv","Ajv","originalToSafeName: Record<string, string>","safeToOriginalName: Record<string, string>","resolvedTools: Record<string, ResolvedToolDescriptor>","typegenTools: Record<string, TypegenToolDescriptor>","ExecuteFailure","isJsonSerializable","isExecuteFailure"],"sources":["../src/identifier.ts","../src/sanitize.ts","../src/schema/normalizeSchema.ts","../src/typegen/render.ts","../src/typegen/jsonSchema.ts","../src/provider/resolveProvider.ts"],"sourcesContent":["const RESERVED_WORDS = new Set([\n \"await\",\n \"break\",\n \"case\",\n \"catch\",\n \"class\",\n \"const\",\n \"continue\",\n \"debugger\",\n \"default\",\n \"delete\",\n \"do\",\n \"else\",\n \"enum\",\n \"export\",\n \"extends\",\n \"false\",\n \"finally\",\n \"for\",\n \"function\",\n \"if\",\n \"import\",\n \"in\",\n \"instanceof\",\n \"new\",\n \"null\",\n \"return\",\n \"super\",\n \"switch\",\n \"this\",\n \"throw\",\n \"true\",\n \"try\",\n \"typeof\",\n \"var\",\n \"void\",\n \"while\",\n \"with\",\n \"yield\",\n]);\n\nconst UNDERSCORE_CHAR_CODE = 95;\n\nfunction trimEdgeUnderscores(value: string): string {\n let start = 0;\n let end = value.length;\n\n while (start < end && value.charCodeAt(start) === UNDERSCORE_CHAR_CODE) {\n start += 1;\n }\n\n while (end > start && value.charCodeAt(end - 1) === UNDERSCORE_CHAR_CODE) {\n end -= 1;\n }\n\n return value.slice(start, end);\n}\n\n/**\n * Returns whether the value is a valid JavaScript identifier.\n */\nexport function isValidIdentifier(value: string): boolean {\n return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(value);\n}\n\n/**\n * Returns whether the identifier is reserved in JavaScript source.\n */\nexport function isReservedWord(value: string): boolean {\n return RESERVED_WORDS.has(value);\n}\n\n/**\n * Throws when the value cannot be used as a bare JavaScript identifier.\n */\nexport function assertValidIdentifier(\n value: string,\n label = \"identifier\",\n): void {\n if (!isValidIdentifier(value) || isReservedWord(value)) {\n throw new Error(`Invalid ${label}: ${value}`);\n }\n}\n\n/**\n * Converts a raw identifier-like value into a safe JavaScript identifier.\n */\nexport function sanitizeIdentifier(value: string): string {\n const sanitized = value.trim().replace(/[^A-Za-z0-9_$]+/g, \"_\");\n\n const trimmed = trimEdgeUnderscores(sanitized);\n\n let safeName = trimmed.length > 0 ? trimmed : \"_\";\n\n if (/^[0-9]/.test(safeName)) {\n safeName = `_${safeName}`;\n }\n\n if (isReservedWord(safeName)) {\n safeName = `${safeName}_`;\n }\n\n return safeName;\n}\n\n/**\n * Renders the name as a bare identifier when possible, otherwise as a string literal.\n */\nexport function serializePropertyName(name: string): string {\n return isValidIdentifier(name) ? name : JSON.stringify(name);\n}\n","import { sanitizeIdentifier } from \"./identifier\";\n\n/**\n * Converts a raw tool name into a safe JavaScript identifier.\n */\nexport function sanitizeToolName(name: string): string {\n return sanitizeIdentifier(name);\n}\n","import * as zod from \"zod\";\nimport type { ZodRawShape, ZodTypeAny } from \"zod\";\n\nimport type { JsonSchema, ToolSchema } from \"../types\";\n\nconst z = \"z\" in zod && typeof zod.z === \"object\" ? zod.z : zod;\nconst toJsonSchema =\n (\"toJSONSchema\" in zod ? zod.toJSONSchema : undefined) ??\n (\"toJSONSchema\" in z ? z.toJSONSchema : undefined);\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n\nfunction isZodSchema(value: unknown): value is ZodTypeAny {\n return isRecord(value) && typeof value.safeParse === \"function\";\n}\n\nfunction isZodRawShape(value: unknown): value is ZodRawShape {\n return (\n isRecord(value) &&\n Object.keys(value).length > 0 &&\n Object.values(value).every(isZodSchema)\n );\n}\n\nfunction normalizeZodSchema(schema: ZodTypeAny): JsonSchema {\n if (typeof toJsonSchema !== \"function\") {\n throw new Error(\"Installed zod package does not expose toJSONSchema\");\n }\n\n const jsonSchema = toJsonSchema(schema) as JsonSchema & {\n $schema?: string;\n };\n\n if (\"$schema\" in jsonSchema) {\n const { $schema: _ignored, ...rest } = jsonSchema;\n return rest;\n }\n\n return jsonSchema;\n}\n\n/**\n * Normalizes supported tool schema inputs to the JSON Schema form used internally.\n */\nexport function normalizeToolSchema(\n schema: ToolSchema | undefined,\n phase: \"input\" | \"output\",\n toolName: string,\n): JsonSchema | undefined {\n if (schema === undefined) {\n return undefined;\n }\n\n if (isZodSchema(schema)) {\n return normalizeZodSchema(schema);\n }\n\n if (isZodRawShape(schema)) {\n return normalizeZodSchema(z.object(schema));\n }\n\n if (isRecord(schema)) {\n return schema;\n }\n\n throw new Error(\n `Unsupported ${phase} schema for tool ${toolName}. Expected JSON Schema, a Zod schema, or an MCP-style Zod shape.`,\n );\n}\n","/**\n * Indents each line of the given string by a specified number of levels.\n */\nexport function indent(value: string, level = 1): string {\n return value\n .split(\"\\n\")\n .map((line) => `${\" \".repeat(level)}${line}`)\n .join(\"\\n\");\n}\n\n/**\n * Renders a short TSDoc-style block when documentation is available.\n */\nexport function renderDocComment(lines: string[]): string {\n if (lines.length === 0) {\n return \"\";\n }\n\n return [\"/**\", ...lines.map((line) => ` * ${line}`), \" */\"].join(\"\\n\");\n}\n\n/**\n * Renders a namespace declaration with optional members.\n */\nexport function renderNamespaceDeclaration(\n name: string,\n members: string[],\n): string {\n if (members.length === 0) {\n return `declare namespace ${name} {}`;\n }\n\n return `declare namespace ${name} {\\n${indent(members.join(\"\\n\\n\"))}\\n}`;\n}\n","import { isValidIdentifier, serializePropertyName } from \"../identifier\";\nimport type { JsonSchema, TypegenToolDescriptor } from \"../types\";\nimport { indent, renderDocComment, renderNamespaceDeclaration } from \"./render\";\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n\nexport { indent } from \"./render\";\n\n/**\n * Converts a supported JSON Schema fragment into a TypeScript type expression.\n */\nexport function schemaToType(\n schema: JsonSchema | undefined,\n level = 0,\n): string {\n if (!schema) {\n return \"unknown\";\n }\n\n if (\n \"allOf\" in schema ||\n \"anyOf\" in schema ||\n \"oneOf\" in schema ||\n \"$ref\" in schema ||\n Array.isArray(schema.type)\n ) {\n return \"unknown\";\n }\n\n switch (schema.type) {\n case \"string\":\n return \"string\";\n case \"number\":\n case \"integer\":\n return \"number\";\n case \"boolean\":\n return \"boolean\";\n case \"null\":\n return \"null\";\n case \"array\": {\n const itemType = schemaToType(\n isRecord(schema.items) ? (schema.items as JsonSchema) : undefined,\n level + 1,\n );\n\n if (isValidIdentifier(itemType)) {\n return `${itemType}[]`;\n }\n\n return `Array<${itemType}>`;\n }\n case \"object\": {\n const properties = isRecord(schema.properties) ? schema.properties : {};\n const required = new Set(\n Array.isArray(schema.required)\n ? schema.required.filter(\n (value): value is string => typeof value === \"string\",\n )\n : [],\n );\n const entries = Object.entries(properties);\n\n if (entries.length === 0) {\n return \"Record<string, unknown>\";\n }\n\n const lines = entries.map(([name, propertySchema]) => {\n const propertyType = schemaToType(\n isRecord(propertySchema) ? (propertySchema as JsonSchema) : undefined,\n level + 1,\n );\n const optionalToken = required.has(name) ? \"\" : \"?\";\n return `${serializePropertyName(name)}${optionalToken}: ${propertyType};`;\n });\n\n return `{\\n${indent(lines.join(\"\\n\"), level + 1)}\\n${\" \".repeat(level)}}`;\n }\n default:\n return \"unknown\";\n }\n}\n\nfunction formatToolDeclaration(\n name: string,\n tool: TypegenToolDescriptor,\n): string {\n const lines: string[] = [];\n const comment = tool.description ? renderDocComment([tool.description]) : \"\";\n if (comment) {\n lines.push(comment);\n }\n\n const inputType = schemaToType(tool.inputSchema);\n const outputType = schemaToType(tool.outputSchema);\n lines.push(`function ${name}(input: ${inputType}): Promise<${outputType}>;`);\n\n return lines.join(\"\\n\");\n}\n\n/**\n * Generates a namespace declaration for a provider's tool schemas.\n */\nexport function generateTypesFromJsonSchema(\n providerName: string,\n tools: Record<string, TypegenToolDescriptor>,\n): string {\n return renderNamespaceDeclaration(\n providerName,\n Object.entries(tools).map(([name, tool]) =>\n formatToolDeclaration(name, tool),\n ),\n );\n}\n","import Ajv, { type AnySchemaObject, type ValidateFunction } from \"ajv\";\n\nimport {\n ExecuteFailure,\n isExecuteFailure,\n isJsonSerializable,\n} from \"../errors\";\nimport { assertValidIdentifier } from \"../identifier\";\nimport { sanitizeToolName } from \"../sanitize\";\nimport { normalizeToolSchema } from \"../schema/normalizeSchema\";\nimport { generateTypesFromJsonSchema } from \"../typegen/jsonSchema\";\nimport type {\n JsonSchema,\n ResolvedToolDescriptor,\n ResolvedToolProvider,\n ToolExecutionContext,\n ToolProvider,\n TypegenToolDescriptor,\n} from \"../types\";\n\nconst DEFAULT_PROVIDER_NAME = \"codemode\";\nfunction assertValidNamespace(name: string): void {\n assertValidIdentifier(name, \"provider namespace\");\n}\n\nfunction compileValidator(\n ajv: Ajv,\n schema: JsonSchema | undefined,\n): ValidateFunction | undefined {\n return schema ? ajv.compile(schema as AnySchemaObject) : undefined;\n}\n\nfunction formatValidationMessage(\n ajv: Ajv,\n phase: \"input\" | \"output\",\n toolName: string,\n validator: ValidateFunction,\n): string {\n return `Invalid ${phase} for tool ${toolName}: ${ajv.errorsText(validator.errors)}`;\n}\n\n/**\n * Resolves a tool provider into the validated, sanitized shape consumed by executors.\n */\nexport function resolveProvider(provider: ToolProvider): ResolvedToolProvider {\n const name = provider.name ?? DEFAULT_PROVIDER_NAME;\n assertValidNamespace(name);\n\n // strict: false allows schemas with extra keywords (e.g. Zod-generated $schema)\n // that don't conform to the strict JSON Schema vocabulary.\n const ajv = new Ajv({\n allErrors: true,\n strict: false,\n });\n\n const originalToSafeName: Record<string, string> = {};\n const safeToOriginalName: Record<string, string> = {};\n const usedSafeNames = new Set<string>();\n const resolvedTools: Record<string, ResolvedToolDescriptor> = {};\n const typegenTools: Record<string, TypegenToolDescriptor> = {};\n\n for (const [originalName, descriptor] of Object.entries(provider.tools)) {\n const baseSafeName = sanitizeToolName(originalName);\n let safeName = baseSafeName;\n let suffix = 2;\n\n while (usedSafeNames.has(safeName)) {\n safeName = `${baseSafeName}__${suffix}`;\n suffix += 1;\n }\n\n usedSafeNames.add(safeName);\n originalToSafeName[originalName] = safeName;\n safeToOriginalName[safeName] = originalName;\n\n const inputSchema = normalizeToolSchema(\n descriptor.inputSchema,\n \"input\",\n originalName,\n );\n const outputSchema = normalizeToolSchema(\n descriptor.outputSchema,\n \"output\",\n originalName,\n );\n const inputValidator = compileValidator(ajv, inputSchema);\n const outputValidator = compileValidator(ajv, outputSchema);\n\n resolvedTools[safeName] = {\n description: descriptor.description,\n execute: async (\n input: unknown,\n context: ToolExecutionContext,\n ): Promise<unknown> => {\n if (inputValidator && !inputValidator(input)) {\n throw new ExecuteFailure(\n \"validation_error\",\n formatValidationMessage(ajv, \"input\", originalName, inputValidator),\n );\n }\n\n try {\n const result = await descriptor.execute(input, context);\n\n if (!isJsonSerializable(result)) {\n throw new ExecuteFailure(\n \"serialization_error\",\n `Tool ${originalName} returned a non-serializable value`,\n );\n }\n\n if (outputValidator && !outputValidator(result)) {\n throw new ExecuteFailure(\n \"validation_error\",\n formatValidationMessage(\n ajv,\n \"output\",\n originalName,\n outputValidator,\n ),\n );\n }\n\n return result;\n } catch (error) {\n if (isExecuteFailure(error)) {\n throw error;\n }\n\n throw new ExecuteFailure(\n \"tool_error\",\n error instanceof Error\n ? error.message\n : `Tool ${originalName} failed`,\n );\n }\n },\n inputSchema,\n originalName,\n outputSchema,\n safeName,\n };\n\n typegenTools[safeName] = {\n description: descriptor.description,\n inputSchema,\n outputSchema,\n };\n }\n\n return {\n name,\n originalToSafeName,\n safeToOriginalName,\n tools: resolvedTools,\n types: provider.types ?? generateTypesFromJsonSchema(name, typegenTools),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAM,iBAAiB,IAAI,IAAI;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAEF,MAAM,uBAAuB;AAE7B,SAAS,oBAAoB,OAAuB;CAClD,IAAI,QAAQ;CACZ,IAAI,MAAM,MAAM;AAEhB,QAAO,QAAQ,OAAO,MAAM,WAAW,MAAM,KAAK,qBAChD,UAAS;AAGX,QAAO,MAAM,SAAS,MAAM,WAAW,MAAM,EAAE,KAAK,qBAClD,QAAO;AAGT,QAAO,MAAM,MAAM,OAAO,IAAI;;;;;AAMhC,SAAgB,kBAAkB,OAAwB;AACxD,QAAO,6BAA6B,KAAK,MAAM;;;;;AAMjD,SAAgB,eAAe,OAAwB;AACrD,QAAO,eAAe,IAAI,MAAM;;;;;AAMlC,SAAgB,sBACd,OACA,QAAQ,cACF;AACN,KAAI,CAAC,kBAAkB,MAAM,I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