capable-kit 0.0.1-alpha.2 → 0.0.1-alpha.4
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 +37 -3
- package/dist/ai-sdk.d.mts +1 -1
- package/dist/app.d.mts +1 -1
- package/dist/bin.mjs +189 -27
- 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-BxJhwhKm.d.mts → index-B_I9n6gN.d.mts} +4 -5
- package/dist/{index-Dp-D73pf.d.mts → index-DCrxWCTv.d.mts} +3 -3
- package/dist/{index-CThfifn8.d.mts → index-DJ--zcWG.d.mts} +5 -5
- package/dist/index.d.mts +1 -1
- package/dist/mcp.d.mts +2 -2
- package/dist/mcp.mjs +1 -1
- package/dist/{mount--YHrgRHJ.mjs → mount-BEBJ2Tss.mjs} +13 -19
- package/dist/mount-BEBJ2Tss.mjs.map +1 -0
- package/dist/runtime-support.d.mts +1 -1
- package/dist/runtime-support.mjs +18 -6
- package/dist/runtime-support.mjs.map +1 -1
- package/dist/server.d.mts +2 -2
- package/dist/server.mjs +2 -2
- 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-DpSA-hBO.mjs → src-ChDFqZaE.mjs} +6 -6
- package/dist/{src-DpSA-hBO.mjs.map → src-ChDFqZaE.mjs.map} +1 -1
- package/dist/{src-XRJ9hgYX.mjs → src-D9pLpfeO.mjs} +19 -3
- package/dist/src-D9pLpfeO.mjs.map +1 -0
- package/docs/CONTEXT.md +108 -0
- package/docs/README.md +28 -0
- package/docs/internal/README.md +16 -0
- package/docs/internal/adr/0001-capability-is-the-semantic-boundary.md +24 -0
- package/docs/internal/architecture.md +126 -0
- package/docs/internal/capability-first-model.md +154 -0
- package/docs/internal/implementation-friction.md +674 -0
- package/docs/internal/why-capable.md +94 -0
- package/docs/site/capable-orpc-and-trpc.mdx +133 -0
- package/docs/site/concepts/apps.mdx +217 -0
- package/docs/site/concepts/architecture.mdx +75 -0
- package/docs/site/concepts/capabilities.mdx +249 -0
- package/docs/site/concepts/errors.mdx +93 -0
- package/docs/site/hosting/any-fetch-host.mdx +74 -0
- package/docs/site/hosting/next-js.mdx +77 -0
- package/docs/site/hosting/standalone-server.mdx +94 -0
- package/docs/site/introduction.mdx +142 -0
- package/docs/site/patterns/composition.mdx +142 -0
- package/docs/site/patterns/remote-apps.mdx +117 -0
- package/docs/site/patterns/subscriptions.mdx +87 -0
- package/docs/site/quickstart.mdx +293 -0
- package/docs/site/reference/packages-and-entry-points.mdx +70 -0
- package/docs/site/reference/surface-metadata.mdx +84 -0
- package/docs/site/reference/the-cap-cli.mdx +81 -0
- package/docs/site/surfaces/ai-sdk.mdx +94 -0
- package/docs/site/surfaces/cli.mdx +138 -0
- package/docs/site/surfaces/eve.mdx +121 -0
- package/docs/site/surfaces/http-and-openapi.mdx +111 -0
- package/docs/site/surfaces/mcp.mdx +97 -0
- package/docs/site/surfaces/react-query.mdx +80 -0
- package/docs/site/surfaces/typescript.mdx +123 -0
- package/docs/site/surfaces.mdx +78 -0
- package/docs/site/why-capable.mdx +99 -0
- package/package.json +13 -3
- package/src/package.test.ts +101 -0
- package/dist/mount--YHrgRHJ.mjs.map +0 -1
- package/dist/src-XRJ9hgYX.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -18,7 +18,6 @@ import { z } from "zod";
|
|
|
18
18
|
const greet = capability({
|
|
19
19
|
id: "greet",
|
|
20
20
|
input: z.object({ name: z.string() }),
|
|
21
|
-
output: z.object({ message: z.string() }),
|
|
22
21
|
handler: ({ input }) => ({ message: `Hello, ${input.name}` }),
|
|
23
22
|
});
|
|
24
23
|
|
|
@@ -28,6 +27,10 @@ export default defineApp({
|
|
|
28
27
|
});
|
|
29
28
|
```
|
|
30
29
|
|
|
30
|
+
TypeScript infers the handler's output type. An `output` schema is optional and
|
|
31
|
+
adds runtime output validation plus a portable schema for OpenAPI and tool
|
|
32
|
+
surfaces.
|
|
33
|
+
|
|
31
34
|
Capable is early alpha software. APIs may change without compatibility layers.
|
|
32
35
|
|
|
33
36
|
The package provides the `cap` CLI command. `capable` remains an alias:
|
|
@@ -52,7 +55,38 @@ cap build --preset vercel
|
|
|
52
55
|
vercel deploy --prebuilt
|
|
53
56
|
```
|
|
54
57
|
|
|
58
|
+
For a deployment protected by Vercel Authentication, link the local project.
|
|
59
|
+
Capable reuses the Vercel CLI login to resolve that project's Protection Bypass
|
|
60
|
+
for Automation:
|
|
61
|
+
|
|
62
|
+
```sh
|
|
63
|
+
vercel link
|
|
64
|
+
cap cli --app https://your-app.vercel.app hello
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
An explicit environment variable remains available for CI or unlinked projects:
|
|
68
|
+
|
|
69
|
+
```sh
|
|
70
|
+
export VERCEL_AUTOMATION_BYPASS_SECRET="..."
|
|
71
|
+
cap cli --app https://your-app.vercel.app hello
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Documentation
|
|
75
|
+
|
|
76
|
+
Documentation matching the installed version ships at:
|
|
77
|
+
|
|
78
|
+
```text
|
|
79
|
+
node_modules/capable-kit/docs/
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Coding agents should start with
|
|
83
|
+
`node_modules/capable-kit/docs/README.md`, then read the relevant guide before
|
|
84
|
+
writing Capable code. The package also includes its original TypeScript source
|
|
85
|
+
under `src/` when a guide does not cover a lower-level API detail.
|
|
86
|
+
|
|
55
87
|
## Package contents
|
|
56
88
|
|
|
57
|
-
The published package includes compiled ESM in `dist/`, declaration files,
|
|
58
|
-
|
|
89
|
+
The published package includes compiled ESM in `dist/`, declaration files, the
|
|
90
|
+
original TypeScript authoring source in `src/`, and the complete documentation
|
|
91
|
+
in `docs/`. User-facing guides are under `docs/site/`; framework design notes
|
|
92
|
+
and invariants are under `docs/internal/`.
|
package/dist/ai-sdk.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { A as CapabilityGroupDefinition, c as CapabilityInput, f as CapabilityOutput, i as CapabilityDefinition, j as CapabilityTree, t as AnyCapability } from "./index-BB5ogMv-.mjs";
|
|
2
|
-
import { c as AppCapabilities, o as AnyApp } from "./index-
|
|
2
|
+
import { c as AppCapabilities, o as AnyApp } from "./index-B_I9n6gN.mjs";
|
|
3
3
|
import { Tool, ToolExecutionOptions } from "ai";
|
|
4
4
|
//#region packages/ai-sdk/src/index.d.ts
|
|
5
5
|
type AiSdkCapabilityMeta = false | {
|
package/dist/app.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as JsonSchema, D as ManifestNode, E as ManifestGroup, O as createAppManifest, S as ApplicationManifest, T as ManifestError, _ as createApp, a as APP_RUNTIME_SYMBOL, b as isApp, c as AppCapabilities, d as AppContextProvider, f as ApplicationTransport, g as TransportError, h as CapabilityResult, i as APP_CAPABILITIES_SYMBOL, l as AppCapabilityCall, m as CapabilityCall, n as mergeApps, o as AnyApp, p as CallableTree, r as selectApp, s as App, t as ApplicationSelection, u as AppCapabilityIsSubscribable, v as createRemoteApp, w as ManifestCapability, x as subscribe, y as getAppRuntime } from "./index-
|
|
1
|
+
import { C as JsonSchema, D as ManifestNode, E as ManifestGroup, O as createAppManifest, S as ApplicationManifest, T as ManifestError, _ as createApp, a as APP_RUNTIME_SYMBOL, b as isApp, c as AppCapabilities, d as AppContextProvider, f as ApplicationTransport, g as TransportError, h as CapabilityResult, i as APP_CAPABILITIES_SYMBOL, l as AppCapabilityCall, m as CapabilityCall, n as mergeApps, o as AnyApp, p as CallableTree, r as selectApp, s as App, t as ApplicationSelection, u as AppCapabilityIsSubscribable, v as createRemoteApp, w as ManifestCapability, x as subscribe, y as getAppRuntime } from "./index-B_I9n6gN.mjs";
|
|
2
2
|
export { APP_CAPABILITIES_SYMBOL, APP_RUNTIME_SYMBOL, type AnyApp, type App, type AppCapabilities, type AppCapabilityCall, type AppCapabilityIsSubscribable, type AppContextProvider, type ApplicationManifest, type ApplicationSelection, type ApplicationTransport, type CallableTree, type CapabilityCall, type CapabilityResult, type JsonSchema, type ManifestCapability, type ManifestError, type ManifestGroup, type ManifestNode, TransportError, createApp, createAppManifest, createRemoteApp, getAppRuntime, isApp, mergeApps, selectApp, subscribe };
|
package/dist/bin.mjs
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
import { t as APPLICATION_SYMBOL } from "./src-B53ZbNtC.mjs";
|
|
3
3
|
import { l as isApp, o as createApp, s as createRemoteApp } from "./src-3UaBqI8H.mjs";
|
|
4
4
|
import { a as createCliStyle, c as renderSection, l as supportsColor, n as runCli, o as descriptionColumn, s as renderRows } from "./src-BjBxOv7x.mjs";
|
|
5
|
-
import { n as createHttpTransport } from "./src-
|
|
5
|
+
import { n as createHttpTransport } from "./src-D9pLpfeO.mjs";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import { spawn } from "node:child_process";
|
|
8
8
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
9
9
|
import { existsSync } from "node:fs";
|
|
10
10
|
import { mkdir, readFile, stat, writeFile } from "node:fs/promises";
|
|
11
11
|
import { build, createDevServer, createNitro, prepare } from "nitro/builder";
|
|
12
|
+
import { homedir } from "node:os";
|
|
12
13
|
//#region packages/nitro-host/src/index.ts
|
|
13
14
|
const virtualServerEntry = "#capable/entry";
|
|
14
15
|
/**
|
|
@@ -217,10 +218,17 @@ const TOPICS = {
|
|
|
217
218
|
cli: {
|
|
218
219
|
usage: "cap cli [options] <command...>",
|
|
219
220
|
summary: "Call your App's Capabilities from the terminal.",
|
|
220
|
-
options: [
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
221
|
+
options: [
|
|
222
|
+
{
|
|
223
|
+
label: "--app <path|url>",
|
|
224
|
+
description: "Project, App entry, or a running Capable server URL"
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
label: "--protection-bypass <secret>",
|
|
228
|
+
description: "Vercel Deployment Protection bypass"
|
|
229
|
+
},
|
|
230
|
+
HELP_OPTION
|
|
231
|
+
],
|
|
224
232
|
footer: "Run `cap cli -- --help` to list the commands your App derives."
|
|
225
233
|
}
|
|
226
234
|
};
|
|
@@ -376,7 +384,7 @@ async function readPackageJson(filename) {
|
|
|
376
384
|
throw error;
|
|
377
385
|
}
|
|
378
386
|
const value = JSON.parse(source);
|
|
379
|
-
if (!isRecord(value)) throw new Error(`${filename} must contain a JSON object`);
|
|
387
|
+
if (!isRecord$1(value)) throw new Error(`${filename} must contain a JSON object`);
|
|
380
388
|
return value;
|
|
381
389
|
}
|
|
382
390
|
function preparePackageJson(directory, existing) {
|
|
@@ -415,7 +423,7 @@ function preparePackageJson(directory, existing) {
|
|
|
415
423
|
function readObjectField(value, field) {
|
|
416
424
|
const current = value[field];
|
|
417
425
|
if (current === void 0) return {};
|
|
418
|
-
if (!isRecord(current)) throw new Error(`package.json "${field}" must be an object`);
|
|
426
|
+
if (!isRecord$1(current)) throw new Error(`package.json "${field}" must be an object`);
|
|
419
427
|
return { ...current };
|
|
420
428
|
}
|
|
421
429
|
function hasDeclaredDependency(packageJson, name) {
|
|
@@ -426,7 +434,7 @@ function hasDeclaredDependency(packageJson, name) {
|
|
|
426
434
|
"optionalDependencies"
|
|
427
435
|
].some((field) => {
|
|
428
436
|
const dependencies = packageJson[field];
|
|
429
|
-
return isRecord(dependencies) && name in dependencies;
|
|
437
|
+
return isRecord$1(dependencies) && name in dependencies;
|
|
430
438
|
});
|
|
431
439
|
}
|
|
432
440
|
function packageName(directory) {
|
|
@@ -435,6 +443,107 @@ function packageName(directory) {
|
|
|
435
443
|
function applicationName(directory, packageJson) {
|
|
436
444
|
return ((typeof packageJson.name === "string" ? packageJson.name.split("/").at(-1) : void 0) || path.basename(directory)).split(/[-_.\s]+/).filter(Boolean).map((part) => `${part[0].toUpperCase()}${part.slice(1)}`).join(" ") || "Capable App";
|
|
437
445
|
}
|
|
446
|
+
function isRecord$1(value) {
|
|
447
|
+
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
448
|
+
}
|
|
449
|
+
//#endregion
|
|
450
|
+
//#region packages/toolchain/src/vercel-protection.ts
|
|
451
|
+
async function resolveVercelProtectionBypass(options) {
|
|
452
|
+
const explicit = trimmed(options.explicit);
|
|
453
|
+
if (explicit) return explicit;
|
|
454
|
+
const configured = trimmed(options.env.VERCEL_AUTOMATION_BYPASS_SECRET);
|
|
455
|
+
if (configured) return configured;
|
|
456
|
+
if (!isLikelyVercelDeployment(options.baseUrl)) return void 0;
|
|
457
|
+
const token = trimmed(options.env.VERCEL_TOKEN) ?? await readVercelCliToken(options.env);
|
|
458
|
+
if (!token) return void 0;
|
|
459
|
+
const project = await resolveLinkedProject(options.cwd, options.env);
|
|
460
|
+
if (!project) return void 0;
|
|
461
|
+
return await fetchAutomationBypass({
|
|
462
|
+
token,
|
|
463
|
+
project,
|
|
464
|
+
fetch: options.fetch ?? fetch
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
function isLikelyVercelDeployment(value) {
|
|
468
|
+
try {
|
|
469
|
+
const hostname = new URL(value).hostname.toLowerCase();
|
|
470
|
+
return hostname.endsWith(".vercel.app") || hostname.endsWith(".vercel.dev") || hostname.endsWith(".now.sh");
|
|
471
|
+
} catch {
|
|
472
|
+
return false;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
async function readVercelCliToken(env) {
|
|
476
|
+
const home = homedir();
|
|
477
|
+
const paths = [
|
|
478
|
+
trimmed(env.VERCEL_AUTH_FILE),
|
|
479
|
+
path.join(home, "Library", "Application Support", "com.vercel.cli", "auth.json"),
|
|
480
|
+
trimmed(env.XDG_CONFIG_HOME) ? path.join(env.XDG_CONFIG_HOME, "com.vercel.cli", "auth.json") : void 0,
|
|
481
|
+
trimmed(env.XDG_DATA_HOME) ? path.join(env.XDG_DATA_HOME, "com.vercel.cli", "auth.json") : void 0,
|
|
482
|
+
path.join(home, ".config", "com.vercel.cli", "auth.json"),
|
|
483
|
+
path.join(home, ".local", "share", "com.vercel.cli", "auth.json"),
|
|
484
|
+
path.join(home, ".vercel", "auth.json"),
|
|
485
|
+
path.join(home, ".now", "auth.json")
|
|
486
|
+
];
|
|
487
|
+
for (const filename of paths) {
|
|
488
|
+
if (!filename) continue;
|
|
489
|
+
const value = await readJson$1(filename);
|
|
490
|
+
const token = isRecord(value) ? trimmed(value.token) : void 0;
|
|
491
|
+
if (token) return token;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
async function resolveLinkedProject(cwd, env) {
|
|
495
|
+
const projectId = trimmed(env.VERCEL_PROJECT_ID);
|
|
496
|
+
const orgId = trimmed(env.VERCEL_ORG_ID);
|
|
497
|
+
if (projectId && orgId) return {
|
|
498
|
+
projectId,
|
|
499
|
+
orgId
|
|
500
|
+
};
|
|
501
|
+
let directory = path.resolve(cwd);
|
|
502
|
+
while (true) {
|
|
503
|
+
const value = await readJson$1(path.join(directory, ".vercel/project.json"));
|
|
504
|
+
if (isRecord(value)) {
|
|
505
|
+
const linkedProjectId = trimmed(value.projectId);
|
|
506
|
+
const linkedOrgId = trimmed(value.orgId);
|
|
507
|
+
if (linkedProjectId && linkedOrgId) return {
|
|
508
|
+
projectId: linkedProjectId,
|
|
509
|
+
orgId: linkedOrgId
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
const parent = path.dirname(directory);
|
|
513
|
+
if (parent === directory) return void 0;
|
|
514
|
+
directory = parent;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
async function fetchAutomationBypass(options) {
|
|
518
|
+
const url = new URL(`https://api.vercel.com/v9/projects/${encodeURIComponent(options.project.projectId)}`);
|
|
519
|
+
if (options.project.orgId.startsWith("team_")) url.searchParams.set("teamId", options.project.orgId);
|
|
520
|
+
let response;
|
|
521
|
+
try {
|
|
522
|
+
response = await options.fetch(url, { headers: { authorization: `Bearer ${options.token}` } });
|
|
523
|
+
} catch {
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
if (!response.ok) return void 0;
|
|
527
|
+
let value;
|
|
528
|
+
try {
|
|
529
|
+
value = await response.json();
|
|
530
|
+
} catch {
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
if (!isRecord(value) || !isRecord(value.protectionBypass)) return;
|
|
534
|
+
for (const [secret, metadata] of Object.entries(value.protectionBypass)) if (isRecord(metadata) && metadata.scope === "automation-bypass") return secret;
|
|
535
|
+
}
|
|
536
|
+
async function readJson$1(filename) {
|
|
537
|
+
try {
|
|
538
|
+
return JSON.parse(await readFile(filename, "utf8"));
|
|
539
|
+
} catch {
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
function trimmed(value) {
|
|
544
|
+
if (typeof value !== "string") return void 0;
|
|
545
|
+
return value.trim() || void 0;
|
|
546
|
+
}
|
|
438
547
|
function isRecord(value) {
|
|
439
548
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
440
549
|
}
|
|
@@ -451,7 +560,7 @@ async function runCapableCommand(argv, options = {}) {
|
|
|
451
560
|
return 0;
|
|
452
561
|
}
|
|
453
562
|
if (command.command === "cli") return runCli({
|
|
454
|
-
app: await resolveCliApp(command.app, options),
|
|
563
|
+
app: await resolveCliApp(command.app, command.protectionBypass, options),
|
|
455
564
|
argv: command.argv,
|
|
456
565
|
...!options.stdout && process.stdout.isTTY ? { isTTY: true } : {},
|
|
457
566
|
...!options.stdout && process.stdout.columns ? { columns: process.stdout.columns } : {},
|
|
@@ -607,6 +716,7 @@ function parseInit(argv) {
|
|
|
607
716
|
function parseCli(argv) {
|
|
608
717
|
const values = [...argv];
|
|
609
718
|
let app;
|
|
719
|
+
let protectionBypass;
|
|
610
720
|
while (values.length) {
|
|
611
721
|
const token = values[0];
|
|
612
722
|
if (token === "--help" || token === "-h") return {
|
|
@@ -617,14 +727,24 @@ function parseCli(argv) {
|
|
|
617
727
|
values.shift();
|
|
618
728
|
break;
|
|
619
729
|
}
|
|
620
|
-
if (token
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
730
|
+
if (token === "--app") {
|
|
731
|
+
values.shift();
|
|
732
|
+
if (app) throw new UsageError("Specify a CLI App once.");
|
|
733
|
+
app = takeValue(values, token);
|
|
734
|
+
continue;
|
|
735
|
+
}
|
|
736
|
+
if (token === "--protection-bypass") {
|
|
737
|
+
values.shift();
|
|
738
|
+
if (protectionBypass) throw new UsageError("Specify a protection bypass once.");
|
|
739
|
+
protectionBypass = takeValue(values, token);
|
|
740
|
+
continue;
|
|
741
|
+
}
|
|
742
|
+
break;
|
|
624
743
|
}
|
|
625
744
|
return {
|
|
626
745
|
command: "cli",
|
|
627
746
|
...app ? { app } : {},
|
|
747
|
+
...protectionBypass ? { protectionBypass } : {},
|
|
628
748
|
argv: values
|
|
629
749
|
};
|
|
630
750
|
}
|
|
@@ -647,8 +767,20 @@ function capitalize(value) {
|
|
|
647
767
|
function shellArgument(value) {
|
|
648
768
|
return /^[a-zA-Z0-9_./-]+$/.test(value) ? value : `'${value.replaceAll("'", "'\\''")}'`;
|
|
649
769
|
}
|
|
650
|
-
async function resolveCliApp(configured, options) {
|
|
651
|
-
if (configured && isHttpUrl(configured))
|
|
770
|
+
async function resolveCliApp(configured, explicitProtectionBypass, options) {
|
|
771
|
+
if (configured && isHttpUrl(configured)) {
|
|
772
|
+
const env = options.env ?? process.env;
|
|
773
|
+
const protectionBypass = await resolveVercelProtectionBypass({
|
|
774
|
+
baseUrl: configured,
|
|
775
|
+
cwd: path.resolve(options.cwd ?? process.cwd()),
|
|
776
|
+
env,
|
|
777
|
+
...explicitProtectionBypass ? { explicit: explicitProtectionBypass } : {}
|
|
778
|
+
});
|
|
779
|
+
return createRemoteApp(createHttpTransport({
|
|
780
|
+
url: new URL("/_capable/", configured),
|
|
781
|
+
fetch: createRemoteAppFetch(protectionBypass)
|
|
782
|
+
}));
|
|
783
|
+
}
|
|
652
784
|
const project = await resolveCapableProject({
|
|
653
785
|
...configured ? { project: configured } : {},
|
|
654
786
|
...options.cwd ? { cwd: options.cwd } : {},
|
|
@@ -675,6 +807,35 @@ function isHttpUrl(value) {
|
|
|
675
807
|
return false;
|
|
676
808
|
}
|
|
677
809
|
}
|
|
810
|
+
function createRemoteAppFetch(protectionBypass) {
|
|
811
|
+
let bypassRequired = false;
|
|
812
|
+
return async (request) => {
|
|
813
|
+
if (bypassRequired && protectionBypass) {
|
|
814
|
+
const response = await fetch(withVercelProtectionBypass(request, protectionBypass));
|
|
815
|
+
if (isVercelProtectionResponse(response)) throw vercelProtectionError();
|
|
816
|
+
return response;
|
|
817
|
+
}
|
|
818
|
+
const retry = protectionBypass ? withVercelProtectionBypass(request.clone(), protectionBypass) : void 0;
|
|
819
|
+
const response = await fetch(request);
|
|
820
|
+
if (!isVercelProtectionResponse(response)) return response;
|
|
821
|
+
if (!retry) throw vercelProtectionError();
|
|
822
|
+
bypassRequired = true;
|
|
823
|
+
const retried = await fetch(retry);
|
|
824
|
+
if (isVercelProtectionResponse(retried)) throw vercelProtectionError();
|
|
825
|
+
return retried;
|
|
826
|
+
};
|
|
827
|
+
}
|
|
828
|
+
function withVercelProtectionBypass(request, protectionBypass) {
|
|
829
|
+
const headers = new Headers(request.headers);
|
|
830
|
+
headers.set("x-vercel-protection-bypass", protectionBypass);
|
|
831
|
+
return new Request(request, { headers });
|
|
832
|
+
}
|
|
833
|
+
function isVercelProtectionResponse(response) {
|
|
834
|
+
return response.url.startsWith("https://vercel.com/sso-api") || response.url.startsWith("https://vercel.com/login");
|
|
835
|
+
}
|
|
836
|
+
function vercelProtectionError() {
|
|
837
|
+
return /* @__PURE__ */ new Error("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.");
|
|
838
|
+
}
|
|
678
839
|
function isFetchServer(value) {
|
|
679
840
|
return Boolean(value && typeof value === "object" && typeof value.fetch === "function");
|
|
680
841
|
}
|
|
@@ -685,7 +846,7 @@ async function renderDevReady(server, options) {
|
|
|
685
846
|
const mcp = await probeMcp(origin);
|
|
686
847
|
const paint = createPainter(options.color ?? false);
|
|
687
848
|
const routes = [["Local", displayOrigin(origin)]];
|
|
688
|
-
if (manifest) routes.push(["
|
|
849
|
+
if (manifest) routes.push(["Capable", "/_capable"]);
|
|
689
850
|
if (openapi) routes.push(["HTTP", "/api"], ["OpenAPI", "/openapi.json"]);
|
|
690
851
|
if (mcp) routes.push(["MCP", "/mcp"]);
|
|
691
852
|
if (!manifest && !openapi && options.hasAuthoredServer) routes.push(["Server", "capable.server.ts"]);
|
|
@@ -739,9 +900,8 @@ async function readJson(url) {
|
|
|
739
900
|
}
|
|
740
901
|
}
|
|
741
902
|
/**
|
|
742
|
-
* Probe the default MCP mount
|
|
743
|
-
*
|
|
744
|
-
* connect at `/mcp`.
|
|
903
|
+
* Probe the default MCP mount with the stateless `server/discover` exchange
|
|
904
|
+
* introduced in MCP 2026-07-28.
|
|
745
905
|
*/
|
|
746
906
|
async function probeMcp(origin) {
|
|
747
907
|
try {
|
|
@@ -749,20 +909,22 @@ async function probeMcp(origin) {
|
|
|
749
909
|
method: "POST",
|
|
750
910
|
headers: {
|
|
751
911
|
"content-type": "application/json",
|
|
752
|
-
accept: "application/json, text/event-stream"
|
|
912
|
+
accept: "application/json, text/event-stream",
|
|
913
|
+
"mcp-protocol-version": "2026-07-28",
|
|
914
|
+
"mcp-method": "server/discover"
|
|
753
915
|
},
|
|
754
916
|
body: JSON.stringify({
|
|
755
917
|
jsonrpc: "2.0",
|
|
756
918
|
id: 1,
|
|
757
|
-
method: "
|
|
758
|
-
params: {
|
|
759
|
-
protocolVersion: "
|
|
760
|
-
|
|
761
|
-
clientInfo: {
|
|
919
|
+
method: "server/discover",
|
|
920
|
+
params: { _meta: {
|
|
921
|
+
"io.modelcontextprotocol/protocolVersion": "2026-07-28",
|
|
922
|
+
"io.modelcontextprotocol/clientInfo": {
|
|
762
923
|
name: "capable",
|
|
763
924
|
version: "0.0.0"
|
|
764
|
-
}
|
|
765
|
-
|
|
925
|
+
},
|
|
926
|
+
"io.modelcontextprotocol/clientCapabilities": {}
|
|
927
|
+
} }
|
|
766
928
|
})
|
|
767
929
|
});
|
|
768
930
|
if (!response.ok) return false;
|