devframe 0.2.3 → 0.4.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/build.mjs +6 -6
- package/dist/adapters/cli.d.mts +1 -1
- package/dist/adapters/cli.mjs +2 -2
- package/dist/adapters/dev.d.mts +2 -2
- 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/adapters/mcp.mjs +9 -8
- package/dist/client/index.d.mts +1 -1
- package/dist/client/index.mjs +44 -37
- package/dist/{context-GUzIxrEK.d.mts → context-Ca70YtrW.d.mts} +1 -1
- package/dist/{dev-BVtS7qBK.mjs → dev-C2wjXjGB.mjs} +4 -4
- package/dist/{devframe-C4DNeFuG.d.mts → devframe-xC8Q-xyt.d.mts} +50 -41
- package/dist/diagnostics-GitRGKbr.mjs +33 -0
- package/dist/diagnostics-reporter-CBBZwoMv.mjs +38 -0
- package/dist/{dump-C5LPsKJC.mjs → dump-B1wd4u68.mjs} +10 -10
- package/dist/helpers/vite.d.mts +1 -1
- package/dist/helpers/vite.mjs +7 -6
- package/dist/{host-h3-DYFKJxAV.mjs → host-h3-Div5Vp8R.mjs} +31 -39
- package/dist/{index-DWczSqdd.d.mts → index-C5PmWqBf.d.mts} +1 -1
- package/dist/{index-CSi2Y5JU.d.mts → index-CTK6fuXs.d.mts} +2 -2
- package/dist/{index-aNunf5Za.d.mts → index-DTeZXHSi.d.mts} +1 -1
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +1 -1
- package/dist/node/auth.d.mts +2 -2
- package/dist/node/auth.mjs +1 -1
- package/dist/node/index.d.mts +10 -14
- package/dist/node/index.mjs +3 -3
- package/dist/node/internal.d.mts +2 -2
- package/dist/node/internal.mjs +3 -3
- package/dist/recipes/open-helpers.d.mts +1 -1
- package/dist/recipes/open-helpers.mjs +2 -2
- package/dist/rpc/dump.d.mts +1 -1
- package/dist/rpc/dump.mjs +1 -1
- package/dist/rpc/index.d.mts +2 -2
- package/dist/rpc/index.mjs +8 -8
- package/dist/rpc/transports/ws-client.d.mts +1 -1
- package/dist/rpc/transports/ws-client.mjs +2 -2
- package/dist/rpc/transports/ws-server.d.mts +1 -1
- package/dist/rpc/transports/ws-server.mjs +2 -2
- package/dist/{serialization-lBLV02kQ.mjs → serialization-BD_qXGjd.mjs} +3 -3
- package/dist/{server-DjMtJQhO.d.mts → server-FNcskEBD.d.mts} +1 -1
- package/dist/{shared-state-SzgfilJP.mjs → shared-state-CasqoUba.mjs} +25 -64
- package/dist/{storage-CTlHUtXI.mjs → storage-CZVTPKsw.mjs} +5 -2
- package/dist/types/index.d.mts +4 -4
- package/dist/utils/events.d.mts +1 -1
- package/dist/utils/open.mjs +1 -1
- package/dist/utils/shared-state.d.mts +1 -1
- package/dist/utils/streaming-channel.d.mts +1 -1
- package/dist/{ws-server-lHQaafrS.d.mts → ws-server-DOwLJL23.d.mts} +1 -1
- package/package.json +3 -3
- package/skills/devframe/SKILL.md +1 -1
- package/dist/diagnostics-D7miaTpL.mjs +0 -36
- /package/dist/{_shared-BNoPn1NG.mjs → _shared-CUFqO4kJ.mjs} +0 -0
- /package/dist/{define-Bb4zh-Dc.mjs → define-CW9gLnyG.mjs} +0 -0
- /package/dist/{human-id-CiBWzVcg.mjs → human-id-Dq-qgtES.mjs} +0 -0
- /package/dist/{open-CX4CiMyw.mjs → open-DiQn6zCH.mjs} +0 -0
- /package/dist/{server-DxiOFSpu.mjs → server-BO8IDVsJ.mjs} +0 -0
- /package/dist/{structured-clone-qP1sPovr.mjs → structured-clone-jegjz0hM.mjs} +0 -0
- /package/dist/{transports-Bl1zuYhZ.mjs → transports-DTFoMUbE.mjs} +0 -0
- /package/dist/{types-kKDaD2NT.d.mts → types-BXL7EIDM.d.mts} +0 -0
package/dist/adapters/build.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { t as collectStaticRpcDump } from "../dump-
|
|
1
|
+
import { t as collectStaticRpcDump } from "../dump-B1wd4u68.mjs";
|
|
2
|
+
import { n as colors } from "../diagnostics-reporter-CBBZwoMv.mjs";
|
|
2
3
|
import { DEVTOOLS_CONNECTION_META_FILENAME, DEVTOOLS_RPC_DUMP_DIRNAME, DEVTOOLS_RPC_DUMP_MANIFEST_FILENAME } from "../constants.mjs";
|
|
3
|
-
import { n as strictJsonStringify } from "../serialization-
|
|
4
|
-
import { n as structuredCloneStringify } from "../structured-clone-
|
|
5
|
-
import {
|
|
6
|
-
import { n as
|
|
7
|
-
import { n as resolveBasePath } from "../_shared-BNoPn1NG.mjs";
|
|
4
|
+
import { n as strictJsonStringify } from "../serialization-BD_qXGjd.mjs";
|
|
5
|
+
import { n as structuredCloneStringify } from "../structured-clone-jegjz0hM.mjs";
|
|
6
|
+
import { n as createHostContext, t as createH3DevToolsHost } from "../host-h3-Div5Vp8R.mjs";
|
|
7
|
+
import { n as resolveBasePath } from "../_shared-CUFqO4kJ.mjs";
|
|
8
8
|
import { existsSync } from "node:fs";
|
|
9
9
|
import process from "node:process";
|
|
10
10
|
import { dirname, resolve } from "pathe";
|
package/dist/adapters/cli.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { G as
|
|
1
|
+
import { G as CliFlagsSchema, J as parseCliFlags, K as InferCliFlags, q as defineCliFlags, r as DevframeDefinition } from "../devframe-xC8Q-xyt.mjs";
|
|
2
2
|
import { H3 } from "h3";
|
|
3
3
|
import { CAC } from "cac";
|
|
4
4
|
|
package/dist/adapters/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as colors } from "../diagnostics-reporter-CBBZwoMv.mjs";
|
|
2
2
|
import { createBuild } from "./build.mjs";
|
|
3
|
-
import { n as resolveDevServerPort, t as createDevServer } from "../dev-
|
|
3
|
+
import { n as resolveDevServerPort, t as createDevServer } from "../dev-C2wjXjGB.mjs";
|
|
4
4
|
import process from "node:process";
|
|
5
5
|
import cac from "cac";
|
|
6
6
|
import { safeParse } from "valibot";
|
package/dist/adapters/dev.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as DevframeDefinition } from "../devframe-
|
|
2
|
-
import { n as StartedServer } from "../server-
|
|
1
|
+
import { r as DevframeDefinition } from "../devframe-xC8Q-xyt.mjs";
|
|
2
|
+
import { n as StartedServer } from "../server-FNcskEBD.mjs";
|
|
3
3
|
import { H3 } from "h3";
|
|
4
4
|
|
|
5
5
|
//#region src/adapters/dev.d.ts
|
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-C2wjXjGB.mjs";
|
|
2
2
|
export { createDevServer, resolveDevServerPort };
|
package/dist/adapters/mcp.d.mts
CHANGED
package/dist/adapters/mcp.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as createHostContext } from "../host-h3-
|
|
1
|
+
import { i as diagnostics } from "../shared-state-CasqoUba.mjs";
|
|
2
|
+
import { n as createHostContext } from "../host-h3-Div5Vp8R.mjs";
|
|
3
3
|
import { homedir } from "node:os";
|
|
4
4
|
import process from "node:process";
|
|
5
5
|
import { join } from "pathe";
|
|
@@ -185,10 +185,10 @@ function buildMcpServerFromContext(ctx, options) {
|
|
|
185
185
|
*/
|
|
186
186
|
async function createMcpServer(definition, options = {}) {
|
|
187
187
|
const transport = options.transport ?? "stdio";
|
|
188
|
-
if (transport !== "stdio") throw
|
|
188
|
+
if (transport !== "stdio") throw diagnostics.DF0017({
|
|
189
189
|
transport,
|
|
190
190
|
reason: "Only stdio transport is supported in this release."
|
|
191
|
-
})
|
|
191
|
+
});
|
|
192
192
|
const ctx = await createHostContext({
|
|
193
193
|
cwd: process.cwd(),
|
|
194
194
|
mode: "dev",
|
|
@@ -204,16 +204,17 @@ async function createMcpServer(definition, options = {}) {
|
|
|
204
204
|
serverVersion: options.serverVersion ?? definition.version ?? "0.0.0",
|
|
205
205
|
exposeSharedState: options.exposeSharedState ?? true
|
|
206
206
|
});
|
|
207
|
-
const { startStdioTransport } = await import("../transports-
|
|
207
|
+
const { startStdioTransport } = await import("../transports-DTFoMUbE.mjs");
|
|
208
208
|
let stop;
|
|
209
209
|
try {
|
|
210
210
|
stop = await startStdioTransport(server);
|
|
211
211
|
} catch (error) {
|
|
212
212
|
const reason = error instanceof Error ? error.message : String(error);
|
|
213
|
-
throw
|
|
213
|
+
throw diagnostics.DF0017({
|
|
214
214
|
transport,
|
|
215
|
-
reason
|
|
216
|
-
|
|
215
|
+
reason,
|
|
216
|
+
cause: error
|
|
217
|
+
});
|
|
217
218
|
}
|
|
218
219
|
options.onReady?.({ transport: "stdio" });
|
|
219
220
|
return { async stop() {
|
package/dist/client/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as RpcCacheOptions, E as RpcCacheManager, O as RpcFunctionDefinitionAny, i as DevToolsRpcServerFunctions, k as RpcFunctionsCollector, l as StreamReader, n as RpcSharedStateHost, r as DevToolsRpcClientFunctions, t as ConnectionMeta, u as StreamSink, w as EventEmitter } from "../index-
|
|
1
|
+
import { D as RpcCacheOptions, E as RpcCacheManager, O as RpcFunctionDefinitionAny, i as DevToolsRpcServerFunctions, k as RpcFunctionsCollector, l as StreamReader, n as RpcSharedStateHost, r as DevToolsRpcClientFunctions, t as ConnectionMeta, u as StreamSink, w as EventEmitter } from "../index-DTeZXHSi.mjs";
|
|
2
2
|
import { BirpcOptions, BirpcReturn } from "birpc";
|
|
3
3
|
|
|
4
4
|
//#region src/rpc/transports/ws-client.d.ts
|
package/dist/client/index.mjs
CHANGED
|
@@ -1,45 +1,52 @@
|
|
|
1
1
|
import { t as hash } from "../hash-bwOD8RgU.mjs";
|
|
2
|
+
import { colors } from "../utils/colors.mjs";
|
|
2
3
|
import { createEventEmitter } from "../utils/events.mjs";
|
|
3
4
|
import { humanId } from "../utils/human-id.mjs";
|
|
4
5
|
import { t as createSharedState } from "../shared-state-u0y123fi.mjs";
|
|
5
6
|
import { i as structuredCloneStringify, n as structuredCloneParse, t as structuredCloneDeserialize } from "../structured-clone-PdCZwt7F.mjs";
|
|
6
7
|
import { createStreamReader, createStreamSink } from "../utils/streaming-channel.mjs";
|
|
7
8
|
import { promiseWithResolver } from "../utils/promise.mjs";
|
|
8
|
-
import {
|
|
9
|
+
import { defineDiagnostics } from "nostics";
|
|
10
|
+
import { ansiFormatter } from "nostics/formatters/ansi";
|
|
9
11
|
import { createBirpc } from "birpc";
|
|
10
12
|
//#region src/constants.ts
|
|
11
13
|
const DEVTOOLS_CONNECTION_META_FILENAME = "__connection.json";
|
|
12
14
|
const DEVTOOLS_RPC_DUMP_MANIFEST_FILENAME = "__rpc-dump/index.json";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/utils/diagnostics-reporter.ts
|
|
17
|
+
const formatAnsi = ansiFormatter(colors);
|
|
18
|
+
function devframeReporter(d, { method = "warn" } = {}) {
|
|
19
|
+
console[method](formatAnsi(d));
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/rpc/diagnostics.ts
|
|
23
|
+
const diagnostics = defineDiagnostics({
|
|
24
|
+
docsBase: "https://devfra.me/errors",
|
|
25
|
+
reporters: [devframeReporter],
|
|
26
|
+
codes: {
|
|
27
|
+
DF0019: {
|
|
28
|
+
why: (p) => `RPC function "${p.name}" has \`agent\` set but \`jsonSerializable\` is not \`true\` — MCP requires JSON-serializable data.`,
|
|
29
|
+
fix: "Set `jsonSerializable: true` if the payload is JSON-safe, or remove `agent` to keep it RPC-only."
|
|
30
|
+
},
|
|
31
|
+
DF0020: {
|
|
32
|
+
why: (p) => `RPC function "${p.name}" declares \`jsonSerializable: true\` but the value at "${p.path}" is a ${p.type}.`,
|
|
33
|
+
fix: "Either drop `jsonSerializable: true` (falls back to structured-clone) or change the value to a JSON-safe shape."
|
|
34
|
+
},
|
|
35
|
+
DF0021: {
|
|
36
|
+
why: (p) => `RPC function "${p.name}" is already registered`,
|
|
37
|
+
fix: "Use the `force` parameter to overwrite an existing registration."
|
|
38
|
+
},
|
|
39
|
+
DF0022: { why: (p) => `RPC function "${p.name}" is not registered. Use register() to add new functions.` },
|
|
40
|
+
DF0023: { why: (p) => `RPC function "${p.name}" is not registered` },
|
|
41
|
+
DF0024: { why: (p) => `Either handler or setup function must be provided for RPC function "${p.name}"` },
|
|
42
|
+
DF0025: { why: (p) => `Function "${p.name}" not found in dump store` },
|
|
43
|
+
DF0026: { why: (p) => `No dump match for "${p.name}" with args: ${p.args}` },
|
|
44
|
+
DF0027: { why: (p) => `Function "${p.name}" with type "${p.type}" cannot have dump configuration. Only "static" and "query" types support dumps.` },
|
|
45
|
+
DF0028: {
|
|
46
|
+
why: (p) => `Function "${p.name}" with type "${p.type}" cannot use \`snapshot: true\`. Only "query" functions support this sugar; "static" functions have equivalent default behavior already.`,
|
|
47
|
+
fix: "Remove `snapshot: true`, or change the function type to `query`."
|
|
39
48
|
}
|
|
40
|
-
}
|
|
41
|
-
formatter: plainFormatter,
|
|
42
|
-
reporters: consoleReporter
|
|
49
|
+
}
|
|
43
50
|
});
|
|
44
51
|
//#endregion
|
|
45
52
|
//#region src/rpc/dump/error.ts
|
|
@@ -76,7 +83,7 @@ async function getRpcResolvedSetupResult(definition, context) {
|
|
|
76
83
|
async function getRpcHandler(definition, context) {
|
|
77
84
|
if (definition.handler) return definition.handler;
|
|
78
85
|
const result = await getRpcResolvedSetupResult(definition, context);
|
|
79
|
-
if (!result.handler) throw
|
|
86
|
+
if (!result.handler) throw diagnostics.DF0024({ name: definition.name });
|
|
80
87
|
return result.handler;
|
|
81
88
|
}
|
|
82
89
|
//#endregion
|
|
@@ -148,13 +155,13 @@ var RpcFunctionsCollectorBase = class {
|
|
|
148
155
|
});
|
|
149
156
|
}
|
|
150
157
|
register(fn, force = false) {
|
|
151
|
-
if (this.definitions.has(fn.name) && !force) throw
|
|
158
|
+
if (this.definitions.has(fn.name) && !force) throw diagnostics.DF0021({ name: fn.name });
|
|
152
159
|
assertAgentJsonSerializable(fn);
|
|
153
160
|
this.definitions.set(fn.name, fn);
|
|
154
161
|
this._onChanged.forEach((cb) => cb(fn.name));
|
|
155
162
|
}
|
|
156
163
|
update(fn, force = false) {
|
|
157
|
-
if (!this.definitions.has(fn.name) && !force) throw
|
|
164
|
+
if (!this.definitions.has(fn.name) && !force) throw diagnostics.DF0022({ name: fn.name });
|
|
158
165
|
assertAgentJsonSerializable(fn);
|
|
159
166
|
this.definitions.set(fn.name, fn);
|
|
160
167
|
this._onChanged.forEach((cb) => cb(fn.name));
|
|
@@ -171,7 +178,7 @@ var RpcFunctionsCollectorBase = class {
|
|
|
171
178
|
}
|
|
172
179
|
getSchema(name) {
|
|
173
180
|
const definition = this.definitions.get(name);
|
|
174
|
-
if (!definition) throw
|
|
181
|
+
if (!definition) throw diagnostics.DF0023({ name: String(name) });
|
|
175
182
|
return {
|
|
176
183
|
args: definition.args,
|
|
177
184
|
returns: definition.returns
|
|
@@ -188,7 +195,7 @@ var RpcFunctionsCollectorBase = class {
|
|
|
188
195
|
}
|
|
189
196
|
};
|
|
190
197
|
function assertAgentJsonSerializable(fn) {
|
|
191
|
-
if (fn.agent && fn.jsonSerializable !== true) throw
|
|
198
|
+
if (fn.agent && fn.jsonSerializable !== true) throw diagnostics.DF0019({ name: fn.name });
|
|
192
199
|
}
|
|
193
200
|
//#endregion
|
|
194
201
|
//#region src/rpc/serialization.ts
|
|
@@ -236,11 +243,11 @@ function strictJsonStringify(value, fnName = "") {
|
|
|
236
243
|
}
|
|
237
244
|
function nonJsonAt(fnName, type, parent, key) {
|
|
238
245
|
const path = formatPath(parent, key);
|
|
239
|
-
return
|
|
246
|
+
return diagnostics.DF0020({
|
|
240
247
|
name: fnName || "<anonymous>",
|
|
241
248
|
type,
|
|
242
249
|
path
|
|
243
|
-
})
|
|
250
|
+
});
|
|
244
251
|
}
|
|
245
252
|
function formatPath(parent, key) {
|
|
246
253
|
if (Array.isArray(parent)) return `[${key}]`;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DEVTOOLS_CONNECTION_META_FILENAME } from "./constants.mjs";
|
|
2
|
-
import { n as createHostContext, t as createH3DevToolsHost } from "./host-h3-
|
|
3
|
-
import { t as startHttpAndWs } from "./server-
|
|
4
|
-
import { n as resolveBasePath, t as normalizeBasePath } from "./_shared-
|
|
5
|
-
import { t as open } from "./open-
|
|
2
|
+
import { n as createHostContext, t as createH3DevToolsHost } from "./host-h3-Div5Vp8R.mjs";
|
|
3
|
+
import { t as startHttpAndWs } from "./server-BO8IDVsJ.mjs";
|
|
4
|
+
import { n as resolveBasePath, t as normalizeBasePath } from "./_shared-CUFqO4kJ.mjs";
|
|
5
|
+
import { t as open } from "./open-DiQn6zCH.mjs";
|
|
6
6
|
import { mountStaticHandler } from "./utils/serve-static.mjs";
|
|
7
7
|
import { networkInterfaces } from "node:os";
|
|
8
8
|
import process$1 from "node:process";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as RpcFunctionsCollectorBase } from "./index-
|
|
2
|
-
import { t as DevToolsNodeRpcSessionMeta } from "./ws-server-
|
|
3
|
-
import {
|
|
1
|
+
import { S as RpcFunctionsCollectorBase } from "./index-CTK6fuXs.mjs";
|
|
2
|
+
import { t as DevToolsNodeRpcSessionMeta } from "./ws-server-DOwLJL23.mjs";
|
|
3
|
+
import { Diagnostic, DiagnosticDefinition, defineDiagnostics } from "nostics";
|
|
4
4
|
import { BirpcReturn } from "birpc";
|
|
5
5
|
import { CAC } from "cac";
|
|
6
6
|
import { GenericSchema, InferOutput } from "valibot";
|
|
@@ -289,17 +289,32 @@ interface DevToolsAgentHost {
|
|
|
289
289
|
* A diagnostics definition object built with `defineDiagnostics`. Typed as
|
|
290
290
|
* `unknown` because each integration's definition has a distinct narrow shape
|
|
291
291
|
* (e.g. specific code keys like `DF0001` / `MYP0001`), and TypeScript's mapped
|
|
292
|
-
* types don't allow assigning a narrow-keyed
|
|
293
|
-
*
|
|
294
|
-
* rebuilds the logger on `register()`.
|
|
292
|
+
* types don't allow assigning a narrow-keyed result to a generically-keyed
|
|
293
|
+
* one. The host stores them in a heterogeneous registry.
|
|
295
294
|
*/
|
|
296
|
-
type DevToolsDiagnosticsDefinition = ReturnType<typeof defineDiagnostics<any>>;
|
|
297
|
-
/** A `logs-sdk` Logger instance built with `createLogger`. */
|
|
298
|
-
type DevToolsDiagnosticsLogger = Logger<readonly any[]>;
|
|
295
|
+
type DevToolsDiagnosticsDefinition = ReturnType<typeof defineDiagnostics<any, any>>;
|
|
299
296
|
/**
|
|
300
|
-
*
|
|
301
|
-
*
|
|
302
|
-
*
|
|
297
|
+
* The shared diagnostics lookup exposed by the host. A `Proxy` that resolves
|
|
298
|
+
* any registered code name to its `nostics` handle (a callable that builds
|
|
299
|
+
* a diagnostic and routes it through registered reporters). Typed loosely
|
|
300
|
+
* because it spans heterogeneous definitions registered by different
|
|
301
|
+
* integrations.
|
|
302
|
+
*/
|
|
303
|
+
type DevToolsDiagnosticsLogger = Record<string, any>;
|
|
304
|
+
/**
|
|
305
|
+
* Options accepted by the host's `defineDiagnostics()` factory — mirrors
|
|
306
|
+
* `nostics`'s shape but the host pre-wires its ANSI console reporter, so
|
|
307
|
+
* plugins typically omit `reporters`.
|
|
308
|
+
*/
|
|
309
|
+
interface DevToolsDefineDiagnosticsOptions<Codes extends Record<string, DiagnosticDefinition>> {
|
|
310
|
+
docsBase?: string | ((code: keyof Codes) => string | undefined);
|
|
311
|
+
codes: Codes;
|
|
312
|
+
reporters?: ReadonlyArray<(d: Diagnostic, o?: any) => void>;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Host for structured diagnostics — a thin layer over `nostics` that lets
|
|
316
|
+
* integrations register their own coded errors/warnings into a shared
|
|
317
|
+
* registry without taking a direct dependency on `nostics`.
|
|
303
318
|
*
|
|
304
319
|
* Typical usage from a plugin's `setup(ctx)`:
|
|
305
320
|
*
|
|
@@ -307,47 +322,41 @@ type DevToolsDiagnosticsLogger = Logger<readonly any[]>;
|
|
|
307
322
|
* const myDiagnostics = ctx.diagnostics.defineDiagnostics({
|
|
308
323
|
* docsBase: 'https://example.com/errors',
|
|
309
324
|
* codes: {
|
|
310
|
-
* MYP0001: {
|
|
325
|
+
* MYP0001: { why: 'Something went wrong' },
|
|
311
326
|
* },
|
|
312
327
|
* })
|
|
313
328
|
* ctx.diagnostics.register(myDiagnostics)
|
|
314
329
|
*
|
|
315
|
-
* //
|
|
316
|
-
* ctx.diagnostics.logger.MYP0001()
|
|
330
|
+
* // Through the shared lookup (loose typing):
|
|
331
|
+
* throw ctx.diagnostics.logger.MYP0001()
|
|
317
332
|
*
|
|
318
|
-
* // Or
|
|
319
|
-
*
|
|
320
|
-
* logger.MYP0001().warn()
|
|
333
|
+
* // Or directly on the typed handle returned from `defineDiagnostics`:
|
|
334
|
+
* throw myDiagnostics.MYP0001()
|
|
321
335
|
* ```
|
|
322
336
|
*/
|
|
323
337
|
interface DevToolsDiagnosticsHost {
|
|
324
338
|
/**
|
|
325
|
-
*
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
*
|
|
339
|
+
* Proxy-backed lookup of every registered diagnostic handle by code name.
|
|
340
|
+
* Resolves to a `nostics` `DiagnosticHandle` — a callable that builds a
|
|
341
|
+
* diagnostic and routes it through registered reporters; prefix with
|
|
342
|
+
* `throw` to raise. Loosely typed — for autocompletion, keep a reference
|
|
343
|
+
* to the typed result of `defineDiagnostics()` instead.
|
|
329
344
|
*/
|
|
330
345
|
readonly logger: DevToolsDiagnosticsLogger;
|
|
331
346
|
/**
|
|
332
|
-
* Register
|
|
333
|
-
* registration, codes from the new definition are
|
|
334
|
-
* `host.logger`.
|
|
335
|
-
*
|
|
336
|
-
*
|
|
337
|
-
*/
|
|
338
|
-
register: (definitions: unknown) => void;
|
|
339
|
-
/**
|
|
340
|
-
* Re-export of `logs-sdk`'s `defineDiagnostics`. Integrations can build
|
|
341
|
-
* their own diagnostic definitions without taking a direct dependency on
|
|
342
|
-
* `logs-sdk`.
|
|
347
|
+
* Register additional diagnostic definitions with this host. After
|
|
348
|
+
* registration, codes from the new definition are reachable via
|
|
349
|
+
* `host.logger.CODE`. Plugins that want shared output formatting should
|
|
350
|
+
* build their diagnostics via `host.defineDiagnostics()` first — that
|
|
351
|
+
* factory pre-wires the host's ANSI console reporter.
|
|
343
352
|
*/
|
|
344
|
-
|
|
353
|
+
register: (definitions: Record<string, unknown>) => void;
|
|
345
354
|
/**
|
|
346
|
-
*
|
|
347
|
-
*
|
|
348
|
-
*
|
|
355
|
+
* Build a typed diagnostics object with the host's ANSI console reporter
|
|
356
|
+
* pre-wired. Mirrors `nostics`'s `defineDiagnostics` so integrations don't
|
|
357
|
+
* need to take a direct dependency on `nostics`.
|
|
349
358
|
*/
|
|
350
|
-
|
|
359
|
+
defineDiagnostics: <const Codes extends Record<string, DiagnosticDefinition>>(options: DevToolsDefineDiagnosticsOptions<Codes>) => ReturnType<typeof defineDiagnostics<Codes, any>>;
|
|
351
360
|
}
|
|
352
361
|
//#endregion
|
|
353
362
|
//#region src/types/host.d.ts
|
|
@@ -849,8 +858,8 @@ interface DevToolsNodeContext {
|
|
|
849
858
|
rpc: RpcFunctionsHost;
|
|
850
859
|
views: DevToolsViewHost;
|
|
851
860
|
/**
|
|
852
|
-
* Structured diagnostics host — wraps `
|
|
853
|
-
* register their own coded errors/warnings into the shared
|
|
861
|
+
* Structured diagnostics host — wraps `nostics` and lets integrations
|
|
862
|
+
* register their own coded errors/warnings into the shared lookup.
|
|
854
863
|
*/
|
|
855
864
|
diagnostics: DevToolsDiagnosticsHost;
|
|
856
865
|
/**
|
|
@@ -998,4 +1007,4 @@ interface DevframeDefinition {
|
|
|
998
1007
|
}
|
|
999
1008
|
declare function defineDevframe(d: DevframeDefinition): DevframeDefinition;
|
|
1000
1009
|
//#endregion
|
|
1001
|
-
export {
|
|
1010
|
+
export { DevToolsDiagnosticsDefinition as A, DevToolsAgentHost as B, PartialWithoutId as C, DevToolsRpcSharedStates as D, DevToolsRpcServerFunctions as E, AgentResource as F, CliFlagsSchema as G, EventEmitter as H, AgentResourceContent as I, parseCliFlags as J, InferCliFlags as K, AgentResourceInput as L, DevToolsDiagnosticsLogger as M, AgentHandle as N, DevToolsHost as O, AgentManifest as P, AgentTool as R, EntriesToObject as S, DevToolsRpcClientFunctions as T, EventUnsubscribe as U, DevToolsAgentHostEvents as V, EventsMap as W, RpcStreamingChannel as _, DevframeRuntime as a, SharedState as b, defineDevframe as c, DevToolsNodeContext as d, DevToolsNodeRpcSession as f, RpcSharedStateHost as g, RpcSharedStateGetOptions as h, DevframeDeploymentKind as i, DevToolsDiagnosticsHost as j, DevToolsDefineDiagnosticsOptions as k, ConnectionMeta as l, RpcFunctionsHost as m, DevframeCliOptions as n, DevframeSetupInfo as o, RpcBroadcastOptions as p, defineCliFlags as q, DevframeDefinition as r, DevframeSpaOptions as s, DevframeBrowserContext as t, DevToolsCapabilities as u, RpcStreamingChannelOptions as v, Thenable as w, DevToolsViewHost as x, RpcStreamingHost as y, AgentToolInput as z };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { t as devframeReporter } from "./diagnostics-reporter-CBBZwoMv.mjs";
|
|
2
|
+
import { defineDiagnostics } from "nostics";
|
|
3
|
+
//#region src/rpc/diagnostics.ts
|
|
4
|
+
const diagnostics = defineDiagnostics({
|
|
5
|
+
docsBase: "https://devfra.me/errors",
|
|
6
|
+
reporters: [devframeReporter],
|
|
7
|
+
codes: {
|
|
8
|
+
DF0019: {
|
|
9
|
+
why: (p) => `RPC function "${p.name}" has \`agent\` set but \`jsonSerializable\` is not \`true\` — MCP requires JSON-serializable data.`,
|
|
10
|
+
fix: "Set `jsonSerializable: true` if the payload is JSON-safe, or remove `agent` to keep it RPC-only."
|
|
11
|
+
},
|
|
12
|
+
DF0020: {
|
|
13
|
+
why: (p) => `RPC function "${p.name}" declares \`jsonSerializable: true\` but the value at "${p.path}" is a ${p.type}.`,
|
|
14
|
+
fix: "Either drop `jsonSerializable: true` (falls back to structured-clone) or change the value to a JSON-safe shape."
|
|
15
|
+
},
|
|
16
|
+
DF0021: {
|
|
17
|
+
why: (p) => `RPC function "${p.name}" is already registered`,
|
|
18
|
+
fix: "Use the `force` parameter to overwrite an existing registration."
|
|
19
|
+
},
|
|
20
|
+
DF0022: { why: (p) => `RPC function "${p.name}" is not registered. Use register() to add new functions.` },
|
|
21
|
+
DF0023: { why: (p) => `RPC function "${p.name}" is not registered` },
|
|
22
|
+
DF0024: { why: (p) => `Either handler or setup function must be provided for RPC function "${p.name}"` },
|
|
23
|
+
DF0025: { why: (p) => `Function "${p.name}" not found in dump store` },
|
|
24
|
+
DF0026: { why: (p) => `No dump match for "${p.name}" with args: ${p.args}` },
|
|
25
|
+
DF0027: { why: (p) => `Function "${p.name}" with type "${p.type}" cannot have dump configuration. Only "static" and "query" types support dumps.` },
|
|
26
|
+
DF0028: {
|
|
27
|
+
why: (p) => `Function "${p.name}" with type "${p.type}" cannot use \`snapshot: true\`. Only "query" functions support this sugar; "static" functions have equivalent default behavior already.`,
|
|
28
|
+
fix: "Remove `snapshot: true`, or change the function type to `query`."
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
//#endregion
|
|
33
|
+
export { diagnostics as t };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ansiFormatter } from "nostics/formatters/ansi";
|
|
2
|
+
//#region src/utils/colors.ts
|
|
3
|
+
function makeColor(open, close) {
|
|
4
|
+
const o = `\x1B[${open}m`;
|
|
5
|
+
const c = `\x1B[${close}m`;
|
|
6
|
+
return ((arg, ...values) => {
|
|
7
|
+
if (Array.isArray(arg) && "raw" in arg) {
|
|
8
|
+
const strings = arg;
|
|
9
|
+
let out = "";
|
|
10
|
+
for (let i = 0; i < strings.length; i++) {
|
|
11
|
+
out += strings[i];
|
|
12
|
+
if (i < values.length) out += String(values[i]);
|
|
13
|
+
}
|
|
14
|
+
return `${o}${out}${c}`;
|
|
15
|
+
}
|
|
16
|
+
return `${o}${String(arg)}${c}`;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
const colors = {
|
|
20
|
+
blue: makeColor(34, 39),
|
|
21
|
+
cyan: makeColor(36, 39),
|
|
22
|
+
gray: makeColor(90, 39),
|
|
23
|
+
green: makeColor(32, 39),
|
|
24
|
+
red: makeColor(31, 39),
|
|
25
|
+
yellow: makeColor(33, 39),
|
|
26
|
+
bold: makeColor(1, 22),
|
|
27
|
+
dim: makeColor(2, 22),
|
|
28
|
+
reset: makeColor(0, 0),
|
|
29
|
+
underline: makeColor(4, 24)
|
|
30
|
+
};
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/utils/diagnostics-reporter.ts
|
|
33
|
+
const formatAnsi = ansiFormatter(colors);
|
|
34
|
+
function devframeReporter(d, { method = "warn" } = {}) {
|
|
35
|
+
console[method](formatAnsi(d));
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
export { colors as n, devframeReporter as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as diagnostics } from "./diagnostics-GitRGKbr.mjs";
|
|
2
2
|
import { DEVTOOLS_RPC_DUMP_DIRNAME } from "./constants.mjs";
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
4
|
//#region ../../node_modules/.pnpm/ohash@2.0.11/node_modules/ohash/dist/shared/ohash.D__AXeF1.mjs
|
|
@@ -262,14 +262,14 @@ function validateConcurrency(concurrency) {
|
|
|
262
262
|
function validateDefinitions(definitions) {
|
|
263
263
|
for (const definition of definitions) {
|
|
264
264
|
const type = definition.type || "query";
|
|
265
|
-
if ((type === "action" || type === "event") && definition.dump) throw
|
|
265
|
+
if ((type === "action" || type === "event") && definition.dump) throw diagnostics.DF0027({
|
|
266
266
|
name: definition.name,
|
|
267
267
|
type
|
|
268
|
-
})
|
|
269
|
-
if (definition.snapshot && type !== "query") throw
|
|
268
|
+
});
|
|
269
|
+
if (definition.snapshot && type !== "query") throw diagnostics.DF0028({
|
|
270
270
|
name: definition.name,
|
|
271
271
|
type
|
|
272
|
-
})
|
|
272
|
+
});
|
|
273
273
|
}
|
|
274
274
|
}
|
|
275
275
|
/**
|
|
@@ -364,7 +364,7 @@ async function dumpFunctions(definitions, context, options = {}) {
|
|
|
364
364
|
if (definition.type === "event" || definition.type === "action") return;
|
|
365
365
|
const setupResult = definition.setup ? await Promise.resolve(definition.setup(context)) : {};
|
|
366
366
|
const handler = setupResult.handler || definition.handler;
|
|
367
|
-
if (!handler) throw
|
|
367
|
+
if (!handler) throw diagnostics.DF0024({ name: definition.name });
|
|
368
368
|
let dump = setupResult.dump ?? definition.dump;
|
|
369
369
|
if (!dump && definition.type === "static") dump = { inputs: [[]] };
|
|
370
370
|
if (!dump && definition.snapshot) dump = async (_ctx, h) => {
|
|
@@ -449,7 +449,7 @@ function createClientFromDump(store, options = {}) {
|
|
|
449
449
|
const { onMiss } = options;
|
|
450
450
|
return new Proxy({}, {
|
|
451
451
|
get(_, functionName) {
|
|
452
|
-
if (!(functionName in store.definitions)) throw
|
|
452
|
+
if (!(functionName in store.definitions)) throw diagnostics.DF0025({ name: functionName });
|
|
453
453
|
return async (...args) => {
|
|
454
454
|
const recordKey = getDumpRecordKey(functionName, args);
|
|
455
455
|
const recordOrGetter = store.records[recordKey];
|
|
@@ -467,10 +467,10 @@ function createClientFromDump(store, options = {}) {
|
|
|
467
467
|
if (fallbackRecord && typeof fallbackRecord.output === "function") return await fallbackRecord.output();
|
|
468
468
|
if (fallbackRecord) return fallbackRecord.output;
|
|
469
469
|
}
|
|
470
|
-
throw
|
|
470
|
+
throw diagnostics.DF0026({
|
|
471
471
|
name: functionName,
|
|
472
472
|
args: JSON.stringify(args)
|
|
473
|
-
})
|
|
473
|
+
});
|
|
474
474
|
};
|
|
475
475
|
},
|
|
476
476
|
has(_, functionName) {
|
|
@@ -510,7 +510,7 @@ async function getRpcResolvedSetupResult(definition, context) {
|
|
|
510
510
|
async function getRpcHandler(definition, context) {
|
|
511
511
|
if (definition.handler) return definition.handler;
|
|
512
512
|
const result = await getRpcResolvedSetupResult(definition, context);
|
|
513
|
-
if (!result.handler) throw
|
|
513
|
+
if (!result.handler) throw diagnostics.DF0024({ name: definition.name });
|
|
514
514
|
return result.handler;
|
|
515
515
|
}
|
|
516
516
|
//#endregion
|
package/dist/helpers/vite.d.mts
CHANGED
package/dist/helpers/vite.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DEVTOOLS_CONNECTION_META_FILENAME } from "../constants.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { n as resolveBasePath } from "../_shared-
|
|
2
|
+
import { i as diagnostics } from "../shared-state-CasqoUba.mjs";
|
|
3
|
+
import { n as resolveBasePath } from "../_shared-CUFqO4kJ.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-C2wjXjGB.mjs";
|
|
6
6
|
import { resolve } from "pathe";
|
|
7
7
|
//#region src/helpers/vite.ts
|
|
8
8
|
/**
|
|
@@ -54,10 +54,11 @@ function viteDevBridge(d, options = {}) {
|
|
|
54
54
|
openBrowser: false
|
|
55
55
|
});
|
|
56
56
|
} catch (e) {
|
|
57
|
-
|
|
57
|
+
diagnostics.DF0033({
|
|
58
58
|
id: d.id,
|
|
59
|
-
reason: String(e)
|
|
60
|
-
|
|
59
|
+
reason: String(e),
|
|
60
|
+
cause: e
|
|
61
|
+
}, { method: "warn" });
|
|
61
62
|
return;
|
|
62
63
|
}
|
|
63
64
|
const metaPath = `${base}${DEVTOOLS_CONNECTION_META_FILENAME}`;
|