@devframes/plugin-inspect 0.8.0 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -7,7 +7,9 @@
7
7
  A devframe plugin that inspects *its own* connection (and, when mounted in a
8
8
  host, the host's): browse every registered RPC function with its metadata,
9
9
  invoke read-only `query`/`static` functions and inspect the results, watch
10
- shared-state keys update live, and explore the agent-exposed surface.
10
+ shared-state keys update live, explore the agent-exposed surface, and — while
11
+ running against a live backend — list the other devframe dev servers running
12
+ alongside it.
11
13
 
12
14
  Ported in spirit from the RPC & State panels of
13
15
  [`vitejs/devtools`](https://github.com/vitejs/devtools); rebuilt on devframe's
@@ -54,7 +56,10 @@ All functions are namespaced `devframes:plugin:inspect:*`:
54
56
  | `invoke` | `action` | Invokes a read-only `query`/`static` function by name and returns a result envelope. Refuses `action`/`event` functions. |
55
57
  | `list-state-keys` | `query` (snapshot) | The keys of every shared-state entry on the connection. |
56
58
  | `describe-agent` | `query` (snapshot) | The agent manifest — tools and readable resources. |
59
+ | `list-instances` | `query` (live) | Every devframe dev server currently running on the machine, discovered through the shared instance registry. Powers the read-only Instances tab. |
57
60
 
58
- The three `query` functions are agent-exposed (read-only) and bake into the
59
- static dump, so the inspector still lists functions, state keys, and the agent
60
- surface when deployed as a static SPA.
61
+ The three snapshot `query` functions are agent-exposed (read-only) and bake into
62
+ the static dump, so the inspector still lists functions, state keys, and the
63
+ agent surface when deployed as a static SPA. `list-instances` is live rather
64
+ than baked (the set of running processes is meaningless in a static dump), so
65
+ the Instances tab appears only against a live backend.
package/dist/cli.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as inspectDevframe } from "./src-C2-F9V7m.mjs";
1
+ import { n as inspectDevframe } from "./src-CzzEF2WN.mjs";
2
2
  import { createCac } from "devframe/adapters/cac";
3
3
  //#region src/cli.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { a as RpcFunctionInfo, i as RpcFunctionAgentInfo, n as DevframeInspectCommandInfo, r as InvokeResult, t as AgentManifest } from "../types-C1KvyFRp.mjs";
1
+ import { a as RpcFunctionAgentInfo, i as InvokeResult, n as DevframeInspectCommandInfo, o as RpcFunctionInfo, r as DevframeInspectInstanceInfo, t as AgentManifest } from "../types-_vo7QhmS.mjs";
2
2
  import { DevframeConnectionStatus, DevframeRpcClient, DevframeRpcClientOptions } from "devframe/client";
3
3
  //#region src/client/index.d.ts
4
4
  /**
@@ -8,4 +8,4 @@ import { DevframeConnectionStatus, DevframeRpcClient, DevframeRpcClientOptions }
8
8
  */
9
9
  declare function connectInspect(options?: DevframeRpcClientOptions): Promise<DevframeRpcClient>;
10
10
  //#endregion
11
- export { type AgentManifest, type DevframeConnectionStatus, type DevframeInspectCommandInfo, type DevframeRpcClient, type InvokeResult, type RpcFunctionAgentInfo, type RpcFunctionInfo, connectInspect };
11
+ export { type AgentManifest, type DevframeConnectionStatus, type DevframeInspectCommandInfo, type DevframeInspectInstanceInfo, type DevframeRpcClient, type InvokeResult, type RpcFunctionAgentInfo, type RpcFunctionInfo, connectInspect };
@@ -1,4 +1,4 @@
1
- import "./types-C1KvyFRp.mjs";
1
+ import "./types-_vo7QhmS.mjs";
2
2
  import { DevframeDefinition } from "devframe/types";
3
3
  //#region src/index.d.ts
4
4
  interface InspectDevframeOptions {
package/dist/index.d.mts CHANGED
@@ -1,3 +1,3 @@
1
- import { a as RpcFunctionInfo, r as InvokeResult } from "./types-C1KvyFRp.mjs";
2
- import { n as createInspectDevframe, r as inspectDevframe, t as InspectDevframeOptions } from "./index-HaJd7k1e.mjs";
1
+ import { i as InvokeResult, o as RpcFunctionInfo } from "./types-_vo7QhmS.mjs";
2
+ import { n as createInspectDevframe, r as inspectDevframe, t as InspectDevframeOptions } from "./index-B7KBbd3U.mjs";
3
3
  export { InspectDevframeOptions, type InvokeResult, type RpcFunctionInfo, createInspectDevframe, inspectDevframe as default };
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { n as inspectDevframe, t as createInspectDevframe } from "./src-C2-F9V7m.mjs";
1
+ import { n as inspectDevframe, t as createInspectDevframe } from "./src-CzzEF2WN.mjs";
2
2
  export { createInspectDevframe, inspectDevframe as default };
@@ -1,4 +1,4 @@
1
- import { t as serverFunctions } from "../rpc-N05JYFtw.mjs";
1
+ import { t as serverFunctions } from "../rpc-BCuMcHnd.mjs";
2
2
  //#region src/node/index.ts
3
3
  /**
4
4
  * Register the inspector's introspection RPC functions on a devframe
@@ -1,5 +1,5 @@
1
- import { a as RpcFunctionInfo, n as DevframeInspectCommandInfo, r as InvokeResult } from "../types-C1KvyFRp.mjs";
2
- import "../index-HaJd7k1e.mjs";
1
+ import { i as InvokeResult, n as DevframeInspectCommandInfo, o as RpcFunctionInfo, r as DevframeInspectInstanceInfo } from "../types-_vo7QhmS.mjs";
2
+ import "../index-B7KBbd3U.mjs";
3
3
  import { RpcDefinitionsToFunctions } from "devframe/rpc";
4
4
  //#region src/rpc/index.d.ts
5
5
  /**
@@ -118,6 +118,20 @@ declare const serverFunctions: readonly [{
118
118
  snapshot?: boolean;
119
119
  __cache?: WeakMap<object, import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[id: string, args?: unknown[] | undefined], Promise<InvokeResult>>>> | undefined;
120
120
  __promise?: import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[id: string, args?: unknown[] | undefined], Promise<InvokeResult>>> | undefined;
121
+ }, {
122
+ name: "devframes:plugin:inspect:list-instances";
123
+ type?: "query" | undefined;
124
+ cacheable?: boolean;
125
+ args?: undefined;
126
+ returns?: undefined;
127
+ jsonSerializable?: boolean;
128
+ agent?: import("devframe").RpcFunctionAgentOptions;
129
+ setup?: ((context: import("devframe").DevframeNodeContext) => import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[], Promise<DevframeInspectInstanceInfo[]>>>) | undefined;
130
+ handler?: (() => Promise<DevframeInspectInstanceInfo[]>) | undefined;
131
+ dump?: import("devframe/rpc").RpcDump<[], Promise<DevframeInspectInstanceInfo[]>, import("devframe").DevframeNodeContext> | undefined;
132
+ snapshot?: boolean;
133
+ __cache?: WeakMap<object, import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[], Promise<DevframeInspectInstanceInfo[]>>>> | undefined;
134
+ __promise?: import("devframe/rpc").Thenable<import("devframe/rpc").RpcFunctionSetupResult<[], Promise<DevframeInspectInstanceInfo[]>>> | undefined;
121
135
  }];
122
136
  declare module 'devframe' {
123
137
  interface DevframeRpcServerFunctions extends RpcDefinitionsToFunctions<typeof serverFunctions> {}
@@ -1,2 +1,2 @@
1
- import { t as serverFunctions } from "../rpc-N05JYFtw.mjs";
1
+ import { t as serverFunctions } from "../rpc-BCuMcHnd.mjs";
2
2
  export { serverFunctions };
@@ -1,6 +1,8 @@
1
1
  import { createDefineWrapperWithContext } from "devframe/rpc";
2
2
  import { defineDiagnostics } from "nostics";
3
3
  import { toJsonSchema } from "@valibot/to-json-schema";
4
+ import process from "node:process";
5
+ import { listLiveDevframeInstances } from "devframe/node";
4
6
  //#region src/rpc/functions/_define.ts
5
7
  /**
6
8
  * `defineRpcFunction` pre-bound to the framework-neutral
@@ -275,6 +277,89 @@ function argsSchemaToJson(args) {
275
277
  //#endregion
276
278
  //#region src/rpc/functions/list-functions.ts
277
279
  const INVOKABLE_TYPES = /* @__PURE__ */ new Set(["query", "static"]);
280
+ /**
281
+ * Enumerate every RPC function registered on the connection, projecting
282
+ * each definition's metadata into a JSON-safe {@link RpcFunctionInfo}.
283
+ * `snapshot: true` bakes the registry into the static dump so the
284
+ * inspector still lists functions in `build`/`spa` mode.
285
+ */
286
+ const listFunctions = defineInspectRpc({
287
+ name: "devframes:plugin:inspect:list-functions",
288
+ type: "query",
289
+ jsonSerializable: true,
290
+ snapshot: true,
291
+ agent: {
292
+ description: "List every RPC function registered on this devframe connection, with metadata (name, type, JSON-serializable/snapshot flags, args/return schema, agent exposure). Read-only — the canonical way to discover what the running devframe can do.",
293
+ title: "List RPC functions"
294
+ },
295
+ setup: (ctx) => ({ handler: async () => {
296
+ const out = [];
297
+ for (const [name, fn] of ctx.rpc.definitions) {
298
+ const type = fn.type ?? "query";
299
+ let agent;
300
+ if (fn.agent) agent = {
301
+ description: fn.agent.description,
302
+ title: fn.agent.title,
303
+ safety: fn.agent.safety,
304
+ tags: fn.agent.tags
305
+ };
306
+ out.push({
307
+ name,
308
+ type,
309
+ jsonSerializable: fn.jsonSerializable === true,
310
+ snapshot: fn.snapshot === true,
311
+ cacheable: fn.cacheable === true,
312
+ hasArgs: !!fn.args,
313
+ hasReturns: !!fn.returns,
314
+ hasDump: !!fn.dump,
315
+ hasSetup: !!fn.setup,
316
+ hasHandler: !!fn.handler,
317
+ invokable: INVOKABLE_TYPES.has(type),
318
+ agent,
319
+ argsSchema: argsSchemaToJson(fn.args),
320
+ returnsSchema: returnSchemaToJson(fn.returns)
321
+ });
322
+ }
323
+ out.sort((a, b) => a.name.localeCompare(b.name));
324
+ return out;
325
+ } })
326
+ });
327
+ //#endregion
328
+ //#region src/rpc/functions/list-instances.ts
329
+ /**
330
+ * Enumerate every devframe dev server currently running on this machine,
331
+ * discovered through the shared instance registry (`~/.devframe/instances/`)
332
+ * with a `__connection.json` liveness probe — the same discovery that backs
333
+ * the `devframe connect` bin. Powers the inspector's read-only Instances tab.
334
+ *
335
+ * Deliberately **not** `snapshot` (the set of live processes is meaningless
336
+ * baked into a static dump — the Instances tab is hidden in `build`/`spa`
337
+ * mode) and **not** agent-exposed (the `devframe connect` bin already offers
338
+ * instance discovery to agents over MCP, so exposing it here would duplicate
339
+ * that surface).
340
+ */
341
+ const listInstances = defineInspectRpc({
342
+ name: "devframes:plugin:inspect:list-instances",
343
+ type: "query",
344
+ jsonSerializable: true,
345
+ setup: () => ({ handler: async () => {
346
+ const { live } = await listLiveDevframeInstances();
347
+ const currentPid = process.pid;
348
+ return live.map((record) => ({
349
+ id: record.id,
350
+ name: record.name,
351
+ port: record.port,
352
+ origin: record.origin,
353
+ basePath: record.basePath,
354
+ url: `${record.origin}${record.basePath}`,
355
+ pid: record.pid,
356
+ rootDir: record.rootDir,
357
+ startedAt: record.startedAt,
358
+ hasMcp: record.mcp != null,
359
+ isCurrent: record.pid === currentPid
360
+ }));
361
+ } })
362
+ });
278
363
  //#endregion
279
364
  //#region src/rpc/index.ts
280
365
  /**
@@ -282,47 +367,7 @@ const INVOKABLE_TYPES = /* @__PURE__ */ new Set(["query", "static"]);
282
367
  * Namespaced `devframes:plugin:inspect:*` per the plugin convention.
283
368
  */
284
369
  const serverFunctions = [
285
- defineInspectRpc({
286
- name: "devframes:plugin:inspect:list-functions",
287
- type: "query",
288
- jsonSerializable: true,
289
- snapshot: true,
290
- agent: {
291
- description: "List every RPC function registered on this devframe connection, with metadata (name, type, JSON-serializable/snapshot flags, args/return schema, agent exposure). Read-only — the canonical way to discover what the running devframe can do.",
292
- title: "List RPC functions"
293
- },
294
- setup: (ctx) => ({ handler: async () => {
295
- const out = [];
296
- for (const [name, fn] of ctx.rpc.definitions) {
297
- const type = fn.type ?? "query";
298
- let agent;
299
- if (fn.agent) agent = {
300
- description: fn.agent.description,
301
- title: fn.agent.title,
302
- safety: fn.agent.safety,
303
- tags: fn.agent.tags
304
- };
305
- out.push({
306
- name,
307
- type,
308
- jsonSerializable: fn.jsonSerializable === true,
309
- snapshot: fn.snapshot === true,
310
- cacheable: fn.cacheable === true,
311
- hasArgs: !!fn.args,
312
- hasReturns: !!fn.returns,
313
- hasDump: !!fn.dump,
314
- hasSetup: !!fn.setup,
315
- hasHandler: !!fn.handler,
316
- invokable: INVOKABLE_TYPES.has(type),
317
- agent,
318
- argsSchema: argsSchemaToJson(fn.args),
319
- returnsSchema: returnSchemaToJson(fn.returns)
320
- });
321
- }
322
- out.sort((a, b) => a.name.localeCompare(b.name));
323
- return out;
324
- } })
325
- }),
370
+ listFunctions,
326
371
  invoke,
327
372
  defineInspectRpc({
328
373
  name: "devframes:plugin:inspect:list-state-keys",
@@ -365,7 +410,8 @@ const serverFunctions = [
365
410
  } })
366
411
  }),
367
412
  listCommands,
368
- executeCommand
413
+ executeCommand,
414
+ listInstances
369
415
  ];
370
416
  //#endregion
371
417
  export { serverFunctions as t };