@elaraai/east

中文文档
1.0.107发布于 2026/11/13AGPL-3.0-or-laterTypeScriptES Module构建来源已验证近 30 天下载 8581

East is a simple and fast language used by Elara AI Pty Ltd.

原始使用文档
文档目录22 节
  1. Motivation
  2. Features
  3. Quick Start
  4. Installation
  5. Basic Example
  6. Type System
  7. Documentation
  8. Key Concepts
  9. Platform Functions
  10. Fluent Interface
  11. Serialization
  12. Examples
  13. Development
  14. Building
  15. Testing
  16. Release Process
  17. Claude Code plugin
  18. License
  19. Contributing
  20. Ecosystem
  21. Links
  22. About Elara

East

East is a statically typed, expression-based programming language embedded in TypeScript. Designed for the Elara platform, East enables you to write portable logic once and execute it across multiple environments (JavaScript, Julia, Python, and more), leveraging each language's native performance characteristics and ecosystem.

Motivation

Delivering a complete business solution requires a wide range of technologies and activities: data integrations, mathematical optimization, machine learning, simulation, user interfaces, authentication & authorization, hosting, managing data consistency, auditing, etc. Multiple programming environments are required to solve any given business problem - for example you may use JavaScript for web front ends and python for training and evaluating machine learning models.

East is designed to make it easy to fuse different technologies together by focussing on a simple yet powerful structural type system which makes all the boilerplate and plumbing work disappear, letting you spend more time solving real-world problems. East is intentionally a simple language that is fast to learn and straightforward to implement in new runtimes.

Features

  • Static Typing: All types, functions and values declared explicitly for speed and correctness
  • Structural Typing: Expressive type system with recursive types, first-class functions and polymorphic variants
  • Portable IR: Compile to JavaScript, Python and Julia
  • Controlled Side Effects: Secure execution with cross-language platform-defined effects
  • LLM Friendly: Designed for AI with clear, composable yet stochastic friendly aliases
  • Serializable: All data can be serialized; functions and closures can be transmitted as IR
  • Minimal Dependencies: Single runtime dependency (sorted-btree for efficient collections)
  • Total Ordering: All types have defined comparisons that are consistent across all language targets

Quick Start

Installation

npm install @elaraai/east

Basic Example

import { East, IntegerType, ArrayType, StructType, StringType, DictType, NullType } from "@elaraai/east";

// Platform function for logging
const log = East.platform("log", [StringType], NullType);

const platform = [
    log.implement(console.log),
];

// Define sale data type
const SaleType = StructType({
    product: StringType,
    quantity: IntegerType,
    price: IntegerType
});

// Calculate revenue per product from sales data
const calculateRevenue = East.function(
    [ArrayType(SaleType)],
    DictType(StringType, IntegerType),
    ($, sales) => {
        // Group sales by product and sum revenue (quantity × price)
        const revenueByProduct = sales.groupSum(
            // Group by product name
            ($, sale) => sale.product,
            // Sum quantity × price
            ($, sale) => sale.quantity.multiply(sale.price)
        );

        // Log revenue for each product
        $(log(East.str`Total Revenue: ${East.Integer.printCurrency(revenueByProduct.sum())}`));

        $.return(revenueByProduct);
    }
);

// Compile and execute
const compiled = East.compile(calculateRevenue, platform);

const sales = [
    { product: "Widget", quantity: 10n, price: 50n },
    { product: "Gadget", quantity: 5n, price: 100n },
    { product: "Widget", quantity: 3n, price: 50n }
];

compiled(sales);
// Total Revenue: $1,150

Type System

East supports a rich type system optimized for business logic and data processing:

TypeValueTypeOfMutabilityDescription
Primitive Types
NullTypenullImmutableUnit type (single value)
BooleanTypebooleanImmutableTrue or false
IntegerTypebigintImmutable64-bit signed integers
FloatTypenumberImmutableIEEE 754 double-precision
StringTypestringImmutableUTF-8 text
DateTimeTypeDateImmutableUTC timestamp with millisecond precision
BlobTypeUint8ArrayImmutableBinary data
Mutable Collections
ArrayType<T>ValueTypeOf<T>[]MutableOrdered collection
SetType<K>Set<ValueTypeOf<K>>MutableSorted set
DictType<K, V>Map<ValueTypeOf<K>, ValueTypeOf<V>>MutableSorted dictionary
RefType<T>ref<ValueTypeOf<T>>MutableRefcell, mutable box
Numeric Arrays
VectorType<FloatType>Float64ArrayMutableDense float vector
VectorType<IntegerType>BigInt64ArrayMutableDense integer vector
VectorType<BooleanType>Uint8ClampedArrayMutableDense boolean vector
MatrixType<T>matrix<TypedArray>MutableDense 2D matrix (row-major)
Compound types
StructType<Fields>{...}ImmutableProduct type (records)
VariantType<Cases>variantImmutableSum type (tagged unions)
RecursiveType<T>ValueTypeOf<T>ImmutableRecursive references for trees, DAGs, and circular structures
Function Type
FunctionType<I, O>FunctionImmutableFirst-class functions/closures
AsyncFunctionType<I, O>Function returning PromiseImmutableAsynchronous functions/closures

Documentation

  • SKILL.md - Comprehensive guide with API and example reference
  • LICENSE.md - Dual licensing information (AGPL-3.0 / Commercial)
  • CONTRIBUTING.md - How to contribute to East
  • CLA.md - Contributor License Agreement

Key Concepts

Platform Functions

East code runs in a controlled environment. You define platform functions that your East code can call:

// Define platform functions
const log = East.platform("log", [StringType], NullType);
const readFile = East.platform("readFile", [StringType], StringType);

// Provide implementations
const platform = [
    log.implement((msg: string) => console.log(msg)),
    readFile.implement((path: string) => fs.readFileSync(path, 'utf-8')),
];

// Compile with platform
const compiled = East.compile(myFunction, platform);

East also supports asyncPlatform functions (which may be called by AsyncFunctionType user-defined functions), inserting await automatically as required. In the above, readFile could have been implemented using fs.promises.readFile to take advantage of concurrency.

Fluent Interface

Build expressions using chainable methods:

const myFunction = East.function([IntegerType], IntegerType, ($, x) => {
    // Arithmetic
    const result = $.const(x.add(10n).multiply(2n));

    // Collections
    const arr = $.const([1n, 2n, 3n]);
    const doubled = $.const(arr.map(($, x, i) => x.multiply(2n)));
    const sum = $.const(doubled.sum());

    // Closures can capture variables from the enclosing scope
    const addResult = $.const(East.function([IntegerType], IntegerType, ($, y) => {
        $.return(y.add(result));
    }));

    $.return(addResult(sum));
});

// Compile and execute
const compiled = East.compile(myFunction, []);
compiled(5n);
// 42n — result = (5+10)*2 = 30, sum of [2,4,6] = 12, addResult(12) = 12+30 = 42

Serialization

All East data can be written and read in any of the following formats:

  • East text format (a JSON-like format designed for the East type system)
  • A binary East format called "beast" (compact, self-describing, streaming)
  • JSON (with a canonical encoding for each East type)

Note that mutable aliasing is preserved through serialization/deserialization.

Function and closure definitions can be serialized as IR in the Beast2 binary format and transmitted across environments to compile and run on the other side:

import { East, IntegerType, Expr, encodeBeast2For, decodeBeast2For } from "@elaraai/east";

const myFunction = East.function([IntegerType], IntegerType, ($, x) => {
    $.return(x.add(1n));
});

// the type of the function (IntegerType -> IntegerType)
const funcType = Expr.type(myFunction);

// Compile the function (this attaches the IR)
const compiled = East.compile(myFunction, []);

// Serialize the compiled function to Beast2 (binary format)
const encode = encodeBeast2For(funcType);
const bytes = encode(compiled);

// Deserialize and recompile
const decode = decodeBeast2For(funcType);
const restored = decode(bytes);

restored(41n); // 42n

Examples

See the SKILL.md for more.

Development

Building

npm run build       # Compile TypeScript to JavaScript
npm run test        # Run test suite (requires build first)
npm run lint        # Check code quality with ESLint
npm run example     # Run the basic example

Testing

East has a comprehensive test suite with tests covering:

  • Type system operations
  • Serialization formats (BEAST v1/v2, JSON, EAST text format)
  • Collections and functional operations
  • Error handling and edge cases

Notably, these tests are hosted in East and allow one to validate the correctness of a new runtime with ease (effectively acting as a compliance suite).

Release Process

@elaraai/east is published together with every other @elaraai/* npm package in the east-workspace monorepo under a single unified version. Releases are triggered manually via the NPM Publish GitHub Actions workflow at the repo root (.github/workflows/npm-publish.yml). There is no per-package release command — see the root README.md for details.

Claude Code plugin

The East ecosystem also ships a Claude Code plugin — East language skills, example search, and preemptive diagnostics for East code — installed separately from the elaraai marketplace:

# Inside Claude Code
/plugin marketplace add elaraai/east-workspace
/plugin install east@elaraai
# From a terminal
claude plugin marketplace add elaraai/east-workspace
claude plugin install east@elaraai

License

This project is dual-licensed:

  • Open Source: AGPL-3.0 - Free for open source use with source disclosure requirements
  • Commercial: Available for proprietary use - contact [email protected]

See LICENSE.md for full details.

Contributing

We welcome contributions! Please see CONTRIBUTING.md for details.

Note: Contributors must sign our CLA before we can accept pull requests. This allows us to offer commercial licenses while keeping the project open source.

Ecosystem

  • East: Statically typed, expression-based language with serializable IR. Run portable logic across TypeScript, Python, C, and other runtimes.

    • @elaraai/east: Core language SDK with type system, expressions, and reference JS compiler
  • East Node: Node.js platform functions for I/O, databases, and system operations.

  • East C: C11 native runtime for executing East IR. Distributed via npm (launcher + per-platform optional dependencies) and as tarballs on each GitHub Release.

    • @elaraai/east-c-cli: npm launcher — installs the matching native binary as an optional dependency
    • east-c: Core runtime — type system, IR interpreter, builtins, serialization (Beast2, JSON, CSV, East text)
    • east-c-std: Console, FileSystem, Fetch, Crypto, Time, Path, Random
    • east-c-cli: CLI for running East IR programs natively
  • East Python: Python runtime, standard platform, I/O, and data-science platform functions. Published to PyPI.

    • east-py: Core Python runtime — type system, IR compiler, 212+ builtins, Cython-accelerated hot paths
    • east-py-std: Console, FileSystem, Fetch, Crypto, Time, Path, Random
    • east-py-io: SQLite, PostgreSQL, MySQL, MongoDB, Redis, S3, FTP, SFTP, XLSX, XML, compression
    • east-py-cli: CLI for running East IR programs in Python
    • east-py-datascience (PyPI) + @elaraai/east-py-datascience (npm): Optimization (MADS, Optuna, ALNS, GoogleOR), ML (XGBoost, LightGBM, NGBoost, PyTorch, Lightning, GP), Bayesian inference (PyMC), explainability (SHAP), conformal prediction (MAPIE)
  • East UI: Typed UI component definitions and React renderer, plus VS Code preview.

  • e3 — East Execution Engine: Durable execution engine for running East pipelines at scale. Git-like content-addressable storage, automatic memoization, reactive dataflow, real-time monitoring.

About Elara

East is developed by Elara AI Pty Ltd, an AI-powered platform that creates economic digital twins of businesses that optimize performance. Elara combines business objectives, decisions and data to help organizations make data-driven decisions across operations, purchasing, sales and customer engagement, and project and investment planning. East powers the computational layer of Elara solutions, enabling the expression of complex business logic and data in a simple, type-safe and portable language.


Developed by Elara AI Pty Ltd.


Developed by Elara AI Pty Ltd

版本与发布记录

@elaraai/east 共发布 150 个版本,首次发布于 2025/12/01;过去 12 个月发布了 150 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.0.107latest2026/11/13今天
1.0.1062026/11/094 天前
1.0.1052026/11/085 天前
1.0.1042026/11/067 天前
1.0.1032026/11/049 天前
1.0.1022026/11/0310 天前

其他发布通道:beta → 0.0.1-beta.43。

关于 @elaraai/east 的常见问题

@elaraai/east 是什么?

East is a simple and fast language used by Elara AI Pty Ltd.

如何安装 @elaraai/east?

在项目目录运行 npm install @elaraai/east,或使用 pnpm add / yarn add / bun add。

@elaraai/east 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@elaraai/east 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@elaraai/east 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@elaraai/east 可以商用吗?

@elaraai/east 使用 AGPL-3.0-or-later 许可。最严格的 Copyleft:除分发外,通过网络向用户提供基于它的服务也需要开源对应源码。闭源 SaaS 使用前务必评估。以上为概括,不构成法律意见,请以许可原文为准。

@elaraai/east 的下载量有多少?

根据 npm 官方下载统计,@elaraai/east 在 2026/10/13 – 2026/11/11 这 30 天内被下载 8,581 次,日均约 286 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@elaraai/east 还在维护吗?

最新版本 1.0.107 发布于 2026/11/13(今天);至今共发布 150 个版本,其中过去 12 个月发布了 150 个;首次发布于 2025/12/01。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。