@archastro/sdk

中文文档
0.23.0发布于 2026/11/04MITTypeScriptES Module构建来源已验证近 30 天下载 21.6万

TypeScript SDK for the ArchAstro Platform API (Node, browser, React Native)

原始使用文档
文档目录7 节
  1. Documentation
  2. Install
  3. Choose An Auth Mode
  4. Quickstart
  5. React Native / Expo
  6. Integration Guides
  7. Common Resource Pattern

@archastro/sdk

TypeScript SDK for the ArchAstro Platform API.

Documentation

API reference documentation is published at archastro.github.io/archastro-js.

Use this site in two layers:

  • Start with the guides when you are wiring the SDK into an app, worker, or internal tool.
  • Use the API reference when you know the resource or method you need.

Install

npm install @archastro/sdk

Choose An Auth Mode

Most app integrations use a publishable API key plus a user access token:

import { PlatformClient } from "@archastro/sdk";

const client = PlatformClient.withToken(
  process.env.ARCHASTRO_API_KEY ?? "",
  process.env.ARCHASTRO_ACCESS_TOKEN ?? "",
);

Server-side org bots and workers can also use an app-scoped user token directly:

const client = new PlatformClient({
  accessToken: process.env.ARCHASTRO_ACCESS_TOKEN,
});

Set baseUrl only for local development or staging:

import { PlatformClient } from "@archastro/sdk";

const client = PlatformClient.withToken(
  process.env.ARCHASTRO_API_KEY ?? "",
  process.env.ARCHASTRO_ACCESS_TOKEN ?? "",
  process.env.ARCHASTRO_PLATFORM_BASE_URL,
);

Quickstart

const me = await client.users.me();
const teams = await client.teams.list();

console.log(me.id, me.email, teams);

React Native / Expo

Native mobile works out of the box — no Node ws / events polyfills. Use PlatformClient.forApp so session storage, passwordless OTP, and auto-refresh stay behind one client (not a parallel session helper):

import { PlatformClient, ApiChatChannel, type SessionStorage } from "@archastro/sdk";

const client = PlatformClient.forApp({
  publishableKey: process.env.EXPO_PUBLIC_PUBLISHABLE_KEY!,
  baseUrl: process.env.EXPO_PUBLIC_API_BASE_URL!,
  storage, // your SessionStorage (SecureStore / AsyncStorage)
});

await client.restore();
// client.passwordless… → client.signIn(tokens, user)
await client.agents.list();
const socket = client.createSocket();

See React Native guide.

Integration Guides

  • Authentication: choose the right token strategy for browser sessions, server-side app integrations, and org workers.
  • React Native / Expo: session storage, passwordless auth, and chat channels without Node polyfills.
  • Integration scenarios: read the current user, list teams, and create an agent with snippets that were smoke-tested against the local platform dev harness.
  • Custom-object collaboration: team-owned objects, same-origin cookie authentication, realtime snapshots, reconnect recovery, presence, and React cleanup.

Common Resource Pattern

Resources hang directly off PlatformClient and under client.v1:

await client.agents.list();
await client.agents.create({
  name: "Support triage",
  identity: "You triage support requests and keep replies concise.",
});

The generated API surface includes typed REST resources, auth helpers, and channel clients. The lower-level Phoenix Channel client is documented in src/phx_channel/README.md.

版本与发布记录

@archastro/sdk 共发布 28 个版本,首次发布于 2026/04/14;过去 12 个月发布了 28 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.23.0latest2026/11/043 天前
0.22.02026/11/016 天前
0.21.02026/10/2216 天前
0.20.02026/09/251 个月前
0.19.02026/09/191 个月前
0.18.02026/08/282 个月前

关于 @archastro/sdk 的常见问题

@archastro/sdk 是什么?

TypeScript SDK for the ArchAstro Platform API (Node, browser, React Native)

如何安装 @archastro/sdk?

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

@archastro/sdk 支持 TypeScript 吗?

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

@archastro/sdk 支持 ESM 还是 CommonJS?

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

@archastro/sdk 可以商用吗?

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

@archastro/sdk 的下载量有多少?

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

@archastro/sdk 还在维护吗?

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