dev/zhi #1
63
install.mjs
63
install.mjs
@@ -12,7 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { execSync } from 'child_process';
|
import { execSync } from 'child_process';
|
||||||
import { existsSync, mkdirSync, copyFileSync, chmodSync } from 'fs';
|
import { existsSync, mkdirSync, copyFileSync, writeFileSync, chmodSync } from 'fs';
|
||||||
import { dirname, join, resolve } from 'path';
|
import { dirname, join, resolve } from 'path';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
import { homedir, platform } from 'os';
|
import { homedir, platform } from 'os';
|
||||||
@@ -317,6 +317,67 @@ async function installComponents(env) {
|
|||||||
// Create bin directory
|
// Create bin directory
|
||||||
mkdirSync(binDir, { recursive: true });
|
mkdirSync(binDir, { recursive: true });
|
||||||
|
|
||||||
|
// Create openclaw.plugin.json if not exists
|
||||||
|
const manifestPath = join(__dirname, 'openclaw.plugin.json');
|
||||||
|
if (!existsSync(manifestPath)) {
|
||||||
|
const manifest = {
|
||||||
|
id: PLUGIN_NAME,
|
||||||
|
name: 'PaddedCell',
|
||||||
|
version: '0.1.0',
|
||||||
|
description: 'Secure password management, safe execution, and coordinated restart',
|
||||||
|
entry: './index.js',
|
||||||
|
configSchema: {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
enabled: { type: 'boolean', default: true }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
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'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
writeFileSync(manifestPath, JSON.stringify(manifest, null, 2));
|
||||||
|
logSuccess('Created openclaw.plugin.json');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create index.js if not exists
|
||||||
|
const indexPath = join(__dirname, 'index.js');
|
||||||
|
if (!existsSync(indexPath)) {
|
||||||
|
const indexContent = `// PaddedCell Plugin Entry Point
|
||||||
|
export const id = '${PLUGIN_NAME}';
|
||||||
|
export const name = 'PaddedCell';
|
||||||
|
export const version = '0.1.0';
|
||||||
|
|
||||||
|
// Export tools (will be loaded by OpenClaw)
|
||||||
|
export { pcexec } from './pcexec/dist/index.js';
|
||||||
|
export {
|
||||||
|
safeRestart,
|
||||||
|
createSafeRestartTool,
|
||||||
|
StatusManager,
|
||||||
|
createApiServer,
|
||||||
|
startApiServer
|
||||||
|
} from './safe-restart/dist/index.js';
|
||||||
|
|
||||||
|
// Default export
|
||||||
|
export default {
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
version,
|
||||||
|
};
|
||||||
|
`;
|
||||||
|
writeFileSync(indexPath, indexContent);
|
||||||
|
logSuccess('Created index.js');
|
||||||
|
}
|
||||||
|
|
||||||
// Install pass_mgr binary
|
// Install pass_mgr binary
|
||||||
log(' Installing pass_mgr binary...', 'blue');
|
log(' Installing pass_mgr binary...', 'blue');
|
||||||
const passMgrSource = join(__dirname, 'pass_mgr', 'dist', 'pass_mgr');
|
const passMgrSource = join(__dirname, 'pass_mgr', 'dist', 'pass_mgr');
|
||||||
|
|||||||
Reference in New Issue
Block a user