dev/zhi #1
77
index.js
77
index.js
@@ -1,4 +1,7 @@
|
||||
const { pcexec } = require('./pcexec/dist/index.js');
|
||||
// PaddedCell Plugin for OpenClaw
|
||||
// Registers pcexec and safe_restart tools
|
||||
|
||||
const { pcexec, pcexecSync } = require('./pcexec/dist/index.js');
|
||||
const {
|
||||
safeRestart,
|
||||
createSafeRestartTool,
|
||||
@@ -8,12 +11,66 @@ const {
|
||||
SlashCommandHandler
|
||||
} = require('./safe-restart/dist/index.js');
|
||||
|
||||
module.exports = {
|
||||
pcexec,
|
||||
safeRestart,
|
||||
createSafeRestartTool,
|
||||
StatusManager,
|
||||
createApiServer,
|
||||
startApiServer,
|
||||
SlashCommandHandler,
|
||||
};
|
||||
// Plugin initialization function
|
||||
function init(api, config) {
|
||||
const logger = api.logger || { info: console.log, error: console.error };
|
||||
|
||||
logger.info('PaddedCell plugin initializing...');
|
||||
|
||||
// Register pcexec tool
|
||||
api.registerTool({
|
||||
name: 'pcexec',
|
||||
description: 'Safe exec with password sanitization',
|
||||
parameters: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
command: { type: 'string', description: 'Command to execute' },
|
||||
cwd: { type: 'string', description: 'Working directory' },
|
||||
timeout: { type: 'number', description: 'Timeout in milliseconds' },
|
||||
},
|
||||
required: ['command'],
|
||||
},
|
||||
async handler(params) {
|
||||
return await pcexec(params.command, {
|
||||
cwd: params.cwd,
|
||||
timeout: params.timeout,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
// Register safe_restart tool
|
||||
api.registerTool({
|
||||
name: 'safe_restart',
|
||||
description: 'Safe coordinated restart of OpenClaw gateway',
|
||||
parameters: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
rollback: { type: 'string', description: 'Rollback script path' },
|
||||
log: { type: 'string', description: 'Log file path' },
|
||||
},
|
||||
},
|
||||
async handler(params, context) {
|
||||
return await safeRestart({
|
||||
agentId: context.agentId,
|
||||
sessionKey: context.sessionKey,
|
||||
rollback: params.rollback,
|
||||
log: params.log,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
logger.info('PaddedCell plugin initialized');
|
||||
}
|
||||
|
||||
// Export for OpenClaw
|
||||
module.exports = { init };
|
||||
|
||||
// Also export individual modules for direct use
|
||||
module.exports.pcexec = pcexec;
|
||||
module.exports.pcexecSync = pcexecSync;
|
||||
module.exports.safeRestart = safeRestart;
|
||||
module.exports.createSafeRestartTool = createSafeRestartTool;
|
||||
module.exports.StatusManager = StatusManager;
|
||||
module.exports.createApiServer = createApiServer;
|
||||
module.exports.startApiServer = startApiServer;
|
||||
module.exports.SlashCommandHandler = SlashCommandHandler;
|
||||
|
||||
@@ -7,19 +7,8 @@
|
||||
"configSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"enabled": { "type": "boolean", "default": true }
|
||||
"enabled": { "type": "boolean", "default": true },
|
||||
"passMgrPath": { "type": "string", "default": "/root/.openclaw/bin/pass_mgr" }
|
||||
}
|
||||
},
|
||||
"tools": [
|
||||
{
|
||||
"name": "pcexec",
|
||||
"entry": "./pcexec/dist/index.js",
|
||||
"description": "Safe exec with password sanitization"
|
||||
},
|
||||
{
|
||||
"name": "safe_restart",
|
||||
"entry": "./safe-restart/dist/index.js",
|
||||
"description": "Safe coordinated restart"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user