Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion plugins/inspect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
}
},
"dependencies": {
"@valibot/to-json-schema": "catalog:deps",
"cac": "catalog:deps",
"nostics": "catalog:deps"
},
Expand Down
17 changes: 9 additions & 8 deletions plugins/inspect/src/rpc/functions/_schema.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { StandardJSONSchemaV1, StandardSchemaV1 } from '@standard-schema/spec'
import { toJsonSchema } from '@valibot/to-json-schema'

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

Expand All @@ -9,17 +8,19 @@ type MaybeJsonSchema = StandardSchemaV1['~standard'] & Partial<StandardJSONSchem
/**
* Convert a schema to JSON Schema for the inspector, vendor-neutrally.
*
* Prefers the schema's own Standard JSON Schema converter
* (`~standard.jsonSchema`, implemented by e.g. zod 4), then falls back to
* valibot's converter, then to a permissive object — so introspection never
* throws regardless of which validator produced the schema.
* Uses the schema's own [Standard JSON Schema](https://standardschema.dev/)
* converter (`~standard.jsonSchema`, implemented by e.g. zod 4) when the
* validator provides one, and degrades to a permissive object schema
* otherwise (e.g. valibot, which has no native converter) — so introspection
* never throws and never pulls in a converter library for a validator devframe
* doesn't otherwise depend on.
*/
function convert(schema: unknown): unknown {
const standard = (schema as StandardSchemaV1)['~standard'] as MaybeJsonSchema
if (!standard.jsonSchema)
return FALLBACK_SCHEMA
try {
if (standard.jsonSchema)
return standard.jsonSchema.input({ target: 'draft-2020-12' })
return toJsonSchema(schema as never)
return standard.jsonSchema.input({ target: 'draft-2020-12' })
}
catch {
return FALLBACK_SCHEMA
Expand Down
8 changes: 4 additions & 4 deletions plugins/inspect/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export interface RpcFunctionAgentInfo {
/**
* Serializable description of a single registered RPC function. Returned
* by `devframes:plugin:inspect:list-functions`. JSON-safe by construction
* — valibot schemas are projected to JSON Schema (best effort), never
* sent as live objects.
* — Standard Schema args/return schemas are projected to JSON Schema (best
* effort), never sent as live objects.
*/
export interface RpcFunctionInfo {
/** Full namespaced function name (e.g. `my-plugin:do-thing`). */
Expand All @@ -32,9 +32,9 @@ export interface RpcFunctionInfo {
snapshot: boolean
/** Whether results may be cached client-side. */
cacheable: boolean
/** Whether an args valibot schema is declared. */
/** Whether an args schema is declared. */
hasArgs: boolean
/** Whether a return valibot schema is declared. */
/** Whether a return schema is declared. */
hasReturns: boolean
/** Whether an explicit dump definition is declared. */
hasDump: boolean
Expand Down
15 changes: 0 additions & 15 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ catalogs:
'@modelcontextprotocol/client': ^2.0.0
'@modelcontextprotocol/server': ^2.0.0
'@standard-schema/spec': ^1.1.0
'@valibot/to-json-schema': ^1.7.1
birpc: ^4.1.0
cac: ^7.0.0
chokidar: ^5.0.0
Expand Down
Loading