effect-codemode 0.0.1 → 0.1.0-beta.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 +638 -2
- package/dist/bridge.d.ts +46 -0
- package/dist/bridge.d.ts.map +1 -0
- package/dist/codemode.d.ts +22 -0
- package/dist/codemode.d.ts.map +1 -0
- package/dist/executor-base.d.ts +25 -0
- package/dist/executor-base.d.ts.map +1 -0
- package/dist/executor.d.ts +18 -0
- package/dist/executor.d.ts.map +1 -0
- package/dist/group.d.ts +71 -0
- package/dist/group.d.ts.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1365 -0
- package/dist/index.js.map +25 -0
- package/dist/middleware.d.ts +18 -0
- package/dist/middleware.d.ts.map +1 -0
- package/dist/registry.d.ts +52 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/sanitize.d.ts +10 -0
- package/dist/sanitize.d.ts.map +1 -0
- package/dist/search.d.ts +35 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/serve.d.ts +35 -0
- package/dist/serve.d.ts.map +1 -0
- package/dist/testing.d.ts +26 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +890 -0
- package/dist/testing.js.map +18 -0
- package/dist/tool.d.ts +69 -0
- package/dist/tool.d.ts.map +1 -0
- package/dist/transport.d.ts +10 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/typegen.d.ts +33 -0
- package/dist/typegen.d.ts.map +1 -0
- package/dist/types.d.ts +69 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +44 -10
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/testing.ts", "../src/bridge.ts", "../src/sanitize.ts", "../src/typegen.ts", "../src/types.ts", "../src/codemode.ts", "../src/executor.ts", "../src/executor-base.ts", "../src/registry.ts", "../src/index.ts", "../src/group.ts", "../src/middleware.ts", "../src/serve.ts", "../src/search.ts", "../src/tool.ts", "../src/transport.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import { Effect, Layer } from \"effect\"\n\nimport type { CodemodeTool } from \"./codemode\"\nimport { createCodemodeTool } from \"./codemode\"\nimport { CodeExecutor } from \"./executor\"\nimport { CodemodeRegistry } from \"./registry\"\nimport { generateDeclarations, type ToolDescriptor as TypegenDescriptor } from \"./typegen\"\nimport type { ToolDescriptor } from \"./types\"\nimport { toTypegenDescriptor } from \"./types\"\n\n/**\n * Shared helper: build a registry from group layers, snapshot it, and merge\n * all available tools. Returns the merged tools, status text, and group names.\n *\n * Used by both `buildTestTool` and `buildInspector` to avoid duplication.\n */\nfunction snapshotGroups(groups: ReadonlyArray<Layer.Layer<CodemodeRegistry, unknown, CodemodeRegistry>>) {\n return Effect.gen(function* () {\n // Create a fresh registry\n const registryImpl = yield* CodemodeRegistry.make\n\n // Build and run all group layers against this registry\n const registryLayer = Layer.succeed(CodemodeRegistry, registryImpl)\n const mergedGroups =\n groups.length === 1\n ? groups[0]!\n : Layer.mergeAll(\n ...(groups as [\n Layer.Layer<CodemodeRegistry, unknown, CodemodeRegistry>,\n Layer.Layer<CodemodeRegistry, unknown, CodemodeRegistry>,\n ...Array<Layer.Layer<CodemodeRegistry, unknown, CodemodeRegistry>>,\n ]),\n )\n const fullLayer = Layer.provide(mergedGroups, registryLayer)\n\n // Build the layer to trigger group registrations\n yield* Layer.build(fullLayer).pipe(Effect.scoped)\n\n // Read the snapshot\n const { available, failed } = yield* registryImpl.snapshot\n\n // Merge all available tools\n const allTools: Record<string, ToolDescriptor> = {}\n for (const group of available) {\n for (const [key, tool] of Object.entries(group.tools)) {\n allTools[key] = { ...tool, service: group.name }\n }\n }\n\n // Build status text\n const statusParts: string[] = []\n for (const g of available) {\n statusParts.push(` ${g.name}: available`)\n }\n for (const f of failed) {\n statusParts.push(` ${f.name}: unavailable (${f.error})`)\n }\n const statusText = statusParts.join(\"\\n\")\n const groupNames = available.map((g) => g.name)\n\n return { allTools, statusText, groupNames }\n })\n}\n\n/**\n * Build a CodemodeTool from group layers synchronously. Intended for use in tests\n * where you want to exercise the full pipeline without starting an MCP server.\n *\n * ```ts\n * import { buildTestTool } from \"effect-codemode/test\"\n * const codemode = buildTestTool(TodoToolsLive, UserToolsLive)\n * const result = await codemode.execute(`Effect.gen(function* () { ... })`)\n * ```\n */\nexport function buildTestTool(\n ...groups: ReadonlyArray<Layer.Layer<CodemodeRegistry, unknown, CodemodeRegistry>>\n): CodemodeTool {\n return Effect.runSync(\n Effect.gen(function* () {\n const { allTools, statusText, groupNames } = yield* snapshotGroups(groups)\n\n // Get a runtime and executor\n const rt = yield* Effect.runtime<never>()\n const exec = yield* Effect.provide(CodeExecutor, CodeExecutor.Default)\n\n return createCodemodeTool(allTools, rt, exec, statusText, [], groupNames)\n }),\n )\n}\n\n/**\n * Return just the TypeScript declarations string for the given group layers.\n * No runtime or executor is created — only resolves tools and generates declarations.\n *\n * ```ts\n * import { buildInspector } from \"effect-codemode/test\"\n * const declarations = buildInspector(TodoToolsLive, UserToolsLive)\n * ```\n */\nexport function buildInspector(\n ...groups: ReadonlyArray<Layer.Layer<CodemodeRegistry, unknown, CodemodeRegistry>>\n): string {\n return Effect.runSync(\n Effect.gen(function* () {\n const { allTools } = yield* snapshotGroups(groups)\n\n // Generate declarations\n const typegenTools: Record<string, TypegenDescriptor> = {}\n for (const [key, tool] of Object.entries(allTools)) {\n typegenTools[key] = toTypegenDescriptor(tool)\n }\n return generateDeclarations(typegenTools)\n }),\n )\n}\n\n// Backward-compatible aliases\nexport { buildTestTool as test, buildInspector as inspect }\n",
|
|
6
|
+
"import { Effect, Exit, Runtime, Schedule, Schema } from \"effect\"\n\nimport { sanitizeToolName } from \"./sanitize\"\nimport type { ToolDescriptor, ToolInvocation, ToolMiddleware } from \"./types\"\n\n// Well-known Effect type ID symbols\nconst OptionTypeId = Symbol.for(\"effect/Option\")\nconst EitherTypeId = Symbol.for(\"effect/Either\")\n\n/**\n * Recursively unwraps Effect tagged types (Option, Either) into plain\n * JSON-friendly values. Uses a WeakSet to safely handle circular references.\n *\n * - Option<A>: Some → unwrapped value, None → null\n * - Either<L, R>: Right → unwrapped right value, Left → { _tag: \"Left\", left: ... }\n * - Arrays: each element recursively unwrapped\n * - Plain objects: each value recursively unwrapped\n */\nexport const unwrapEffectTypes = (value: unknown, seen?: WeakSet<object>): unknown => {\n // Primitives pass through\n if (value === null || value === undefined || typeof value !== \"object\") {\n return value\n }\n\n const obj = value as Record<string | symbol, unknown>\n const tracking = seen ?? new WeakSet<object>()\n\n // Circular reference guard\n if (tracking.has(obj)) {\n return \"[Circular]\"\n }\n tracking.add(obj)\n\n // Option: { [OptionTypeId]: ..., _tag: \"Some\" | \"None\" }\n if (OptionTypeId in obj) {\n if (obj[\"_tag\"] === \"None\") {\n return null\n }\n if (obj[\"_tag\"] === \"Some\") {\n return unwrapEffectTypes(obj[\"value\"], tracking)\n }\n }\n\n // Either: { [EitherTypeId]: ..., _tag: \"Right\" | \"Left\" }\n if (EitherTypeId in obj) {\n if (obj[\"_tag\"] === \"Right\") {\n return unwrapEffectTypes(obj[\"right\"], tracking)\n }\n if (obj[\"_tag\"] === \"Left\") {\n return { _tag: \"Left\", left: unwrapEffectTypes(obj[\"left\"], tracking) }\n }\n }\n\n // Arrays\n if (Array.isArray(obj)) {\n return obj.map((item) => unwrapEffectTypes(item, tracking))\n }\n\n // Plain objects — recurse over own enumerable string keys\n const result: Record<string, unknown> = {}\n for (const key of Object.keys(obj)) {\n result[key] = unwrapEffectTypes(obj[key], tracking)\n }\n return result\n}\n\n/**\n * Maximum number of retry attempts for rate-limited requests.\n */\nconst MAX_RETRIES = 3\n\n/**\n * Returns whether an error looks like a rate limit error:\n * - Effect TaggedError with _tag \"RateLimitError\"\n * - Any error object with a status of 429\n */\nconst isRateLimitError = (err: unknown): err is { _tag: string; retryAfter?: number; status?: number } => {\n if (typeof err !== \"object\" || err === null) return false\n const obj = err as Record<string, unknown>\n if (obj[\"_tag\"] === \"RateLimitError\") return true\n if (obj[\"status\"] === 429) return true\n return false\n}\n\n/**\n * Waits for a backoff duration. Uses `retryAfter` from the error if available,\n * otherwise exponential backoff: 1s, 2s, 4s.\n */\nconst backoff = (attempt: number, retryAfterSeconds?: number): Promise<void> => {\n const ms = retryAfterSeconds !== undefined ? retryAfterSeconds * 1000 : Math.pow(2, attempt) * 1000\n return new Promise((resolve) => setTimeout(resolve, ms))\n}\n\n/**\n * Composes an array of middleware into a single wrapper around a base Effect.\n * Middleware are applied in order: the first middleware in the array is the\n * outermost wrapper. Each middleware receives `next` which is the rest of the\n * chain (subsequent middleware + the base effect).\n */\nconst applyMiddleware = (\n middlewares: ReadonlyArray<ToolMiddleware>,\n invocation: ToolInvocation,\n base: Effect.Effect<unknown, unknown>,\n): Effect.Effect<unknown, unknown> => {\n // Build the chain from right to left: last middleware wraps the base first\n let current = base\n for (let i = middlewares.length - 1; i >= 0; i--) {\n const mw = middlewares[i]!\n const next = current\n current = mw(invocation, next)\n }\n return current\n}\n\nexport interface EffectToAsyncFnOptions {\n /** Whether to validate output against the tool's outputSchema (default: true) */\n readonly validateOutput?: boolean | undefined\n /** Middleware to wrap around each tool execution */\n readonly middleware?: ReadonlyArray<ToolMiddleware> | undefined\n}\n\n/**\n * Converts a single Effect-based tool into a plain async function\n * using a captured Effect Runtime. Unwraps Effect types (Option, Either)\n * from the return value and retries on rate limit errors.\n */\nexport const effectToAsyncFn = <R>(\n tool: ToolDescriptor,\n runtime: Runtime.Runtime<R>,\n options?: EffectToAsyncFnOptions,\n): ((rawInput: unknown) => Promise<unknown>) => {\n const shouldValidateOutput = options?.validateOutput !== false\n\n const middlewares = options?.middleware ?? []\n\n return async (rawInput: unknown): Promise<unknown> => {\n // Decode input through the tool's schema\n const decoded = Schema.decodeUnknownSync(tool.inputSchema as Schema.Schema<unknown, unknown, never>)(rawInput)\n\n let lastError: unknown\n\n for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {\n // Back off before retrying (skip on first attempt)\n if (attempt > 0) {\n const retryAfter = isRateLimitError(lastError) ? lastError.retryAfter : undefined\n await backoff(attempt - 1, retryAfter)\n }\n\n // Build the Effect with middleware applied\n let effect = tool.execute(decoded) as Effect.Effect<unknown, unknown, R>\n\n if (middlewares.length > 0) {\n const invocation: ToolInvocation = { name: tool.name, input: decoded }\n const provided = Effect.provide(effect, runtime.context) as Effect.Effect<unknown, unknown>\n effect = applyMiddleware(middlewares, invocation, provided) as Effect.Effect<unknown, unknown, R>\n }\n\n // Run the Effect program using the captured runtime\n const exit = await Runtime.runPromiseExit(runtime)(effect)\n\n if (Exit.isSuccess(exit)) {\n const unwrapped = unwrapEffectTypes(exit.value)\n\n // Lenient output validation: warn on mismatch but still return raw result\n if (shouldValidateOutput && tool.outputSchema) {\n try {\n Schema.decodeUnknownSync(tool.outputSchema as Schema.Schema<unknown, unknown, never>, {\n onExcessProperty: \"preserve\",\n })(unwrapped)\n } catch (e) {\n console.warn(\n `[codemode] Output validation warning for tool \"${tool.name}\":`,\n e instanceof Error ? e.message : String(e),\n )\n }\n }\n\n return unwrapped\n }\n\n // On failure, extract a useful error\n const cause = exit.cause\n const failure = cause._tag === \"Fail\" ? cause.error : cause\n const error: Record<string, unknown> = {\n _tag:\n typeof failure === \"object\" && failure !== null && \"_tag\" in failure\n ? (failure as { _tag: string })._tag\n : \"ExecutionError\",\n message:\n typeof failure === \"object\" && failure !== null && \"message\" in failure\n ? (failure as { message: string }).message\n : String(failure),\n }\n\n // Flatten all error fields to top level (matches generated type shape)\n if (typeof failure === \"object\" && failure !== null) {\n for (const [k, v] of Object.entries(failure)) {\n if (k !== \"_tag\" && k !== \"message\") {\n error[k] = v\n }\n }\n }\n\n // Retry on rate limit errors, throw immediately on anything else\n if (isRateLimitError(error) && attempt < MAX_RETRIES) {\n lastError = error\n continue\n }\n\n throw error\n }\n\n // Should be unreachable, but satisfies the type checker\n throw lastError\n }\n}\n\n/**\n * Builds a table of plain async functions from an array of tool descriptors\n * and a captured Effect Runtime.\n */\nexport const buildFnTable = <R>(\n tools: ReadonlyArray<ToolDescriptor>,\n runtime: Runtime.Runtime<R>,\n options?: EffectToAsyncFnOptions,\n): Record<string, (...args: Array<unknown>) => Promise<unknown>> => {\n const table: Record<string, (...args: Array<unknown>) => Promise<unknown>> = {}\n\n for (const tool of tools) {\n const fn = effectToAsyncFn(tool, runtime, options)\n const key = sanitizeToolName(tool.name)\n // Wrap to accept spread args — the first arg is the input object\n table[key] = async (...args: Array<unknown>) => fn(args[0])\n }\n\n return table\n}\n\n/**\n * Converts a single Effect-based tool into a function that returns an Effect.\n * The returned Effect decodes input, calls the service, unwraps Effect types,\n * and keeps errors in the Effect error channel (no throwing).\n *\n * Rate limit errors are retried using Effect.retry with exponential backoff.\n */\nexport const effectToEffectFn = <R>(\n tool: ToolDescriptor,\n runtime: Runtime.Runtime<R>,\n options?: EffectToAsyncFnOptions,\n): ((rawInput: unknown) => Effect.Effect<unknown, unknown>) => {\n const shouldValidateOutput = options?.validateOutput !== false\n const middlewares = options?.middleware ?? []\n\n return (rawInput: unknown): Effect.Effect<unknown, unknown> => {\n const decoded = Schema.decodeUnknownSync(tool.inputSchema as Schema.Schema<unknown, unknown, never>)(rawInput)\n\n const baseEffect: Effect.Effect<unknown, unknown> = Effect.flatMap(\n Effect.provide(tool.execute(decoded), runtime.context) as Effect.Effect<unknown, unknown>,\n (value) => {\n const unwrapped = unwrapEffectTypes(value)\n\n if (shouldValidateOutput && tool.outputSchema) {\n try {\n Schema.decodeUnknownSync(tool.outputSchema as Schema.Schema<unknown, unknown, never>, {\n onExcessProperty: \"preserve\",\n })(unwrapped)\n } catch (e) {\n console.warn(\n `[codemode] Output validation warning for tool \"${tool.name}\":`,\n e instanceof Error ? e.message : String(e),\n )\n }\n }\n\n return Effect.succeed(unwrapped)\n },\n )\n\n // Apply middleware chain around the base effect\n const withMiddleware =\n middlewares.length > 0\n ? applyMiddleware(middlewares, { name: tool.name, input: decoded }, baseEffect)\n : baseEffect\n\n // Retry rate limit errors with exponential backoff (1s, 2s, 4s)\n const retrySchedule = Schedule.exponential(\"1 second\").pipe(Schedule.compose(Schedule.recurs(MAX_RETRIES)))\n\n return withMiddleware.pipe(\n Effect.retry({\n schedule: retrySchedule,\n while: (err) => isRateLimitError(err),\n }),\n )\n }\n}\n\n/**\n * Builds a table of Effect-returning functions from an array of tool\n * descriptors and a captured Effect Runtime.\n *\n * Each function in the table takes an input and returns an\n * `Effect<unknown, unknown>` — errors stay in the Effect error channel.\n */\nexport const buildEffectFnTable = <R>(\n tools: ReadonlyArray<ToolDescriptor>,\n runtime: Runtime.Runtime<R>,\n options?: EffectToAsyncFnOptions,\n): Record<string, (...args: Array<unknown>) => Effect.Effect<unknown, unknown>> => {\n const table: Record<string, (...args: Array<unknown>) => Effect.Effect<unknown, unknown>> = {}\n\n for (const tool of tools) {\n const fn = effectToEffectFn(tool, runtime, options)\n const key = sanitizeToolName(tool.name)\n table[key] = (...args: Array<unknown>) => fn(args[0])\n }\n\n return table\n}\n",
|
|
7
|
+
"/**\n * Sanitizes a tool name so it can be used as a valid JavaScript identifier.\n *\n * - Replaces `-`, `.`, and spaces with `_`\n * - Strips remaining non-identifier characters\n * - Prefixes digit-leading names with `_`\n * - Appends `_` to JS reserved words\n */\n\nconst JS_RESERVED = new Set([\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 \"let\",\n \"new\",\n \"null\",\n \"return\",\n \"super\",\n \"switch\",\n \"this\",\n \"throw\",\n \"true\",\n \"try\",\n \"typeof\",\n \"undefined\",\n \"var\",\n \"void\",\n \"while\",\n \"with\",\n \"yield\",\n \"await\",\n \"static\",\n \"implements\",\n \"interface\",\n \"package\",\n \"private\",\n \"protected\",\n \"public\",\n])\n\nexport function sanitizeToolName(name: string): string {\n // Replace common separators with underscores\n let result = name.replace(/[-.\\s]/g, \"_\")\n\n // Strip any remaining characters that aren't valid in identifiers\n result = result.replace(/[^a-zA-Z0-9_$]/g, \"\")\n\n // Empty after stripping — fallback\n if (result.length === 0) return \"_\"\n\n // Prefix digit-leading names\n if (/^\\d/.test(result)) {\n result = `_${result}`\n }\n\n // Append underscore to reserved words\n if (JS_RESERVED.has(result)) {\n result = `${result}_`\n }\n\n return result\n}\n",
|
|
8
|
+
"import { Option } from \"effect\"\nimport * as SchemaAST from \"effect/SchemaAST\"\n\nimport { sanitizeToolName } from \"./sanitize\"\n\n/**\n * Describes an error type for typegen.\n * - `string` form: just the tag name (e.g. \"NotFoundError\") — generates a minimal type with `_tag` and `message`.\n * - `object` form: tag name plus the full SchemaAST — generates a complete type with all fields.\n */\nexport type ErrorDescriptor =\n | string\n | {\n readonly tag: string\n readonly ast: SchemaAST.AST\n }\n\nexport interface ToolDescriptor {\n readonly name: string\n readonly description: string\n readonly inputSchema: SchemaAST.AST\n readonly outputSchema?: SchemaAST.AST | undefined\n readonly errors?: ReadonlyArray<ErrorDescriptor> | undefined\n}\n\n/**\n * Walk an Effect SchemaAST and produce a TypeScript type string.\n */\nexport function astToTypeScript(ast: SchemaAST.AST, seen = new Set<SchemaAST.AST>()): string {\n switch (ast._tag) {\n case \"StringKeyword\":\n return \"string\"\n case \"NumberKeyword\":\n return \"number\"\n case \"BooleanKeyword\":\n return \"boolean\"\n case \"BigIntKeyword\":\n return \"bigint\"\n case \"UndefinedKeyword\":\n return \"undefined\"\n case \"VoidKeyword\":\n return \"void\"\n case \"NeverKeyword\":\n return \"never\"\n case \"UnknownKeyword\":\n return \"unknown\"\n case \"AnyKeyword\":\n return \"any\"\n case \"ObjectKeyword\":\n return \"object\"\n case \"SymbolKeyword\":\n return \"symbol\"\n case \"UniqueSymbol\":\n return `typeof ${String(ast.symbol)}`\n\n case \"Literal\": {\n if (ast.literal === null) return \"null\"\n if (typeof ast.literal === \"string\") return JSON.stringify(ast.literal)\n return String(ast.literal)\n }\n\n case \"Enums\":\n return ast.enums.map(([_, v]) => JSON.stringify(v)).join(\" | \") || \"never\"\n\n case \"TemplateLiteral\": {\n const spans = ast.spans\n .map((s) => {\n const t =\n s.type._tag === \"StringKeyword\"\n ? \"string\"\n : s.type._tag === \"NumberKeyword\"\n ? \"number\"\n : astToTypeScript(s.type as SchemaAST.AST, seen)\n return `\\${${t}}${s.literal}`\n })\n .join(\"\")\n return `\\`${ast.head}${spans}\\``\n }\n\n case \"Union\":\n return ast.types.map((t) => astToTypeScript(t, seen)).join(\" | \")\n\n case \"TupleType\": {\n const elems = ast.elements.map((e) => {\n const t = astToTypeScript(e.type, seen)\n return e.isOptional ? `${t}?` : t\n })\n if (ast.rest.length > 0) {\n const restType = astToTypeScript(ast.rest[0]!.type, seen)\n if (ast.elements.length === 0) return `Array<${restType}>`\n elems.push(`...Array<${restType}>`)\n }\n return `[${elems.join(\", \")}]`\n }\n\n case \"TypeLiteral\": {\n if (ast.propertySignatures.length === 0 && ast.indexSignatures.length === 0) {\n return \"{}\"\n }\n const props = ast.propertySignatures.map((ps) => {\n const key =\n typeof ps.name === \"string\"\n ? /^[a-zA-Z_$][\\w$]*$/.test(ps.name)\n ? ps.name\n : JSON.stringify(ps.name)\n : `[${String(ps.name)}]`\n const opt = ps.isOptional ? \"?\" : \"\"\n return ` ${key}${opt}: ${astToTypeScript(ps.type, seen)}`\n })\n const idxSigs = ast.indexSignatures.map((is) => {\n const param = astToTypeScript(is.parameter, seen)\n return ` [key: ${param}]: ${astToTypeScript(is.type, seen)}`\n })\n return `{\\n${[...props, ...idxSigs].join(\"\\n\")}\\n}`\n }\n\n case \"Refinement\":\n return astToTypeScript(ast.from, seen)\n\n case \"Transformation\":\n return astToTypeScript(ast.to, seen)\n\n case \"Suspend\": {\n const id = Option.getOrUndefined(SchemaAST.getIdentifierAnnotation(ast))\n if (id) return id\n if (seen.has(ast)) return \"unknown\"\n seen.add(ast)\n return astToTypeScript(ast.f(), seen)\n }\n\n case \"Declaration\": {\n const id = Option.getOrUndefined(SchemaAST.getIdentifierAnnotation(ast))\n return id ?? \"unknown\"\n }\n\n default:\n return \"unknown\"\n }\n}\n\nfunction toPascalCase(name: string): string {\n return name\n .split(/[-_]/)\n .map((s) => s.charAt(0).toUpperCase() + s.slice(1))\n .join(\"\")\n}\n\nfunction fieldDescription(ast: SchemaAST.AST): string | undefined {\n const direct = Option.getOrUndefined(SchemaAST.getDescriptionAnnotation(ast))\n if (direct) return direct\n // For optional fields: Union(T, UndefinedKeyword) — check non-undefined members\n if (ast._tag === \"Union\") {\n for (const member of ast.types) {\n if (member._tag === \"UndefinedKeyword\") continue\n const desc = Option.getOrUndefined(SchemaAST.getDescriptionAnnotation(member))\n if (desc) return desc\n }\n }\n return undefined\n}\n\nfunction resolveTypeLiteral(ast: SchemaAST.AST): SchemaAST.AST {\n if (ast._tag === \"Transformation\") return ast.to\n return ast\n}\n\nfunction buildJSDoc(description: string, inputAst?: SchemaAST.AST, errors?: ReadonlyArray<ErrorDescriptor>): string {\n const lines: string[] = [`/** ${description}`]\n if (inputAst) {\n const resolved = resolveTypeLiteral(inputAst)\n if (resolved._tag === \"TypeLiteral\") {\n for (const ps of resolved.propertySignatures) {\n const desc = fieldDescription(ps.type)\n if (desc) lines.push(` * @param ${String(ps.name)} - ${desc}`)\n }\n }\n }\n if (errors && errors.length > 0) {\n for (const err of errors) {\n const tag = errorTag(err)\n lines.push(` * @error ${tag} — catchable with Effect.catchTag(\"${tag}\", ...)`)\n }\n }\n lines.push(\" */\")\n return lines.join(\"\\n\")\n}\n\n/**\n * Extract the tag name from an ErrorDescriptor.\n */\nfunction errorTag(error: ErrorDescriptor): string {\n return typeof error === \"string\" ? error : error.tag\n}\n\n/**\n * Build a TypeScript type declaration for an error.\n *\n * When a rich AST is available, generates the full type with all fields.\n * Otherwise, falls back to the minimal `{ _tag, message }` shape.\n */\nfunction buildErrorType(error: ErrorDescriptor): string {\n const tag = errorTag(error)\n if (typeof error === \"string\") {\n return `type ${tag} = { readonly _tag: \"${tag}\"; readonly message: string }`\n }\n // Rich error: walk the AST to generate all fields\n const typeString = astToTypeScript(error.ast)\n return `type ${tag} = ${typeString}`\n}\n\n/**\n * Resolve the best name for a shared output schema.\n *\n * Prefers the SchemaAST identifier annotation (e.g. \"Issue\", \"User\").\n * Falls back to the PascalCase name derived from the first tool that uses it.\n */\nfunction resolveSharedOutputName(ast: SchemaAST.AST | undefined, firstToolKey: string): string {\n if (ast) {\n // Check the outer AST node first\n const id = Option.getOrUndefined(SchemaAST.getIdentifierAnnotation(ast))\n if (id) return id\n // For Transformations, also check the decoded (to) side\n if (ast._tag === \"Transformation\") {\n const toId = Option.getOrUndefined(SchemaAST.getIdentifierAnnotation(ast.to))\n if (toId) return toId\n }\n }\n return `${toPascalCase(sanitizeToolName(firstToolKey))}Output`\n}\n\n/**\n * Generate TypeScript declarations for a set of tool descriptors.\n *\n * Methods return `Effect<Output, ErrorType>` for use in Effect.gen programs.\n * Error types are generated as tagged union members.\n *\n * When multiple tools share an identical output schema, the type is emitted\n * once (using the schema's identifier annotation if available) and referenced\n * by name in each method signature.\n */\nexport function generateDeclarations(tools: Record<string, ToolDescriptor>): string {\n const entries = Object.entries(tools)\n\n // --- Phase 1: compute output type strings and group duplicates -----------\n // Map from generated type string -> { name, keys[] }\n const outputTypeStringToGroup = new Map<string, { name: string; keys: string[] }>()\n // Map from tool key -> the output type name to use in its signature\n const toolOutputTypeName = new Map<string, string>()\n\n for (const [key, tool] of entries) {\n const typeString = tool.outputSchema ? astToTypeScript(tool.outputSchema) : \"unknown\"\n\n const existing = outputTypeStringToGroup.get(typeString)\n if (existing) {\n existing.keys.push(key)\n } else {\n outputTypeStringToGroup.set(typeString, { name: \"\", keys: [key] })\n }\n }\n\n // Assign names: shared groups get a shared name, singletons get PerToolOutput\n for (const [_typeString, group] of outputTypeStringToGroup) {\n if (group.keys.length > 1) {\n // Shared — use identifier annotation or derive from first tool\n const firstTool = tools[group.keys[0]!]!\n group.name = resolveSharedOutputName(firstTool.outputSchema, group.keys[0]!)\n } else {\n // Singleton — use the classic per-tool naming\n const key = group.keys[0]!\n group.name = `${toPascalCase(sanitizeToolName(key))}Output`\n }\n for (const key of group.keys) {\n toolOutputTypeName.set(key, group.name)\n }\n }\n\n // --- Phase 2: emit declarations ------------------------------------------\n const parts: string[] = []\n const methods: string[] = []\n const emittedErrors = new Set<string>()\n const emittedOutputTypes = new Set<string>()\n\n for (const [key, tool] of entries) {\n const safeName = sanitizeToolName(key)\n const pascal = toPascalCase(safeName)\n const inputType = `${pascal}Input`\n const outputType = toolOutputTypeName.get(key)!\n\n parts.push(`type ${inputType} = ${astToTypeScript(tool.inputSchema)}`)\n\n // Only emit each output type declaration once\n if (!emittedOutputTypes.has(outputType)) {\n emittedOutputTypes.add(outputType)\n const typeString = tool.outputSchema ? astToTypeScript(tool.outputSchema) : \"unknown\"\n parts.push(`type ${outputType} = ${typeString}`)\n }\n\n // Collect error types for this tool\n if (tool.errors && tool.errors.length > 0) {\n for (const err of tool.errors) {\n const tag = errorTag(err)\n if (!emittedErrors.has(tag)) {\n emittedErrors.add(tag)\n parts.push(buildErrorType(err))\n }\n }\n }\n\n // Build Effect return type: Effect<Output, Error1 | Error2> or Effect<Output, never>\n const errorType = tool.errors && tool.errors.length > 0 ? tool.errors.map((e) => errorTag(e)).join(\" | \") : \"never\"\n\n const jsdoc = buildJSDoc(tool.description, tool.inputSchema, tool.errors)\n methods.push(` ${jsdoc}\\n ${safeName}(input: ${inputType}): Effect<${outputType}, ${errorType}>`)\n }\n\n parts.push(\"\")\n parts.push(`declare const codemode: {\\n${methods.join(\"\\n\")}\\n}`)\n\n return parts.join(\"\\n\\n\")\n}\n",
|
|
9
|
+
"import { Effect, Schema } from \"effect\"\nimport * as SchemaAST from \"effect/SchemaAST\"\n\nimport type { ErrorDescriptor, ToolDescriptor as TypegenDescriptor } from \"./typegen\"\n\n/**\n * Describes a tool that can be bridged from an Effect service to a plain async function.\n */\nexport interface ToolDescriptor {\n readonly name: string\n readonly description: string\n readonly example?: string | undefined\n readonly inputSchema: Schema.Schema.Any\n readonly outputSchema?: Schema.Schema.Any | undefined\n readonly errors?: ReadonlyArray<ErrorDescriptor> | undefined\n readonly service?: string | undefined\n readonly requiresConfirmation?: boolean | undefined\n readonly middleware?: ReadonlyArray<ToolMiddleware> | undefined\n readonly execute: (input: unknown) => Effect.Effect<unknown, unknown, unknown>\n}\n\n/**\n * Context passed to each middleware function, describing the tool being invoked.\n */\nexport interface ToolInvocation {\n readonly name: string\n readonly input: unknown\n}\n\n/**\n * A middleware function that wraps tool execution.\n *\n * Receives the tool invocation context and a `next` Effect representing\n * the downstream execution (either the next middleware or the tool itself).\n * Must return an Effect that produces the tool result.\n *\n * ```ts\n * const logging: ToolMiddleware = (tool, next) =>\n * Effect.gen(function* () {\n * console.log(`Calling ${tool.name}`)\n * const result = yield* next\n * console.log(`Done ${tool.name}`)\n * return result\n * })\n * ```\n */\nexport type ToolMiddleware = (\n tool: ToolInvocation,\n next: Effect.Effect<unknown, unknown>,\n) => Effect.Effect<unknown, unknown>\n\n/**\n * Result of executing user-provided code in the sandbox.\n */\nexport interface ExecuteResult {\n readonly result: unknown\n readonly error?: string\n readonly logs: string[]\n}\n\n/**\n * Interface for code execution engines.\n */\nexport interface ExecutorOptions {\n /** Called for each console.log/warn/error/info/debug from sandbox code — use for streaming progress */\n readonly onLog?: (level: string, message: string) => void\n /** Whether to allow network access (fetch, URL, Request, Headers, Response) in the sandbox. Defaults to true. */\n readonly allowNetwork?: boolean\n /** Maximum execution time in milliseconds. */\n readonly timeoutMs?: number | undefined\n}\n\nexport interface Executor {\n readonly execute: (\n code: string,\n fns: Record<string, (...args: Array<unknown>) => unknown>,\n options?: ExecutorOptions,\n ) => Promise<ExecuteResult>\n}\n\n/**\n * Convert a tool descriptor (Schema.Schema.Any) to typegen format (SchemaAST.AST).\n */\nexport function toTypegenDescriptor(tool: ToolDescriptor): TypegenDescriptor {\n return {\n name: tool.name,\n description: tool.description,\n inputSchema: (tool.inputSchema as { ast: SchemaAST.AST }).ast,\n outputSchema: tool.outputSchema ? (tool.outputSchema as { ast: SchemaAST.AST }).ast : undefined,\n errors: tool.errors,\n }\n}\n",
|
|
10
|
+
"import { Runtime } from \"effect\"\n\nimport { buildEffectFnTable } from \"./bridge\"\nimport { generateDeclarations, type ToolDescriptor as TypegenDescriptor } from \"./typegen\"\nimport type { ExecuteResult, Executor, ExecutorOptions, ToolDescriptor, ToolMiddleware } from \"./types\"\nimport { toTypegenDescriptor } from \"./types\"\n\nexport interface CodemodeTool {\n /** The tool name for MCP registration */\n readonly name: string\n /** Full description including generated TS declarations */\n readonly description: string\n /** The generated TypeScript declarations (for debugging/display) */\n readonly declarations: string\n /** Execute LLM-generated code, optionally streaming console output */\n readonly execute: (code: string, options?: ExecutorOptions) => Promise<ExecuteResult>\n}\n\n/**\n * Pick up to `max` representative examples from tool shapes, spanning different groups.\n */\nfunction buildExamplesBlock(tools: Record<string, ToolDescriptor>, max: number = 3): string {\n const withExamples = Object.entries(tools).filter(([_, t]) => t.example)\n if (withExamples.length === 0) return \"\"\n\n // Try to pick from different services for diversity\n const seen = new Set<string>()\n const picked: Array<[string, ToolDescriptor]> = []\n\n for (const [key, tool] of withExamples) {\n const svc = tool.service ?? \"unknown\"\n if (!seen.has(svc) && picked.length < max) {\n seen.add(svc)\n picked.push([key, tool])\n }\n }\n\n // Fill remaining slots if we have room\n for (const entry of withExamples) {\n if (picked.length >= max) break\n if (!picked.includes(entry)) {\n picked.push(entry)\n }\n }\n\n const lines = picked.map(([key, tool]) => `**${key}:**\\n\\`\\`\\`typescript\\n${tool.example}\\n\\`\\`\\``)\n\n return `\\n\\nExamples:\\n\\n${lines.join(\"\\n\\n\")}`\n}\n\nconst COMPACT_THRESHOLD = 7\n\n/**\n * Creates the codemode tool by wiring together:\n * - Type generation (for the LLM prompt)\n * - The fn table (Effect services -> plain async functions)\n * - The executor (sandbox)\n *\n * Accepts sandbox tools only — confirmation tools should be split out before calling.\n */\nexport function createCodemodeTool<R>(\n sandboxTools: Record<string, ToolDescriptor>,\n runtime: Runtime.Runtime<R>,\n executor: Executor,\n serviceStatuses?: string,\n middleware?: ReadonlyArray<ToolMiddleware>,\n groupNames?: ReadonlyArray<string>,\n): CodemodeTool {\n // Generate TypeScript declarations for the LLM (sandbox tools only)\n const typegenTools: Record<string, TypegenDescriptor> = {}\n for (const [key, tool] of Object.entries(sandboxTools)) {\n typegenTools[key] = toTypegenDescriptor(tool)\n }\n const declarations = generateDeclarations(typegenTools)\n\n // Build Effect-returning function table from sandbox tools only\n const tools = Object.values(sandboxTools)\n const fns = buildEffectFnTable(tools, runtime, { middleware })\n\n const statusBlock = serviceStatuses ? `\\nService status:\\n${serviceStatuses}\\n` : \"\"\n\n // Dynamic service list from group names or fallback\n const serviceList = groupNames && groupNames.length > 0 ? groupNames.join(\", \") : \"configured services\"\n\n // Dynamic examples from tool shapes\n const examplesBlock = buildExamplesBlock(sandboxTools)\n\n const toolCount = Object.keys(sandboxTools).length\n const isCompact = toolCount > COMPACT_THRESHOLD\n\n let apiBlock: string\n if (isCompact) {\n // Compact: one-line summaries with instruction to use search_tools for full types\n const catalog = Object.entries(sandboxTools)\n .map(([key, tool]) => ` ${key}(input): ${tool.description}`)\n .join(\"\\n\")\n apiBlock = `Available API (${toolCount} tools — use \\`search_tools\\` for full type signatures):\n\n${catalog}`\n } else {\n // Full declarations inline\n apiBlock = `Available API:\n\n\\`\\`\\`typescript\n${declarations}\n\\`\\`\\``\n }\n\n const description = `Execute TypeScript code using Effect to orchestrate operations across ${serviceList}.\n\nThe sandbox has \\`Effect\\`, \\`pipe\\`, \\`Duration\\`, \\`Schedule\\`, \\`Option\\`, \\`Either\\`, \\`Match\\`, \\`Schema\\`, \\`Arr\\` (Effect's Array module), \\`Ref\\`, \\`Stream\\`, \\`Chunk\\`, \\`Data\\`, \\`Order\\`, and \\`Predicate\\` available as globals.\nEach method on \\`codemode\\` returns an \\`Effect\\` — use \\`yield*\\` inside \\`Effect.gen\\` to unwrap values.\nReturn an Effect as the final value and the runtime will execute it.\n${statusBlock}\n\n${apiBlock}\n\nWrite an \\`Effect.gen\\` program that calls methods on the \\`codemode\\` object using \\`yield*\\`.\nReturn a value from the generator to send results back.\n${examplesBlock}\n\n**Error handling with catchTag** — gracefully catch service-specific errors:\n\\`\\`\\`typescript\nEffect.gen(function* () {\n return yield* codemode.some_tool({ id: \"nonexistent\" })\n}).pipe(\n Effect.catchTag(\"NotFoundError\", (e) => Effect.succeed({ error: e.message }))\n)\n\\`\\`\\`\n\n**Retry with backoff** — retry a flaky operation:\n\\`\\`\\`typescript\nEffect.gen(function* () {\n return yield* codemode.some_tool({ id: \"ID\" })\n}).pipe(\n Effect.retry({ times: 3, schedule: Schedule.exponential(\"1 second\") })\n)\n\\`\\`\\`\n\n**Timeout** — bail if an operation takes too long:\n\\`\\`\\`typescript\nEffect.gen(function* () {\n return yield* codemode.some_tool({})\n}).pipe(\n Effect.timeout(\"10 seconds\")\n)\n\\`\\`\\`\n\n**Backward compatibility** — async/await still works:\n\\`\\`\\`typescript\nasync () => {\n const result = await Effect.runPromise(codemode.some_tool({}))\n return result\n}\n\\`\\`\\``\n\n return {\n name: \"execute_code\",\n description,\n declarations,\n execute: (code: string, options?: ExecutorOptions) => executor.execute(code, fns, options),\n }\n}\n",
|
|
11
|
+
"import * as vm from \"node:vm\"\n\nimport { Context, Layer } from \"effect\"\n\nimport { createBaseExecutor, normalizeCode } from \"./executor-base\"\nimport type { Executor } from \"./types\"\n\n// Re-export normalizeCode so existing imports from \"./executor\" still work\nexport { normalizeCode } from \"./executor-base\"\n\n/**\n * Direct executor: uses `new Function()` with a curated set of globals.\n */\nconst createDirectExecutor = (): Executor =>\n createBaseExecutor(async (wrappedCode, globals) => {\n const paramNames = Object.keys(globals)\n const paramValues = Object.values(globals)\n const fn = new Function(...paramNames, wrappedCode)\n return fn(...paramValues)\n })\n\n/**\n * VM executor: uses node:vm for stronger isolation than new Function().\n *\n * normalizeCode produces function-body code (with `return` statements),\n * but vm.Script runs as a program where top-level `return` is illegal.\n * Strip the leading `return ` so the expression is evaluated directly.\n */\nconst createVmExecutor = (): Executor =>\n createBaseExecutor(async (wrappedCode, globals) => {\n // normalizeCode outputs \"return <expr>\" — strip \"return \" for vm script context\n const scriptCode = wrappedCode.startsWith(\"return \")\n ? wrappedCode.slice(7)\n : wrappedCode\n const context = vm.createContext(globals)\n const script = new vm.Script(scriptCode)\n return script.runInContext(context, { timeout: 35_000 }) as Promise<unknown>\n })\n\n/**\n * Effect service for code execution.\n *\n * Provides multiple Layer implementations following the @effect/platform pattern:\n * - `CodeExecutor.Direct` — uses `new Function()` (fast, less isolated)\n * - `CodeExecutor.Vm` — uses `node:vm` (stronger isolation)\n * - `CodeExecutor.Default` — alias for `Vm`\n */\nexport class CodeExecutor extends Context.Tag(\"@effect-codemode/Executor\")<CodeExecutor, Executor>() {\n static readonly Direct = Layer.succeed(CodeExecutor, createDirectExecutor())\n static readonly Vm = Layer.succeed(CodeExecutor, createVmExecutor())\n static readonly Default = CodeExecutor.Vm\n}\n",
|
|
12
|
+
"import * as acorn from \"acorn\"\nimport {\n Array as Arr,\n Chunk,\n Data,\n Duration,\n Effect,\n Either,\n Match,\n Option,\n Order,\n Predicate,\n Ref,\n Schedule,\n Schema,\n Stream,\n pipe,\n} from \"effect\"\n\nimport type { ExecuteResult, Executor, ExecutorOptions } from \"./types\"\n\n// Well-known Effect type ID symbol for runtime detection\nconst EffectTypeId = Symbol.for(\"effect/Effect\")\n\nconst DEFAULT_TIMEOUT_MS = 30_000\n\n// Bun.Transpiler for stripping TypeScript syntax — zero dependencies, ~120μs per transform.\n// Resolves at module load: uses Bun.Transpiler when running on Bun, identity function otherwise.\n//\n// IMPORTANT: Bun.Transpiler performs dead-code elimination, which removes bare expressions\n// like `() => 42`, `42`, and `async () => { ... }` that aren't assigned or called.\n// To prevent this, we first try wrapping the code as `export default (code)` which forces\n// the transpiler to preserve the expression. Falls back to raw transpile for multi-statement code.\nconst stripTypeScript: (code: string) => string = (() => {\n const g = globalThis as Record<string, unknown>\n if (typeof g[\"Bun\"] === \"object\" && g[\"Bun\"] !== null) {\n const BunNs = g[\"Bun\"] as { Transpiler: new (opts: { loader: string }) => { transformSync: (code: string) => string } }\n const transpiler = new BunNs.Transpiler({ loader: \"ts\" })\n const WRAP_PREFIX = \"var __codemode__ = \"\n return (code: string) => {\n // Try 1: wrap as var assignment to prevent DCE on single expressions\n try {\n const wrapped = `${WRAP_PREFIX}${code}`\n const result = transpiler.transformSync(wrapped).trim()\n if (result.startsWith(WRAP_PREFIX)) {\n let body = result.slice(WRAP_PREFIX.length)\n if (body.endsWith(\";\")) body = body.slice(0, -1)\n return body.trim()\n }\n } catch {\n // Not a single expression — fall through to raw transpile\n }\n // Try 2: raw transpile for multi-statement code\n try {\n return transpiler.transformSync(code).trim()\n } catch {\n return code\n }\n }\n }\n return (code: string) => code\n})()\n\n// Grab references to globals that will be injected into the sandbox.\n// These are available in Bun but TypeScript may not know about them\n// without DOM lib or bun-types.\nconst _globals = globalThis as Record<string, unknown>\nconst _fetch = _globals[\"fetch\"] as typeof fetch\nconst _setTimeout = _globals[\"setTimeout\"] as (cb: () => void, ms: number) => number\nconst _clearTimeout = _globals[\"clearTimeout\"] as (id: number) => void\nconst _URL = _globals[\"URL\"] as typeof URL\nconst _Response = _globals[\"Response\"] as typeof Response\nconst _Request = _globals[\"Request\"] as typeof Request\nconst _Headers = _globals[\"Headers\"] as typeof Headers\nconst _Promise = _globals[\"Promise\"] as typeof Promise\n\n/**\n * Run an array of async functions concurrently, like Promise.all but\n * available to sandbox code without needing access to the Promise global.\n */\nfunction parallel<T>(fns: ReadonlyArray<() => Promise<T>>): Promise<Array<T>> {\n return _Promise.all(fns.map((fn) => fn()))\n}\n\n/**\n * Sleep for a given number of milliseconds.\n */\nfunction sleep(ms: number): Promise<void> {\n return new _Promise<void>((resolve) => _setTimeout(resolve, ms))\n}\n\n/**\n * Test whether a value is an Effect by checking for the well-known type ID symbol.\n */\nfunction isEffect(value: unknown): value is Effect.Effect<unknown, unknown> {\n return typeof value === \"object\" && value !== null && EffectTypeId in value\n}\n\n/**\n * Normalize user-provided code into a form suitable for `new Function()`.\n *\n * Uses acorn to parse the code as a module and determines the best wrapping:\n * 1. Single ExpressionStatement that is an ArrowFunctionExpression -> call it directly\n * 2. Body ends with an ExpressionStatement -> splice `return` before it, wrap in async IIFE\n * 3. Otherwise -> wrap entire body in async IIFE\n *\n * Falls back to the regex heuristic if acorn parsing fails.\n */\nexport function normalizeCode(code: string): string {\n // Strip TypeScript syntax (type annotations, as casts, interfaces, etc.)\n const trimmed = code.trim()\n const stripped = stripTypeScript(trimmed)\n // Guard: if the transpiler eliminated all code (DCE), fall back to the original\n const jsCode = stripped || trimmed\n try {\n const ast = acorn.parse(jsCode, { ecmaVersion: 2022, sourceType: \"module\" })\n const body = ast.body\n\n if (body.length === 0) {\n return `return (async () => { ${jsCode} })()`\n }\n\n // Case 1: single expression that is an arrow function -> call it\n const first = body[0]!\n if (body.length === 1 && first.type === \"ExpressionStatement\") {\n const expr = first.expression\n if (expr.type === \"ArrowFunctionExpression\") {\n // Use AST positions to extract just the expression (no trailing semicolons)\n const arrowExpr = jsCode.slice(expr.start, expr.end)\n return `return (${arrowExpr})()`\n }\n }\n\n // Case 2: last statement is an expression -> inject return\n const last = body[body.length - 1]!\n if (last.type === \"ExpressionStatement\") {\n const before = jsCode.slice(0, last.start)\n const expr = jsCode.slice(last.start, last.end)\n // Strip trailing semicolons from the expression for clean `return expr`\n const cleanExpr = expr.replace(/;\\s*$/, \"\")\n return `return (async () => { ${before}return ${cleanExpr} })()`\n }\n\n // Case 3: general statements (variable decls, if/for, etc.)\n return `return (async () => { ${jsCode} })()`\n } catch {\n // Acorn parse failed — fall back to regex heuristic\n return normalizeCodeFallback(jsCode)\n }\n}\n\n/**\n * Regex-based fallback: detect arrow functions or wrap as IIFE.\n */\nfunction normalizeCodeFallback(code: string): string {\n if (isArrowFallback(code)) {\n return `return (${code})()`\n }\n return `return (async () => { ${code} })()`\n}\n\nfunction isArrowFallback(code: string): boolean {\n if (/^async\\s*\\(/.test(code)) return true\n if (/^async\\s+[a-zA-Z_$]\\w*\\s*=>/.test(code)) return true\n if (code.startsWith(\"(\")) {\n let depth = 0\n for (let i = 0; i < code.length; i++) {\n if (code[i] === \"(\") depth++\n else if (code[i] === \")\") {\n depth--\n if (depth === 0) {\n const rest = code.slice(i + 1).trimStart()\n return rest.startsWith(\"=>\")\n }\n }\n }\n }\n if (/^[a-zA-Z_$]\\w*\\s*=>/.test(code)) return true\n return false\n}\n\nconst networkBlockedFn = () => {\n throw new Error(\"Network access is disabled (allowNetwork: false)\")\n}\n\n// A class that throws on construction — needed because `new fn()` fails with\n// \"is not a constructor\" when fn is a plain function in some runtimes.\n// oxlint-disable-next-line no-extraneous-class\nconst NetworkBlockedClass = new Proxy(class {}, {\n construct() {\n throw new Error(\"Network access is disabled (allowNetwork: false)\")\n },\n apply() {\n throw new Error(\"Network access is disabled (allowNetwork: false)\")\n },\n})\n\n/**\n * Build the sandbox globals object: console capture, network control, Effect modules, and tool fns.\n */\nexport function buildSandboxGlobals(\n fns: Record<string, (...args: Array<unknown>) => unknown>,\n options: ExecutorOptions | undefined,\n logs: string[],\n): Record<string, unknown> {\n const onLog = options?.onLog\n\n const emit = (level: string, msg: string) => {\n logs.push(level === \"log\" ? msg : `[${level}] ${msg}`)\n onLog?.(level, msg)\n }\n\n const capturedConsole = {\n log: (...args: Array<unknown>) => emit(\"log\", args.map(String).join(\" \")),\n warn: (...args: Array<unknown>) => emit(\"warn\", args.map(String).join(\" \")),\n error: (...args: Array<unknown>) => emit(\"error\", args.map(String).join(\" \")),\n info: (...args: Array<unknown>) => emit(\"info\", args.map(String).join(\" \")),\n debug: (...args: Array<unknown>) => emit(\"debug\", args.map(String).join(\" \")),\n }\n\n const allowNetwork = options?.allowNetwork !== false\n\n const globals: Record<string, unknown> = {\n codemode: Object.freeze(fns),\n console: Object.freeze(capturedConsole),\n fetch: allowNetwork ? _fetch : networkBlockedFn,\n setTimeout: _setTimeout,\n clearTimeout: _clearTimeout,\n URL: allowNetwork ? _URL : NetworkBlockedClass,\n Response: allowNetwork ? _Response : NetworkBlockedClass,\n Request: allowNetwork ? _Request : NetworkBlockedClass,\n Headers: allowNetwork ? _Headers : NetworkBlockedClass,\n Promise: _Promise,\n parallel,\n sleep,\n // Effect runtime globals — sandbox code can write Effect.gen programs\n Effect,\n pipe,\n Duration,\n Schedule,\n Option,\n Either,\n Match,\n Schema,\n Arr,\n Ref,\n Stream,\n Chunk,\n Data,\n Order,\n Predicate,\n }\n\n return globals\n}\n\n/**\n * Create an executor from a `runCode` function that handles the actual code execution mechanism.\n *\n * The `runCode` function receives the normalized code and sandbox globals, and must return\n * a Promise of the raw result (before Effect detection). The shared infrastructure handles\n * console capture, global injection, network blocking, Effect detection, timeout, and error handling.\n */\nexport function createBaseExecutor(\n runCode: (wrappedCode: string, globals: Record<string, unknown>) => Promise<unknown>,\n): Executor {\n return {\n execute: async (\n code: string,\n fns: Record<string, (...args: Array<unknown>) => unknown>,\n options?: ExecutorOptions,\n ): Promise<ExecuteResult> => {\n const logs: string[] = []\n const globals = buildSandboxGlobals(fns, options, logs)\n\n try {\n const trimmed = code.trim()\n const wrappedCode = normalizeCode(trimmed)\n const timeout = (options as Record<string, unknown> | undefined)?.[\"timeoutMs\"] as number | undefined ?? DEFAULT_TIMEOUT_MS\n\n let result = await _Promise.race([\n runCode(wrappedCode, globals),\n new _Promise<never>((_, reject) =>\n _setTimeout(() => reject(new Error(`Execution timed out after ${timeout}ms`)), timeout),\n ),\n ])\n\n // If the result is an Effect, run it to get the final value\n if (isEffect(result)) {\n result = await Effect.runPromise(result)\n }\n\n return { result, logs }\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n return { result: undefined, error: message, logs }\n }\n },\n }\n}\n",
|
|
13
|
+
"import { Context, Effect, Layer, Ref } from \"effect\"\n\nimport type { ToolDescriptor, ToolMiddleware } from \"./types\"\n\n/**\n * Internal service that accumulates tool registrations from groups.\n * Not part of the public API.\n *\n * Groups register during Layer construction (via `Layer.effectDiscard` in `.toLayer()`).\n * `serve()` reads the snapshot after all group layers have been built.\n */\nexport class CodemodeRegistry extends Context.Tag(\"@effect-codemode/Registry\")<\n CodemodeRegistry,\n {\n readonly registerGroup: (\n name: string,\n tools: Record<string, ToolDescriptor>,\n middleware?: ReadonlyArray<ToolMiddleware>,\n ) => Effect.Effect<void>\n readonly registerFailure: (name: string, error: string) => Effect.Effect<void>\n readonly registerMiddleware: (mw: ToolMiddleware) => Effect.Effect<void>\n readonly snapshot: Effect.Effect<{\n available: Array<{\n name: string\n tools: Record<string, ToolDescriptor>\n middleware: ReadonlyArray<ToolMiddleware>\n }>\n failed: Array<{ name: string; error: string }>\n globalMiddleware: ReadonlyArray<ToolMiddleware>\n }>\n }\n>() {\n /**\n * Create a live registry backed by Ref.\n * Used internally by serve().\n */\n static make = Effect.gen(function* () {\n const groupsRef = yield* Ref.make<\n Array<{\n name: string\n tools: Record<string, ToolDescriptor>\n middleware: ReadonlyArray<ToolMiddleware>\n }>\n >([])\n const failedRef = yield* Ref.make<Array<{ name: string; error: string }>>([])\n const globalMiddlewareRef = yield* Ref.make<ReadonlyArray<ToolMiddleware>>([])\n\n return CodemodeRegistry.of({\n registerGroup: (name, tools, middleware) =>\n Ref.update(groupsRef, (groups) => [...groups, { name, tools, middleware: middleware ?? [] }]),\n registerFailure: (name, error) => Ref.update(failedRef, (failed) => [...failed, { name, error }]),\n registerMiddleware: (mw) => Ref.update(globalMiddlewareRef, (mws) => [...mws, mw]),\n snapshot: Effect.all({\n available: Ref.get(groupsRef),\n failed: Ref.get(failedRef),\n globalMiddleware: Ref.get(globalMiddlewareRef),\n }),\n })\n })\n\n static layer = Layer.effect(CodemodeRegistry, CodemodeRegistry.make)\n}\n",
|
|
14
|
+
"/**\n * effect-codemode — Effect-native codemode for MCP\n *\n * Give LLMs a typed Effect SDK instead of individual tool calls.\n * Tools return Effects with typed errors. The LLM writes Effect.gen code.\n */\n\nimport { Layer } from \"effect\"\n\nimport { CodeExecutor } from \"./executor\"\nimport { group } from \"./group\"\nimport { withMiddleware } from \"./middleware\"\nimport { CodemodeRegistry } from \"./registry\"\nimport { serve } from \"./serve\"\nimport { tool } from \"./tool\"\nimport { StdioTransport } from \"./transport\"\n\n/**\n * Convenience: `serve()` with `CodeExecutor.Default` bundled.\n * For quick prototyping — production usage should provide the executor explicitly.\n */\nconst live = () => serve().pipe(Layer.provide(CodeExecutor.Default))\n\nexport const Codemode = {\n tool,\n group,\n serve,\n live,\n StdioTransport,\n withMiddleware,\n CodemodeRegistry,\n} as const\n\n// Shape definition\nexport { tool, type ToolShape } from \"./tool\"\nexport { group } from \"./group\"\n\n// Server\nexport { serve } from \"./serve\"\n\n// Transport\nexport { StdioTransport } from \"./transport\"\n\n// Middleware\nexport { withMiddleware } from \"./middleware\"\n\n// Registry\nexport { CodemodeRegistry } from \"./registry\"\n\n// Types\nexport type { ToolDescriptor, ToolInvocation, ToolMiddleware, ExecuteResult, Executor, ExecutorOptions } from \"./types\"\n\n// Executor\nexport { CodeExecutor, normalizeCode } from \"./executor\"\n\n// Testing\nexport { buildTestTool, buildInspector } from \"./testing\"\n\n// Advanced — typegen\nexport { generateDeclarations, astToTypeScript } from \"./typegen\"\n\n// Advanced — search\nexport { searchTools, listToolSummary } from \"./search\"\n\n// Advanced — bridge\nexport { effectToEffectFn, buildEffectFnTable, unwrapEffectTypes } from \"./bridge\"\n\n// Utilities\nexport { sanitizeToolName } from \"./sanitize\"\n",
|
|
15
|
+
"import { Cause, Effect, Exit, Layer } from \"effect\"\nimport * as SchemaAST from \"effect/SchemaAST\"\n\nimport { CodemodeRegistry } from \"./registry\"\nimport type { TaggedErrorClassLike, ToolShape } from \"./tool\"\nimport type { ToolDescriptor, ToolMiddleware } from \"./types\"\n\n/**\n * Shorthand for any ToolShape regardless of its type parameters.\n */\ntype AnyToolShape = ToolShape<string, unknown, unknown, ReadonlyArray<TaggedErrorClassLike>>\n\n/**\n * Extract the input type from a ToolShape.\n */\ntype ExtractInput<T> = T extends ToolShape<string, infer I, unknown, ReadonlyArray<TaggedErrorClassLike>> ? I : never\n\n/**\n * Extract the output type from a ToolShape.\n */\ntype ExtractOutput<T> = T extends ToolShape<string, unknown, infer O, ReadonlyArray<TaggedErrorClassLike>> ? O : never\n\n/**\n * Extract the error types from a ToolShape as a union.\n */\ntype ExtractErrors<T> =\n T extends ToolShape<string, unknown, unknown, infer Errors>\n ? Errors[number] extends abstract new (...args: ReadonlyArray<never>) => infer E\n ? E\n : never\n : never\n\n/**\n * Maps tool shapes to a handler record type.\n * Each key is a tool name, each value is a handler function.\n */\nexport type HandlersFrom<Tools extends ReadonlyArray<AnyToolShape>> = {\n readonly [T in Tools[number] as T[\"name\"]]: (\n input: ExtractInput<T>,\n ) => Effect.Effect<ExtractOutput<T>, ExtractErrors<T>>\n}\n\n/**\n * Options for `toLayer`.\n */\nexport interface ToLayerOptions {\n readonly middleware?: ReadonlyArray<ToolMiddleware>\n}\n\n/**\n * The class returned by `group()`.\n */\nexport interface GroupClass<GroupName extends string, Tools extends ReadonlyArray<AnyToolShape>> {\n new (_: never): {}\n readonly groupName: GroupName\n readonly tools: Tools\n toLayer(factory: HandlersFrom<Tools>, options?: ToLayerOptions): Layer.Layer<CodemodeRegistry, never, never>\n toLayer<E, R>(\n factory: Effect.Effect<HandlersFrom<Tools>, E, R>,\n options?: ToLayerOptions,\n ): Layer.Layer<CodemodeRegistry, never, R>\n middleware(...mws: ReadonlyArray<ToolMiddleware>): GroupClass<GroupName, Tools>\n}\n\n/**\n * Create a tool group — bundles related tool shapes under a name.\n *\n * Returns a class suitable for `class TodoTools extends Codemode.group(\"todos\", TodoGet, ...) {}`.\n * The class has:\n * - `static groupName` — the group name\n * - `static tools` — the tool shape array\n * - `static toLayer(factory)` — returns a `Layer.Layer<CodemodeRegistry, never, R>`\n *\n * ```ts\n * class TodoTools extends Codemode.group(\"todos\", TodoGet, TodoList, TodoCreate) {}\n *\n * const TodoToolsLive = TodoTools.toLayer(\n * Effect.gen(function* () {\n * const svc = yield* TodoService\n * return {\n * todo_get: ({ id }) => svc.get(id),\n * todo_list: (input) => svc.list(input),\n * todo_create: (input) => svc.create(input),\n * }\n * })\n * ).pipe(Layer.provide(TodoServiceLive))\n * ```\n */\nexport function group<GroupName extends string, Tools extends ReadonlyArray<AnyToolShape>>(\n name: GroupName,\n ...tools: Tools\n): GroupClass<GroupName, Tools> {\n const groupName = name\n const groupTools = tools\n\n function toLayer(\n factory: HandlersFrom<Tools> | Effect.Effect<HandlersFrom<Tools>, unknown, unknown>,\n options?: ToLayerOptions,\n ) {\n const factoryEffect = Effect.isEffect(factory)\n ? (factory as Effect.Effect<HandlersFrom<Tools>, unknown, unknown>)\n : Effect.succeed(factory as HandlersFrom<Tools>)\n const groupMiddleware = options?.middleware ?? []\n\n return Layer.effectDiscard(\n Effect.gen(function* () {\n const registry = yield* CodemodeRegistry\n const exit = yield* Effect.exit(factoryEffect)\n\n if (Exit.isSuccess(exit)) {\n const handlers = exit.value as Record<string, (input: unknown) => Effect.Effect<unknown, unknown, unknown>>\n const toolDescriptors: Record<string, ToolDescriptor> = {}\n\n for (const shape of groupTools) {\n const handler = handlers[shape.name]\n if (handler) {\n toolDescriptors[shape.name] = {\n name: shape.name,\n description: shape.description,\n inputSchema: shape.input,\n outputSchema: shape.output,\n errors: shape.errors.map((e: TaggedErrorClassLike) => {\n const tag = e._tag ?? (e as { name?: string }).name ?? \"UnknownError\"\n // If the error class has a Schema AST (Schema.TaggedError), extract the encoded form\n const errorAst = (e as { ast?: { _tag: string; from?: unknown } }).ast\n if (errorAst && errorAst._tag === \"Transformation\" && errorAst.from) {\n return { tag, ast: errorAst.from as SchemaAST.AST }\n }\n return tag // fallback to string form for non-Schema errors\n }),\n requiresConfirmation: shape.requiresConfirmation,\n example: shape.example,\n middleware: [...(shape.middleware ?? []), ...groupMiddleware],\n execute: (input: unknown) => handler(input),\n }\n }\n }\n\n yield* registry.registerGroup(groupName, toolDescriptors)\n } else {\n yield* registry.registerFailure(groupName, Cause.pretty(exit.cause))\n }\n }),\n )\n }\n\n // Build a class constructor with static properties\n // eslint-disable-next-line no-extraneous-class\n const GroupClassImpl = class {\n static groupName = groupName\n static tools = groupTools\n static toLayer = toLayer\n static middleware = (...mws: ReadonlyArray<ToolMiddleware>) => {\n const newTools = groupTools.map((shape) => ({\n ...shape,\n middleware: [...(shape.middleware ?? []), ...mws],\n })) as unknown as Tools\n return group(groupName, ...newTools)\n }\n }\n\n return GroupClassImpl as unknown as GroupClass<GroupName, Tools>\n}\n",
|
|
16
|
+
"import { Effect, Layer } from \"effect\"\n\nimport { CodemodeRegistry } from \"./registry\"\nimport type { ToolMiddleware } from \"./types\"\n\n/**\n * Register a global middleware with the CodemodeRegistry.\n * Returns a Layer that, when provided, adds the middleware to the registry.\n *\n * Global middleware wraps ALL tools from every group.\n *\n * ```ts\n * Codemode.serve().pipe(\n * Layer.provide(withMiddleware(loggingMiddleware)),\n * Layer.provide(Layer.mergeAll(TodoToolsLive, UserToolsLive)),\n * )\n * ```\n */\nexport const withMiddleware = (mw: ToolMiddleware) =>\n Layer.effectDiscard(\n Effect.gen(function* () {\n const registry = yield* CodemodeRegistry\n yield* registry.registerMiddleware(mw)\n }),\n )\n\n",
|
|
17
|
+
"import { CallToolResult, Tool } from \"@effect/ai/McpSchema\"\nimport { McpServer } from \"@effect/ai/McpServer\"\nimport { Cause, Effect, JSONSchema, Layer } from \"effect\"\n\nimport { effectToAsyncFn } from \"./bridge\"\nimport { createCodemodeTool } from \"./codemode\"\nimport { CodeExecutor } from \"./executor\"\nimport { CodemodeRegistry } from \"./registry\"\nimport { searchTools, listToolSummary } from \"./search\"\nimport type { ExecuteResult, ToolDescriptor } from \"./types\"\n\n/**\n * Returns a Layer that sets up the full MCP server using the CodemodeRegistry.\n *\n * 1. Reads `CodemodeRegistry` snapshot for available/failed groups\n * 2. Logs warnings for failed groups\n * 3. Fails if no groups available\n * 4. Merges all available tools, tagging each with `service: group.name`\n * 5. Captures runtime via `yield* Effect.runtime<never>()`\n * 6. Splits tools into sandbox vs confirmation-required\n * 7. Collects global middleware from the registry\n * 8. Creates the codemode tool via `createCodemodeTool()`\n * 9. Registers `search_tools`, `execute_code`, and individual confirmation tools with McpServer\n *\n * Requires: McpServer, CodemodeRegistry, CodeExecutor\n *\n * ```ts\n * import { Codemode } from \"effect-codemode\"\n * import { CodemodeRegistry } from \"effect-codemode\"\n *\n * Codemode.serve().pipe(\n * Layer.provide(Layer.mergeAll(TodoToolsLive, UserToolsLive)),\n * Layer.provide(CodemodeRegistry.layer),\n * Layer.provide(Codemode.StdioTransport(stdin, stdout, { name: \"my-server\", version: \"1.0.0\" })),\n * Layer.provide(CodeExecutor.Default),\n * Layer.launch,\n * BunRuntime.runMain,\n * )\n * ```\n */\nexport function serve() {\n return Layer.effectDiscard(\n Effect.gen(function* () {\n const server = yield* McpServer\n const registry = yield* CodemodeRegistry\n const { available, failed, globalMiddleware } = yield* registry.snapshot\n\n // Log failures\n for (const f of failed) {\n yield* Effect.logWarning(`${f.name}: unavailable (${f.error})`)\n }\n\n if (available.length === 0) {\n return yield* Effect.fail(new Error(\"No tool groups available. Check your configuration.\"))\n }\n\n // Merge all available tools, tagging each with the group name\n const allTools: Record<string, ToolDescriptor> = {}\n for (const group of available) {\n for (const [key, tool] of Object.entries(group.tools)) {\n allTools[key] = { ...tool, service: group.name }\n }\n }\n\n // Build status text\n const statusParts: string[] = []\n for (const g of available) {\n statusParts.push(` ${g.name}: available`)\n }\n for (const f of failed) {\n statusParts.push(` ${f.name}: unavailable (${f.error})`)\n }\n const statusText = statusParts.join(\"\\n\")\n\n yield* Effect.logInfo(`Service status:\\n${statusText}`)\n\n // Capture runtime for all available services\n const rt = yield* Effect.runtime<never>()\n\n // Get executor\n const executor = yield* CodeExecutor\n\n // Split sandbox vs confirmation tools\n const sandboxTools: Record<string, ToolDescriptor> = {}\n const confirmationTools: Record<string, ToolDescriptor> = {}\n for (const [key, tool] of Object.entries(allTools)) {\n if (tool.requiresConfirmation) confirmationTools[key] = tool\n else sandboxTools[key] = tool\n }\n\n // Build group names for dynamic description\n const groupNames = available.map((g) => g.name)\n\n // Create the codemode tool (sandbox tools only)\n // Middleware is baked into each ToolDescriptor by group.ts; pass globalMiddleware for sandbox composition\n const codemode = createCodemodeTool(sandboxTools, rt, executor, statusText, globalMiddleware, groupNames)\n\n // Register search_tools with McpServer\n yield* server.addTool({\n tool: new Tool({\n name: \"search_tools\",\n description:\n \"Search available API tools by keyword. Returns matching tool type declarations and descriptions. Use this to discover what operations are available before writing code. Pass no query to see all available tools grouped by service.\",\n inputSchema: {\n type: \"object\",\n properties: {\n query: {\n type: \"string\",\n description:\n \"Search query to match against tool names and descriptions. Leave empty to list all tools.\",\n },\n detail: {\n type: \"string\",\n enum: [\"list\", \"summary\", \"full\"],\n description:\n 'Detail level for results. \"list\" = names + descriptions, \"summary\" = names + descriptions + parameter names, \"full\" = complete TypeScript declarations (default).',\n },\n },\n },\n }),\n handle: (payload: Record<string, unknown>) =>\n Effect.sync(() => {\n const query = (payload[\"query\"] as string) ?? \"\"\n const detail = (payload[\"detail\"] as \"list\" | \"summary\" | \"full\") ?? undefined\n if (!query.trim()) {\n const summary = listToolSummary(allTools, detail)\n return new CallToolResult({ content: [{ type: \"text\" as const, text: summary }] })\n }\n const result = searchTools(allTools, query, detail)\n const text =\n result.matches.length > 0\n ? `Found ${result.matches.length} matching tool(s):\\n\\n${result.declarations}`\n : result.declarations\n return new CallToolResult({ content: [{ type: \"text\" as const, text }] })\n }),\n })\n\n // Register execute_code with McpServer\n yield* server.addTool({\n tool: new Tool({\n name: codemode.name,\n description: codemode.description,\n inputSchema: {\n type: \"object\",\n properties: {\n code: {\n type: \"string\",\n description: \"TypeScript async arrow function to execute\",\n },\n },\n required: [\"code\"],\n },\n }),\n handle: (payload: Record<string, unknown>) =>\n Effect.gen(function* () {\n const code = payload[\"code\"] as string | undefined\n if (!code) {\n return new CallToolResult({\n content: [{ type: \"text\" as const, text: \"Missing required parameter: code\" }],\n isError: true,\n })\n }\n const result: ExecuteResult = yield* Effect.promise(() => codemode.execute(code))\n if (result.error) {\n const text =\n result.logs.length > 0\n ? `Error: ${result.error}\\n\\nLogs:\\n${result.logs.join(\"\\n\")}`\n : `Error: ${result.error}`\n return new CallToolResult({ content: [{ type: \"text\" as const, text }], isError: true })\n }\n const parts: string[] = []\n if (result.result !== undefined) {\n parts.push(typeof result.result === \"string\" ? result.result : JSON.stringify(result.result, null, 2))\n }\n if (result.logs.length > 0) {\n parts.push(`\\nLogs:\\n${result.logs.join(\"\\n\")}`)\n }\n return new CallToolResult({\n content: [{ type: \"text\" as const, text: parts.join(\"\\n\") || \"(no output)\" }],\n })\n }).pipe(\n Effect.catchAllCause((cause) =>\n Effect.succeed(\n new CallToolResult({\n content: [{ type: \"text\" as const, text: `Internal error: ${Cause.pretty(cause)}` }],\n isError: true,\n }),\n ),\n ),\n ),\n })\n\n // Register confirmation-required tools as individual MCP tools\n for (const [key, tool] of Object.entries(confirmationTools)) {\n const jsonSchema = JSONSchema.make(tool.inputSchema)\n const fullMiddleware = [...(tool.middleware ?? []), ...globalMiddleware]\n const asyncFn = effectToAsyncFn(tool, rt, { middleware: fullMiddleware })\n\n yield* server.addTool({\n tool: new Tool({\n name: key,\n description: tool.description,\n inputSchema: jsonSchema,\n }),\n handle: (payload: Record<string, unknown>) =>\n Effect.gen(function* () {\n const result = yield* Effect.promise(() => asyncFn(payload))\n const text = typeof result === \"string\" ? result : JSON.stringify(result, null, 2)\n return new CallToolResult({ content: [{ type: \"text\" as const, text }] })\n }).pipe(\n Effect.catchAllCause((cause) =>\n Effect.succeed(\n new CallToolResult({\n content: [{ type: \"text\" as const, text: `Error: ${Cause.pretty(cause)}` }],\n isError: true,\n }),\n ),\n ),\n ),\n })\n }\n\n yield* Effect.logInfo(\"MCP server ready\")\n }),\n )\n}\n",
|
|
18
|
+
"import { generateDeclarations, type ToolDescriptor as TypegenDescriptor } from \"./typegen\"\nimport type { ToolDescriptor } from \"./types\"\nimport { toTypegenDescriptor } from \"./types\"\n\n/**\n * Detail level for search/list results:\n * - `\"list\"` — names + one-line descriptions\n * - `\"summary\"` — names + descriptions + parameter names\n * - `\"full\"` — complete TypeScript declarations (default)\n */\nexport type DetailLevel = \"list\" | \"summary\" | \"full\"\n\n/**\n * Search results grouped by service.\n */\ninterface SearchResult {\n readonly matches: ReadonlyArray<{\n readonly name: string\n readonly description: string\n readonly service: string\n readonly example?: string\n }>\n readonly declarations: string\n}\n\nfunction getService(_toolName: string, tool?: ToolDescriptor): string {\n return tool?.service ?? \"unknown\"\n}\n\n/**\n * Score a tool against a set of search terms.\n *\n * Scoring strategy (tighter than the previous \"any term matches\" approach):\n * - Each term is scored independently: name match (3), service match (2), description word-boundary match (1)\n * - A term that matches nothing contributes 0\n * - Final score is the *product* of per-term scores — so ALL terms must match something\n * to get a non-zero score. This prevents \"PR review\" from matching every tool that\n * mentions \"PR\" OR \"review\" (which was basically everything).\n */\nfunction scoreTool(key: string, tool: ToolDescriptor, terms: ReadonlyArray<string>): number {\n if (terms.length === 0) return 0\n\n const service = getService(key, tool)\n const descLower = tool.description.toLowerCase()\n\n let total = 0\n let allTermsHit = true\n\n for (const term of terms) {\n let termScore = 0\n\n // Name/key match — strongest signal\n if (key.toLowerCase().includes(term)) {\n termScore += 3\n }\n\n // Service match\n if (service.includes(term)) {\n termScore += 2\n }\n\n // Description match — use word boundary check for tighter matching\n // We check for the term appearing as a word boundary (not buried in an unrelated word)\n const wordBoundaryRe = new RegExp(`\\\\b${escapeRegExp(term)}`, \"i\")\n if (wordBoundaryRe.test(descLower)) {\n termScore += 1\n }\n\n // Fuzzy fallback: if exact matching found nothing and the term is long enough,\n // try Levenshtein distance against words in the name, service, and description.\n if (termScore === 0 && term.length >= 4) {\n const candidates = [...key.toLowerCase().split(\"_\"), service, ...descLower.split(/\\s+/)]\n for (const word of candidates) {\n if (word.length >= 3 && levenshtein(term, word) <= 2) {\n termScore = 0.5\n break\n }\n }\n }\n\n if (termScore === 0) {\n allTermsHit = false\n break\n }\n total += termScore\n }\n\n // All terms must contribute — otherwise score is 0\n return allTermsHit ? total : 0\n}\n\nfunction escapeRegExp(s: string): string {\n return s.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")\n}\n\n/**\n * Classic Levenshtein distance via dynamic programming.\n * Returns the minimum number of single-character edits (insert, delete, substitute)\n * needed to transform string `a` into string `b`.\n */\nfunction levenshtein(a: string, b: string): number {\n const m = a.length\n const n = b.length\n const dp: number[][] = Array.from({ length: m + 1 }, () => Array(n + 1).fill(0))\n\n for (let i = 0; i <= m; i++) dp[i]![0] = i\n for (let j = 0; j <= n; j++) dp[0]![j] = j\n\n for (let i = 1; i <= m; i++) {\n for (let j = 1; j <= n; j++) {\n if (a[i - 1] === b[j - 1]) {\n dp[i]![j] = dp[i - 1]![j - 1]!\n } else {\n dp[i]![j] = 1 + Math.min(dp[i - 1]![j]!, dp[i]![j - 1]!, dp[i - 1]![j - 1]!)\n }\n }\n }\n\n return dp[m]![n]!\n}\n\n/**\n * Extract parameter names from a ToolDescriptor's input schema.\n */\nfunction getParamNames(tool: ToolDescriptor): string[] {\n try {\n const schema = tool.inputSchema as { ast?: { _tag?: string; propertySignatures?: ReadonlyArray<{ name: string }> } }\n const ast = schema.ast\n if (ast && ast.propertySignatures) {\n return ast.propertySignatures.map((p) => p.name)\n }\n } catch {\n // Ignore\n }\n return []\n}\n\n/**\n * Format a single match at the given detail level.\n */\nfunction formatMatch(key: string, tool: ToolDescriptor, detail: DetailLevel): string {\n switch (detail) {\n case \"list\":\n return ` - ${key}: ${tool.description}`\n case \"summary\": {\n const params = getParamNames(tool)\n const paramStr = params.length > 0 ? `(${params.join(\", \")})` : \"()\"\n return ` - ${key}${paramStr}: ${tool.description}`\n }\n case \"full\":\n // Handled separately via generateDeclarations\n return \"\"\n }\n}\n\n/**\n * Search tools by query against names and descriptions.\n * Returns matching tools with their type declarations and examples.\n *\n * All query terms must match at least one of: tool name, service, or description.\n * This prevents broad queries from returning the entire tool catalog.\n */\nexport function searchTools(\n allTools: Record<string, ToolDescriptor>,\n query: string,\n detail?: DetailLevel,\n): SearchResult {\n const trimmed = query.trim().toLowerCase()\n const resolvedDetail = detail ?? \"full\"\n\n // Category browsing: \"service:<name>\" returns all tools for that service\n if (trimmed.startsWith(\"service:\")) {\n const serviceName = trimmed.slice(\"service:\".length).trim()\n const serviceMatches = Object.entries(allTools)\n .filter(([key, tool]) => getService(key, tool) === serviceName)\n .map(([key, tool]) => ({ key, tool, score: 1 }))\n return buildResult(serviceMatches, resolvedDetail)\n }\n\n const terms = trimmed.split(/\\s+/).filter(Boolean)\n\n const scored = Object.entries(allTools).map(([key, tool]) => ({\n key,\n tool,\n score: scoreTool(key, tool, terms),\n }))\n\n // Filter to matches and sort by score descending\n let matches = scored.filter((s) => s.score > 0).toSorted((a, b) => b.score - a.score)\n\n // Workflow-level fallback: if strict AND returned zero matches, check if any\n // query term matches a service name. If exactly one service matches, return all\n // its tools. This handles queries like \"sheets read write\" where no single tool\n // matches all terms but the intent is clearly about one service.\n if (matches.length === 0) {\n const allEntries = Object.entries(allTools)\n const matchedServices = new Set<string>()\n for (const term of terms) {\n for (const [key, tool] of allEntries) {\n const svc = getService(key, tool)\n if (svc === term) {\n matchedServices.add(svc)\n }\n }\n }\n if (matchedServices.size === 1) {\n const targetService = [...matchedServices][0]!\n matches = allEntries\n .filter(([key, tool]) => getService(key, tool) === targetService)\n .map(([key, tool]) => ({ key, tool, score: 1 }))\n }\n }\n\n return buildResult(matches, resolvedDetail)\n}\n\n/**\n * Build a SearchResult from a list of scored matches.\n * Shared by the main search path and the service: prefix path.\n */\nfunction buildResult(\n matches: ReadonlyArray<{ key: string; tool: ToolDescriptor; score: number }>,\n detail: DetailLevel,\n): SearchResult {\n if (matches.length === 0) {\n return {\n matches: [],\n declarations: \"No tools matched your query. Try broader terms like 'linear', 'github', 'sheets', or 'slack'.\",\n }\n }\n\n let declarations: string\n\n if (detail === \"full\") {\n // Build type declarations for just the matching tools\n const matchedToolsForTypegen: Record<string, TypegenDescriptor> = {}\n for (const m of matches) {\n matchedToolsForTypegen[m.key] = toTypegenDescriptor(m.tool)\n }\n declarations = generateDeclarations(matchedToolsForTypegen)\n\n // Append per-tool examples if available\n const exampleLines: string[] = []\n for (const m of matches) {\n if (m.tool.example) {\n exampleLines.push(`**${m.key}:**\\n\\`\\`\\`typescript\\n${m.tool.example}\\n\\`\\`\\``)\n }\n }\n if (exampleLines.length > 0) {\n declarations += `\\n\\nExamples:\\n\\n${exampleLines.join(\"\\n\\n\")}`\n }\n } else {\n // list or summary mode\n const lines = matches.map((m) => formatMatch(m.key, m.tool, detail))\n declarations = lines.join(\"\\n\")\n }\n\n return {\n matches: matches.map((m) => ({\n name: m.key,\n description: m.tool.description,\n service: getService(m.key, m.tool),\n ...(m.tool.example !== undefined ? { example: m.tool.example } : {}),\n })),\n declarations,\n }\n}\n\n/**\n * Generate a summary of all available tools grouped by service.\n * Used when no query is provided.\n */\nexport function listToolSummary(allTools: Record<string, ToolDescriptor>, detail?: DetailLevel): string {\n const resolvedDetail = detail ?? \"list\"\n const byService: Record<string, string[]> = {}\n\n for (const [key, tool] of Object.entries(allTools)) {\n const svc = getService(key, tool)\n if (!byService[svc]) byService[svc] = []\n byService[svc]!.push(formatMatchForSummary(key, tool, resolvedDetail))\n }\n\n const sections: string[] = []\n for (const [svc, tools] of Object.entries(byService)) {\n sections.push(`## ${svc}\\n${tools.join(\"\\n\")}`)\n }\n\n return sections.join(\"\\n\\n\")\n}\n\n/**\n * Format a tool entry for the summary listing.\n */\nfunction formatMatchForSummary(key: string, tool: ToolDescriptor, detail: DetailLevel): string {\n switch (detail) {\n case \"list\":\n return ` - ${key}: ${tool.description}`\n case \"summary\": {\n const params = getParamNames(tool)\n const paramStr = params.length > 0 ? `(${params.join(\", \")})` : \"()\"\n return ` - ${key}${paramStr}: ${tool.description}`\n }\n case \"full\": {\n const typegenTool = toTypegenDescriptor(tool)\n const decl = generateDeclarations({ [key]: typegenTool })\n return decl\n }\n }\n}\n",
|
|
19
|
+
"import { Schema } from \"effect\"\n\nimport { sanitizeToolName } from \"./sanitize\"\nimport type { ToolMiddleware } from \"./types\"\n\n/**\n * Structural constraint for a Schema.TaggedError class.\n *\n * We avoid using `Schema.TaggedErrorClass<any, string, any>` directly because\n * its `Invariant<Self>` wrapper in the Schema TypeId causes variance issues\n * under strict tsconfig (e.g. `exactOptionalPropertyTypes`). Instead, we match\n * the structural shape: a constructor with a static `_tag` property.\n */\nexport interface TaggedErrorClassLike {\n readonly _tag: string\n new (...args: ReadonlyArray<never>): { readonly _tag: string }\n}\n\n/**\n * A pure shape descriptor for a tool — name, description, input/output schemas,\n * error types, and flags. No execute function.\n *\n * Analogous to `Rpc.make()` in `@effect/rpc`.\n */\nexport interface ToolShape<Name extends string, I, O, Errors extends ReadonlyArray<TaggedErrorClassLike>> {\n readonly _tag: \"ToolShape\"\n readonly name: Name\n readonly description: string\n readonly input: Schema.Schema.Any & { readonly Type: I }\n readonly output: (Schema.Schema.Any & { readonly Type: O }) | undefined\n readonly errors: Errors\n readonly requiresConfirmation: boolean\n readonly example: string | undefined\n readonly middleware: ReadonlyArray<ToolMiddleware>\n}\n\n/**\n * Configuration for defining a tool shape.\n */\nexport interface ToolConfig<I, O, Errors extends ReadonlyArray<TaggedErrorClassLike>> {\n readonly description: string\n readonly input: Schema.Schema.Any & { readonly Type: I }\n readonly output?: (Schema.Schema.Any & { readonly Type: O }) | undefined\n readonly errors?: Errors\n readonly requiresConfirmation?: boolean\n readonly example?: string\n readonly middleware?: ReadonlyArray<ToolMiddleware>\n}\n\n/**\n * Create a tool shape — a pure data descriptor with no implementation.\n *\n * Tool names are validated and sanitized at definition time using `sanitizeToolName`.\n *\n * ```ts\n * const TodoGet = Codemode.tool(\"todo_get\", {\n * description: \"Get a todo by ID\",\n * input: Schema.Struct({ id: Schema.String }),\n * output: Todo,\n * errors: [NotFoundError],\n * })\n * ```\n */\nexport function tool<Name extends string, I, O = never, Errors extends ReadonlyArray<TaggedErrorClassLike> = []>(\n name: Name,\n config: ToolConfig<I, O, Errors>,\n): ToolShape<Name, I, O, Errors> {\n const sanitized = sanitizeToolName(name)\n\n return {\n _tag: \"ToolShape\" as const,\n name: sanitized as Name,\n description: config.description,\n input: config.input,\n output: config.output as (Schema.Schema.Any & { readonly Type: O }) | undefined,\n errors: (config.errors ?? []) as Errors,\n requiresConfirmation: config.requiresConfirmation ?? false,\n example: config.example,\n middleware: config.middleware ?? [],\n }\n}\n",
|
|
20
|
+
"import { layerStdio } from \"@effect/ai/McpServer\"\nimport type { Sink } from \"effect/Sink\"\nimport type { Stream } from \"effect/Stream\"\n\n/**\n * Stdio transport — provides McpServer via stdin/stdout.\n */\nexport const StdioTransport = (\n stdin: Stream<Uint8Array, unknown, unknown>,\n stdout: Sink<unknown, Uint8Array | string, unknown, unknown, unknown>,\n options?: { name?: string; version?: string },\n) =>\n layerStdio({\n name: options?.name ?? \"codemode\",\n version: options?.version ?? \"0.0.0\",\n stdin,\n stdout,\n })\n"
|
|
21
|
+
],
|
|
22
|
+
"mappings": ";AAAA,mBAAS,kBAAQ;;;ACAjB;;;ACSA,IAAM,cAAc,IAAI,IAAI;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AA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,MAAM;AAAA,IACN,MAAM;AAAA,IACN,aAAa,OAAO;AAAA,IACpB,OAAO,OAAO;AAAA,IACd,QAAQ,OAAO;AAAA,IACf,QAAS,OAAO,UAAU,CAAC;AAAA,IAC3B,sBAAsB,OAAO,wBAAwB;AAAA,IACrD,SAAS,OAAO;AAAA,IAChB,YAAY,OAAO,cAAc,CAAC;AAAA,EACpC;AAAA;;;AC/EF;AAOO,IAAM,iBAAiB,CAC5B,OACA,QACA,YAEA,WAAW;AAAA,EACT,MAAM,SAAS,QAAQ;AAAA,EACvB,SAAS,SAAS,WAAW;AAAA,EAC7B;AAAA,EACA;AACF,CAAC;;;ANIH,IAAM,OAAO,MAAM,MAAM,EAAE,KAAK,OAAM,QAAQ,aAAa,OAAO,CAAC;AAE5D,IAAM,WAAW;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;",
|
|
23
|
+
"debugId": "959973B2F4026BBF64756E2164756E21",
|
|
24
|
+
"names": []
|
|
25
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Layer } from "effect";
|
|
2
|
+
import { CodemodeRegistry } from "./registry";
|
|
3
|
+
import type { ToolMiddleware } from "./types";
|
|
4
|
+
/**
|
|
5
|
+
* Register a global middleware with the CodemodeRegistry.
|
|
6
|
+
* Returns a Layer that, when provided, adds the middleware to the registry.
|
|
7
|
+
*
|
|
8
|
+
* Global middleware wraps ALL tools from every group.
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* Codemode.serve().pipe(
|
|
12
|
+
* Layer.provide(withMiddleware(loggingMiddleware)),
|
|
13
|
+
* Layer.provide(Layer.mergeAll(TodoToolsLive, UserToolsLive)),
|
|
14
|
+
* )
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare const withMiddleware: (mw: ToolMiddleware) => Layer.Layer<never, never, CodemodeRegistry>;
|
|
18
|
+
//# sourceMappingURL=middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,EAAE,MAAM,QAAQ,CAAA;AAEtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc,qEAMxB,CAAA"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Context, Effect, Layer } from "effect";
|
|
2
|
+
import type { ToolDescriptor, ToolMiddleware } from "./types";
|
|
3
|
+
declare const CodemodeRegistry_base: Context.TagClass<CodemodeRegistry, "@effect-codemode/Registry", {
|
|
4
|
+
readonly registerGroup: (name: string, tools: Record<string, ToolDescriptor>, middleware?: readonly ToolMiddleware[] | undefined) => Effect.Effect<void, never, never>;
|
|
5
|
+
readonly registerFailure: (name: string, error: string) => Effect.Effect<void, never, never>;
|
|
6
|
+
readonly registerMiddleware: (mw: ToolMiddleware) => Effect.Effect<void, never, never>;
|
|
7
|
+
readonly snapshot: Effect.Effect<{
|
|
8
|
+
available: {
|
|
9
|
+
name: string;
|
|
10
|
+
tools: Record<string, ToolDescriptor>;
|
|
11
|
+
middleware: readonly ToolMiddleware[];
|
|
12
|
+
}[];
|
|
13
|
+
failed: {
|
|
14
|
+
name: string;
|
|
15
|
+
error: string;
|
|
16
|
+
}[];
|
|
17
|
+
globalMiddleware: readonly ToolMiddleware[];
|
|
18
|
+
}, never, never>;
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* Internal service that accumulates tool registrations from groups.
|
|
22
|
+
* Not part of the public API.
|
|
23
|
+
*
|
|
24
|
+
* Groups register during Layer construction (via `Layer.effectDiscard` in `.toLayer()`).
|
|
25
|
+
* `serve()` reads the snapshot after all group layers have been built.
|
|
26
|
+
*/
|
|
27
|
+
export declare class CodemodeRegistry extends CodemodeRegistry_base {
|
|
28
|
+
/**
|
|
29
|
+
* Create a live registry backed by Ref.
|
|
30
|
+
* Used internally by serve().
|
|
31
|
+
*/
|
|
32
|
+
static make: Effect.Effect<{
|
|
33
|
+
readonly registerGroup: (name: string, tools: Record<string, ToolDescriptor>, middleware?: readonly ToolMiddleware[] | undefined) => Effect.Effect<void, never, never>;
|
|
34
|
+
readonly registerFailure: (name: string, error: string) => Effect.Effect<void, never, never>;
|
|
35
|
+
readonly registerMiddleware: (mw: ToolMiddleware) => Effect.Effect<void, never, never>;
|
|
36
|
+
readonly snapshot: Effect.Effect<{
|
|
37
|
+
available: {
|
|
38
|
+
name: string;
|
|
39
|
+
tools: Record<string, ToolDescriptor>;
|
|
40
|
+
middleware: readonly ToolMiddleware[];
|
|
41
|
+
}[];
|
|
42
|
+
failed: {
|
|
43
|
+
name: string;
|
|
44
|
+
error: string;
|
|
45
|
+
}[];
|
|
46
|
+
globalMiddleware: readonly ToolMiddleware[];
|
|
47
|
+
}, never, never>;
|
|
48
|
+
}, never, never>;
|
|
49
|
+
static layer: Layer.Layer<CodemodeRegistry, never, never>;
|
|
50
|
+
}
|
|
51
|
+
export {};
|
|
52
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAO,MAAM,QAAQ,CAAA;AAEpD,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;;;;;;;;;;;;;;;;;;AAE7D;;;;;;GAMG;AACH,qBAAa,gBAAiB,SAAQ,qBAoBnC;IACD;;;OAGG;IACH,MAAM,CAAC,IAAI;;;;;;;;;;;;;;;;qBAsBT;IAEF,MAAM,CAAC,KAAK,8CAAwD;CACrE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sanitizes a tool name so it can be used as a valid JavaScript identifier.
|
|
3
|
+
*
|
|
4
|
+
* - Replaces `-`, `.`, and spaces with `_`
|
|
5
|
+
* - Strips remaining non-identifier characters
|
|
6
|
+
* - Prefixes digit-leading names with `_`
|
|
7
|
+
* - Appends `_` to JS reserved words
|
|
8
|
+
*/
|
|
9
|
+
export declare function sanitizeToolName(name: string): string;
|
|
10
|
+
//# sourceMappingURL=sanitize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../src/sanitize.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAoDH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAqBrD"}
|
package/dist/search.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ToolDescriptor } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Detail level for search/list results:
|
|
4
|
+
* - `"list"` — names + one-line descriptions
|
|
5
|
+
* - `"summary"` — names + descriptions + parameter names
|
|
6
|
+
* - `"full"` — complete TypeScript declarations (default)
|
|
7
|
+
*/
|
|
8
|
+
export type DetailLevel = "list" | "summary" | "full";
|
|
9
|
+
/**
|
|
10
|
+
* Search results grouped by service.
|
|
11
|
+
*/
|
|
12
|
+
interface SearchResult {
|
|
13
|
+
readonly matches: ReadonlyArray<{
|
|
14
|
+
readonly name: string;
|
|
15
|
+
readonly description: string;
|
|
16
|
+
readonly service: string;
|
|
17
|
+
readonly example?: string;
|
|
18
|
+
}>;
|
|
19
|
+
readonly declarations: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Search tools by query against names and descriptions.
|
|
23
|
+
* Returns matching tools with their type declarations and examples.
|
|
24
|
+
*
|
|
25
|
+
* All query terms must match at least one of: tool name, service, or description.
|
|
26
|
+
* This prevents broad queries from returning the entire tool catalog.
|
|
27
|
+
*/
|
|
28
|
+
export declare function searchTools(allTools: Record<string, ToolDescriptor>, query: string, detail?: DetailLevel): SearchResult;
|
|
29
|
+
/**
|
|
30
|
+
* Generate a summary of all available tools grouped by service.
|
|
31
|
+
* Used when no query is provided.
|
|
32
|
+
*/
|
|
33
|
+
export declare function listToolSummary(allTools: Record<string, ToolDescriptor>, detail?: DetailLevel): string;
|
|
34
|
+
export {};
|
|
35
|
+
//# sourceMappingURL=search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../src/search.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAG7C;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CAAA;AAErD;;GAEG;AACH,UAAU,YAAY;IACpB,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;QAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;QACrB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;QAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;QACxB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAC1B,CAAC,CAAA;IACF,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;CAC9B;AAoID;;;;;;GAMG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,EACxC,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,WAAW,GACnB,YAAY,CAgDd;AAsDD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,MAAM,CAgBtG"}
|
package/dist/serve.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { McpServer } from "@effect/ai/McpServer";
|
|
2
|
+
import { Layer } from "effect";
|
|
3
|
+
import { CodeExecutor } from "./executor";
|
|
4
|
+
import { CodemodeRegistry } from "./registry";
|
|
5
|
+
/**
|
|
6
|
+
* Returns a Layer that sets up the full MCP server using the CodemodeRegistry.
|
|
7
|
+
*
|
|
8
|
+
* 1. Reads `CodemodeRegistry` snapshot for available/failed groups
|
|
9
|
+
* 2. Logs warnings for failed groups
|
|
10
|
+
* 3. Fails if no groups available
|
|
11
|
+
* 4. Merges all available tools, tagging each with `service: group.name`
|
|
12
|
+
* 5. Captures runtime via `yield* Effect.runtime<never>()`
|
|
13
|
+
* 6. Splits tools into sandbox vs confirmation-required
|
|
14
|
+
* 7. Collects global middleware from the registry
|
|
15
|
+
* 8. Creates the codemode tool via `createCodemodeTool()`
|
|
16
|
+
* 9. Registers `search_tools`, `execute_code`, and individual confirmation tools with McpServer
|
|
17
|
+
*
|
|
18
|
+
* Requires: McpServer, CodemodeRegistry, CodeExecutor
|
|
19
|
+
*
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { Codemode } from "effect-codemode"
|
|
22
|
+
* import { CodemodeRegistry } from "effect-codemode"
|
|
23
|
+
*
|
|
24
|
+
* Codemode.serve().pipe(
|
|
25
|
+
* Layer.provide(Layer.mergeAll(TodoToolsLive, UserToolsLive)),
|
|
26
|
+
* Layer.provide(CodemodeRegistry.layer),
|
|
27
|
+
* Layer.provide(Codemode.StdioTransport(stdin, stdout, { name: "my-server", version: "1.0.0" })),
|
|
28
|
+
* Layer.provide(CodeExecutor.Default),
|
|
29
|
+
* Layer.launch,
|
|
30
|
+
* BunRuntime.runMain,
|
|
31
|
+
* )
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare function serve(): Layer.Layer<never, Error, CodeExecutor | CodemodeRegistry | McpServer>;
|
|
35
|
+
//# sourceMappingURL=serve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../src/serve.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAChD,OAAO,EAA6B,KAAK,EAAE,MAAM,QAAQ,CAAA;AAIzD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAI7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,KAAK,2EAyLpB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Layer } from "effect";
|
|
2
|
+
import type { CodemodeTool } from "./codemode";
|
|
3
|
+
import { CodemodeRegistry } from "./registry";
|
|
4
|
+
/**
|
|
5
|
+
* Build a CodemodeTool from group layers synchronously. Intended for use in tests
|
|
6
|
+
* where you want to exercise the full pipeline without starting an MCP server.
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { buildTestTool } from "effect-codemode/test"
|
|
10
|
+
* const codemode = buildTestTool(TodoToolsLive, UserToolsLive)
|
|
11
|
+
* const result = await codemode.execute(`Effect.gen(function* () { ... })`)
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare function buildTestTool(...groups: ReadonlyArray<Layer.Layer<CodemodeRegistry, unknown, CodemodeRegistry>>): CodemodeTool;
|
|
15
|
+
/**
|
|
16
|
+
* Return just the TypeScript declarations string for the given group layers.
|
|
17
|
+
* No runtime or executor is created — only resolves tools and generates declarations.
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { buildInspector } from "effect-codemode/test"
|
|
21
|
+
* const declarations = buildInspector(TodoToolsLive, UserToolsLive)
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function buildInspector(...groups: ReadonlyArray<Layer.Layer<CodemodeRegistry, unknown, CodemodeRegistry>>): string;
|
|
25
|
+
export { buildTestTool as test, buildInspector as inspect };
|
|
26
|
+
//# sourceMappingURL=testing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,EAAE,MAAM,QAAQ,CAAA;AAEtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAG9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AA2D7C;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAC3B,GAAG,MAAM,EAAE,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,gBAAgB,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAC,GACjF,YAAY,CAYd;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,GAAG,MAAM,EAAE,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,gBAAgB,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAC,GACjF,MAAM,CAaR;AAGD,OAAO,EAAE,aAAa,IAAI,IAAI,EAAE,cAAc,IAAI,OAAO,EAAE,CAAA"}
|