@inkibra/voice-sdk 0.1.0

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 ADDED
@@ -0,0 +1,75 @@
1
+ # `@inkibra/voice-sdk`
2
+
3
+ The browser and server SDK for Inkibra Live Voice.
4
+
5
+ ```ts
6
+ import LiveVoice from "@inkibra/voice-sdk";
7
+
8
+ const session = await LiveVoice.connect({
9
+ token,
10
+ prompt: "Help the user complete a concise inventory.",
11
+ conversation: {
12
+ starts: "assistant",
13
+ prompt: "Be concise and clarify uncertainty before moving on.",
14
+ },
15
+ tools: {
16
+ update_inventory: {
17
+ description: "Update an inventory item",
18
+ parameters: {
19
+ type: "object",
20
+ properties: { name: { type: "string" }, quantity: { type: "number" } },
21
+ required: ["name", "quantity"],
22
+ additionalProperties: false,
23
+ },
24
+ execute: async ({ name, quantity }) => updateInventory(String(name), Number(quantity)),
25
+ },
26
+ },
27
+ });
28
+
29
+ session.on("transcript.instantaneous", ({ text }) => console.log(text));
30
+ session.on("transcript.canonical", ({ turns }) => console.log(turns));
31
+ session.on("floor", ({ owner, assistantAudible }) => console.log(owner, assistantAudible));
32
+ session.on("assistant.energy", ({ current, predictions }) => {
33
+ animateAgent(current);
34
+ renderAssistantForecast(predictions);
35
+ });
36
+ session.on("phase", ({ phase, previousPhase }) => console.log(phase, previousPhase));
37
+ session.on("tool.call", ({ name, input }) => console.log(name, input));
38
+ session.on("error", console.error);
39
+
40
+ // Later:
41
+ session.stop();
42
+ ```
43
+
44
+ Create the short-lived browser token on your server. Never expose your Inkibra API key to the browser:
45
+
46
+ ```ts
47
+ const response = await fetch("https://inkibra-voice.inkibra.workers.dev/v1/sessions", {
48
+ method: "POST",
49
+ headers: { authorization: `Bearer ${process.env.INKIBRA_API_KEY}`, "content-type": "application/json" },
50
+ body: JSON.stringify({ voice: "ara" }),
51
+ });
52
+
53
+ const { token } = await response.json();
54
+ ```
55
+
56
+ ## Server media
57
+
58
+ Telephone and calling-provider adapters use the server entry point. The adapter supplies PCM16LE mono audio at 24 kHz and maps Inkibra output commands to its provider playback queue.
59
+
60
+ ```ts
61
+ import LiveVoice from "@inkibra/voice/server";
62
+
63
+ const session = await LiveVoice.connect({
64
+ apiKey: process.env.INKIBRA_API_KEY!,
65
+ audio: providerAudioTransport,
66
+ voice: "ara",
67
+ prompt: "Help callers schedule an appointment.",
68
+ conversation: { starts: "assistant" },
69
+ tools: {},
70
+ });
71
+
72
+ await session.closed;
73
+ ```
74
+
75
+ The Durable Object remains the sole owner of conversation state. The server audio transport owns only codec conversion and transient provider playback.
@@ -0,0 +1,2 @@
1
+ export { default } from "./public";
2
+ export * from "./public";