chore: convert plugin to ESM and migrate to current openclaw plugin SDK
ESM conversion:
- package.json: add "type": "module"; drop stale "main": "index.ts"
- tsconfig.json: switch module/moduleResolution to "nodenext"
- plugin/index.ts: replace `module.exports = { register }` and
`module.exports.X = X` with `export default definePluginEntry({ ... })`
plus named ESM re-exports; replace `require('os')`/`require('path')`
with proper imports.
- plugin/tools/pcexec.ts: replace `require('child_process')` with import
from "node:child_process".
- plugin/commands/ego-mgr-slash.ts: replace `require('path')` with
proper path import.
- All relative imports/exports across plugin/ now carry .js extensions
as required by Node ESM (nodenext module resolution).
Plugin SDK convention update:
- Wrap default export with definePluginEntry({ id, name, description,
register }) per the current openclaw authoring contract.
- Type api parameter as OpenClawPluginApi (was `any`); the non-standard
api.registerSlashCommand call is preserved behind a guarded any-cast,
so the plugin remains a no-op for slash commands when the host doesn't
expose that hook (matches the previous defensive guard).
- Add openclaw as a devDependency (file:/usr/lib/node_modules/openclaw)
so tsc can resolve openclaw/plugin-sdk/* subpath types at build time.
- Modernize openclaw.plugin.json: drop entry/version, add
activation.onStartup so gateway_start fires for this plugin at boot,
declare contracts.tools listing pcexec/proxy-pcexec/safe_restart.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
"name": "padded-cell-plugin",
|
||||
"version": "0.2.0",
|
||||
"description": "PaddedCell plugin for OpenClaw - secure exec, password management, coordinated restart",
|
||||
"main": "index.ts",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"dev": "tsc --watch"
|
||||
@@ -15,6 +15,7 @@
|
||||
"devDependencies": {
|
||||
"typescript": "^5.0.0",
|
||||
"@types/express": "^4.17.0",
|
||||
"@types/ws": "^8.5.0"
|
||||
"@types/ws": "^8.5.0",
|
||||
"openclaw": "file:/usr/lib/node_modules/openclaw"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user