@livekit/agents-plugin-anam 0.0.0-next-20260624041820
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/LICENSE +201 -0
- package/README.md +17 -0
- package/dist/api.cjs +165 -0
- package/dist/api.cjs.map +1 -0
- package/dist/api.d.cts +26 -0
- package/dist/api.d.ts +26 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +143 -0
- package/dist/api.js.map +1 -0
- package/dist/avatar.cjs +117 -0
- package/dist/avatar.cjs.map +1 -0
- package/dist/avatar.d.cts +34 -0
- package/dist/avatar.d.ts +34 -0
- package/dist/avatar.d.ts.map +1 -0
- package/dist/avatar.js +94 -0
- package/dist/avatar.js.map +1 -0
- package/dist/avatar.test.cjs +23 -0
- package/dist/avatar.test.cjs.map +1 -0
- package/dist/avatar.test.d.cts +2 -0
- package/dist/avatar.test.d.ts +2 -0
- package/dist/avatar.test.d.ts.map +1 -0
- package/dist/avatar.test.js +22 -0
- package/dist/avatar.test.js.map +1 -0
- package/dist/index.cjs +38 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/types.cjs +30 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +28 -0
- package/dist/types.d.ts +28 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/package.json +54 -0
- package/src/api.ts +187 -0
- package/src/avatar.test.ts +30 -0
- package/src/avatar.ts +138 -0
- package/src/index.ts +19 -0
- package/src/types.ts +32 -0
package/dist/avatar.cjs
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var avatar_exports = {};
|
|
20
|
+
__export(avatar_exports, {
|
|
21
|
+
AvatarSession: () => AvatarSession,
|
|
22
|
+
mintAvatarJoinToken: () => mintAvatarJoinToken
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(avatar_exports);
|
|
25
|
+
var import_agents = require("@livekit/agents");
|
|
26
|
+
var import_rtc_node = require("@livekit/rtc-node");
|
|
27
|
+
var import_livekit_server_sdk = require("livekit-server-sdk");
|
|
28
|
+
var import_api = require("./api.cjs");
|
|
29
|
+
var import_types = require("./types.cjs");
|
|
30
|
+
async function mintAvatarJoinToken({
|
|
31
|
+
roomName,
|
|
32
|
+
avatarIdentity,
|
|
33
|
+
publishOnBehalf,
|
|
34
|
+
apiKey = process.env.LIVEKIT_API_KEY,
|
|
35
|
+
apiSecret = process.env.LIVEKIT_API_SECRET,
|
|
36
|
+
ttl = "60s"
|
|
37
|
+
}) {
|
|
38
|
+
const at = new import_livekit_server_sdk.AccessToken(apiKey, apiSecret);
|
|
39
|
+
at.identity = avatarIdentity;
|
|
40
|
+
at.name = "Anam Avatar";
|
|
41
|
+
at.kind = "agent";
|
|
42
|
+
at.ttl = ttl;
|
|
43
|
+
at.attributes = { "lk.publish_on_behalf": publishOnBehalf };
|
|
44
|
+
at.addGrant({ roomJoin: true, room: roomName });
|
|
45
|
+
return at.toJwt();
|
|
46
|
+
}
|
|
47
|
+
const AVATAR_IDENTITY = "anam-avatar-agent";
|
|
48
|
+
const _AVATAR_NAME = "anam-avatar-agent";
|
|
49
|
+
class AvatarSession extends import_agents.voice.AvatarSession {
|
|
50
|
+
constructor(opts) {
|
|
51
|
+
super();
|
|
52
|
+
this.opts = opts;
|
|
53
|
+
}
|
|
54
|
+
sessionId;
|
|
55
|
+
get avatarIdentity() {
|
|
56
|
+
return this.opts.avatarParticipantIdentity ?? AVATAR_IDENTITY;
|
|
57
|
+
}
|
|
58
|
+
get provider() {
|
|
59
|
+
return "anam";
|
|
60
|
+
}
|
|
61
|
+
async start(agentSession, room, params) {
|
|
62
|
+
var _a, _b, _c;
|
|
63
|
+
await super.start(agentSession, room);
|
|
64
|
+
const logger = (0, import_agents.log)().child({ module: "AnamAvatar" });
|
|
65
|
+
const apiKey = this.opts.apiKey ?? process.env.ANAM_API_KEY;
|
|
66
|
+
if (!apiKey) throw new import_types.AnamException("ANAM_API_KEY is required");
|
|
67
|
+
const apiUrl = this.opts.apiUrl ?? process.env.ANAM_API_URL;
|
|
68
|
+
const livekitUrl = (params == null ? void 0 : params.livekitUrl) ?? process.env.LIVEKIT_URL;
|
|
69
|
+
const lkKey = (params == null ? void 0 : params.livekitApiKey) ?? process.env.LIVEKIT_API_KEY;
|
|
70
|
+
const lkSecret = (params == null ? void 0 : params.livekitApiSecret) ?? process.env.LIVEKIT_API_SECRET;
|
|
71
|
+
if (!livekitUrl || !lkKey || !lkSecret) {
|
|
72
|
+
throw new import_types.AnamException("LIVEKIT_URL/API_KEY/API_SECRET must be set");
|
|
73
|
+
}
|
|
74
|
+
const localIdentity = room.localParticipant && room.localParticipant.identity || "agent";
|
|
75
|
+
logger.debug(
|
|
76
|
+
{
|
|
77
|
+
personaName: (_a = this.opts.personaConfig) == null ? void 0 : _a.name,
|
|
78
|
+
avatarId: (_b = this.opts.personaConfig) == null ? void 0 : _b.avatarId,
|
|
79
|
+
personaId: (_c = this.opts.personaConfig) == null ? void 0 : _c.personaId,
|
|
80
|
+
apiUrl: apiUrl ?? "(default https://api.anam.ai)",
|
|
81
|
+
livekitUrl,
|
|
82
|
+
avatarParticipantIdentity: this.opts.avatarParticipantIdentity ?? "anam-avatar-agent",
|
|
83
|
+
publishOnBehalf: localIdentity
|
|
84
|
+
},
|
|
85
|
+
"starting Anam avatar session"
|
|
86
|
+
);
|
|
87
|
+
const jwt = await mintAvatarJoinToken({
|
|
88
|
+
roomName: room.name,
|
|
89
|
+
avatarIdentity: this.avatarIdentity,
|
|
90
|
+
publishOnBehalf: localIdentity,
|
|
91
|
+
apiKey: lkKey,
|
|
92
|
+
apiSecret: lkSecret
|
|
93
|
+
});
|
|
94
|
+
const anam = new import_api.AnamAPI(apiKey, apiUrl, this.opts.connOptions);
|
|
95
|
+
logger.debug({ livekitUrl }, "requesting Anam session token");
|
|
96
|
+
const { sessionToken } = await anam.createSessionToken({
|
|
97
|
+
personaConfig: this.opts.personaConfig,
|
|
98
|
+
livekitUrl,
|
|
99
|
+
livekitToken: jwt,
|
|
100
|
+
sessionOptions: this.opts.sessionOptions
|
|
101
|
+
});
|
|
102
|
+
logger.debug("starting Anam engine session");
|
|
103
|
+
const started = await anam.startEngineSession({ sessionToken });
|
|
104
|
+
this.sessionId = started.sessionId;
|
|
105
|
+
agentSession.output.audio = new import_agents.voice.DataStreamAudioOutput({
|
|
106
|
+
room,
|
|
107
|
+
destinationIdentity: this.avatarIdentity,
|
|
108
|
+
waitRemoteTrack: import_rtc_node.TrackKind.KIND_VIDEO
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
113
|
+
0 && (module.exports = {
|
|
114
|
+
AvatarSession,
|
|
115
|
+
mintAvatarJoinToken
|
|
116
|
+
});
|
|
117
|
+
//# sourceMappingURL=avatar.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/avatar.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2025 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { log, voice } from '@livekit/agents';\nimport type { Room } from '@livekit/rtc-node';\nimport { TrackKind } from '@livekit/rtc-node';\nimport { AccessToken, type VideoGrant } from 'livekit-server-sdk';\nimport { AnamAPI } from './api.js';\nimport {\n type APIConnectOptions,\n AnamException,\n type PersonaConfig,\n type SessionOptions,\n} from './types.js';\n\n/** @public */\nexport async function mintAvatarJoinToken({\n roomName,\n avatarIdentity,\n publishOnBehalf,\n apiKey = process.env.LIVEKIT_API_KEY!,\n apiSecret = process.env.LIVEKIT_API_SECRET!,\n ttl = '60s',\n}: {\n roomName: string;\n avatarIdentity: string;\n publishOnBehalf: string;\n apiKey?: string;\n apiSecret?: string;\n ttl?: string | number;\n}): Promise<string> {\n const at = new AccessToken(apiKey, apiSecret);\n at.identity = avatarIdentity;\n at.name = 'Anam Avatar';\n at.kind = 'agent';\n at.ttl = ttl;\n at.attributes = { 'lk.publish_on_behalf': publishOnBehalf };\n\n at.addGrant({ roomJoin: true, room: roomName } as VideoGrant);\n return at.toJwt();\n}\n\nconst AVATAR_IDENTITY = 'anam-avatar-agent';\nconst _AVATAR_NAME = 'anam-avatar-agent';\n\n/** @public */\nexport class AvatarSession extends voice.AvatarSession {\n private sessionId?: string;\n\n constructor(\n private opts: {\n personaConfig: PersonaConfig;\n sessionOptions?: SessionOptions;\n apiUrl?: string;\n apiKey?: string;\n avatarParticipantIdentity?: string;\n avatarParticipantName?: string;\n connOptions?: APIConnectOptions;\n },\n ) {\n super();\n }\n\n override get avatarIdentity(): string {\n return this.opts.avatarParticipantIdentity ?? AVATAR_IDENTITY;\n }\n\n override get provider(): string {\n return 'anam';\n }\n\n async start(\n agentSession: voice.AgentSession,\n room: Room,\n params?: {\n livekitUrl?: string;\n livekitApiKey?: string;\n livekitApiSecret?: string;\n },\n ) {\n await super.start(agentSession, room);\n\n const logger = log().child({ module: 'AnamAvatar' });\n const apiKey = this.opts.apiKey ?? process.env.ANAM_API_KEY;\n if (!apiKey) throw new AnamException('ANAM_API_KEY is required');\n\n const apiUrl = this.opts.apiUrl ?? process.env.ANAM_API_URL;\n const livekitUrl = params?.livekitUrl ?? process.env.LIVEKIT_URL;\n const lkKey = params?.livekitApiKey ?? process.env.LIVEKIT_API_KEY;\n const lkSecret = params?.livekitApiSecret ?? process.env.LIVEKIT_API_SECRET;\n\n if (!livekitUrl || !lkKey || !lkSecret) {\n throw new AnamException('LIVEKIT_URL/API_KEY/API_SECRET must be set');\n }\n\n const localIdentity = (room.localParticipant && room.localParticipant.identity) || 'agent';\n\n logger.debug(\n {\n personaName: this.opts.personaConfig?.name,\n avatarId: this.opts.personaConfig?.avatarId,\n personaId: this.opts.personaConfig?.personaId,\n apiUrl: apiUrl ?? '(default https://api.anam.ai)',\n livekitUrl,\n avatarParticipantIdentity: this.opts.avatarParticipantIdentity ?? 'anam-avatar-agent',\n publishOnBehalf: localIdentity,\n },\n 'starting Anam avatar session',\n );\n\n const jwt = await mintAvatarJoinToken({\n roomName: room.name!,\n avatarIdentity: this.avatarIdentity,\n publishOnBehalf: localIdentity,\n apiKey: lkKey,\n apiSecret: lkSecret,\n });\n\n const anam = new AnamAPI(apiKey, apiUrl, this.opts.connOptions);\n logger.debug({ livekitUrl }, 'requesting Anam session token');\n\n const { sessionToken } = await anam.createSessionToken({\n personaConfig: this.opts.personaConfig,\n livekitUrl,\n livekitToken: jwt,\n sessionOptions: this.opts.sessionOptions,\n });\n logger.debug('starting Anam engine session');\n const started = await anam.startEngineSession({ sessionToken });\n this.sessionId = started.sessionId;\n\n agentSession.output.audio = new voice.DataStreamAudioOutput({\n room,\n destinationIdentity: this.avatarIdentity,\n waitRemoteTrack: TrackKind.KIND_VIDEO,\n });\n }\n}\n"],"mappings":";;;;;;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type APIConnectOptions, type PersonaConfig, type SessionOptions } from './types.js';
|
|
4
|
+
/** @public */
|
|
5
|
+
export declare function mintAvatarJoinToken({ roomName, avatarIdentity, publishOnBehalf, apiKey, apiSecret, ttl, }: {
|
|
6
|
+
roomName: string;
|
|
7
|
+
avatarIdentity: string;
|
|
8
|
+
publishOnBehalf: string;
|
|
9
|
+
apiKey?: string;
|
|
10
|
+
apiSecret?: string;
|
|
11
|
+
ttl?: string | number;
|
|
12
|
+
}): Promise<string>;
|
|
13
|
+
/** @public */
|
|
14
|
+
export declare class AvatarSession extends voice.AvatarSession {
|
|
15
|
+
private opts;
|
|
16
|
+
private sessionId?;
|
|
17
|
+
constructor(opts: {
|
|
18
|
+
personaConfig: PersonaConfig;
|
|
19
|
+
sessionOptions?: SessionOptions;
|
|
20
|
+
apiUrl?: string;
|
|
21
|
+
apiKey?: string;
|
|
22
|
+
avatarParticipantIdentity?: string;
|
|
23
|
+
avatarParticipantName?: string;
|
|
24
|
+
connOptions?: APIConnectOptions;
|
|
25
|
+
});
|
|
26
|
+
get avatarIdentity(): string;
|
|
27
|
+
get provider(): string;
|
|
28
|
+
start(agentSession: voice.AgentSession, room: Room, params?: {
|
|
29
|
+
livekitUrl?: string;
|
|
30
|
+
livekitApiKey?: string;
|
|
31
|
+
livekitApiSecret?: string;
|
|
32
|
+
}): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=avatar.d.ts.map
|
package/dist/avatar.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { voice } from '@livekit/agents';
|
|
2
|
+
import type { Room } from '@livekit/rtc-node';
|
|
3
|
+
import { type APIConnectOptions, type PersonaConfig, type SessionOptions } from './types.js';
|
|
4
|
+
/** @public */
|
|
5
|
+
export declare function mintAvatarJoinToken({ roomName, avatarIdentity, publishOnBehalf, apiKey, apiSecret, ttl, }: {
|
|
6
|
+
roomName: string;
|
|
7
|
+
avatarIdentity: string;
|
|
8
|
+
publishOnBehalf: string;
|
|
9
|
+
apiKey?: string;
|
|
10
|
+
apiSecret?: string;
|
|
11
|
+
ttl?: string | number;
|
|
12
|
+
}): Promise<string>;
|
|
13
|
+
/** @public */
|
|
14
|
+
export declare class AvatarSession extends voice.AvatarSession {
|
|
15
|
+
private opts;
|
|
16
|
+
private sessionId?;
|
|
17
|
+
constructor(opts: {
|
|
18
|
+
personaConfig: PersonaConfig;
|
|
19
|
+
sessionOptions?: SessionOptions;
|
|
20
|
+
apiUrl?: string;
|
|
21
|
+
apiKey?: string;
|
|
22
|
+
avatarParticipantIdentity?: string;
|
|
23
|
+
avatarParticipantName?: string;
|
|
24
|
+
connOptions?: APIConnectOptions;
|
|
25
|
+
});
|
|
26
|
+
get avatarIdentity(): string;
|
|
27
|
+
get provider(): string;
|
|
28
|
+
start(agentSession: voice.AgentSession, room: Room, params?: {
|
|
29
|
+
livekitUrl?: string;
|
|
30
|
+
livekitApiKey?: string;
|
|
31
|
+
livekitApiSecret?: string;
|
|
32
|
+
}): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=avatar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"avatar.d.ts","sourceRoot":"","sources":["../src/avatar.ts"],"names":[],"mappings":"AAGA,OAAO,EAAO,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAI9C,OAAO,EACL,KAAK,iBAAiB,EAEtB,KAAK,aAAa,EAClB,KAAK,cAAc,EACpB,MAAM,YAAY,CAAC;AAEpB,cAAc;AACd,wBAAsB,mBAAmB,CAAC,EACxC,QAAQ,EACR,cAAc,EACd,eAAe,EACf,MAAqC,EACrC,SAA2C,EAC3C,GAAW,GACZ,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,MAAM,CAAC,CAUlB;AAKD,cAAc;AACd,qBAAa,aAAc,SAAQ,KAAK,CAAC,aAAa;IAIlD,OAAO,CAAC,IAAI;IAHd,OAAO,CAAC,SAAS,CAAC,CAAS;gBAGjB,IAAI,EAAE;QACZ,aAAa,EAAE,aAAa,CAAC;QAC7B,cAAc,CAAC,EAAE,cAAc,CAAC;QAChC,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,yBAAyB,CAAC,EAAE,MAAM,CAAC;QACnC,qBAAqB,CAAC,EAAE,MAAM,CAAC;QAC/B,WAAW,CAAC,EAAE,iBAAiB,CAAC;KACjC;IAKH,IAAa,cAAc,IAAI,MAAM,CAEpC;IAED,IAAa,QAAQ,IAAI,MAAM,CAE9B;IAEK,KAAK,CACT,YAAY,EAAE,KAAK,CAAC,YAAY,EAChC,IAAI,EAAE,IAAI,EACV,MAAM,CAAC,EAAE;QACP,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;KAC3B;CA2DJ"}
|
package/dist/avatar.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { log, voice } from "@livekit/agents";
|
|
2
|
+
import { TrackKind } from "@livekit/rtc-node";
|
|
3
|
+
import { AccessToken } from "livekit-server-sdk";
|
|
4
|
+
import { AnamAPI } from "./api.js";
|
|
5
|
+
import {
|
|
6
|
+
AnamException
|
|
7
|
+
} from "./types.js";
|
|
8
|
+
async function mintAvatarJoinToken({
|
|
9
|
+
roomName,
|
|
10
|
+
avatarIdentity,
|
|
11
|
+
publishOnBehalf,
|
|
12
|
+
apiKey = process.env.LIVEKIT_API_KEY,
|
|
13
|
+
apiSecret = process.env.LIVEKIT_API_SECRET,
|
|
14
|
+
ttl = "60s"
|
|
15
|
+
}) {
|
|
16
|
+
const at = new AccessToken(apiKey, apiSecret);
|
|
17
|
+
at.identity = avatarIdentity;
|
|
18
|
+
at.name = "Anam Avatar";
|
|
19
|
+
at.kind = "agent";
|
|
20
|
+
at.ttl = ttl;
|
|
21
|
+
at.attributes = { "lk.publish_on_behalf": publishOnBehalf };
|
|
22
|
+
at.addGrant({ roomJoin: true, room: roomName });
|
|
23
|
+
return at.toJwt();
|
|
24
|
+
}
|
|
25
|
+
const AVATAR_IDENTITY = "anam-avatar-agent";
|
|
26
|
+
const _AVATAR_NAME = "anam-avatar-agent";
|
|
27
|
+
class AvatarSession extends voice.AvatarSession {
|
|
28
|
+
constructor(opts) {
|
|
29
|
+
super();
|
|
30
|
+
this.opts = opts;
|
|
31
|
+
}
|
|
32
|
+
sessionId;
|
|
33
|
+
get avatarIdentity() {
|
|
34
|
+
return this.opts.avatarParticipantIdentity ?? AVATAR_IDENTITY;
|
|
35
|
+
}
|
|
36
|
+
get provider() {
|
|
37
|
+
return "anam";
|
|
38
|
+
}
|
|
39
|
+
async start(agentSession, room, params) {
|
|
40
|
+
var _a, _b, _c;
|
|
41
|
+
await super.start(agentSession, room);
|
|
42
|
+
const logger = log().child({ module: "AnamAvatar" });
|
|
43
|
+
const apiKey = this.opts.apiKey ?? process.env.ANAM_API_KEY;
|
|
44
|
+
if (!apiKey) throw new AnamException("ANAM_API_KEY is required");
|
|
45
|
+
const apiUrl = this.opts.apiUrl ?? process.env.ANAM_API_URL;
|
|
46
|
+
const livekitUrl = (params == null ? void 0 : params.livekitUrl) ?? process.env.LIVEKIT_URL;
|
|
47
|
+
const lkKey = (params == null ? void 0 : params.livekitApiKey) ?? process.env.LIVEKIT_API_KEY;
|
|
48
|
+
const lkSecret = (params == null ? void 0 : params.livekitApiSecret) ?? process.env.LIVEKIT_API_SECRET;
|
|
49
|
+
if (!livekitUrl || !lkKey || !lkSecret) {
|
|
50
|
+
throw new AnamException("LIVEKIT_URL/API_KEY/API_SECRET must be set");
|
|
51
|
+
}
|
|
52
|
+
const localIdentity = room.localParticipant && room.localParticipant.identity || "agent";
|
|
53
|
+
logger.debug(
|
|
54
|
+
{
|
|
55
|
+
personaName: (_a = this.opts.personaConfig) == null ? void 0 : _a.name,
|
|
56
|
+
avatarId: (_b = this.opts.personaConfig) == null ? void 0 : _b.avatarId,
|
|
57
|
+
personaId: (_c = this.opts.personaConfig) == null ? void 0 : _c.personaId,
|
|
58
|
+
apiUrl: apiUrl ?? "(default https://api.anam.ai)",
|
|
59
|
+
livekitUrl,
|
|
60
|
+
avatarParticipantIdentity: this.opts.avatarParticipantIdentity ?? "anam-avatar-agent",
|
|
61
|
+
publishOnBehalf: localIdentity
|
|
62
|
+
},
|
|
63
|
+
"starting Anam avatar session"
|
|
64
|
+
);
|
|
65
|
+
const jwt = await mintAvatarJoinToken({
|
|
66
|
+
roomName: room.name,
|
|
67
|
+
avatarIdentity: this.avatarIdentity,
|
|
68
|
+
publishOnBehalf: localIdentity,
|
|
69
|
+
apiKey: lkKey,
|
|
70
|
+
apiSecret: lkSecret
|
|
71
|
+
});
|
|
72
|
+
const anam = new AnamAPI(apiKey, apiUrl, this.opts.connOptions);
|
|
73
|
+
logger.debug({ livekitUrl }, "requesting Anam session token");
|
|
74
|
+
const { sessionToken } = await anam.createSessionToken({
|
|
75
|
+
personaConfig: this.opts.personaConfig,
|
|
76
|
+
livekitUrl,
|
|
77
|
+
livekitToken: jwt,
|
|
78
|
+
sessionOptions: this.opts.sessionOptions
|
|
79
|
+
});
|
|
80
|
+
logger.debug("starting Anam engine session");
|
|
81
|
+
const started = await anam.startEngineSession({ sessionToken });
|
|
82
|
+
this.sessionId = started.sessionId;
|
|
83
|
+
agentSession.output.audio = new voice.DataStreamAudioOutput({
|
|
84
|
+
room,
|
|
85
|
+
destinationIdentity: this.avatarIdentity,
|
|
86
|
+
waitRemoteTrack: TrackKind.KIND_VIDEO
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
export {
|
|
91
|
+
AvatarSession,
|
|
92
|
+
mintAvatarJoinToken
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=avatar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/avatar.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2025 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { log, voice } from '@livekit/agents';\nimport type { Room } from '@livekit/rtc-node';\nimport { TrackKind } from '@livekit/rtc-node';\nimport { AccessToken, type VideoGrant } from 'livekit-server-sdk';\nimport { AnamAPI } from './api.js';\nimport {\n type APIConnectOptions,\n AnamException,\n type PersonaConfig,\n type SessionOptions,\n} from './types.js';\n\n/** @public */\nexport async function mintAvatarJoinToken({\n roomName,\n avatarIdentity,\n publishOnBehalf,\n apiKey = process.env.LIVEKIT_API_KEY!,\n apiSecret = process.env.LIVEKIT_API_SECRET!,\n ttl = '60s',\n}: {\n roomName: string;\n avatarIdentity: string;\n publishOnBehalf: string;\n apiKey?: string;\n apiSecret?: string;\n ttl?: string | number;\n}): Promise<string> {\n const at = new AccessToken(apiKey, apiSecret);\n at.identity = avatarIdentity;\n at.name = 'Anam Avatar';\n at.kind = 'agent';\n at.ttl = ttl;\n at.attributes = { 'lk.publish_on_behalf': publishOnBehalf };\n\n at.addGrant({ roomJoin: true, room: roomName } as VideoGrant);\n return at.toJwt();\n}\n\nconst AVATAR_IDENTITY = 'anam-avatar-agent';\nconst _AVATAR_NAME = 'anam-avatar-agent';\n\n/** @public */\nexport class AvatarSession extends voice.AvatarSession {\n private sessionId?: string;\n\n constructor(\n private opts: {\n personaConfig: PersonaConfig;\n sessionOptions?: SessionOptions;\n apiUrl?: string;\n apiKey?: string;\n avatarParticipantIdentity?: string;\n avatarParticipantName?: string;\n connOptions?: APIConnectOptions;\n },\n ) {\n super();\n }\n\n override get avatarIdentity(): string {\n return this.opts.avatarParticipantIdentity ?? AVATAR_IDENTITY;\n }\n\n override get provider(): string {\n return 'anam';\n }\n\n async start(\n agentSession: voice.AgentSession,\n room: Room,\n params?: {\n livekitUrl?: string;\n livekitApiKey?: string;\n livekitApiSecret?: string;\n },\n ) {\n await super.start(agentSession, room);\n\n const logger = log().child({ module: 'AnamAvatar' });\n const apiKey = this.opts.apiKey ?? process.env.ANAM_API_KEY;\n if (!apiKey) throw new AnamException('ANAM_API_KEY is required');\n\n const apiUrl = this.opts.apiUrl ?? process.env.ANAM_API_URL;\n const livekitUrl = params?.livekitUrl ?? process.env.LIVEKIT_URL;\n const lkKey = params?.livekitApiKey ?? process.env.LIVEKIT_API_KEY;\n const lkSecret = params?.livekitApiSecret ?? process.env.LIVEKIT_API_SECRET;\n\n if (!livekitUrl || !lkKey || !lkSecret) {\n throw new AnamException('LIVEKIT_URL/API_KEY/API_SECRET must be set');\n }\n\n const localIdentity = (room.localParticipant && room.localParticipant.identity) || 'agent';\n\n logger.debug(\n {\n personaName: this.opts.personaConfig?.name,\n avatarId: this.opts.personaConfig?.avatarId,\n personaId: this.opts.personaConfig?.personaId,\n apiUrl: apiUrl ?? '(default https://api.anam.ai)',\n livekitUrl,\n avatarParticipantIdentity: this.opts.avatarParticipantIdentity ?? 'anam-avatar-agent',\n publishOnBehalf: localIdentity,\n },\n 'starting Anam avatar session',\n );\n\n const jwt = await mintAvatarJoinToken({\n roomName: room.name!,\n avatarIdentity: this.avatarIdentity,\n publishOnBehalf: localIdentity,\n apiKey: lkKey,\n apiSecret: lkSecret,\n });\n\n const anam = new AnamAPI(apiKey, apiUrl, this.opts.connOptions);\n logger.debug({ livekitUrl }, 'requesting Anam session token');\n\n const { sessionToken } = await anam.createSessionToken({\n personaConfig: this.opts.personaConfig,\n livekitUrl,\n livekitToken: jwt,\n sessionOptions: this.opts.sessionOptions,\n });\n logger.debug('starting Anam engine session');\n const started = await anam.startEngineSession({ sessionToken });\n this.sessionId = started.sessionId;\n\n agentSession.output.audio = new voice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
|
|
1
|
+
"use strict";
|
|
2
|
+
var import_agents = require("@livekit/agents");
|
|
3
|
+
var import_vitest = require("vitest");
|
|
4
|
+
var import_avatar = require("./avatar.cjs");
|
|
5
|
+
(0, import_vitest.describe)("Anam AvatarSession", () => {
|
|
6
|
+
(0, import_vitest.afterEach)(() => {
|
|
7
|
+
import_vitest.vi.restoreAllMocks();
|
|
8
|
+
});
|
|
9
|
+
(0, import_vitest.it)("calls base AvatarSession.start first", async () => {
|
|
10
|
+
const sentinel = new Error("super-start-called");
|
|
11
|
+
const superStartSpy = import_vitest.vi.spyOn(import_agents.voice.AvatarSession.prototype, "start").mockRejectedValue(sentinel);
|
|
12
|
+
const avatar = new import_avatar.AvatarSession({
|
|
13
|
+
personaConfig: {
|
|
14
|
+
personaId: "persona-test"
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
await (0, import_vitest.expect)(
|
|
18
|
+
avatar.start({ _started: false, output: { audio: null } }, {})
|
|
19
|
+
).rejects.toThrow("super-start-called");
|
|
20
|
+
(0, import_vitest.expect)(superStartSpy).toHaveBeenCalledTimes(1);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=avatar.test.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/avatar.test.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2026 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { voice } from '@livekit/agents';\nimport { afterEach, describe, expect, it, vi } from 'vitest';\nimport { AvatarSession } from './avatar.js';\n\ndescribe('Anam AvatarSession', () => {\n afterEach(() => {\n vi.restoreAllMocks();\n });\n\n it('calls base AvatarSession.start first', async () => {\n const sentinel = new Error('super-start-called');\n const superStartSpy = vi\n .spyOn(voice.AvatarSession.prototype, 'start')\n .mockRejectedValue(sentinel);\n\n const avatar = new AvatarSession({\n personaConfig: {\n personaId: 'persona-test',\n },\n });\n\n await expect(\n avatar.start({ _started: false, output: { audio: null } } as any, {} as any),\n ).rejects.toThrow('super-start-called');\n expect(superStartSpy).toHaveBeenCalledTimes(1);\n });\n});\n"],"mappings":";AAGA,oBAAsB;AACtB,oBAAoD;AACpD,oBAA8B;AAAA,IAE9B,wBAAS,sBAAsB,MAAM;AACnC,+BAAU,MAAM;AACd,qBAAG,gBAAgB;AAAA,EACrB,CAAC;AAED,wBAAG,wCAAwC,YAAY;AACrD,UAAM,WAAW,IAAI,MAAM,oBAAoB;AAC/C,UAAM,gBAAgB,iBACnB,MAAM,oBAAM,cAAc,WAAW,OAAO,EAC5C,kBAAkB,QAAQ;AAE7B,UAAM,SAAS,IAAI,4BAAc;AAAA,MAC/B,eAAe;AAAA,QACb,WAAW;AAAA,MACb;AAAA,IACF,CAAC;AAED,cAAM;AAAA,MACJ,OAAO,MAAM,EAAE,UAAU,OAAO,QAAQ,EAAE,OAAO,KAAK,EAAE,GAAU,CAAC,CAAQ;AAAA,IAC7E,EAAE,QAAQ,QAAQ,oBAAoB;AACtC,8BAAO,aAAa,EAAE,sBAAsB,CAAC;AAAA,EAC/C,CAAC;AACH,CAAC;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"avatar.test.d.ts","sourceRoot":"","sources":["../src/avatar.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { voice } from "@livekit/agents";
|
|
2
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
3
|
+
import { AvatarSession } from "./avatar.js";
|
|
4
|
+
describe("Anam AvatarSession", () => {
|
|
5
|
+
afterEach(() => {
|
|
6
|
+
vi.restoreAllMocks();
|
|
7
|
+
});
|
|
8
|
+
it("calls base AvatarSession.start first", async () => {
|
|
9
|
+
const sentinel = new Error("super-start-called");
|
|
10
|
+
const superStartSpy = vi.spyOn(voice.AvatarSession.prototype, "start").mockRejectedValue(sentinel);
|
|
11
|
+
const avatar = new AvatarSession({
|
|
12
|
+
personaConfig: {
|
|
13
|
+
personaId: "persona-test"
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
await expect(
|
|
17
|
+
avatar.start({ _started: false, output: { audio: null } }, {})
|
|
18
|
+
).rejects.toThrow("super-start-called");
|
|
19
|
+
expect(superStartSpy).toHaveBeenCalledTimes(1);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=avatar.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/avatar.test.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2026 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { voice } from '@livekit/agents';\nimport { afterEach, describe, expect, it, vi } from 'vitest';\nimport { AvatarSession } from './avatar.js';\n\ndescribe('Anam AvatarSession', () => {\n afterEach(() => {\n vi.restoreAllMocks();\n });\n\n it('calls base AvatarSession.start first', async () => {\n const sentinel = new Error('super-start-called');\n const superStartSpy = vi\n .spyOn(voice.AvatarSession.prototype, 'start')\n .mockRejectedValue(sentinel);\n\n const avatar = new AvatarSession({\n personaConfig: {\n personaId: 'persona-test',\n },\n });\n\n await expect(\n avatar.start({ _started: false, output: { audio: null } } as any, {} as any),\n ).rejects.toThrow('super-start-called');\n expect(superStartSpy).toHaveBeenCalledTimes(1);\n });\n});\n"],"mappings":"AAGA,SAAS,aAAa;AACtB,SAAS,WAAW,UAAU,QAAQ,IAAI,UAAU;AACpD,SAAS,qBAAqB;AAE9B,SAAS,sBAAsB,MAAM;AACnC,YAAU,MAAM;AACd,OAAG,gBAAgB;AAAA,EACrB,CAAC;AAED,KAAG,wCAAwC,YAAY;AACrD,UAAM,WAAW,IAAI,MAAM,oBAAoB;AAC/C,UAAM,gBAAgB,GACnB,MAAM,MAAM,cAAc,WAAW,OAAO,EAC5C,kBAAkB,QAAQ;AAE7B,UAAM,SAAS,IAAI,cAAc;AAAA,MAC/B,eAAe;AAAA,QACb,WAAW;AAAA,MACb;AAAA,IACF,CAAC;AAED,UAAM;AAAA,MACJ,OAAO,MAAM,EAAE,UAAU,OAAO,QAAQ,EAAE,OAAO,KAAK,EAAE,GAAU,CAAC,CAAQ;AAAA,IAC7E,EAAE,QAAQ,QAAQ,oBAAoB;AACtC,WAAO,aAAa,EAAE,sBAAsB,CAAC;AAAA,EAC/C,CAAC;AACH,CAAC;","names":[]}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var index_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(index_exports);
|
|
18
|
+
var import_agents = require("@livekit/agents");
|
|
19
|
+
__reExport(index_exports, require("./types.cjs"), module.exports);
|
|
20
|
+
__reExport(index_exports, require("./api.cjs"), module.exports);
|
|
21
|
+
__reExport(index_exports, require("./avatar.cjs"), module.exports);
|
|
22
|
+
class AnamPlugin extends import_agents.Plugin {
|
|
23
|
+
constructor() {
|
|
24
|
+
super({
|
|
25
|
+
title: "anam",
|
|
26
|
+
version: "0.0.0-next-20260624041820",
|
|
27
|
+
package: "@livekit/agents-plugin-anam"
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
import_agents.Plugin.registerPlugin(new AnamPlugin());
|
|
32
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
+
0 && (module.exports = {
|
|
34
|
+
...require("./types.cjs"),
|
|
35
|
+
...require("./api.cjs"),
|
|
36
|
+
...require("./avatar.cjs")
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2025 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { Plugin } from '@livekit/agents';\n\nexport * from './types.js';\nexport * from './api.js';\nexport * from './avatar.js';\n\nclass AnamPlugin extends Plugin {\n constructor() {\n super({\n title: 'anam',\n version: __PACKAGE_VERSION__,\n package: __PACKAGE_NAME__,\n });\n }\n}\nPlugin.registerPlugin(new AnamPlugin());\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAGA,oBAAuB;AAEvB,0BAAc,uBALd;AAMA,0BAAc,qBANd;AAOA,0BAAc,wBAPd;AASA,MAAM,mBAAmB,qBAAO;AAAA,EAC9B,cAAc;AACZ,UAAM;AAAA,MACJ,OAAO;AAAA,MACP,SAAS;AAAA,MACT,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AACF;AACA,qBAAO,eAAe,IAAI,WAAW,CAAC;","names":[]}
|
package/dist/index.d.cts
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Plugin } from "@livekit/agents";
|
|
2
|
+
export * from "./types.js";
|
|
3
|
+
export * from "./api.js";
|
|
4
|
+
export * from "./avatar.js";
|
|
5
|
+
class AnamPlugin extends Plugin {
|
|
6
|
+
constructor() {
|
|
7
|
+
super({
|
|
8
|
+
title: "anam",
|
|
9
|
+
version: "0.0.0-next-20260624041820",
|
|
10
|
+
package: "@livekit/agents-plugin-anam"
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
Plugin.registerPlugin(new AnamPlugin());
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2025 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { Plugin } from '@livekit/agents';\n\nexport * from './types.js';\nexport * from './api.js';\nexport * from './avatar.js';\n\nclass AnamPlugin extends Plugin {\n constructor() {\n super({\n title: 'anam',\n version: __PACKAGE_VERSION__,\n package: __PACKAGE_NAME__,\n });\n }\n}\nPlugin.registerPlugin(new AnamPlugin());\n"],"mappings":"AAGA,SAAS,cAAc;AAEvB,cAAc;AACd,cAAc;AACd,cAAc;AAEd,MAAM,mBAAmB,OAAO;AAAA,EAC9B,cAAc;AACZ,UAAM;AAAA,MACJ,OAAO;AAAA,MACP,SAAS;AAAA,MACT,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AACF;AACA,OAAO,eAAe,IAAI,WAAW,CAAC;","names":[]}
|
package/dist/types.cjs
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var types_exports = {};
|
|
20
|
+
__export(types_exports, {
|
|
21
|
+
AnamException: () => AnamException
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(types_exports);
|
|
24
|
+
class AnamException extends Error {
|
|
25
|
+
}
|
|
26
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
27
|
+
0 && (module.exports = {
|
|
28
|
+
AnamException
|
|
29
|
+
});
|
|
30
|
+
//# sourceMappingURL=types.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2025 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n/** @public */\nexport type PersonaConfig = {\n /** Optional display name (prod flow) */\n name?: string;\n /** Optional avatar asset id (prod flow) */\n avatarId?: string;\n /** Optional avatar model version, e.g. \"cara-3\" or \"cara-4-latest\" (prod flow) */\n avatarModel?: string;\n /** Optional persona id (dev flow) */\n personaId?: string;\n};\n\n/** @public */\nexport type SessionOptions = {\n /** Output video frame width in pixels. Provide together with videoHeight. */\n videoWidth?: number;\n /** Output video frame height in pixels. Provide together with videoWidth. */\n videoHeight?: number;\n};\n\n/** @public */\nexport type APIConnectOptions = {\n maxRetry?: number;\n retryInterval?: number; // seconds\n timeout?: number; // seconds\n};\n\n/** @public */\nexport class AnamException extends Error {}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA+BO,MAAM,sBAAsB,MAAM;AAAC;","names":[]}
|
package/dist/types.d.cts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** @public */
|
|
2
|
+
export type PersonaConfig = {
|
|
3
|
+
/** Optional display name (prod flow) */
|
|
4
|
+
name?: string;
|
|
5
|
+
/** Optional avatar asset id (prod flow) */
|
|
6
|
+
avatarId?: string;
|
|
7
|
+
/** Optional avatar model version, e.g. "cara-3" or "cara-4-latest" (prod flow) */
|
|
8
|
+
avatarModel?: string;
|
|
9
|
+
/** Optional persona id (dev flow) */
|
|
10
|
+
personaId?: string;
|
|
11
|
+
};
|
|
12
|
+
/** @public */
|
|
13
|
+
export type SessionOptions = {
|
|
14
|
+
/** Output video frame width in pixels. Provide together with videoHeight. */
|
|
15
|
+
videoWidth?: number;
|
|
16
|
+
/** Output video frame height in pixels. Provide together with videoWidth. */
|
|
17
|
+
videoHeight?: number;
|
|
18
|
+
};
|
|
19
|
+
/** @public */
|
|
20
|
+
export type APIConnectOptions = {
|
|
21
|
+
maxRetry?: number;
|
|
22
|
+
retryInterval?: number;
|
|
23
|
+
timeout?: number;
|
|
24
|
+
};
|
|
25
|
+
/** @public */
|
|
26
|
+
export declare class AnamException extends Error {
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** @public */
|
|
2
|
+
export type PersonaConfig = {
|
|
3
|
+
/** Optional display name (prod flow) */
|
|
4
|
+
name?: string;
|
|
5
|
+
/** Optional avatar asset id (prod flow) */
|
|
6
|
+
avatarId?: string;
|
|
7
|
+
/** Optional avatar model version, e.g. "cara-3" or "cara-4-latest" (prod flow) */
|
|
8
|
+
avatarModel?: string;
|
|
9
|
+
/** Optional persona id (dev flow) */
|
|
10
|
+
personaId?: string;
|
|
11
|
+
};
|
|
12
|
+
/** @public */
|
|
13
|
+
export type SessionOptions = {
|
|
14
|
+
/** Output video frame width in pixels. Provide together with videoHeight. */
|
|
15
|
+
videoWidth?: number;
|
|
16
|
+
/** Output video frame height in pixels. Provide together with videoWidth. */
|
|
17
|
+
videoHeight?: number;
|
|
18
|
+
};
|
|
19
|
+
/** @public */
|
|
20
|
+
export type APIConnectOptions = {
|
|
21
|
+
maxRetry?: number;
|
|
22
|
+
retryInterval?: number;
|
|
23
|
+
timeout?: number;
|
|
24
|
+
};
|
|
25
|
+
/** @public */
|
|
26
|
+
export declare class AnamException extends Error {
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,cAAc;AACd,MAAM,MAAM,aAAa,GAAG;IAC1B,wCAAwC;IACxC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kFAAkF;IAClF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qCAAqC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,cAAc;AACd,MAAM,MAAM,cAAc,GAAG;IAC3B,6EAA6E;IAC7E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6EAA6E;IAC7E,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,cAAc;AACd,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,cAAc;AACd,qBAAa,aAAc,SAAQ,KAAK;CAAG"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2025 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n/** @public */\nexport type PersonaConfig = {\n /** Optional display name (prod flow) */\n name?: string;\n /** Optional avatar asset id (prod flow) */\n avatarId?: string;\n /** Optional avatar model version, e.g. \"cara-3\" or \"cara-4-latest\" (prod flow) */\n avatarModel?: string;\n /** Optional persona id (dev flow) */\n personaId?: string;\n};\n\n/** @public */\nexport type SessionOptions = {\n /** Output video frame width in pixels. Provide together with videoHeight. */\n videoWidth?: number;\n /** Output video frame height in pixels. Provide together with videoWidth. */\n videoHeight?: number;\n};\n\n/** @public */\nexport type APIConnectOptions = {\n maxRetry?: number;\n retryInterval?: number; // seconds\n timeout?: number; // seconds\n};\n\n/** @public */\nexport class AnamException extends Error {}\n"],"mappings":"AA+BO,MAAM,sBAAsB,MAAM;AAAC;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@livekit/agents-plugin-anam",
|
|
3
|
+
"version": "0.0.0-next-20260624041820",
|
|
4
|
+
"description": "Anam plugin for LiveKit Node Agents",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"require": "dist/index.cjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
"import": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"require": {
|
|
14
|
+
"types": "./dist/index.d.cts",
|
|
15
|
+
"default": "./dist/index.cjs"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"author": "LiveKit",
|
|
19
|
+
"type": "module",
|
|
20
|
+
"repository": "git@github.com:livekit/agents-js.git",
|
|
21
|
+
"license": "Apache-2.0",
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"src",
|
|
25
|
+
"README.md"
|
|
26
|
+
],
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@livekit/rtc-node": "^0.13.29",
|
|
29
|
+
"@microsoft/api-extractor": "^7.35.0",
|
|
30
|
+
"@types/ws": "^8.5.10",
|
|
31
|
+
"tsup": "^8.3.5",
|
|
32
|
+
"typescript": "^5.0.0",
|
|
33
|
+
"@livekit/agents": "0.0.0-next-20260624041820",
|
|
34
|
+
"@livekit/agents-plugin-openai": "0.0.0-next-20260624041820",
|
|
35
|
+
"@livekit/agents-plugins-test": "0.0.0-next-20260624041820"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"livekit-server-sdk": "^2.9.2",
|
|
39
|
+
"ws": "^8.18.0"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"@livekit/rtc-node": "^0.13.29",
|
|
43
|
+
"@livekit/agents": "0.0.0-next-20260624041820"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "tsup --onSuccess \"pnpm build:types\"",
|
|
47
|
+
"build:types": "tsc --declaration --emitDeclarationOnly && node ../../scripts/copyDeclarationOutput.js",
|
|
48
|
+
"clean": "rm -rf dist",
|
|
49
|
+
"clean:build": "pnpm clean && pnpm build",
|
|
50
|
+
"lint": "eslint -f unix \"src/**/*.{ts,js}\"",
|
|
51
|
+
"api:check": "api-extractor run --typescript-compiler-folder ../../node_modules/typescript",
|
|
52
|
+
"api:update": "api-extractor run --local --typescript-compiler-folder ../../node_modules/typescript --verbose"
|
|
53
|
+
}
|
|
54
|
+
}
|