@telorun/sdk

中文文档
0.127.0发布于 2026/11/02MITTypeScriptES Module

Telo SDK - Public API for Telo module authors.

原始使用文档
文档目录3 节
  1. What It Provides
  2. When to Use It
  3. Errors

Telo SDK (Node.js)

The Node.js SDK provides the authoring surface for Telo modules. It defines the shared contracts (types and lifecycle interfaces) that modules use to plug into the kernel, so module code stays consistent across implementations.

What It Provides

  • Module interfaces for registering resources and handling execution.
  • Context types for accessing the kernel, registry, and events.
  • Shared primitives used by Telo modules and tooling.

When to Use It

Use the SDK when building or extending Telo modules. It is not the kernel itself; it is the contract layer that keeps module behavior consistent and predictable.

Errors

Telo distinguishes two kinds of failure from an Invocable / Runnable:

  • Operational failures — plain Error or RuntimeError throws. Propagate to the kernel's infrastructure layer (HTTP → Fastify 5xx, sequence → bubbles up). These represent bugs or environment failure.
  • Domain failures — InvokeError throws. Part of the invocable's public contract. Route handlers match on error.code via catches: entries; sequences handle them in try/catch.
import { InvokeError, isInvokeError } from "@telorun/sdk";

// In a controller:
throw new InvokeError("UNAUTHORIZED", "Token missing or invalid", {
  reason: "expired",
});

// Anywhere a thrown value crosses a boundary:
if (isInvokeError(err)) {
  // err.code, err.message, err.data
}

Use isInvokeError(err) for recognition — it's dual-realm-safe (survives pnpm hoist splits, registry-loaded modules with their own SDK copy, and future sandbox isolation). instanceof InvokeError is not reliable across package boundaries.

Controllers that throw InvokeError must declare their codes in their Telo.Definition:

kind: Telo.Definition
metadata: { name: VerifyToken }
capability: Telo.Invocable
throws:
  codes:
    UNAUTHORIZED: { description: Missing or invalid token. }
    EXPIRED:
      description: Token is past its expires_at.
      data:
        type: object
        properties:
          expiredAt: { type: string, format: date-time }
        required: [expiredAt]

Undeclared codes emit an ${kind}.${name}.InvokeRejected.Undeclared observability event — the analyzer catches these statically.

Composers that propagate rather than originate codes can declare:

throws:
  inherit: true   # union of everything I call (requires x-telo-step-context)
  # or
  passthrough: true   # union is whatever my inputs.code resolves to (Run.Throw-style)

inherit is driven by the analyzer's dataflow pass over x-telo-step-context arrays; future composers opt in by declaring both the annotation and inherit: true. See modules/run/docs/structured-errors.md for the end-to-end flow.

版本与发布记录

@telorun/sdk 共发布 105 个版本,首次发布于 2026/02/18;过去 12 个月发布了 105 个版本。

版本发布日期距今
0.127.0latest2026/11/02今天
0.126.02026/11/011 天前
0.125.12026/10/313 天前
0.125.02026/10/304 天前
0.124.02026/10/295 天前
0.123.12026/10/268 天前

关于 @telorun/sdk 的常见问题

@telorun/sdk 是什么?

Telo SDK - Telo模块作者的公共API。

如何安装 @telorun/sdk?

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

@telorun/sdk 支持 TypeScript 吗?

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

@telorun/sdk 支持 ESM 还是 CommonJS?

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

@telorun/sdk 可以商用吗?

@telorun/sdk 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@telorun/sdk 还在维护吗?

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