feat: add openclaw-plugin-dev skill
Plugin development reference and workflows based on real development experience (Dirigent, ContractorAgent, PrismFacet). Docs: structure, entry-point, hooks, tools, state, config, debugging Workflows: create-plugin, add-hook Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
40
openclaw-plugin-dev/docs/tools.md
Normal file
40
openclaw-plugin-dev/docs/tools.md
Normal file
@@ -0,0 +1,40 @@
|
||||
# Tool Registration
|
||||
|
||||
## Interface
|
||||
|
||||
```typescript
|
||||
// Without agent context
|
||||
api.registerTool({
|
||||
name: "my-tool",
|
||||
description: "Does something",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
param: { type: "string", description: "..." },
|
||||
},
|
||||
required: ["param"],
|
||||
},
|
||||
execute: async (toolCallId, params) => {
|
||||
const { param } = params as { param: string };
|
||||
return { result: "ok" };
|
||||
},
|
||||
});
|
||||
|
||||
// With agent context (factory function)
|
||||
api.registerTool((ctx) => ({
|
||||
name: "my-contextual-tool",
|
||||
description: "...",
|
||||
inputSchema: { /* ... */ },
|
||||
execute: async (toolCallId, params) => {
|
||||
const agentId = ctx.agentId;
|
||||
return { result: agentId };
|
||||
},
|
||||
}));
|
||||
```
|
||||
|
||||
## Key Points
|
||||
|
||||
- Interface is `execute: async (toolCallId, params)`, NOT `handler:`
|
||||
- Use `inputSchema` (JSON Schema), NOT `parameters`
|
||||
- Return `{ result: "..." }` object
|
||||
- Factory form `(ctx) => ({...})` gives access to agent context (agentId, sessionKey, etc.)
|
||||
Reference in New Issue
Block a user