77 lines
2.2 KiB
JavaScript
77 lines
2.2 KiB
JavaScript
// PaddedCell Plugin for OpenClaw
|
|
// Registers pcexec and safe_restart tools
|
|
|
|
const { pcexec, pcexecSync } = require('./pcexec/dist/index.js');
|
|
const {
|
|
safeRestart,
|
|
createSafeRestartTool,
|
|
StatusManager,
|
|
createApiServer,
|
|
startApiServer,
|
|
SlashCommandHandler
|
|
} = require('./safe-restart/dist/index.js');
|
|
|
|
// Plugin registration function (OpenClaw expects 'register' or 'activate')
|
|
function register(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 = { register };
|
|
|
|
// 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;
|