devframe 0.1.22 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/README.md +20 -77
  2. package/dist/{_shared-DcJX9-Az.mjs → _shared-C_yZKUmx.mjs} +3 -3
  3. package/dist/adapters/build.d.mts +1 -1
  4. package/dist/adapters/build.mjs +5 -6
  5. package/dist/adapters/cli.d.mts +3 -3
  6. package/dist/adapters/cli.mjs +2 -2
  7. package/dist/adapters/dev.d.mts +7 -7
  8. package/dist/adapters/dev.mjs +1 -1
  9. package/dist/adapters/embedded.d.mts +1 -1
  10. package/dist/adapters/mcp.d.mts +2 -2
  11. package/dist/adapters/mcp.mjs +73 -18
  12. package/dist/client/index.d.mts +5 -7
  13. package/dist/client/index.mjs +10 -23
  14. package/dist/colors-DS7k8ljB.mjs +123 -0
  15. package/dist/{context-DBd794Rn.d.mts → context-BaX-SZti.d.mts} +1 -1
  16. package/dist/{dev-BGpTpYiR.mjs → dev-CA0-8Amw.mjs} +14 -18
  17. package/dist/{devframe-DulcIxwu.d.mts → devframe-BXZUBuy6.d.mts} +12 -28
  18. package/dist/{diagnostics-BFhNNmST.mjs → diagnostics-Cg9ycFIM.mjs} +2 -2
  19. package/dist/hash-CIBte1yS.mjs +263 -0
  20. package/dist/{adapters → helpers}/vite.d.mts +7 -8
  21. package/dist/{adapters → helpers}/vite.mjs +8 -9
  22. package/dist/{context-DUibxhrR.mjs → host-h3-CpYkiCIU.mjs} +36 -14
  23. package/dist/{index-DB2Ie0Or.d.mts → index-BO4daMzR.d.mts} +51 -3
  24. package/dist/index.d.mts +4 -4
  25. package/dist/{launch-editor-KA_21J1T.mjs → launch-editor-1dAC7Uk5.mjs} +9 -9
  26. package/dist/node/auth.d.mts +2 -2
  27. package/dist/node/auth.mjs +2 -2
  28. package/dist/node/index.d.mts +12 -44
  29. package/dist/node/index.mjs +4 -6
  30. package/dist/node/internal.d.mts +5 -5
  31. package/dist/node/internal.mjs +4 -4
  32. package/dist/{open-DmFp0qZA.mjs → open-CWL4Zasd.mjs} +26 -21
  33. package/dist/recipes/open-helpers.d.mts +1 -1
  34. package/dist/recipes/open-helpers.mjs +2 -2
  35. package/dist/rpc/index.d.mts +3 -3
  36. package/dist/rpc/index.mjs +2 -2
  37. package/dist/rpc/transports/ws-client.d.mts +1 -1
  38. package/dist/rpc/transports/ws-client.mjs +2 -2
  39. package/dist/rpc/transports/ws-server.d.mts +1 -1
  40. package/dist/rpc/transports/ws-server.mjs +2 -2
  41. package/dist/{rpc-CkZuoz-m.mjs → rpc-BlVCyk9W.mjs} +138 -14
  42. package/dist/{server-zKEDxgqD.d.mts → server-CgqyJG9m.d.mts} +5 -5
  43. package/dist/{server-ma8-ZVyX.mjs → server-G1ymmN3_.mjs} +3 -3
  44. package/dist/{shared-state-DCDs0e7y.mjs → shared-state-q9-1EOSX.mjs} +1 -1
  45. package/dist/{storage-CNC38eU-.mjs → storage-BaLJK6e_.mjs} +3 -3
  46. package/dist/{structured-clone-DcDc2Dds.mjs → structured-clone-CD2l4fI3.mjs} +1 -1
  47. package/dist/{transports-BnCs4rj9.mjs → transports-BLwT342H.mjs} +1 -1
  48. package/dist/types/index.d.mts +4 -4
  49. package/dist/types/index.mjs +1 -10
  50. package/dist/{types-4rdUEi2R.d.mts → types-ip8THGH1.d.mts} +21 -5
  51. package/dist/utils/colors.mjs +1 -1
  52. package/dist/utils/events.d.mts +1 -1
  53. package/dist/utils/hash.mjs +1 -1
  54. package/dist/utils/human-id.mjs +1 -1
  55. package/dist/utils/launch-editor.mjs +1 -1
  56. package/dist/utils/open.mjs +1 -1
  57. package/dist/utils/serve-static.d.mts +13 -3
  58. package/dist/utils/serve-static.mjs +41 -20
  59. package/dist/utils/shared-state.d.mts +1 -1
  60. package/dist/utils/shared-state.mjs +1 -1
  61. package/dist/utils/streaming-channel.d.mts +1 -1
  62. package/dist/utils/structured-clone.mjs +1 -1
  63. package/dist/utils/when.d.mts +1 -1
  64. package/dist/utils/when.mjs +1 -1
  65. package/dist/{ws-client-Bavoya6-.d.mts → ws-client-DFUf-xgm.d.mts} +1 -1
  66. package/dist/{ws-server-DjvlwLuM.d.mts → ws-server-kW8RZXTw.d.mts} +1 -1
  67. package/package.json +18 -11
  68. package/skills/devframe/SKILL.md +24 -21
  69. package/skills/devframe/templates/spa-devframe.ts +2 -2
  70. package/dist/colors-Bl4W18Mh.mjs +0 -123
  71. package/dist/hash-BHZbo80D.mjs +0 -126
  72. package/dist/host-h3-Dz8YnFgu.mjs +0 -24
  73. package/dist/static-dump-D7AvjrgL.mjs +0 -80
  74. /package/dist/{human-id-adtUWQLr.mjs → human-id-mPh1HcFO.mjs} +0 -0
  75. /package/dist/{revoke-DIMz1r7-.mjs → revoke-CWSPBbJH.mjs} +0 -0
package/README.md CHANGED
@@ -1,85 +1,28 @@
1
1
  # devframe
2
2
 
3
- Framework-neutral foundation for building generic DevTools. Describe one devframe — its RPC, its data, its SPA, its CLI shape — and deploy the same definition through any of seven adapters.
3
+ [![npm version][npm-version-src]][npm-version-href]
4
+ [![npm downloads][npm-downloads-src]][npm-downloads-href]
5
+ [![bundle][bundle-src]][bundle-href]
6
+ [![JSDocs][jsdocs-src]][jsdocs-href]
7
+ [![License][license-src]][license-href]
4
8
 
5
- Part of the [Vite DevTools](https://devtools.vite.dev) monorepo. Full documentation: [https://devfra.me/](https://devfra.me/).
9
+ Framework-neutral foundation for building generic DevTools.
6
10
 
7
- ## Install
11
+ Documentation: [https://devfra.me/](https://devfra.me/).
8
12
 
9
- ```sh
10
- pnpm add devframe
11
- ```
12
-
13
- ## Hello, Devframe
14
-
15
- ```ts
16
- import { defineDevframe, defineRpcFunction } from 'devframe'
17
- import { createCli } from 'devframe/adapters/cli'
18
-
19
- const devframe = defineDevframe({
20
- id: 'my-devframe',
21
- name: 'My Devframe',
22
- setup(ctx) {
23
- ctx.rpc.register(defineRpcFunction({
24
- name: 'my-devframe:hello',
25
- type: 'static',
26
- jsonSerializable: true,
27
- handler: () => ({ message: 'hello' }),
28
- }))
29
- },
30
- })
31
-
32
- await createCli(devframe).parse()
33
- ```
34
-
35
- ## Adapters
36
-
37
- | Adapter | Use case |
38
- |---------|----------|
39
- | `cli` | Standalone CLI tool with `dev` / `build` / `mcp` subcommands. |
40
- | `build` | Generates a static, self-contained SPA snapshot. |
41
- | `vite` | Runs as a Vite plugin alongside the host app's dev server. |
42
- | `kit` | Mounts into the DevTools Kit aggregator. |
43
- | `embedded` | Overlays inside another devtool's UI. |
44
- | `mcp` | Surfaces the devframe's RPC to coding agents over MCP. |
45
-
46
- ## Agent-Native (experimental)
47
-
48
- > [!WARNING]
49
- > The agent-native surface — the `agent` field on `defineRpcFunction`, `DevToolsAgentHost`, and the `devframe/adapters/mcp` adapter — may change without a major version bump until it stabilizes.
50
-
51
- Devframe surfaces a devframe's RPC functions, tools, and resources to coding agents over [MCP](https://modelcontextprotocol.io). Flag an RPC function with `agent: { description }` to expose it, then spin up an MCP server:
52
-
53
- ```ts
54
- import { defineDevframe, defineRpcFunction } from 'devframe'
55
- import { createMcpServer } from 'devframe/adapters/mcp'
56
-
57
- const getSummary = defineRpcFunction({
58
- name: 'my-plugin:get-summary',
59
- type: 'query',
60
- agent: {
61
- description: 'Return a short summary of the current build state.',
62
- },
63
- setup: ctx => ({ handler: async () => buildSummary() }),
64
- })
65
-
66
- const devframe = defineDevframe({
67
- id: 'my-plugin',
68
- setup(ctx) {
69
- ctx.rpc.register(getSummary)
70
- ctx.agent.registerResource({
71
- id: 'latest-build',
72
- name: 'Latest build',
73
- read: () => ({ text: renderMarkdown(latestBuild) }),
74
- })
75
- },
76
- })
77
-
78
- await createMcpServer(devframe, { transport: 'stdio' })
79
- ```
13
+ ## License
80
14
 
81
- Or via the CLI: `devframe mcp`. `@modelcontextprotocol/sdk` is a peer dependency — add it when you want MCP support. See the [Agent-Native guide](https://devfra.me/guide/agent-native) for the full API and Claude Desktop integration example.
15
+ [MIT](../../LICENSE.md) License © [Anthony Fu](https://github.com/antfu)
82
16
 
83
- ## License
17
+ <!-- Badges -->
84
18
 
85
- [MIT](./LICENSE.md)
19
+ [npm-version-src]: https://img.shields.io/npm/v/devframe?style=flat&colorA=080f12&colorB=517158
20
+ [npm-version-href]: https://npmx.dev/package/devframe
21
+ [npm-downloads-src]: https://img.shields.io/npm/dm/devframe?style=flat&colorA=080f12&colorB=517158
22
+ [npm-downloads-href]: https://npmx.dev/package/devframe
23
+ [bundle-src]: https://img.shields.io/bundlephobia/minzip/devframe?style=flat&colorA=080f12&colorB=517158&label=minzip
24
+ [bundle-href]: https://bundlephobia.com/result?p=devframe
25
+ [license-src]: https://img.shields.io/github/license/devframes/devframe.svg?style=flat&colorA=080f12&colorB=517158
26
+ [license-href]: https://github.com/devframes/devframe/blob/main/LICENSE.md
27
+ [jsdocs-src]: https://img.shields.io/badge/jsdocs-reference-080f12?style=flat&colorA=080f12&colorB=517158
28
+ [jsdocs-href]: https://www.jsdocs.io/package/devframe
@@ -1,9 +1,9 @@
1
1
  //#region src/adapters/_shared.ts
2
2
  /**
3
3
  * Resolve the mount base path for a devframe's SPA. Hosted adapters
4
- * (`vite`, `kit`, `embedded`) default to `/__<id>/` so they don't
5
- * collide with the host app; standalone adapters (`cli`, `spa`,
6
- * `build`) default to `/` because they own the origin.
4
+ * (`vite`, `embedded`) default to `/__<id>/` so they don't collide
5
+ * with the host app; standalone adapters (`cli`, `spa`, `build`)
6
+ * default to `/` because they own the origin.
7
7
  *
8
8
  * The devframe author can override with `basePath` on the definition.
9
9
  */
@@ -1,4 +1,4 @@
1
- import { r as DevframeDefinition } from "../devframe-DulcIxwu.mjs";
1
+ import { r as DevframeDefinition } from "../devframe-BXZUBuy6.mjs";
2
2
 
3
3
  //#region src/adapters/build.d.ts
4
4
  interface CreateBuildOptions {
@@ -1,11 +1,10 @@
1
+ import { t as collectStaticRpcDump } from "../rpc-BlVCyk9W.mjs";
1
2
  import { n as strictJsonStringify } from "../serialization-CwO31axa.mjs";
2
- import { i as structuredCloneStringify } from "../structured-clone-DcDc2Dds.mjs";
3
- import { t as colors } from "../colors-Bl4W18Mh.mjs";
4
- import { t as createHostContext } from "../context-DUibxhrR.mjs";
5
- import { t as createH3DevToolsHost } from "../host-h3-Dz8YnFgu.mjs";
6
3
  import { DEVTOOLS_CONNECTION_META_FILENAME, DEVTOOLS_RPC_DUMP_DIRNAME, DEVTOOLS_RPC_DUMP_MANIFEST_FILENAME } from "../constants.mjs";
7
- import { t as collectStaticRpcDump } from "../static-dump-D7AvjrgL.mjs";
8
- import { n as resolveBasePath } from "../_shared-DcJX9-Az.mjs";
4
+ import { i as structuredCloneStringify } from "../structured-clone-CD2l4fI3.mjs";
5
+ import { t as colors } from "../colors-DS7k8ljB.mjs";
6
+ import { n as createHostContext, t as createH3DevToolsHost } from "../host-h3-CpYkiCIU.mjs";
7
+ import { n as resolveBasePath } from "../_shared-C_yZKUmx.mjs";
9
8
  import { existsSync } from "node:fs";
10
9
  import process from "node:process";
11
10
  import { dirname, resolve } from "pathe";
@@ -1,5 +1,5 @@
1
- import { _t as InferCliFlags, gt as CliFlagsSchema, r as DevframeDefinition, vt as defineCliFlags, yt as parseCliFlags } from "../devframe-DulcIxwu.mjs";
2
- import { App } from "h3";
1
+ import { ct as CliFlagsSchema, dt as parseCliFlags, lt as InferCliFlags, r as DevframeDefinition, ut as defineCliFlags } from "../devframe-BXZUBuy6.mjs";
2
+ import { H3 } from "h3";
3
3
  import { CAC } from "cac";
4
4
 
5
5
  //#region src/adapters/cli.d.ts
@@ -19,7 +19,7 @@ interface CreateCliOptions {
19
19
  onReady?: (info: {
20
20
  origin: string;
21
21
  port: number;
22
- app: App;
22
+ app: H3;
23
23
  }) => void | Promise<void>;
24
24
  }
25
25
  interface CliHandle {
@@ -1,6 +1,6 @@
1
- import { t as colors } from "../colors-Bl4W18Mh.mjs";
1
+ import { t as colors } from "../colors-DS7k8ljB.mjs";
2
2
  import { createBuild } from "./build.mjs";
3
- import { n as resolveDevServerPort, t as createDevServer } from "../dev-BGpTpYiR.mjs";
3
+ import { n as resolveDevServerPort, t as createDevServer } from "../dev-CA0-8Amw.mjs";
4
4
  import process from "node:process";
5
5
  import cac from "cac";
6
6
  import { safeParse } from "valibot";
@@ -1,6 +1,6 @@
1
- import { r as DevframeDefinition } from "../devframe-DulcIxwu.mjs";
2
- import { n as StartedServer } from "../server-zKEDxgqD.mjs";
3
- import { App } from "h3";
1
+ import { r as DevframeDefinition } from "../devframe-BXZUBuy6.mjs";
2
+ import { n as StartedServer } from "../server-CgqyJG9m.mjs";
3
+ import { H3 } from "h3";
4
4
 
5
5
  //#region src/adapters/dev.d.ts
6
6
  interface CreateDevServerOptions {
@@ -23,7 +23,7 @@ interface CreateDevServerOptions {
23
23
  * `def.cli?.distDir` is set, the dev server runs in **bridge mode** —
24
24
  * only `__connection.json` and the WS endpoint are mounted; the SPA
25
25
  * is expected to be hosted elsewhere (e.g. by a parent Vite/Nuxt
26
- * dev server via `createVitePlugin({ devMiddleware })`).
26
+ * dev server via `viteDevBridge({ devMiddleware })`).
27
27
  */
28
28
  distDir?: string;
29
29
  /**
@@ -37,7 +37,7 @@ interface CreateDevServerOptions {
37
37
  * middleware (auth, logging, extra static assets) before devframe's
38
38
  * own handlers.
39
39
  */
40
- app?: App;
40
+ app?: H3;
41
41
  /**
42
42
  * Auto-open the browser. When `undefined` the resolution falls
43
43
  * through to `flags.open` (incl. string path) and finally
@@ -52,7 +52,7 @@ interface CreateDevServerOptions {
52
52
  onReady?: (info: {
53
53
  origin: string;
54
54
  port: number;
55
- app: App;
55
+ app: H3;
56
56
  }) => void | Promise<void>;
57
57
  }
58
58
  interface ResolveDevServerPortOptions {
@@ -78,7 +78,7 @@ declare function resolveDevServerPort(def: DevframeDefinition, options?: Resolve
78
78
  * server runs in **bridge mode**: only `__connection.json` and the WS
79
79
  * endpoint are mounted, with no SPA mount. The SPA is expected to be
80
80
  * hosted elsewhere (e.g. by a parent Vite/Nuxt dev server) — see
81
- * `createVitePlugin({ devMiddleware })`.
81
+ * `viteDevBridge({ devMiddleware })`.
82
82
  *
83
83
  * Returns the underlying {@link StartedServer} handle so callers can
84
84
  * close it gracefully (SIGINT, hot-reload, test teardown).
@@ -1,2 +1,2 @@
1
- import { n as resolveDevServerPort, t as createDevServer } from "../dev-BGpTpYiR.mjs";
1
+ import { n as resolveDevServerPort, t as createDevServer } from "../dev-CA0-8Amw.mjs";
2
2
  export { createDevServer, resolveDevServerPort };
@@ -1,4 +1,4 @@
1
- import { r as DevframeDefinition, y as DevToolsNodeContext } from "../devframe-DulcIxwu.mjs";
1
+ import { d as DevToolsNodeContext, r as DevframeDefinition } from "../devframe-BXZUBuy6.mjs";
2
2
 
3
3
  //#region src/adapters/embedded.d.ts
4
4
  interface CreateEmbeddedOptions {
@@ -1,7 +1,7 @@
1
- import { r as DevframeDefinition } from "../devframe-DulcIxwu.mjs";
1
+ import { r as DevframeDefinition } from "../devframe-BXZUBuy6.mjs";
2
2
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
3
3
 
4
- //#region src/node/mcp/build-server.d.ts
4
+ //#region src/adapters/mcp/build-server.d.ts
5
5
  interface CreateMcpServerOptions {
6
6
  /**
7
7
  * Transport to use. Only `'stdio'` is implemented today; HTTP support
@@ -1,12 +1,76 @@
1
- import { n as logger } from "../diagnostics-BFhNNmST.mjs";
2
- import { t as createHostContext } from "../context-DUibxhrR.mjs";
1
+ import { n as logger } from "../diagnostics-Cg9ycFIM.mjs";
2
+ import { n as createHostContext } from "../host-h3-CpYkiCIU.mjs";
3
3
  import { homedir } from "node:os";
4
4
  import process from "node:process";
5
5
  import { join } from "pathe";
6
6
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
7
7
  import { CallToolRequestSchema, ListResourcesRequestSchema, ListToolsRequestSchema, ReadResourceRequestSchema } from "@modelcontextprotocol/sdk/types.js";
8
8
  import { toJsonSchema } from "@valibot/to-json-schema";
9
- //#region src/node/mcp/to-json-schema.ts
9
+ //#region src/adapters/mcp/stringify.ts
10
+ /**
11
+ * JSON-coercing serializer for MCP text payloads.
12
+ *
13
+ * MCP carries tool results and resource reads as plain text over a
14
+ * JSON-RPC transport, so we cannot use the `s:`-prefixed structured-clone
15
+ * format the WS RPC transport falls back to for non-JSON values. Instead,
16
+ * we coerce common non-JSON types into JSON-friendly forms so the LLM
17
+ * client sees something useful instead of `[object Object]`.
18
+ *
19
+ * Coercions:
20
+ * - `BigInt` → `"123n"`
21
+ * - `Date` → ISO string (via the native `toJSON`)
22
+ * - `Map` → `{ __type: 'Map', entries: [[k, v], …] }`
23
+ * - `Set` → `{ __type: 'Set', entries: [v, …] }`
24
+ * - `Error` → `{ name, message, stack, cause? }` (cause recurses)
25
+ * - `Function` → `"[Function: name]"`
26
+ * - `Symbol` → `value.toString()`
27
+ * - cycles → `"[Circular]"`
28
+ */
29
+ function stringifyForMcp(value) {
30
+ if (value === void 0) return "undefined";
31
+ if (typeof value === "string") return value;
32
+ const seen = /* @__PURE__ */ new WeakSet();
33
+ return JSON.stringify(value, (_key, val) => {
34
+ if (typeof val === "bigint") return `${val}n`;
35
+ if (val instanceof Error) {
36
+ const out = {
37
+ name: val.name,
38
+ message: val.message,
39
+ stack: val.stack
40
+ };
41
+ if (val.cause !== void 0) out.cause = val.cause;
42
+ return out;
43
+ }
44
+ if (val instanceof Map) return {
45
+ __type: "Map",
46
+ entries: [...val.entries()]
47
+ };
48
+ if (val instanceof Set) return {
49
+ __type: "Set",
50
+ entries: [...val]
51
+ };
52
+ if (typeof val === "function") return `[Function: ${val.name || "anonymous"}]`;
53
+ if (typeof val === "symbol") return val.toString();
54
+ if (val !== null && typeof val === "object") {
55
+ if (seen.has(val)) return "[Circular]";
56
+ seen.add(val);
57
+ }
58
+ return val;
59
+ }, 2);
60
+ }
61
+ /**
62
+ * Format a thrown value for an MCP `isError` text payload. Surfaces the
63
+ * `Error.name`/`message`, and one level of `cause.message` so context
64
+ * isn't dropped silently.
65
+ */
66
+ function formatMcpError(error) {
67
+ if (!(error instanceof Error)) return String(error);
68
+ const cause = error.cause;
69
+ const causeText = cause instanceof Error ? ` (cause: ${cause.message})` : cause !== void 0 ? ` (cause: ${String(cause)})` : "";
70
+ return `${error.name}: ${error.message}${causeText}`;
71
+ }
72
+ //#endregion
73
+ //#region src/adapters/mcp/to-json-schema.ts
10
74
  const FALLBACK_OBJECT_SCHEMA = Object.freeze({
11
75
  type: "object",
12
76
  additionalProperties: true
@@ -75,7 +139,7 @@ function isObjectJsonSchema(value) {
75
139
  return !!value && typeof value === "object" && value.type === "object";
76
140
  }
77
141
  //#endregion
78
- //#region src/node/mcp/build-server.ts
142
+ //#region src/adapters/mcp/build-server.ts
79
143
  /**
80
144
  * Wire an MCP {@link Server} to a devframe context. Returns the server
81
145
  * plus a disposal function for the subscriptions it sets up. The
@@ -140,7 +204,7 @@ async function createMcpServer(definition, options = {}) {
140
204
  serverVersion: options.serverVersion ?? definition.version ?? "0.0.0",
141
205
  exposeSharedState: options.exposeSharedState ?? true
142
206
  });
143
- const { startStdioTransport } = await import("../transports-BnCs4rj9.mjs");
207
+ const { startStdioTransport } = await import("../transports-BLwT342H.mjs");
144
208
  let stop;
145
209
  try {
146
210
  stop = await startStdioTransport(server);
@@ -166,14 +230,14 @@ function registerToolHandlers(server, ctx) {
166
230
  try {
167
231
  return { content: [{
168
232
  type: "text",
169
- text: stringify(await ctx.agent.invoke(name, args ?? {}))
233
+ text: stringifyForMcp(await ctx.agent.invoke(name, args ?? {}))
170
234
  }] };
171
235
  } catch (error) {
172
236
  return {
173
237
  isError: true,
174
238
  content: [{
175
239
  type: "text",
176
- text: `Error invoking "${name}": ${error instanceof Error ? error.message : String(error)}`
240
+ text: `Error invoking "${name}": ${formatMcpError(error)}`
177
241
  }]
178
242
  };
179
243
  }
@@ -209,13 +273,13 @@ function registerResourceHandlers(server, ctx, exposeSharedState) {
209
273
  return { contents: [{
210
274
  uri,
211
275
  mimeType: content.mimeType ?? "application/json",
212
- text: content.text ?? stringify(content.json)
276
+ text: content.text ?? stringifyForMcp(content.json)
213
277
  }] };
214
278
  }
215
279
  if (parsed.kind === "state") return { contents: [{
216
280
  uri,
217
281
  mimeType: "application/json",
218
- text: stringify((await ctx.rpc.sharedState.get(parsed.key)).value())
282
+ text: stringifyForMcp((await ctx.rpc.sharedState.get(parsed.key)).value())
219
283
  }] };
220
284
  throw new Error(`[devframe/mcp] unknown resource URI "${uri}"`);
221
285
  });
@@ -269,14 +333,5 @@ function parseResourceUri(uri) {
269
333
  key: decoded
270
334
  };
271
335
  }
272
- function stringify(value) {
273
- if (value === void 0) return "undefined";
274
- if (typeof value === "string") return value;
275
- try {
276
- return JSON.stringify(value, null, 2);
277
- } catch {
278
- return String(value);
279
- }
280
- }
281
336
  //#endregion
282
337
  export { createMcpServer };
@@ -1,7 +1,7 @@
1
- import { M as StreamReader, N as StreamSink, Q as DevToolsRpcServerFunctions, Z as DevToolsRpcClientFunctions, _ as ConnectionMeta, pt as EventEmitter, w as RpcSharedStateHost } from "../devframe-DulcIxwu.mjs";
2
- import { m as RpcCacheOptions, p as RpcCacheManager } from "../index-DB2Ie0Or.mjs";
3
- import { S as RpcFunctionsCollector } from "../types-4rdUEi2R.mjs";
4
- import { t as WsRpcChannelOptions } from "../ws-client-Bavoya6-.mjs";
1
+ import { T as StreamSink, U as DevToolsRpcClientFunctions, W as DevToolsRpcServerFunctions, at as EventEmitter, g as RpcSharedStateHost, l as ConnectionMeta, w as StreamReader } from "../devframe-BXZUBuy6.mjs";
2
+ import { C as RpcCacheManager, w as RpcCacheOptions } from "../index-BO4daMzR.mjs";
3
+ import { C as RpcFunctionsCollector } from "../types-ip8THGH1.mjs";
4
+ import { t as WsRpcChannelOptions } from "../ws-client-DFUf-xgm.mjs";
5
5
  import { BirpcOptions, BirpcReturn } from "birpc";
6
6
 
7
7
  //#region src/client/rpc-streaming.d.ts
@@ -133,7 +133,5 @@ declare function getDevToolsRpcClient(options?: DevToolsRpcClientOptions): Promi
133
133
  //#endregion
134
134
  //#region src/client/index.d.ts
135
135
  declare const connectDevframe: typeof getDevToolsRpcClient;
136
- /** @deprecated Use `connectDevframe`. */
137
- declare function connectDevtool(...args: Parameters<typeof getDevToolsRpcClient>): ReturnType<typeof getDevToolsRpcClient>;
138
136
  //#endregion
139
- export { DevToolsClientRpcHost, DevToolsRpcClient, DevToolsRpcClientCall, DevToolsRpcClientCallEvent, DevToolsRpcClientCallOptional, DevToolsRpcClientMode, DevToolsRpcClientOptions, DevToolsRpcContext, RpcClientEvents, RpcStreamingClientHost, StreamingSubscribeOptions, connectDevframe, connectDevtool, createRpcStreamingClientHost, getDevToolsRpcClient };
137
+ export { DevToolsClientRpcHost, DevToolsRpcClient, DevToolsRpcClientCall, DevToolsRpcClientCallEvent, DevToolsRpcClientCallOptional, DevToolsRpcClientMode, DevToolsRpcClientOptions, DevToolsRpcContext, RpcClientEvents, RpcStreamingClientHost, StreamingSubscribeOptions, connectDevframe, createRpcStreamingClientHost, getDevToolsRpcClient };
@@ -1,13 +1,13 @@
1
- import { t as hash } from "../hash-BHZbo80D.mjs";
2
- import { l as RpcCacheManager, o as RpcFunctionsCollectorBase } from "../rpc-CkZuoz-m.mjs";
1
+ import { t as hash } from "../hash-CIBte1yS.mjs";
2
+ import { a as reviveDumpError, f as RpcCacheManager, l as RpcFunctionsCollectorBase } from "../rpc-BlVCyk9W.mjs";
3
+ import { DEVTOOLS_CONNECTION_META_FILENAME, DEVTOOLS_RPC_DUMP_MANIFEST_FILENAME } from "../constants.mjs";
3
4
  import { createRpcClient } from "../rpc/client.mjs";
4
- import { t as structuredCloneDeserialize } from "../structured-clone-DcDc2Dds.mjs";
5
+ import { t as structuredCloneDeserialize } from "../structured-clone-CD2l4fI3.mjs";
5
6
  import { createWsRpcChannel } from "../rpc/transports/ws-client.mjs";
6
7
  import { createEventEmitter } from "../utils/events.mjs";
7
- import { t as createSharedState } from "../shared-state-DCDs0e7y.mjs";
8
+ import { t as createSharedState } from "../shared-state-q9-1EOSX.mjs";
8
9
  import { createStreamReader, createStreamSink } from "../utils/streaming-channel.mjs";
9
- import { DEVTOOLS_CONNECTION_META_FILENAME, DEVTOOLS_RPC_DUMP_MANIFEST_FILENAME } from "../constants.mjs";
10
- import { t as humanId } from "../human-id-adtUWQLr.mjs";
10
+ import { t as humanId } from "../human-id-mPh1HcFO.mjs";
11
11
  import { promiseWithResolver } from "../utils/promise.mjs";
12
12
  //#region src/client/rpc-shared-state.ts
13
13
  function createRpcSharedStateClientHost(rpc) {
@@ -111,11 +111,7 @@ function isRecord(value) {
111
111
  return typeof value === "object" && value !== null && ("output" in value || "error" in value);
112
112
  }
113
113
  function resolveRecordOutput(record) {
114
- if (record.error) {
115
- const error = new Error(record.error.message);
116
- error.name = record.error.name;
117
- throw error;
118
- }
114
+ if (record.error) throw reviveDumpError(record.error);
119
115
  return record.output;
120
116
  }
121
117
  function createStaticRpcCaller(manifest, fetchJson) {
@@ -277,7 +273,7 @@ function createRpcStreamingClientHost(rpc) {
277
273
  };
278
274
  }
279
275
  //#endregion
280
- //#region ../../../node_modules/.pnpm/ua-parser-modern@0.1.1/node_modules/ua-parser-modern/dist/index.mjs
276
+ //#region ../../node_modules/.pnpm/ua-parser-modern@0.1.1/node_modules/ua-parser-modern/dist/index.mjs
281
277
  const EMPTY = "";
282
278
  const UNKNOWN = "?";
283
279
  const MAJOR = "major";
@@ -1500,7 +1496,7 @@ function createWsRpcClientMode(options) {
1500
1496
  let clear = () => {};
1501
1497
  await Promise.race([trustedPromise.promise.then(clear), new Promise((resolve, reject) => {
1502
1498
  const id = setTimeout(() => {
1503
- reject(/* @__PURE__ */ new Error("[Vite DevTools] Timeout waiting for rpc to be trusted"));
1499
+ reject(/* @__PURE__ */ new Error("[devframe] Timeout waiting for rpc to be trusted"));
1504
1500
  }, timeout);
1505
1501
  clear = () => clearTimeout(id);
1506
1502
  })]);
@@ -1660,14 +1656,5 @@ async function getDevToolsRpcClient(options = {}) {
1660
1656
  //#endregion
1661
1657
  //#region src/client/index.ts
1662
1658
  const connectDevframe = getDevToolsRpcClient;
1663
- let warnedConnectDevtool = false;
1664
- /** @deprecated Use `connectDevframe`. */
1665
- function connectDevtool(...args) {
1666
- if (!warnedConnectDevtool) {
1667
- warnedConnectDevtool = true;
1668
- console.warn("[devframe] `connectDevtool` is deprecated; use `connectDevframe` instead.");
1669
- }
1670
- return getDevToolsRpcClient(...args);
1671
- }
1672
1659
  //#endregion
1673
- export { connectDevframe, connectDevtool, createRpcStreamingClientHost, getDevToolsRpcClient };
1660
+ export { connectDevframe, createRpcStreamingClientHost, getDevToolsRpcClient };
@@ -0,0 +1,123 @@
1
+ import { r as __toESM, t as __commonJSMin } from "./chunk-e9Ob2GDo.mjs";
2
+ //#endregion
3
+ //#region ../../node_modules/.pnpm/ansis@4.3.0/node_modules/ansis/index.mjs
4
+ var import_ansis = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
5
+ let e, r, { defineProperty: t, setPrototypeOf: n, create: l, keys: o } = Object, i = "", { round: s, max: f } = Math, u = (e) => {
6
+ let r = /([a-f\d]{3,6})/i.exec(e)?.[1], t = r?.length, n = parseInt(6 ^ t ? 3 ^ t ? "0" : r[0] + r[0] + r[1] + r[1] + r[2] + r[2] : r, 16);
7
+ return [
8
+ n >> 16 & 255,
9
+ n >> 8 & 255,
10
+ 255 & n
11
+ ];
12
+ }, a = (e, r, t) => e ^ r || r ^ t ? 16 + 36 * s(e / 51) + 6 * s(r / 51) + s(t / 51) : 8 > e ? 16 : e > 248 ? 231 : s(24 * (e - 8) / 247) + 232, c = (e) => {
13
+ let r, t, n, l, o;
14
+ return 8 > e ? 30 + e : 16 > e ? 82 + e : (232 > e ? (o = (e -= 16) % 36, r = (e / 36 | 0) / 5, t = (o / 6 | 0) / 5, n = o % 6 / 5) : r = t = n = (10 * (e - 232) + 8) / 255, l = 2 * f(r, t, n), l ? 30 + (s(n) << 2 | s(t) << 1 | s(r)) + (2 ^ l ? 0 : 60) : 30);
15
+ }, g = {
16
+ open: i,
17
+ close: i
18
+ }, b = 39, d = 49, p = {}, $ = ({ p: e }, { open: t = "", close: l = "", f: o }) => {
19
+ let s = (e, ...r) => {
20
+ if (!e) {
21
+ if (t && t === l) return t;
22
+ if ((e ?? i) === i) return i;
23
+ }
24
+ let n, f = s.p, u = f.o, a = f.c, c = o ? o(e, ...r) : e.raw ? String.raw({ raw: e }, ...r) : i + e;
25
+ if (c.includes("\x1B")) for (; f; f = f.p) {
26
+ let { t: e, l: r } = f, t = r.length, l = i, o = 0;
27
+ if (t) for (; ~(n = c.indexOf(r, o)); o = n + t) l += c.slice(o, n) + e;
28
+ c = l + c.slice(o);
29
+ }
30
+ return u + (c.includes("\n") ? c.replace(/(\r?\n)/g, a + "$1" + u) : c) + a;
31
+ }, f = t, u = l;
32
+ return e && (f = e.o + t, u = l + e.c), n(s, r), s.p = {
33
+ t,
34
+ l,
35
+ o: s.open = f,
36
+ c: s.close = u,
37
+ p: e
38
+ }, s;
39
+ };
40
+ const h = new function s(f = globalThis) {
41
+ let h, y, m = "number" == typeof f ? f : ((r) => {
42
+ let t = r.process ?? {}, n = t.argv ?? [], l = t.env ?? {}, i = 0;
43
+ try {
44
+ i = ((r, t, n) => (e = t.TERM, {
45
+ "24bit": 3,
46
+ truecolor: 3,
47
+ ansi256: 2,
48
+ ansi: 1
49
+ }[t.COLORTERM] || (t.CI ? /,GITHUB/.test(n) ? 3 : 1 : (t.PM2_HOME || /edge/.test(t.NEXT_RUNTIME) || r.stdout?.isTTY) && "dumb" !== e ? "win32" === r.platform ? 3 : /-256/.test(e) ? 2 : 1 : 0)))(t, l, "," + o(l).join(","));
50
+ } catch (e) {
51
+ l = {};
52
+ }
53
+ let s, f = i || 1, u = "FORCE_COLOR", a = {
54
+ false: 0,
55
+ 0: 0,
56
+ 1: 1,
57
+ 2: 2,
58
+ 3: 3
59
+ }[l[u]] ?? f, c = -1;
60
+ for (s of n) /^--color=?(true|always)?$/.test(s) && (c = f), /^--(no-color|color=(false|never))$/.test(s) && (c = 0);
61
+ return r.window?.chrome ? 3 : u in l ? a : ~c ? c : l.NO_COLOR ? 0 : i;
62
+ })(f), w = {
63
+ Ansis: s,
64
+ level: m,
65
+ isSupported: () => v,
66
+ strip: (e) => e.replace(/[›][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, i),
67
+ extend(e) {
68
+ for (let r in e) {
69
+ let t = e[r], n = (typeof t)[0];
70
+ "s" === n && (O(B(r), I(...u(t))), t = H(...u(t))), O(r, t, "f" === n);
71
+ }
72
+ return n(w, r = l({}, p)), w;
73
+ }
74
+ }, O = (e, r, n) => {
75
+ p[e] = { get() {
76
+ let l = n ? (...e) => $(this, r(...e)) : $(this, r);
77
+ return t(this, e, { value: l }), l;
78
+ } };
79
+ }, v = m > 0, _ = (e, r) => v ? {
80
+ open: `[${e}m`,
81
+ close: `[${r}m`
82
+ } : g, k = (e) => (r) => e(...u(r)), x = (e, r) => (t, n, l) => _(`${e}8;2;${t};${n};${l}`, r), R = (e) => (r, t, n) => e(a(r, t, n)), A = (e, r) => (t, n, l) => _(c(a(t, n, l)) + e, r), B = (e) => "bg" + e[0].toUpperCase() + e.slice(1), C = "Bright", H = x(3, b), I = x(4, d), P = (e) => _("38;5;" + e, b), S = (e) => _("48;5;" + e, d);
83
+ return 2 === m ? (H = R(P), I = R(S)) : 1 === m && (H = A(0, b), I = A(10, d), P = (e) => _(c(e), b), S = (e) => _(c(e) + 10, d)), y = {
84
+ fg: P,
85
+ bg: S,
86
+ rgb: H,
87
+ bgRgb: I,
88
+ hex: k(H),
89
+ bgHex: k(I),
90
+ visible: g,
91
+ reset: _(0, 0),
92
+ bold: _(1, 22),
93
+ dim: _(2, 22),
94
+ italic: _(3, 23),
95
+ underline: _(4, 24),
96
+ inverse: _(7, 27),
97
+ hidden: _(8, 28),
98
+ strikethrough: _(9, 29),
99
+ link: { f: (e, r = e) => v ? `]8;;${e}${r}]8;;` : r != e ? `${r} (​${e}​)` : e }
100
+ }, "gray,black,red,green,yellow,blue,magenta,cyan,white".split(",").map(((e, r) => {
101
+ h = B(e), r ? (y[e + C] = _(89 + r, b), y[h + C] = _(99 + r, d)) : r = 61, y[e] = _(29 + r, b), y[h] = _(39 + r, d);
102
+ })), w.extend(y);
103
+ }();
104
+ module.exports = h.default = h;
105
+ })))(), 1);
106
+ var ansis_default = import_ansis.default;
107
+ const { Ansis, fg, bg, rgb, bgRgb, hex, bgHex, reset, inverse, hidden, visible, link, bold, dim, italic, underline, strikethrough, black, red, green, yellow, blue, magenta, cyan, white, gray, redBright, greenBright, yellowBright, blueBright, magentaBright, cyanBright, whiteBright, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bgGray, bgRedBright, bgGreenBright, bgYellowBright, bgBlueBright, bgMagentaBright, bgCyanBright, bgWhiteBright } = import_ansis.default;
108
+ //#endregion
109
+ //#region src/utils/colors.ts
110
+ const colors = {
111
+ blue: ansis_default.blue,
112
+ cyan: ansis_default.cyan,
113
+ gray: ansis_default.gray,
114
+ green: ansis_default.green,
115
+ red: ansis_default.red,
116
+ yellow: ansis_default.yellow,
117
+ bold: ansis_default.bold,
118
+ dim: ansis_default.dim,
119
+ reset: ansis_default.reset,
120
+ underline: ansis_default.underline
121
+ };
122
+ //#endregion
123
+ export { colors as t };
@@ -1,4 +1,4 @@
1
- import { H as SharedState, y as DevToolsNodeContext } from "./devframe-DulcIxwu.mjs";
1
+ import { P as SharedState, d as DevToolsNodeContext } from "./devframe-BXZUBuy6.mjs";
2
2
 
3
3
  //#region src/node/internal/context.d.ts
4
4
  interface InternalAnonymousAuthStorage {