defineModule
defineModule lives in @knetikdotdev/sdk. It returns the definition after checking it, and throws on the first problem.
import { defineModule, v } from '@knetikdotdev/sdk';v is Valibot, re-exported so modules use the same copy as the host.
Fields
Section titled “Fields”| Field | Type | Meaning |
|---|---|---|
id |
string | Lowercase letters, digits and dashes, starting with a letter. Used in URLs and agent identities. |
version |
string | Shown in the dashboard and recorded on each install. |
title |
string | The name people see. |
description |
string, optional | A short summary shown on the module card. |
input |
Valibot schema | The start form. The host converts it to JSON Schema and renders a form. |
config |
Valibot schema, optional | Per-deployment settings. See Config schema. |
connectors |
record, optional | The integrations the module needs. See below. |
stages |
list | At least one. See Stages. |
ui |
object, optional | How the dashboard presents the module. See Module UI. |
Input schema and form labels
Section titled “Input schema and form labels”Use Valibot’s title action to label a field. The form uses it as the field label.
input: v.object({ from: v.pipe(v.picklist(['topic', 'url', 'text']), v.title('Start from')), material: v.pipe(v.string(), v.minLength(2), v.maxLength(20000), v.title('Topic, link or text')), images: v.optional(v.pipe(v.boolean(), v.title('Draw images to choose from'))),}),Declaring connectors
Section titled “Declaring connectors”Each key is the connector name you use in code. Each value is a ConnectorNeed.
connectors: { slack: { scopes: ['chat:write'], required: false }, google: { scopes: ['https://www.googleapis.com/auth/drive.file'], required: false }, tools: { provider: 'mcp', url: 'https://mcp.example.com/mcp' },},| Property | Meaning |
|---|---|
provider |
'slack', 'google' or 'mcp'. Defaults to the key when the key is slack or google. Must be stated for mcp. |
scopes |
The OAuth scopes the module needs. The host asks for exactly these. |
required |
Default true: the run is blocked until the connector is connected. Set false for optional connectors. |
url |
For mcp only. Pinned here so it is reviewed when the module is installed. |
See Connectors.
What defineModule rejects
Section titled “What defineModule rejects”- an id that is not lowercase letters, digits and dashes;
- duplicate stage ids, or no stages;
- a connector name that is not lowercase with dashes, a missing provider, a non-http(s) MCP url, or a
urlon a non-MCP connector; - a gate whose
regenerate.stageis not an earlier stage; - a stage that
requiresa connector that is not declared; - a
uidescriptor with a problem (unknown keys, paths to stages that do not exist, and so on).
What the host publishes
Section titled “What the host publishes”The dashboard receives a serializable summary: id, version, title, description, the input and config JSON Schemas, the connectors, the ui descriptor, and the stage list (id, kind, requires, whether it is conditional, the agent key, and gate details). No functions cross to the browser.