capable-kit 0.0.1-alpha.0 → 0.0.1-alpha.1

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.
Files changed (60) hide show
  1. package/README.md +42 -0
  2. package/dist/ai-sdk.d.mts +2 -2
  3. package/dist/ai-sdk.mjs +1 -1
  4. package/dist/app.d.mts +1 -1
  5. package/dist/app.mjs +1 -1
  6. package/dist/bin.mjs +395 -47
  7. package/dist/bin.mjs.map +1 -1
  8. package/dist/cli.d.mts +27 -2
  9. package/dist/cli.mjs +2 -2
  10. package/dist/core.d.mts +3 -3
  11. package/dist/core.mjs +1 -1
  12. package/dist/eve.d.mts +1 -1
  13. package/dist/eve.mjs +1 -1
  14. package/dist/http.d.mts +1 -1
  15. package/dist/http.mjs +1 -1
  16. package/dist/{index-DLcYNpfo.d.mts → index-BB5ogMv-.d.mts} +17 -14
  17. package/dist/{index-C9ZThFPN.d.mts → index-BxJhwhKm.d.mts} +2 -2
  18. package/dist/{index-BuXwkN8G.d.mts → index-CThfifn8.d.mts} +4 -4
  19. package/dist/{index-u9ZOETR5.d.mts → index-Dp-D73pf.d.mts} +3 -3
  20. package/dist/index.d.mts +3 -3
  21. package/dist/index.mjs +2 -2
  22. package/dist/mcp.d.mts +2 -2
  23. package/dist/mcp.mjs +1 -139
  24. package/dist/mount--YHrgRHJ.mjs +140 -0
  25. package/dist/mount--YHrgRHJ.mjs.map +1 -0
  26. package/dist/runtime-support.d.mts +20 -0
  27. package/dist/runtime-support.mjs +325 -0
  28. package/dist/runtime-support.mjs.map +1 -0
  29. package/dist/server.d.mts +1 -1
  30. package/dist/server.mjs +1 -81
  31. package/dist/{src-CT4fbWqb.mjs → src-3UaBqI8H.mjs} +26 -16
  32. package/dist/src-3UaBqI8H.mjs.map +1 -0
  33. package/dist/{src-DX-_J6l2.mjs → src-B53ZbNtC.mjs} +6 -7
  34. package/dist/src-B53ZbNtC.mjs.map +1 -0
  35. package/dist/{src-CvWOGyGW.mjs → src-BjBxOv7x.mjs} +148 -96
  36. package/dist/src-BjBxOv7x.mjs.map +1 -0
  37. package/dist/src-DpSA-hBO.mjs +82 -0
  38. package/dist/src-DpSA-hBO.mjs.map +1 -0
  39. package/dist/{src-DlSJtEhv.mjs → src-XRJ9hgYX.mjs} +7 -7
  40. package/dist/src-XRJ9hgYX.mjs.map +1 -0
  41. package/dist/{subscription-CBnnIU42.d.mts → subscription-McaLyHM2.d.mts} +2 -2
  42. package/package.json +59 -17
  43. package/src/ai-sdk.ts +1 -0
  44. package/src/app.ts +1 -0
  45. package/src/bin.ts +4 -0
  46. package/src/cli.ts +1 -0
  47. package/src/core.ts +1 -0
  48. package/src/eve.ts +1 -0
  49. package/src/http.ts +1 -0
  50. package/src/index.test.ts +56 -0
  51. package/src/index.ts +38 -0
  52. package/src/mcp.ts +2 -0
  53. package/src/runtime-support.ts +1 -0
  54. package/src/server.ts +1 -0
  55. package/dist/mcp.mjs.map +0 -1
  56. package/dist/server.mjs.map +0 -1
  57. package/dist/src-CT4fbWqb.mjs.map +0 -1
  58. package/dist/src-CvWOGyGW.mjs.map +0 -1
  59. package/dist/src-DX-_J6l2.mjs.map +0 -1
  60. package/dist/src-DlSJtEhv.mjs.map +0 -1
package/dist/bin.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"bin.mjs","names":[],"sources":["../../nitro-host/src/index.ts","../../toolchain/src/project.ts","../../toolchain/src/index.ts","../src/bin.ts"],"sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport {\n build,\n createDevServer,\n createNitro,\n prepare,\n} from \"nitro/builder\";\nimport type { NitroConfig } from \"nitro/types\";\n\nconst defaultRuntimeHandler = fileURLToPath(new URL(\"./runtime.ts\", import.meta.url));\nconst devRuntimeHandler = fileURLToPath(new URL(\"./dev-runtime.ts\", import.meta.url));\nconst devServerRuntimeHandler = fileURLToPath(\n new URL(\"./dev-server-runtime.ts\", import.meta.url),\n);\nconst configuredRuntimeHandler = fileURLToPath(\n new URL(\"./server-runtime.ts\", import.meta.url),\n);\n\nexport type CapableNitroProject = {\n readonly rootDir: string;\n readonly entry: string | URL;\n readonly serverEntry?: string | URL;\n};\n\nexport type CapableNitroDevServer = {\n readonly origin: string;\n close(): Promise<void>;\n};\n\nexport async function startCapableNitroDevServer(options: {\n project: CapableNitroProject;\n hostname?: string;\n port?: number;\n}): Promise<CapableNitroDevServer> {\n const nitro = await createNitro(\n createCapableNitroConfig(options.project, { dev: true }),\n );\n const server = createDevServer(nitro);\n\n try {\n const listener = server.listen({\n port: options.port ?? 3000,\n hostname: options.hostname ?? \"localhost\",\n silent: true,\n });\n await listener.ready();\n await prepare(nitro);\n await build(nitro);\n\n if (!listener.url) {\n throw new Error(\"Nitro dev server started without a public URL\");\n }\n\n return {\n origin: listener.url.replace(/\\/$/, \"\"),\n close: () => nitro.close(),\n };\n } catch (error) {\n await nitro.close();\n throw error;\n }\n}\n\nexport async function buildCapableNitroApplication(options: {\n project: CapableNitroProject;\n outputDir?: string;\n preset?: string;\n}): Promise<{ outputDir: string }> {\n const outputDir = options.outputDir\n ? path.resolve(options.project.rootDir, options.outputDir)\n : undefined;\n const nitro = await createNitro(\n createCapableNitroConfig(options.project, {\n dev: false,\n ...(outputDir ? { outputDir } : {}),\n ...(options.preset ? { preset: options.preset } : {}),\n }),\n );\n\n try {\n await prepare(nitro);\n await build(nitro);\n return { outputDir: nitro.options.output.dir };\n } finally {\n await nitro.close();\n }\n}\n\nexport async function resolveCapableNitroPreviewCommand(outputDir: string): Promise<{\n command: string;\n cwd: string;\n}> {\n const cwd = path.resolve(outputDir);\n const manifestPath = path.join(cwd, \"nitro.json\");\n let manifest: {\n preset?: unknown;\n commands?: { preview?: unknown };\n };\n try {\n manifest = JSON.parse(await readFile(manifestPath, \"utf8\")) as {\n preset?: unknown;\n commands?: { preview?: unknown };\n };\n } catch {\n throw new Error(`Could not read a runnable Capable build at ${manifestPath}. Run \\`capable build\\` with the node-server preset first.`);\n }\n\n const command = manifest.commands?.preview;\n if (typeof command !== \"string\" || !command.trim()) {\n throw new Error(\n `The Nitro ${String(manifest.preset ?? \"deployment\")} preset does not produce a locally runnable preview command. Build with the node-server preset to use \\`capable preview\\`.`,\n );\n }\n return { command, cwd };\n}\n\nfunction createCapableNitroConfig(\n project: CapableNitroProject,\n options: {\n dev: boolean;\n outputDir?: string;\n preset?: string;\n },\n): NitroConfig {\n const entry = project.entry instanceof URL\n ? fileURLToPath(project.entry)\n : path.resolve(project.entry);\n const serverEntry = project.serverEntry instanceof URL\n ? fileURLToPath(project.serverEntry)\n : project.serverEntry\n ? path.resolve(project.serverEntry)\n : undefined;\n\n return {\n rootDir: project.rootDir,\n dev: options.dev,\n preset: options.dev ? \"nitro-dev\" : options.preset ?? \"node-server\",\n compatibilityDate: \"2026-07-15\",\n alias: serverEntry\n ? { \"#capable/server\": serverEntry, \"#capable/app\": entry }\n : { \"#capable/app\": entry },\n serverEntry: serverEntry\n ? options.dev\n ? devServerRuntimeHandler\n : configuredRuntimeHandler\n : options.dev\n ? devRuntimeHandler\n : defaultRuntimeHandler,\n serverDir: false,\n scanDirs: [],\n imports: false,\n noPublicDir: true,\n logLevel: 2,\n logging: { buildSuccess: false },\n framework: { name: \"capable\" },\n ...(options.outputDir ? { output: { dir: options.outputDir } } : {}),\n };\n}\n","import { readFile, stat } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport type { CapableNitroProject } from \"@capable/nitro-host\";\n\nconst APPLICATION_ENTRIES = [\n \"capable.app.ts\",\n \"capable.app.tsx\",\n \"capable.app.js\",\n \"capable.app.mjs\",\n \"capable.app.cjs\",\n] as const;\n\nconst SERVER_ENTRIES = [\n \"capable.server.ts\",\n \"capable.server.tsx\",\n \"capable.server.js\",\n \"capable.server.mjs\",\n \"capable.server.cjs\",\n] as const;\n\nexport type ResolvedCapableProject = CapableNitroProject & {\n readonly entry: string;\n readonly serverEntry?: string;\n};\n\nexport async function resolveCapableProject(options: {\n readonly project?: string;\n readonly cwd?: string;\n readonly env?: Readonly<Record<string, string | undefined>>;\n} = {}): Promise<ResolvedCapableProject> {\n const cwd = path.resolve(options.cwd ?? process.cwd());\n const env = options.env ?? process.env;\n const configured =\n options.project ??\n env.CAPABLE_APP ??\n await readPackageEntry(cwd);\n const candidate = path.resolve(cwd, configured ?? \".\");\n const candidateStat = await stat(candidate).catch(() => undefined);\n\n let entry: string | undefined;\n let rootDir: string;\n if (candidateStat?.isFile()) {\n entry = candidate;\n rootDir = await findPackageRoot(path.dirname(candidate)) ??\n path.dirname(candidate);\n } else if (candidateStat?.isDirectory()) {\n entry = await findEntry(candidate, APPLICATION_ENTRIES);\n rootDir = await findPackageRoot(candidate) ?? candidate;\n } else {\n throw projectNotFound(candidate, configured);\n }\n\n if (!entry) throw projectNotFound(candidate, configured);\n const serverEntry = await findEntry(rootDir, SERVER_ENTRIES);\n return {\n rootDir,\n entry,\n ...(serverEntry ? { serverEntry } : {}),\n };\n}\n\nasync function readPackageEntry(cwd: string): Promise<string | undefined> {\n try {\n const value = JSON.parse(\n await readFile(path.join(cwd, \"package.json\"), \"utf8\"),\n ) as { readonly capable?: unknown };\n return typeof value.capable === \"string\" ? value.capable : undefined;\n } catch {\n return undefined;\n }\n}\n\nasync function findPackageRoot(start: string): Promise<string | undefined> {\n let directory = start;\n while (true) {\n if ((await stat(path.join(directory, \"package.json\")).catch(() => undefined))\n ?.isFile()) {\n return directory;\n }\n const parent = path.dirname(directory);\n if (parent === directory) return undefined;\n directory = parent;\n }\n}\n\nasync function findEntry(\n directory: string,\n names: readonly string[],\n): Promise<string | undefined> {\n for (const name of names) {\n const candidate = path.join(directory, name);\n if ((await stat(candidate).catch(() => undefined))?.isFile()) {\n return candidate;\n }\n }\n return undefined;\n}\n\nfunction projectNotFound(candidate: string, configured?: string): Error {\n return new Error(\n configured\n ? `Could not find a Capable application at ${candidate}`\n : `Could not find ${APPLICATION_ENTRIES.join(\", \")} in ${candidate}`,\n );\n}\n","import path from \"node:path\";\nimport { spawn } from \"node:child_process\";\nimport { pathToFileURL } from \"node:url\";\nimport { runCli } from \"@capable/cli\";\nimport {\n APPLICATION_SYMBOL,\n type AppDefinition,\n} from \"@capable/core\";\nimport {\n buildCapableNitroApplication,\n resolveCapableNitroPreviewCommand,\n startCapableNitroDevServer,\n type CapableNitroDevServer,\n} from \"@capable/nitro-host\";\nimport {\n createApp,\n createRemoteApp,\n isApp,\n type AnyApp,\n type ApplicationManifest,\n type ManifestNode,\n} from \"@capable/app\";\nimport { createHttpTransport } from \"@capable/fetch\";\nimport { resolveCapableProject } from \"./project.ts\";\n\nexport { resolveCapableProject, type ResolvedCapableProject } from \"./project.ts\";\n\ntype Write = (text: string) => void;\n\nexport type RunCapableCommandOptions = {\n readonly cwd?: string;\n readonly env?: Readonly<Record<string, string | undefined>>;\n readonly stdout?: Write;\n readonly stderr?: Write;\n};\n\ntype LifecycleCommand = {\n readonly command: \"dev\" | \"build\" | \"preview\";\n readonly project?: string;\n readonly host?: string;\n readonly output?: string;\n readonly port?: number;\n readonly preset?: string;\n};\n\ntype CliCommand = {\n readonly command: \"cli\";\n readonly app?: string;\n readonly argv: readonly string[];\n};\n\ntype ParsedCommand =\n | LifecycleCommand\n | CliCommand\n | { readonly command: \"help\" };\n\nclass UsageError extends Error {}\n\nexport async function runCapableCommand(\n argv: readonly string[],\n options: RunCapableCommandOptions = {},\n): Promise<number> {\n const stdout = options.stdout ?? ((text) => process.stdout.write(text));\n const stderr = options.stderr ?? ((text) => process.stderr.write(text));\n try {\n const command = parseCapableCommand(argv);\n if (command.command === \"help\") {\n stdout(renderCapableHelp());\n return 0;\n }\n if (command.command === \"cli\") {\n return runCli({\n app: await resolveCliApp(command.app, options),\n argv: command.argv,\n ...(!options.stdout && process.stdout.isTTY\n ? { isTTY: true }\n : {}),\n ...(!options.stdout && process.stdout.columns\n ? { columns: process.stdout.columns }\n : {}),\n ...(options.stdout || options.stderr\n ? {\n io: {\n ...(options.stdout ? { stdout: options.stdout } : {}),\n ...(options.stderr ? { stderr: options.stderr } : {}),\n },\n }\n : {}),\n });\n }\n\n const project = await resolveCapableProject({\n ...(command.project ? { project: command.project } : {}),\n ...(options.cwd ? { cwd: options.cwd } : {}),\n ...(options.env ? { env: options.env } : {}),\n });\n\n if (command.command === \"dev\") {\n const server = await startCapableNitroDevServer({\n project,\n ...(command.host ? { hostname: command.host } : {}),\n ...(command.port !== undefined ? { port: command.port } : {}),\n });\n try {\n stdout(await renderDevReady(server, {\n hasAuthoredServer: Boolean(project.serverEntry),\n }));\n await waitForShutdown();\n } finally {\n await server.close();\n }\n return 0;\n }\n\n if (command.command === \"build\") {\n const result = await buildCapableNitroApplication({\n project,\n ...(command.output ? { outputDir: command.output } : {}),\n ...(command.preset ? { preset: command.preset } : {}),\n });\n stdout(`Built Capable application at ${result.outputDir}\\n`);\n return 0;\n }\n\n const outputDir = path.resolve(\n project.rootDir,\n command.output ?? \".output\",\n );\n const preview = await resolveCapableNitroPreviewCommand(outputDir);\n const child = spawn(preview.command, {\n cwd: preview.cwd,\n env: {\n ...process.env,\n ...(command.host ? { NITRO_HOST: command.host } : {}),\n ...(command.port !== undefined\n ? { NITRO_PORT: String(command.port) }\n : {}),\n },\n shell: true,\n stdio: \"inherit\",\n });\n return await new Promise<number>((resolve, reject) => {\n child.once(\"error\", reject);\n child.once(\"exit\", (code, signal) => {\n if (code !== null) return resolve(code);\n reject(new Error(`Preview process exited from signal ${signal ?? \"unknown\"}`));\n });\n });\n } catch (error) {\n stderr(`${error instanceof Error ? error.message : String(error)}\\n`);\n if (error instanceof UsageError) {\n stderr(\"Run `capable --help` for usage.\\n\");\n return 2;\n }\n return 1;\n }\n}\n\nexport function parseCapableCommand(argv: readonly string[]): ParsedCommand {\n const [rawCommand, ...rest] = argv;\n if (\n rawCommand === undefined ||\n rawCommand === \"help\" ||\n rawCommand === \"--help\" ||\n rawCommand === \"-h\"\n ) {\n return { command: \"help\" };\n }\n if (rawCommand === \"start\") {\n throw new UsageError(\"`capable start` was renamed to `capable preview`.\");\n }\n if (rawCommand === \"cli\") return parseCli(rest);\n if (\n rawCommand !== \"dev\" &&\n rawCommand !== \"build\" &&\n rawCommand !== \"preview\"\n ) {\n throw new UsageError(`Unknown Capable command: ${rawCommand}`);\n }\n if (rest.includes(\"--help\") || rest.includes(\"-h\")) {\n return { command: \"help\" };\n }\n\n const values = [...rest];\n let project: string | undefined;\n let host: string | undefined;\n let output: string | undefined;\n let port: number | undefined;\n let preset: string | undefined;\n\n while (values.length) {\n const token = values.shift()!;\n if (!token.startsWith(\"-\")) {\n if (project) {\n throw new UsageError(\n `Unexpected argument for capable ${rawCommand}: ${token}`,\n );\n }\n project = token;\n continue;\n }\n switch (token) {\n case \"--app\":\n if (project) {\n throw new UsageError(\"Specify a project path once.\");\n }\n project = takeValue(values, token);\n break;\n case \"--host\":\n if (rawCommand === \"build\") {\n throw unsupportedOption(rawCommand, token);\n }\n host = takeValue(values, token);\n break;\n case \"--port\":\n if (rawCommand === \"build\") {\n throw unsupportedOption(rawCommand, token);\n }\n port = parsePort(takeValue(values, token));\n break;\n case \"--output\":\n if (rawCommand === \"dev\") {\n throw unsupportedOption(rawCommand, token);\n }\n output = takeValue(values, token);\n break;\n case \"--preset\":\n if (rawCommand !== \"build\") {\n throw unsupportedOption(rawCommand, token);\n }\n preset = takeValue(values, token);\n break;\n default:\n throw unsupportedOption(rawCommand, token);\n }\n }\n\n return {\n command: rawCommand,\n ...(project ? { project } : {}),\n ...(host ? { host } : {}),\n ...(output ? { output } : {}),\n ...(port !== undefined ? { port } : {}),\n ...(preset ? { preset } : {}),\n };\n}\n\nfunction parseCli(argv: readonly string[]): CliCommand | { command: \"help\" } {\n const values = [...argv];\n let app: string | undefined;\n while (values.length) {\n const token = values[0]!;\n if (token === \"--help\" || token === \"-h\") {\n return { command: \"help\" };\n }\n if (token === \"--\") {\n values.shift();\n break;\n }\n if (token !== \"--app\") break;\n values.shift();\n if (app) throw new UsageError(\"Specify a CLI App once.\");\n app = takeValue(values, token);\n }\n return {\n command: \"cli\",\n ...(app ? { app } : {}),\n argv: values,\n };\n}\n\nfunction takeValue(argv: string[], option: string): string {\n const value = argv.shift();\n if (!value || value.startsWith(\"-\")) {\n throw new UsageError(`${option} requires a value`);\n }\n return value;\n}\n\nfunction parsePort(value: string): number {\n const port = Number(value);\n if (!Number.isInteger(port) || port < 0 || port > 65_535) {\n throw new UsageError(`Invalid --port value: ${value}`);\n }\n return port;\n}\n\nfunction unsupportedOption(command: string, option: string): UsageError {\n return new UsageError(`Unknown option for capable ${command}: ${option}`);\n}\n\nexport function renderCapableHelp(): string {\n return [\n \"Capable\",\n \"\",\n \"Usage:\",\n \" capable dev [project] [--host localhost] [--port 3000]\",\n \" capable build [project] [--output .output] [--preset node-server]\",\n \" capable preview [project] [--output .output] [--host localhost] [--port 3000]\",\n \" capable cli [--app <project-or-url>] <command...>\",\n \"\",\n \"Project discovery:\",\n \" [project] or --app → CAPABLE_APP → package.json \\\"capable\\\" → capable.app.*\",\n \"\",\n ].join(\"\\n\");\n}\n\nasync function resolveCliApp(\n configured: string | undefined,\n options: Pick<RunCapableCommandOptions, \"cwd\" | \"env\">,\n): Promise<AnyApp> {\n if (configured && isHttpUrl(configured)) {\n return createRemoteApp(createHttpTransport({\n url: new URL(\"/_capable/\", configured),\n }));\n }\n\n const project = await resolveCapableProject({\n ...(configured ? { project: configured } : {}),\n ...(options.cwd ? { cwd: options.cwd } : {}),\n ...(options.env ? { env: options.env } : {}),\n });\n if (project.serverEntry) {\n const module = await import(pathToFileURL(project.serverEntry).href) as {\n readonly default?: unknown;\n };\n const server = module.default;\n if (!isFetchServer(server)) {\n throw new Error(\n `${project.serverEntry} must default-export a Capable server`,\n );\n }\n return createRemoteApp(createHttpTransport({\n url: \"http://capable.local/_capable/\",\n fetch: (request) => server.fetch(request),\n }));\n }\n\n const module = await import(pathToFileURL(project.entry).href) as {\n readonly default?: unknown;\n };\n const definition = module.default;\n if (isApp(definition)) return definition;\n if (\n !definition ||\n typeof definition !== \"object\" ||\n (definition as Partial<AppDefinition<any>>)[APPLICATION_SYMBOL] !== true\n ) {\n throw new Error(\n `${project.entry} must default-export a Capable App Definition`,\n );\n }\n return createApp(definition as AppDefinition<any, undefined>);\n}\n\nfunction isHttpUrl(value: string): boolean {\n try {\n const url = new URL(value);\n return url.protocol === \"http:\" || url.protocol === \"https:\";\n } catch {\n return false;\n }\n}\n\nfunction isFetchServer(value: unknown): value is {\n readonly fetch: (request: Request) => Response | Promise<Response>;\n} {\n return Boolean(\n value &&\n typeof value === \"object\" &&\n typeof (value as { readonly fetch?: unknown }).fetch === \"function\",\n );\n}\n\nasync function renderDevReady(\n server: CapableNitroDevServer,\n options: { readonly hasAuthoredServer: boolean },\n): Promise<string> {\n const origin = server.origin;\n const manifest = await readJson<ApplicationManifest>(\n `${origin}/_capable/manifest`,\n );\n const openapi = await readJson<Record<string, unknown>>(\n `${origin}/openapi.json`,\n );\n const mcp = await probeMcp(origin);\n const lines = [\n \"\",\n `Capable ${origin}`,\n \"\",\n ];\n lines.push(\"Index /\");\n if (manifest) {\n lines.push(\n `Application ${manifest.name} (${manifest.version})`,\n `Capabilities ${countCapabilities(manifest.capabilities)}`,\n \"Standard /_capable\",\n );\n }\n if (openapi) lines.push(\"HTTP /api\", \"OpenAPI /openapi.json\");\n if (mcp) lines.push(\"MCP /mcp\");\n if (!manifest && !openapi && options.hasAuthoredServer) {\n lines.push(\"Server authored by capable.server.ts\");\n }\n lines.push(\"\", \"Watching application dependencies\", \"\");\n return lines.join(\"\\n\");\n}\n\nasync function readJson<T>(url: string): Promise<T | undefined> {\n try {\n const response = await fetch(url);\n if (!response.ok) return undefined;\n return await response.json() as T;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Probe the default MCP mount by issuing a JSON-RPC `initialize`. The mount\n * is stateless per request, so a successful response means an agent can\n * connect at `/mcp`.\n */\nasync function probeMcp(origin: string): Promise<boolean> {\n try {\n const response = await fetch(`${origin}/mcp`, {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n accept: \"application/json, text/event-stream\",\n },\n body: JSON.stringify({\n jsonrpc: \"2.0\",\n id: 1,\n method: \"initialize\",\n params: {\n protocolVersion: \"2025-06-18\",\n capabilities: {},\n clientInfo: { name: \"capable\", version: \"0.0.0\" },\n },\n }),\n });\n if (!response.ok) return false;\n const body = await response.json().catch(() => undefined);\n return Boolean(body && body.result);\n } catch {\n return false;\n }\n}\n\nfunction countCapabilities(nodes: readonly ManifestNode[]): number {\n return nodes.reduce(\n (count, node) =>\n count + (node.type === \"capability\"\n ? 1\n : countCapabilities(node.children)),\n 0,\n );\n}\n\nfunction waitForShutdown(): Promise<void> {\n return new Promise((resolve) => {\n const finish = () => {\n process.off(\"SIGINT\", finish);\n process.off(\"SIGTERM\", finish);\n resolve();\n };\n process.once(\"SIGINT\", finish);\n process.once(\"SIGTERM\", finish);\n });\n}\n","#!/usr/bin/env node\nimport { runCapableCommand } from \"@capable/toolchain\";\n\nprocess.exit(await runCapableCommand(process.argv.slice(2)));\n"],"mappings":";;;;;;;;;;;AAWA,MAAM,wBAAwB,cAAc,IAAI,IAAI,gBAAgB,OAAO,KAAK,GAAG,CAAC;AACpF,MAAM,oBAAoB,cAAc,IAAI,IAAI,oBAAoB,OAAO,KAAK,GAAG,CAAC;AACpF,MAAM,0BAA0B,cAC9B,IAAI,IAAI,2BAA2B,OAAO,KAAK,GAAG,CACpD;AACA,MAAM,2BAA2B,cAC/B,IAAI,IAAI,uBAAuB,OAAO,KAAK,GAAG,CAChD;AAaA,eAAsB,2BAA2B,SAId;CACjC,MAAM,QAAQ,MAAM,YAClB,yBAAyB,QAAQ,SAAS,EAAE,KAAK,KAAK,CAAC,CACzD;CACA,MAAM,SAAS,gBAAgB,KAAK;CAEpC,IAAI;EACF,MAAM,WAAW,OAAO,OAAO;GAC7B,MAAM,QAAQ,QAAQ;GACtB,UAAU,QAAQ,YAAY;GAC9B,QAAQ;EACV,CAAC;EACD,MAAM,SAAS,MAAM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,SAAS,kBAAiC;CACxC,OAAO,IAAI,SAAS,YAAY;EAC9B,MAAM,eAAe;GACnB,QAAQ,IAAI,UAAU,MAAM;GAC5B,QAAQ,IAAI,WAAW,MAAM;GAC7B,QAAQ;EACV;EACA,QAAQ,KAAK,UAAU,MAAM;EAC7B,QAAQ,KAAK,WAAW,MAAM;CAChC,CAAC;AACH;;;ACndA,QAAQ,KAAK,MAAM,kBAAkB,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"bin.mjs","names":[],"sources":["../../nitro-host/src/index.ts","../../toolchain/src/help.ts","../../toolchain/src/project.ts","../../toolchain/src/init.ts","../../toolchain/src/index.ts","../src/bin.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport {\n build,\n createDevServer,\n createNitro,\n prepare,\n} from \"nitro/builder\";\nimport type { NitroConfig } from \"nitro/types\";\n\nconst virtualServerEntry = \"#capable/entry\";\n\n/**\n * Support code for the virtual entry. It sits beside this module as\n * TypeScript in the repository and as bundled JavaScript in a published\n * package, so resolve whichever extension is actually there.\n */\nfunction runtimeSupportModule(): string {\n for (const extension of [\".ts\", \".mjs\", \".js\"]) {\n const candidate = fileURLToPath(\n new URL(`./runtime-support${extension}`, import.meta.url),\n );\n if (existsSync(candidate)) return candidate;\n }\n throw new Error(\"Missing the Capable Nitro runtime support module\");\n}\n\n/**\n * Render Nitro's in-memory server entry. Keeping the entry virtual lets Nitro\n * transform the project's `#capable/*` aliases without writing generated files\n * into the project.\n */\nfunction renderServerEntry(\n project: CapableNitroProject,\n options: { readonly dev: boolean },\n): string {\n const hasServer = Boolean(project.serverEntry);\n return [\n `import { createCapableNitroEntry } from ${\n JSON.stringify(runtimeSupportModule())\n };`,\n 'import definition from \"#capable/app\";',\n ...(hasServer ? ['import server from \"#capable/server\";'] : []),\n \"\",\n \"export default createCapableNitroEntry({\",\n \" definition,\",\n ...(hasServer ? [\" server,\"] : []),\n ` dev: ${options.dev},`,\n \"});\",\n \"\",\n ].join(\"\\n\");\n}\n\nexport type CapableNitroProject = {\n readonly rootDir: string;\n readonly entry: string | URL;\n readonly serverEntry?: string | URL;\n};\n\nexport type CapableNitroDevServer = {\n readonly origin: string;\n close(): Promise<void>;\n};\n\nexport async function startCapableNitroDevServer(options: {\n project: CapableNitroProject;\n hostname?: string;\n port?: number;\n}): Promise<CapableNitroDevServer> {\n const nitro = await createNitro(\n createCapableNitroConfig(options.project, { dev: true }),\n );\n const server = createDevServer(nitro);\n\n try {\n const listener = server.listen({\n port: options.port ?? 3000,\n hostname: options.hostname ?? \"localhost\",\n silent: true,\n });\n await listener.ready();\n await prepare(nitro);\n await build(nitro);\n\n if (!listener.url) {\n throw new Error(\"Nitro dev server started without a public URL\");\n }\n\n return {\n origin: listener.url.replace(/\\/$/, \"\"),\n close: () => nitro.close(),\n };\n } catch (error) {\n await nitro.close();\n throw error;\n }\n}\n\nexport async function buildCapableNitroApplication(options: {\n project: CapableNitroProject;\n outputDir?: string;\n preset?: string;\n}): Promise<{ outputDir: string }> {\n const outputDir = options.outputDir\n ? path.resolve(options.project.rootDir, options.outputDir)\n : undefined;\n const nitro = await createNitro(\n createCapableNitroConfig(options.project, {\n dev: false,\n ...(outputDir ? { outputDir } : {}),\n ...(options.preset ? { preset: options.preset } : {}),\n }),\n );\n\n try {\n await prepare(nitro);\n await build(nitro);\n return { outputDir: nitro.options.output.dir };\n } finally {\n await nitro.close();\n }\n}\n\nexport async function resolveCapableNitroPreviewCommand(outputDir: string): Promise<{\n command: string;\n cwd: string;\n}> {\n const cwd = path.resolve(outputDir);\n const manifestPath = path.join(cwd, \"nitro.json\");\n let manifest: {\n preset?: unknown;\n commands?: { preview?: unknown };\n };\n try {\n manifest = JSON.parse(await readFile(manifestPath, \"utf8\")) as {\n preset?: unknown;\n commands?: { preview?: unknown };\n };\n } catch {\n throw new Error(`Could not read a runnable Capable build at ${manifestPath}. Run \\`cap build\\` with the node-server preset first.`);\n }\n\n const command = manifest.commands?.preview;\n if (typeof command !== \"string\" || !command.trim()) {\n throw new Error(\n `The Nitro ${String(manifest.preset ?? \"deployment\")} preset does not produce a locally runnable preview command. Build with the node-server preset to use \\`cap preview\\`.`,\n );\n }\n return { command, cwd };\n}\n\nfunction createCapableNitroConfig(\n project: CapableNitroProject,\n options: {\n dev: boolean;\n outputDir?: string;\n preset?: string;\n },\n): NitroConfig {\n const entry = project.entry instanceof URL\n ? fileURLToPath(project.entry)\n : path.resolve(project.entry);\n const serverEntry = project.serverEntry instanceof URL\n ? fileURLToPath(project.serverEntry)\n : project.serverEntry\n ? path.resolve(project.serverEntry)\n : undefined;\n\n return {\n rootDir: project.rootDir,\n dev: options.dev,\n preset: options.dev ? \"nitro-dev\" : options.preset ?? \"node-server\",\n compatibilityDate: \"2026-07-15\",\n alias: serverEntry\n ? { \"#capable/server\": serverEntry, \"#capable/app\": entry }\n : { \"#capable/app\": entry },\n virtual: {\n [virtualServerEntry]: renderServerEntry(project, { dev: options.dev }),\n },\n serverEntry: virtualServerEntry,\n serverDir: false,\n scanDirs: [],\n imports: false,\n noPublicDir: true,\n logLevel: 2,\n logging: { buildSuccess: false },\n framework: { name: \"capable\" },\n ...(options.outputDir ? { output: { dir: options.outputDir } } : {}),\n };\n}\n","import {\n createCliStyle,\n descriptionColumn,\n MARGIN,\n renderRows,\n renderSection,\n supportsColor,\n type CliRow,\n type CliStyle,\n} from \"@capable/cli\";\n\nexport type HelpTopic = \"init\" | \"dev\" | \"build\" | \"preview\" | \"cli\";\n\nconst HELP_OPTION: CliRow = { label: \"-h, --help\", description: \"Show help\" };\n\nconst APP_OPTION: CliRow = {\n label: \"--app <path>\",\n description: \"Project directory or App entry\",\n};\n\nconst COMMANDS: readonly CliRow[] = [\n { label: \"init [directory]\", description: \"Create a starter Capable App\" },\n { label: \"dev [project]\", description: \"Run the development server\" },\n { label: \"build [project]\", description: \"Build the App for deployment\" },\n { label: \"preview [project]\", description: \"Serve the built App\" },\n { label: \"cli <command...>\", description: \"Call Capabilities from your terminal\" },\n];\n\nconst TOPICS: Record<HelpTopic, {\n readonly usage: string;\n readonly summary: string;\n readonly options: readonly CliRow[];\n readonly footer?: string;\n}> = {\n init: {\n usage: \"cap init [directory]\",\n summary: \"Create a runnable App package without overwriting existing work.\",\n options: [HELP_OPTION],\n },\n dev: {\n usage: \"cap dev [project] [options]\",\n summary: \"Run the development server with live reload.\",\n options: [\n { label: \"--host <host>\", description: \"Hostname to bind (default: localhost)\" },\n { label: \"--port <port>\", description: \"Port to bind (default: 3000)\" },\n APP_OPTION,\n HELP_OPTION,\n ],\n },\n build: {\n usage: \"cap build [project] [options]\",\n summary: \"Build the App for deployment.\",\n options: [\n { label: \"--output <dir>\", description: \"Build directory (default: .output)\" },\n { label: \"--preset <preset>\", description: \"Nitro preset (default: node-server)\" },\n APP_OPTION,\n HELP_OPTION,\n ],\n },\n preview: {\n usage: \"cap preview [project] [options]\",\n summary: \"Serve a previous build the way production will.\",\n options: [\n { label: \"--output <dir>\", description: \"Build directory (default: .output)\" },\n { label: \"--host <host>\", description: \"Hostname to bind (default: localhost)\" },\n { label: \"--port <port>\", description: \"Port to bind (default: 3000)\" },\n APP_OPTION,\n HELP_OPTION,\n ],\n },\n cli: {\n usage: \"cap cli [options] <command...>\",\n summary: \"Call your App's Capabilities from the terminal.\",\n options: [\n {\n label: \"--app <path|url>\",\n description: \"Project, App entry, or a running Capable server URL\",\n },\n HELP_OPTION,\n ],\n footer: \"Run `cap cli -- --help` to list the commands your App derives.\",\n },\n};\n\nexport function renderCapableHelp(\n topic?: HelpTopic,\n options: { readonly color?: boolean } = {},\n): string {\n const style = createCliStyle(options.color ?? supportsColor());\n return topic ? renderTopicHelp(topic, style) : renderRootHelp(style);\n}\n\nfunction renderRootHelp(style: CliStyle): string {\n const options = [HELP_OPTION];\n const column = descriptionColumn([...COMMANDS, ...options]);\n return page([\n banner(\"cap <command> [options]\", \"Develop, build, and call Capable Apps\", style, \"Capable\"),\n renderSection(\"Commands\", renderRows(COMMANDS, style, { column }), style),\n renderSection(\"Options\", renderRows(options, style, { column }), style),\n renderSection(\n \"Project discovery\",\n `${MARGIN}${MARGIN}${style.dim(\n '[project] or --app → CAPABLE_APP → package.json \"capable\" → capable.app.*',\n )}`,\n style,\n ),\n `${MARGIN}${style.dim(\"Run `cap <command> --help` for details on a command.\")}`,\n ]);\n}\n\nfunction renderTopicHelp(topic: HelpTopic, style: CliStyle): string {\n const { usage, summary, options, footer } = TOPICS[topic];\n return page([\n banner(usage, summary, style),\n renderSection(\"Options\", renderRows(options, style), style),\n footer ? `${MARGIN}${style.dim(footer)}` : undefined,\n ]);\n}\n\nfunction banner(\n usage: string,\n summary: string,\n style: CliStyle,\n title?: string,\n): string {\n return title\n ? [\n `${MARGIN}${style.bold(title)}\\n${MARGIN}${style.dim(summary)}`,\n `${MARGIN}${style.accent(usage)}`,\n ].join(\"\\n\\n\")\n : `${MARGIN}${style.bold(usage)}\\n\\n${MARGIN}${style.dim(summary)}`;\n}\n\nfunction page(sections: readonly (string | undefined)[]): string {\n return `\\n${sections.filter(Boolean).join(\"\\n\\n\")}\\n`;\n}\n","import { readFile, stat } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport type { CapableNitroProject } from \"@capable/nitro-host\";\n\nexport const CAPABLE_APPLICATION_ENTRIES = [\n \"capable.app.ts\",\n \"capable.app.tsx\",\n \"capable.app.js\",\n \"capable.app.mjs\",\n \"capable.app.cjs\",\n] as const;\n\nconst SERVER_ENTRIES = [\n \"capable.server.ts\",\n \"capable.server.tsx\",\n \"capable.server.js\",\n \"capable.server.mjs\",\n \"capable.server.cjs\",\n] as const;\n\nexport type ResolvedCapableProject = CapableNitroProject & {\n readonly entry: string;\n readonly serverEntry?: string;\n};\n\nexport async function resolveCapableProject(options: {\n readonly project?: string;\n readonly cwd?: string;\n readonly env?: Readonly<Record<string, string | undefined>>;\n} = {}): Promise<ResolvedCapableProject> {\n const cwd = path.resolve(options.cwd ?? process.cwd());\n const env = options.env ?? process.env;\n const configured =\n options.project ??\n env.CAPABLE_APP ??\n await readPackageEntry(cwd);\n const candidate = path.resolve(cwd, configured ?? \".\");\n const candidateStat = await stat(candidate).catch(() => undefined);\n\n let entry: string | undefined;\n let rootDir: string;\n if (candidateStat?.isFile()) {\n entry = candidate;\n rootDir = await findPackageRoot(path.dirname(candidate)) ??\n path.dirname(candidate);\n } else if (candidateStat?.isDirectory()) {\n entry = await findEntry(candidate, CAPABLE_APPLICATION_ENTRIES);\n rootDir = await findPackageRoot(candidate) ?? candidate;\n } else {\n throw projectNotFound(candidate, configured);\n }\n\n if (!entry) throw projectNotFound(candidate, configured);\n const serverEntry = await findEntry(rootDir, SERVER_ENTRIES);\n return {\n rootDir,\n entry,\n ...(serverEntry ? { serverEntry } : {}),\n };\n}\n\nasync function readPackageEntry(cwd: string): Promise<string | undefined> {\n try {\n const value = JSON.parse(\n await readFile(path.join(cwd, \"package.json\"), \"utf8\"),\n ) as { readonly capable?: unknown };\n return typeof value.capable === \"string\" ? value.capable : undefined;\n } catch {\n return undefined;\n }\n}\n\nasync function findPackageRoot(start: string): Promise<string | undefined> {\n let directory = start;\n while (true) {\n if ((await stat(path.join(directory, \"package.json\")).catch(() => undefined))\n ?.isFile()) {\n return directory;\n }\n const parent = path.dirname(directory);\n if (parent === directory) return undefined;\n directory = parent;\n }\n}\n\nasync function findEntry(\n directory: string,\n names: readonly string[],\n): Promise<string | undefined> {\n for (const name of names) {\n const candidate = path.join(directory, name);\n if ((await stat(candidate).catch(() => undefined))?.isFile()) {\n return candidate;\n }\n }\n return undefined;\n}\n\nfunction projectNotFound(candidate: string, configured?: string): Error {\n return new Error(\n configured\n ? `Could not find a Capable application at ${candidate}`\n : `Could not find ${CAPABLE_APPLICATION_ENTRIES.join(\", \")} in ${candidate}`,\n );\n}\n","import { mkdir, readFile, stat, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { CAPABLE_APPLICATION_ENTRIES } from \"./project.ts\";\n\nfunction starter(appName: string): string {\n return `import { capability, defineApp } from \"capable-kit\";\nimport { z } from \"zod\";\n\nconst hello = capability({\n id: \"hello\",\n title: \"Say hello\",\n effect: \"read\",\n output: z.object({ message: z.string() }),\n handler: () => ({ message: \"Hello from Capable\" }),\n});\n\nexport default defineApp({\n name: ${JSON.stringify(appName)},\n capabilities: { hello },\n});\n`;\n}\n\nconst SCRIPTS = {\n dev: \"cap dev\",\n build: \"cap build\",\n preview: \"cap preview\",\n} as const;\n\nconst DEPENDENCIES = {\n \"capable-kit\": \"latest\",\n zod: \"^4.0.0\",\n} as const;\n\nexport async function initializeCapableProject(options: {\n readonly directory: string;\n}): Promise<{\n readonly entry: string;\n readonly packageJson: string;\n readonly packageAction: \"created\" | \"updated\" | \"unchanged\";\n}> {\n const directory = path.resolve(options.directory);\n await mkdir(directory, { recursive: true });\n\n const packageJson = path.join(directory, \"package.json\");\n const existingPackage = await readPackageJson(packageJson);\n if (typeof existingPackage?.capable === \"string\") {\n throw new Error(\n `package.json already configures a Capable application at ${existingPackage.capable}`,\n );\n }\n\n for (const name of CAPABLE_APPLICATION_ENTRIES) {\n const existing = path.join(directory, name);\n if ((await stat(existing).catch(() => undefined))?.isFile()) {\n throw new Error(`A Capable application already exists at ${existing}`);\n }\n }\n\n const entry = path.join(directory, CAPABLE_APPLICATION_ENTRIES[0]);\n const packageResult = preparePackageJson(directory, existingPackage);\n await writeFile(\n entry,\n starter(applicationName(directory, packageResult.value)),\n { flag: \"wx\" },\n );\n if (packageResult.action !== \"unchanged\") {\n await writeFile(\n packageJson,\n `${JSON.stringify(packageResult.value, null, 2)}\\n`,\n existingPackage ? undefined : { flag: \"wx\" },\n );\n }\n return {\n entry,\n packageJson,\n packageAction: packageResult.action,\n };\n}\n\nasync function readPackageJson(\n filename: string,\n): Promise<Record<string, unknown> | undefined> {\n let source: string;\n try {\n source = await readFile(filename, \"utf8\");\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") return undefined;\n throw error;\n }\n const value = JSON.parse(source) as unknown;\n if (!isRecord(value)) {\n throw new Error(`${filename} must contain a JSON object`);\n }\n return value;\n}\n\nfunction preparePackageJson(\n directory: string,\n existing: Record<string, unknown> | undefined,\n): {\n readonly value: Record<string, unknown>;\n readonly action: \"created\" | \"updated\" | \"unchanged\";\n} {\n if (!existing) {\n return {\n action: \"created\",\n value: {\n name: packageName(directory),\n private: true,\n version: \"0.0.0\",\n type: \"module\",\n scripts: SCRIPTS,\n dependencies: DEPENDENCIES,\n },\n };\n }\n\n let changed = false;\n const value = { ...existing };\n const scripts = readObjectField(value, \"scripts\");\n for (const [name, command] of Object.entries(SCRIPTS)) {\n if (name in scripts) continue;\n scripts[name] = command;\n changed = true;\n }\n if (changed || !(\"scripts\" in value)) value.scripts = scripts;\n\n const dependencies = readObjectField(value, \"dependencies\");\n for (const [name, version] of Object.entries(DEPENDENCIES)) {\n if (hasDeclaredDependency(value, name)) continue;\n dependencies[name] = version;\n changed = true;\n }\n if (Object.keys(dependencies).length || \"dependencies\" in value) {\n value.dependencies = dependencies;\n }\n\n return {\n value,\n action: changed ? \"updated\" : \"unchanged\",\n };\n}\n\nfunction readObjectField(\n value: Record<string, unknown>,\n field: string,\n): Record<string, unknown> {\n const current = value[field];\n if (current === undefined) return {};\n if (!isRecord(current)) {\n throw new Error(`package.json \"${field}\" must be an object`);\n }\n return { ...current };\n}\n\nfunction hasDeclaredDependency(\n packageJson: Record<string, unknown>,\n name: string,\n): boolean {\n return [\n \"dependencies\",\n \"devDependencies\",\n \"peerDependencies\",\n \"optionalDependencies\",\n ].some((field) => {\n const dependencies = packageJson[field];\n return isRecord(dependencies) && name in dependencies;\n });\n}\n\nfunction packageName(directory: string): string {\n return path.basename(directory)\n .toLowerCase()\n .replace(/[^a-z0-9._-]+/g, \"-\")\n .replace(/^[-._]+|[-._]+$/g, \"\") || \"capable-app\";\n}\n\nfunction applicationName(\n directory: string,\n packageJson: Record<string, unknown>,\n): string {\n const configured = typeof packageJson.name === \"string\"\n ? packageJson.name.split(\"/\").at(-1)\n : undefined;\n const name = configured || path.basename(directory);\n return name\n .split(/[-_.\\s]+/)\n .filter(Boolean)\n .map((part) => `${part[0]!.toUpperCase()}${part.slice(1)}`)\n .join(\" \") || \"Capable App\";\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return Boolean(value && typeof value === \"object\" && !Array.isArray(value));\n}\n","import path from \"node:path\";\nimport { spawn } from \"node:child_process\";\nimport { pathToFileURL } from \"node:url\";\nimport { runCli } from \"@capable/cli\";\nimport {\n APPLICATION_SYMBOL,\n type AppDefinition,\n} from \"@capable/core\";\nimport {\n buildCapableNitroApplication,\n resolveCapableNitroPreviewCommand,\n startCapableNitroDevServer,\n type CapableNitroDevServer,\n} from \"@capable/nitro-host\";\nimport {\n createApp,\n createRemoteApp,\n isApp,\n type AnyApp,\n type ApplicationManifest,\n type ManifestNode,\n} from \"@capable/app\";\nimport { createHttpTransport } from \"@capable/fetch\";\nimport { renderCapableHelp, type HelpTopic } from \"./help.ts\";\nimport { initializeCapableProject } from \"./init.ts\";\nimport { resolveCapableProject } from \"./project.ts\";\n\nexport { renderCapableHelp, type HelpTopic } from \"./help.ts\";\n\nexport { resolveCapableProject, type ResolvedCapableProject } from \"./project.ts\";\n\ntype Write = (text: string) => void;\n\nexport type RunCapableCommandOptions = {\n readonly cwd?: string;\n readonly env?: Readonly<Record<string, string | undefined>>;\n readonly stdout?: Write;\n readonly stderr?: Write;\n};\n\ntype LifecycleCommand = {\n readonly command: \"dev\" | \"build\" | \"preview\";\n readonly project?: string;\n readonly host?: string;\n readonly output?: string;\n readonly port?: number;\n readonly preset?: string;\n};\n\ntype CliCommand = {\n readonly command: \"cli\";\n readonly app?: string;\n readonly argv: readonly string[];\n};\n\ntype HelpCommand = {\n readonly command: \"help\";\n readonly topic?: HelpTopic;\n};\n\ntype InitCommand = {\n readonly command: \"init\";\n readonly project?: string;\n};\n\ntype ParsedCommand = LifecycleCommand | CliCommand | InitCommand | HelpCommand;\n\nclass UsageError extends Error {}\n\nexport async function runCapableCommand(\n argv: readonly string[],\n options: RunCapableCommandOptions = {},\n): Promise<number> {\n const stdout = options.stdout ?? ((text) => process.stdout.write(text));\n const stderr = options.stderr ?? ((text) => process.stderr.write(text));\n try {\n const command = parseCapableCommand(argv);\n if (command.command === \"help\") {\n stdout(renderCapableHelp(command.topic, {\n color: !options.stdout && Boolean(process.stdout.isTTY),\n }));\n return 0;\n }\n if (command.command === \"cli\") {\n return runCli({\n app: await resolveCliApp(command.app, options),\n argv: command.argv,\n ...(!options.stdout && process.stdout.isTTY\n ? { isTTY: true }\n : {}),\n ...(!options.stdout && process.stdout.columns\n ? { columns: process.stdout.columns }\n : {}),\n ...(options.stdout || options.stderr\n ? {\n io: {\n ...(options.stdout ? { stdout: options.stdout } : {}),\n ...(options.stderr ? { stderr: options.stderr } : {}),\n },\n }\n : {}),\n });\n }\n if (command.command === \"init\") {\n const cwd = path.resolve(options.cwd ?? process.cwd());\n const directory = path.resolve(cwd, command.project ?? \".\");\n const result = await initializeCapableProject({ directory });\n const entry = path.relative(cwd, result.entry) ||\n path.basename(result.entry);\n const packageJson = path.relative(cwd, result.packageJson) ||\n path.basename(result.packageJson);\n stdout([\n `Created ${entry}`,\n ...(result.packageAction === \"unchanged\"\n ? []\n : [`${capitalize(result.packageAction)} ${packageJson}`]),\n \"\",\n \"Next:\",\n ...(command.project\n ? [` cd ${shellArgument(command.project)}`]\n : []),\n \" pnpm install\",\n \" pnpm dev\",\n \"\",\n ].join(\"\\n\"));\n return 0;\n }\n\n const project = await resolveCapableProject({\n ...(command.project ? { project: command.project } : {}),\n ...(options.cwd ? { cwd: options.cwd } : {}),\n ...(options.env ? { env: options.env } : {}),\n });\n\n if (command.command === \"dev\") {\n const server = await startCapableNitroDevServer({\n project,\n ...(command.host ? { hostname: command.host } : {}),\n ...(command.port !== undefined ? { port: command.port } : {}),\n });\n try {\n stdout(await renderDevReady(server, {\n hasAuthoredServer: Boolean(project.serverEntry),\n color: !options.stdout && Boolean(process.stdout.isTTY),\n }));\n await waitForShutdown();\n } finally {\n await server.close();\n }\n return 0;\n }\n\n if (command.command === \"build\") {\n const result = await buildCapableNitroApplication({\n project,\n ...(command.output ? { outputDir: command.output } : {}),\n ...(command.preset ? { preset: command.preset } : {}),\n });\n stdout(`Built Capable application at ${result.outputDir}\\n`);\n return 0;\n }\n\n const outputDir = path.resolve(\n project.rootDir,\n command.output ?? \".output\",\n );\n const preview = await resolveCapableNitroPreviewCommand(outputDir);\n const child = spawn(preview.command, {\n cwd: preview.cwd,\n env: {\n ...process.env,\n ...(command.host ? { NITRO_HOST: command.host } : {}),\n ...(command.port !== undefined\n ? { NITRO_PORT: String(command.port) }\n : {}),\n },\n shell: true,\n stdio: \"inherit\",\n });\n return await new Promise<number>((resolve, reject) => {\n child.once(\"error\", reject);\n child.once(\"exit\", (code, signal) => {\n if (code !== null) return resolve(code);\n reject(new Error(`Preview process exited from signal ${signal ?? \"unknown\"}`));\n });\n });\n } catch (error) {\n stderr(`${error instanceof Error ? error.message : String(error)}\\n`);\n if (error instanceof UsageError) {\n stderr(\"Run `cap --help` for usage.\\n\");\n return 2;\n }\n return 1;\n }\n}\n\nexport function parseCapableCommand(argv: readonly string[]): ParsedCommand {\n const [rawCommand, ...rest] = argv;\n if (\n rawCommand === undefined ||\n rawCommand === \"help\" ||\n rawCommand === \"--help\" ||\n rawCommand === \"-h\"\n ) {\n return { command: \"help\" };\n }\n if (rawCommand === \"start\") {\n throw new UsageError(\"`cap start` was renamed to `cap preview`.\");\n }\n if (rawCommand === \"cli\") return parseCli(rest);\n if (rawCommand === \"init\") return parseInit(rest);\n if (\n rawCommand !== \"dev\" &&\n rawCommand !== \"build\" &&\n rawCommand !== \"preview\"\n ) {\n throw new UsageError(`Unknown Capable command: ${rawCommand}`);\n }\n if (rest.includes(\"--help\") || rest.includes(\"-h\")) {\n return { command: \"help\", topic: rawCommand };\n }\n\n const values = [...rest];\n let project: string | undefined;\n let host: string | undefined;\n let output: string | undefined;\n let port: number | undefined;\n let preset: string | undefined;\n\n while (values.length) {\n const token = values.shift()!;\n if (!token.startsWith(\"-\")) {\n if (project) {\n throw new UsageError(\n `Unexpected argument for cap ${rawCommand}: ${token}`,\n );\n }\n project = token;\n continue;\n }\n switch (token) {\n case \"--app\":\n if (project) {\n throw new UsageError(\"Specify a project path once.\");\n }\n project = takeValue(values, token);\n break;\n case \"--host\":\n if (rawCommand === \"build\") {\n throw unsupportedOption(rawCommand, token);\n }\n host = takeValue(values, token);\n break;\n case \"--port\":\n if (rawCommand === \"build\") {\n throw unsupportedOption(rawCommand, token);\n }\n port = parsePort(takeValue(values, token));\n break;\n case \"--output\":\n if (rawCommand === \"dev\") {\n throw unsupportedOption(rawCommand, token);\n }\n output = takeValue(values, token);\n break;\n case \"--preset\":\n if (rawCommand !== \"build\") {\n throw unsupportedOption(rawCommand, token);\n }\n preset = takeValue(values, token);\n break;\n default:\n throw unsupportedOption(rawCommand, token);\n }\n }\n\n return {\n command: rawCommand,\n ...(project ? { project } : {}),\n ...(host ? { host } : {}),\n ...(output ? { output } : {}),\n ...(port !== undefined ? { port } : {}),\n ...(preset ? { preset } : {}),\n };\n}\n\nfunction parseInit(argv: readonly string[]): InitCommand | HelpCommand {\n if (argv.includes(\"--help\") || argv.includes(\"-h\")) {\n return { command: \"help\", topic: \"init\" };\n }\n if (argv.length > 1) {\n throw new UsageError(`Unexpected argument for cap init: ${argv[1]}`);\n }\n const project = argv[0];\n if (project?.startsWith(\"-\")) {\n throw unsupportedOption(\"init\", project);\n }\n return {\n command: \"init\",\n ...(project ? { project } : {}),\n };\n}\n\nfunction parseCli(argv: readonly string[]): CliCommand | HelpCommand {\n const values = [...argv];\n let app: string | undefined;\n while (values.length) {\n const token = values[0]!;\n if (token === \"--help\" || token === \"-h\") {\n return { command: \"help\", topic: \"cli\" };\n }\n if (token === \"--\") {\n values.shift();\n break;\n }\n if (token !== \"--app\") break;\n values.shift();\n if (app) throw new UsageError(\"Specify a CLI App once.\");\n app = takeValue(values, token);\n }\n return {\n command: \"cli\",\n ...(app ? { app } : {}),\n argv: values,\n };\n}\n\nfunction takeValue(argv: string[], option: string): string {\n const value = argv.shift();\n if (!value || value.startsWith(\"-\")) {\n throw new UsageError(`${option} requires a value`);\n }\n return value;\n}\n\nfunction parsePort(value: string): number {\n const port = Number(value);\n if (!Number.isInteger(port) || port < 0 || port > 65_535) {\n throw new UsageError(`Invalid --port value: ${value}`);\n }\n return port;\n}\n\nfunction unsupportedOption(command: string, option: string): UsageError {\n return new UsageError(`Unknown option for cap ${command}: ${option}`);\n}\n\nfunction capitalize(value: string): string {\n return `${value[0]?.toUpperCase() ?? \"\"}${value.slice(1)}`;\n}\n\nfunction shellArgument(value: string): string {\n return /^[a-zA-Z0-9_./-]+$/.test(value)\n ? value\n : `'${value.replaceAll(\"'\", \"'\\\\''\")}'`;\n}\n\nasync function resolveCliApp(\n configured: string | undefined,\n options: Pick<RunCapableCommandOptions, \"cwd\" | \"env\">,\n): Promise<AnyApp> {\n if (configured && isHttpUrl(configured)) {\n return createRemoteApp(createHttpTransport({\n url: new URL(\"/_capable/\", configured),\n }));\n }\n\n const project = await resolveCapableProject({\n ...(configured ? { project: configured } : {}),\n ...(options.cwd ? { cwd: options.cwd } : {}),\n ...(options.env ? { env: options.env } : {}),\n });\n if (project.serverEntry) {\n const module = await import(pathToFileURL(project.serverEntry).href) as {\n readonly default?: unknown;\n };\n const server = module.default;\n if (!isFetchServer(server)) {\n throw new Error(\n `${project.serverEntry} must default-export a Capable server`,\n );\n }\n return createRemoteApp(createHttpTransport({\n url: \"http://capable.local/_capable/\",\n fetch: (request) => server.fetch(request),\n }));\n }\n\n const module = await import(pathToFileURL(project.entry).href) as {\n readonly default?: unknown;\n };\n const definition = module.default;\n if (isApp(definition)) return definition;\n if (\n !definition ||\n typeof definition !== \"object\" ||\n (definition as Partial<AppDefinition<any>>)[APPLICATION_SYMBOL] !== true\n ) {\n throw new Error(\n `${project.entry} must default-export a Capable App Definition`,\n );\n }\n return createApp(definition as AppDefinition<any, undefined>);\n}\n\nfunction isHttpUrl(value: string): boolean {\n try {\n const url = new URL(value);\n return url.protocol === \"http:\" || url.protocol === \"https:\";\n } catch {\n return false;\n }\n}\n\nfunction isFetchServer(value: unknown): value is {\n readonly fetch: (request: Request) => Response | Promise<Response>;\n} {\n return Boolean(\n value &&\n typeof value === \"object\" &&\n typeof (value as { readonly fetch?: unknown }).fetch === \"function\",\n );\n}\n\nasync function renderDevReady(\n server: CapableNitroDevServer,\n options: {\n readonly hasAuthoredServer: boolean;\n readonly color?: boolean;\n },\n): Promise<string> {\n const origin = server.origin;\n const manifest = await readJson<ApplicationManifest>(\n `${origin}/_capable/manifest`,\n );\n const openapi = await readJson<Record<string, unknown>>(\n `${origin}/openapi.json`,\n );\n const mcp = await probeMcp(origin);\n\n const paint = createPainter(options.color ?? false);\n const routes: Array<readonly [string, string]> = [\n [\"Local\", displayOrigin(origin)],\n ];\n if (manifest) routes.push([\"Standard\", \"/_capable\"]);\n if (openapi) {\n routes.push([\"HTTP\", \"/api\"], [\"OpenAPI\", \"/openapi.json\"]);\n }\n if (mcp) routes.push([\"MCP\", \"/mcp\"]);\n if (!manifest && !openapi && options.hasAuthoredServer) {\n routes.push([\"Server\", \"capable.server.ts\"]);\n }\n const width = routes.reduce((max, [label]) => Math.max(max, label.length), 0);\n\n const heading = manifest\n ? `${paint.bold(manifest.name)} ${paint.dim(manifest.version)}`\n : paint.bold(\"Capable\");\n const summary = manifest\n ? `${plural(\n countCapabilities(manifest.capabilities),\n \"capability\",\n \"capabilities\",\n )} ready, watching for changes`\n : \"Ready, watching for changes\";\n\n return [\n \"\",\n `${paint.accent(\"◆\")} ${heading}`,\n \"\",\n ...routes.map(([label, value]) =>\n `${paint.dim(label.padEnd(width))} ${value}`\n ),\n \"\",\n `${paint.accent(\"✓\")} ${paint.dim(summary)}`,\n \"\",\n ...(manifest\n ? [\n `${paint.dim(\"Call these capabilities from your terminal:\")}`,\n ` ${paint.bold(\"cap cli --help\")} ${paint.dim(\"every command, typed and documented\")}`,\n \"\",\n ]\n : []),\n \"\",\n ].join(\"\\n\");\n}\n\n/** Wildcard and loopback hosts are noise in a dev banner; show localhost. */\nfunction displayOrigin(origin: string): string {\n try {\n const url = new URL(origin);\n if (\n url.hostname === \"[::1]\" || url.hostname === \"::1\" ||\n url.hostname === \"127.0.0.1\" || url.hostname === \"0.0.0.0\" ||\n url.hostname === \"[::]\"\n ) {\n url.hostname = \"localhost\";\n }\n return url.toString().replace(/\\/$/, \"\");\n } catch {\n return origin;\n }\n}\n\nfunction plural(count: number, one: string, many: string): string {\n return `${count} ${count === 1 ? one : many}`;\n}\n\nfunction createPainter(enabled: boolean) {\n const wrap = (code: string) =>\n (text: string) => (enabled ? `\\u001B[${code}m${text}\\u001B[0m` : text);\n return {\n bold: wrap(\"1\"),\n dim: wrap(\"2\"),\n accent: wrap(\"36\"),\n };\n}\n\nasync function readJson<T>(url: string): Promise<T | undefined> {\n try {\n const response = await fetch(url);\n if (!response.ok) return undefined;\n return await response.json() as T;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Probe the default MCP mount by issuing a JSON-RPC `initialize`. The mount\n * is stateless per request, so a successful response means an agent can\n * connect at `/mcp`.\n */\nasync function probeMcp(origin: string): Promise<boolean> {\n try {\n const response = await fetch(`${origin}/mcp`, {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n accept: \"application/json, text/event-stream\",\n },\n body: JSON.stringify({\n jsonrpc: \"2.0\",\n id: 1,\n method: \"initialize\",\n params: {\n protocolVersion: \"2025-06-18\",\n capabilities: {},\n clientInfo: { name: \"capable\", version: \"0.0.0\" },\n },\n }),\n });\n if (!response.ok) return false;\n const body = await response.json().catch(() => undefined);\n return Boolean(body && body.result);\n } catch {\n return false;\n }\n}\n\nfunction countCapabilities(nodes: readonly ManifestNode[]): number {\n return nodes.reduce(\n (count, node) =>\n count + (node.type === \"capability\"\n ? 1\n : countCapabilities(node.children)),\n 0,\n );\n}\n\nfunction waitForShutdown(): Promise<void> {\n return new Promise((resolve) => {\n const finish = () => {\n process.off(\"SIGINT\", finish);\n process.off(\"SIGTERM\", finish);\n resolve();\n };\n process.once(\"SIGINT\", finish);\n process.once(\"SIGTERM\", finish);\n });\n}\n","#!/usr/bin/env node\nimport { runCapableCommand } from \"@capable/toolchain\";\n\nprocess.exit(await runCapableCommand(process.argv.slice(2)));\n"],"mappings":";;;;;;;;;;;;AAYA,MAAM,qBAAqB;;;;;;AAO3B,SAAS,uBAA+B;CACtC,KAAK,MAAM,aAAa;EAAC;EAAO;EAAQ;CAAK,GAAG;EAC9C,MAAM,YAAY,cAChB,IAAI,IAAI,oBAAoB,aAAa,OAAO,KAAK,GAAG,CAC1D;EACA,IAAI,WAAW,SAAS,GAAG,OAAO;CACpC;CACA,MAAM,IAAI,MAAM,kDAAkD;AACpE;;;;;;AAOA,SAAS,kBACP,SACA,SACQ;CACR,MAAM,YAAY,QAAQ,QAAQ,WAAW;CAC7C,OAAO;EACL,2CACE,KAAK,UAAU,qBAAqB,CAAC,EACtC;EACD;EACA,GAAI,YAAY,CAAC,yCAAuC,IAAI,CAAC;EAC7D;EACA;EACA;EACA,GAAI,YAAY,CAAC,WAAW,IAAI,CAAC;EACjC,UAAU,QAAQ,IAAI;EACtB;EACA;CACF,CAAC,CAAC,KAAK,IAAI;AACb;AAaA,eAAsB,2BAA2B,SAId;CACjC,MAAM,QAAQ,MAAM,YAClB,yBAAyB,QAAQ,SAAS,EAAE,KAAK,KAAK,CAAC,CACzD;CACA,MAAM,SAAS,gBAAgB,KAAK;CAEpC,IAAI;EACF,MAAM,WAAW,OAAO,OAAO;GAC7B,MAAM,QAAQ,QAAQ;GACtB,UAAU,QAAQ,YAAY;GAC9B,QAAQ;EACV,CAAC;EACD,MAAM,SAAS,MAAM;EACrB,MAAM,QAAQ,KAAK;EACnB,MAAM,MAAM,KAAK;EAEjB,IAAI,CAAC,SAAS,KACZ,MAA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,CAAC,CAAC,YAAY,KAAA,CAAS;EACxD,OAAO,QAAQ,QAAQ,KAAK,MAAM;CACpC,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAAS,kBAAkB,OAAwC;CACjE,OAAO,MAAM,QACV,OAAO,SACN,SAAS,KAAK,SAAS,eACnB,IACA,kBAAkB,KAAK,QAAQ,IACrC,CACF;AACF;AAEA,SAAS,kBAAiC;CACxC,OAAO,IAAI,SAAS,YAAY;EAC9B,MAAM,eAAe;GACnB,QAAQ,IAAI,UAAU,MAAM;GAC5B,QAAQ,IAAI,WAAW,MAAM;GAC7B,QAAQ;EACV;EACA,QAAQ,KAAK,UAAU,MAAM;EAC7B,QAAQ,KAAK,WAAW,MAAM;CAChC,CAAC;AACH;;;AChkBA,QAAQ,KAAK,MAAM,kBAAkB,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC"}
package/dist/cli.d.mts CHANGED
@@ -1,4 +1,29 @@
1
- import { o as AnyApp } from "./index-C9ZThFPN.mjs";
1
+ import { o as AnyApp } from "./index-BxJhwhKm.mjs";
2
+ //#region packages/cli/src/style.d.ts
3
+ type CliStyle = {
4
+ readonly bold: (text: string) => string;
5
+ readonly accent: (text: string) => string;
6
+ readonly dim: (text: string) => string;
7
+ };
8
+ type CliRow = {
9
+ readonly label: string;
10
+ readonly description?: string;
11
+ };
12
+ /** Every help line hangs off this margin. */
13
+ declare const MARGIN = " ";
14
+ /** Rows sit one step inside their section heading. */
15
+ declare const ROW_INDENT = " ";
16
+ declare function createCliStyle(color?: boolean): CliStyle;
17
+ declare function supportsColor(env?: Record<string, string | undefined>, isTTY?: boolean): boolean;
18
+ declare function renderRows(rows: readonly CliRow[], style: CliStyle, options?: {
19
+ readonly indent?: string;
20
+ /** Absolute column for descriptions, so sibling sections stay aligned. */
21
+ readonly column?: number;
22
+ }): string;
23
+ /** Shared description column so sibling sections stay visually aligned. */
24
+ declare function descriptionColumn(rows: readonly CliRow[], indent?: string): number;
25
+ declare function renderSection(title: string, body: string, style: CliStyle): string;
26
+ //#endregion
2
27
  //#region packages/cli/src/index.d.ts
3
28
  type CliCapabilityMeta = false | {
4
29
  readonly name?: string;
@@ -41,5 +66,5 @@ declare function runCli(options: {
41
66
  readonly io?: Partial<CliIo>;
42
67
  }): Promise<number>;
43
68
  //#endregion
44
- export { CliCapabilityMeta, CliGroupMeta, CliIo, CreateCliOptions, createCli, runCli };
69
+ export { CliCapabilityMeta, CliGroupMeta, CliIo, type CliRow, type CliStyle, CreateCliOptions, MARGIN, ROW_INDENT, createCli, createCliStyle, descriptionColumn, renderRows, renderSection, runCli, supportsColor };
45
70
  //# sourceMappingURL=cli.d.mts.map
package/dist/cli.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { n as runCli, t as createCli } from "./src-CvWOGyGW.mjs";
2
- export { createCli, runCli };
1
+ import { a as createCliStyle, c as renderSection, i as ROW_INDENT, l as supportsColor, n as runCli, o as descriptionColumn, r as MARGIN, s as renderRows, t as createCli } from "./src-BjBxOv7x.mjs";
2
+ export { MARGIN, ROW_INDENT, createCli, createCliStyle, descriptionColumn, renderRows, renderSection, runCli, supportsColor };
package/dist/core.d.mts CHANGED
@@ -1,3 +1,3 @@
1
- import { $ as parseSchema, A as CapabilityGroupDefinition, B as CAPABILITY_ERRORS_SYMBOL, C as subscribeCapability, D as AppContext, E as AnyCapabilityGroup, F as group, G as DefinedErrors, H as CapabilityErrorDefinition, I as isCapabilityGroup, J as AnyObjectSchema, K as ErrorMetaRegistry, L as MaybePromise, M as GroupMetaRegistry, N as LocatedCapability, O as AppDefinition, P as defineApp, Q as SchemaValidationError, R as md, S as isCapability, T as APPLICATION_SYMBOL, U as CapabilityErrorFactory, V as CapabilityErrorContract, W as CapableError, X as InferSchemaInput, Y as AnySchema, Z as InferSchemaOutput, _ as SubscribableCapability, a as CapabilityEffect, b as executeCapability, c as CapabilityInput, d as CapabilityMiddlewareArgs, et as schemaToJsonSchema, f as CapabilityOutput, g as MarkdownRenderer, h as ExecuteCapabilityOptions, i as CapabilityDefinition, j as CapabilityTree, k as CAPABILITY_GROUP_SYMBOL, l as CapabilityMetaRegistry, m as CapabilitySubscriberArgs, n as CAPABILITY_SYMBOL, o as CapabilityFactory, p as CapabilitySubscriber, q as defineErrors, r as CapabilityContext, s as CapabilityHandlerArgs, t as AnyCapability, u as CapabilityMiddleware, v as SubscribeCapabilityOptions, w as subscribeLocatedCapability, x as executeLocatedCapability, y as capability, z as AnyDefinedErrors } from "./index-DLcYNpfo.mjs";
2
- import { n as watchQuery, t as WatchQueryOptions } from "./subscription-CBnnIU42.mjs";
3
- export { APPLICATION_SYMBOL, type AnyCapability, type AnyCapabilityGroup, type AnyDefinedErrors, type AnyObjectSchema, type AnySchema, type AppContext, type AppDefinition, CAPABILITY_ERRORS_SYMBOL, CAPABILITY_GROUP_SYMBOL, CAPABILITY_SYMBOL, type CapabilityContext, type CapabilityDefinition, type CapabilityEffect, type CapabilityErrorContract, type CapabilityErrorDefinition, type CapabilityErrorFactory, type CapabilityFactory, type CapabilityGroupDefinition, type CapabilityHandlerArgs, type CapabilityInput, type CapabilityMetaRegistry, type CapabilityMiddleware, type CapabilityMiddlewareArgs, type CapabilityOutput, type CapabilitySubscriber, type CapabilitySubscriberArgs, type CapabilityTree, CapableError, type DefinedErrors, type ErrorMetaRegistry, type ExecuteCapabilityOptions, type GroupMetaRegistry, type InferSchemaInput, type InferSchemaOutput, type LocatedCapability, type MarkdownRenderer, type MaybePromise, SchemaValidationError, type SubscribableCapability, type SubscribeCapabilityOptions, type WatchQueryOptions, capability, defineApp, defineErrors, executeCapability, executeLocatedCapability, group, isCapability, isCapabilityGroup, md, parseSchema, schemaToJsonSchema, subscribeCapability, subscribeLocatedCapability, watchQuery };
1
+ import { $ as SchemaValidationError, A as CapabilityGroupDefinition, B as CAPABILITY_ERRORS_SYMBOL, C as subscribeCapability, D as AppContext, E as AnyCapabilityGroup, F as group, G as DefinedErrors, H as CapabilityErrorDefinition, I as isCapabilityGroup, J as AnyObjectSchema, K as ErrorMetaRegistry, L as MaybePromise, M as GroupMetaRegistry, N as LocatedCapability, O as AppDefinition, P as defineApp, Q as Schema, R as md, S as isCapability, T as APPLICATION_SYMBOL, U as CapabilityErrorFactory, V as CapabilityErrorContract, W as CapableError, X as InferSchemaInput, Y as AnySchema, Z as InferSchemaOutput, _ as SubscribableCapability, a as CapabilityEffect, b as executeCapability, c as CapabilityInput, d as CapabilityMiddlewareArgs, et as parseSchema, f as CapabilityOutput, g as MarkdownRenderer, h as ExecuteCapabilityOptions, i as CapabilityDefinition, j as CapabilityTree, k as CAPABILITY_GROUP_SYMBOL, l as CapabilityMetaRegistry, m as CapabilitySubscriberArgs, n as CAPABILITY_SYMBOL, o as CapabilityFactory, p as CapabilitySubscriber, q as defineErrors, r as CapabilityContext, s as CapabilityHandlerArgs, t as AnyCapability, tt as schemaToJsonSchema, u as CapabilityMiddleware, v as SubscribeCapabilityOptions, w as subscribeLocatedCapability, x as executeLocatedCapability, y as capability, z as AnyDefinedErrors } from "./index-BB5ogMv-.mjs";
2
+ import { n as watchQuery, t as WatchQueryOptions } from "./subscription-McaLyHM2.mjs";
3
+ export { APPLICATION_SYMBOL, type AnyCapability, type AnyCapabilityGroup, type AnyDefinedErrors, type AnyObjectSchema, type AnySchema, type AppContext, type AppDefinition, CAPABILITY_ERRORS_SYMBOL, CAPABILITY_GROUP_SYMBOL, CAPABILITY_SYMBOL, type CapabilityContext, type CapabilityDefinition, type CapabilityEffect, type CapabilityErrorContract, type CapabilityErrorDefinition, type CapabilityErrorFactory, type CapabilityFactory, type CapabilityGroupDefinition, type CapabilityHandlerArgs, type CapabilityInput, type CapabilityMetaRegistry, type CapabilityMiddleware, type CapabilityMiddlewareArgs, type CapabilityOutput, type CapabilitySubscriber, type CapabilitySubscriberArgs, type CapabilityTree, CapableError, type DefinedErrors, type ErrorMetaRegistry, type ExecuteCapabilityOptions, type GroupMetaRegistry, type InferSchemaInput, type InferSchemaOutput, type LocatedCapability, type MarkdownRenderer, type MaybePromise, type Schema, SchemaValidationError, type SubscribableCapability, type SubscribeCapabilityOptions, type WatchQueryOptions, capability, defineApp, defineErrors, executeCapability, executeLocatedCapability, group, isCapability, isCapabilityGroup, md, parseSchema, schemaToJsonSchema, subscribeCapability, subscribeLocatedCapability, watchQuery };
package/dist/core.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { _ as CAPABILITY_ERRORS_SYMBOL, a as isCapabilityGroup, c as executeCapability, d as subscribeCapability, f as subscribeLocatedCapability, g as watchQuery, h as schemaToJsonSchema, i as group, l as executeLocatedCapability, m as parseSchema, n as CAPABILITY_GROUP_SYMBOL, o as CAPABILITY_SYMBOL, p as SchemaValidationError, r as defineApp, s as capability, t as APPLICATION_SYMBOL, u as isCapability, v as CapableError, y as defineErrors } from "./src-DX-_J6l2.mjs";
1
+ import { _ as CAPABILITY_ERRORS_SYMBOL, a as isCapabilityGroup, c as executeCapability, d as subscribeCapability, f as subscribeLocatedCapability, g as watchQuery, h as schemaToJsonSchema, i as group, l as executeLocatedCapability, m as parseSchema, n as CAPABILITY_GROUP_SYMBOL, o as CAPABILITY_SYMBOL, p as SchemaValidationError, r as defineApp, s as capability, t as APPLICATION_SYMBOL, u as isCapability, v as CapableError, y as defineErrors } from "./src-B53ZbNtC.mjs";
2
2
  import { t as md } from "./projection-Cgq2u0Wt.mjs";
3
3
  export { APPLICATION_SYMBOL, CAPABILITY_ERRORS_SYMBOL, CAPABILITY_GROUP_SYMBOL, CAPABILITY_SYMBOL, CapableError, SchemaValidationError, capability, defineApp, defineErrors, executeCapability, executeLocatedCapability, group, isCapability, isCapabilityGroup, md, parseSchema, schemaToJsonSchema, subscribeCapability, subscribeLocatedCapability, watchQuery };
package/dist/eve.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { o as AnyApp, w as ManifestCapability } from "./index-C9ZThFPN.mjs";
1
+ import { o as AnyApp, w as ManifestCapability } from "./index-BxJhwhKm.mjs";
2
2
  import { DynamicResolveContext, ToolDefinition } from "eve/tools";
3
3
  import { Approval } from "eve/tools/approval";
4
4
  //#region packages/eve/src/index.d.ts
package/dist/eve.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { c as getAppRuntime } from "./src-CT4fbWqb.mjs";
1
+ import { c as getAppRuntime } from "./src-3UaBqI8H.mjs";
2
2
  import { defineDynamic, defineTool } from "eve/tools";
3
3
  //#region packages/eve/src/index.ts
4
4
  const emptyInputSchema = Object.freeze({
package/dist/http.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as HttpGroupMeta, c as FetchHandler, d as createProtocolHandler, i as HttpCapabilityMeta, l as TransportHeaders, n as CompiledHttpRoute, o as HttpMethod, r as ContextProvider, s as createHttpHandler, t as CapabilitySelection, u as createHttpTransport } from "./index-u9ZOETR5.mjs";
1
+ import { a as HttpGroupMeta, c as FetchHandler, d as createProtocolHandler, i as HttpCapabilityMeta, l as TransportHeaders, n as CompiledHttpRoute, o as HttpMethod, r as ContextProvider, s as createHttpHandler, t as CapabilitySelection, u as createHttpTransport } from "./index-Dp-D73pf.mjs";
2
2
  export { type CapabilitySelection, type CompiledHttpRoute, type ContextProvider, type FetchHandler, type HttpCapabilityMeta, type HttpGroupMeta, type HttpMethod, type TransportHeaders, createHttpHandler, createHttpTransport, createProtocolHandler };
package/dist/http.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { n as createHttpTransport, r as createProtocolHandler, t as createHttpHandler } from "./src-DlSJtEhv.mjs";
1
+ import { n as createHttpTransport, r as createProtocolHandler, t as createHttpHandler } from "./src-XRJ9hgYX.mjs";
2
2
  export { createHttpHandler, createHttpTransport, createProtocolHandler };
@@ -1,14 +1,17 @@
1
- import { z } from "zod";
1
+ import { StandardJSONSchemaV1, StandardSchemaV1 } from "@standard-schema/spec";
2
2
  //#region packages/core/src/schema.d.ts
3
- type AnySchema = z.ZodType;
4
- type AnyObjectSchema = z.ZodObject;
5
- type InferSchemaInput<TSchema> = TSchema extends AnySchema ? z.input<TSchema> : never;
6
- type InferSchemaOutput<TSchema> = TSchema extends AnySchema ? z.output<TSchema> : never;
3
+ type Schema<TInput = unknown, TOutput = TInput> = {
4
+ readonly "~standard": StandardSchemaV1.Props<TInput, TOutput> & StandardJSONSchemaV1.Props<TInput, TOutput>;
5
+ };
6
+ type AnySchema = Schema<any, any>;
7
+ type AnyObjectSchema = Schema<any, Record<string, unknown>>;
8
+ type InferSchemaInput<TSchema extends AnySchema> = StandardSchemaV1.InferInput<TSchema>;
9
+ type InferSchemaOutput<TSchema extends AnySchema> = StandardSchemaV1.InferOutput<TSchema>;
7
10
  declare function parseSchema<TSchema extends AnySchema>(schema: TSchema, value: unknown): Promise<InferSchemaOutput<TSchema>>;
8
- declare function schemaToJsonSchema(schema: AnySchema): Readonly<Record<string, unknown>>;
11
+ declare function schemaToJsonSchema(schema: AnySchema, direction: "input" | "output"): Readonly<Record<string, unknown>>;
9
12
  declare class SchemaValidationError extends Error {
10
- readonly issues: readonly z.core.$ZodIssue[];
11
- constructor(issues: readonly z.core.$ZodIssue[]);
13
+ readonly issues: readonly StandardSchemaV1.Issue[];
14
+ constructor(issues: readonly StandardSchemaV1.Issue[]);
12
15
  }
13
16
  //#endregion
14
17
  //#region packages/core/src/errors.d.ts
@@ -217,16 +220,16 @@ type InferredOutputCapabilityConfig<TContext, TInput extends AnyObjectSchema | u
217
220
  readonly subscribe?: CapabilitySubscriber<TContext, ParsedInput<TInput>, Awaited<ReturnType<THandler>>>;
218
221
  };
219
222
  type CapabilityFactory<TContext> = {
220
- <const TInput extends AnyObjectSchema | undefined = undefined, const TOutput extends AnySchema = AnySchema, const TErrors extends AnyDefinedErrors = DefinedNoErrors, const TMeta extends OpenMeta<CapabilityMetaRegistry> = {}>(config: ExplicitOutputCapabilityConfig<TContext, TInput, TOutput, TErrors, TMeta> & {
223
+ <TInput extends AnyObjectSchema | undefined = undefined, TOutput extends AnySchema = AnySchema, const TErrors extends AnyDefinedErrors = DefinedNoErrors, const TMeta extends OpenMeta<CapabilityMetaRegistry> = {}>(config: ExplicitOutputCapabilityConfig<TContext, TInput, TOutput, TErrors, TMeta> & {
221
224
  readonly subscribe: CapabilitySubscriber<TContext, ParsedInput<TInput>, InferSchemaInput<TOutput>>;
222
225
  }): CapabilityDefinition<TContext, TInput, InferSchemaOutput<TOutput>, TErrors, TMeta, true>;
223
- <const TInput extends AnyObjectSchema | undefined = undefined, const TOutput extends AnySchema = AnySchema, const TErrors extends AnyDefinedErrors = DefinedNoErrors, const TMeta extends OpenMeta<CapabilityMetaRegistry> = {}>(config: ExplicitOutputCapabilityConfig<TContext, TInput, TOutput, TErrors, TMeta> & {
226
+ <TInput extends AnyObjectSchema | undefined = undefined, TOutput extends AnySchema = AnySchema, const TErrors extends AnyDefinedErrors = DefinedNoErrors, const TMeta extends OpenMeta<CapabilityMetaRegistry> = {}>(config: ExplicitOutputCapabilityConfig<TContext, TInput, TOutput, TErrors, TMeta> & {
224
227
  readonly subscribe?: never;
225
228
  }): CapabilityDefinition<TContext, TInput, InferSchemaOutput<TOutput>, TErrors, TMeta, false>;
226
- <const TInput extends AnyObjectSchema | undefined = undefined, const THandler extends (args: CapabilityHandlerArgs<TContext, ParsedInput<TInput>>) => unknown = (args: CapabilityHandlerArgs<TContext, ParsedInput<TInput>>) => unknown, const TErrors extends AnyDefinedErrors = DefinedNoErrors, const TMeta extends OpenMeta<CapabilityMetaRegistry> = {}>(config: InferredOutputCapabilityConfig<TContext, TInput, THandler, TErrors, TMeta> & {
229
+ <TInput extends AnyObjectSchema | undefined = undefined, const THandler extends (args: CapabilityHandlerArgs<TContext, ParsedInput<TInput>>) => unknown = (args: CapabilityHandlerArgs<TContext, ParsedInput<TInput>>) => unknown, const TErrors extends AnyDefinedErrors = DefinedNoErrors, const TMeta extends OpenMeta<CapabilityMetaRegistry> = {}>(config: InferredOutputCapabilityConfig<TContext, TInput, THandler, TErrors, TMeta> & {
227
230
  readonly subscribe: CapabilitySubscriber<TContext, ParsedInput<TInput>, Awaited<ReturnType<THandler>>>;
228
231
  }): CapabilityDefinition<TContext, TInput, Awaited<ReturnType<THandler>>, TErrors, TMeta, true>;
229
- <const TInput extends AnyObjectSchema | undefined = undefined, const THandler extends (args: CapabilityHandlerArgs<TContext, ParsedInput<TInput>>) => unknown = (args: CapabilityHandlerArgs<TContext, ParsedInput<TInput>>) => unknown, const TErrors extends AnyDefinedErrors = DefinedNoErrors, const TMeta extends OpenMeta<CapabilityMetaRegistry> = {}>(config: InferredOutputCapabilityConfig<TContext, TInput, THandler, TErrors, TMeta> & {
232
+ <TInput extends AnyObjectSchema | undefined = undefined, const THandler extends (args: CapabilityHandlerArgs<TContext, ParsedInput<TInput>>) => unknown = (args: CapabilityHandlerArgs<TContext, ParsedInput<TInput>>) => unknown, const TErrors extends AnyDefinedErrors = DefinedNoErrors, const TMeta extends OpenMeta<CapabilityMetaRegistry> = {}>(config: InferredOutputCapabilityConfig<TContext, TInput, THandler, TErrors, TMeta> & {
230
233
  readonly subscribe?: never;
231
234
  }): CapabilityDefinition<TContext, TInput, Awaited<ReturnType<THandler>>, TErrors, TMeta, false>;
232
235
  };
@@ -248,5 +251,5 @@ declare function subscribeLocatedCapability(located: LocatedCapability, input: u
248
251
  }): AsyncIterableIterator<unknown>;
249
252
  declare function isCapability(value: unknown): value is AnyCapability;
250
253
  //#endregion
251
- export { parseSchema as $, CapabilityGroupDefinition as A, CAPABILITY_ERRORS_SYMBOL as B, subscribeCapability as C, AppContext as D, AnyCapabilityGroup as E, group as F, DefinedErrors as G, CapabilityErrorDefinition as H, isCapabilityGroup as I, AnyObjectSchema as J, ErrorMetaRegistry as K, MaybePromise as L, GroupMetaRegistry as M, LocatedCapability as N, AppDefinition as O, defineApp as P, SchemaValidationError as Q, md as R, isCapability as S, APPLICATION_SYMBOL as T, CapabilityErrorFactory as U, CapabilityErrorContract as V, CapableError as W, InferSchemaInput as X, AnySchema as Y, InferSchemaOutput as Z, SubscribableCapability as _, CapabilityEffect as a, executeCapability as b, CapabilityInput as c, CapabilityMiddlewareArgs as d, schemaToJsonSchema as et, CapabilityOutput as f, MarkdownRenderer as g, ExecuteCapabilityOptions as h, CapabilityDefinition as i, CapabilityTree as j, CAPABILITY_GROUP_SYMBOL as k, CapabilityMetaRegistry as l, CapabilitySubscriberArgs as m, CAPABILITY_SYMBOL as n, CapabilityFactory as o, CapabilitySubscriber as p, defineErrors as q, CapabilityContext as r, CapabilityHandlerArgs as s, AnyCapability as t, CapabilityMiddleware as u, SubscribeCapabilityOptions as v, subscribeLocatedCapability as w, executeLocatedCapability as x, capability as y, AnyDefinedErrors as z };
252
- //# sourceMappingURL=index-DLcYNpfo.d.mts.map
254
+ export { SchemaValidationError as $, CapabilityGroupDefinition as A, CAPABILITY_ERRORS_SYMBOL as B, subscribeCapability as C, AppContext as D, AnyCapabilityGroup as E, group as F, DefinedErrors as G, CapabilityErrorDefinition as H, isCapabilityGroup as I, AnyObjectSchema as J, ErrorMetaRegistry as K, MaybePromise as L, GroupMetaRegistry as M, LocatedCapability as N, AppDefinition as O, defineApp as P, Schema as Q, md as R, isCapability as S, APPLICATION_SYMBOL as T, CapabilityErrorFactory as U, CapabilityErrorContract as V, CapableError as W, InferSchemaInput as X, AnySchema as Y, InferSchemaOutput as Z, SubscribableCapability as _, CapabilityEffect as a, executeCapability as b, CapabilityInput as c, CapabilityMiddlewareArgs as d, parseSchema as et, CapabilityOutput as f, MarkdownRenderer as g, ExecuteCapabilityOptions as h, CapabilityDefinition as i, CapabilityTree as j, CAPABILITY_GROUP_SYMBOL as k, CapabilityMetaRegistry as l, CapabilitySubscriberArgs as m, CAPABILITY_SYMBOL as n, CapabilityFactory as o, CapabilitySubscriber as p, defineErrors as q, CapabilityContext as r, CapabilityHandlerArgs as s, AnyCapability as t, schemaToJsonSchema as tt, CapabilityMiddleware as u, SubscribeCapabilityOptions as v, subscribeLocatedCapability as w, executeLocatedCapability as x, capability as y, AnyDefinedErrors as z };
255
+ //# sourceMappingURL=index-BB5ogMv-.d.mts.map
@@ -1,4 +1,4 @@
1
- import { A as CapabilityGroupDefinition, D as AppContext, J as AnyObjectSchema, L as MaybePromise, O as AppDefinition, X as InferSchemaInput, _ as SubscribableCapability, f as CapabilityOutput, i as CapabilityDefinition, j as CapabilityTree, t as AnyCapability } from "./index-DLcYNpfo.mjs";
1
+ import { A as CapabilityGroupDefinition, D as AppContext, J as AnyObjectSchema, L as MaybePromise, O as AppDefinition, X as InferSchemaInput, _ as SubscribableCapability, f as CapabilityOutput, i as CapabilityDefinition, j as CapabilityTree, t as AnyCapability } from "./index-BB5ogMv-.mjs";
2
2
  //#region packages/app/src/manifest.d.ts
3
3
  type JsonSchema = Readonly<Record<string, unknown>>;
4
4
  type ManifestError = {
@@ -122,4 +122,4 @@ type ApplicationSelection<TCapabilities extends CapabilityTree = CapabilityTree>
122
122
  declare function selectApp<const TCapabilities extends CapabilityTree>(application: App<TCapabilities>, selection: ApplicationSelection<TCapabilities>): App<TCapabilities>;
123
123
  //#endregion
124
124
  export { JsonSchema as C, ManifestNode as D, ManifestGroup as E, createAppManifest as O, ApplicationManifest as S, ManifestError as T, createApp as _, APP_RUNTIME_SYMBOL as a, isApp as b, AppCapabilities as c, AppContextProvider as d, ApplicationTransport as f, TransportError as g, CapabilityResult as h, APP_CAPABILITIES_SYMBOL as i, AppCapabilityCall as l, CapabilityCall as m, mergeApps as n, AnyApp as o, CallableTree as p, selectApp as r, App as s, ApplicationSelection as t, AppCapabilityIsSubscribable as u, createRemoteApp as v, ManifestCapability as w, subscribe as x, getAppRuntime as y };
125
- //# sourceMappingURL=index-C9ZThFPN.d.mts.map
125
+ //# sourceMappingURL=index-BxJhwhKm.d.mts.map
@@ -1,6 +1,6 @@
1
- import { L as MaybePromise, O as AppDefinition } from "./index-DLcYNpfo.mjs";
2
- import { t as ApplicationSelection } from "./index-C9ZThFPN.mjs";
3
- import { r as ContextProvider, t as CapabilitySelection } from "./index-u9ZOETR5.mjs";
1
+ import { L as MaybePromise, O as AppDefinition } from "./index-BB5ogMv-.mjs";
2
+ import { t as ApplicationSelection } from "./index-BxJhwhKm.mjs";
3
+ import { r as ContextProvider, t as CapabilitySelection } from "./index-Dp-D73pf.mjs";
4
4
  //#region packages/server/src/index.d.ts
5
5
  type ServerMount<TContext> = {
6
6
  readonly kind: "capable.server.mount";
@@ -39,4 +39,4 @@ type CreateServerArgs<TContext> = [TContext] extends [undefined] ? [options?: Cr
39
39
  declare function createServer<TContext>(app: AppDefinition<any, TContext>, ...[providedOptions]: CreateServerArgs<TContext>): CapableServer;
40
40
  //#endregion
41
41
  export { createServer as a, ServerMount as i, CompiledServerMount as n, http as o, ServerMiddleware as r, standard as s, CapableServer as t };
42
- //# sourceMappingURL=index-BuXwkN8G.d.mts.map
42
+ //# sourceMappingURL=index-CThfifn8.d.mts.map
@@ -1,5 +1,5 @@
1
- import { N as LocatedCapability, O as AppDefinition, j as CapabilityTree } from "./index-DLcYNpfo.mjs";
2
- import { f as ApplicationTransport, o as AnyApp, t as ApplicationSelection } from "./index-C9ZThFPN.mjs";
1
+ import { N as LocatedCapability, O as AppDefinition, j as CapabilityTree } from "./index-BB5ogMv-.mjs";
2
+ import { f as ApplicationTransport, o as AnyApp, t as ApplicationSelection } from "./index-BxJhwhKm.mjs";
3
3
  //#region packages/fetch/src/standard.d.ts
4
4
  type FetchHandler = (request: Request) => Response | Promise<Response>;
5
5
  declare function createProtocolHandler(application: AnyApp | ((request: Request) => AnyApp | Promise<AnyApp>), options?: {
@@ -54,4 +54,4 @@ declare function createHttpHandler<const TCapabilities extends CapabilityTree, T
54
54
  };
55
55
  //#endregion
56
56
  export { HttpGroupMeta as a, FetchHandler as c, createProtocolHandler as d, HttpCapabilityMeta as i, TransportHeaders as l, CompiledHttpRoute as n, HttpMethod as o, ContextProvider as r, createHttpHandler as s, CapabilitySelection as t, createHttpTransport as u };
57
- //# sourceMappingURL=index-u9ZOETR5.d.mts.map
57
+ //# sourceMappingURL=index-Dp-D73pf.d.mts.map
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { D as AppContext, F as group, G as DefinedErrors, O as AppDefinition, P as defineApp, R as md, a as CapabilityEffect, b as executeCapability, c as CapabilityInput, d as CapabilityMiddlewareArgs, f as CapabilityOutput, g as MarkdownRenderer, h as ExecuteCapabilityOptions, i as CapabilityDefinition, j as CapabilityTree, m as CapabilitySubscriberArgs, o as CapabilityFactory, p as CapabilitySubscriber, q as defineErrors, r as CapabilityContext, s as CapabilityHandlerArgs, u as CapabilityMiddleware, y as capability } from "./index-DLcYNpfo.mjs";
2
- import { n as watchQuery, t as WatchQueryOptions } from "./subscription-CBnnIU42.mjs";
3
- import { _ as createApp, d as AppContextProvider, l as AppCapabilityCall, n as mergeApps, r as selectApp, s as App, t as ApplicationSelection, v as createRemoteApp, x as subscribe } from "./index-C9ZThFPN.mjs";
1
+ import { D as AppContext, F as group, G as DefinedErrors, O as AppDefinition, P as defineApp, R as md, a as CapabilityEffect, b as executeCapability, c as CapabilityInput, d as CapabilityMiddlewareArgs, f as CapabilityOutput, g as MarkdownRenderer, h as ExecuteCapabilityOptions, i as CapabilityDefinition, j as CapabilityTree, m as CapabilitySubscriberArgs, o as CapabilityFactory, p as CapabilitySubscriber, q as defineErrors, r as CapabilityContext, s as CapabilityHandlerArgs, u as CapabilityMiddleware, y as capability } from "./index-BB5ogMv-.mjs";
2
+ import { n as watchQuery, t as WatchQueryOptions } from "./subscription-McaLyHM2.mjs";
3
+ import { _ as createApp, d as AppContextProvider, l as AppCapabilityCall, n as mergeApps, r as selectApp, s as App, t as ApplicationSelection, v as createRemoteApp, x as subscribe } from "./index-BxJhwhKm.mjs";
4
4
  export { type App, type AppCapabilityCall, type AppContext, type AppContextProvider, type AppDefinition, type ApplicationSelection, type CapabilityContext, type CapabilityDefinition, type CapabilityEffect, type CapabilityFactory, type CapabilityHandlerArgs, type CapabilityInput, type CapabilityMiddleware, type CapabilityMiddlewareArgs, type CapabilityOutput, type CapabilitySubscriber, type CapabilitySubscriberArgs, type CapabilityTree, type DefinedErrors, type ExecuteCapabilityOptions, type MarkdownRenderer, type WatchQueryOptions, capability, createApp, createRemoteApp, defineApp, defineErrors, executeCapability, group, md, mergeApps, selectApp, subscribe, watchQuery };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { c as executeCapability, g as watchQuery, i as group, r as defineApp, s as capability, y as defineErrors } from "./src-DX-_J6l2.mjs";
1
+ import { c as executeCapability, g as watchQuery, i as group, r as defineApp, s as capability, y as defineErrors } from "./src-B53ZbNtC.mjs";
2
2
  import { t as md } from "./projection-Cgq2u0Wt.mjs";
3
- import { n as selectApp, o as createApp, s as createRemoteApp, t as mergeApps, u as subscribe } from "./src-CT4fbWqb.mjs";
3
+ import { n as selectApp, o as createApp, s as createRemoteApp, t as mergeApps, u as subscribe } from "./src-3UaBqI8H.mjs";
4
4
  export { capability, createApp, createRemoteApp, defineApp, defineErrors, executeCapability, group, md, mergeApps, selectApp, subscribe, watchQuery };
package/dist/mcp.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as JsonSchema, h as CapabilityResult, o as AnyApp } from "./index-C9ZThFPN.mjs";
2
- import { i as ServerMount } from "./index-BuXwkN8G.mjs";
1
+ import { C as JsonSchema, h as CapabilityResult, o as AnyApp } from "./index-BxJhwhKm.mjs";
2
+ import { i as ServerMount } from "./index-CThfifn8.mjs";
3
3
  //#region packages/mcp/src/index.d.ts
4
4
  type McpCapabilityMeta = false | {
5
5
  readonly name?: string;
package/dist/mcp.mjs CHANGED
@@ -1,140 +1,2 @@
1
- import { a as TransportError, c as getAppRuntime, o as createApp } from "./src-CT4fbWqb.mjs";
2
- import { Server } from "@modelcontextprotocol/sdk/server/index.js";
3
- import { WebStandardStreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";
4
- import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
5
- //#region packages/mcp/src/index.ts
6
- async function createMcp(app) {
7
- const runtime = getAppRuntime(app);
8
- const tools = flatten((await runtime.manifest()).capabilities).filter((capability) => capability.meta.mcp !== false).map((capability) => {
9
- const meta = capability.meta.mcp;
10
- return Object.freeze({
11
- name: meta?.name ?? capability.path.join("__"),
12
- ...capability.title ? { title: capability.title } : {},
13
- ...capability.description ? { description: capability.description } : {},
14
- inputSchema: capability.input ?? {
15
- type: "object",
16
- properties: {},
17
- additionalProperties: false
18
- },
19
- ...capability.output ? { outputSchema: mcpOutputSchema(capability.output) } : {},
20
- annotations: {
21
- readOnlyHint: capability.effect === "read",
22
- destructiveHint: capability.effect === "destructive"
23
- },
24
- call(input, options) {
25
- return runtime.call({
26
- id: capability.id,
27
- input,
28
- ...options?.signal ? { signal: options.signal } : {}
29
- });
30
- }
31
- });
32
- });
33
- const names = /* @__PURE__ */ new Set();
34
- for (const tool of tools) {
35
- if (names.has(tool.name)) throw new Error(`Duplicate MCP tool name "${tool.name}"`);
36
- names.add(tool.name);
37
- }
38
- return tools;
39
- }
40
- function mcpOutputSchema(schema) {
41
- if (schema.type === "object") return schema;
42
- return {
43
- type: "object",
44
- properties: { value: schema },
45
- required: ["value"],
46
- additionalProperties: false
47
- };
48
- }
49
- function flatten(nodes) {
50
- return nodes.flatMap((node) => node.type === "capability" ? [node] : flatten(node.children));
51
- }
52
- //#endregion
53
- //#region packages/mcp/src/mount.ts
54
- function mcp(options = {}) {
55
- const path = normalizePath(options.path ?? "/mcp");
56
- return {
57
- kind: "capable.server.mount",
58
- compile(app, context) {
59
- return {
60
- name: "mcp",
61
- async fetch(request) {
62
- if (new URL(request.url).pathname !== path) return void 0;
63
- const server = createMcpServer(await createMcp(createApp(app, context ? { context: () => context({ request }) } : void 0)), {
64
- name: options.name ?? app.name ?? "capable",
65
- version: options.version ?? app.version ?? "0.0.0"
66
- });
67
- const transport = new WebStandardStreamableHTTPServerTransport({ enableJsonResponse: true });
68
- await server.connect(transport);
69
- try {
70
- return await transport.handleRequest(request);
71
- } finally {
72
- await transport.close();
73
- await server.close();
74
- }
75
- }
76
- };
77
- }
78
- };
79
- }
80
- function createMcpServer(tools, info) {
81
- const server = new Server(info, { capabilities: { tools: {} } });
82
- server.setRequestHandler(ListToolsRequestSchema, () => ({ tools: tools.map(toProtocolTool) }));
83
- server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
84
- const tool = tools.find(({ name }) => name === request.params.name);
85
- if (!tool) return toolError(`Unknown tool "${request.params.name}"`);
86
- try {
87
- const result = await tool.call(request.params.arguments ?? {}, { signal: extra.signal });
88
- return {
89
- content: [{
90
- type: "text",
91
- text: result.markdown ?? stringify(result.output)
92
- }],
93
- structuredContent: isRecord(result.output) ? result.output : { value: result.output }
94
- };
95
- } catch (error) {
96
- if (!(error instanceof TransportError)) throw error;
97
- return toolError(error.message, {
98
- code: error.code,
99
- status: error.status,
100
- data: error.data
101
- });
102
- }
103
- });
104
- return server;
105
- }
106
- function toProtocolTool(tool) {
107
- return {
108
- name: tool.name,
109
- ...tool.title ? { title: tool.title } : {},
110
- ...tool.description ? { description: tool.description } : {},
111
- inputSchema: tool.inputSchema,
112
- ...tool.outputSchema ? { outputSchema: tool.outputSchema } : {},
113
- annotations: tool.annotations
114
- };
115
- }
116
- function toolError(message, details) {
117
- return {
118
- isError: true,
119
- content: [{
120
- type: "text",
121
- text: details ? JSON.stringify({
122
- message,
123
- ...details
124
- }) : message
125
- }]
126
- };
127
- }
128
- function stringify(value) {
129
- return typeof value === "string" ? value : JSON.stringify(value) ?? String(value);
130
- }
131
- function normalizePath(value) {
132
- return `/${value.split("/").filter(Boolean).join("/")}`;
133
- }
134
- function isRecord(value) {
135
- return Boolean(value && typeof value === "object" && !Array.isArray(value));
136
- }
137
- //#endregion
1
+ import { n as createMcp, t as mcp } from "./mount--YHrgRHJ.mjs";
138
2
  export { createMcp, mcp };
139
-
140
- //# sourceMappingURL=mcp.mjs.map