@laplace.live/persona-sdk

中文文档
1.35.0发布于 2026/11/01MITTypeScriptES Module

TypeScript SDK and wire schema for the LAPLACE Persona plugin API

原始使用文档
文档目录3 节
  1. Setup
  2. Identifying your app
  3. Registry and catalog metadata

@laplace.live/persona-sdk

TypeScript SDK and wire schema for the LAPLACE Persona plugin API — a token-authenticated WebSocket API for driving the avatar, scenes, expressions, motions, hotkeys, and tracking parameters from outside the app.

Isomorphic: runs in Node ≥24, Bun, browsers, and OBS browser sources on the global WebSocket. One runtime dependency (zod, backing the wire schemas).

Setup

Enable the API in Persona under Advanced → Plugin API, create a key, and copy the token.

import { PersonaClient } from '@laplace.live/persona-sdk'

const persona = new PersonaClient({ token: 'sk-lp-v1-…' })
await persona.connect()

// Typed request/response
const { scenes, activeSceneId } = await persona.call('scene.list')
await persona.call('expression.toggle', { name: 'Smile' })
await persona.call('scene.patch', {
  background: { mode: 'color', color: '#112233', imageAssetId: null },
})

// Events (subscriptions survive reconnects)
persona.on('motion.started', m => console.log('playing', m.group))

// Parameter leases: the value keeps applying until released; the SDK owns the
// heartbeat, and if your process dies the parameter reverts within ~1 s.
const mouth = persona.driveParameter('MouthOpen', 0.8)
mouth.set(0.3)
mouth.release()

By default the token travels as ?token= (works in browsers). From Node, createNodeClient sends it as an Authorization: Bearer header instead, over Node's global WebSocket, and logs the close that ends a session for good (the key revoked, or the session disconnected in Persona):

import { createNodeClient } from '@laplace.live/persona-sdk'

const persona = createNodeClient({ token, log: console.warn })
await persona.connect()

Any other socket that can set headers, such as the ws package, plugs into new PersonaClient({ token, auth: "header", createWebSocket }).

Identifying your app

Pass clientInfo so your app shows up by name under Connected Clients in Persona's settings (optional — unidentified clients work the same). The SDK re-declares it on every reconnect; it is self-declared and display-only, never authorization:

const persona = new PersonaClient({
  token,
  clientInfo: { name: 'My Overlay', version: '1.2.0', developer: 'You' },
})

Two server close codes are terminal and stop the reconnect loop: CLOSE_KEY_REVOKED (4001, the key was revoked) and CLOSE_FORCE_DISCONNECTED (4002, the user disconnected the session in Persona). The client reports them via onWarning and goes closed.

Treat the token like a password: it grants control of the app, including loading registered models and web overlays. The server listens on loopback unless LAN access is enabled in Persona's settings.

Registry and catalog metadata

model.list / asset.list return refs with provenance and attribution: every ref carries origin ('bundled' for first-party content, shipped with the app or downloaded from the Persona catalog; 'user' for anything the user added) and may carry optional author / url credits.

CatalogItem is the transport-agnostic content-metadata shape behind pickers: a stable id (scene refs key off it), an InventoryKind, display name, and optional description, thumbnailUrl, previewUrl (a short looping video shown in the thumbnail's place), version, author, url, and download (a CatalogDownload: an https zip with its byte size and sha256). The Persona marketplace serves its catalog as { version, items } at https://marketplace.laplace.live + MARKETPLACE_ITEMS_PATH. healCatalog turns a parsed document into usable rows, dropping malformed ones, and pickLocalized(item.description, locale) reads a description in the reader's language, falling back to English.

healCatalogItem heals one row, and healCatalogRows(raw, healRow) a document through a row healer of your own, keeping the first of two ids equal ignoring case. A row needs an id that passes isCatalogId (one path-safe segment, since an id names an install folder), a non-blank name, and a kind from CATALOG_KINDS; CATALOG_FORMAT is the document's version. healSha256 reads a digest as 64 lowercase hex characters, and payloadEntryPath checks a payload zip's entry name, answering the relative POSIX path an extractor may write, or null; no two of a payload's entries may share a payloadEntryKey. healLocalizedText heals a LocalizedText (en required, the other shipped locales optional) and never promotes another locale to en.

版本与发布记录

@laplace.live/persona-sdk 共发布 62 个版本,首次发布于 2026/08/11;过去 12 个月发布了 62 个版本。

版本发布日期距今
1.35.0latest2026/11/011 天前
1.34.02026/10/304 天前
1.33.02026/10/267 天前
1.32.02026/10/259 天前
1.31.02026/10/2410 天前
1.30.02026/10/2310 天前

关于 @laplace.live/persona-sdk 的常见问题

@laplace.live/persona-sdk 是什么?

拉普拉斯Persona插件API的TypeScript SDK和连线模式

如何安装 @laplace.live/persona-sdk?

在项目目录运行 npm install @laplace.live/persona-sdk,或使用 pnpm add / yarn add / bun add。

@laplace.live/persona-sdk 支持 TypeScript 吗?

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

@laplace.live/persona-sdk 支持 ESM 还是 CommonJS?

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

@laplace.live/persona-sdk 需要什么版本的 Node.js?

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

@laplace.live/persona-sdk 可以商用吗?

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

@laplace.live/persona-sdk 还在维护吗?

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