@openmotoko/skill-sdk
v0.1.3
Published
SDK for building OpenMotoko skills
Maintainers
Readme
@openmotoko/skill-sdk
SDK for building OpenMotoko skills.
Install
pnpm add @openmotoko/skill-sdkQuick Start
import { defineSkill } from '@openmotoko/skill-sdk'
import type { SkillManifest } from '@openmotoko/skill-sdk'
import { readFile } from 'node:fs/promises'
const manifest: SkillManifest = JSON.parse(
await readFile(new URL('./manifest.json', import.meta.url), 'utf-8'),
)
export const mySkill = defineSkill(manifest, async (toolName, args, ctx) => {
ctx.log(`Running tool: ${toolName}`)
return {
success: true,
data: { message: 'Hello from my skill!' },
}
})Manifest
Every skill needs a manifest.json:
{
"id": "my-skill",
"name": "My Skill",
"version": "0.1.0",
"description": "What this skill does",
"author": "your-name",
"capabilities": {},
"tools": [
{
"name": "my_tool",
"description": "What this tool does",
"inputSchema": {
"type": "object",
"properties": {
"input": { "type": "string", "description": "The input value" }
},
"required": ["input"]
}
}
]
}API
defineSkill(manifest, handler)
Creates a skill from a manifest and a handler function.
manifest- parsedSkillManifestobjecthandler(toolName, args, ctx)- async function called when a tool is invokedtoolName- name of the tool being calledargs- input arguments asRecord<string, unknown>ctx-SkillContextwithlog()andenvaccess
Returns a ToolResult with { success, data?, error? }.
Types
SkillManifest- full skill manifest schemaToolDefinition- single tool definitionSkillCapabilities- capability declarations (filesystem, shell, network, env)SkillHandler- handler function typeSkillContext- context passed to handlersToolResult- return type from handlers
Helpers
parseJsonInput(raw, schema)- validate input with a Zod schemaformatToolResult(data)- wrap data in a success resultformatError(err)- wrap an error in a failure resultvalidateInput(args, schema)- validate and return typed input or throw
Scaffold a New Skill
npx create-openmotoko-skill my-skill