capable-kit 0.0.1-alpha.1 → 0.0.1-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -0
- package/dist/ai-sdk.d.mts +1 -1
- package/dist/app.d.mts +1 -1
- package/dist/bin.mjs +179 -18
- package/dist/bin.mjs.map +1 -1
- package/dist/cli.d.mts +1 -1
- package/dist/eve.d.mts +3 -3
- package/dist/eve.mjs.map +1 -1
- package/dist/http.d.mts +1 -1
- package/dist/http.mjs +1 -1
- package/dist/{index-Dp-D73pf.d.mts → index-AqKbVZ8Z.d.mts} +2 -2
- package/dist/{index-CThfifn8.d.mts → index-B2ru1zGQ.d.mts} +3 -3
- package/dist/{index-BxJhwhKm.d.mts → index-B_I9n6gN.d.mts} +4 -5
- package/dist/index.d.mts +1 -1
- package/dist/mcp.d.mts +2 -2
- package/dist/runtime-support.d.mts +2 -3
- package/dist/runtime-support.mjs +278 -24
- package/dist/runtime-support.mjs.map +1 -1
- package/dist/server.d.mts +1 -1
- package/dist/server.mjs +1 -1
- package/dist/src-3UaBqI8H.mjs.map +1 -1
- package/dist/src-B53ZbNtC.mjs.map +1 -1
- package/dist/src-BjBxOv7x.mjs.map +1 -1
- package/dist/{src-XRJ9hgYX.mjs → src-DX2xrplP.mjs} +18 -2
- package/dist/src-DX2xrplP.mjs.map +1 -0
- package/dist/{src-DpSA-hBO.mjs → src-DtSY5fzY.mjs} +2 -2
- package/dist/{src-DpSA-hBO.mjs.map → src-DtSY5fzY.mjs.map} +1 -1
- package/package.json +1 -1
- package/dist/src-XRJ9hgYX.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/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,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kBA,QAAQ,KAAK,MAAM,kBAAkB,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"bin.mjs","names":["isRecord","readJson"],"sources":["../../nitro-host/src/index.ts","../../toolchain/src/help.ts","../../toolchain/src/project.ts","../../toolchain/src/init.ts","../../toolchain/src/vercel-protection.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 ...(options.dev\n ? { preset: \"nitro-dev\" }\n : options.preset\n ? { preset: options.preset }\n : { defaultPreset: \"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 {\n label: \"--preset <preset>\",\n description: \"Nitro preset (auto-detected; fallback: node-server)\",\n },\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 {\n label: \"--protection-bypass <secret>\",\n description: \"Vercel Deployment Protection bypass\",\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\": \"alpha\",\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 { readFile } from \"node:fs/promises\";\nimport { homedir } from \"node:os\";\nimport path from \"node:path\";\n\ntype Environment = Readonly<Record<string, string | undefined>>;\n\ntype ProjectLink = {\n readonly projectId: string;\n readonly orgId: string;\n};\n\nexport async function resolveVercelProtectionBypass(options: {\n readonly baseUrl: string;\n readonly cwd: string;\n readonly env: Environment;\n readonly explicit?: string;\n readonly fetch?: typeof fetch;\n}): Promise<string | undefined> {\n const explicit = trimmed(options.explicit);\n if (explicit) return explicit;\n\n const configured = trimmed(options.env.VERCEL_AUTOMATION_BYPASS_SECRET);\n if (configured) return configured;\n if (!isLikelyVercelDeployment(options.baseUrl)) return undefined;\n\n const token = trimmed(options.env.VERCEL_TOKEN) ??\n await readVercelCliToken(options.env);\n if (!token) return undefined;\n\n const project = await resolveLinkedProject(options.cwd, options.env);\n if (!project) return undefined;\n\n return await fetchAutomationBypass({\n token,\n project,\n fetch: options.fetch ?? fetch,\n });\n}\n\nfunction isLikelyVercelDeployment(value: string): boolean {\n try {\n const hostname = new URL(value).hostname.toLowerCase();\n return hostname.endsWith(\".vercel.app\") ||\n hostname.endsWith(\".vercel.dev\") ||\n hostname.endsWith(\".now.sh\");\n } catch {\n return false;\n }\n}\n\nasync function readVercelCliToken(\n env: Environment,\n): Promise<string | undefined> {\n const home = homedir();\n const paths = [\n trimmed(env.VERCEL_AUTH_FILE),\n path.join(home, \"Library\", \"Application Support\", \"com.vercel.cli\", \"auth.json\"),\n trimmed(env.XDG_CONFIG_HOME)\n ? path.join(env.XDG_CONFIG_HOME!, \"com.vercel.cli\", \"auth.json\")\n : undefined,\n trimmed(env.XDG_DATA_HOME)\n ? path.join(env.XDG_DATA_HOME!, \"com.vercel.cli\", \"auth.json\")\n : undefined,\n path.join(home, \".config\", \"com.vercel.cli\", \"auth.json\"),\n path.join(home, \".local\", \"share\", \"com.vercel.cli\", \"auth.json\"),\n path.join(home, \".vercel\", \"auth.json\"),\n path.join(home, \".now\", \"auth.json\"),\n ];\n for (const filename of paths) {\n if (!filename) continue;\n const value = await readJson(filename);\n const token = isRecord(value) ? trimmed(value.token) : undefined;\n if (token) return token;\n }\n return undefined;\n}\n\nasync function resolveLinkedProject(\n cwd: string,\n env: Environment,\n): Promise<ProjectLink | undefined> {\n const projectId = trimmed(env.VERCEL_PROJECT_ID);\n const orgId = trimmed(env.VERCEL_ORG_ID);\n if (projectId && orgId) return { projectId, orgId };\n\n let directory = path.resolve(cwd);\n while (true) {\n const value = await readJson(path.join(directory, \".vercel/project.json\"));\n if (isRecord(value)) {\n const linkedProjectId = trimmed(value.projectId);\n const linkedOrgId = trimmed(value.orgId);\n if (linkedProjectId && linkedOrgId) {\n return { projectId: linkedProjectId, orgId: linkedOrgId };\n }\n }\n const parent = path.dirname(directory);\n if (parent === directory) return undefined;\n directory = parent;\n }\n}\n\nasync function fetchAutomationBypass(options: {\n readonly token: string;\n readonly project: ProjectLink;\n readonly fetch: typeof fetch;\n}): Promise<string | undefined> {\n const url = new URL(\n `https://api.vercel.com/v9/projects/${\n encodeURIComponent(options.project.projectId)\n }`,\n );\n if (options.project.orgId.startsWith(\"team_\")) {\n url.searchParams.set(\"teamId\", options.project.orgId);\n }\n\n let response: Response;\n try {\n response = await options.fetch(url, {\n headers: { authorization: `Bearer ${options.token}` },\n });\n } catch {\n return undefined;\n }\n if (!response.ok) return undefined;\n\n let value: unknown;\n try {\n value = await response.json();\n } catch {\n return undefined;\n }\n if (!isRecord(value) || !isRecord(value.protectionBypass)) {\n return undefined;\n }\n for (const [secret, metadata] of Object.entries(value.protectionBypass)) {\n if (isRecord(metadata) && metadata.scope === \"automation-bypass\") {\n return secret;\n }\n }\n return undefined;\n}\n\nasync function readJson(filename: string): Promise<unknown> {\n try {\n return JSON.parse(await readFile(filename, \"utf8\")) as unknown;\n } catch {\n return undefined;\n }\n}\n\nfunction trimmed(value: unknown): string | undefined {\n if (typeof value !== \"string\") return undefined;\n const result = value.trim();\n return result || undefined;\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\";\nimport { resolveVercelProtectionBypass } from \"./vercel-protection.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 protectionBypass?: 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(\n command.app,\n command.protectionBypass,\n options,\n ),\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 let protectionBypass: 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\") {\n values.shift();\n if (app) throw new UsageError(\"Specify a CLI App once.\");\n app = takeValue(values, token);\n continue;\n }\n if (token === \"--protection-bypass\") {\n values.shift();\n if (protectionBypass) {\n throw new UsageError(\"Specify a protection bypass once.\");\n }\n protectionBypass = takeValue(values, token);\n continue;\n }\n break;\n }\n return {\n command: \"cli\",\n ...(app ? { app } : {}),\n ...(protectionBypass ? { protectionBypass } : {}),\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 explicitProtectionBypass: string | undefined,\n options: Pick<RunCapableCommandOptions, \"cwd\" | \"env\">,\n): Promise<AnyApp> {\n if (configured && isHttpUrl(configured)) {\n const env = options.env ?? process.env;\n const protectionBypass = await resolveVercelProtectionBypass({\n baseUrl: configured,\n cwd: path.resolve(options.cwd ?? process.cwd()),\n env,\n ...(explicitProtectionBypass\n ? { explicit: explicitProtectionBypass }\n : {}),\n });\n return createRemoteApp(createHttpTransport({\n url: new URL(\"/_capable/\", configured),\n fetch: createRemoteAppFetch(protectionBypass),\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 createRemoteAppFetch(protectionBypass: string | undefined) {\n let bypassRequired = false;\n return async (request: Request): Promise<Response> => {\n if (bypassRequired && protectionBypass) {\n const response = await fetch(withVercelProtectionBypass(\n request,\n protectionBypass,\n ));\n if (isVercelProtectionResponse(response)) {\n throw vercelProtectionError();\n }\n return response;\n }\n\n const retry = protectionBypass\n ? withVercelProtectionBypass(request.clone(), protectionBypass)\n : undefined;\n const response = await fetch(request);\n if (!isVercelProtectionResponse(response)) return response;\n if (!retry) throw vercelProtectionError();\n\n bypassRequired = true;\n const retried = await fetch(retry);\n if (isVercelProtectionResponse(retried)) {\n throw vercelProtectionError();\n }\n return retried;\n };\n}\n\nfunction withVercelProtectionBypass(\n request: Request,\n protectionBypass: string,\n): Request {\n const headers = new Headers(request.headers);\n headers.set(\"x-vercel-protection-bypass\", protectionBypass);\n return new Request(request, { headers });\n}\n\nfunction isVercelProtectionResponse(response: Response): boolean {\n return response.url.startsWith(\"https://vercel.com/sso-api\") ||\n response.url.startsWith(\"https://vercel.com/login\");\n}\n\nfunction vercelProtectionError(): Error {\n return new Error(\n \"Vercel Deployment Protection blocked the remote App. Run `vercel link` while logged in, set VERCEL_AUTOMATION_BYPASS_SECRET to a valid Protection Bypass for Automation secret, or use a public production domain.\",\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,MAAM,IAAI,MAAM,+CAA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.d.mts
CHANGED
package/dist/eve.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { o as AnyApp, w as ManifestCapability } from "./index-
|
|
2
|
-
import { DynamicResolveContext, ToolDefinition } from "eve/tools";
|
|
1
|
+
import { o as AnyApp, w as ManifestCapability } from "./index-B_I9n6gN.mjs";
|
|
2
|
+
import { DynamicResolveContext, DynamicSentinel, ToolDefinition } from "eve/tools";
|
|
3
3
|
import { Approval } from "eve/tools/approval";
|
|
4
4
|
//#region packages/eve/src/index.d.ts
|
|
5
5
|
type EveCapabilityMeta = false | {
|
|
@@ -22,7 +22,7 @@ type EveTool = ToolDefinition<Record<string, unknown>, unknown>;
|
|
|
22
22
|
* keeps step-scoped executors live, so the Capable App and its context provider do
|
|
23
23
|
* not have to cross a durable serialization boundary.
|
|
24
24
|
*/
|
|
25
|
-
declare function createEveTools(app: EveAppProvider, options?: CreateEveToolsOptions):
|
|
25
|
+
declare function createEveTools(app: EveAppProvider, options?: CreateEveToolsOptions): DynamicSentinel<Record<string, EveTool>>;
|
|
26
26
|
//#endregion
|
|
27
27
|
export { CreateEveToolsOptions, EveAppProvider, EveCapabilityMeta, createEveTools };
|
|
28
28
|
//# sourceMappingURL=eve.d.mts.map
|
package/dist/eve.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eve.mjs","names":[],"sources":["../../eve/src/index.ts"],"sourcesContent":["import {\n getAppRuntime,\n type AnyApp,\n type ManifestNode,\n type ManifestCapability,\n} from \"@capable/app\";\nimport type { CapabilityMetaRegistry } from \"@capable/core\";\nimport {\n defineDynamic,\n defineTool,\n type DynamicResolveContext,\n type ToolDefinition,\n} from \"eve/tools\";\nimport type { Approval } from \"eve/tools/approval\";\n\nexport type EveCapabilityMeta =\n | false\n | {\n readonly name?: string;\n };\n\ndeclare module \"@capable/core\" {\n interface CapabilityMetaRegistry {\n readonly eve?: EveCapabilityMeta;\n }\n}\n\nexport type CreateEveToolsOptions = {\n readonly approval?: (\n capability: ManifestCapability,\n ) => Approval | undefined;\n};\n\nexport type EveAppProvider =\n | AnyApp\n | ((\n context: DynamicResolveContext,\n ) => AnyApp | Promise<AnyApp>);\n\nconst emptyInputSchema = Object.freeze({\n type: \"object\",\n properties: Object.freeze({}),\n additionalProperties: false,\n});\n\ntype EveTool = ToolDefinition<Record<string, unknown>, unknown>;\n\n/**\n * Projects an executable Capable App into native, in-process Eve tools.\n *\n * The returned dynamic definition resolves at `step.started`. Eve deliberately\n * keeps step-scoped executors live, so the Capable App and its context provider do\n * not have to cross a durable serialization boundary.\n */\nexport function createEveTools(\n app: EveAppProvider,\n options: CreateEveToolsOptions = {},\n) {\n const capabilitiesByApp = new WeakMap<\n AnyApp,\n Promise<readonly ManifestCapability[]>\n >();\n const capabilities = (resolvedApp: AnyApp) => {\n const existing = capabilitiesByApp.get(resolvedApp);\n if (existing) return existing;\n const resolved = getAppRuntime(resolvedApp).manifest().then((manifest) =>\n flatten(manifest.capabilities)\n );\n capabilitiesByApp.set(resolvedApp, resolved);\n return resolved;\n };\n\n return defineDynamic({\n events: {\n \"step.started\": async (_event, context) => {\n const resolvedApp = typeof app === \"function\"\n ? await app(context)\n : app;\n const runtime = getAppRuntime(resolvedApp);\n const tools: Record<string, EveTool> = {};\n const names = new Set<string>();\n\n for (const capability of await capabilities(resolvedApp)) {\n const meta = capability.meta.eve as EveCapabilityMeta | undefined;\n if (meta === false) continue;\n\n const name = meta?.name ?? capability.path.join(\"__\");\n if (!/^[A-Za-z0-9_-]{1,64}$/.test(name)) {\n throw new Error(\n `Eve tool name \"${name}\" is invalid; set meta.eve.name to 1-64 letters, numbers, underscores, or hyphens`,\n );\n }\n if (names.has(name)) {\n throw new Error(`Duplicate Eve tool name \"${name}\"`);\n }\n names.add(name);\n\n const approval = options.approval?.(capability);\n const tool: EveTool = {\n description:\n capability.description ??\n capability.title ??\n `Run the Capable Capability at ${capability.path.join(\".\")}.`,\n inputSchema: (capability.input ??\n emptyInputSchema) as EveTool[\"inputSchema\"],\n ...(capability.output\n ? {\n outputSchema:\n capability.output as NonNullable<EveTool[\"outputSchema\"]>,\n }\n : {}),\n ...(approval ? { approval } : {}),\n async execute(input, context) {\n const result = await runtime.call({\n id: capability.id,\n input,\n signal: context.abortSignal,\n });\n return result.output;\n },\n };\n tools[name] = defineTool(tool);\n }\n\n return tools;\n },\n },\n });\n}\n\nfunction flatten(\n nodes: readonly ManifestNode[],\n): readonly ManifestCapability[] {\n return nodes.flatMap((node) =>\n node.type === \"capability\" ? [node] : flatten(node.children)\n );\n}\n"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"eve.mjs","names":[],"sources":["../../eve/src/index.ts"],"sourcesContent":["import {\n getAppRuntime,\n type AnyApp,\n type ManifestNode,\n type ManifestCapability,\n} from \"@capable/app\";\nimport type { CapabilityMetaRegistry } from \"@capable/core\";\nimport {\n defineDynamic,\n defineTool,\n type DynamicResolveContext,\n type DynamicSentinel,\n type ToolDefinition,\n} from \"eve/tools\";\nimport type { Approval } from \"eve/tools/approval\";\n\nexport type EveCapabilityMeta =\n | false\n | {\n readonly name?: string;\n };\n\ndeclare module \"@capable/core\" {\n interface CapabilityMetaRegistry {\n readonly eve?: EveCapabilityMeta;\n }\n}\n\nexport type CreateEveToolsOptions = {\n readonly approval?: (\n capability: ManifestCapability,\n ) => Approval | undefined;\n};\n\nexport type EveAppProvider =\n | AnyApp\n | ((\n context: DynamicResolveContext,\n ) => AnyApp | Promise<AnyApp>);\n\nconst emptyInputSchema = Object.freeze({\n type: \"object\",\n properties: Object.freeze({}),\n additionalProperties: false,\n});\n\ntype EveTool = ToolDefinition<Record<string, unknown>, unknown>;\n\n/**\n * Projects an executable Capable App into native, in-process Eve tools.\n *\n * The returned dynamic definition resolves at `step.started`. Eve deliberately\n * keeps step-scoped executors live, so the Capable App and its context provider do\n * not have to cross a durable serialization boundary.\n */\nexport function createEveTools(\n app: EveAppProvider,\n options: CreateEveToolsOptions = {},\n): DynamicSentinel<Record<string, EveTool>> {\n const capabilitiesByApp = new WeakMap<\n AnyApp,\n Promise<readonly ManifestCapability[]>\n >();\n const capabilities = (resolvedApp: AnyApp) => {\n const existing = capabilitiesByApp.get(resolvedApp);\n if (existing) return existing;\n const resolved = getAppRuntime(resolvedApp).manifest().then((manifest) =>\n flatten(manifest.capabilities)\n );\n capabilitiesByApp.set(resolvedApp, resolved);\n return resolved;\n };\n\n return defineDynamic({\n events: {\n \"step.started\": async (_event, context) => {\n const resolvedApp = typeof app === \"function\"\n ? await app(context)\n : app;\n const runtime = getAppRuntime(resolvedApp);\n const tools: Record<string, EveTool> = {};\n const names = new Set<string>();\n\n for (const capability of await capabilities(resolvedApp)) {\n const meta = capability.meta.eve as EveCapabilityMeta | undefined;\n if (meta === false) continue;\n\n const name = meta?.name ?? capability.path.join(\"__\");\n if (!/^[A-Za-z0-9_-]{1,64}$/.test(name)) {\n throw new Error(\n `Eve tool name \"${name}\" is invalid; set meta.eve.name to 1-64 letters, numbers, underscores, or hyphens`,\n );\n }\n if (names.has(name)) {\n throw new Error(`Duplicate Eve tool name \"${name}\"`);\n }\n names.add(name);\n\n const approval = options.approval?.(capability);\n const tool: EveTool = {\n description:\n capability.description ??\n capability.title ??\n `Run the Capable Capability at ${capability.path.join(\".\")}.`,\n inputSchema: (capability.input ??\n emptyInputSchema) as EveTool[\"inputSchema\"],\n ...(capability.output\n ? {\n outputSchema:\n capability.output as NonNullable<EveTool[\"outputSchema\"]>,\n }\n : {}),\n ...(approval ? { approval } : {}),\n async execute(input, context) {\n const result = await runtime.call({\n id: capability.id,\n input,\n signal: context.abortSignal,\n });\n return result.output;\n },\n };\n tools[name] = defineTool(tool);\n }\n\n return tools;\n },\n },\n });\n}\n\nfunction flatten(\n nodes: readonly ManifestNode[],\n): readonly ManifestCapability[] {\n return nodes.flatMap((node) =>\n node.type === \"capability\" ? [node] : flatten(node.children)\n );\n}\n"],"mappings":";;;AAwCA,MAAM,mBAAmB,OAAO,OAAO;CACrC,MAAM;CACN,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KAM5B,QAAO,MALc,QAAQ,KAAK;MAChC,IAAI,WAAW;MACf;MACA,QAAQ,QAAQ;KAClB,CAAC,EAAA,CACa;IAChB;GAE0B,CAAC;EAC/B;EAEA,OAAO;CACT,EACF,EACF,CAAC;AACH;AAEA,SAAS,QACP,OAC+B;CAC/B,OAAO,MAAM,SAAS,SACpB,KAAK,SAAS,eAAe,CAAC,IAAI,IAAI,QAAQ,KAAK,QAAQ,CAC7D;AACF"}
|
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-
|
|
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-AqKbVZ8Z.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-
|
|
1
|
+
import { n as createHttpTransport, r as createProtocolHandler, t as createHttpHandler } from "./src-DX2xrplP.mjs";
|
|
2
2
|
export { createHttpHandler, createHttpTransport, createProtocolHandler };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
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-
|
|
2
|
+
import { f as ApplicationTransport, o as AnyApp, t as ApplicationSelection } from "./index-B_I9n6gN.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-
|
|
57
|
+
//# sourceMappingURL=index-AqKbVZ8Z.d.mts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { L as MaybePromise, O as AppDefinition } from "./index-BB5ogMv-.mjs";
|
|
2
|
-
import { t as ApplicationSelection } from "./index-
|
|
3
|
-
import { r as ContextProvider, t as CapabilitySelection } from "./index-
|
|
2
|
+
import { t as ApplicationSelection } from "./index-B_I9n6gN.mjs";
|
|
3
|
+
import { r as ContextProvider, t as CapabilitySelection } from "./index-AqKbVZ8Z.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-
|
|
42
|
+
//# sourceMappingURL=index-B2ru1zGQ.d.mts.map
|
|
@@ -65,11 +65,10 @@ type AppCapabilityType<TCapability extends AnyCapability> = {
|
|
|
65
65
|
};
|
|
66
66
|
type AppCapabilityInput<TCapability extends AnyCapability> = TCapability extends CapabilityDefinition<any, infer TInput, any, any, any> ? TInput extends AnyObjectSchema ? InferSchemaInput<TInput> : Record<never, never> : never;
|
|
67
67
|
type AppCapabilityOutput<TCapability extends AnyCapability> = TCapability extends CapabilityDefinition<any, any, infer TOutput, any, any> ? TOutput : never;
|
|
68
|
-
type
|
|
68
|
+
type AppCapabilityOptions = {
|
|
69
69
|
readonly signal?: AbortSignal;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
}] : never;
|
|
70
|
+
};
|
|
71
|
+
type AppCapabilityArgs<TCapability extends AnyCapability> = TCapability extends CapabilityDefinition<any, infer TInput, any, any, any> ? TInput extends undefined ? [input?: Record<never, never>, options?: AppCapabilityOptions] : Record<never, never> extends AppCapabilityInput<TCapability> ? [input?: AppCapabilityInput<TCapability>, options?: AppCapabilityOptions] : [input: AppCapabilityInput<TCapability>, options?: AppCapabilityOptions] : never;
|
|
73
72
|
type AppCapabilityCall<TCapability extends AnyCapability> = ((...args: AppCapabilityArgs<TCapability>) => Promise<AppCapabilityOutput<TCapability>>) & AppCapabilityType<TCapability>;
|
|
74
73
|
type AppCapabilityIsSubscribable<TCall> = TCall extends AppCapabilityType<infer TCapability> ? TCapability extends CapabilityDefinition<any, any, any, any, any, true> ? true : false : false;
|
|
75
74
|
type CallableTree<TTree> = TTree extends AnyCapability ? AppCapabilityCall<TTree> : TTree extends CapabilityGroupDefinition<infer TCapabilities, any, any> ? CallableTree<TCapabilities> : TTree extends CapabilityTree ? { readonly [TKey in keyof TTree]: CallableTree<TTree[TKey]>; } : never;
|
|
@@ -122,4 +121,4 @@ type ApplicationSelection<TCapabilities extends CapabilityTree = CapabilityTree>
|
|
|
122
121
|
declare function selectApp<const TCapabilities extends CapabilityTree>(application: App<TCapabilities>, selection: ApplicationSelection<TCapabilities>): App<TCapabilities>;
|
|
123
122
|
//#endregion
|
|
124
123
|
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-
|
|
124
|
+
//# sourceMappingURL=index-B_I9n6gN.d.mts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
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
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-
|
|
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-B_I9n6gN.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/mcp.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as JsonSchema, h as CapabilityResult, o as AnyApp } from "./index-
|
|
2
|
-
import { i as ServerMount } from "./index-
|
|
1
|
+
import { C as JsonSchema, h as CapabilityResult, o as AnyApp } from "./index-B_I9n6gN.mjs";
|
|
2
|
+
import { i as ServerMount } from "./index-B2ru1zGQ.mjs";
|
|
3
3
|
//#region packages/mcp/src/index.d.ts
|
|
4
4
|
type McpCapabilityMeta = false | {
|
|
5
5
|
readonly name?: string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { t as CapableServer } from "./index-B2ru1zGQ.mjs";
|
|
1
2
|
//#region packages/nitro-host/src/runtime-support.d.ts
|
|
2
3
|
type CapableNitroEntryOptions = {
|
|
3
4
|
/** The default export of the project's `capable.app.*`. */
|
|
@@ -12,9 +13,7 @@ type CapableNitroEntryOptions = {
|
|
|
12
13
|
* Build the server Nitro hosts. The generated entry in the project supplies the
|
|
13
14
|
* project's own modules, so nothing here depends on how they were resolved.
|
|
14
15
|
*/
|
|
15
|
-
declare function createCapableNitroEntry(options: CapableNitroEntryOptions):
|
|
16
|
-
readonly fetch: (request: Request) => unknown;
|
|
17
|
-
};
|
|
16
|
+
declare function createCapableNitroEntry(options: CapableNitroEntryOptions): CapableServer;
|
|
18
17
|
//#endregion
|
|
19
18
|
export { CapableNitroEntryOptions, createCapableNitroEntry };
|
|
20
19
|
//# sourceMappingURL=runtime-support.d.mts.map
|