Skip to content

Commit 1112b4d

Browse files
authored
fix(inspect): drop @valibot/to-json-schema runtime dependency (#200)
1 parent e4a04cc commit 1112b4d

5 files changed

Lines changed: 13 additions & 29 deletions

File tree

plugins/inspect/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
}
5757
},
5858
"dependencies": {
59-
"@valibot/to-json-schema": "catalog:deps",
6059
"cac": "catalog:deps",
6160
"nostics": "catalog:deps"
6261
},

plugins/inspect/src/rpc/functions/_schema.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { StandardJSONSchemaV1, StandardSchemaV1 } from '@standard-schema/spec'
2-
import { toJsonSchema } from '@valibot/to-json-schema'
32

43
const FALLBACK_SCHEMA = Object.freeze({ type: 'object', additionalProperties: true })
54

@@ -9,17 +8,19 @@ type MaybeJsonSchema = StandardSchemaV1['~standard'] & Partial<StandardJSONSchem
98
/**
109
* Convert a schema to JSON Schema for the inspector, vendor-neutrally.
1110
*
12-
* Prefers the schema's own Standard JSON Schema converter
13-
* (`~standard.jsonSchema`, implemented by e.g. zod 4), then falls back to
14-
* valibot's converter, then to a permissive object — so introspection never
15-
* throws regardless of which validator produced the schema.
11+
* Uses the schema's own [Standard JSON Schema](https://standardschema.dev/)
12+
* converter (`~standard.jsonSchema`, implemented by e.g. zod 4) when the
13+
* validator provides one, and degrades to a permissive object schema
14+
* otherwise (e.g. valibot, which has no native converter) — so introspection
15+
* never throws and never pulls in a converter library for a validator devframe
16+
* doesn't otherwise depend on.
1617
*/
1718
function convert(schema: unknown): unknown {
1819
const standard = (schema as StandardSchemaV1)['~standard'] as MaybeJsonSchema
20+
if (!standard.jsonSchema)
21+
return FALLBACK_SCHEMA
1922
try {
20-
if (standard.jsonSchema)
21-
return standard.jsonSchema.input({ target: 'draft-2020-12' })
22-
return toJsonSchema(schema as never)
23+
return standard.jsonSchema.input({ target: 'draft-2020-12' })
2324
}
2425
catch {
2526
return FALLBACK_SCHEMA

plugins/inspect/src/types.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ export interface RpcFunctionAgentInfo {
1818
/**
1919
* Serializable description of a single registered RPC function. Returned
2020
* by `devframes:plugin:inspect:list-functions`. JSON-safe by construction
21-
* — valibot schemas are projected to JSON Schema (best effort), never
22-
* sent as live objects.
21+
* — Standard Schema args/return schemas are projected to JSON Schema (best
22+
* effort), never sent as live objects.
2323
*/
2424
export interface RpcFunctionInfo {
2525
/** Full namespaced function name (e.g. `my-plugin:do-thing`). */
@@ -32,9 +32,9 @@ export interface RpcFunctionInfo {
3232
snapshot: boolean
3333
/** Whether results may be cached client-side. */
3434
cacheable: boolean
35-
/** Whether an args valibot schema is declared. */
35+
/** Whether an args schema is declared. */
3636
hasArgs: boolean
37-
/** Whether a return valibot schema is declared. */
37+
/** Whether a return schema is declared. */
3838
hasReturns: boolean
3939
/** Whether an explicit dump definition is declared. */
4040
hasDump: boolean

pnpm-lock.yaml

Lines changed: 0 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ catalogs:
7777
'@modelcontextprotocol/client': ^2.0.0
7878
'@modelcontextprotocol/server': ^2.0.0
7979
'@standard-schema/spec': ^1.1.0
80-
'@valibot/to-json-schema': ^1.7.1
8180
birpc: ^4.1.0
8281
cac: ^7.0.0
8382
chokidar: ^5.0.0

0 commit comments

Comments
 (0)