DeepSeek Harness: Declare Plugin Config Fields
Declare a DeepSeek Harness plugin's configurable fields in a TypeScript Config type and an exported, same-named Schemastery schema; Cordis validates the supplied configuration and fills schema defaults when the plugin loads.
DeepSeek Harness: what belongs in plugin configuration?
The plugin configuration guide says values that two deployments may reasonably set differently should be configuration fields. Examples include a greeting, a retry count or a timeout. A TypeScript interface documents the shape used by the implementation; a runtime schema defines validation and defaults. The type alone disappears at runtime and does not validate the values supplied by a deployment.
This authoring task differs from looking up a built-in plugin's settings. The generated configuration catalog describes declared types and documentation for Harness packages. It is useful as an example and a lookup tool, but an entry may also contain a runtime-only field that cannot be supplied in cordis.yml. Do not copy a field from an unrelated plugin and assume your own schema implements it.
DeepSeek Harness: how do I declare fields and defaults?
The guide's example exports both the interface and schema under the name Config:
import type { Context } from '@deepseek-ai/cordis'
import Schema from '@deepseek-ai/schemastery'
export const name = 'my-plugin'
export interface Config {
greeting: string
maxRetries: number
verbose?: boolean
}
export const Config: Schema<Config> = Schema.object({
greeting: Schema.string().default('Hello'),
maxRetries: Schema.number().default(3),
verbose: Schema.boolean().default(false),
})
export function apply(ctx: Context, config: Config) {
console.log(config.greeting)
}
Here the defaults belong to this example, not all plugins. The loader uses the schema to validate the supplied configuration and fill omitted defaults. apply receives the resulting config. The guide specifically warns against exporting a plain object as Config: it does not implement the Standard Schema interface Cordis requires. A TypeScript annotation cannot make a plain object implement that runtime contract.
| Piece | Responsibility | Example consequence |
|---|---|---|
Config interface | Describe the plugin's expected shape | Code can refer to greeting as a string |
| Exported schema | Validate input and declare defaults | Omitted greeting gets the example default |
Plugin row config | Supply deployment-specific values | An explicit greeting overrides the default |
apply | Consume the loaded configuration | Behavior uses the value received at load |
A schema default is not evidence of the effective value in every profile. A particular row can supply another value, and the effective composition depends on its layers. See configuration precedence when investigating an override.
DeepSeek Harness: how do I supply and validate values?
The guide inserts its local plugin row in scratch-plugin/cordis.yml:
- insert:
- id: hello
name: './src/my-plugin.ts'
config:
greeting: 'Hi there'
maxRetries: 5
In this example, verbose is omitted, so the schema's false default applies. The path and row ID are tutorial examples; use the actual location and composition of your plugin. Do not paste the example path into an unrelated deployment and assume it resolves there.
For stricter validation, the guide demonstrates Schema.string().required() for an apiKey, Schema.number().default(30000) for a timeout, and Schema.union(['fast', 'accurate']).default('fast') for a mode. Invalid configuration fails plugin loading with an actionable error. Put self-contained constraints in the schema; checking a reference to another service or registered resource requires the appropriate dependency mechanism, not an invented schema guarantee.
DeepSeek Harness: what is a practical authoring workflow?
- Identify deployment-specific choices and their meanings. Decide which values must be supplied and which have defensible defaults. Document units and semantics, especially for numeric values.
- Define the interface and same-named runtime schema. Keep the declared types, requiredness and actual schema behavior aligned. Apply defaults to fields in the schema, not just in prose.
- Add the plugin to the intended configuration row and provide a representative value. Test omission of each defaulted field and invalid values against the plugin loader in a suitable development environment.
- Observe the configuration passed to the plugin and test the behavior the field controls. A loader accepting a number does not by itself establish that the number makes sense for your service.
- Test an edited value in the composition you actually use. The guide describes hot replacement when HMR is active: the old instance unloads and a new one loads, with its registrations cleaned up. Verify whether your own composition has that capability before relying on an edit to take effect without restart.
When a field fails validation, fix the input or the documented schema deliberately. Preserve the original error for diagnosis, but redact values that may be private. The configuration catalog and finding defaults help inspect built-in examples; they are not proof that a newly authored plugin was loaded with the values you intended.
A useful comparison is to load the same example twice: once with greeting omitted and once with the explicit value from the row. The first checks default insertion; the second checks that the plugin receives the supplied value. Keep the environment and plugin version fixed so a change in behavior can be attributed to the input you changed.
DeepSeek Harness: what are the limits and safety boundaries?
A schema checks the rules it declares. It cannot by itself prove that a credential is authorized, a service exists, or a configuration is appropriate for production. A successful load is evidence of validation and loading, not a security audit or an end-to-end behavior test. The guide's example API key illustrates a required field; do not put real credentials into sample files or commit them to a repository.
The catalog is generated for documented packages and may differ from the version or third-party plugin installed locally. Its TypeScript declaration can include runtime-only seams excluded from YAML. HMR behavior also depends on the actual composition. Keep a reversible change and check the installed version, loader diagnostics and observed behavior before assuming a setting took effect.
DeepSeek Harness: what do the terms mean?
- Config interface: the TypeScript shape expected by plugin code.
- Schemastery schema: the exported runtime validation and default declaration in the guide.
- Plugin row: a composed configuration entry that identifies a plugin and can supply its values.
- Default: a schema-provided value used when the relevant input is omitted.
- HMR: hot replacement of a plugin instance when supported and enabled by the composition.
Frequently asked questions
Is a TypeScript interface enough?
No. Cordis needs an exported runtime schema implementing the required Standard Schema interface.
Where should defaults go?
The guide places defaults directly on the exported schema fields.
Does schema validation prove a service is available?
No. External service and resource checks require their own dependency handling.
Sources
Every claim in this article was checked against the sources below. Community discussions are user reports, not official behavior.
This is an independent community article, not official DeepSeek documentation. Listing a plugin in the registry is not a security review.