devframe 0.9.0-beta.2 → 0.9.0-beta.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/dist/{_shared-DmpWW-HH.d.mts → _shared-Bm8p4-fD.d.mts} +1 -3
- package/dist/{dist-D8jAMwxU.mjs → _shared-CGPVmXUM.mjs} +67 -1
- package/dist/adapters/build.d.mts +1 -1
- package/dist/adapters/build.mjs +3 -3
- package/dist/adapters/cac.d.mts +1 -1
- package/dist/adapters/cac.mjs +4 -4
- package/dist/adapters/dev.d.mts +7 -7
- package/dist/adapters/dev.mjs +2 -2
- package/dist/adapters/embedded.d.mts +1 -1
- package/dist/adapters/initiate.d.mts +3 -3
- package/dist/adapters/initiate.mjs +1 -1
- package/dist/adapters/mcp.d.mts +1 -8
- package/dist/adapters/mcp.mjs +1 -1
- package/dist/{agent-tool-name-C3b5vEwJ.mjs → agent-tool-name-EgfoFO8C.mjs} +0 -3
- package/dist/cli/main.d.mts +0 -2
- package/dist/cli/main.mjs +3 -7
- package/dist/client/index.d.mts +5 -5
- package/dist/{context-C33rR7n0.mjs → context-CMSryXs-.mjs} +10 -1
- package/dist/{context-CSCwoABx.d.mts → context-DV4uWieM.d.mts} +19 -1
- package/dist/{context-Du11TLcO.mjs → context-b6iSomtv.mjs} +4 -5
- package/dist/{dev-BEveeA5H.mjs → dev-4xjiynUD.mjs} +6 -6
- package/dist/{devframe-Bdd9YXTy.d.mts → devframe-5oblos7I.d.mts} +52 -36
- package/dist/{diagnostics-DLYH5oD3.mjs → diagnostics-C7IGWppM.mjs} +2 -2
- package/dist/{host-agent-CpbAoqBx.mjs → host-agent-BBkKT27Q.mjs} +2 -6
- package/dist/{http-DLr_cJZ7.mjs → http-Z0w9baEe.mjs} +3 -10
- package/dist/{index-CZRd2K1C.d.mts → index-BzDl02lt.d.mts} +2 -2
- package/dist/{index-DSCq4M4q.d.mts → index-tdrk1bzV.d.mts} +1 -1
- package/dist/index.d.mts +5 -5
- package/dist/{instance-registry-BQqGoDO9.mjs → instance-registry-Du_hbx-j.mjs} +1 -7
- package/dist/{instance-shell-DBTXTSjN.d.mts → instance-shell-B-BSVp37.d.mts} +3 -12
- package/dist/{instance-shell-KRdee1QF.mjs → instance-shell-B0TwOxCl.mjs} +9 -8
- package/dist/internal/index.d.mts +202 -9
- package/dist/internal/index.mjs +7 -5
- package/dist/node/auth.d.mts +2 -2
- package/dist/node/hub-internals.d.mts +2 -2
- package/dist/node/hub-internals.mjs +2 -2
- package/dist/node/index.d.mts +3 -3
- package/dist/node/index.mjs +2 -2
- package/dist/recipes/common-rpc-functions.d.mts +3 -3
- package/dist/recipes/interactive-auth.d.mts +2 -2
- package/dist/recipes/interactive-auth.mjs +1 -1
- package/dist/rpc/dump.d.mts +1 -1
- package/dist/rpc/index.d.mts +2 -2
- package/dist/rpc/transports/sse-client.d.mts +1 -1
- package/dist/rpc/transports/sse-server.d.mts +2 -2
- package/dist/rpc/transports/ws-bun.d.mts +2 -2
- package/dist/rpc/transports/ws-client.d.mts +1 -1
- package/dist/rpc/transports/ws-server.d.mts +1 -1
- package/dist/{rpc-core-CGctXToO.d.mts → rpc-core-B4Qm66Qt.d.mts} +3 -3
- package/dist/{rpc-core-CqcJkAu9.mjs → rpc-core-Cva-0pw0.mjs} +1 -1
- package/dist/{sse-client-BsIK3hMD.d.mts → sse-client-CFBOIaUi.d.mts} +1 -1
- package/dist/{storage-BcmVEJRc.mjs → storage-CaUVrBrG.mjs} +1 -1
- package/dist/types/index.d.mts +4 -4
- package/dist/{types-CnJSgRVa.d.mts → types-Djq7CBXh.d.mts} +0 -7
- package/dist/utils/agent-tool-name.d.mts +0 -3
- package/dist/utils/agent-tool-name.mjs +0 -3
- package/dist/utils/events.d.mts +1 -1
- package/dist/utils/shared-state.d.mts +1 -1
- package/dist/utils/streaming-channel.d.mts +1 -1
- package/dist/{ws-client-CdNuATYa.d.mts → ws-client-DhjNyQo3.d.mts} +1 -1
- package/dist/{ws-server-Ces08fjP.d.mts → ws-server-D1d3QM9f.d.mts} +1 -1
- package/package.json +1 -2
- package/skills/devframe/SKILL.md +6 -6
- package/dist/_shared-CttmCMBi.mjs +0 -70
- package/dist/helpers/vite.d.mts +0 -104
- package/dist/helpers/vite.mjs +0 -93
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import "./constants.mjs";
|
|
2
|
-
import { n as getPort } from "./dist-D8jAMwxU.mjs";
|
|
3
|
-
import { cleanDoubleSlashes, withLeadingSlash, withTrailingSlash, withoutLeadingSlash } from "ufo";
|
|
4
|
-
//#region src/adapters/_shared.ts
|
|
5
|
-
const DEFAULT_PORT = 9999;
|
|
6
|
-
/**
|
|
7
|
-
* Resolve the mount base path for a devframe's SPA. Hosted adapters
|
|
8
|
-
* (`vite`, `embedded`) default to `/__<id>/` so they don't collide
|
|
9
|
-
* with the host app; standalone adapters (`cli`, `spa`, `build`)
|
|
10
|
-
* default to `/` because they own the origin.
|
|
11
|
-
*
|
|
12
|
-
* The devframe author can override with `basePath` on the definition.
|
|
13
|
-
*/
|
|
14
|
-
function resolveBasePath(def, kind) {
|
|
15
|
-
if (def.basePath) return normalizeBasePath(def.basePath);
|
|
16
|
-
return kind === "standalone" ? "/" : `/__${def.id}/`;
|
|
17
|
-
}
|
|
18
|
-
function normalizeBasePath(base) {
|
|
19
|
-
return cleanDoubleSlashes(withTrailingSlash(withLeadingSlash(base)));
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Resolve the listening port for `createDevServer` (and `createHandler`'s
|
|
23
|
-
* side-car tiers), honoring the definition's `cli.port` / `cli.portRange` /
|
|
24
|
-
* `cli.random` settings. Exposed separately so authors who run their own
|
|
25
|
-
* argv parsing can resolve a port up-front (to print it, log it, etc.)
|
|
26
|
-
* before starting the server.
|
|
27
|
-
*/
|
|
28
|
-
async function resolveDevServerPort(def, options = {}) {
|
|
29
|
-
const host = options.host ?? def.cli?.host ?? "localhost";
|
|
30
|
-
const portOptions = {
|
|
31
|
-
port: options.defaultPort ?? def.cli?.port ?? DEFAULT_PORT,
|
|
32
|
-
host
|
|
33
|
-
};
|
|
34
|
-
if (def.cli?.portRange) portOptions.portRange = def.cli.portRange;
|
|
35
|
-
if (def.cli?.random) portOptions.random = def.cli.random;
|
|
36
|
-
return getPort(portOptions);
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Normalize the `cli.mcp` / `mcp` option (`boolean | McpRouteOptions`) into
|
|
40
|
-
* concrete options, or `undefined` when the MCP route is disabled.
|
|
41
|
-
*/
|
|
42
|
-
function resolveMcpConfig(mcp) {
|
|
43
|
-
if (!mcp) return void 0;
|
|
44
|
-
return mcp === true ? {} : mcp;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Resolve the `mcp` entry a `__connection.json` should advertise for a dev
|
|
48
|
-
* server started with the given `mcp` option (falling back to `def.cli?.mcp`,
|
|
49
|
-
* exactly like `createDevServer`), or `undefined` when the route is
|
|
50
|
-
* disabled.
|
|
51
|
-
*
|
|
52
|
-
* Hosted bridges that hand-roll their connection meta pass the side-car
|
|
53
|
-
* `port`: the advertised path becomes absolute (the side-car mounts at `/`)
|
|
54
|
-
* and the client dials `<page-host>:<port><path>`. Without `port` the path
|
|
55
|
-
* stays relative, resolved against `__connection.json`'s own location (the
|
|
56
|
-
* same-server default).
|
|
57
|
-
*
|
|
58
|
-
* @experimental
|
|
59
|
-
*/
|
|
60
|
-
function resolveMcpConnectionMeta(def, mcp, port) {
|
|
61
|
-
const config = resolveMcpConfig(mcp ?? def.cli?.mcp);
|
|
62
|
-
if (!config) return void 0;
|
|
63
|
-
const route = withoutLeadingSlash(config.path ?? "__mcp");
|
|
64
|
-
return port != null ? {
|
|
65
|
-
path: withLeadingSlash(route),
|
|
66
|
-
port
|
|
67
|
-
} : { path: route };
|
|
68
|
-
}
|
|
69
|
-
//#endregion
|
|
70
|
-
export { resolveMcpConnectionMeta as i, resolveBasePath as n, resolveDevServerPort as r, normalizeBasePath as t };
|
package/dist/helpers/vite.d.mts
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { f as McpRouteOptions, p as DevframeAuthHandler, r as DevframeDefinition } from "../devframe-Bdd9YXTy.mjs";
|
|
2
|
-
import { IncomingMessage, Server, ServerResponse } from "node:http";
|
|
3
|
-
//#region src/helpers/vite.d.ts
|
|
4
|
-
interface ViteDevBridgeOptions {
|
|
5
|
-
/**
|
|
6
|
-
* Mount base. Defaults to `def.basePath ?? '/__<id>/'` for this hosted
|
|
7
|
-
* adapter — the devframe shares the origin with the host Vite app.
|
|
8
|
-
*
|
|
9
|
-
* Relative spellings like `'./'` (common for base-agnostic Nuxt builds)
|
|
10
|
-
* are normalized to absolute paths so they compose with Vite's connect
|
|
11
|
-
* router.
|
|
12
|
-
*/
|
|
13
|
-
base?: string;
|
|
14
|
-
/**
|
|
15
|
-
* Dev-time middleware mode. When set, the host app owns the SPA and
|
|
16
|
-
* devframe serves the RPC surface through the Vite dev server itself —
|
|
17
|
-
* `<base>__connection.json` for discovery and the WebSocket upgrade at
|
|
18
|
-
* `<base>__ws` on Vite's own HTTP server (zero extra ports, proxy/HTTPS
|
|
19
|
-
* friendly). When Vite runs in middleware mode (no `httpServer`) — or a
|
|
20
|
-
* `port` is pinned — the socket falls back to a side-car server on its
|
|
21
|
-
* own port instead.
|
|
22
|
-
*
|
|
23
|
-
* - `false` (default) — static-mount the SPA at `base` with SPA
|
|
24
|
-
* fallback. No RPC server is started.
|
|
25
|
-
* - `true` — bridge mode with all defaults.
|
|
26
|
-
* - object — bridge mode with explicit overrides.
|
|
27
|
-
*/
|
|
28
|
-
devMiddleware?: boolean | {
|
|
29
|
-
/**
|
|
30
|
-
* Pin a side-car port for the RPC socket instead of sharing Vite's
|
|
31
|
-
* server. Default: share Vite's HTTP server (side-car only when Vite
|
|
32
|
-
* has none).
|
|
33
|
-
*/
|
|
34
|
-
port?: number;
|
|
35
|
-
/** Override the side-car bind host. Default: `def.cli?.host ?? 'localhost'`. */
|
|
36
|
-
host?: string;
|
|
37
|
-
/** Flag bag forwarded to `def.setup(ctx, { flags })`. */
|
|
38
|
-
flags?: Record<string, unknown>;
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Whether the bridged devframe runs its own auth gate. The RPC endpoint is
|
|
42
|
-
* reachable by anything that can open its socket, so it **gates by
|
|
43
|
-
* default**: when unset, authentication resolves through devframe's
|
|
44
|
-
* interactive OTP gate (unless the definition's `cli.auth` opts out), and
|
|
45
|
-
* the bridge prints its code/link banner to stdout. Pass a
|
|
46
|
-
* {@link DevframeAuthHandler} to install a custom scheme, or `false` to opt
|
|
47
|
-
* out for a single-user localhost host that owns the trust boundary another
|
|
48
|
-
* way. Only applies in bridge mode (`devMiddleware`); the static-mount mode
|
|
49
|
-
* starts no RPC server.
|
|
50
|
-
*
|
|
51
|
-
* @default gated (devframe's interactive OTP, unless `cli.auth` opts out)
|
|
52
|
-
*/
|
|
53
|
-
auth?: boolean | DevframeAuthHandler;
|
|
54
|
-
/**
|
|
55
|
-
* Expose the bridge's route-based MCP server (Streamable-HTTP) at
|
|
56
|
-
* `<base>__mcp` — on the Vite app's own origin — and advertise it in the
|
|
57
|
-
* bridge's `__connection.json`. Overrides `def.cli?.mcp`, `undefined`
|
|
58
|
-
* falls through to it, `false` disables the route regardless. Only applies
|
|
59
|
-
* in bridge mode (`devMiddleware`); the static-mount mode starts no server.
|
|
60
|
-
*
|
|
61
|
-
* @experimental
|
|
62
|
-
*/
|
|
63
|
-
mcp?: boolean | McpRouteOptions;
|
|
64
|
-
}
|
|
65
|
-
/** The slice of a Vite dev server the bridge plugin touches. */
|
|
66
|
-
interface DevframeViteDevServerLike {
|
|
67
|
-
middlewares: {
|
|
68
|
-
use: ((path: string, handler: (req: IncomingMessage, res: ServerResponse, next?: (err?: unknown) => void) => void) => void) & ((handler: (req: IncomingMessage, res: ServerResponse, next?: (err?: unknown) => void) => void) => void);
|
|
69
|
-
};
|
|
70
|
-
httpServer?: Server | null;
|
|
71
|
-
}
|
|
72
|
-
interface DevframeVitePlugin {
|
|
73
|
-
name: string;
|
|
74
|
-
apply: 'serve';
|
|
75
|
-
configureServer: (server: DevframeViteDevServerLike) => void | Promise<void>;
|
|
76
|
-
closeBundle?: () => void | Promise<void>;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Bridge a devframe into an existing Vite dev server. Returns a Vite
|
|
80
|
-
* plugin with two modes, picked via `options.devMiddleware`:
|
|
81
|
-
*
|
|
82
|
-
* - **static-mount mode** (default) — mounts `def.cli.distDir` at
|
|
83
|
-
* `options.base` with SPA fallback enabled. No RPC server is started.
|
|
84
|
-
*
|
|
85
|
-
* - **bridge mode** (`devMiddleware: true | {…}`) — skips the static
|
|
86
|
-
* mount; the host app owns the SPA. Devframe serves discovery
|
|
87
|
-
* (`<base>__connection.json`), the WebSocket RPC upgrade
|
|
88
|
-
* (`<base>__ws`, shared on Vite's own HTTP server), and the optional
|
|
89
|
-
* MCP route through {@link initDevframe}'s node middleware, so the
|
|
90
|
-
* host-served SPA can discover the endpoint via {@link connectDevframe}.
|
|
91
|
-
*
|
|
92
|
-
* The bridge **gates by default** (devframe's interactive OTP unless the
|
|
93
|
-
* definition's `cli.auth` opts out), printing its code/link banner to stdout,
|
|
94
|
-
* so a bridged devframe isn't silently reachable by anything that can open
|
|
95
|
-
* its socket. Pass `options.auth: false` to opt out for a single-user
|
|
96
|
-
* localhost host, or a {@link DevframeAuthHandler} for a custom scheme.
|
|
97
|
-
*
|
|
98
|
-
* Use bridge mode when integrating with frameworks that own the SPA
|
|
99
|
-
* (Nuxt, Astro, SolidStart, plain Vite apps). For the all-in-one
|
|
100
|
-
* `dev` / `build` / `mcp` shell, reach for {@link createCac} instead.
|
|
101
|
-
*/
|
|
102
|
-
declare function viteDevBridge(d: DevframeDefinition, options?: ViteDevBridgeOptions): DevframeVitePlugin;
|
|
103
|
-
//#endregion
|
|
104
|
-
export { DevframeViteDevServerLike, DevframeVitePlugin, ViteDevBridgeOptions, viteDevBridge };
|
package/dist/helpers/vite.mjs
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { t as diagnostics } from "../diagnostics-DLYH5oD3.mjs";
|
|
2
|
-
import { n as resolveBasePath, t as normalizeBasePath } from "../_shared-CttmCMBi.mjs";
|
|
3
|
-
import { serveStaticNodeMiddleware } from "../utils/serve-static.mjs";
|
|
4
|
-
import { r as initDevframe } from "../dev-BEveeA5H.mjs";
|
|
5
|
-
import { resolve } from "pathe";
|
|
6
|
-
//#region src/helpers/vite.ts
|
|
7
|
-
/**
|
|
8
|
-
* Bridge a devframe into an existing Vite dev server. Returns a Vite
|
|
9
|
-
* plugin with two modes, picked via `options.devMiddleware`:
|
|
10
|
-
*
|
|
11
|
-
* - **static-mount mode** (default) — mounts `def.cli.distDir` at
|
|
12
|
-
* `options.base` with SPA fallback enabled. No RPC server is started.
|
|
13
|
-
*
|
|
14
|
-
* - **bridge mode** (`devMiddleware: true | {…}`) — skips the static
|
|
15
|
-
* mount; the host app owns the SPA. Devframe serves discovery
|
|
16
|
-
* (`<base>__connection.json`), the WebSocket RPC upgrade
|
|
17
|
-
* (`<base>__ws`, shared on Vite's own HTTP server), and the optional
|
|
18
|
-
* MCP route through {@link initDevframe}'s node middleware, so the
|
|
19
|
-
* host-served SPA can discover the endpoint via {@link connectDevframe}.
|
|
20
|
-
*
|
|
21
|
-
* The bridge **gates by default** (devframe's interactive OTP unless the
|
|
22
|
-
* definition's `cli.auth` opts out), printing its code/link banner to stdout,
|
|
23
|
-
* so a bridged devframe isn't silently reachable by anything that can open
|
|
24
|
-
* its socket. Pass `options.auth: false` to opt out for a single-user
|
|
25
|
-
* localhost host, or a {@link DevframeAuthHandler} for a custom scheme.
|
|
26
|
-
*
|
|
27
|
-
* Use bridge mode when integrating with frameworks that own the SPA
|
|
28
|
-
* (Nuxt, Astro, SolidStart, plain Vite apps). For the all-in-one
|
|
29
|
-
* `dev` / `build` / `mcp` shell, reach for {@link createCac} instead.
|
|
30
|
-
*/
|
|
31
|
-
function viteDevBridge(d, options = {}) {
|
|
32
|
-
const base = normalizeMountBase(options.base ?? resolveBasePath(d, "hosted"));
|
|
33
|
-
if (!options.devMiddleware) {
|
|
34
|
-
const distDir = d.cli?.distDir;
|
|
35
|
-
return {
|
|
36
|
-
name: `devframe:${d.id}`,
|
|
37
|
-
apply: "serve",
|
|
38
|
-
configureServer(server) {
|
|
39
|
-
if (!distDir) return;
|
|
40
|
-
server.middlewares.use(base, serveStaticNodeMiddleware(resolve(distDir)));
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
const mw = options.devMiddleware === true ? {} : options.devMiddleware;
|
|
45
|
-
let instance;
|
|
46
|
-
return {
|
|
47
|
-
name: `devframe:${d.id}`,
|
|
48
|
-
apply: "serve",
|
|
49
|
-
async configureServer(server) {
|
|
50
|
-
await instance?.close().catch(() => {});
|
|
51
|
-
instance = void 0;
|
|
52
|
-
try {
|
|
53
|
-
const created = initDevframe(d, {
|
|
54
|
-
base,
|
|
55
|
-
distDir: false,
|
|
56
|
-
flags: mw.flags,
|
|
57
|
-
host: mw.host,
|
|
58
|
-
...mw.port != null ? { ws: { port: mw.port } } : server.httpServer ? { server: server.httpServer } : { ws: { sidecar: true } },
|
|
59
|
-
auth: options.auth,
|
|
60
|
-
mcp: options.mcp
|
|
61
|
-
});
|
|
62
|
-
server.middlewares.use(created.nodeMiddleware);
|
|
63
|
-
await created.ready;
|
|
64
|
-
instance = created;
|
|
65
|
-
} catch (e) {
|
|
66
|
-
diagnostics.DF0033({
|
|
67
|
-
id: d.id,
|
|
68
|
-
reason: String(e),
|
|
69
|
-
cause: e
|
|
70
|
-
}, { method: "warn" });
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
server.httpServer?.once("close", () => {
|
|
74
|
-
instance?.close().catch(() => {});
|
|
75
|
-
});
|
|
76
|
-
},
|
|
77
|
-
async closeBundle() {
|
|
78
|
-
await instance?.close().catch(() => {});
|
|
79
|
-
instance = void 0;
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Make `base` safe for `server.middlewares.use(path, …)`. Vite's connect
|
|
85
|
-
* router matches by absolute URL prefix, so relative spellings like
|
|
86
|
-
* `'./'` (commonly used for base-agnostic Nuxt builds) collapse to the
|
|
87
|
-
* origin root before the shared leading/trailing-slash normalization.
|
|
88
|
-
*/
|
|
89
|
-
function normalizeMountBase(base) {
|
|
90
|
-
return normalizeBasePath(base.replace(/^\.\/?/, "/"));
|
|
91
|
-
}
|
|
92
|
-
//#endregion
|
|
93
|
-
export { viteDevBridge };
|