@alienplatform/commands

中文文档
3.3.54发布于 2026/11/05FSL-1.1-Apache-2.0TypeScriptES Module近 30 天下载 4234

Pure-TypeScript command sender and pull receiver for the Alien platform, over fetch

原始使用文档
文档目录4 节
  1. Install
  2. Send from an external app
  3. Receive in an external app
  4. Self-hosted manager

@alienplatform/commands

Send commands to an Alien deployment or receive them from any Node or Bun process. For hosted Alien, an ordinary app needs no alien.ts, manager URL, or manually minted token. The package is pure TypeScript over fetch.

Install

npm install @alienplatform/commands

Requires Node 18+ or Bun 1.0.23+.

Send from an external app

Connect with the deployment ID and a server-side Alien API key:

import { CommandsClient } from "@alienplatform/commands"

const commands = await CommandsClient.forDeployment({
  deploymentId: "dep_123",
  apiKey: process.env.ALIEN_API_KEY!,
})

const result = await commands
  .target("image-processor")
  .invoke<{ ok: boolean }>("health-check", {})

Alien discovers the deployment's current manager and mints short-lived, commands-only access. The API key is sent only to the Alien API; the client uses the short-lived credential with the manager and refreshes it internally.

Receive in an external app

Name the command-enabled Container or Daemon this process serves:

import { createCommandReceiver } from "@alienplatform/commands"

const receiver = createCommandReceiver({
  deploymentId: "dep_123",
  apiKey: process.env.ALIEN_API_KEY!,
  target: "image-processor",
})

receiver.command("health-check", async () => ({ ok: true }))

process.on("SIGTERM", () => receiver.stop())
await receiver.run()

The target is explicit because one deployment can contain several command-capable resources. Discovery starts when run() starts; Alien resolves whether the target is a Container or Daemon and issues short-lived access limited to that deployment and target.

Apps deployed by Alien remain zero-config because Alien injects their receiver identity and credentials:

const receiver = createCommandReceiver()
receiver.command("health-check", async () => ({ ok: true }))
await receiver.run()

Self-hosted manager

The explicit constructor remains available for self-hosting and local development:

const commands = new CommandsClient({
  managerUrl: "http://localhost:8080",
  deploymentId: "dep_123",
  token: process.env.ALIEN_COMMANDS_TOKEN!,
})

For an explicit receiver, configure the existing ALIEN_COMMANDS_* environment variables and call createCommandReceiver().

Both hosted APIs accept platformUrl when the Alien Platform API is not at https://api.alien.dev.

A disconnected installation sets ALIEN_COMMANDS_DISABLED=true for command-capable workloads. The receiver accepts handler registration and waits until stop() without making network requests. Without this explicit setting, missing receiver configuration still fails at startup.

版本与发布记录

@alienplatform/commands 共发布 71 个版本,首次发布于 2026/07/20;过去 12 个月发布了 71 个版本。

版本发布日期距今
3.3.54latest2026/11/051 天前
3.3.532026/11/042 天前
3.3.522026/11/042 天前
3.3.512026/11/042 天前
3.3.502026/11/033 天前
3.3.492026/11/024 天前

其他发布通道:dev → 3.3.42-dev.6e3a661b219b3886d55014b3cef8af0ecdcc65fe。

关于 @alienplatform/commands 的常见问题

@alienplatform/commands 是什么?

Pure-TypeScript command sender and pull receiver for the Alien platform, over fetch

如何安装 @alienplatform/commands?

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

@alienplatform/commands 支持 TypeScript 吗?

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

@alienplatform/commands 支持 ESM 还是 CommonJS?

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

@alienplatform/commands 需要什么版本的 Node.js?

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

@alienplatform/commands 可以商用吗?

@alienplatform/commands 使用 FSL-1.1-Apache-2.0 许可。声明的许可为 FSL-1.1-Apache-2.0,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

@alienplatform/commands 的下载量有多少?

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

@alienplatform/commands 还在维护吗?

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