@happyrobot-ai/sdk 0.1.24 → 0.1.25
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/package.json +1 -1
- package/resources/voice.d.ts +13 -1
- package/resources/voice.js +13 -1
- package/types/voice.types.d.ts +30 -4
package/package.json
CHANGED
package/resources/voice.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Server-side only. Creates LiveKit tokens that are passed to the
|
|
5
5
|
* browser-side `HappyRobotVoiceClient`.
|
|
6
6
|
*
|
|
7
|
-
* @example
|
|
7
|
+
* @example Start a new call
|
|
8
8
|
* ```ts
|
|
9
9
|
* const client = new HappyRobotClient({ apiKey: "sk_live_..." });
|
|
10
10
|
* const { url, token } = await client.voice.createToken({
|
|
@@ -13,6 +13,14 @@
|
|
|
13
13
|
* });
|
|
14
14
|
* // Pass `url` and `token` to the browser → new HappyRobotVoiceClient({ url, token })
|
|
15
15
|
* ```
|
|
16
|
+
*
|
|
17
|
+
* @example Take over an in-progress call (the AI agent drops)
|
|
18
|
+
* ```ts
|
|
19
|
+
* const { url, token } = await client.voice.createToken({
|
|
20
|
+
* session_id: "the-live-session-id",
|
|
21
|
+
* should_takeover: true,
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
16
24
|
*/
|
|
17
25
|
import type { HttpClient } from "../core/http";
|
|
18
26
|
import type { CreateVoiceTokenBody, CreateVoiceTokenResponse } from "../types/voice.types";
|
|
@@ -24,6 +32,10 @@ export declare class VoiceResource {
|
|
|
24
32
|
*
|
|
25
33
|
* Call this from your server, then pass the returned `url` and `token`
|
|
26
34
|
* to the browser where they can be used to initialize `HappyRobotVoiceClient`.
|
|
35
|
+
*
|
|
36
|
+
* Provide `workflow_id` to start a new call, or `session_id` to join an
|
|
37
|
+
* in-progress call. Pair `session_id` with `should_takeover: true` to drop
|
|
38
|
+
* the AI agent and take over the call.
|
|
27
39
|
*/
|
|
28
40
|
createToken(body: CreateVoiceTokenBody): Promise<CreateVoiceTokenResponse>;
|
|
29
41
|
}
|
package/resources/voice.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Server-side only. Creates LiveKit tokens that are passed to the
|
|
6
6
|
* browser-side `HappyRobotVoiceClient`.
|
|
7
7
|
*
|
|
8
|
-
* @example
|
|
8
|
+
* @example Start a new call
|
|
9
9
|
* ```ts
|
|
10
10
|
* const client = new HappyRobotClient({ apiKey: "sk_live_..." });
|
|
11
11
|
* const { url, token } = await client.voice.createToken({
|
|
@@ -14,6 +14,14 @@
|
|
|
14
14
|
* });
|
|
15
15
|
* // Pass `url` and `token` to the browser → new HappyRobotVoiceClient({ url, token })
|
|
16
16
|
* ```
|
|
17
|
+
*
|
|
18
|
+
* @example Take over an in-progress call (the AI agent drops)
|
|
19
|
+
* ```ts
|
|
20
|
+
* const { url, token } = await client.voice.createToken({
|
|
21
|
+
* session_id: "the-live-session-id",
|
|
22
|
+
* should_takeover: true,
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
17
25
|
*/
|
|
18
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
27
|
exports.VoiceResource = void 0;
|
|
@@ -27,6 +35,10 @@ class VoiceResource {
|
|
|
27
35
|
*
|
|
28
36
|
* Call this from your server, then pass the returned `url` and `token`
|
|
29
37
|
* to the browser where they can be used to initialize `HappyRobotVoiceClient`.
|
|
38
|
+
*
|
|
39
|
+
* Provide `workflow_id` to start a new call, or `session_id` to join an
|
|
40
|
+
* in-progress call. Pair `session_id` with `should_takeover: true` to drop
|
|
41
|
+
* the AI agent and take over the call.
|
|
30
42
|
*/
|
|
31
43
|
async createToken(body) {
|
|
32
44
|
return this.http.request({
|
package/types/voice.types.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
workflow_id: string;
|
|
1
|
+
type CreateVoiceTokenBase = {
|
|
2
|
+
/** Payload data passed to the voice agent as participant attributes (`workflow_id` only). */
|
|
4
3
|
data?: Record<string, unknown>;
|
|
5
4
|
env?: "production" | "staging" | "development";
|
|
6
5
|
/**
|
|
@@ -10,7 +9,33 @@ export interface CreateVoiceTokenBody {
|
|
|
10
9
|
* outlives the TTL.
|
|
11
10
|
*/
|
|
12
11
|
ttl_seconds?: number;
|
|
13
|
-
}
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* POST /voice/tokens request body.
|
|
15
|
+
*
|
|
16
|
+
* Provide exactly one of `workflow_id` (start a new call) or `session_id`
|
|
17
|
+
* (join an in-progress call). `should_takeover` is only available alongside
|
|
18
|
+
* `session_id`.
|
|
19
|
+
*/
|
|
20
|
+
export type CreateVoiceTokenBody = (CreateVoiceTokenBase & {
|
|
21
|
+
/** Workflow UUID or slug to start a new call with. */
|
|
22
|
+
workflow_id: string;
|
|
23
|
+
session_id?: never;
|
|
24
|
+
should_takeover?: never;
|
|
25
|
+
}) | (CreateVoiceTokenBase & {
|
|
26
|
+
/**
|
|
27
|
+
* ID of an in-progress session to join. Generates a token for the
|
|
28
|
+
* session's existing LiveKit room.
|
|
29
|
+
*/
|
|
30
|
+
session_id: string;
|
|
31
|
+
workflow_id?: never;
|
|
32
|
+
/**
|
|
33
|
+
* When `true`, the joining participant takes over the call and the AI
|
|
34
|
+
* agent drops. When `false` (default), the participant joins alongside
|
|
35
|
+
* the agent without dropping it.
|
|
36
|
+
*/
|
|
37
|
+
should_takeover?: boolean;
|
|
38
|
+
});
|
|
14
39
|
/** POST /voice/tokens response. */
|
|
15
40
|
export interface CreateVoiceTokenResponse {
|
|
16
41
|
url: string;
|
|
@@ -18,3 +43,4 @@ export interface CreateVoiceTokenResponse {
|
|
|
18
43
|
room_name: string;
|
|
19
44
|
run_id: string;
|
|
20
45
|
}
|
|
46
|
+
export {};
|