@elaraai/e3-api-client

中文文档
1.0.107发布于 2026/11/13BUSL-1.1TypeScriptES Module构建来源已验证近 30 天下载 5446

East Execution Engine API Client - TypeScript client library for e3 API server

原始使用文档
文档目录17 节
  1. Installation
  2. Overview
  3. API
  4. Repository
  5. Packages
  6. Workspaces
  7. Datasets
  8. Tasks
  9. Execution
  10. Function calls
  11. One-shot calls
  12. Split calls
  13. Claude Code plugin
  14. License
  15. Ecosystem
  16. Links
  17. About Elara

@elaraai/e3-api-client

TypeScript client library for e3 API servers.

Installation

npm install @elaraai/e3-api-client

Overview

Stateless functions for interacting with an e3 API server. Uses BEAST2 binary serialization for efficient request/response encoding.

API

Repository

import { repoStatus, repoGc } from '@elaraai/e3-api-client';

const status = await repoStatus('http://localhost:3000');
// { path: '/path/to/repo', objectCount: 42n, packageCount: 3n, workspaceCount: 2n }

// Keep each workspace's last 5 runs and 30 days of history; the server's
// defaults when `none`
const gcResult = await repoGc(url, { dryRun: true, minAge: none, keepRuns: some(5n), keepDays: some(30n) });
// { deletedRuns: 2n, deletedExecutions: 14n, deletedObjects: 0n, retainedObjects: 42n, bytesFreed: 0n, ... }

Packages

import { packageList, packageImport, packageGet, packageExport, packageRemove } from '@elaraai/e3-api-client';

// List all packages
const packages = await packageList(url);
// [{ name: 'my-pkg', version: '1.0.0' }, ...]

// Import a package from zip bytes
const result = await packageImport(url, zipBytes);
// { name: 'my-pkg', version: '1.0.0', packageHash: 'abc123...', objectCount: 5n }

// Get package object
const pkg = await packageGet(url, 'my-pkg', '1.0.0');

// Export package as zip
const zip = await packageExport(url, 'my-pkg', '1.0.0');

// Remove package
await packageRemove(url, 'my-pkg', '1.0.0');

Workspaces

import { workspaceList, workspaceCreate, workspaceGet, workspaceStatus, workspaceDeploy, workspaceRemove } from '@elaraai/e3-api-client';

// Create workspace
const info = await workspaceCreate(url, 'production');
// { name: 'production', deployed: false, packageName: null, packageVersion: null }

// Deploy package to workspace: the server runs the deploy as a job, which
// this polls, and answers what it decided for each record and index
const deployed = await workspaceDeploy(url, 'production', '[email protected]');
// { records: [{ record: 'records/plans', action: <mint | keep | migrate | reset | drop | refused> }], indexes: [...], warnings: [] }

// Get workspace status
const status = await workspaceStatus(url, 'production');
// { workspace: 'production', datasets: [...], tasks: [...], summary: { ... } }

// List workspaces
const workspaces = await workspaceList(url);

A view that follows a few datasets asks for those alone: workspaceStatus(url, repo, ws, options, { paths }) answers the datasets named that the workspace has, and the tasks producing them, each as the whole status gives it. It costs the server what the view binds, not the workspace.

A poll asks conditionally: workspaceStatusSince(url, repo, ws, etag, options, query) answers the status with its ETag, and null while the status answered under the tag it was given is current, which costs the server a read of the workspace's revision and nothing else. The tag does not name the runner's view of an execution recorded running, so a poll that must notice a runner gone asks unconditionally (etag null) now and then. A poll gains nothing from retrying a transient failure, since its next poll is its retry: pollRequestOptions(options) gives it one attempt (NO_RETRY) unless the caller set a policy of its own.

Datasets

import { datasetList, datasetListAt, datasetGet, datasetSet } from '@elaraai/e3-api-client';
import { encodeBeast2For, decodeBeast2For, StringType, variant } from '@elaraai/east';

// List root fields
const fields = await datasetList(url, 'production');
// ['inputs', 'tasks']

// List nested fields
const inputFields = await datasetListAt(url, 'production', [variant('field', 'inputs')]);
// ['config', 'data']

// Get dataset value (raw BEAST2 bytes)
const path = [variant('field', 'inputs'), variant('field', 'config')];
const bytes = await datasetGet(url, 'production', path);
const value = decodeBeast2For(StringType)(bytes);

// Set dataset value
const encoded = encodeBeast2For(StringType)('new value');
await datasetSet(url, 'production', path, encoded);

datasetGet downloads a collection as the segment objects its manifest names, a few at a time, checks each against its hash, and splices them into the value's bytes, so no response carries more than one segment and a server whose host caps its responses still serves a collection of any size.

A dataset that moves while it is read (a run writes a new value, and the old one's objects can no longer be fetched) is read again. datasetGet starts over from the new content, at most 3 times, and returns its hash. datasetGetStream starts over only before it returns. Once it has returned a hash, its chunks end in a DatasetHashMismatchError naming the content the dataset holds now (currentHash), and the caller starts over. A manifest above level 0, which only a newer e3 writes, is refused, naming the update to make.

A value named by its hash rather than by a dataset, such as a record's state at a past commit, is read through the objects route the same way: collectionGetStream streams a collection by its manifest's hash, collectionOpen opens one to read a window at a time (below), and objectGet reads any other value, which is one object. The caller picks by the value's type. A client of a host's own routes reads a page with parsePage, as datasetGetPage reads its own, and a JSON refusal with parseErrorBody, so it throws the ApiError codes the rest of the client does.

Tasks

import { taskList, taskGet } from '@elaraai/e3-api-client';

// List tasks
const tasks = await taskList(url, 'production');
// [{ name: 'compute', hash: 'abc123...', role: <data | ui> }, ...]

// Get task details
const task = await taskGet(url, 'production', 'compute');
// { name: 'compute', hash: '...', body: <east program | command>, runner: <runtime>,
//   inputs: [{ path, partition }], output: { path, kind }, role: <data | ui> }

Execution

import { dataflowExecuteLaunch, dataflowExecute, dataflowGraph, taskLogs } from '@elaraai/e3-api-client';

// Start execution (non-blocking), re-running every task even where cached
await dataflowExecuteLaunch(url, 'production', { force: true });

// Execute and wait for result (blocking), re-running only the tasks named;
// a filter is one task's exact name, run with the tasks it depends on
const result = await dataflowExecute(url, 'production', { force: ['import_sales'] });
// { success: true, executed: 1n, cached: 0n, failed: 0n, tasks: [...], duration: 1.234 }

// Get dependency graph
const graph = await dataflowGraph(url, 'production');
// { tasks: [{ name: 'compute', inputs: [...], output: '...', dependsOn: [...] }] }

// Read task logs
const logs = await taskLogs(url, 'production', 'compute', { stream: 'stdout' });
// { data: '...', offset: 0n, size: 1024n, totalSize: 2048n, complete: false }

Function calls

import {
  workspaceFunctionCall, workspaceFunctionStart, workspaceFunctionCallStatus, workspaceFunctionCallCancel,
  workspaceCallList, workspaceCallGet,
} from '@elaraai/e3-api-client';
import { encodeBeast2For, IntegerType, none, variant } from '@elaraai/east';

// Call a function of the workspace's package and wait for its result,
// however long it runs
const stop = new AbortController();
const result = await workspaceFunctionCall(url, repo, 'production', 'forecast', {
  args: [variant('value', encodeBeast2For(IntegerType)(12n))], runner: none, limits: none,
}, options, { signal: stop.signal, onStarted: (id) => console.log(`call ${id} runs on`) });
// { outcome: <success | failed | invalid | too_large | timed_out>, stdout, stderr, inputs, ... }

// The calls the workspace keeps, the latest first, and one whole
const page = await workspaceCallList(url, repo, 'production', options, { state: 'failed' });
// { calls: [{ id, function: <some(name) | none for a one-shot>, caller, startedAt, endedAt, state }, ...], next: <none | some(cursor)> }
const call = await workspaceCallGet(url, repo, 'production', page.calls[0].id, options);
// { function, package: <some({ name, version }) | none>, args, inputs, limits, state: <succeeded { value: hash } | …>, stdout, stderr, expiresAt, ... }

A call through a workspace is the server's, and outlives the request that starts it. workspaceFunctionCall starts it, which waits up to the server's window (20 s), and polls a call still running to its end, each poll held by the server until the call ends or a while passes, 250 ms apart at first and backing off to 2 s: a call runs as long as its timeout allows, the server's ceiling unless its limits ask for less. The client names the call before it sends it, a UUIDv7 of its own, so aborting signal stops waiting at once — whatever the fetch does with the abort — and asks the server to stop the call by that id, its start's answer or not; the ask is sent keepalive, so one a closing page makes still reaches the server. onStarted is told the id of a call that runs on past its start, and startWaitMs tells it sooner. A server that predates kept calls is called through the sync route, workspaceFunctionCallSync, which a caller may also name itself to answer within one request.

The pieces apart: workspaceFunctionStart(…, { waitMs, id }) answers the call's id and status (?wait=0 answers running at once; an id of the caller's, a UUIDv7 of now, names the call, and the server sets aside one far from its clock), workspaceFunctionCallStatus(…, id, options, { waitMs, signal }) its status — running, completed with its result, cancelled naming who asked, or lost — and workspaceFunctionCallCancel asks a running call to stop. The server keeps each call for its lifetime, an hour for a success or a cancel and a week for any other end: who made it, its arguments, the versions of the inputs it read, its value and its logs, by hash, which objectGet reads.

One-shot calls

import { oneShotCall, oneShotExecute } from '@elaraai/e3-api-client';

// Run a program of the caller's over the workspace's datasets, kept among the
// workspace's calls, and wait for its result however long it runs
const result = await oneShotCall(url, repo, 'production', request, options, { signal: stop.signal });
// { outcome: <success | failed | invalid | too_large | timed_out>, stdout, stderr, inputs, ... }

// Or within one request, its timeout clamped under the server's sync
// deadline, keeping nothing
const quick = await oneShotExecute(url, repo, 'production', request, options);

A one-shot is held to the caller's grant: one who may read the workspace runs a platform-free program, a stock runner given no platform and a body that calls none, and only an elevated grant any other. oneShotCall starts it as a call (oneShotStart) and follows it as workspaceFunctionCall follows a function's: its timeout the server's ceiling unless its limits ask for less, polled to its end, stopped by signal through the id the client named it by, and onStarted told its id. The workspace keeps it, naming no function or package, so workspaceCallList lists it and workspaceCallGet reads it, and its status and cancel are a function call's (workspaceFunctionCallStatus, workspaceFunctionCallCancel). A server that predates kept one-shots runs it within one request, as oneShotExecute does.

Split calls

import { collectionOpen, splitCall, splitCallCancel, splitCallLaunch, splitCallStatus } from '@elaraai/e3-api-client';
import { decodeBeast2For, variant } from '@elaraai/east';

// Run a program over a dataset's pieces as a job, polled to its end. Aborting
// the signal stops polling and cancels the job, so the server stops its units;
// the call rejects with the signal's reason.
const controller = new AbortController();
const { result, output, report } = await splitCall(url, 'my-repo', 'production', request, { token }, {
  onProgress: (progress) => console.log(progress.phase.type, progress.done, progress.units),
  signal: controller.signal,
});
// report: { pieces, ran, cached, peakBytes } — the pieces its input was cut
// into, the units this call ran and the cache served it, and the highest peak
// a unit reached. A call the cache served whole ran 0 and was served 0, and
// still names its pieces and peak.

// An array's first `limit` elements, in input order: the body emits as an
// array call's does, and the pieces run in order, a few at a time, stopping
// once they hold that many. The pieces are shared with an array call's.
const firstMatch = await splitCall(url, 'my-repo', 'production', { ...request, output: variant('first', { limit: 1n }) }, { token });

// A value over the call's result limit is answered too_large, naming the
// stored output instead: open it, and read it a window at a time. Each window
// fetches only the segments it overlaps, each checked against its hash.
if (result.outcome.type === 'too_large' && output !== null) {
  const remote = await collectionOpen(url, 'my-repo', output, { token });
  // remote.type: the collection's type; remote.totalElements: how many it holds
  const page = await remote.page({ offset: 1_000, limit: 100 });
  const rows = decodeBeast2For(remote.type)(page.data);
  // page.count: fewer than asked at the end, and none past it
}

// Or launch, poll and cancel it yourself
const { id } = await splitCallLaunch(url, 'my-repo', 'production', request, { token });
const status = await splitCallStatus(url, 'my-repo', 'production', id, { token });
// processing | completed { result, output, report } | planned | failed | cancelled
const after = await splitCallCancel(url, 'my-repo', 'production', id, { token });
// cancelled, or the status the job had already ended with

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

BSL 1.1. See LICENSE.md.

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/e3-api-client 共发布 165 个版本,首次发布于 2025/12/13;过去 12 个月发布了 165 个版本。最新版本附带 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 天前

其他发布通道:alpha → 0.0.1-alpha.3,beta → 0.0.2-beta.54。

关于 @elaraai/e3-api-client 的常见问题

@elaraai/e3-api-client 是什么?

East Execution Engine API Client - TypeScript client library for e3 API server

如何安装 @elaraai/e3-api-client?

在项目目录运行 npm install @elaraai/e3-api-client,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@elaraai/east(1.0.107)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@elaraai/e3-api-client 支持 TypeScript 吗?

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

@elaraai/e3-api-client 支持 ESM 还是 CommonJS?

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

@elaraai/e3-api-client 可以商用吗?

@elaraai/e3-api-client 使用 BUSL-1.1 许可。声明的许可为 BUSL-1.1,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

@elaraai/e3-api-client 的下载量有多少?

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

@elaraai/e3-api-client 还在维护吗?

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