# What Programming Language Is ego-lite Written In? A Deep Dive into Its TypeScript Architecture

> Discover what programming language ego-lite uses. Explore its TypeScript architecture and Node.js runtime, built with a modern ESM pipeline. Learn more now.

- Repository: [CitroLabs/ego-lite](https://github.com/citrolabs/ego-lite)
- Tags: deep-dive
- Published: 2026-08-03

---

**ego-lite is written in TypeScript, running on the Node.js runtime with a modern ESM-based build pipeline.**

The citrolabs/ego-lite repository is a browser-automation framework built entirely in TypeScript. Every core module, driver, and utility is implemented as `.ts` files that compile to JavaScript, enabling type-safe development for programmatic web scraping and browser control.

## TypeScript as the Primary Language

The codebase follows standard Node.js/TypeScript conventions. All source files reside in `package/ego-browser/src/` and use `.ts` extensions exclusively.

### Source File Organization

The project structure reveals the TypeScript foundation:

- **[`src/index.ts`](https://github.com/citrolabs/ego-lite/blob/main/src/index.ts)** — CLI entry point and module initializer
- **[`src/helpers.ts`](https://github.com/citrolabs/ego-lite/blob/main/src/helpers.ts)** — Public helper functions exposed to agent scripts
- **[`src/cdp-eval.ts`](https://github.com/citrolabs/ego-lite/blob/main/src/cdp-eval.ts)** — Chrome DevTools Protocol evaluation logic
- **[`src/browser-runtime.ts`](https://github.com/citrolabs/ego-lite/blob/main/src/browser-runtime.ts)** — Core browser-automation runtime
- **`src/driver/*.ts`** — Driver modules for navigation, interaction, and control
- **[`src/element-resolver.ts`](https://github.com/citrolabs/ego-lite/blob/main/src/element-resolver.ts)** — DOM element resolution utilities

This architecture demonstrates that ego-lite is not a polyglot project—it commits fully to TypeScript for its entire implementation layer.

## Build Configuration and Tooling

The [`package.json`](https://github.com/citrolabs/ego-lite/blob/main/package.json) in [`package/ego-browser/package.json`](https://github.com/citrolabs/ego-lite/blob/main/package/ego-browser/package.json) declares a Node.js ESM project. TypeScript compilation is controlled by [`tsconfig.json`](https://github.com/citrolabs/ego-lite/blob/main/tsconfig.json), with npm scripts orchestrating the build process using esbuild or rollup before publishing.

### Key Build Files

| File | Purpose |
|------|---------|
| [`package/ego-browser/package.json`](https://github.com/citrolabs/ego-lite/blob/main/package/ego-browser/package.json) | Node.js ESM project declaration |
| [`package/ego-browser/tsconfig.json`](https://github.com/citrolabs/ego-lite/blob/main/package/ego-browser/tsconfig.json) | TypeScript compiler configuration |

These configuration files confirm that every line of source code passes through the TypeScript compiler, producing JavaScript that executes on Node.js.

## Code Examples: TypeScript in Practice

The source code exhibits modern TypeScript patterns: async/await, explicit return types, and JSDoc documentation.

### Helper Functions ([`src/helpers.ts`](https://github.com/citrolabs/ego-lite/blob/main/src/helpers.ts))

```typescript
// src/helpers.ts – example of a public helper exposed to agent scripts
/**
 * Clicks an element located by a CSS selector.
 *
 * @param selector CSS selector string
 */
export async function click(selector: string): Promise<void> {
  const element = await resolveElement(selector);
  await element.click();
}

```

The `click` function demonstrates strict typing: the `selector` parameter is explicitly `string`, and the return type is `Promise<void>`.

### CDP Evaluation ([`src/cdp-eval.ts`](https://github.com/citrolabs/ego-lite/blob/main/src/cdp-eval.ts))

```typescript
// src/cdp-eval.ts – evaluating a JS expression in the page context
export async function js(expr: string): Promise<unknown> {
  const wrapped = `(function(){ return ${expr}; })()`;
  return await sendCDPMessage('Runtime.evaluate', { expression: wrapped });
}

```

Here `js` returns `Promise<unknown>` because the evaluated expression's type cannot be statically determined—showing TypeScript's type system handling dynamic runtime behavior.

### Navigation Driver ([`src/driver/nav.ts`](https://github.com/citrolabs/ego-lite/blob/main/src/driver/nav.ts))

```typescript
// src/driver/nav.ts – navigating to a URL
export async function goto(url: string): Promise<void> {
  await sendCDPMessage('Page.navigate', { url });
  await waitForLoadEvent();
}

```

All driver modules follow this pattern: async functions with typed parameters, interacting with the Chrome DevTools Protocol.

## Why TypeScript for ego-lite?

The TypeScript choice aligns with the project's goals. Browser automation requires reliable interaction with unpredictable web content. TypeScript's static analysis catches errors before runtime, while the compiled output runs natively on Node.js without performance overhead.

The codebase also leverages TypeScript's module system. The ESM configuration in [`package.json`](https://github.com/citrolabs/ego-lite/blob/main/package.json) enables tree-shaking and modern JavaScript features, producing optimized bundles for distribution.

## Summary

- **ego-lite is implemented in TypeScript**, confirmed by `.ts` extensions on all source files and the [`tsconfig.json`](https://github.com/citrolabs/ego-lite/blob/main/tsconfig.json) build configuration
- **Node.js runtime** executes the compiled JavaScript, with ESM module support declared in [`package.json`](https://github.com/citrolabs/ego-lite/blob/main/package.json)
- **File locations**: All source code lives under `package/ego-browser/src/` with predictable naming conventions
- **Type safety**: Core functions like `click`, `js`, and `goto` use explicit TypeScript annotations for parameters and return values
- **Build pipeline**: TypeScript compiles to JavaScript via esbuild or rollup before npm publication

## Frequently Asked Questions

### What version of TypeScript does ego-lite use?

The [`tsconfig.json`](https://github.com/citrolabs/ego-lite/blob/main/tsconfig.json) file specifies the compiler options, though the exact version is managed through [`package.json`](https://github.com/citrolabs/ego-lite/blob/main/package.json) dependencies. The project uses modern TypeScript features including async/await and ESM modules.

### Is ego-lite a pure TypeScript project or does it mix languages?

ego-lite is a pure TypeScript project. All source files in `package/ego-browser/src/` use `.ts` extensions, and no other programming languages appear in the core implementation.

### How does TypeScript compilation work in ego-lite?

The build process runs through npm scripts defined in [`package.json`](https://github.com/citrolabs/ego-lite/blob/main/package.json). TypeScript source compiles to JavaScript via esbuild or rollup, producing distributable ESM modules that Node.js executes directly.

### Can I use ego-lite from JavaScript projects?

Yes. Since TypeScript compiles to standard JavaScript, ego-lite's published npm package contains JavaScript files that any Node.js project—TypeScript or JavaScript—can import and use.