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";
|
import * as z from "zod";
|
||||||
|
|
||||||
export const McpServerConfigSchema = z.object({
|
export const McpServerConfigSchema = z.strictObject({
|
||||||
command: z.string(),
|
command: z.string(),
|
||||||
args: z.array(z.string()).optional(),
|
args: z.array(z.string()).optional(),
|
||||||
env: z.record(z.string(), z.string()).optional(),
|
env: z.record(z.string(), z.string()).optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const DxtManifestAuthorSchema = z.object({
|
export const DxtManifestAuthorSchema = z.strictObject({
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
email: z.string().email().optional(),
|
email: z.string().email().optional(),
|
||||||
url: z.string().url().optional(),
|
url: z.string().url().optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const DxtManifestRepositorySchema = z.object({
|
export const DxtManifestRepositorySchema = z.strictObject({
|
||||||
type: z.string(),
|
type: z.string(),
|
||||||
url: z.string().url(),
|
url: z.string().url(),
|
||||||
});
|
});
|
||||||
|
|
@ -26,18 +26,18 @@ export const DxtManifestMcpConfigSchema = McpServerConfigSchema.extend({
|
||||||
.optional(),
|
.optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const DxtManifestServerSchema = z.object({
|
export const DxtManifestServerSchema = z.strictObject({
|
||||||
type: z.enum(["python", "node", "binary"]),
|
type: z.enum(["python", "node", "binary"]),
|
||||||
entry_point: z.string(),
|
entry_point: z.string(),
|
||||||
mcp_config: DxtManifestMcpConfigSchema,
|
mcp_config: DxtManifestMcpConfigSchema,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const DxtManifestCompatibilitySchema = z
|
export const DxtManifestCompatibilitySchema = z
|
||||||
.object({
|
.strictObject({
|
||||||
claude_desktop: z.string().optional(),
|
claude_desktop: z.string().optional(),
|
||||||
platforms: z.array(z.enum(["darwin", "win32", "linux"])).optional(),
|
platforms: z.array(z.enum(["darwin", "win32", "linux"])).optional(),
|
||||||
runtimes: z
|
runtimes: z
|
||||||
.object({
|
.strictObject({
|
||||||
python: z.string().optional(),
|
python: z.string().optional(),
|
||||||
node: z.string().optional(),
|
node: z.string().optional(),
|
||||||
})
|
})
|
||||||
|
|
@ -45,19 +45,19 @@ export const DxtManifestCompatibilitySchema = z
|
||||||
})
|
})
|
||||||
.passthrough();
|
.passthrough();
|
||||||
|
|
||||||
export const DxtManifestToolSchema = z.object({
|
export const DxtManifestToolSchema = z.strictObject({
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
description: z.string().optional(),
|
description: z.string().optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const DxtManifestPromptSchema = z.object({
|
export const DxtManifestPromptSchema = z.strictObject({
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
description: z.string().optional(),
|
description: z.string().optional(),
|
||||||
arguments: z.array(z.string()).optional(),
|
arguments: z.array(z.string()).optional(),
|
||||||
text: z.string(),
|
text: z.string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const DxtUserConfigurationOptionSchema = z.object({
|
export const DxtUserConfigurationOptionSchema = z.strictObject({
|
||||||
type: z.enum(["string", "number", "boolean", "directory", "file"]),
|
type: z.enum(["string", "number", "boolean", "directory", "file"]),
|
||||||
title: z.string(),
|
title: z.string(),
|
||||||
description: 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())]),
|
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(),
|
$schema: z.string().optional(),
|
||||||
dxt_version: z.string(),
|
dxt_version: z.string(),
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
|
|
@ -104,7 +104,7 @@ export const DxtManifestSchema = z.object({
|
||||||
.optional(),
|
.optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const DxtSignatureInfoSchema = z.object({
|
export const DxtSignatureInfoSchema = z.strictObject({
|
||||||
status: z.enum(["signed", "unsigned", "self-signed"]),
|
status: z.enum(["signed", "unsigned", "self-signed"]),
|
||||||
publisher: z.string().optional(),
|
publisher: z.string().optional(),
|
||||||
issuer: z.string().optional(),
|
issuer: z.string().optional(),
|
||||||
|
|
|
||||||
|
|
@ -65,15 +65,11 @@ describe("DxtManifestSchema", () => {
|
||||||
args: ["main.py"],
|
args: ["main.py"],
|
||||||
env: { PYTHONPATH: "." },
|
env: { PYTHONPATH: "." },
|
||||||
},
|
},
|
||||||
runtime_requirements: {
|
|
||||||
python: ">=3.8",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
tools: [
|
tools: [
|
||||||
{
|
{
|
||||||
name: "my_tool",
|
name: "my_tool",
|
||||||
description: "A useful tool",
|
description: "A useful tool",
|
||||||
input_schema: { type: "object" },
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
keywords: ["test", "example"],
|
keywords: ["test", "example"],
|
||||||
|
|
@ -86,13 +82,6 @@ describe("DxtManifestSchema", () => {
|
||||||
node: ">=16.0.0",
|
node: ">=16.0.0",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
settings: {
|
|
||||||
configurable: true,
|
|
||||||
schema: {
|
|
||||||
type: "object",
|
|
||||||
properties: {},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
user_config: {
|
user_config: {
|
||||||
api_key: {
|
api_key: {
|
||||||
type: "string",
|
type: "string",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue