fix: strictly validate manifests (#66)
* fix: strictly validate manifests * spec: align tests with strict schema
This commit is contained in:
parent
641213ad47
commit
9523b5af19
2 changed files with 11 additions and 22 deletions
|
|
@ -1,18 +1,18 @@
|
|||
import * as z from "zod";
|
||||
|
||||
export const McpServerConfigSchema = z.object({
|
||||
export const McpServerConfigSchema = z.strictObject({
|
||||
command: z.string(),
|
||||
args: z.array(z.string()).optional(),
|
||||
env: z.record(z.string(), z.string()).optional(),
|
||||
});
|
||||
|
||||
export const DxtManifestAuthorSchema = z.object({
|
||||
export const DxtManifestAuthorSchema = z.strictObject({
|
||||
name: z.string(),
|
||||
email: z.string().email().optional(),
|
||||
url: z.string().url().optional(),
|
||||
});
|
||||
|
||||
export const DxtManifestRepositorySchema = z.object({
|
||||
export const DxtManifestRepositorySchema = z.strictObject({
|
||||
type: z.string(),
|
||||
url: z.string().url(),
|
||||
});
|
||||
|
|
@ -26,18 +26,18 @@ export const DxtManifestMcpConfigSchema = McpServerConfigSchema.extend({
|
|||
.optional(),
|
||||
});
|
||||
|
||||
export const DxtManifestServerSchema = z.object({
|
||||
export const DxtManifestServerSchema = z.strictObject({
|
||||
type: z.enum(["python", "node", "binary"]),
|
||||
entry_point: z.string(),
|
||||
mcp_config: DxtManifestMcpConfigSchema,
|
||||
});
|
||||
|
||||
export const DxtManifestCompatibilitySchema = z
|
||||
.object({
|
||||
.strictObject({
|
||||
claude_desktop: z.string().optional(),
|
||||
platforms: z.array(z.enum(["darwin", "win32", "linux"])).optional(),
|
||||
runtimes: z
|
||||
.object({
|
||||
.strictObject({
|
||||
python: z.string().optional(),
|
||||
node: z.string().optional(),
|
||||
})
|
||||
|
|
@ -45,19 +45,19 @@ export const DxtManifestCompatibilitySchema = z
|
|||
})
|
||||
.passthrough();
|
||||
|
||||
export const DxtManifestToolSchema = z.object({
|
||||
export const DxtManifestToolSchema = z.strictObject({
|
||||
name: z.string(),
|
||||
description: z.string().optional(),
|
||||
});
|
||||
|
||||
export const DxtManifestPromptSchema = z.object({
|
||||
export const DxtManifestPromptSchema = z.strictObject({
|
||||
name: z.string(),
|
||||
description: z.string().optional(),
|
||||
arguments: z.array(z.string()).optional(),
|
||||
text: z.string(),
|
||||
});
|
||||
|
||||
export const DxtUserConfigurationOptionSchema = z.object({
|
||||
export const DxtUserConfigurationOptionSchema = z.strictObject({
|
||||
type: z.enum(["string", "number", "boolean", "directory", "file"]),
|
||||
title: z.string(),
|
||||
description: z.string(),
|
||||
|
|
@ -76,7 +76,7 @@ export const DxtUserConfigValuesSchema = z.record(
|
|||
z.union([z.string(), z.number(), z.boolean(), z.array(z.string())]),
|
||||
);
|
||||
|
||||
export const DxtManifestSchema = z.object({
|
||||
export const DxtManifestSchema = z.strictObject({
|
||||
$schema: z.string().optional(),
|
||||
dxt_version: z.string(),
|
||||
name: z.string(),
|
||||
|
|
@ -104,7 +104,7 @@ export const DxtManifestSchema = z.object({
|
|||
.optional(),
|
||||
});
|
||||
|
||||
export const DxtSignatureInfoSchema = z.object({
|
||||
export const DxtSignatureInfoSchema = z.strictObject({
|
||||
status: z.enum(["signed", "unsigned", "self-signed"]),
|
||||
publisher: z.string().optional(),
|
||||
issuer: z.string().optional(),
|
||||
|
|
|
|||
|
|
@ -65,15 +65,11 @@ describe("DxtManifestSchema", () => {
|
|||
args: ["main.py"],
|
||||
env: { PYTHONPATH: "." },
|
||||
},
|
||||
runtime_requirements: {
|
||||
python: ">=3.8",
|
||||
},
|
||||
},
|
||||
tools: [
|
||||
{
|
||||
name: "my_tool",
|
||||
description: "A useful tool",
|
||||
input_schema: { type: "object" },
|
||||
},
|
||||
],
|
||||
keywords: ["test", "example"],
|
||||
|
|
@ -86,13 +82,6 @@ describe("DxtManifestSchema", () => {
|
|||
node: ">=16.0.0",
|
||||
},
|
||||
},
|
||||
settings: {
|
||||
configurable: true,
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {},
|
||||
},
|
||||
},
|
||||
user_config: {
|
||||
api_key: {
|
||||
type: "string",
|
||||
|
|
|
|||
Loading…
Reference in a new issue