@laplace.live/persona-sdk 0.0.1 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,24 +12,24 @@ One runtime dependency ([`zod`](https://zod.dev), backing the wire schemas).
|
|
|
12
12
|
Enable the API in Persona under **Advanced → Plugin API**, create a key, and copy the token.
|
|
13
13
|
|
|
14
14
|
```ts
|
|
15
|
-
import { PersonaClient } from
|
|
15
|
+
import { PersonaClient } from "@laplace.live/persona-sdk";
|
|
16
16
|
|
|
17
|
-
const persona = new PersonaClient({ token:
|
|
18
|
-
await persona.connect()
|
|
17
|
+
const persona = new PersonaClient({ token: "sk-lp-v1-…" });
|
|
18
|
+
await persona.connect();
|
|
19
19
|
|
|
20
20
|
// Typed request/response
|
|
21
|
-
const { scenes, activeSceneId } = await persona.call(
|
|
22
|
-
await persona.call(
|
|
23
|
-
await persona.call(
|
|
21
|
+
const { scenes, activeSceneId } = await persona.call("scene.list");
|
|
22
|
+
await persona.call("expression.toggle", { name: "Smile" });
|
|
23
|
+
await persona.call("scene.patch", { behavior: { lookAtCursor: true } });
|
|
24
24
|
|
|
25
25
|
// Events (subscriptions survive reconnects)
|
|
26
|
-
persona.on(
|
|
26
|
+
persona.on("motion.started", (m) => console.log("playing", m.group));
|
|
27
27
|
|
|
28
28
|
// Parameter leases: the value keeps applying until released; the SDK owns the
|
|
29
29
|
// heartbeat, and if your process dies the parameter reverts within ~1 s.
|
|
30
|
-
const mouth = persona.driveParameter(
|
|
31
|
-
mouth.set(0.3)
|
|
32
|
-
mouth.release()
|
|
30
|
+
const mouth = persona.driveParameter("MouthOpen", 0.8);
|
|
31
|
+
mouth.set(0.3);
|
|
32
|
+
mouth.release();
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
By default the token travels as `?token=` (works in browsers). From Node you can use an
|
|
@@ -38,13 +38,14 @@ By default the token travels as `?token=` (works in browsers). From Node you can
|
|
|
38
38
|
dependency of this SDK):
|
|
39
39
|
|
|
40
40
|
```ts
|
|
41
|
-
import WebSocket from
|
|
41
|
+
import WebSocket from "ws";
|
|
42
42
|
|
|
43
43
|
const persona = new PersonaClient({
|
|
44
44
|
token,
|
|
45
|
-
auth:
|
|
46
|
-
createWebSocket: (url, headers) =>
|
|
47
|
-
})
|
|
45
|
+
auth: "header",
|
|
46
|
+
createWebSocket: (url, headers) =>
|
|
47
|
+
new WebSocket(url, { headers }) as unknown as globalThis.WebSocket,
|
|
48
|
+
});
|
|
48
49
|
```
|
|
49
50
|
|
|
50
51
|
Treat the token like a password: it grants control of the app, including loading registered
|