commit bb367eb9526beaaee7fdfb33d5b5f787d6be8c1d Author: openclaw Date: Tue Oct 13 05:38:03 2026 +0000 chore: openclaw plugins init tools diff --git a/README.md b/README.md new file mode 100644 index 0000000..538bf50 --- /dev/null +++ b/README.md @@ -0,0 +1,12 @@ +# Tools + +Simple OpenClaw tool plugin. + +## Build + +```bash +npm install +npm run plugin:build +npm run plugin:validate +npm test +``` diff --git a/openclaw.plugin.json b/openclaw.plugin.json new file mode 100644 index 0000000..4483167 --- /dev/null +++ b/openclaw.plugin.json @@ -0,0 +1,19 @@ +{ + "id": "tools", + "name": "Tools", + "description": "Add Tools tools to OpenClaw.", + "version": "0.1.0", + "configSchema": { + "type": "object", + "additionalProperties": false, + "properties": {} + }, + "activation": { + "onStartup": true + }, + "contracts": { + "tools": [ + "echo" + ] + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..0f0956b --- /dev/null +++ b/package.json @@ -0,0 +1,39 @@ +{ + "name": "openclaw-plugin-tools", + "version": "0.1.0", + "type": "module", + "private": true, + "scripts": { + "build": "tsc -p tsconfig.json", + "plugin:build": "npm run build && openclaw plugins build --entry ./dist/index.js", + "plugin:validate": "npm run build && openclaw plugins validate --entry ./dist/index.js", + "test": "vitest run --config ./vitest.config.ts" + }, + "files": [ + "dist", + "openclaw.plugin.json", + "README.md" + ], + "peerDependencies": { + "openclaw": ">=2026.5.17" + }, + "dependencies": { + "typebox": "^1.1.38" + }, + "devDependencies": { + "openclaw": "latest", + "typescript": "7.0.2", + "vitest": "^3.2.0" + }, + "openclaw": { + "extensions": [ + "./dist/index.js" + ], + "compat": { + "pluginApi": ">=2026.5.17" + }, + "build": { + "openclawVersion": "2026.10.1" + } + } +} diff --git a/src/index.test.ts b/src/index.test.ts new file mode 100644 index 0000000..1c66811 --- /dev/null +++ b/src/index.test.ts @@ -0,0 +1,9 @@ +import { describe, expect, it } from "vitest"; +import entry from "./index.js"; +import { getToolPluginMetadata } from "openclaw/plugin-sdk/tool-plugin"; + +describe("tools", () => { + it("declares tool metadata", () => { + expect(getToolPluginMetadata(entry)?.tools.map((tool) => tool.name)).toEqual(["echo"]); + }); +}); diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..d33abea --- /dev/null +++ b/src/index.ts @@ -0,0 +1,18 @@ +import { Type } from "typebox"; +import { defineToolPlugin } from "openclaw/plugin-sdk/tool-plugin"; + +export default defineToolPlugin({ + id: "tools", + name: "Tools", + description: "Add Tools tools to OpenClaw.", + tools: (tool) => [ + tool({ + name: "echo", + description: "Echo input text.", + parameters: Type.Object({ + input: Type.String({ description: "Text to echo." }), + }), + execute: async ({ input }) => ({ input }), + }), + ], +}); diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..eb6660e --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "NodeNext", + "moduleResolution": "NodeNext", + "strict": true, + "declaration": true, + "rootDir": "src", + "outDir": "dist", + "skipLibCheck": true + }, + "include": [ + "src/index.ts" + ] +} diff --git a/vitest.config.ts b/vitest.config.ts new file mode 100644 index 0000000..c1433e6 --- /dev/null +++ b/vitest.config.ts @@ -0,0 +1,8 @@ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + environment: "node", + include: ["src/**/*.test.ts"], + }, +});