devframe 0.6.2 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/build.d.mts +1 -1
- package/dist/adapters/cac.d.mts +41 -0
- package/dist/adapters/cac.mjs +2 -0
- package/dist/adapters/cli.d.mts +8 -31
- package/dist/adapters/cli.mjs +3 -143
- package/dist/adapters/dev.d.mts +3 -3
- package/dist/adapters/dev.mjs +1 -1
- package/dist/adapters/embedded.d.mts +1 -1
- package/dist/adapters/mcp.d.mts +1 -1
- package/dist/cac-DCBSjlzl.mjs +152 -0
- package/dist/client/index.d.mts +87 -2
- package/dist/client/index.mjs +143 -6
- package/dist/{context-DgkYTlXx.d.mts → context-BsiCAEC4.d.mts} +1 -1
- package/dist/{dev-DE51PeJc.mjs → dev-YeAm6GL0.mjs} +1 -1
- package/dist/{devframe-CpXy1ZlO.d.mts → devframe-Dma0XG3U.d.mts} +50 -3
- package/dist/helpers/vite.d.mts +2 -2
- package/dist/helpers/vite.mjs +2 -2
- package/dist/{index-DzeFcwMM.d.mts → index-d40ZLcYw.d.mts} +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/node/auth.d.mts +1 -1
- package/dist/node/hub-internals.d.mts +2 -2
- package/dist/node/index.d.mts +2 -2
- package/dist/recipes/interactive-auth.d.mts +2 -2
- package/dist/{server-C83NJvZp.d.mts → server-BD-tKDVf.d.mts} +2 -2
- package/dist/types/index.d.mts +2 -2
- 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/package.json +8 -3
- package/skills/devframe/SKILL.md +4 -4
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Dt as defineCliFlags, Et as InferCliFlags, Ot as parseCliFlags, Tt as CliFlagsSchema, r as DevframeDefinition } from "../devframe-Dma0XG3U.mjs";
|
|
2
|
+
import { CAC } from "cac";
|
|
3
|
+
import { H3 } from "h3";
|
|
4
|
+
|
|
5
|
+
//#region src/adapters/cac.d.ts
|
|
6
|
+
interface CreateCacOptions {
|
|
7
|
+
/** Default port for `dev` (default: 9999). */
|
|
8
|
+
defaultPort?: number;
|
|
9
|
+
/**
|
|
10
|
+
* Final CAC hook invoked after devframe's built-in subcommands and
|
|
11
|
+
* after the definition's `cli.configure`. Use this to add app-level
|
|
12
|
+
* flags and commands at the assembly stage.
|
|
13
|
+
*/
|
|
14
|
+
configureCli?: (cli: CAC) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Called once the dev server is listening. Use this to print a
|
|
17
|
+
* startup banner or trigger side-effects that depend on the live URL.
|
|
18
|
+
*/
|
|
19
|
+
onReady?: (info: {
|
|
20
|
+
origin: string;
|
|
21
|
+
port: number;
|
|
22
|
+
app: H3;
|
|
23
|
+
}) => void | Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
interface CacHandle {
|
|
26
|
+
/**
|
|
27
|
+
* Raw CAC instance. Mutate before calling `parse()` for last-mile
|
|
28
|
+
* flag or command additions that don't fit `configureCli`.
|
|
29
|
+
*/
|
|
30
|
+
cli: CAC;
|
|
31
|
+
parse: (argv?: string[]) => Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Wrap a {@link DevframeDefinition} in a `cac`-powered command-line
|
|
35
|
+
* interface exposing `dev` / `build` / `mcp` subcommands.
|
|
36
|
+
*
|
|
37
|
+
* Requires the optional `cac` peer dependency.
|
|
38
|
+
*/
|
|
39
|
+
declare function createCac(d: DevframeDefinition, options?: CreateCacOptions): CacHandle;
|
|
40
|
+
//#endregion
|
|
41
|
+
export { CacHandle, type CliFlagsSchema, CreateCacOptions, type InferCliFlags, createCac, defineCliFlags, parseCliFlags };
|
package/dist/adapters/cli.d.mts
CHANGED
|
@@ -1,35 +1,12 @@
|
|
|
1
|
-
import { Dt as
|
|
2
|
-
import {
|
|
3
|
-
import { H3 } from "h3";
|
|
1
|
+
import { Dt as defineCliFlags, Et as InferCliFlags, Ot as parseCliFlags, Tt as CliFlagsSchema } from "../devframe-Dma0XG3U.mjs";
|
|
2
|
+
import { CacHandle, CreateCacOptions, createCac } from "./cac.mjs";
|
|
4
3
|
|
|
5
4
|
//#region src/adapters/cli.d.ts
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* flags and commands at the assembly stage.
|
|
13
|
-
*/
|
|
14
|
-
configureCli?: (cli: CAC) => void;
|
|
15
|
-
/**
|
|
16
|
-
* Called once the dev server is listening. Use this to print a
|
|
17
|
-
* startup banner or trigger side-effects that depend on the live URL.
|
|
18
|
-
*/
|
|
19
|
-
onReady?: (info: {
|
|
20
|
-
origin: string;
|
|
21
|
-
port: number;
|
|
22
|
-
app: H3;
|
|
23
|
-
}) => void | Promise<void>;
|
|
24
|
-
}
|
|
25
|
-
interface CliHandle {
|
|
26
|
-
/**
|
|
27
|
-
* Raw CAC instance. Mutate before calling `parse()` for last-mile
|
|
28
|
-
* flag or command additions that don't fit `configureCli`.
|
|
29
|
-
*/
|
|
30
|
-
cli: CAC;
|
|
31
|
-
parse: (argv?: string[]) => Promise<void>;
|
|
32
|
-
}
|
|
33
|
-
declare function createCli(d: DevframeDefinition, options?: CreateCliOptions): CliHandle;
|
|
5
|
+
/** @deprecated Use `createCac` from `devframe/adapters/cac` instead. */
|
|
6
|
+
declare const createCli: typeof createCac;
|
|
7
|
+
/** @deprecated Use `CreateCacOptions` from `devframe/adapters/cac` instead. */
|
|
8
|
+
type CreateCliOptions = CreateCacOptions;
|
|
9
|
+
/** @deprecated Use `CacHandle` from `devframe/adapters/cac` instead. */
|
|
10
|
+
type CliHandle = CacHandle;
|
|
34
11
|
//#endregion
|
|
35
12
|
export { type CliFlagsSchema, CliHandle, CreateCliOptions, type InferCliFlags, createCli, defineCliFlags, parseCliFlags };
|
package/dist/adapters/cli.mjs
CHANGED
|
@@ -1,146 +1,6 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
import { createBuild } from "./build.mjs";
|
|
3
|
-
import { n as resolveDevServerPort, t as createDevServer } from "../dev-DE51PeJc.mjs";
|
|
4
|
-
import process from "node:process";
|
|
5
|
-
import cac from "cac";
|
|
6
|
-
import { safeParse } from "valibot";
|
|
7
|
-
//#region src/adapters/flags.ts
|
|
8
|
-
/**
|
|
9
|
-
* Identity helper that preserves the literal schema-map type — use this
|
|
10
|
-
* so `InferCliFlags<typeof myFlags>` resolves to the right object shape.
|
|
11
|
-
*
|
|
12
|
-
* ```ts
|
|
13
|
-
* const appFlags = defineCliFlags({
|
|
14
|
-
* depth: v.pipe(v.number(), v.integer()),
|
|
15
|
-
* config: v.optional(v.string()),
|
|
16
|
-
* })
|
|
17
|
-
*
|
|
18
|
-
* defineDevframe({
|
|
19
|
-
* cli: { flags: appFlags },
|
|
20
|
-
* setup(ctx, info) {
|
|
21
|
-
* const flags = info.flags as InferCliFlags<typeof appFlags>
|
|
22
|
-
* flags.depth // number
|
|
23
|
-
* flags.config // string | undefined
|
|
24
|
-
* },
|
|
25
|
-
* })
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
function defineCliFlags(flags) {
|
|
29
|
-
return flags;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Best-effort probe of a valibot schema to decide whether the
|
|
33
|
-
* corresponding CAC option takes a value. Unwraps `optional` / `nullable`
|
|
34
|
-
* / `nullish` / `default` / `pipe` wrappers then matches on the inner
|
|
35
|
-
* type's kind.
|
|
36
|
-
*/
|
|
37
|
-
function getSchemaKind(schema) {
|
|
38
|
-
let current = schema;
|
|
39
|
-
while (current) {
|
|
40
|
-
const kind = current.type;
|
|
41
|
-
if (kind === "optional" || kind === "nullable" || kind === "nullish" || kind === "undefined") {
|
|
42
|
-
current = current.wrapped ?? current.inner;
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
if (kind === "pipe" && Array.isArray(current.pipe) && current.pipe.length > 0) {
|
|
46
|
-
current = current.pipe[0];
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
return kind;
|
|
50
|
-
}
|
|
51
|
-
return "unknown";
|
|
52
|
-
}
|
|
53
|
-
/** Whether the CAC option for this schema should be a boolean flag. */
|
|
54
|
-
function isBooleanFlag(schema) {
|
|
55
|
-
return getSchemaKind(schema) === "boolean";
|
|
56
|
-
}
|
|
57
|
-
/** Validate and coerce the raw cac-parsed bag against a {@link CliFlagsSchema}. */
|
|
58
|
-
function parseCliFlags(schema, raw) {
|
|
59
|
-
const flags = {};
|
|
60
|
-
const issues = [];
|
|
61
|
-
for (const [key, fieldSchema] of Object.entries(schema)) {
|
|
62
|
-
const result = safeParse(fieldSchema, raw[key]);
|
|
63
|
-
if (result.success) flags[key] = result.output;
|
|
64
|
-
else issues.push(`--${toKebab(key)}: ${result.issues.map((i) => i.message).join(", ")}`);
|
|
65
|
-
}
|
|
66
|
-
for (const [key, value] of Object.entries(raw)) if (!(key in schema) && !(key in flags)) flags[key] = value;
|
|
67
|
-
return issues.length ? {
|
|
68
|
-
flags,
|
|
69
|
-
issues
|
|
70
|
-
} : { flags };
|
|
71
|
-
}
|
|
72
|
-
function toKebab(camel) {
|
|
73
|
-
return camel.replaceAll(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
74
|
-
}
|
|
75
|
-
/** Kebab-case a schema key for CAC option registration. */
|
|
76
|
-
function flagKeyToOption(camel) {
|
|
77
|
-
return toKebab(camel);
|
|
78
|
-
}
|
|
79
|
-
//#endregion
|
|
1
|
+
import { n as defineCliFlags, r as parseCliFlags, t as createCac } from "../cac-DCBSjlzl.mjs";
|
|
80
2
|
//#region src/adapters/cli.ts
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const defaultHost = d.cli?.host ?? "localhost";
|
|
84
|
-
const cli = cac(d.cli?.command ?? d.id);
|
|
85
|
-
const devCommand = cli.command("[...args]", "Start a local dev server").option("--port <port>", "Port to listen on").option("--host <host>", "Host to bind to", { default: defaultHost }).option("--open", "Open the browser on start").option("--no-open", "Do not open the browser").option("--mcp", "Expose an MCP server over HTTP at /__mcp (use --no-mcp to disable) [experimental]");
|
|
86
|
-
if (d.cli?.flags) for (const [key, schema] of Object.entries(d.cli.flags)) {
|
|
87
|
-
const optionName = flagKeyToOption(key);
|
|
88
|
-
const description = schema.description ?? "";
|
|
89
|
-
if (isBooleanFlag(schema)) devCommand.option(`--${optionName}`, description);
|
|
90
|
-
else devCommand.option(`--${optionName} <value>`, description);
|
|
91
|
-
}
|
|
92
|
-
devCommand.action(async (_args, rawFlags) => {
|
|
93
|
-
const flags = resolveTypedFlags(d, rawFlags);
|
|
94
|
-
const host = flags.host ?? defaultHost;
|
|
95
|
-
const port = flags.port ?? await resolveDevServerPort(d, {
|
|
96
|
-
host,
|
|
97
|
-
defaultPort
|
|
98
|
-
});
|
|
99
|
-
const mcp = flags.mcp;
|
|
100
|
-
await createDevServer(d, {
|
|
101
|
-
host,
|
|
102
|
-
port,
|
|
103
|
-
flags,
|
|
104
|
-
mcp,
|
|
105
|
-
onReady: options.onReady
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
cli.command("build", "Build a self-contained static deploy of the devframe").option("--out-dir <outDir>", "Output directory", { default: "dist-static" }).option("--base <base>", "URL base", { default: "/" }).option("--pretty", "Pretty-print dump JSON (larger on disk)").action(async (flags) => {
|
|
109
|
-
await createBuild(d, {
|
|
110
|
-
outDir: flags.outDir,
|
|
111
|
-
base: flags.base,
|
|
112
|
-
pretty: flags.pretty
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
cli.command("mcp", "Start an MCP server exposing agent-facing tools (stdio) [experimental]").action(async () => {
|
|
116
|
-
const { createMcpServer } = await import("./mcp.mjs");
|
|
117
|
-
await createMcpServer(d, {
|
|
118
|
-
transport: "stdio",
|
|
119
|
-
onReady: ({ transport }) => {
|
|
120
|
-
console.error(`[devframe] "${d.id}" MCP server ready (${transport})`);
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
d.cli?.configure?.(cli);
|
|
125
|
-
options.configureCli?.(cli);
|
|
126
|
-
cli.help();
|
|
127
|
-
cli.version("0.0.0");
|
|
128
|
-
return {
|
|
129
|
-
cli,
|
|
130
|
-
async parse(argv = process.argv) {
|
|
131
|
-
cli.parse(argv, { run: false });
|
|
132
|
-
await cli.runMatchedCommand();
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
function resolveTypedFlags(d, raw) {
|
|
137
|
-
if (!d.cli?.flags) return raw;
|
|
138
|
-
const { flags, issues } = parseCliFlags(d.cli.flags, raw);
|
|
139
|
-
if (issues?.length) {
|
|
140
|
-
for (const issue of issues) console.error(colors.red`[devframe] invalid flag — ${issue}`);
|
|
141
|
-
process.exit(1);
|
|
142
|
-
}
|
|
143
|
-
return flags;
|
|
144
|
-
}
|
|
3
|
+
/** @deprecated Use `createCac` from `devframe/adapters/cac` instead. */
|
|
4
|
+
const createCli = createCac;
|
|
145
5
|
//#endregion
|
|
146
6
|
export { createCli, defineCliFlags, parseCliFlags };
|
package/dist/adapters/dev.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as StartedServer } from "../server-
|
|
1
|
+
import { d as McpRouteOptions, r as DevframeDefinition, u as DevframeWsOptions } from "../devframe-Dma0XG3U.mjs";
|
|
2
|
+
import { n as StartedServer } from "../server-BD-tKDVf.mjs";
|
|
3
3
|
import { H3 } from "h3";
|
|
4
4
|
|
|
5
5
|
//#region src/adapters/dev.d.ts
|
|
@@ -98,7 +98,7 @@ declare function resolveDevServerPort(def: DevframeDefinition, options?: Resolve
|
|
|
98
98
|
*
|
|
99
99
|
* Use this directly when integrating devframe into an existing CLI
|
|
100
100
|
* framework (commander, yargs, hand-rolled CAC). For the all-in-one
|
|
101
|
-
* `dev` / `build` / `mcp` shell, reach for {@link
|
|
101
|
+
* `dev` / `build` / `mcp` shell, reach for {@link createCac} instead.
|
|
102
102
|
*/
|
|
103
103
|
declare function createDevServer(def: DevframeDefinition, options?: CreateDevServerOptions): Promise<StartedServer>;
|
|
104
104
|
//#endregion
|
package/dist/adapters/dev.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as resolveDevServerPort, t as createDevServer } from "../dev-
|
|
1
|
+
import { n as resolveDevServerPort, t as createDevServer } from "../dev-YeAm6GL0.mjs";
|
|
2
2
|
export { createDevServer, resolveDevServerPort };
|
package/dist/adapters/mcp.d.mts
CHANGED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { n as colors } from "./diagnostics-reporter-CsIG85Q5.mjs";
|
|
2
|
+
import { createBuild } from "./adapters/build.mjs";
|
|
3
|
+
import { n as resolveDevServerPort, t as createDevServer } from "./dev-YeAm6GL0.mjs";
|
|
4
|
+
import process from "node:process";
|
|
5
|
+
import cac from "cac";
|
|
6
|
+
import { safeParse } from "valibot";
|
|
7
|
+
//#region src/adapters/flags.ts
|
|
8
|
+
/**
|
|
9
|
+
* Identity helper that preserves the literal schema-map type — use this
|
|
10
|
+
* so `InferCliFlags<typeof myFlags>` resolves to the right object shape.
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* const appFlags = defineCliFlags({
|
|
14
|
+
* depth: v.pipe(v.number(), v.integer()),
|
|
15
|
+
* config: v.optional(v.string()),
|
|
16
|
+
* })
|
|
17
|
+
*
|
|
18
|
+
* defineDevframe({
|
|
19
|
+
* cli: { flags: appFlags },
|
|
20
|
+
* setup(ctx, info) {
|
|
21
|
+
* const flags = info.flags as InferCliFlags<typeof appFlags>
|
|
22
|
+
* flags.depth // number
|
|
23
|
+
* flags.config // string | undefined
|
|
24
|
+
* },
|
|
25
|
+
* })
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
function defineCliFlags(flags) {
|
|
29
|
+
return flags;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Best-effort probe of a valibot schema to decide whether the
|
|
33
|
+
* corresponding CAC option takes a value. Unwraps `optional` / `nullable`
|
|
34
|
+
* / `nullish` / `default` / `pipe` wrappers then matches on the inner
|
|
35
|
+
* type's kind.
|
|
36
|
+
*/
|
|
37
|
+
function getSchemaKind(schema) {
|
|
38
|
+
let current = schema;
|
|
39
|
+
while (current) {
|
|
40
|
+
const kind = current.type;
|
|
41
|
+
if (kind === "optional" || kind === "nullable" || kind === "nullish" || kind === "undefined") {
|
|
42
|
+
current = current.wrapped ?? current.inner;
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (kind === "pipe" && Array.isArray(current.pipe) && current.pipe.length > 0) {
|
|
46
|
+
current = current.pipe[0];
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
return kind;
|
|
50
|
+
}
|
|
51
|
+
return "unknown";
|
|
52
|
+
}
|
|
53
|
+
/** Whether the CAC option for this schema should be a boolean flag. */
|
|
54
|
+
function isBooleanFlag(schema) {
|
|
55
|
+
return getSchemaKind(schema) === "boolean";
|
|
56
|
+
}
|
|
57
|
+
/** Validate and coerce the raw cac-parsed bag against a {@link CliFlagsSchema}. */
|
|
58
|
+
function parseCliFlags(schema, raw) {
|
|
59
|
+
const flags = {};
|
|
60
|
+
const issues = [];
|
|
61
|
+
for (const [key, fieldSchema] of Object.entries(schema)) {
|
|
62
|
+
const result = safeParse(fieldSchema, raw[key]);
|
|
63
|
+
if (result.success) flags[key] = result.output;
|
|
64
|
+
else issues.push(`--${toKebab(key)}: ${result.issues.map((i) => i.message).join(", ")}`);
|
|
65
|
+
}
|
|
66
|
+
for (const [key, value] of Object.entries(raw)) if (!(key in schema) && !(key in flags)) flags[key] = value;
|
|
67
|
+
return issues.length ? {
|
|
68
|
+
flags,
|
|
69
|
+
issues
|
|
70
|
+
} : { flags };
|
|
71
|
+
}
|
|
72
|
+
function toKebab(camel) {
|
|
73
|
+
return camel.replaceAll(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
74
|
+
}
|
|
75
|
+
/** Kebab-case a schema key for CAC option registration. */
|
|
76
|
+
function flagKeyToOption(camel) {
|
|
77
|
+
return toKebab(camel);
|
|
78
|
+
}
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/adapters/cac.ts
|
|
81
|
+
/**
|
|
82
|
+
* Wrap a {@link DevframeDefinition} in a `cac`-powered command-line
|
|
83
|
+
* interface exposing `dev` / `build` / `mcp` subcommands.
|
|
84
|
+
*
|
|
85
|
+
* Requires the optional `cac` peer dependency.
|
|
86
|
+
*/
|
|
87
|
+
function createCac(d, options = {}) {
|
|
88
|
+
const defaultPort = options.defaultPort ?? d.cli?.port ?? 9999;
|
|
89
|
+
const defaultHost = d.cli?.host ?? "localhost";
|
|
90
|
+
const cli = cac(d.cli?.command ?? d.id);
|
|
91
|
+
const devCommand = cli.command("[...args]", "Start a local dev server").option("--port <port>", "Port to listen on").option("--host <host>", "Host to bind to", { default: defaultHost }).option("--open", "Open the browser on start").option("--no-open", "Do not open the browser").option("--mcp", "Expose an MCP server over HTTP at /__mcp (use --no-mcp to disable) [experimental]");
|
|
92
|
+
if (d.cli?.flags) for (const [key, schema] of Object.entries(d.cli.flags)) {
|
|
93
|
+
const optionName = flagKeyToOption(key);
|
|
94
|
+
const description = schema.description ?? "";
|
|
95
|
+
if (isBooleanFlag(schema)) devCommand.option(`--${optionName}`, description);
|
|
96
|
+
else devCommand.option(`--${optionName} <value>`, description);
|
|
97
|
+
}
|
|
98
|
+
devCommand.action(async (_args, rawFlags) => {
|
|
99
|
+
const flags = resolveTypedFlags(d, rawFlags);
|
|
100
|
+
const host = flags.host ?? defaultHost;
|
|
101
|
+
const port = flags.port ?? await resolveDevServerPort(d, {
|
|
102
|
+
host,
|
|
103
|
+
defaultPort
|
|
104
|
+
});
|
|
105
|
+
const mcp = flags.mcp;
|
|
106
|
+
await createDevServer(d, {
|
|
107
|
+
host,
|
|
108
|
+
port,
|
|
109
|
+
flags,
|
|
110
|
+
mcp,
|
|
111
|
+
onReady: options.onReady
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
cli.command("build", "Build a self-contained static deploy of the devframe").option("--out-dir <outDir>", "Output directory", { default: "dist-static" }).option("--base <base>", "URL base", { default: "/" }).option("--pretty", "Pretty-print dump JSON (larger on disk)").action(async (flags) => {
|
|
115
|
+
await createBuild(d, {
|
|
116
|
+
outDir: flags.outDir,
|
|
117
|
+
base: flags.base,
|
|
118
|
+
pretty: flags.pretty
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
cli.command("mcp", "Start an MCP server exposing agent-facing tools (stdio) [experimental]").action(async () => {
|
|
122
|
+
const { createMcpServer } = await import("./adapters/mcp.mjs");
|
|
123
|
+
await createMcpServer(d, {
|
|
124
|
+
transport: "stdio",
|
|
125
|
+
onReady: ({ transport }) => {
|
|
126
|
+
console.error(`[devframe] "${d.id}" MCP server ready (${transport})`);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
d.cli?.configure?.(cli);
|
|
131
|
+
options.configureCli?.(cli);
|
|
132
|
+
cli.help();
|
|
133
|
+
cli.version("0.0.0");
|
|
134
|
+
return {
|
|
135
|
+
cli,
|
|
136
|
+
async parse(argv = process.argv) {
|
|
137
|
+
cli.parse(argv, { run: false });
|
|
138
|
+
await cli.runMatchedCommand();
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function resolveTypedFlags(d, raw) {
|
|
143
|
+
if (!d.cli?.flags) return raw;
|
|
144
|
+
const { flags, issues } = parseCliFlags(d.cli.flags, raw);
|
|
145
|
+
if (issues?.length) {
|
|
146
|
+
for (const issue of issues) console.error(colors.red`[devframe] invalid flag — ${issue}`);
|
|
147
|
+
process.exit(1);
|
|
148
|
+
}
|
|
149
|
+
return flags;
|
|
150
|
+
}
|
|
151
|
+
//#endregion
|
|
152
|
+
export { defineCliFlags as n, parseCliFlags as r, createCac as t };
|
package/dist/client/index.d.mts
CHANGED
|
@@ -1,9 +1,58 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as StreamSink, St as EventEmitter, X as DevframeSettings, at as DevframeRpcClientFunctions, b as RpcSharedStateGetOptions, k as StreamReader, nt as ScopedSharedStates, ot as DevframeRpcServerFunctions, p as ConnectionMeta, rt as SettingsForNamespace, tt as ScopedServerFunctions, x as RpcSharedStateHost, z as SharedState } from "../devframe-Dma0XG3U.mjs";
|
|
2
2
|
import { _ as RpcFunctionDefinition, w as RpcFunctionsCollector } from "../types-oEqKqUC9.mjs";
|
|
3
3
|
import { C as RpcCacheManager, w as RpcCacheOptions } from "../index-DI_TMGjv.mjs";
|
|
4
4
|
import { t as WsRpcChannelOptions } from "../ws-client-nBjpin71.mjs";
|
|
5
5
|
import { BirpcOptions, BirpcReturn } from "birpc";
|
|
6
6
|
|
|
7
|
+
//#region src/client/connection.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* The connection lifecycle of a devframe client, as a single value a UI can
|
|
10
|
+
* render from. Derived from the transport (WebSocket open/close/error) and the
|
|
11
|
+
* trust handshake, so a viewer never has to reason about the two dimensions
|
|
12
|
+
* separately.
|
|
13
|
+
*
|
|
14
|
+
* - `connecting` — establishing the WebSocket / running the initial trust
|
|
15
|
+
* handshake. Calls issued here queue until the socket opens.
|
|
16
|
+
* - `connected` — socket open and trusted; RPC calls will be served.
|
|
17
|
+
* - `unauthorized` — socket open but the server rejected trust (no valid token,
|
|
18
|
+
* or an auth-enforcing host refused it). Calls fail fast with an auth error;
|
|
19
|
+
* the UI should prompt for re-authentication or a reload.
|
|
20
|
+
* - `disconnected` — the socket closed (dropped mid-session, or never opened).
|
|
21
|
+
* Pending and new calls fail fast until the page reconnects.
|
|
22
|
+
* - `error` — a fatal connection error (e.g. the WebSocket errored, or the
|
|
23
|
+
* connection meta could not be loaded).
|
|
24
|
+
*
|
|
25
|
+
* A `static` backend has no live socket, so it reports `connected` for its
|
|
26
|
+
* whole life.
|
|
27
|
+
*/
|
|
28
|
+
type DevframeConnectionStatus = 'connecting' | 'connected' | 'unauthorized' | 'disconnected' | 'error';
|
|
29
|
+
/**
|
|
30
|
+
* What kind of failure a {@link DevframeConnectionError} describes:
|
|
31
|
+
* - `connection` — the transport dropped, errored, or never opened.
|
|
32
|
+
* - `auth` — the server rejected trust for this client.
|
|
33
|
+
* - `timeout` — a call exceeded its {@link DevframeRpcClientOptions.callTimeout}.
|
|
34
|
+
*/
|
|
35
|
+
type DevframeConnectionErrorKind = 'connection' | 'auth' | 'timeout';
|
|
36
|
+
/**
|
|
37
|
+
* The error rejected from `rpc.call(...)` (and carried on
|
|
38
|
+
* `rpc.connectionError`) when a call cannot be served because the connection is
|
|
39
|
+
* down, the client is unauthorized, or a call timed out. Its `kind` lets a UI
|
|
40
|
+
* tailor its message and recovery affordance without string-matching.
|
|
41
|
+
*/
|
|
42
|
+
declare class DevframeConnectionError extends Error {
|
|
43
|
+
name: string;
|
|
44
|
+
readonly kind: DevframeConnectionErrorKind;
|
|
45
|
+
constructor(kind: DevframeConnectionErrorKind, message: string, options?: {
|
|
46
|
+
cause?: unknown;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Whether a status means calls can be attempted. `connecting` counts because
|
|
51
|
+
* the transport queues outgoing calls until the socket opens; the terminal
|
|
52
|
+
* failure states short-circuit calls so a stuck socket never hangs the UI.
|
|
53
|
+
*/
|
|
54
|
+
declare function isCallableStatus(status: DevframeConnectionStatus): boolean;
|
|
55
|
+
//#endregion
|
|
7
56
|
//#region src/client/rpc-streaming.d.ts
|
|
8
57
|
interface StreamingSubscribeOptions {
|
|
9
58
|
/** Maximum buffered chunks before the oldest is dropped. Default 256. */
|
|
@@ -119,6 +168,21 @@ interface DevframeRpcContext {
|
|
|
119
168
|
type DevframeClientRpcHost = RpcFunctionsCollector<DevframeRpcClientFunctions, DevframeRpcContext>;
|
|
120
169
|
interface RpcClientEvents {
|
|
121
170
|
'rpc:is-trusted:updated': (isTrusted: boolean) => void;
|
|
171
|
+
/**
|
|
172
|
+
* The connection status changed. Carries the new status and the previous one
|
|
173
|
+
* so a UI can react to specific transitions (e.g. `connected` → `disconnected`).
|
|
174
|
+
*/
|
|
175
|
+
'connection:status': (status: DevframeConnectionStatus, previous: DevframeConnectionStatus) => void;
|
|
176
|
+
/**
|
|
177
|
+
* A connection-level error occurred (the WebSocket errored, or trust was
|
|
178
|
+
* refused). The status typically moves to `error`/`unauthorized` alongside it.
|
|
179
|
+
*/
|
|
180
|
+
'connection:error': (error: Error) => void;
|
|
181
|
+
/**
|
|
182
|
+
* An RPC call rejected — either from the server, or because the connection
|
|
183
|
+
* was down / timed out. Useful for a global error feed or toast surface.
|
|
184
|
+
*/
|
|
185
|
+
'rpc:error': (error: Error, method: string) => void;
|
|
122
186
|
}
|
|
123
187
|
interface DevframeRpcClientOptions {
|
|
124
188
|
connectionMeta?: ConnectionMeta;
|
|
@@ -138,6 +202,14 @@ interface DevframeRpcClientOptions {
|
|
|
138
202
|
wsOptions?: Partial<WsRpcChannelOptions>;
|
|
139
203
|
rpcOptions?: Partial<BirpcOptions<DevframeRpcServerFunctions, DevframeRpcClientFunctions, boolean>>;
|
|
140
204
|
cacheOptions?: boolean | Partial<RpcCacheOptions>;
|
|
205
|
+
/**
|
|
206
|
+
* Reject a pending `rpc.call(...)` if the server hasn't answered within this
|
|
207
|
+
* many milliseconds, with a {@link DevframeConnectionError} of kind
|
|
208
|
+
* `'timeout'`. Guards against a live-but-unresponsive server hanging the UI.
|
|
209
|
+
* Omit (or `0`) to wait indefinitely. Calls always fail fast — regardless of
|
|
210
|
+
* this option — once the socket closes or trust is refused.
|
|
211
|
+
*/
|
|
212
|
+
callTimeout?: number;
|
|
141
213
|
}
|
|
142
214
|
type DevframeRpcClientCall = BirpcReturn<DevframeRpcServerFunctions, DevframeRpcClientFunctions>['$call'];
|
|
143
215
|
type DevframeRpcClientCallEvent = BirpcReturn<DevframeRpcServerFunctions, DevframeRpcClientFunctions>['$callEvent'];
|
|
@@ -151,6 +223,17 @@ interface DevframeRpcClient {
|
|
|
151
223
|
* Whether the client is trusted
|
|
152
224
|
*/
|
|
153
225
|
readonly isTrusted: boolean | null;
|
|
226
|
+
/**
|
|
227
|
+
* The current connection status. Drives connection/auth/error UI without the
|
|
228
|
+
* consumer having to track the transport and trust handshake separately.
|
|
229
|
+
* Subscribe to `events.on('connection:status', …)` to react to changes.
|
|
230
|
+
*/
|
|
231
|
+
readonly status: DevframeConnectionStatus;
|
|
232
|
+
/**
|
|
233
|
+
* The most recent connection-level error (WebSocket error, refused trust, or
|
|
234
|
+
* failed connection-meta load), or `null` when the connection is healthy.
|
|
235
|
+
*/
|
|
236
|
+
readonly connectionError: Error | null;
|
|
154
237
|
/**
|
|
155
238
|
* The connection meta
|
|
156
239
|
*/
|
|
@@ -225,6 +308,8 @@ interface DevframeRpcClient {
|
|
|
225
308
|
}
|
|
226
309
|
interface DevframeRpcClientMode {
|
|
227
310
|
readonly isTrusted: boolean;
|
|
311
|
+
readonly status: DevframeConnectionStatus;
|
|
312
|
+
readonly connectionError: Error | null;
|
|
228
313
|
ensureTrusted: DevframeRpcClient['ensureTrusted'];
|
|
229
314
|
requestTrust: DevframeRpcClient['requestTrust'];
|
|
230
315
|
requestTrustWithToken: DevframeRpcClient['requestTrustWithToken'];
|
|
@@ -276,4 +361,4 @@ declare function createClientSettings<T extends Record<string, any> = Record<str
|
|
|
276
361
|
//#region src/client/index.d.ts
|
|
277
362
|
declare const connectDevframe: typeof getDevframeRpcClient;
|
|
278
363
|
//#endregion
|
|
279
|
-
export { DevframeClientRpcHost, DevframeRpcClient, DevframeRpcClientCall, DevframeRpcClientCallEvent, DevframeRpcClientCallOptional, DevframeRpcClientMode, DevframeRpcClientOptions, DevframeRpcContext, DevframeScopedClientContext, DevframeScopedClientRpc, DevframeScopedClientStreamingHost, RpcClientEvents, RpcStreamingClientHost, StreamingSubscribeOptions, authenticateWithUrlOtp, connectDevframe, consumeOtpFromUrl, createClientSettings, createRpcStreamingClientHost, createScopedClientContext, getDevframeRpcClient, readOtpFromUrl };
|
|
364
|
+
export { DevframeClientRpcHost, DevframeConnectionError, DevframeConnectionErrorKind, DevframeConnectionStatus, DevframeRpcClient, DevframeRpcClientCall, DevframeRpcClientCallEvent, DevframeRpcClientCallOptional, DevframeRpcClientMode, DevframeRpcClientOptions, DevframeRpcContext, DevframeScopedClientContext, DevframeScopedClientRpc, DevframeScopedClientStreamingHost, RpcClientEvents, RpcStreamingClientHost, StreamingSubscribeOptions, authenticateWithUrlOtp, connectDevframe, consumeOtpFromUrl, createClientSettings, createRpcStreamingClientHost, createScopedClientContext, getDevframeRpcClient, isCallableStatus, readOtpFromUrl };
|
package/dist/client/index.mjs
CHANGED
|
@@ -505,6 +505,8 @@ async function createStaticRpcClientMode(options) {
|
|
|
505
505
|
const staticCaller = createStaticRpcCaller(await options.fetchJsonFromBases(DEVFRAME_RPC_DUMP_MANIFEST_FILENAME), options.fetchJsonFromBases);
|
|
506
506
|
return {
|
|
507
507
|
isTrusted: true,
|
|
508
|
+
status: "connected",
|
|
509
|
+
connectionError: null,
|
|
508
510
|
requestTrust: async () => true,
|
|
509
511
|
requestTrustWithToken: async () => true,
|
|
510
512
|
requestTrustWithCode: async () => null,
|
|
@@ -1857,6 +1859,30 @@ function parseUA(uastringOrExtensions, extensions) {
|
|
|
1857
1859
|
};
|
|
1858
1860
|
}
|
|
1859
1861
|
//#endregion
|
|
1862
|
+
//#region src/client/connection.ts
|
|
1863
|
+
/**
|
|
1864
|
+
* The error rejected from `rpc.call(...)` (and carried on
|
|
1865
|
+
* `rpc.connectionError`) when a call cannot be served because the connection is
|
|
1866
|
+
* down, the client is unauthorized, or a call timed out. Its `kind` lets a UI
|
|
1867
|
+
* tailor its message and recovery affordance without string-matching.
|
|
1868
|
+
*/
|
|
1869
|
+
var DevframeConnectionError = class extends Error {
|
|
1870
|
+
name = "DevframeConnectionError";
|
|
1871
|
+
kind;
|
|
1872
|
+
constructor(kind, message, options) {
|
|
1873
|
+
super(message, options);
|
|
1874
|
+
this.kind = kind;
|
|
1875
|
+
}
|
|
1876
|
+
};
|
|
1877
|
+
/**
|
|
1878
|
+
* Whether a status means calls can be attempted. `connecting` counts because
|
|
1879
|
+
* the transport queues outgoing calls until the socket opens; the terminal
|
|
1880
|
+
* failure states short-circuit calls so a stuck socket never hangs the UI.
|
|
1881
|
+
*/
|
|
1882
|
+
function isCallableStatus(status) {
|
|
1883
|
+
return status === "connected" || status === "connecting";
|
|
1884
|
+
}
|
|
1885
|
+
//#endregion
|
|
1860
1886
|
//#region src/client/rpc-ws.ts
|
|
1861
1887
|
/**
|
|
1862
1888
|
* Resolve a {@link ConnectionMeta.websocket} descriptor into a concrete
|
|
@@ -1899,10 +1925,65 @@ function resolveWsUrl(websocket, metaBaseUrl, loc) {
|
|
|
1899
1925
|
return target.href;
|
|
1900
1926
|
}
|
|
1901
1927
|
function createWsRpcClientMode(options) {
|
|
1902
|
-
const { authToken, connectionMeta, metaBaseUrl, events, clientRpc, rpcOptions = {}, wsOptions = {} } = options;
|
|
1928
|
+
const { authToken, connectionMeta, metaBaseUrl, events, clientRpc, rpcOptions = {}, wsOptions = {}, callTimeout = 0 } = options;
|
|
1903
1929
|
let isTrusted = false;
|
|
1930
|
+
let status = "connecting";
|
|
1931
|
+
let connectionError = null;
|
|
1904
1932
|
const trustedPromise = promiseWithResolver();
|
|
1905
1933
|
const url = resolveWsUrl(connectionMeta.websocket, metaBaseUrl ?? "./", location);
|
|
1934
|
+
function setStatus(next, error = null) {
|
|
1935
|
+
if (error) connectionError = error;
|
|
1936
|
+
else if (next === "connected") connectionError = null;
|
|
1937
|
+
if (next === status) return;
|
|
1938
|
+
const previous = status;
|
|
1939
|
+
status = next;
|
|
1940
|
+
events.emit("connection:status", next, previous);
|
|
1941
|
+
}
|
|
1942
|
+
const pending = /* @__PURE__ */ new Set();
|
|
1943
|
+
function rejectAllPending(error) {
|
|
1944
|
+
for (const entry of [...pending]) entry.reject(error);
|
|
1945
|
+
}
|
|
1946
|
+
function terminalError() {
|
|
1947
|
+
if (status === "disconnected" || status === "error") return new DevframeConnectionError("connection", "[devframe] Not connected to the devframe server", { cause: connectionError ?? void 0 });
|
|
1948
|
+
if (status === "unauthorized") return new DevframeConnectionError("auth", "[devframe] Not authorized by the devframe server", { cause: connectionError ?? void 0 });
|
|
1949
|
+
return null;
|
|
1950
|
+
}
|
|
1951
|
+
/**
|
|
1952
|
+
* Wrap an in-flight call promise so it settles on server response, on an
|
|
1953
|
+
* optional wall-clock timeout, or when the connection drops — never hangs.
|
|
1954
|
+
*/
|
|
1955
|
+
function guardCall(promise, method) {
|
|
1956
|
+
return new Promise((resolve, reject) => {
|
|
1957
|
+
let settled = false;
|
|
1958
|
+
let timer;
|
|
1959
|
+
const entry = { reject(error) {
|
|
1960
|
+
if (settled) return;
|
|
1961
|
+
finish();
|
|
1962
|
+
events.emit("rpc:error", error, method);
|
|
1963
|
+
reject(error);
|
|
1964
|
+
} };
|
|
1965
|
+
function finish() {
|
|
1966
|
+
settled = true;
|
|
1967
|
+
pending.delete(entry);
|
|
1968
|
+
if (timer) clearTimeout(timer);
|
|
1969
|
+
}
|
|
1970
|
+
pending.add(entry);
|
|
1971
|
+
if (callTimeout > 0) timer = setTimeout(() => {
|
|
1972
|
+
entry.reject(new DevframeConnectionError("timeout", `[devframe] RPC call "${method}" timed out after ${callTimeout}ms`));
|
|
1973
|
+
}, callTimeout);
|
|
1974
|
+
promise.then((value) => {
|
|
1975
|
+
if (settled) return;
|
|
1976
|
+
finish();
|
|
1977
|
+
resolve(value);
|
|
1978
|
+
}, (error) => {
|
|
1979
|
+
if (settled) return;
|
|
1980
|
+
finish();
|
|
1981
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
1982
|
+
events.emit("rpc:error", err, method);
|
|
1983
|
+
reject(err);
|
|
1984
|
+
});
|
|
1985
|
+
});
|
|
1986
|
+
}
|
|
1906
1987
|
const definitions = /* @__PURE__ */ new Map();
|
|
1907
1988
|
for (const name of connectionMeta.jsonSerializableMethods ?? []) definitions.set(name, { jsonSerializable: true });
|
|
1908
1989
|
const serverRpc = createRpcClient(clientRpc.functions, {
|
|
@@ -1910,7 +1991,21 @@ function createWsRpcClientMode(options) {
|
|
|
1910
1991
|
url,
|
|
1911
1992
|
authToken,
|
|
1912
1993
|
definitions,
|
|
1913
|
-
...wsOptions
|
|
1994
|
+
...wsOptions,
|
|
1995
|
+
onConnected(event) {
|
|
1996
|
+
wsOptions.onConnected?.(event);
|
|
1997
|
+
},
|
|
1998
|
+
onError(error) {
|
|
1999
|
+
setStatus("error", error);
|
|
2000
|
+
events.emit("connection:error", error);
|
|
2001
|
+
rejectAllPending(new DevframeConnectionError("connection", "[devframe] Connection to the devframe server failed", { cause: error }));
|
|
2002
|
+
wsOptions.onError?.(error);
|
|
2003
|
+
},
|
|
2004
|
+
onDisconnected(event) {
|
|
2005
|
+
if (status !== "error") setStatus("disconnected");
|
|
2006
|
+
rejectAllPending(new DevframeConnectionError("connection", "[devframe] Disconnected from the devframe server", { cause: connectionError ?? void 0 }));
|
|
2007
|
+
wsOptions.onDisconnected?.(event);
|
|
2008
|
+
}
|
|
1914
2009
|
}),
|
|
1915
2010
|
rpcOptions
|
|
1916
2011
|
});
|
|
@@ -1919,6 +2014,10 @@ function createWsRpcClientMode(options) {
|
|
|
1919
2014
|
type: "event",
|
|
1920
2015
|
handler: () => {
|
|
1921
2016
|
isTrusted = false;
|
|
2017
|
+
const authError = new DevframeConnectionError("auth", "[devframe] The devframe server revoked this client's trust");
|
|
2018
|
+
setStatus("unauthorized", authError);
|
|
2019
|
+
events.emit("connection:error", authError);
|
|
2020
|
+
rejectAllPending(authError);
|
|
1922
2021
|
events.emit("rpc:is-trusted:updated", false);
|
|
1923
2022
|
}
|
|
1924
2023
|
});
|
|
@@ -1942,7 +2041,14 @@ function createWsRpcClientMode(options) {
|
|
|
1942
2041
|
origin: location.origin
|
|
1943
2042
|
});
|
|
1944
2043
|
isTrusted = result.isTrusted;
|
|
1945
|
-
if (isTrusted)
|
|
2044
|
+
if (isTrusted) {
|
|
2045
|
+
trustedPromise.resolve(true);
|
|
2046
|
+
setStatus("connected");
|
|
2047
|
+
} else {
|
|
2048
|
+
const authError = new DevframeConnectionError("auth", "[devframe] The devframe server refused this client's credentials");
|
|
2049
|
+
setStatus("unauthorized", authError);
|
|
2050
|
+
events.emit("connection:error", authError);
|
|
2051
|
+
}
|
|
1946
2052
|
events.emit("rpc:is-trusted:updated", isTrusted);
|
|
1947
2053
|
return result.isTrusted;
|
|
1948
2054
|
}
|
|
@@ -1956,6 +2062,7 @@ function createWsRpcClientMode(options) {
|
|
|
1956
2062
|
currentAuthToken = token;
|
|
1957
2063
|
isTrusted = true;
|
|
1958
2064
|
trustedPromise.resolve(true);
|
|
2065
|
+
setStatus("connected");
|
|
1959
2066
|
events.emit("rpc:is-trusted:updated", true);
|
|
1960
2067
|
}
|
|
1961
2068
|
return token;
|
|
@@ -1980,18 +2087,41 @@ function createWsRpcClientMode(options) {
|
|
|
1980
2087
|
get isTrusted() {
|
|
1981
2088
|
return isTrusted;
|
|
1982
2089
|
},
|
|
2090
|
+
get status() {
|
|
2091
|
+
return status;
|
|
2092
|
+
},
|
|
2093
|
+
get connectionError() {
|
|
2094
|
+
return connectionError;
|
|
2095
|
+
},
|
|
1983
2096
|
requestTrust,
|
|
1984
2097
|
requestTrustWithToken,
|
|
1985
2098
|
requestTrustWithCode,
|
|
1986
2099
|
ensureTrusted,
|
|
1987
2100
|
call: (...args) => {
|
|
1988
|
-
|
|
2101
|
+
const method = String(args[0]);
|
|
2102
|
+
const failFast = terminalError();
|
|
2103
|
+
if (failFast) {
|
|
2104
|
+
events.emit("rpc:error", failFast, method);
|
|
2105
|
+
return Promise.reject(failFast);
|
|
2106
|
+
}
|
|
2107
|
+
return guardCall(serverRpc.$call(...args), method);
|
|
1989
2108
|
},
|
|
1990
2109
|
callEvent: (...args) => {
|
|
2110
|
+
const failFast = terminalError();
|
|
2111
|
+
if (failFast) {
|
|
2112
|
+
events.emit("rpc:error", failFast, String(args[0]));
|
|
2113
|
+
return;
|
|
2114
|
+
}
|
|
1991
2115
|
return serverRpc.$callEvent(...args);
|
|
1992
2116
|
},
|
|
1993
2117
|
callOptional: (...args) => {
|
|
1994
|
-
|
|
2118
|
+
const method = String(args[0]);
|
|
2119
|
+
const failFast = terminalError();
|
|
2120
|
+
if (failFast) {
|
|
2121
|
+
events.emit("rpc:error", failFast, method);
|
|
2122
|
+
return Promise.reject(failFast);
|
|
2123
|
+
}
|
|
2124
|
+
return guardCall(serverRpc.$callOptional(...args), method);
|
|
1995
2125
|
}
|
|
1996
2126
|
};
|
|
1997
2127
|
}
|
|
@@ -2156,6 +2286,7 @@ async function getDevframeRpcClient(options = {}) {
|
|
|
2156
2286
|
metaBaseUrl: resolveMetaBaseUrl(),
|
|
2157
2287
|
events,
|
|
2158
2288
|
clientRpc,
|
|
2289
|
+
callTimeout: options.callTimeout,
|
|
2159
2290
|
rpcOptions: {
|
|
2160
2291
|
...rpcOptions,
|
|
2161
2292
|
async onRequest(req, next, resolve) {
|
|
@@ -2178,6 +2309,12 @@ async function getDevframeRpcClient(options = {}) {
|
|
|
2178
2309
|
get isTrusted() {
|
|
2179
2310
|
return mode.isTrusted;
|
|
2180
2311
|
},
|
|
2312
|
+
get status() {
|
|
2313
|
+
return mode.status;
|
|
2314
|
+
},
|
|
2315
|
+
get connectionError() {
|
|
2316
|
+
return mode.connectionError;
|
|
2317
|
+
},
|
|
2181
2318
|
connectionMeta,
|
|
2182
2319
|
ensureTrusted: mode.ensureTrusted,
|
|
2183
2320
|
requestTrust: mode.requestTrust,
|
|
@@ -2231,4 +2368,4 @@ async function getDevframeRpcClient(options = {}) {
|
|
|
2231
2368
|
//#region src/client/index.ts
|
|
2232
2369
|
const connectDevframe = getDevframeRpcClient;
|
|
2233
2370
|
//#endregion
|
|
2234
|
-
export { authenticateWithUrlOtp, connectDevframe, consumeOtpFromUrl, createClientSettings, createRpcStreamingClientHost, createScopedClientContext, getDevframeRpcClient, readOtpFromUrl };
|
|
2371
|
+
export { DevframeConnectionError, authenticateWithUrlOtp, connectDevframe, consumeOtpFromUrl, createClientSettings, createRpcStreamingClientHost, createScopedClientContext, getDevframeRpcClient, isCallableStatus, readOtpFromUrl };
|
|
@@ -262,7 +262,7 @@ async function resolveDevServerPort(def, options = {}) {
|
|
|
262
262
|
*
|
|
263
263
|
* Use this directly when integrating devframe into an existing CLI
|
|
264
264
|
* framework (commander, yargs, hand-rolled CAC). For the all-in-one
|
|
265
|
-
* `dev` / `build` / `mcp` shell, reach for {@link
|
|
265
|
+
* `dev` / `build` / `mcp` shell, reach for {@link createCac} instead.
|
|
266
266
|
*/
|
|
267
267
|
async function createDevServer(def, options = {}) {
|
|
268
268
|
const distDir = options.distDir ?? def.cli?.distDir;
|
|
@@ -1378,7 +1378,7 @@ interface DevframeCliOptions {
|
|
|
1378
1378
|
/**
|
|
1379
1379
|
* Capability-side CAC hook. Called with the CAC instance after the
|
|
1380
1380
|
* adapter registers its built-in commands (`build` / `spa` / `mcp`)
|
|
1381
|
-
* but before `
|
|
1381
|
+
* but before `createCac`'s own `configureCli` caller. Use this to
|
|
1382
1382
|
* contribute tool-specific flags and subcommands from the definition
|
|
1383
1383
|
* itself.
|
|
1384
1384
|
*/
|
|
@@ -1409,6 +1409,44 @@ interface DevframeCliOptions {
|
|
|
1409
1409
|
*/
|
|
1410
1410
|
flags?: CliFlagsSchema;
|
|
1411
1411
|
}
|
|
1412
|
+
/**
|
|
1413
|
+
* Default dock attributes for the iframe entry a hub synthesizes when it
|
|
1414
|
+
* mounts this devframe. Framework-neutral metadata only — the hub layer
|
|
1415
|
+
* (`mountDevframe`) merges these beneath its per-mount `dock` overrides,
|
|
1416
|
+
* which in turn sit beneath the locked, derived `id` / `type` / `url`.
|
|
1417
|
+
*
|
|
1418
|
+
* Every field is optional. `title` / `icon` default to the definition's
|
|
1419
|
+
* `name` / `icon` when omitted here; the rest are unset by default.
|
|
1420
|
+
* Standalone adapters (`cli` / `spa` / `build`) ignore this entirely.
|
|
1421
|
+
*/
|
|
1422
|
+
interface DevframeDockDefaults {
|
|
1423
|
+
/** Dock entry title. Defaults to the definition's `name`. */
|
|
1424
|
+
title?: string;
|
|
1425
|
+
/** Dock entry icon. Defaults to the definition's `icon`. */
|
|
1426
|
+
icon?: string | {
|
|
1427
|
+
light: string;
|
|
1428
|
+
dark: string;
|
|
1429
|
+
};
|
|
1430
|
+
/**
|
|
1431
|
+
* Sort weight within the dock; higher sorts earlier.
|
|
1432
|
+
* @default 0
|
|
1433
|
+
*/
|
|
1434
|
+
defaultOrder?: number;
|
|
1435
|
+
/**
|
|
1436
|
+
* Category the entry groups under in the dock.
|
|
1437
|
+
* @default 'default'
|
|
1438
|
+
*/
|
|
1439
|
+
category?: string;
|
|
1440
|
+
/**
|
|
1441
|
+
* Conditional-visibility expression (same syntax as command `when`
|
|
1442
|
+
* clauses). Set to `'false'` to hide the entry unconditionally.
|
|
1443
|
+
*/
|
|
1444
|
+
when?: string;
|
|
1445
|
+
/** Badge text rendered on the dock icon (e.g. an unread count). */
|
|
1446
|
+
badge?: string;
|
|
1447
|
+
/** Id of the dock group this entry collapses under, if any. */
|
|
1448
|
+
groupId?: string;
|
|
1449
|
+
}
|
|
1412
1450
|
interface DevframeSpaOptions {
|
|
1413
1451
|
base?: string;
|
|
1414
1452
|
/**
|
|
@@ -1428,7 +1466,7 @@ interface DevframeBrowserContext {
|
|
|
1428
1466
|
/**
|
|
1429
1467
|
* Runtime information threaded into `setup(ctx, info)`. Adapters
|
|
1430
1468
|
* populate the fields that make sense for their deployment. In
|
|
1431
|
-
* particular, `
|
|
1469
|
+
* particular, `createCac` fills `flags` with the parsed CAC bag.
|
|
1432
1470
|
*/
|
|
1433
1471
|
interface DevframeSetupInfo {
|
|
1434
1472
|
/** Parsed CLI flags, populated by the CLI adapter. */
|
|
@@ -1449,6 +1487,15 @@ interface DevframeDefinition {
|
|
|
1449
1487
|
light: string;
|
|
1450
1488
|
dark: string;
|
|
1451
1489
|
};
|
|
1490
|
+
/**
|
|
1491
|
+
* Default dock attributes applied when a hub mounts this devframe as an
|
|
1492
|
+
* iframe dock entry. Consulted only by hub adapters (`mountDevframe`),
|
|
1493
|
+
* which merge these beneath the per-mount `dock` overrides; standalone
|
|
1494
|
+
* adapters (`cli` / `spa` / `build`) ignore it.
|
|
1495
|
+
*
|
|
1496
|
+
* @see {@link DevframeDockDefaults}
|
|
1497
|
+
*/
|
|
1498
|
+
dock?: DevframeDockDefaults;
|
|
1452
1499
|
/**
|
|
1453
1500
|
* Mount path override. Defaults depend on the adapter:
|
|
1454
1501
|
* `/` for standalone (`cli` / `spa` / `build`), `/__<id>/` for hosted
|
|
@@ -1478,4 +1525,4 @@ interface DevframeDefinition {
|
|
|
1478
1525
|
}
|
|
1479
1526
|
declare function defineDevframe(d: DevframeDefinition): DevframeDefinition;
|
|
1480
1527
|
//#endregion
|
|
1481
|
-
export {
|
|
1528
|
+
export { ScopedBroadcastOptions as $, StreamSink as A, SharedStateEvents as B, RpcStreamingChannelOptions as C, EventUnsubscribe as Ct, CreateStreamSinkOptions as D, defineCliFlags as Dt, CreateStreamReaderOptions as E, InferCliFlags as Et, ImmutableArray as F, PartialWithoutId as G, SharedStatePatch as H, ImmutableMap as I, DevframeScopedNodeRpc as J, Thenable as K, ImmutableObject as L, createStreamReader as M, createStreamSink as N, StreamErrorPayload as O, parseCliFlags as Ot, Immutable as P, DevframeSettingsStore as Q, ImmutableSet as R, RpcStreamingChannel as S, EventEmitter as St, BufferedChunk as T, CliFlagsSchema as Tt, createSharedState as U, SharedStateOptions as V, EntriesToObject as W, DevframeSettings as X, DevframeScopedStreamingHost as Y, DevframeSettingsRegistry as Z, DevframeNodeRpcSession as _, AgentResourceInput as _t, DevframeDockDefaults as a, DevframeRpcClientFunctions as at, RpcSharedStateGetOptions as b, DevframeAgentHost as bt, DevframeSetupInfo as c, DevframeHost as ct, McpRouteOptions as d, DevframeDiagnosticsHost as dt, ScopedClientFunctions as et, defineDevframe as f, DevframeDiagnosticsLogger as ft, DevframeNodeContext as g, AgentResourceContent as gt, DevframeCapabilities as h, AgentResource as ht, DevframeDeploymentKind as i, DevframeViewHost as it, StreamSinkEvents as j, StreamReader as k, DevframeSpaOptions as l, DevframeDefineDiagnosticsOptions as lt, ConnectionMetaWebsocket as m, AgentManifest as mt, DevframeCliOptions as n, ScopedSharedStates as nt, DevframeDuplicationStrategy as o, DevframeRpcServerFunctions as ot, ConnectionMeta as p, AgentHandle as pt, DevframeScopedNodeContext as q, DevframeDefinition as r, SettingsForNamespace as rt, DevframeRuntime as s, DevframeRpcSharedStates as st, DevframeBrowserContext as t, ScopedServerFunctions as tt, DevframeWsOptions as u, DevframeDiagnosticsDefinition as ut, RpcBroadcastOptions as v, AgentTool as vt, RpcStreamingHost as w, EventsMap as wt, RpcSharedStateHost as x, DevframeAgentHostEvents as xt, RpcFunctionsHost as y, AgentToolInput as yt, SharedState as z };
|
package/dist/helpers/vite.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as DevframeDefinition } from "../devframe-
|
|
1
|
+
import { r as DevframeDefinition } from "../devframe-Dma0XG3U.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/helpers/vite.d.ts
|
|
4
4
|
interface ViteDevBridgeOptions {
|
|
@@ -58,7 +58,7 @@ interface DevframeVitePlugin {
|
|
|
58
58
|
*
|
|
59
59
|
* Use bridge mode when integrating with frameworks that own the SPA
|
|
60
60
|
* (Nuxt, Astro, SolidStart, plain Vite apps). For the all-in-one
|
|
61
|
-
* `dev` / `build` / `mcp` shell, reach for {@link
|
|
61
|
+
* `dev` / `build` / `mcp` shell, reach for {@link createCac} instead.
|
|
62
62
|
*/
|
|
63
63
|
declare function viteDevBridge(d: DevframeDefinition, options?: ViteDevBridgeOptions): DevframeVitePlugin;
|
|
64
64
|
//#endregion
|
package/dist/helpers/vite.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { DEVFRAME_CONNECTION_META_FILENAME, DEVFRAME_WS_ROUTE } from "../constan
|
|
|
2
2
|
import { a as diagnostics } from "../storage-yrUZaiib.mjs";
|
|
3
3
|
import { n as resolveBasePath, t as normalizeBasePath } from "../_shared-bWRzeSa0.mjs";
|
|
4
4
|
import { serveStaticNodeMiddleware } from "../utils/serve-static.mjs";
|
|
5
|
-
import { n as resolveDevServerPort, t as createDevServer } from "../dev-
|
|
5
|
+
import { n as resolveDevServerPort, t as createDevServer } from "../dev-YeAm6GL0.mjs";
|
|
6
6
|
import { resolve } from "pathe";
|
|
7
7
|
//#region src/helpers/vite.ts
|
|
8
8
|
/**
|
|
@@ -21,7 +21,7 @@ import { resolve } from "pathe";
|
|
|
21
21
|
*
|
|
22
22
|
* Use bridge mode when integrating with frameworks that own the SPA
|
|
23
23
|
* (Nuxt, Astro, SolidStart, plain Vite apps). For the all-in-one
|
|
24
|
-
* `dev` / `build` / `mcp` shell, reach for {@link
|
|
24
|
+
* `dev` / `build` / `mcp` shell, reach for {@link createCac} instead.
|
|
25
25
|
*/
|
|
26
26
|
function viteDevBridge(d, options = {}) {
|
|
27
27
|
const base = normalizeMountBase(options.base ?? resolveBasePath(d, "hosted"));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as DevframeNodeRpcSession, g as DevframeNodeContext, z as SharedState } from "./devframe-Dma0XG3U.mjs";
|
|
2
2
|
import { v as RpcFunctionDefinitionAny } from "./types-oEqKqUC9.mjs";
|
|
3
|
-
import { n as InternalAnonymousAuthStorage } from "./context-
|
|
3
|
+
import { n as InternalAnonymousAuthStorage } from "./context-BsiCAEC4.mjs";
|
|
4
4
|
import { Peer } from "crossws";
|
|
5
5
|
|
|
6
6
|
//#region src/node/auth/handler.d.ts
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as ScopedBroadcastOptions, C as RpcStreamingChannelOptions, Ct as EventUnsubscribe, G as PartialWithoutId, J as DevframeScopedNodeRpc, K as Thenable, Q as DevframeSettingsStore, S as RpcStreamingChannel, St as EventEmitter, W as EntriesToObject, X as DevframeSettings, Y as DevframeScopedStreamingHost, Z as DevframeSettingsRegistry, _ as DevframeNodeRpcSession, _t as AgentResourceInput, a as DevframeDockDefaults, at as DevframeRpcClientFunctions, b as RpcSharedStateGetOptions, bt as DevframeAgentHost, c as DevframeSetupInfo, ct as DevframeHost, d as McpRouteOptions, dt as DevframeDiagnosticsHost, et as ScopedClientFunctions, f as defineDevframe, ft as DevframeDiagnosticsLogger, g as DevframeNodeContext, gt as AgentResourceContent, h as DevframeCapabilities, ht as AgentResource, i as DevframeDeploymentKind, it as DevframeViewHost, l as DevframeSpaOptions, lt as DevframeDefineDiagnosticsOptions, m as ConnectionMetaWebsocket, mt as AgentManifest, n as DevframeCliOptions, nt as ScopedSharedStates, o as DevframeDuplicationStrategy, ot as DevframeRpcServerFunctions, p as ConnectionMeta, pt as AgentHandle, q as DevframeScopedNodeContext, r as DevframeDefinition, rt as SettingsForNamespace, s as DevframeRuntime, st as DevframeRpcSharedStates, t as DevframeBrowserContext, tt as ScopedServerFunctions, u as DevframeWsOptions, ut as DevframeDiagnosticsDefinition, v as RpcBroadcastOptions, vt as AgentTool, w as RpcStreamingHost, wt as EventsMap, x as RpcSharedStateHost, xt as DevframeAgentHostEvents, y as RpcFunctionsHost, yt as AgentToolInput } from "./devframe-Dma0XG3U.mjs";
|
|
2
2
|
import { C as RpcFunctionType, T as RpcReturnSchema, _ as RpcFunctionDefinition, g as RpcFunctionAgentOptions, i as RpcArgsSchema } from "./types-oEqKqUC9.mjs";
|
|
3
3
|
import { t as DevframeNodeRpcSessionMeta } from "./ws-server-BUgJpdX4.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/define.d.ts
|
|
6
6
|
declare const defineRpcFunction: <NAME extends string, TYPE extends RpcFunctionType, ARGS extends any[], RETURN = void, const AS extends RpcArgsSchema | undefined = undefined, const RS extends RpcReturnSchema | undefined = undefined>(definition: RpcFunctionDefinition<NAME, TYPE, ARGS, RETURN, AS, RS, DevframeNodeContext>) => RpcFunctionDefinition<NAME, TYPE, ARGS, RETURN, AS, RS, DevframeNodeContext>;
|
|
7
7
|
//#endregion
|
|
8
|
-
export { type AgentHandle, type AgentManifest, type AgentResource, type AgentResourceContent, type AgentResourceInput, type AgentTool, type AgentToolInput, type ConnectionMeta, type ConnectionMetaWebsocket, type DevframeAgentHost, type DevframeAgentHostEvents, type DevframeBrowserContext, type DevframeCapabilities, type DevframeCliOptions, type DevframeDefineDiagnosticsOptions, type DevframeDefinition, type DevframeDeploymentKind, type DevframeDiagnosticsDefinition, type DevframeDiagnosticsHost, type DevframeDiagnosticsLogger, type DevframeDuplicationStrategy, type DevframeHost, type DevframeNodeContext, type DevframeNodeRpcSession, type DevframeNodeRpcSessionMeta, type DevframeRpcClientFunctions, type DevframeRpcServerFunctions, type DevframeRpcSharedStates, type DevframeRuntime, type DevframeScopedNodeContext, type DevframeScopedNodeRpc, type DevframeScopedStreamingHost, type DevframeSettings, type DevframeSettingsRegistry, type DevframeSettingsStore, type DevframeSetupInfo, type DevframeSpaOptions, type DevframeViewHost, type DevframeWsOptions, type EntriesToObject, type EventEmitter, type EventUnsubscribe, type EventsMap, type McpRouteOptions, type PartialWithoutId, type RpcBroadcastOptions, type RpcFunctionAgentOptions, type RpcFunctionsHost, type RpcSharedStateGetOptions, type RpcSharedStateHost, type RpcStreamingChannel, type RpcStreamingChannelOptions, type RpcStreamingHost, type ScopedBroadcastOptions, type ScopedClientFunctions, type ScopedServerFunctions, type ScopedSharedStates, type SettingsForNamespace, type Thenable, type defineDevframe, defineRpcFunction };
|
|
8
|
+
export { type AgentHandle, type AgentManifest, type AgentResource, type AgentResourceContent, type AgentResourceInput, type AgentTool, type AgentToolInput, type ConnectionMeta, type ConnectionMetaWebsocket, type DevframeAgentHost, type DevframeAgentHostEvents, type DevframeBrowserContext, type DevframeCapabilities, type DevframeCliOptions, type DevframeDefineDiagnosticsOptions, type DevframeDefinition, type DevframeDeploymentKind, type DevframeDiagnosticsDefinition, type DevframeDiagnosticsHost, type DevframeDiagnosticsLogger, type DevframeDockDefaults, type DevframeDuplicationStrategy, type DevframeHost, type DevframeNodeContext, type DevframeNodeRpcSession, type DevframeNodeRpcSessionMeta, type DevframeRpcClientFunctions, type DevframeRpcServerFunctions, type DevframeRpcSharedStates, type DevframeRuntime, type DevframeScopedNodeContext, type DevframeScopedNodeRpc, type DevframeScopedStreamingHost, type DevframeSettings, type DevframeSettingsRegistry, type DevframeSettingsStore, type DevframeSetupInfo, type DevframeSpaOptions, type DevframeViewHost, type DevframeWsOptions, type EntriesToObject, type EventEmitter, type EventUnsubscribe, type EventsMap, type McpRouteOptions, type PartialWithoutId, type RpcBroadcastOptions, type RpcFunctionAgentOptions, type RpcFunctionsHost, type RpcSharedStateGetOptions, type RpcSharedStateHost, type RpcStreamingChannel, type RpcStreamingChannelOptions, type RpcStreamingHost, type ScopedBroadcastOptions, type ScopedClientFunctions, type ScopedServerFunctions, type ScopedSharedStates, type SettingsForNamespace, type Thenable, type defineDevframe, defineRpcFunction };
|
package/dist/node/auth.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as verifyAuthToken, c as DevframeAuthHandler, i as refreshTempAuthCode, n as exchangeTempAuthCode, o as revokeActiveConnectionsForToken, r as getTempAuthCode, s as revokeAuthToken, t as buildOtpAuthUrl } from "../index-
|
|
1
|
+
import { a as verifyAuthToken, c as DevframeAuthHandler, i as refreshTempAuthCode, n as exchangeTempAuthCode, o as revokeActiveConnectionsForToken, r as getTempAuthCode, s as revokeAuthToken, t as buildOtpAuthUrl } from "../index-d40ZLcYw.mjs";
|
|
2
2
|
export { DevframeAuthHandler, buildOtpAuthUrl, exchangeTempAuthCode, getTempAuthCode, refreshTempAuthCode, revokeActiveConnectionsForToken, revokeAuthToken, verifyAuthToken };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as DevframeDeploymentKind, r as DevframeDefinition } from "../devframe-
|
|
2
|
-
import { a as internalContextMap, i as getInternalContext, n as InternalAnonymousAuthStorage, r as RemoteTokenRecord, t as DevframeInternalContext } from "../context-
|
|
1
|
+
import { i as DevframeDeploymentKind, r as DevframeDefinition } from "../devframe-Dma0XG3U.mjs";
|
|
2
|
+
import { a as internalContextMap, i as getInternalContext, n as InternalAnonymousAuthStorage, r as RemoteTokenRecord, t as DevframeInternalContext } from "../context-BsiCAEC4.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/adapters/_shared.d.ts
|
|
5
5
|
/**
|
package/dist/node/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { St as EventEmitter, X as DevframeSettings, _ as DevframeNodeRpcSession, _t as AgentResourceInput, at as DevframeRpcClientFunctions, bt as DevframeAgentHost$1, ct as DevframeHost, dt as DevframeDiagnosticsHost$1, ft as DevframeDiagnosticsLogger, g as DevframeNodeContext, gt as AgentResourceContent, ht as AgentResource, it as DevframeViewHost$1, mt as AgentManifest, ot as DevframeRpcServerFunctions, pt as AgentHandle, q as DevframeScopedNodeContext, v as RpcBroadcastOptions, vt as AgentTool, w as RpcStreamingHost, x as RpcSharedStateHost, xt as DevframeAgentHostEvents, y as RpcFunctionsHost$1, yt as AgentToolInput, z as SharedState } from "../devframe-Dma0XG3U.mjs";
|
|
2
2
|
import { v as RpcFunctionDefinitionAny } from "../types-oEqKqUC9.mjs";
|
|
3
3
|
import { S as RpcFunctionsCollectorBase } from "../index-DI_TMGjv.mjs";
|
|
4
4
|
import { t as DevframeNodeRpcSessionMeta } from "../ws-server-BUgJpdX4.mjs";
|
|
5
|
-
import { n as StartedServer, r as startHttpAndWs, t as StartHttpAndWsOptions } from "../server-
|
|
5
|
+
import { n as StartedServer, r as startHttpAndWs, t as StartHttpAndWsOptions } from "../server-BD-tKDVf.mjs";
|
|
6
6
|
import { BirpcGroup } from "birpc";
|
|
7
7
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
8
8
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { c as DevframeAuthHandler } from "../index-
|
|
1
|
+
import { g as DevframeNodeContext } from "../devframe-Dma0XG3U.mjs";
|
|
2
|
+
import { c as DevframeAuthHandler } from "../index-d40ZLcYw.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/recipes/interactive-auth.d.ts
|
|
5
5
|
interface CreateInteractiveAuthOptions {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { c as DevframeAuthHandler } from "./index-
|
|
1
|
+
import { _ as DevframeNodeRpcSession, at as DevframeRpcClientFunctions, g as DevframeNodeContext, ot as DevframeRpcServerFunctions, p as ConnectionMeta } from "./devframe-Dma0XG3U.mjs";
|
|
2
|
+
import { c as DevframeAuthHandler } from "./index-d40ZLcYw.mjs";
|
|
3
3
|
import { BirpcGroup, EventOptions } from "birpc";
|
|
4
4
|
import { Peer } from "crossws";
|
|
5
5
|
import { NodeAdapter } from "crossws/adapters/node";
|
package/dist/types/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as ScopedBroadcastOptions, C as RpcStreamingChannelOptions, Ct as EventUnsubscribe, G as PartialWithoutId, J as DevframeScopedNodeRpc, K as Thenable, Q as DevframeSettingsStore, S as RpcStreamingChannel, St as EventEmitter, W as EntriesToObject, X as DevframeSettings, Y as DevframeScopedStreamingHost, Z as DevframeSettingsRegistry, _ as DevframeNodeRpcSession, _t as AgentResourceInput, a as DevframeDockDefaults, at as DevframeRpcClientFunctions, b as RpcSharedStateGetOptions, bt as DevframeAgentHost, c as DevframeSetupInfo, ct as DevframeHost, d as McpRouteOptions, dt as DevframeDiagnosticsHost, et as ScopedClientFunctions, f as defineDevframe, ft as DevframeDiagnosticsLogger, g as DevframeNodeContext, gt as AgentResourceContent, h as DevframeCapabilities, ht as AgentResource, i as DevframeDeploymentKind, it as DevframeViewHost, l as DevframeSpaOptions, lt as DevframeDefineDiagnosticsOptions, m as ConnectionMetaWebsocket, mt as AgentManifest, n as DevframeCliOptions, nt as ScopedSharedStates, o as DevframeDuplicationStrategy, ot as DevframeRpcServerFunctions, p as ConnectionMeta, pt as AgentHandle, q as DevframeScopedNodeContext, r as DevframeDefinition, rt as SettingsForNamespace, s as DevframeRuntime, st as DevframeRpcSharedStates, t as DevframeBrowserContext, tt as ScopedServerFunctions, u as DevframeWsOptions, ut as DevframeDiagnosticsDefinition, v as RpcBroadcastOptions, vt as AgentTool, w as RpcStreamingHost, wt as EventsMap, x as RpcSharedStateHost, xt as DevframeAgentHostEvents, y as RpcFunctionsHost, yt as AgentToolInput } from "../devframe-Dma0XG3U.mjs";
|
|
2
2
|
import { g as RpcFunctionAgentOptions } from "../types-oEqKqUC9.mjs";
|
|
3
3
|
import { t as DevframeNodeRpcSessionMeta } from "../ws-server-BUgJpdX4.mjs";
|
|
4
|
-
export { AgentHandle, AgentManifest, AgentResource, AgentResourceContent, AgentResourceInput, AgentTool, AgentToolInput, ConnectionMeta, ConnectionMetaWebsocket, DevframeAgentHost, DevframeAgentHostEvents, DevframeBrowserContext, DevframeCapabilities, DevframeCliOptions, DevframeDefineDiagnosticsOptions, DevframeDefinition, DevframeDeploymentKind, DevframeDiagnosticsDefinition, DevframeDiagnosticsHost, DevframeDiagnosticsLogger, DevframeDuplicationStrategy, DevframeHost, DevframeNodeContext, DevframeNodeRpcSession, type DevframeNodeRpcSessionMeta, DevframeRpcClientFunctions, DevframeRpcServerFunctions, DevframeRpcSharedStates, DevframeRuntime, DevframeScopedNodeContext, DevframeScopedNodeRpc, DevframeScopedStreamingHost, DevframeSettings, DevframeSettingsRegistry, DevframeSettingsStore, DevframeSetupInfo, DevframeSpaOptions, DevframeViewHost, DevframeWsOptions, EntriesToObject, EventEmitter, EventUnsubscribe, EventsMap, McpRouteOptions, PartialWithoutId, RpcBroadcastOptions, type RpcFunctionAgentOptions, RpcFunctionsHost, RpcSharedStateGetOptions, RpcSharedStateHost, RpcStreamingChannel, RpcStreamingChannelOptions, RpcStreamingHost, ScopedBroadcastOptions, ScopedClientFunctions, ScopedServerFunctions, ScopedSharedStates, SettingsForNamespace, Thenable, defineDevframe };
|
|
4
|
+
export { AgentHandle, AgentManifest, AgentResource, AgentResourceContent, AgentResourceInput, AgentTool, AgentToolInput, ConnectionMeta, ConnectionMetaWebsocket, DevframeAgentHost, DevframeAgentHostEvents, DevframeBrowserContext, DevframeCapabilities, DevframeCliOptions, DevframeDefineDiagnosticsOptions, DevframeDefinition, DevframeDeploymentKind, DevframeDiagnosticsDefinition, DevframeDiagnosticsHost, DevframeDiagnosticsLogger, DevframeDockDefaults, DevframeDuplicationStrategy, DevframeHost, DevframeNodeContext, DevframeNodeRpcSession, type DevframeNodeRpcSessionMeta, DevframeRpcClientFunctions, DevframeRpcServerFunctions, DevframeRpcSharedStates, DevframeRuntime, DevframeScopedNodeContext, DevframeScopedNodeRpc, DevframeScopedStreamingHost, DevframeSettings, DevframeSettingsRegistry, DevframeSettingsStore, DevframeSetupInfo, DevframeSpaOptions, DevframeViewHost, DevframeWsOptions, EntriesToObject, EventEmitter, EventUnsubscribe, EventsMap, McpRouteOptions, PartialWithoutId, RpcBroadcastOptions, type RpcFunctionAgentOptions, RpcFunctionsHost, RpcSharedStateGetOptions, RpcSharedStateHost, RpcStreamingChannel, RpcStreamingChannelOptions, RpcStreamingHost, ScopedBroadcastOptions, ScopedClientFunctions, ScopedServerFunctions, ScopedSharedStates, SettingsForNamespace, Thenable, defineDevframe };
|
package/dist/utils/events.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { B as
|
|
1
|
+
import { B as SharedStateEvents, F as ImmutableArray, H as SharedStatePatch, I as ImmutableMap, L as ImmutableObject, P as Immutable, R as ImmutableSet, U as createSharedState, V as SharedStateOptions, z as SharedState } from "../devframe-Dma0XG3U.mjs";
|
|
2
2
|
export { Immutable, ImmutableArray, ImmutableMap, ImmutableObject, ImmutableSet, SharedState, SharedStateEvents, SharedStateOptions, SharedStatePatch, createSharedState };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as StreamSink, D as CreateStreamSinkOptions, E as CreateStreamReaderOptions, M as createStreamReader, N as createStreamSink, O as StreamErrorPayload, T as BufferedChunk, j as StreamSinkEvents, k as StreamReader } from "../devframe-Dma0XG3U.mjs";
|
|
2
2
|
export { BufferedChunk, CreateStreamReaderOptions, CreateStreamSinkOptions, StreamErrorPayload, StreamReader, StreamSink, StreamSinkEvents, createStreamReader, createStreamSink };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "devframe",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.7.0",
|
|
5
5
|
"description": "Framework for building generic devframes",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"exports": {
|
|
22
22
|
".": "./dist/index.mjs",
|
|
23
23
|
"./adapters/build": "./dist/adapters/build.mjs",
|
|
24
|
+
"./adapters/cac": "./dist/adapters/cac.mjs",
|
|
24
25
|
"./adapters/cli": "./dist/adapters/cli.mjs",
|
|
25
26
|
"./adapters/dev": "./dist/adapters/dev.mjs",
|
|
26
27
|
"./adapters/embedded": "./dist/adapters/embedded.mjs",
|
|
@@ -62,17 +63,20 @@
|
|
|
62
63
|
"skills"
|
|
63
64
|
],
|
|
64
65
|
"peerDependencies": {
|
|
65
|
-
"@modelcontextprotocol/sdk": "^1.0.0"
|
|
66
|
+
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
67
|
+
"cac": "^7.0.0"
|
|
66
68
|
},
|
|
67
69
|
"peerDependenciesMeta": {
|
|
68
70
|
"@modelcontextprotocol/sdk": {
|
|
69
71
|
"optional": true
|
|
72
|
+
},
|
|
73
|
+
"cac": {
|
|
74
|
+
"optional": true
|
|
70
75
|
}
|
|
71
76
|
},
|
|
72
77
|
"dependencies": {
|
|
73
78
|
"@valibot/to-json-schema": "^1.7.1",
|
|
74
79
|
"birpc": "^4.0.0",
|
|
75
|
-
"cac": "^7.0.0",
|
|
76
80
|
"crossws": "^0.4.9",
|
|
77
81
|
"destr": "^2.0.5",
|
|
78
82
|
"h3": "2.0.1-rc.22",
|
|
@@ -84,6 +88,7 @@
|
|
|
84
88
|
},
|
|
85
89
|
"devDependencies": {
|
|
86
90
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
91
|
+
"cac": "^7.0.0",
|
|
87
92
|
"get-port-please": "^3.2.0",
|
|
88
93
|
"immer": "^11.1.11",
|
|
89
94
|
"launch-editor": "^2.14.1",
|
package/skills/devframe/SKILL.md
CHANGED
|
@@ -11,7 +11,7 @@ description: >
|
|
|
11
11
|
terminals, palette, etc.), the devframe can be mounted into a
|
|
12
12
|
host that provides them — Vite DevTools is one supported target,
|
|
13
13
|
reached via the `vite` adapter. Triggers on `devframe` imports,
|
|
14
|
-
`defineDevframe`, `
|
|
14
|
+
`defineDevframe`, `createCac`, `createMcpServer`,
|
|
15
15
|
`connectDevframe`, and on migrations of existing inspectors
|
|
16
16
|
(eslint-config-inspector, unocss-inspector,
|
|
17
17
|
node-modules-inspector-style tools) to devframe.
|
|
@@ -31,7 +31,7 @@ All adapter factories share the shape `createXxx(devframeDef, options?)`.
|
|
|
31
31
|
|
|
32
32
|
| Author goal | Factory | Entry |
|
|
33
33
|
|-------------|---------|-------|
|
|
34
|
-
| Standalone CLI for local use | `
|
|
34
|
+
| Standalone CLI for local use | `createCac(def, options?)` | `devframe/adapters/cac` |
|
|
35
35
|
| Run the dev server programmatically (any CLI framework) | `createDevServer(def, options?)` | `devframe/adapters/dev` |
|
|
36
36
|
| Self-contained static deploy with baked data | `createBuild(def, options?)` | `devframe/adapters/build` |
|
|
37
37
|
| Mount into a host (Vite DevTools or any compatible host) | `createPluginFromDevframe(def, options?)` | `@vitejs/devtools-kit/node` |
|
|
@@ -530,7 +530,7 @@ At runtime, static clients look up the argument hash in the dump; misses resolve
|
|
|
530
530
|
|
|
531
531
|
## CLI adapter subcommands
|
|
532
532
|
|
|
533
|
-
`
|
|
533
|
+
`createCac(devframe).parse()` gives the tool four subcommands out of the box:
|
|
534
534
|
|
|
535
535
|
| Subcommand | Action |
|
|
536
536
|
|------------|--------|
|
|
@@ -539,7 +539,7 @@ At runtime, static clients look up the argument hash in the dump; misses resolve
|
|
|
539
539
|
| `spa` | Deployable SPA → `./dist-spa/` |
|
|
540
540
|
| `mcp` | stdio MCP server (experimental) |
|
|
541
541
|
|
|
542
|
-
**Bring your own CLI framework?** `
|
|
542
|
+
**Bring your own CLI framework?** `createCac` (`devframe/adapters/cac`) is just a cac wrapper around three peer factories — `createDevServer` (`devframe/adapters/dev`), `createBuild` (`devframe/adapters/build`), and `createMcpServer` (`devframe/adapters/mcp`). Use them directly with commander/yargs/oclif when `createCac`'s baked-in command structure doesn't fit. `cac` is an optional peer dependency pulled in only through `devframe/adapters/cac`, so bring-your-own-CLI tools run without installing it. (The legacy `devframe/adapters/cli` entry / `createCli` remains as a deprecated alias.) `createDevServer` returns a `StartedServer` handle (`origin`, `port`, `app`, `wss`, `close()`) so you can wire SIGINT / hot-reload teardown into the surrounding program. `parseCliFlags(schema, raw)` and `defineCliFlags(...)` (both from `devframe/adapters/cac`) validate an arbitrary flag bag against a `CliFlagsSchema` — the helpers are framework-agnostic.
|
|
543
543
|
|
|
544
544
|
## Bundled utilities
|
|
545
545
|
|