@nifrajs/cli 2.1.0 → 2.3.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/README.md +25 -25
- package/dist/assure.d.ts +2 -2
- package/dist/assure.d.ts.map +1 -1
- package/dist/assure.js +17 -10
- package/dist/assure.js.map +1 -1
- package/dist/capabilities-tool.d.ts +7 -0
- package/dist/capabilities-tool.d.ts.map +1 -1
- package/dist/capabilities-tool.js +68 -16
- package/dist/capabilities-tool.js.map +1 -1
- package/dist/check.d.ts +64 -22
- package/dist/check.d.ts.map +1 -1
- package/dist/check.js +400 -83
- package/dist/check.js.map +1 -1
- package/dist/cli.d.ts +37 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +291 -53
- package/dist/cli.js.map +1 -1
- package/dist/diff-tool.d.ts +3 -3
- package/dist/diff-tool.js +7 -7
- package/dist/docs-search.d.ts +3 -3
- package/dist/docs-search.js +6 -6
- package/dist/doctor.d.ts +8 -4
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +74 -14
- package/dist/doctor.js.map +1 -1
- package/dist/examples.d.ts +5 -5
- package/dist/examples.js +5 -5
- package/dist/init-agents.d.ts +14 -14
- package/dist/init-agents.js +14 -14
- package/dist/internal/typescript-import.d.ts +24 -0
- package/dist/internal/typescript-import.d.ts.map +1 -0
- package/dist/internal/typescript-import.js +32 -0
- package/dist/internal/typescript-import.js.map +1 -0
- package/dist/introspect.d.ts +12 -12
- package/dist/introspect.js +24 -24
- package/dist/levels-tool.d.ts +8 -8
- package/dist/levels-tool.d.ts.map +1 -1
- package/dist/levels-tool.js +33 -30
- package/dist/levels-tool.js.map +1 -1
- package/dist/load.d.ts +17 -6
- package/dist/load.d.ts.map +1 -1
- package/dist/load.js +45 -7
- package/dist/load.js.map +1 -1
- package/dist/manifest-tool.d.ts +1 -1
- package/dist/manifest-tool.d.ts.map +1 -1
- package/dist/manifest-tool.js +4 -2
- package/dist/manifest-tool.js.map +1 -1
- package/dist/mcp-docs-tools.d.ts +1 -1
- package/dist/mcp-docs-tools.d.ts.map +1 -1
- package/dist/mcp-docs-tools.js +14 -10
- package/dist/mcp-docs-tools.js.map +1 -1
- package/dist/mcp-http.d.ts +5 -5
- package/dist/mcp-http.js +7 -7
- package/dist/mcp-protocol.d.ts +2 -2
- package/dist/mcp-protocol.js +2 -2
- package/dist/mcp-render.d.ts +3 -3
- package/dist/mcp-render.js +15 -7
- package/dist/mcp-render.js.map +1 -1
- package/dist/mcp-run.d.ts +2 -2
- package/dist/mcp-run.js +2 -2
- package/dist/mcp.d.ts +14 -14
- package/dist/mcp.d.ts.map +1 -1
- package/dist/mcp.js +119 -47
- package/dist/mcp.js.map +1 -1
- package/dist/openapi-tool.d.ts +1 -1
- package/dist/openapi-tool.js +2 -2
- package/dist/pipeline-guard.d.ts +83 -0
- package/dist/pipeline-guard.d.ts.map +1 -0
- package/dist/pipeline-guard.js +136 -0
- package/dist/pipeline-guard.js.map +1 -0
- package/dist/port.d.ts +9 -9
- package/dist/port.js +27 -27
- package/dist/recipes/1.8.0.d.ts +2 -2
- package/dist/recipes/1.8.0.js +5 -5
- package/dist/recipes/index.d.ts +2 -2
- package/dist/recipes/index.js +1 -1
- package/dist/scaffold.d.ts +3 -3
- package/dist/scaffold.js +8 -8
- package/dist/sync-routes.d.ts +28 -0
- package/dist/sync-routes.d.ts.map +1 -0
- package/dist/sync-routes.js +55 -0
- package/dist/sync-routes.js.map +1 -0
- package/dist/types-search.d.ts +6 -6
- package/dist/types-search.d.ts.map +1 -1
- package/dist/types-search.js +53 -8
- package/dist/types-search.js.map +1 -1
- package/dist/upgrade.d.ts +7 -7
- package/dist/upgrade.js +12 -12
- package/dist/verification.d.ts +51 -0
- package/dist/verification.d.ts.map +1 -0
- package/dist/verification.js +80 -0
- package/dist/verification.js.map +1 -0
- package/docs/examples.json +178 -88
- package/docs/llms-full.txt +1766 -766
- package/docs/types.json +2171 -2807
- package/package.json +22 -11
- package/src/assure.ts +17 -18
- package/src/capabilities-tool.ts +82 -16
- package/src/check.ts +493 -100
- package/src/cli.ts +306 -54
- package/src/diff-tool.ts +8 -8
- package/src/docs-search.ts +6 -6
- package/src/doctor.ts +81 -16
- package/src/examples.ts +7 -7
- package/src/init-agents.ts +17 -17
- package/src/internal/typescript-import.ts +33 -0
- package/src/introspect.ts +28 -28
- package/src/levels-tool.ts +37 -31
- package/src/load.ts +65 -12
- package/src/manifest-tool.ts +4 -2
- package/src/mcp-docs-tools.ts +20 -10
- package/src/mcp-http.ts +7 -7
- package/src/mcp-protocol.ts +2 -2
- package/src/mcp-render.ts +15 -7
- package/src/mcp-run.ts +2 -2
- package/src/mcp.ts +127 -47
- package/src/openapi-tool.ts +2 -2
- package/src/pipeline-guard.ts +186 -0
- package/src/port.ts +31 -31
- package/src/recipes/1.8.0.ts +5 -5
- package/src/recipes/index.ts +2 -2
- package/src/scaffold.ts +8 -8
- package/src/sync-routes.ts +69 -0
- package/src/types-search.ts +57 -8
- package/src/upgrade.ts +12 -12
- package/src/verification.ts +123 -0
package/dist/mcp-protocol.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The MCP JSON-RPC dispatch now lives in `@nifrajs/mcp` (shared with nifra apps that expose their own
|
|
3
|
-
* MCP server / MCP Apps widgets). This module is a thin re-export so the CLI's existing imports
|
|
4
|
-
* the `@nifrajs/cli/mcp` self-host surface
|
|
3
|
+
* MCP server / MCP Apps widgets). This module is a thin re-export so the CLI's existing imports - and
|
|
4
|
+
* the `@nifrajs/cli/mcp` self-host surface - keep resolving here unchanged.
|
|
5
5
|
*/
|
|
6
6
|
export * from "@nifrajs/mcp/protocol";
|
|
7
7
|
//# sourceMappingURL=mcp-protocol.js.map
|
package/dist/mcp-render.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The `nifra_render` engine + its child-process entry
|
|
2
|
+
* The `nifra_render` engine + its child-process entry - the page half of `nifra_run`. Where `nifra_run`
|
|
3
3
|
* runs requests through the BACKEND, this SSRs page routes through the WEB app (`createWebApp`), so an
|
|
4
4
|
* agent can verify a page renders and its loader ran after an edit. Spawned fresh per call (`bun
|
|
5
5
|
* mcp-render.ts <cwd>`) so the project's CURRENT route/loader code is loaded.
|
|
6
6
|
*
|
|
7
|
-
* No build required: a placeholder `clientEntry` is injected (the SSR HTML renders regardless
|
|
7
|
+
* No build required: a placeholder `clientEntry` is injected (the SSR HTML renders regardless - the
|
|
8
8
|
* client bundle only matters for hydration in the browser, not for "did this page render server-side").
|
|
9
|
-
* {@link renderPages} never throws
|
|
9
|
+
* {@link renderPages} never throws - every failure (no config, a loader error, a render throw) becomes
|
|
10
10
|
* `{ error }` so the agent gets the actionable message.
|
|
11
11
|
*/
|
|
12
12
|
export declare function renderPages(cwd: string, requests: unknown): Promise<{
|
package/dist/mcp-render.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The `nifra_render` engine + its child-process entry
|
|
2
|
+
* The `nifra_render` engine + its child-process entry - the page half of `nifra_run`. Where `nifra_run`
|
|
3
3
|
* runs requests through the BACKEND, this SSRs page routes through the WEB app (`createWebApp`), so an
|
|
4
4
|
* agent can verify a page renders and its loader ran after an edit. Spawned fresh per call (`bun
|
|
5
5
|
* mcp-render.ts <cwd>`) so the project's CURRENT route/loader code is loaded.
|
|
6
6
|
*
|
|
7
|
-
* No build required: a placeholder `clientEntry` is injected (the SSR HTML renders regardless
|
|
7
|
+
* No build required: a placeholder `clientEntry` is injected (the SSR HTML renders regardless - the
|
|
8
8
|
* client bundle only matters for hydration in the browser, not for "did this page render server-side").
|
|
9
|
-
* {@link renderPages} never throws
|
|
9
|
+
* {@link renderPages} never throws - every failure (no config, a loader error, a render throw) becomes
|
|
10
10
|
* `{ error }` so the agent gets the actionable message.
|
|
11
11
|
*/
|
|
12
12
|
import { inProcessClient } from "@nifrajs/client";
|
|
@@ -15,7 +15,7 @@ import { createWebApp } from "@nifrajs/web";
|
|
|
15
15
|
import { discoverRoutes } from "@nifrajs/web/fs";
|
|
16
16
|
import { loadApp, resolvePlugins } from "./load.js";
|
|
17
17
|
const errString = (err) => err instanceof Error ? `${err.name}: ${err.message}` : String(err);
|
|
18
|
-
/** Load the project, register its SSR plugins, and build the SSR `createWebApp` once
|
|
18
|
+
/** Load the project, register its SSR plugins, and build the SSR `createWebApp` once - the cost the warm
|
|
19
19
|
* worker amortizes across calls. Never throws (every failure → `{ error }`). Factored out of
|
|
20
20
|
* {@link renderPages} so the cold path (fresh process per call) and the warm worker share one builder. */
|
|
21
21
|
async function buildWebApp(cwd) {
|
|
@@ -79,7 +79,7 @@ function redirectConsoleToStderr() {
|
|
|
79
79
|
/**
|
|
80
80
|
* Warm-worker loop (`--worker`): build the web app ONCE, then SSR each `{ id, input: { requests } }` line
|
|
81
81
|
* against that hot app and reply `{ id, output }`. The parent (`mcp.ts`'s warm-render handler) spawns this,
|
|
82
|
-
* fingerprints the source tree, and restarts the worker when a file changes
|
|
82
|
+
* fingerprints the source tree, and restarts the worker when a file changes - so warm reuse never serves a
|
|
83
83
|
* stale render. Mirrors `mcp-run.ts`'s worker (single backend entry → no per-call entry key needed here).
|
|
84
84
|
*/
|
|
85
85
|
async function runWorker(cwd) {
|
|
@@ -136,7 +136,7 @@ if (import.meta.main) {
|
|
|
136
136
|
// The parent (mcp.ts) spawns `bun mcp-render.ts <cwd>` WITHOUT setting the subprocess `cwd` option, so
|
|
137
137
|
// this process inherits the MCP server's working dir, not the app's. SSR resolves `react-dom/server`
|
|
138
138
|
// from `process.cwd()` to share ONE React core with the app's route components (the dual-React fix in
|
|
139
|
-
// @nifrajs/web-react)
|
|
139
|
+
// @nifrajs/web-react) - so we must chdir to the app root before any render. Best-effort: a bad path
|
|
140
140
|
// surfaces later as a load error rather than crashing the child here.
|
|
141
141
|
if (cwd !== process.cwd()) {
|
|
142
142
|
try {
|
|
@@ -159,6 +159,14 @@ if (import.meta.main) {
|
|
|
159
159
|
catch {
|
|
160
160
|
output = { error: "invalid input: expected JSON { requests: [...] }" };
|
|
161
161
|
}
|
|
162
|
-
|
|
162
|
+
await Bun.write(Bun.stdout, JSON.stringify(output, null, 2));
|
|
163
|
+
// Exit explicitly, exactly as the `--worker` branch above already does.
|
|
164
|
+
//
|
|
165
|
+
// Loading the app runs its module side effects, and a real app opens things: a database pool, a
|
|
166
|
+
// Redis client, a metrics interval. Any one of those keeps the event loop alive, so falling off
|
|
167
|
+
// the end of this module never terminates the process - and the parent is sitting in
|
|
168
|
+
// `await proc.exited`. The render itself finished; there is nothing left to wait for, and this
|
|
169
|
+
// process is single-use. `Bun.write` above is awaited so the output is flushed before we exit.
|
|
170
|
+
process.exit(0);
|
|
163
171
|
}
|
|
164
172
|
//# sourceMappingURL=mcp-render.js.map
|
package/dist/mcp-render.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-render.js","sourceRoot":"","sources":["../src/mcp-render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAgB,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACtD,OAAO,EAAE,YAAY,EAAsB,MAAM,cAAc,CAAA;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAEnD,MAAM,SAAS,GAAG,CAAC,GAAY,EAAU,EAAE,CACzC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;AAEpE;;0GAE0G;AAC1G,KAAK,UAAU,WAAW,CAAC,GAAW;IACpC,IAAI,GAAwC,CAAA;IAC5C,IAAI,CAAC;QACH,GAAG,GAAG,MAA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,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QACtC,MAAM,SAAS,CAAC,GAAG,CAAC,CAAA;QACpB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;IACD,IAAI,MAAe,CAAA;IACnB,IAAI,CAAC;QACH,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAA0B,CAAA;QAChF,MAAM,GAAG,MAAM,WAAW,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;IAC3C,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,GAAG,EAAE,KAAK,EAAE,kDAAkD,EAAE,CAAA;IACxE,CAAC;IACD,MAAM,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;IAC5D,wEAAwE;IACxE,EAAE;IACF,gGAAgG;IAChG,gGAAgG;IAChG,qFAAqF;IACrF,+FAA+F;IAC/F,+FAA+F;IAC/F,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC"}
|
package/dist/mcp-run.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The `nifra_run` engine + its child-process entry. The MCP server spawns this file fresh on every
|
|
3
|
-
* `nifra_run` call (`bun mcp-run.ts <cwd>`) so the project's CURRENT backend code is loaded
|
|
3
|
+
* `nifra_run` call (`bun mcp-run.ts <cwd>`) so the project's CURRENT backend code is loaded - picking
|
|
4
4
|
* up the agent's latest edits. {@link runBackend} is the pure-ish core (resolve entry → import → run),
|
|
5
5
|
* exported so it's unit-testable in-process; the entry below wires it to stdin/stdout.
|
|
6
6
|
*/
|
|
@@ -12,7 +12,7 @@ export declare function loadBackend(cwd: string, entry?: string): Promise<{
|
|
|
12
12
|
}>;
|
|
13
13
|
/**
|
|
14
14
|
* Resolve the backend entry under `cwd`, import it, and run `requests` through its exported app. Never
|
|
15
|
-
* throws
|
|
15
|
+
* throws - every failure (missing/invalid entry, import/compile/runtime error) becomes `{ error }`, so
|
|
16
16
|
* the caller (and the agent) always gets actionable output. An import error here IS the failure the
|
|
17
17
|
* agent needs to see and fix.
|
|
18
18
|
*/
|
package/dist/mcp-run.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The `nifra_run` engine + its child-process entry. The MCP server spawns this file fresh on every
|
|
3
|
-
* `nifra_run` call (`bun mcp-run.ts <cwd>`) so the project's CURRENT backend code is loaded
|
|
3
|
+
* `nifra_run` call (`bun mcp-run.ts <cwd>`) so the project's CURRENT backend code is loaded - picking
|
|
4
4
|
* up the agent's latest edits. {@link runBackend} is the pure-ish core (resolve entry → import → run),
|
|
5
5
|
* exported so it's unit-testable in-process; the entry below wires it to stdin/stdout.
|
|
6
6
|
*/
|
|
@@ -47,7 +47,7 @@ export async function loadBackend(cwd, entry) {
|
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* Resolve the backend entry under `cwd`, import it, and run `requests` through its exported app. Never
|
|
50
|
-
* throws
|
|
50
|
+
* throws - every failure (missing/invalid entry, import/compile/runtime error) becomes `{ error }`, so
|
|
51
51
|
* the caller (and the agent) always gets actionable output. An import error here IS the failure the
|
|
52
52
|
* agent needs to see and fix.
|
|
53
53
|
*/
|
package/dist/mcp.d.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `nifra mcp`
|
|
2
|
+
* `nifra mcp` - a Model Context Protocol server (stdio) that lets a coding agent (Claude, Cursor, …)
|
|
3
3
|
* act on a nifra project, not just read about it:
|
|
4
4
|
*
|
|
5
|
-
* - `nifra_context`
|
|
6
|
-
* - `nifra_run`
|
|
5
|
+
* - `nifra_context` - this project's API routes + page routes + conventions (see {@link describeProject}).
|
|
6
|
+
* - `nifra_run` - run HTTP requests through the project's backend and return structured results
|
|
7
7
|
* (status, body, errors). The write → run → see-the-failure → fix loop, powered by `@nifrajs/runner`.
|
|
8
8
|
* Each call runs the backend in a FRESH subprocess, so it reflects the agent's latest edits.
|
|
9
|
-
* - `nifra_render`
|
|
9
|
+
* - `nifra_render` - SSR a page route through the project's web app; returns the rendered HTML (the
|
|
10
10
|
* page half of `nifra_run`). Fresh subprocess per call; no build needed.
|
|
11
|
-
* - `nifra_ws`
|
|
12
|
-
* - `nifra_docs`
|
|
13
|
-
* - `nifra_example`
|
|
11
|
+
* - `nifra_ws` - verify a WebSocket route with a real Bun WebSocket round-trip.
|
|
12
|
+
* - `nifra_docs` - keyword-search the framework docs; returns only the matching sections.
|
|
13
|
+
* - `nifra_example` - a verified, copy-pasteable snippet for a task (typechecked against the live API,
|
|
14
14
|
* so it can't hallucinate a drifted nifra API).
|
|
15
|
-
* - `nifra_scaffold
|
|
16
|
-
* - `nifra_check`
|
|
17
|
-
* - `nifra_assure`
|
|
15
|
+
* - `nifra_scaffold`- map a URL path to the correct `routes/` file + a contract-correct page stub.
|
|
16
|
+
* - `nifra_check` - the drift gate (typecheck + lints, each with a structured fix), for an agent to fix against.
|
|
17
|
+
* - `nifra_assure` - route classification + enforcement-evidence gate.
|
|
18
18
|
* - `nifra_levels` - the cumulative verification ladder (L0 contract → L4 invariants): what the
|
|
19
19
|
* project actually proves, and why each level it misses does not hold.
|
|
20
|
-
* - `nifra_doctor`
|
|
20
|
+
* - `nifra_doctor` - package.json dependency drift detector, with safe local-version auto-fix.
|
|
21
21
|
*
|
|
22
22
|
* Wire it into a client (e.g. Claude Desktop / Cursor) as: command `nifra`, args `["mcp"]`, run in the
|
|
23
23
|
* project root. The protocol is hand-rolled (newline-delimited JSON-RPC 2.0 over stdio), including
|
|
24
|
-
* standard MCP progress notifications and request cancellation
|
|
24
|
+
* standard MCP progress notifications and request cancellation - no SDK dependency, the same
|
|
25
25
|
* minimal-surface choice as the rest of nifra. The pure dispatch lives in `./mcp-protocol.ts`; this
|
|
26
26
|
* module is the I/O shell (stdin loop, tool wiring, the run subprocess).
|
|
27
27
|
*/
|
|
@@ -29,7 +29,7 @@ import type { LoadAppOptions, LoadedApp } from "./load.js";
|
|
|
29
29
|
import { type McpPrompt, type McpResource, type McpServerFeatures, type McpTool } from "./mcp-protocol.js";
|
|
30
30
|
/** A persistent `mcp-run`/`mcp-render` `--worker` subprocess: the backend/web app is loaded ONCE and
|
|
31
31
|
* reused across newline-delimited `{ id, input }` requests, replying `{ id, output }`. The same machinery
|
|
32
|
-
* powers both `nifra_run warm` and `nifra_render warm`
|
|
32
|
+
* powers both `nifra_run warm` and `nifra_render warm` - `child` selects which engine, `label` shapes the
|
|
33
33
|
* cancellation message. The owning handler ({@link createWarmHandler}) fingerprints the source tree and
|
|
34
34
|
* replaces the worker when a file changes, so warm reuse never serves a stale result. Exported for the
|
|
35
35
|
* concurrency test that proves a single per-request cancel doesn't tear down the shared worker. */
|
|
@@ -60,7 +60,7 @@ export declare function projectResources(cwd: string, loadAppCached?: (outDirNam
|
|
|
60
60
|
export declare function projectPrompts(): McpPrompt[];
|
|
61
61
|
export declare function projectFeatures(cwd: string, loadAppCached?: (outDirName?: string) => Promise<LoadedApp>): McpServerFeatures;
|
|
62
62
|
/**
|
|
63
|
-
* Resolve an optional `dir` tool argument
|
|
63
|
+
* Resolve an optional `dir` tool argument - a subdirectory of the project root the caller wants to scope a
|
|
64
64
|
* check/test to (e.g. `nifra check` on `app/` when the MCP server's root is a monorepo). Returns the
|
|
65
65
|
* absolute target, or `null` if `dir` escapes the root (a path-traversal guard: no `..` out, no absolute
|
|
66
66
|
* path elsewhere). `undefined`/empty → the root itself.
|
package/dist/mcp.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;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OAAO,GAAG,SAAS,EAAE,CAgBnE;AA2ED,uGAAuG;AACvG,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA8E9E"}
|
package/dist/mcp.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `nifra mcp`
|
|
2
|
+
* `nifra mcp` - a Model Context Protocol server (stdio) that lets a coding agent (Claude, Cursor, …)
|
|
3
3
|
* act on a nifra project, not just read about it:
|
|
4
4
|
*
|
|
5
|
-
* - `nifra_context`
|
|
6
|
-
* - `nifra_run`
|
|
5
|
+
* - `nifra_context` - this project's API routes + page routes + conventions (see {@link describeProject}).
|
|
6
|
+
* - `nifra_run` - run HTTP requests through the project's backend and return structured results
|
|
7
7
|
* (status, body, errors). The write → run → see-the-failure → fix loop, powered by `@nifrajs/runner`.
|
|
8
8
|
* Each call runs the backend in a FRESH subprocess, so it reflects the agent's latest edits.
|
|
9
|
-
* - `nifra_render`
|
|
9
|
+
* - `nifra_render` - SSR a page route through the project's web app; returns the rendered HTML (the
|
|
10
10
|
* page half of `nifra_run`). Fresh subprocess per call; no build needed.
|
|
11
|
-
* - `nifra_ws`
|
|
12
|
-
* - `nifra_docs`
|
|
13
|
-
* - `nifra_example`
|
|
11
|
+
* - `nifra_ws` - verify a WebSocket route with a real Bun WebSocket round-trip.
|
|
12
|
+
* - `nifra_docs` - keyword-search the framework docs; returns only the matching sections.
|
|
13
|
+
* - `nifra_example` - a verified, copy-pasteable snippet for a task (typechecked against the live API,
|
|
14
14
|
* so it can't hallucinate a drifted nifra API).
|
|
15
|
-
* - `nifra_scaffold
|
|
16
|
-
* - `nifra_check`
|
|
17
|
-
* - `nifra_assure`
|
|
15
|
+
* - `nifra_scaffold`- map a URL path to the correct `routes/` file + a contract-correct page stub.
|
|
16
|
+
* - `nifra_check` - the drift gate (typecheck + lints, each with a structured fix), for an agent to fix against.
|
|
17
|
+
* - `nifra_assure` - route classification + enforcement-evidence gate.
|
|
18
18
|
* - `nifra_levels` - the cumulative verification ladder (L0 contract → L4 invariants): what the
|
|
19
19
|
* project actually proves, and why each level it misses does not hold.
|
|
20
|
-
* - `nifra_doctor`
|
|
20
|
+
* - `nifra_doctor` - package.json dependency drift detector, with safe local-version auto-fix.
|
|
21
21
|
*
|
|
22
22
|
* Wire it into a client (e.g. Claude Desktop / Cursor) as: command `nifra`, args `["mcp"]`, run in the
|
|
23
23
|
* project root. The protocol is hand-rolled (newline-delimited JSON-RPC 2.0 over stdio), including
|
|
24
|
-
* standard MCP progress notifications and request cancellation
|
|
24
|
+
* standard MCP progress notifications and request cancellation - no SDK dependency, the same
|
|
25
25
|
* minimal-surface choice as the rest of nifra. The pure dispatch lives in `./mcp-protocol.ts`; this
|
|
26
26
|
* module is the I/O shell (stdin loop, tool wiring, the run subprocess).
|
|
27
27
|
*/
|
|
@@ -43,6 +43,23 @@ function childPath(name) {
|
|
|
43
43
|
return fileURLToPath(new URL(import.meta.url)).replace(/mcp\.(ts|js)$/, `${name}.$1`);
|
|
44
44
|
}
|
|
45
45
|
/** Spawn `bun <child> <cwd>`, pipe `input` to its stdin, return its stdout (or a stderr-backed error). */
|
|
46
|
+
/**
|
|
47
|
+
* How long a child gets before it is killed.
|
|
48
|
+
*
|
|
49
|
+
* A child loads the app, which runs its module side effects - a database pool, a Redis client, a
|
|
50
|
+
* metrics interval. Any of those keeps the child's event loop alive after the work is done, and the
|
|
51
|
+
* parent is sitting in `await proc.exited`. The children now exit explicitly, so this is the backstop
|
|
52
|
+
* rather than the fix: without it a single wedged child blocks an agent indefinitely, and the caller
|
|
53
|
+
* has no way to tell "still working" from "never returning".
|
|
54
|
+
*
|
|
55
|
+
* Generous enough for a cold start that compiles route modules, short enough that a hang is reported
|
|
56
|
+
* within one attention span rather than after minutes of polling.
|
|
57
|
+
*/
|
|
58
|
+
const CHILD_TIMEOUT_MS = 30_000;
|
|
59
|
+
const timeoutMessage = (label, ms) => `${label} timed out after ${ms / 1000}s and was terminated.\n` +
|
|
60
|
+
`The app was loaded but the process did not finish. Most often this is a module-level side effect ` +
|
|
61
|
+
`that keeps the event loop alive (a database pool, a Redis client, an interval) opened during import ` +
|
|
62
|
+
`rather than lazily. Check for top-level connections in the app entry or anything it imports.`;
|
|
46
63
|
async function spawnChild(child, cwd, input, label, signal) {
|
|
47
64
|
if (signal?.aborted)
|
|
48
65
|
return `${label} cancelled before it started.`;
|
|
@@ -53,6 +70,11 @@ async function spawnChild(child, cwd, input, label, signal) {
|
|
|
53
70
|
});
|
|
54
71
|
const abort = () => proc.kill();
|
|
55
72
|
signal?.addEventListener("abort", abort, { once: true });
|
|
73
|
+
let timedOut = false;
|
|
74
|
+
const timer = setTimeout(() => {
|
|
75
|
+
timedOut = true;
|
|
76
|
+
proc.kill();
|
|
77
|
+
}, CHILD_TIMEOUT_MS);
|
|
56
78
|
try {
|
|
57
79
|
proc.stdin.write(JSON.stringify(input));
|
|
58
80
|
await proc.stdin.end();
|
|
@@ -65,9 +87,15 @@ async function spawnChild(child, cwd, input, label, signal) {
|
|
|
65
87
|
const reason = typeof signal.reason === "string" ? `: ${signal.reason}` : "";
|
|
66
88
|
return `${label} cancelled${reason}.`;
|
|
67
89
|
}
|
|
68
|
-
|
|
90
|
+
// A killed child may still have flushed a complete result before the timer fired; prefer real
|
|
91
|
+
// output over the timeout message so a slow-but-successful render is not reported as a failure.
|
|
92
|
+
const text = out.trim();
|
|
93
|
+
if (timedOut && text === "")
|
|
94
|
+
return timeoutMessage(label, CHILD_TIMEOUT_MS);
|
|
95
|
+
return text || `${label} failed:\n${err.trim() || "(no output)"}`;
|
|
69
96
|
}
|
|
70
97
|
finally {
|
|
98
|
+
clearTimeout(timer);
|
|
71
99
|
signal?.removeEventListener("abort", abort);
|
|
72
100
|
}
|
|
73
101
|
}
|
|
@@ -99,7 +127,7 @@ function boundedAppend(current, next, max = 12_000) {
|
|
|
99
127
|
}
|
|
100
128
|
/** A persistent `mcp-run`/`mcp-render` `--worker` subprocess: the backend/web app is loaded ONCE and
|
|
101
129
|
* reused across newline-delimited `{ id, input }` requests, replying `{ id, output }`. The same machinery
|
|
102
|
-
* powers both `nifra_run warm` and `nifra_render warm`
|
|
130
|
+
* powers both `nifra_run warm` and `nifra_render warm` - `child` selects which engine, `label` shapes the
|
|
103
131
|
* cancellation message. The owning handler ({@link createWarmHandler}) fingerprints the source tree and
|
|
104
132
|
* replaces the worker when a file changes, so warm reuse never serves a stale result. Exported for the
|
|
105
133
|
* concurrency test that proves a single per-request cancel doesn't tear down the shared worker. */
|
|
@@ -147,12 +175,26 @@ export class WarmWorker {
|
|
|
147
175
|
// Per-request cancel: drop just THIS id and resolve its cancellation. The worker is shared
|
|
148
176
|
// across concurrent requests (`pending` is id-keyed for exactly this reason), so killing the
|
|
149
177
|
// process here would reject every OTHER in-flight request via the `exited` handler and force a
|
|
150
|
-
// cold rebuild. Leave it hot
|
|
178
|
+
// cold rebuild. Leave it hot - `createWarmHandler` already replaces it on file change.
|
|
151
179
|
this.pending.delete(id);
|
|
180
|
+
clearTimeout(timer);
|
|
152
181
|
const reason = typeof signal?.reason === "string" ? `: ${signal.reason}` : "";
|
|
153
182
|
resolve(`${this.label} cancelled${reason}.`);
|
|
154
183
|
};
|
|
155
|
-
|
|
184
|
+
// Same backstop as the cold path: a worker wedged mid-request would otherwise leave this
|
|
185
|
+
// promise unsettled forever. Drop the id and replace the worker - unlike a per-request cancel,
|
|
186
|
+
// a timeout means the worker itself is suspect, so the next call should start from a fresh one.
|
|
187
|
+
const timer = setTimeout(() => {
|
|
188
|
+
if (!this.pending.delete(id))
|
|
189
|
+
return;
|
|
190
|
+
signal?.removeEventListener("abort", abort);
|
|
191
|
+
this.stop();
|
|
192
|
+
resolve(timeoutMessage(this.label, CHILD_TIMEOUT_MS));
|
|
193
|
+
}, CHILD_TIMEOUT_MS);
|
|
194
|
+
const cleanup = () => {
|
|
195
|
+
clearTimeout(timer);
|
|
196
|
+
signal?.removeEventListener("abort", abort);
|
|
197
|
+
};
|
|
156
198
|
signal?.addEventListener("abort", abort, { once: true });
|
|
157
199
|
this.pending.set(id, { resolve, reject, cleanup });
|
|
158
200
|
try {
|
|
@@ -214,7 +256,7 @@ export class WarmWorker {
|
|
|
214
256
|
}
|
|
215
257
|
/** A warm handler that reuses a hot {@link WarmWorker} across calls and falls back to a one-shot fresh
|
|
216
258
|
* subprocess on any worker failure. Shared by `nifra_run` (`child: "mcp-run"`, `label: "run"`) and
|
|
217
|
-
* `nifra_render` (`child: "mcp-render"`, `label: "render"`)
|
|
259
|
+
* `nifra_render` (`child: "mcp-render"`, `label: "render"`) - the only differences are the engine and the
|
|
218
260
|
* message label, so there's a single source for the reuse + auto-restart-on-file-change logic. */
|
|
219
261
|
function createWarmHandler(child, cwd, label) {
|
|
220
262
|
let worker;
|
|
@@ -442,7 +484,7 @@ export function projectFeatures(cwd, loadAppCached = createCachedAppLoader(cwd))
|
|
|
442
484
|
return { resources: projectResources(cwd, loadAppCached), prompts: projectPrompts() };
|
|
443
485
|
}
|
|
444
486
|
/**
|
|
445
|
-
* Resolve an optional `dir` tool argument
|
|
487
|
+
* Resolve an optional `dir` tool argument - a subdirectory of the project root the caller wants to scope a
|
|
446
488
|
* check/test to (e.g. `nifra check` on `app/` when the MCP server's root is a monorepo). Returns the
|
|
447
489
|
* absolute target, or `null` if `dir` escapes the root (a path-traversal guard: no `..` out, no absolute
|
|
448
490
|
* path elsewhere). `undefined`/empty → the root itself.
|
|
@@ -455,7 +497,7 @@ export function resolveProjectDir(root, dir) {
|
|
|
455
497
|
}
|
|
456
498
|
/** Consistent error string for a `dir` that escapes the project root. */
|
|
457
499
|
function dirError(dir) {
|
|
458
|
-
return JSON.stringify({ ok: false, error: `dir must be a subdirectory of the project root
|
|
500
|
+
return JSON.stringify({ ok: false, error: `dir must be a subdirectory of the project root - "${dir}" escapes it.` }, null, 2);
|
|
459
501
|
}
|
|
460
502
|
/** Build the project-scoped tools for `cwd`. */
|
|
461
503
|
export function projectTools(cwd, loadAppCached = createCachedAppLoader(cwd)) {
|
|
@@ -464,7 +506,7 @@ export function projectTools(cwd, loadAppCached = createCachedAppLoader(cwd)) {
|
|
|
464
506
|
return [
|
|
465
507
|
{
|
|
466
508
|
name: "nifra_context",
|
|
467
|
-
description: "Get this nifra project's surface. Call it once UNFILTERED for a tight INDEX: the route list (API routes as `METHOD path`, page routes as `pattern → file`) + framework conventions + a pointer
|
|
509
|
+
description: "Get this nifra project's surface. Call it once UNFILTERED for a tight INDEX: the route list (API routes as `METHOD path`, page routes as `pattern → file`) + framework conventions + a pointer - cheap even on a big app, no per-route schema dump. Then pass `path` (a route prefix like /api/orders) and/or `kind` (api|pages) to fetch the FULL contract for that slice (body/query/response TS shapes + the exact typed-client call form).",
|
|
468
510
|
inputSchema: {
|
|
469
511
|
type: "object",
|
|
470
512
|
properties: {
|
|
@@ -487,7 +529,7 @@ export function projectTools(cwd, loadAppCached = createCachedAppLoader(cwd)) {
|
|
|
487
529
|
},
|
|
488
530
|
{
|
|
489
531
|
name: "nifra_routes",
|
|
490
|
-
description: "List this project's API routes as STRUCTURED JSON
|
|
532
|
+
description: "List this project's API routes as STRUCTURED JSON - each `{ method, path, call, body?, query?, response? }`, where `call` is the exact typed-client call form and the shapes are compact TS-typed contracts. For programmatic use (list_routes / get_route_schema) instead of parsing the nifra_context Markdown. No args = every route; pass `path` (a path or prefix like /api/orders) to narrow to those routes.",
|
|
491
533
|
inputSchema: {
|
|
492
534
|
type: "object",
|
|
493
535
|
properties: {
|
|
@@ -652,7 +694,7 @@ export function projectTools(cwd, loadAppCached = createCachedAppLoader(cwd)) {
|
|
|
652
694
|
...docsTools(loadDocsCorpus, loadExamplesCorpus, loadTypesCorpus),
|
|
653
695
|
{
|
|
654
696
|
name: "nifra_scaffold",
|
|
655
|
-
description: 'Map a URL path to the CORRECT routes/ file and get a contract-correct page stub. Agents routinely place file routes wrong
|
|
697
|
+
description: 'Map a URL path to the CORRECT routes/ file and get a contract-correct page stub. Agents routinely place file routes wrong - this applies the convention for you: ":id"/"[id]" → [id], "*rest" → [...rest], "/" → index. Pass path (e.g. "/users/:id"). Returns the file to create + the route-module contract (loader/action/meta/default) + a stub (ready-to-write for react/preact/solid; path+contract for vue/svelte/vanilla - use nifra_example for those bodies).',
|
|
656
698
|
inputSchema: {
|
|
657
699
|
type: "object",
|
|
658
700
|
properties: {
|
|
@@ -686,7 +728,7 @@ export function projectTools(cwd, loadAppCached = createCachedAppLoader(cwd)) {
|
|
|
686
728
|
},
|
|
687
729
|
{
|
|
688
730
|
name: "nifra_check",
|
|
689
|
-
description: 'Run the project\'s drift gate and return a structured result { ok, typecheck, diagnostics[] }: typecheck (the frontend↔backend contract), plus lints for hand-rolled fetch() to your own API, untyped client("…") calls missing <typeof app>, and server-only imports in routes/. Pass lintsOnly:true for a near-instant lint pass while iterating; run the full gate (default) to confirm the work is done
|
|
731
|
+
description: 'Run the project\'s drift gate and return a structured result { ok, typecheck, diagnostics[] }: typecheck (the frontend↔backend contract), plus lints for hand-rolled fetch() to your own API, untyped client("…") calls missing <typeof app>, and server-only imports in routes/. Pass lintsOnly:true for a near-instant lint pass while iterating; run the full gate (default) to confirm the work is done - fix every diagnostic before finishing.',
|
|
690
732
|
inputSchema: {
|
|
691
733
|
type: "object",
|
|
692
734
|
properties: {
|
|
@@ -855,7 +897,7 @@ export function projectTools(cwd, loadAppCached = createCachedAppLoader(cwd)) {
|
|
|
855
897
|
},
|
|
856
898
|
{
|
|
857
899
|
name: "nifra_doctor",
|
|
858
|
-
description: "Check this project for packages imported in source but NOT declared in package.json
|
|
900
|
+
description: "Check this project for packages imported in source but NOT declared in package.json - the Bun-workspace trap where an import resolves at runtime (hoisting/workspace) so tests pass and `bun install` says no changes, yet tsc fails and a fresh/standalone install can't resolve it. Returns { ok, ran, findings[], fixed?, skippedFixes? }. Pass autoFix:true to update package.json only when the dependency version can be inferred locally from an ancestor package.json or installed package metadata; otherwise the tool returns the exact bun add command to run.",
|
|
859
901
|
inputSchema: {
|
|
860
902
|
type: "object",
|
|
861
903
|
properties: {
|
|
@@ -986,6 +1028,51 @@ function namespaceForApp(name, tools, features) {
|
|
|
986
1028
|
features: { resources: namespacedResources, prompts: namespacedPrompts },
|
|
987
1029
|
};
|
|
988
1030
|
}
|
|
1031
|
+
/**
|
|
1032
|
+
* Merge the backend-derived resources/prompts into `base` - and keep a project that cannot be loaded
|
|
1033
|
+
* from deciding whether the server starts at all.
|
|
1034
|
+
*
|
|
1035
|
+
* Resources and prompts are OPTIONAL capabilities extracted from the app's backend, so this load is a
|
|
1036
|
+
* best-effort enrichment. It was awaited unguarded, which made it a hard boot requirement: `loadApp`
|
|
1037
|
+
* needs a web config (`adapter` + `clientModule`) and a `routes/` directory, and a backend-only
|
|
1038
|
+
* project - the shape `create-nifra`'s DEFAULT template produces - has neither. On those projects the
|
|
1039
|
+
* throw escaped before the JSON-RPC loop began, so the server wrote nothing and exited. `nifra
|
|
1040
|
+
* init-agents` would happily register an `.mcp.json` pointing at a server that could never start, and
|
|
1041
|
+
* every tool went with it, including the twelve that never touch the app (docs, examples, types,
|
|
1042
|
+
* check, doctor, levels, test).
|
|
1043
|
+
*
|
|
1044
|
+
* Degrading costs only the backend resources/prompts. Tools that genuinely need the app still fail,
|
|
1045
|
+
* but per call, with their own message - which is a diagnosis instead of a silence.
|
|
1046
|
+
*/
|
|
1047
|
+
async function backendFeatures(loader, base) {
|
|
1048
|
+
const resources = [...(base.resources ?? [])];
|
|
1049
|
+
const prompts = [...(base.prompts ?? [])];
|
|
1050
|
+
try {
|
|
1051
|
+
const app = await loader();
|
|
1052
|
+
resources.push(...extractBackendResources(app.backend));
|
|
1053
|
+
prompts.push(...extractBackendPrompts(app.backend));
|
|
1054
|
+
}
|
|
1055
|
+
catch {
|
|
1056
|
+
// Not loadable here (no web config, or the config itself throws). The server still serves.
|
|
1057
|
+
}
|
|
1058
|
+
return { resources, prompts };
|
|
1059
|
+
}
|
|
1060
|
+
/**
|
|
1061
|
+
* The MCP tools the app itself declares via `app.tool(...)`, or none when the app cannot be loaded.
|
|
1062
|
+
*
|
|
1063
|
+
* Same reasoning as {@link backendFeatures}, on the hotter path: this ran on EVERY JSON-RPC message,
|
|
1064
|
+
* so an unloadable project failed `initialize` itself with a `-32603` and the session never opened.
|
|
1065
|
+
* An app's own tools are an extension of the built-in set, so their absence must not withdraw the
|
|
1066
|
+
* built-ins - a backend-only project still gets docs, examples, types, check, doctor, levels and test.
|
|
1067
|
+
*/
|
|
1068
|
+
async function appDeclaredTools(loader) {
|
|
1069
|
+
try {
|
|
1070
|
+
return extractBackendTools((await loader()).backend);
|
|
1071
|
+
}
|
|
1072
|
+
catch {
|
|
1073
|
+
return [];
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
989
1076
|
/** Run the stdio MCP server: read newline-delimited JSON-RPC from stdin, write responses to stdout. */
|
|
990
1077
|
export async function runMcpServer(cwd, version) {
|
|
991
1078
|
let features;
|
|
@@ -996,12 +1083,7 @@ export async function runMcpServer(cwd, version) {
|
|
|
996
1083
|
const allPrompts = [];
|
|
997
1084
|
for (const { name, cwd: appCwd } of appEntries) {
|
|
998
1085
|
const loader = createCachedAppLoader(appCwd);
|
|
999
|
-
const
|
|
1000
|
-
const base = projectFeatures(appCwd, loader);
|
|
1001
|
-
const ns = namespaceForApp(name, [], {
|
|
1002
|
-
resources: [...(base.resources ?? []), ...extractBackendResources(app.backend)],
|
|
1003
|
-
prompts: [...(base.prompts ?? []), ...extractBackendPrompts(app.backend)],
|
|
1004
|
-
});
|
|
1086
|
+
const ns = namespaceForApp(name, [], await backendFeatures(loader, projectFeatures(appCwd, loader)));
|
|
1005
1087
|
allResources.push(...(ns.features.resources ?? []));
|
|
1006
1088
|
allPrompts.push(...(ns.features.prompts ?? []));
|
|
1007
1089
|
}
|
|
@@ -1009,12 +1091,7 @@ export async function runMcpServer(cwd, version) {
|
|
|
1009
1091
|
}
|
|
1010
1092
|
else {
|
|
1011
1093
|
const loadAppCached = createCachedAppLoader(cwd);
|
|
1012
|
-
|
|
1013
|
-
const app = await loadAppCached();
|
|
1014
|
-
features = {
|
|
1015
|
-
resources: [...(base.resources ?? []), ...extractBackendResources(app.backend)],
|
|
1016
|
-
prompts: [...(base.prompts ?? []), ...extractBackendPrompts(app.backend)],
|
|
1017
|
-
};
|
|
1094
|
+
features = await backendFeatures(loadAppCached, projectFeatures(cwd, loadAppCached));
|
|
1018
1095
|
}
|
|
1019
1096
|
const loadAppCached = createCachedAppLoader(cwd);
|
|
1020
1097
|
const serverInfo = { name: "nifra", version };
|
|
@@ -1029,22 +1106,17 @@ export async function runMcpServer(cwd, version) {
|
|
|
1029
1106
|
const allTools = [];
|
|
1030
1107
|
for (const { name, cwd: appCwd } of appEntries) {
|
|
1031
1108
|
const loader = createCachedAppLoader(appCwd);
|
|
1032
|
-
const
|
|
1033
|
-
const
|
|
1034
|
-
const backendTools = extractBackendTools(app.backend);
|
|
1035
|
-
const ns = namespaceForApp(name, [...baseTools, ...backendTools], {
|
|
1036
|
-
resources: [],
|
|
1037
|
-
prompts: [],
|
|
1038
|
-
});
|
|
1109
|
+
const tools = [...projectTools(appCwd, loader), ...(await appDeclaredTools(loader))];
|
|
1110
|
+
const ns = namespaceForApp(name, tools, { resources: [], prompts: [] });
|
|
1039
1111
|
allTools.push(...ns.tools);
|
|
1040
1112
|
}
|
|
1041
1113
|
activeTools = [...docsTools(loadDocsCorpus, loadExamplesCorpus, loadTypesCorpus), ...allTools];
|
|
1042
1114
|
}
|
|
1043
1115
|
else {
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1116
|
+
activeTools = [
|
|
1117
|
+
...projectTools(cwd, loadAppCached),
|
|
1118
|
+
...(await appDeclaredTools(loadAppCached)),
|
|
1119
|
+
];
|
|
1048
1120
|
}
|
|
1049
1121
|
const response = await handleRpc(message, activeTools, serverInfo, features, {
|
|
1050
1122
|
state,
|