Lines 1-44javascript
2import express from 'express';
3import cors from 'cors';
4import { EventEmitter } from 'events';
5import { Runner } from '../core/runner.js';
6import { Logger } from '../utils/logger.js';
7import { Command } from 'commander';
8import * as readline from 'readline';
9import { spawn } from 'child_process';
10import * as fs from 'fs';
HighChild Process
Package source references child process execution.
dist/cli/agent.jsView on unpkg · L8 11import * as path from 'path';
12import { fileURLToPath } from 'url';
13import { ConfigManager } from '../utils/configManager.js';
14const __filename = fileURLToPath(import.meta.url);
15const __dirname = path.dirname(__filename);
16const program = new Command();
18 .name('scrapit-agent')
19 .description('Local execution agent for Scrapit OS')
22 .command('serve', { isDefault: true })
23 .description('Start the local agent server')
24 .option('-p, --port <number>', 'Port to run the agent on', '4001')
25 .option('-u, --auth-uri <uri>', 'Cloud service base URI', 'http://localhost:4000')
26 .option('-d, --daemon', 'Run agent in background as a daemon')
27 .action(async (options) => {
28 if (options.daemon && !process.env.__DETACHED__) {
29 console.log('🚀 Starting Scrapit Agent in background...');
30 const logDir = ConfigManager.getInstance().getLogBaseDir();
31 if (!fs.existsSync(logDir))
32 fs.mkdirSync(logDir, { recursive: true });
33 const out = fs.openSync(path.join(logDir, 'agent.log'), 'a');
34 const err = fs.openSync(path.join(logDir, 'agent.err'), 'a');
35 const child = spawn(process.argv[0], [...process.argv.slice(1)], {
36 detached: true,
HighSame File Env Network Execution
A single source file combines environment access, network access, and code or shell execution; review context before blocking.
dist/cli/agent.jsView on unpkg · L24 37 stdio: ['ignore', out, err],
38 env: { ...process.env, __DETACHED__: 'true' }
43 await startAgent(options);