tinyagent
Version:
Connect your local shell to any device - access your dev environment from anywhere
71 lines • 3.16 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const commander_1 = require("commander");
const chalk_1 = __importDefault(require("chalk"));
const dotenv_1 = require("dotenv");
const shell_client_v2_1 = require("./shell-client-v2");
const qr_generator_1 = require("./qr-generator");
(0, dotenv_1.config)();
const program = new commander_1.Command();
program
.name('tinyagent')
.description('Connect your local shell to any device')
.version('1.0.5')
.argument('[sessionId]', 'Session ID to connect to (optional, auto-generated if not provided)')
.option('--session-id <id>', 'Session ID (alternative to positional argument)')
.option('-r, --relay <url>', 'Relay server URL', process.env.RELAY_URL || 'wss://relay.tinyagent.app')
.option('-s, --shell <shell>', 'Shell to use', process.env.SHELL || '/bin/bash')
.option('-c, --command <cmd>', 'Server command to run (e.g., "npm run dev")')
.option('-p, --port <port>', 'Local server port', '3000')
.option('--no-tunnel', 'Disable tunnel creation')
.option('--no-claude', 'Do not auto-start Claude')
.option('-v, --verbose', 'Show detailed debug output')
.option('--password <password>', 'Password required for mobile clients to connect')
.option('--resume', 'Resume the last Claude session')
.option('--continue', 'Continue the last Claude session (alias for --resume)')
.action(async (sessionIdArg, options) => {
// Determine session ID from argument or option, or generate one
let sessionId = sessionIdArg || options.sessionId;
if (!sessionId) {
// Generate a random session ID
sessionId = Math.random().toString(36).substring(2, 15);
console.log(chalk_1.default.cyan(`Generated session ID: ${sessionId}`));
}
try {
console.log(chalk_1.default.blue(`Connecting to session: ${sessionId}`));
// Always show QR code for easy mobile connection
(0, qr_generator_1.generateConnectionQR)(sessionId, options.relay);
const client = new shell_client_v2_1.ShellClient({
sessionId,
relayUrl: options.relay,
shell: options.shell,
serverCommand: options.command,
serverPort: parseInt(options.port),
createTunnel: options.tunnel,
autoStartClaude: !options.noClaude,
password: options.password,
resumeClaude: options.resume || options.continue,
verbose: options.verbose
});
await client.connect();
process.on('SIGINT', () => {
console.log(chalk_1.default.yellow('\nDisconnecting...'));
client.disconnect();
process.exit(0);
});
process.on('SIGTERM', () => {
client.disconnect();
process.exit(0);
});
}
catch (error) {
console.error(chalk_1.default.red(`Error: ${error}`));
process.exit(1);
}
});
program.parse();
//# sourceMappingURL=cli.js.map