agora-agents 2.12.0 → 3.0.0-alpha.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 +30 -1
- package/dist/cjs/AgoraPoolClient.d.ts +12 -24
- package/dist/cjs/AgoraPoolClient.js +73 -54
- package/dist/cjs/BaseClient.js +3 -2
- package/dist/cjs/agentkit/Agent.d.ts +7 -0
- package/dist/cjs/agentkit/Agent.js +104 -10
- package/dist/cjs/agentkit/AgentSession.d.ts +11 -2
- package/dist/cjs/agentkit/AgentSession.js +134 -22
- package/dist/cjs/agentkit/index.d.ts +3 -0
- package/dist/cjs/agentkit/index.js +12 -2
- package/dist/cjs/agentkit/session-backend.d.ts +23 -0
- package/dist/cjs/agentkit/session-backend.js +136 -0
- package/dist/cjs/agentkit/types.d.ts +21 -4
- package/dist/cjs/agentkit/v3.d.ts +66 -0
- package/dist/cjs/agentkit/v3.js +658 -0
- package/dist/cjs/agentkit/vendors/base.d.ts +8 -0
- package/dist/cjs/agentkit/vendors/base.js +33 -7
- package/dist/cjs/core/publicHeaders.d.ts +2 -0
- package/dist/cjs/core/publicHeaders.js +8 -0
- package/dist/cjs/index.d.ts +5 -0
- package/dist/cjs/index.js +14 -1
- package/dist/cjs/v3/campaign-schema.d.ts +1 -0
- package/dist/cjs/v3/campaign-schema.js +18 -0
- package/dist/cjs/v3/campaigns.d.ts +50 -0
- package/dist/cjs/v3/campaigns.js +81 -0
- package/dist/cjs/v3/contract.d.ts +1 -0
- package/dist/cjs/v3/contract.js +9006 -0
- package/dist/cjs/v3/index.d.ts +15 -0
- package/dist/cjs/v3/index.js +56 -0
- package/dist/cjs/v3/resources.d.ts +121 -0
- package/dist/cjs/v3/resources.js +187 -0
- package/dist/cjs/v3/session-lifecycle.d.ts +51 -0
- package/dist/cjs/v3/session-lifecycle.js +127 -0
- package/dist/cjs/v3/session-schema.d.ts +1 -0
- package/dist/cjs/v3/session-schema.js +18 -0
- package/dist/cjs/v3/transport.d.ts +36 -0
- package/dist/cjs/v3/transport.js +161 -0
- package/dist/cjs/v3/types.d.ts +992 -0
- package/dist/cjs/v3/types.js +2 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/AgoraPoolClient.d.mts +12 -24
- package/dist/esm/AgoraPoolClient.mjs +67 -48
- package/dist/esm/BaseClient.mjs +3 -2
- package/dist/esm/agentkit/Agent.d.mts +7 -0
- package/dist/esm/agentkit/Agent.mjs +104 -10
- package/dist/esm/agentkit/AgentSession.d.mts +11 -2
- package/dist/esm/agentkit/AgentSession.mjs +134 -22
- package/dist/esm/agentkit/index.d.mts +3 -0
- package/dist/esm/agentkit/index.mjs +2 -0
- package/dist/esm/agentkit/session-backend.d.mts +23 -0
- package/dist/esm/agentkit/session-backend.mjs +131 -0
- package/dist/esm/agentkit/types.d.mts +21 -4
- package/dist/esm/agentkit/v3.d.mts +66 -0
- package/dist/esm/agentkit/v3.mjs +645 -0
- package/dist/esm/agentkit/vendors/base.d.mts +8 -0
- package/dist/esm/agentkit/vendors/base.mjs +33 -7
- package/dist/esm/core/publicHeaders.d.mts +2 -0
- package/dist/esm/core/publicHeaders.mjs +5 -0
- package/dist/esm/index.d.mts +5 -0
- package/dist/esm/index.mjs +3 -0
- package/dist/esm/v3/campaign-schema.d.mts +1 -0
- package/dist/esm/v3/campaign-schema.mjs +2 -0
- package/dist/esm/v3/campaigns.d.mts +50 -0
- package/dist/esm/v3/campaigns.mjs +77 -0
- package/dist/esm/v3/contract.d.mts +1 -0
- package/dist/esm/v3/contract.mjs +9003 -0
- package/dist/esm/v3/index.d.mts +15 -0
- package/dist/esm/v3/index.mjs +15 -0
- package/dist/esm/v3/resources.d.mts +121 -0
- package/dist/esm/v3/resources.mjs +180 -0
- package/dist/esm/v3/session-lifecycle.d.mts +51 -0
- package/dist/esm/v3/session-lifecycle.mjs +121 -0
- package/dist/esm/v3/session-schema.d.mts +1 -0
- package/dist/esm/v3/session-schema.mjs +2 -0
- package/dist/esm/v3/transport.d.mts +36 -0
- package/dist/esm/v3/transport.mjs +151 -0
- package/dist/esm/v3/types.d.mts +992 -0
- package/dist/esm/v3/types.mjs +1 -0
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/openapi.yaml +8848 -0
- package/package.json +3 -2
- package/reference.md +3 -0
|
@@ -14,13 +14,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
14
14
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
15
|
});
|
|
16
16
|
};
|
|
17
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
18
|
+
var t = {};
|
|
19
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
20
|
+
t[p] = s[p];
|
|
21
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
22
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
23
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
24
|
+
t[p[i]] = s[p[i]];
|
|
25
|
+
}
|
|
26
|
+
return t;
|
|
27
|
+
};
|
|
17
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
29
|
exports.AgentSession = void 0;
|
|
19
30
|
const index_js_1 = require("../errors/index.js");
|
|
31
|
+
const transport_js_1 = require("../v3/transport.js");
|
|
20
32
|
const avatar_types_js_1 = require("./avatar-types.js");
|
|
21
33
|
const debug_js_1 = require("./debug.js");
|
|
22
34
|
const presets_js_1 = require("./presets.js");
|
|
23
35
|
const client_js_1 = require("./preview/client.js");
|
|
36
|
+
const session_backend_js_1 = require("./session-backend.js");
|
|
24
37
|
const token_js_1 = require("./token.js");
|
|
25
38
|
/**
|
|
26
39
|
* AgentSession class for managing agent lifecycle and interactions.
|
|
@@ -56,14 +69,28 @@ const token_js_1 = require("./token.js");
|
|
|
56
69
|
* ```
|
|
57
70
|
*/
|
|
58
71
|
class AgentSession {
|
|
72
|
+
_beginLifecycle() {
|
|
73
|
+
const revision = ++this._lifecycleRevision;
|
|
74
|
+
this._pendingLifecycle = revision;
|
|
75
|
+
return revision;
|
|
76
|
+
}
|
|
77
|
+
_finishLifecycle(revision) {
|
|
78
|
+
if (revision !== undefined && this._pendingLifecycle === revision) {
|
|
79
|
+
this._pendingLifecycle = undefined;
|
|
80
|
+
++this._lifecycleRevision;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
59
83
|
constructor(options) {
|
|
60
84
|
var _a, _b;
|
|
61
85
|
this._previewFeatures = [];
|
|
62
86
|
this._agentId = null;
|
|
63
87
|
this._status = "idle";
|
|
88
|
+
this._lifecycleRevision = 0;
|
|
89
|
+
this._infoReadRevision = 0;
|
|
64
90
|
this._eventHandlers = new Map();
|
|
65
91
|
this._client = options.client;
|
|
66
92
|
this._agent = options.agent;
|
|
93
|
+
this._backend = options.backend;
|
|
67
94
|
this._appId = options.appId;
|
|
68
95
|
this._appCertificate = options.appCertificate;
|
|
69
96
|
this._name = options.name;
|
|
@@ -78,8 +105,8 @@ class AgentSession {
|
|
|
78
105
|
this._expiresIn = options.expiresIn;
|
|
79
106
|
this._debug = options.debug;
|
|
80
107
|
this._warn = (_a = options.warn) !== null && _a !== void 0 ? _a : ((msg) => console.warn(msg));
|
|
81
|
-
// Read authMode from pool client if available, else
|
|
82
|
-
this._authMode = (_b = options.client.authMode) !== null && _b !== void 0 ? _b : "
|
|
108
|
+
// Read authMode from pool client if available, else leave authorization to the supplied client
|
|
109
|
+
this._authMode = (_b = options.client.authMode) !== null && _b !== void 0 ? _b : "token";
|
|
83
110
|
this._agentsClient = options.client.agents;
|
|
84
111
|
this._agentManagementClient = options.client.agentManagement;
|
|
85
112
|
this._sessionBaseUrl = this._clientCurrentUrl();
|
|
@@ -157,6 +184,8 @@ class AgentSession {
|
|
|
157
184
|
* The agent configuration.
|
|
158
185
|
*/
|
|
159
186
|
get agent() {
|
|
187
|
+
if (!this._agent)
|
|
188
|
+
throw new Error("This session uses a saved agent; no local configuration is available");
|
|
160
189
|
return this._agent;
|
|
161
190
|
}
|
|
162
191
|
/**
|
|
@@ -185,19 +214,23 @@ class AgentSession {
|
|
|
185
214
|
* ```
|
|
186
215
|
*/
|
|
187
216
|
get raw() {
|
|
217
|
+
if (this._backend)
|
|
218
|
+
throw new session_backend_js_1.UnsupportedSessionOperationError("raw running-agent client");
|
|
188
219
|
return this._agentsClient;
|
|
189
220
|
}
|
|
190
221
|
/**
|
|
191
222
|
* Direct access to the underlying Fern-generated AgentManagement client.
|
|
192
223
|
*/
|
|
193
224
|
get rawAgentManagement() {
|
|
225
|
+
if (this._backend)
|
|
226
|
+
throw new session_backend_js_1.UnsupportedSessionOperationError("rawAgentManagement");
|
|
194
227
|
return this._agentManagementClient;
|
|
195
228
|
}
|
|
196
229
|
/**
|
|
197
230
|
* Returns true when the agent is configured for MLLM (multimodal end-to-end audio).
|
|
198
231
|
*/
|
|
199
232
|
_isMllmMode() {
|
|
200
|
-
const mllm = this.
|
|
233
|
+
const mllm = this.agent.mllm;
|
|
201
234
|
if ((mllm === null || mllm === void 0 ? void 0 : mllm.enable) === true) {
|
|
202
235
|
return true;
|
|
203
236
|
}
|
|
@@ -213,10 +246,10 @@ class AgentSession {
|
|
|
213
246
|
*/
|
|
214
247
|
_warnOnDroppedMllmInstructions() {
|
|
215
248
|
var _a;
|
|
216
|
-
if (!this._isMllmMode() || this.
|
|
249
|
+
if (!this._isMllmMode() || this.agent.instructions === undefined) {
|
|
217
250
|
return;
|
|
218
251
|
}
|
|
219
|
-
const params = (_a = this.
|
|
252
|
+
const params = (_a = this.agent.mllm) === null || _a === void 0 ? void 0 : _a.params;
|
|
220
253
|
if (typeof (params === null || params === void 0 ? void 0 : params.instructions) === "string" && params.instructions.length > 0) {
|
|
221
254
|
return;
|
|
222
255
|
}
|
|
@@ -233,9 +266,9 @@ class AgentSession {
|
|
|
233
266
|
* @throws {Error} If configuration is invalid
|
|
234
267
|
*/
|
|
235
268
|
_validateAvatarConfig() {
|
|
236
|
-
const agentConfig = this.
|
|
269
|
+
const agentConfig = this.agent.config;
|
|
237
270
|
const avatar = agentConfig.avatar;
|
|
238
|
-
const tts = this.
|
|
271
|
+
const tts = this.agent.tts;
|
|
239
272
|
// Skip validation if no avatar is configured
|
|
240
273
|
if (!avatar || avatar.enable === false) {
|
|
241
274
|
return;
|
|
@@ -379,13 +412,13 @@ class AgentSession {
|
|
|
379
412
|
}
|
|
380
413
|
}
|
|
381
414
|
}
|
|
382
|
-
if ((0, presets_js_1.inferAsrPreset)(this.
|
|
415
|
+
if ((0, presets_js_1.inferAsrPreset)(this.agent.stt)) {
|
|
383
416
|
skipVendorValidationCategories.add("asr");
|
|
384
417
|
}
|
|
385
|
-
if ((0, presets_js_1.inferLlmPreset)(this.
|
|
418
|
+
if ((0, presets_js_1.inferLlmPreset)(this.agent.llm)) {
|
|
386
419
|
skipVendorValidationCategories.add("llm");
|
|
387
420
|
}
|
|
388
|
-
if ((0, presets_js_1.inferTtsPreset)(this.
|
|
421
|
+
if ((0, presets_js_1.inferTtsPreset)(this.agent.tts)) {
|
|
389
422
|
skipVendorValidationCategories.add("tts");
|
|
390
423
|
}
|
|
391
424
|
return { skipVendorValidationCategories, allowMissingVendorCategories };
|
|
@@ -404,6 +437,25 @@ class AgentSession {
|
|
|
404
437
|
if (this._status !== "idle" && this._status !== "stopped" && this._status !== "error") {
|
|
405
438
|
throw new Error(`Cannot start session in ${this._status} state`);
|
|
406
439
|
}
|
|
440
|
+
if (this._backend) {
|
|
441
|
+
const lifecycle = this._beginLifecycle();
|
|
442
|
+
this._agentId = null;
|
|
443
|
+
this._status = "starting";
|
|
444
|
+
try {
|
|
445
|
+
const started = yield this._backend.start();
|
|
446
|
+
this._agentId = started.id;
|
|
447
|
+
this._status = started.status;
|
|
448
|
+
this._finishLifecycle(lifecycle);
|
|
449
|
+
this._emit("started", { agentId: this._agentId, sessionId: this._agentId });
|
|
450
|
+
return this._agentId;
|
|
451
|
+
}
|
|
452
|
+
catch (error) {
|
|
453
|
+
this._status = "error";
|
|
454
|
+
this._finishLifecycle(lifecycle);
|
|
455
|
+
this._emit("error", error);
|
|
456
|
+
throw error;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
407
459
|
// Validate avatar configuration before starting
|
|
408
460
|
this._validateAvatarConfig();
|
|
409
461
|
this._warnOnDroppedMllmInstructions();
|
|
@@ -414,7 +466,7 @@ class AgentSession {
|
|
|
414
466
|
}
|
|
415
467
|
this._status = "starting";
|
|
416
468
|
try {
|
|
417
|
-
const pipelineId = (_a = this._pipelineId) !== null && _a !== void 0 ? _a : this.
|
|
469
|
+
const pipelineId = (_a = this._pipelineId) !== null && _a !== void 0 ? _a : this.agent.pipelineId;
|
|
418
470
|
// appCertificate presence is guaranteed by the guard above when no token is provided.
|
|
419
471
|
let expiresIn = this._expiresIn;
|
|
420
472
|
if (expiresIn !== undefined) {
|
|
@@ -428,7 +480,7 @@ class AgentSession {
|
|
|
428
480
|
expiresIn,
|
|
429
481
|
};
|
|
430
482
|
const { skipVendorValidationCategories, allowMissingVendorCategories } = this._vendorValidationCategories(pipelineId);
|
|
431
|
-
const properties = this.
|
|
483
|
+
const properties = this.agent.toProperties(Object.assign({ channel: this._channel, agentUid: this._agentUid, remoteUids: this._remoteUids, idleTimeout: this._idleTimeout, enableStringUid: this._enableStringUid, skipVendorValidationCategories,
|
|
432
484
|
allowMissingVendorCategories }, tokenOpts));
|
|
433
485
|
const resolved = (0, presets_js_1.resolveSessionPresets)({
|
|
434
486
|
preset: this._preset,
|
|
@@ -484,29 +536,47 @@ class AgentSession {
|
|
|
484
536
|
*/
|
|
485
537
|
stop() {
|
|
486
538
|
return __awaiter(this, void 0, void 0, function* () {
|
|
487
|
-
if (this._status !== "running") {
|
|
539
|
+
if (this._status !== "running" && !(this._backend && this._status === "starting")) {
|
|
488
540
|
throw new Error(`Cannot stop session in ${this._status} state`);
|
|
489
541
|
}
|
|
490
542
|
if (!this._agentId) {
|
|
491
543
|
throw new Error("No agent ID available");
|
|
492
544
|
}
|
|
545
|
+
const lifecycle = this._backend ? this._beginLifecycle() : undefined;
|
|
493
546
|
this._status = "stopping";
|
|
494
547
|
try {
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
548
|
+
if (this._backend)
|
|
549
|
+
yield this._backend.stop(this._agentId);
|
|
550
|
+
else
|
|
551
|
+
yield this._agentsClient.stop({
|
|
552
|
+
appid: this._appId,
|
|
553
|
+
agentId: this._agentId,
|
|
554
|
+
}, { headers: this._requestHeaders() });
|
|
499
555
|
this._status = "stopped";
|
|
500
|
-
this.
|
|
556
|
+
this._finishLifecycle(lifecycle);
|
|
557
|
+
this._emit("stopped", Object.assign({ agentId: this._agentId }, (this._backend ? { sessionId: this._agentId } : {})));
|
|
501
558
|
}
|
|
502
559
|
catch (error) {
|
|
503
560
|
// Handle 404 "task not found" gracefully - agent is already stopped
|
|
504
|
-
if (error instanceof index_js_1.AgoraError && error.statusCode === 404) {
|
|
561
|
+
if (!this._backend && error instanceof index_js_1.AgoraError && error.statusCode === 404) {
|
|
505
562
|
this._status = "stopped";
|
|
506
|
-
this._emit("stopped", { agentId: this._agentId });
|
|
563
|
+
this._emit("stopped", Object.assign({ agentId: this._agentId }, (this._backend ? { sessionId: this._agentId } : {})));
|
|
507
564
|
return; // Don't throw - agent is already stopped
|
|
508
565
|
}
|
|
509
|
-
|
|
566
|
+
const reason = error instanceof transport_js_1.V3Error &&
|
|
567
|
+
error.statusCode === 409 &&
|
|
568
|
+
error.body !== null &&
|
|
569
|
+
typeof error.body === "object" &&
|
|
570
|
+
"reason" in error.body
|
|
571
|
+
? error.body.reason
|
|
572
|
+
: undefined;
|
|
573
|
+
this._status =
|
|
574
|
+
this._backend && reason === "TaskNotRunning"
|
|
575
|
+
? "stopped"
|
|
576
|
+
: this._backend && reason === "TaskConflict"
|
|
577
|
+
? "stopping"
|
|
578
|
+
: "error";
|
|
579
|
+
this._finishLifecycle(lifecycle);
|
|
510
580
|
this._emit("error", error);
|
|
511
581
|
throw error;
|
|
512
582
|
}
|
|
@@ -520,6 +590,8 @@ class AgentSession {
|
|
|
520
590
|
*/
|
|
521
591
|
say(text, options) {
|
|
522
592
|
return __awaiter(this, void 0, void 0, function* () {
|
|
593
|
+
if (this._backend)
|
|
594
|
+
throw new session_backend_js_1.UnsupportedSessionOperationError("say");
|
|
523
595
|
if (this._status !== "running") {
|
|
524
596
|
throw new Error(`Cannot say in ${this._status} state`);
|
|
525
597
|
}
|
|
@@ -540,6 +612,8 @@ class AgentSession {
|
|
|
540
612
|
*/
|
|
541
613
|
interrupt() {
|
|
542
614
|
return __awaiter(this, void 0, void 0, function* () {
|
|
615
|
+
if (this._backend)
|
|
616
|
+
throw new session_backend_js_1.UnsupportedSessionOperationError("interrupt");
|
|
543
617
|
if (this._status !== "running") {
|
|
544
618
|
throw new Error(`Cannot interrupt in ${this._status} state`);
|
|
545
619
|
}
|
|
@@ -557,6 +631,8 @@ class AgentSession {
|
|
|
557
631
|
*/
|
|
558
632
|
think(text, options) {
|
|
559
633
|
return __awaiter(this, void 0, void 0, function* () {
|
|
634
|
+
if (this._backend)
|
|
635
|
+
throw new session_backend_js_1.UnsupportedSessionOperationError("think");
|
|
560
636
|
if (this._status !== "running") {
|
|
561
637
|
throw new Error(`Cannot think in ${this._status} state`);
|
|
562
638
|
}
|
|
@@ -582,16 +658,28 @@ class AgentSession {
|
|
|
582
658
|
*/
|
|
583
659
|
update(config) {
|
|
584
660
|
return __awaiter(this, void 0, void 0, function* () {
|
|
661
|
+
var _a;
|
|
585
662
|
if (this._status !== "running") {
|
|
586
663
|
throw new Error(`Cannot update in ${this._status} state`);
|
|
587
664
|
}
|
|
588
665
|
if (!this._agentId) {
|
|
589
666
|
throw new Error("No agent ID available");
|
|
590
667
|
}
|
|
668
|
+
if (this._backend) {
|
|
669
|
+
yield this._backend.update(this._agentId, config);
|
|
670
|
+
return;
|
|
671
|
+
}
|
|
672
|
+
let properties = config;
|
|
673
|
+
if ((config === null || config === void 0 ? void 0 : config.messages) !== undefined) {
|
|
674
|
+
if (((_a = config.llm) === null || _a === void 0 ? void 0 : _a.system_messages) !== undefined)
|
|
675
|
+
throw new Error("Provide messages or llm.system_messages, not both");
|
|
676
|
+
const { messages } = config, remaining = __rest(config, ["messages"]);
|
|
677
|
+
properties = Object.assign(Object.assign({}, remaining), { llm: Object.assign(Object.assign({}, remaining.llm), { system_messages: messages }) });
|
|
678
|
+
}
|
|
591
679
|
yield this._agentsClient.update({
|
|
592
680
|
appid: this._appId,
|
|
593
681
|
agentId: this._agentId,
|
|
594
|
-
properties
|
|
682
|
+
properties,
|
|
595
683
|
}, { headers: this._requestHeaders() });
|
|
596
684
|
});
|
|
597
685
|
}
|
|
@@ -602,6 +690,8 @@ class AgentSession {
|
|
|
602
690
|
*/
|
|
603
691
|
getHistory() {
|
|
604
692
|
return __awaiter(this, void 0, void 0, function* () {
|
|
693
|
+
if (this._backend)
|
|
694
|
+
throw new session_backend_js_1.UnsupportedSessionOperationError("getHistory");
|
|
605
695
|
if (!this._agentId) {
|
|
606
696
|
throw new Error("No agent ID available");
|
|
607
697
|
}
|
|
@@ -618,6 +708,8 @@ class AgentSession {
|
|
|
618
708
|
*/
|
|
619
709
|
getTurns(options) {
|
|
620
710
|
return __awaiter(this, void 0, void 0, function* () {
|
|
711
|
+
if (this._backend)
|
|
712
|
+
throw new session_backend_js_1.UnsupportedSessionOperationError("getTurns");
|
|
621
713
|
if (!this._agentId) {
|
|
622
714
|
throw new Error("No agent ID available");
|
|
623
715
|
}
|
|
@@ -638,6 +730,8 @@ class AgentSession {
|
|
|
638
730
|
getAllTurns(options) {
|
|
639
731
|
return __awaiter(this, void 0, void 0, function* () {
|
|
640
732
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
733
|
+
if (this._backend)
|
|
734
|
+
throw new session_backend_js_1.UnsupportedSessionOperationError("getAllTurns");
|
|
641
735
|
let page = yield this.getTurns({ page_index: 1, page_size: options === null || options === void 0 ? void 0 : options.page_size });
|
|
642
736
|
const allTurns = [...((_a = page.turns) !== null && _a !== void 0 ? _a : [])];
|
|
643
737
|
let currentPage = (_c = (_b = page.pagination) === null || _b === void 0 ? void 0 : _b.page_index) !== null && _c !== void 0 ? _c : 1;
|
|
@@ -678,9 +772,27 @@ class AgentSession {
|
|
|
678
772
|
*/
|
|
679
773
|
getInfo() {
|
|
680
774
|
return __awaiter(this, void 0, void 0, function* () {
|
|
775
|
+
var _a;
|
|
681
776
|
if (!this._agentId) {
|
|
682
777
|
throw new Error("No agent ID available");
|
|
683
778
|
}
|
|
779
|
+
if (this._backend) {
|
|
780
|
+
const id = this._agentId;
|
|
781
|
+
const lifecycle = this._lifecycleRevision;
|
|
782
|
+
const read = ++this._infoReadRevision;
|
|
783
|
+
const info = yield this._backend.getInfo(id);
|
|
784
|
+
if (this._pendingLifecycle !== undefined ||
|
|
785
|
+
lifecycle !== this._lifecycleRevision ||
|
|
786
|
+
read !== this._infoReadRevision ||
|
|
787
|
+
id !== this._agentId)
|
|
788
|
+
return info;
|
|
789
|
+
const status = (_a = info.status) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
790
|
+
if (status === "failed")
|
|
791
|
+
this._status = "error";
|
|
792
|
+
else if (status && ["idle", "starting", "running", "stopping", "stopped"].includes(status))
|
|
793
|
+
this._status = status;
|
|
794
|
+
return info;
|
|
795
|
+
}
|
|
684
796
|
return this._agentsClient.get({
|
|
685
797
|
appid: this._appId,
|
|
686
798
|
agentId: this._agentId,
|
|
@@ -34,9 +34,12 @@ export { createPreviewRoute, PREVIEW_API_BASE_URL, PREVIEW_FEATURE_HEADER, Previ
|
|
|
34
34
|
export type { GeminiTTSConfig, GeminiTTSModel, GeminiTTSOptions } from "./preview/gemini-tts.js";
|
|
35
35
|
export { GeminiTTS, GeminiTTSModels } from "./preview/gemini-tts.js";
|
|
36
36
|
export type { AvatarVendor, CNAvatarVendor, CNLlmVendor, CNMllmVendor, CNSttVendor, CNTtsVendor, GlobalAvatarVendor, GlobalLlmVendor, GlobalMllmVendor, GlobalSttVendor, GlobalTtsVendor, LlmVendor, SttVendor, TtsVendor, } from "./region-vendors.js";
|
|
37
|
+
export { UnsupportedSessionOperationError } from "./session-backend.js";
|
|
37
38
|
export type { GenerateConvoAITokenOptions, GenerateTokenOptions, } from "./token.js";
|
|
38
39
|
export { ExpiresIn, generateConvoAIToken, generateRtcToken, MAX_EXPIRY_SECONDS, } from "./token.js";
|
|
39
40
|
export type { AdvancedFeatures, AgentConfig, AgentConfigUpdate, AmazonTts, AmazonTtsParams, AsrConfig, AsrVendorName, AvatarConfig, AvatarWireVendor, CartesiaTts, CartesiaTtsParams, ConversationHistory, ConversationRole, ConversationSessionTurn, ConversationTurn, ConversationTurns, Eagerness, ElevenLabsTts, ElevenLabsTtsParams, EndOfSpeechConfig, EndOfSpeechMode, EndOfSpeechSemanticConfig, EndOfSpeechVadConfig, FarewellConfig, FillerWordsConfig, FillerWordsContent, FillerWordsContentGeneratedConfig, FillerWordsContentSelectionRule, FillerWordsContentStaticConfig, FillerWordsGeneratedLlmProvider, FillerWordsTrigger, FillerWordsTriggerFixedTimeConfig, FishAudioTts, FishAudioTtsParams, GeminiAsrParams, GenericTts, GenericTtsParams, GeofenceArea, GeofenceConfig, GeofenceExcludeArea, GetTurnsOptions, GoogleTts, GoogleTtsParams, GradiumTts, GradiumTtsParams, HumeAiTts, HumeAiTtsParams, InterruptionConfig, InterruptionMode, InterruptMode, Labels, LlmConfig, LlmGreetingConfigs, LlmGreetingConfigsMode, LlmStyle, LlmTool, LlmToolExecution, LlmToolFunction, LlmToolServer, McpServer, McpServersItem, MicrosoftTts, MicrosoftTtsParams, MinimaxTts, MinimaxTtsParams, MistralTts, MistralTtsParams, MllmConfig, MllmTurnDetectionConfig, MllmTurnDetectionMode, MllmVendor, MurfTts, MurfTtsParams, OpenAiTts, OpenAiTtsParams, ParametersAudioScenario, ParametersDataChannel, RimeTts, RimeTtsParams, RtcConfig, SalConfig, SalMode, SarvamTts, SarvamTtsParams, SayOptions, SessionInfo, SessionListResponse, SessionOptions, SessionParams, SessionParamsInput, SessionStatus, SessionSummary, SilenceAction, SilenceConfig, SmallestAiAsr, SmallestAiAsrParams, SmallestAiTts, SmallestAiTtsParams, SpatiusAvatarParams, SpeakPriority, StartOfSpeechConfig, StartOfSpeechDisabledConfig, StartOfSpeechDisabledConfigStrategy, StartOfSpeechKeywordsConfig, StartOfSpeechMode, StartOfSpeechVadConfig, SttConfig, ThinkOnListeningAction, ThinkOnSpeakingAction, ThinkOnThinkingAction, ThinkOptions, ThinkResponse, TtsConfig, TurnDetectionConfig, TurnDetectionLanguage, TurnDetectionNestedConfig, TurnDetectionType, TypecastTts, TypecastTtsParams, XAiAsr, XAiAsrParams, XAiTts, XAiTtsParams, } from "./types.js";
|
|
41
|
+
export type { AssignNumberOptions, DeployOptions, SaveOptions, SecretRef, VariableDefinition } from "./v3.js";
|
|
42
|
+
export { DeployedAgent, NumberNotFoundError, SavedAgent, SecretRefNotSupportedError, secretRef, UnsupportedFieldError, } from "./v3.js";
|
|
40
43
|
export type { AkoolAvatarOptions, AnamAvatarOptions, GenericAvatarOptions, HeyGenAvatarOptions, LemonSliceOptions, LiveAvatarAvatarOptions, ProtofaceOptions, TavusOptions, } from "./vendors/avatar.js";
|
|
41
44
|
export { AkoolAvatar, AnamAvatar, GenericAvatar, HeyGenAvatar, LemonSlice, LiveAvatarAvatar, Protoface, Tavus, } from "./vendors/avatar.js";
|
|
42
45
|
export type { AkoolSampleRate, CartesiaSampleRate, ElevenLabsSampleRate, HeyGenSampleRate, LiveAvatarSampleRate, MicrosoftSampleRate, SampleRate, } from "./vendors/base.js";
|
|
@@ -21,8 +21,9 @@
|
|
|
21
21
|
*/
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
23
|
exports.PREVIEW_FEATURE_HEADER = exports.PREVIEW_API_BASE_URL = exports.createPreviewRoute = exports.normalizePresetInput = exports.AgentPresets = exports.redactSecrets = exports.redactHeadersForDebug = exports.REDACTED = exports.TurnDetectionTypeValues = exports.ThinkOnThinkingActionInterrupt = exports.ThinkOnThinkingActionIgnore = exports.ThinkOnSpeakingActionInterrupt = exports.ThinkOnSpeakingActionIgnore = exports.ThinkOnListeningActionInterrupt = exports.ThinkOnListeningActionInject = exports.ThinkOnListeningActionIgnore = exports.SpeakPriorityValues = exports.SpeakPriorityInterrupt = exports.SpeakPriorityIgnore = exports.SpeakPriorityAppend = exports.SilenceActionValues = exports.SalModeValues = exports.MllmTurnDetectionModeValues = exports.MllmTurnDetectionModeServerVad = exports.MllmTurnDetectionModeSemanticVad = exports.MllmTurnDetectionModeAgoraVad = exports.InterruptionModeValues = exports.InterruptionModeStartOfSpeech = exports.InterruptionModeKeywords = exports.InterruptionDisabledStrategyIgnore = exports.InterruptionDisabledStrategyAppend = exports.InterruptionDisabledStrategy = exports.Geofence = exports.FillerWordsSelectionRule = exports.DataChannel = exports.CredentialMode = exports.AudioScenario = exports.validateTtsSampleRate = exports.validateAvatarConfig = exports.toBaseAvatarConfig = exports.isSpatiusAvatar = exports.isSensetimeAvatar = exports.isLiveAvatarAvatar = exports.isHeyGenAvatar = exports.isGenericAvatar = exports.isAvatarTokenManaged = exports.isAnamAvatar = exports.isAkoolAvatar = exports.AgentSession = exports.Agent = void 0;
|
|
24
|
-
exports.
|
|
25
|
-
exports.
|
|
24
|
+
exports.TencentTTS = exports.TencentSTT = exports.TencentLLM = exports.StepFunTTS = exports.SpatiusAvatar = exports.SensetimeAvatar = exports.MiniMaxCNTTS = exports.MicrosoftCNTTS = exports.MicrosoftCNSTT = exports.FengmingSTT = exports.DeepSeekLLM = exports.CosyVoiceTTS = exports.BytedanceTTS = exports.BytedanceLLM = exports.BytedanceDuplexTTS = exports.AliyunLLM = exports.BaseTTS = exports.BaseSTT = exports.BaseMLLM = exports.BaseLLM = exports.BaseCNTTS = exports.BaseCNSTT = exports.BaseCNMLLM = exports.BaseCNLLM = exports.BaseCNAvatar = exports.BaseAvatar = exports.Tavus = exports.Protoface = exports.LiveAvatarAvatar = exports.LemonSlice = exports.HeyGenAvatar = exports.GenericAvatar = exports.AnamAvatar = exports.AkoolAvatar = exports.UnsupportedFieldError = exports.secretRef = exports.SecretRefNotSupportedError = exports.SavedAgent = exports.NumberNotFoundError = exports.DeployedAgent = exports.MAX_EXPIRY_SECONDS = exports.generateRtcToken = exports.generateConvoAIToken = exports.ExpiresIn = exports.UnsupportedSessionOperationError = exports.GeminiTTSModels = exports.GeminiTTS = exports.requiredPreviewFeatures = exports.previewRequestHeaders = exports.PreviewFeatures = void 0;
|
|
25
|
+
exports.MistralTTS = exports.MiniMaxTTS = exports.MicrosoftTTS = exports.HumeAITTS = exports.GradiumTTS = exports.GoogleTTS = exports.GenericTTS = exports.FishAudioTTS = exports.ElevenLabsTTS = exports.DeepgramTTS = exports.CartesiaTTS = exports.AmazonTTS = exports.XAiSTT = exports.SpeechmaticsSTT = exports.SmallestAISTT = exports.SarvamSTT = exports.OpenAISTT = exports.MicrosoftSTT = exports.GoogleSTT = exports.GeminiTranscriptionMode = exports.GeminiSTTModels = exports.GeminiSTT = exports.DeepgramSTT = exports.AssemblyAISTT = exports.AresSTT = exports.AmazonSTT = exports.XaiGrok = exports.VertexAI = exports.QwenOmni = exports.OpenAIRealtime = exports.OpenAIGPTLive = exports.GeminiThinkingLevels = exports.GeminiLiveModels = exports.GeminiLive = exports.GEMINI_PREVIEW_MLLM_URL = exports.GEMINI_MLLM_URL = exports.GEMINI_MLLM_DEFAULT_MODEL = exports.AzureOpenAIRealtime = exports.VertexAILLM = exports.OpenAI = exports.Groq = exports.Gemini = exports.Dify = exports.CustomLLM = exports.AzureOpenAI = exports.Anthropic = exports.AmazonBedrock = exports.XfyunSTT = exports.XfyunDialectSTT = exports.XfyunBigModelSTT = void 0;
|
|
26
|
+
exports.XAiTTS = exports.TypecastTTS = exports.SmallestAITTS = exports.SarvamTTS = exports.RimeTTS = exports.OpenAITTS = exports.MurfTTS = void 0;
|
|
26
27
|
// Core classes
|
|
27
28
|
var Agent_js_1 = require("./Agent.js");
|
|
28
29
|
Object.defineProperty(exports, "Agent", { enumerable: true, get: function () { return Agent_js_1.Agent; } });
|
|
@@ -88,12 +89,21 @@ Object.defineProperty(exports, "requiredPreviewFeatures", { enumerable: true, ge
|
|
|
88
89
|
var gemini_tts_js_1 = require("./preview/gemini-tts.js");
|
|
89
90
|
Object.defineProperty(exports, "GeminiTTS", { enumerable: true, get: function () { return gemini_tts_js_1.GeminiTTS; } });
|
|
90
91
|
Object.defineProperty(exports, "GeminiTTSModels", { enumerable: true, get: function () { return gemini_tts_js_1.GeminiTTSModels; } });
|
|
92
|
+
var session_backend_js_1 = require("./session-backend.js");
|
|
93
|
+
Object.defineProperty(exports, "UnsupportedSessionOperationError", { enumerable: true, get: function () { return session_backend_js_1.UnsupportedSessionOperationError; } });
|
|
91
94
|
// Token generation
|
|
92
95
|
var token_js_1 = require("./token.js");
|
|
93
96
|
Object.defineProperty(exports, "ExpiresIn", { enumerable: true, get: function () { return token_js_1.ExpiresIn; } });
|
|
94
97
|
Object.defineProperty(exports, "generateConvoAIToken", { enumerable: true, get: function () { return token_js_1.generateConvoAIToken; } });
|
|
95
98
|
Object.defineProperty(exports, "generateRtcToken", { enumerable: true, get: function () { return token_js_1.generateRtcToken; } });
|
|
96
99
|
Object.defineProperty(exports, "MAX_EXPIRY_SECONDS", { enumerable: true, get: function () { return token_js_1.MAX_EXPIRY_SECONDS; } });
|
|
100
|
+
var v3_js_1 = require("./v3.js");
|
|
101
|
+
Object.defineProperty(exports, "DeployedAgent", { enumerable: true, get: function () { return v3_js_1.DeployedAgent; } });
|
|
102
|
+
Object.defineProperty(exports, "NumberNotFoundError", { enumerable: true, get: function () { return v3_js_1.NumberNotFoundError; } });
|
|
103
|
+
Object.defineProperty(exports, "SavedAgent", { enumerable: true, get: function () { return v3_js_1.SavedAgent; } });
|
|
104
|
+
Object.defineProperty(exports, "SecretRefNotSupportedError", { enumerable: true, get: function () { return v3_js_1.SecretRefNotSupportedError; } });
|
|
105
|
+
Object.defineProperty(exports, "secretRef", { enumerable: true, get: function () { return v3_js_1.secretRef; } });
|
|
106
|
+
Object.defineProperty(exports, "UnsupportedFieldError", { enumerable: true, get: function () { return v3_js_1.UnsupportedFieldError; } });
|
|
97
107
|
// Avatar vendor classes
|
|
98
108
|
var avatar_js_1 = require("./vendors/avatar.js");
|
|
99
109
|
Object.defineProperty(exports, "AkoolAvatar", { enumerable: true, get: function () { return avatar_js_1.AkoolAvatar; } });
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Internal adapter for session identities, without mixing them with running-agent IDs. */
|
|
2
|
+
import type { AgoraClient } from "../AgoraPoolClient.js";
|
|
3
|
+
import type { AgentCreateRequest } from "../v3/types.js";
|
|
4
|
+
import type { Agent } from "./Agent.js";
|
|
5
|
+
import { AgentSession } from "./AgentSession.js";
|
|
6
|
+
import type { AgentConfigUpdate, SessionInfo, SessionOptions } from "./types.js";
|
|
7
|
+
export interface SessionBackend {
|
|
8
|
+
start(): Promise<{
|
|
9
|
+
id: string;
|
|
10
|
+
status: "starting" | "running";
|
|
11
|
+
}>;
|
|
12
|
+
stop(id: string): Promise<void>;
|
|
13
|
+
update(id: string, config: AgentConfigUpdate): Promise<void>;
|
|
14
|
+
getInfo(id: string): Promise<SessionInfo>;
|
|
15
|
+
}
|
|
16
|
+
export declare class UnsupportedSessionOperationError extends Error {
|
|
17
|
+
constructor(operation: string);
|
|
18
|
+
}
|
|
19
|
+
export declare function createStoredSession(client: AgoraClient, options: SessionOptions, source: {
|
|
20
|
+
agent_id: string;
|
|
21
|
+
} | {
|
|
22
|
+
agent: Omit<AgentCreateRequest, "agent_name">;
|
|
23
|
+
}, config?: Agent): AgentSession;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.UnsupportedSessionOperationError = void 0;
|
|
13
|
+
exports.createStoredSession = createStoredSession;
|
|
14
|
+
const session_lifecycle_js_1 = require("../v3/session-lifecycle.js");
|
|
15
|
+
const AgentSession_js_1 = require("./AgentSession.js");
|
|
16
|
+
class UnsupportedSessionOperationError extends Error {
|
|
17
|
+
constructor(operation) {
|
|
18
|
+
super(`${operation} is not supported by this session backend; start, stop, getInfo and update are available`);
|
|
19
|
+
this.name = "UnsupportedSessionOperationError";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.UnsupportedSessionOperationError = UnsupportedSessionOperationError;
|
|
23
|
+
function createStoredSession(client, options, source, config) {
|
|
24
|
+
var _a, _b;
|
|
25
|
+
for (const key of [
|
|
26
|
+
"clientReference",
|
|
27
|
+
"client_reference",
|
|
28
|
+
"expiresIn",
|
|
29
|
+
"enableStringUid",
|
|
30
|
+
"preset",
|
|
31
|
+
"pipelineId",
|
|
32
|
+
]) {
|
|
33
|
+
if (key in options && options[key] !== undefined)
|
|
34
|
+
throw new Error(`${key} is not supported by this session backend`);
|
|
35
|
+
}
|
|
36
|
+
const lifecycle = {};
|
|
37
|
+
for (const [key, wire] of [
|
|
38
|
+
["idleTimeout", "idle_timeout_ms"],
|
|
39
|
+
["maxDuration", "max_duration_ms"],
|
|
40
|
+
]) {
|
|
41
|
+
if (options[key] !== undefined)
|
|
42
|
+
lifecycle[wire] = options[key] * 1000;
|
|
43
|
+
}
|
|
44
|
+
if (options.gracefulStop !== undefined)
|
|
45
|
+
lifecycle.graceful_stop = options.gracefulStop;
|
|
46
|
+
const payload = JSON.parse(JSON.stringify(Object.assign(Object.assign(Object.assign({}, source), { values: options.values, idempotencyKey: options.idempotencyKey, data_policy: options.dataPolicy, labels: options.labels, transport: {
|
|
47
|
+
type: "rtc",
|
|
48
|
+
channel: options.channel,
|
|
49
|
+
uid: options.agentUid,
|
|
50
|
+
subscribe_uids: options.remoteUids,
|
|
51
|
+
token: options.token,
|
|
52
|
+
encryption: options.encryption,
|
|
53
|
+
audio_scenario: options.audioScenario,
|
|
54
|
+
geofence: options.geofence,
|
|
55
|
+
} }), (Object.keys(lifecycle).length ? { lifecycle } : {}))));
|
|
56
|
+
(0, session_lifecycle_js_1.validateSessionStart)(payload);
|
|
57
|
+
let successfullyStarted = false;
|
|
58
|
+
const backend = {
|
|
59
|
+
start() {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
if (payload.idempotencyKey && successfullyStarted)
|
|
62
|
+
throw new Error("This idempotency key already started a session; create a new handle with a new key for another session");
|
|
63
|
+
const result = "agent_id" in payload
|
|
64
|
+
? yield client.v3.sessions.start(payload)
|
|
65
|
+
: yield client.v3.sessions.startEphemeral(payload);
|
|
66
|
+
if (typeof result.agent_session_id !== "string" || !result.agent_session_id.trim()) {
|
|
67
|
+
throw new Error("Session start response is missing agent_session_id");
|
|
68
|
+
}
|
|
69
|
+
successfullyStarted = true;
|
|
70
|
+
return { id: result.agent_session_id, status: result.status === "STARTING" ? "starting" : "running" };
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
stop(id) {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
yield client.v3.sessions.stop({ agentSessionId: id });
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
update(id, config) {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
var _a, _b, _c;
|
|
81
|
+
const input = config;
|
|
82
|
+
if (!input || typeof input !== "object" || Array.isArray(input))
|
|
83
|
+
throw new Error("Invalid session update");
|
|
84
|
+
for (const key of Object.keys(input))
|
|
85
|
+
if (!["token", "messages", "llm"].includes(key))
|
|
86
|
+
throw new Error(`Unsupported session update field: ${key}`);
|
|
87
|
+
if (input.messages !== undefined && ((_a = input.llm) === null || _a === void 0 ? void 0 : _a.system_messages) !== undefined)
|
|
88
|
+
throw new Error("Provide messages or llm.system_messages, not both");
|
|
89
|
+
const patch = {};
|
|
90
|
+
if (input.token !== undefined) {
|
|
91
|
+
if (typeof input.token !== "string" || !input.token)
|
|
92
|
+
throw new Error("token must be a string");
|
|
93
|
+
patch.transport = { token: input.token };
|
|
94
|
+
}
|
|
95
|
+
const overrides = {};
|
|
96
|
+
const messages = (_b = input.messages) !== null && _b !== void 0 ? _b : (_c = input.llm) === null || _c === void 0 ? void 0 : _c.system_messages;
|
|
97
|
+
if (messages !== undefined) {
|
|
98
|
+
if (!Array.isArray(messages) ||
|
|
99
|
+
messages.some((message) => !message ||
|
|
100
|
+
!["system", "user", "assistant"].includes(message.role) ||
|
|
101
|
+
typeof message.content !== "string" ||
|
|
102
|
+
Object.keys(message).some((key) => !["role", "content"].includes(key))))
|
|
103
|
+
throw new Error("Invalid session messages");
|
|
104
|
+
overrides.messages = messages;
|
|
105
|
+
}
|
|
106
|
+
for (const kind of ["llm"])
|
|
107
|
+
if (input[kind] !== undefined) {
|
|
108
|
+
const module = input[kind];
|
|
109
|
+
if (!module ||
|
|
110
|
+
typeof module !== "object" ||
|
|
111
|
+
Array.isArray(module) ||
|
|
112
|
+
Object.keys(module).some((key) => !["params", ...(kind === "llm" ? ["system_messages"] : [])].includes(key)))
|
|
113
|
+
throw new Error(`Invalid ${kind} update`);
|
|
114
|
+
if (module.params !== undefined) {
|
|
115
|
+
if (!module.params || typeof module.params !== "object" || Array.isArray(module.params))
|
|
116
|
+
throw new Error("params must be an object");
|
|
117
|
+
if (Object.keys(module.params).some((key) => ["url", "base_url", "api_base_url", "endpoint"].includes(key.toLowerCase())))
|
|
118
|
+
throw new Error("Runtime endpoint aliases are not mutable");
|
|
119
|
+
overrides.pipeline = { [kind]: { params: module.params } };
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (Object.keys(overrides).length)
|
|
123
|
+
patch.agent = { overrides };
|
|
124
|
+
yield client.v3.sessions.update(Object.assign({ agentSessionId: id }, patch));
|
|
125
|
+
});
|
|
126
|
+
},
|
|
127
|
+
getInfo(id) {
|
|
128
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
129
|
+
var _a, _b;
|
|
130
|
+
const info = yield client.v3.sessions.get({ agentSessionId: id });
|
|
131
|
+
return Object.assign(Object.assign({}, info), { message: (_a = info.message) !== null && _a !== void 0 ? _a : undefined, stop_ts: (_b = info.stop_ts) !== null && _b !== void 0 ? _b : undefined });
|
|
132
|
+
});
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
return new AgentSession_js_1.AgentSession(Object.assign(Object.assign({ client, agent: config, backend, appId: client.appId, name: (_a = options.name) !== null && _a !== void 0 ? _a : "session" }, options), { agentUid: (_b = options.agentUid) !== null && _b !== void 0 ? _b : "0" }));
|
|
136
|
+
}
|
|
@@ -235,17 +235,29 @@ export type McpServersItem = McpServer & Record<string, unknown>;
|
|
|
235
235
|
/** Full agent configuration (alias for StartAgentsRequest.Properties) */
|
|
236
236
|
export type AgentConfig = StartAgentsRequest.Properties;
|
|
237
237
|
/** Agent configuration update (for runtime updates) */
|
|
238
|
-
export type AgentConfigUpdate = UpdateAgentsRequest.Properties
|
|
238
|
+
export type AgentConfigUpdate = UpdateAgentsRequest.Properties & {
|
|
239
|
+
messages?: import("../v3/types.js").Message[];
|
|
240
|
+
};
|
|
239
241
|
/** Options for creating a session via {@link Agent.createSession} */
|
|
240
242
|
export interface SessionOptions {
|
|
243
|
+
/** Runtime values for declared template variables; selects ephemeral startup for inline builders. */
|
|
244
|
+
values?: Record<string, string | number | boolean>;
|
|
245
|
+
idempotencyKey?: string;
|
|
246
|
+
labels?: Record<string, string>;
|
|
247
|
+
maxDuration?: number;
|
|
248
|
+
encryption?: import("../v3/session-schema.js").RtcEncryption;
|
|
249
|
+
audioScenario?: "aiserver" | "chorus";
|
|
250
|
+
geofence?: import("../v3/session-lifecycle.js").SessionGeofence;
|
|
251
|
+
gracefulStop?: import("../v3/session-schema.js").GracefulStop;
|
|
252
|
+
dataPolicy?: import("../v3/session-schema.js").DataPolicy;
|
|
241
253
|
/** Unique agent instance name sent to the Agora API. Omit to auto-generate `agent-{timestamp}`. */
|
|
242
254
|
name?: string;
|
|
243
255
|
/** The channel to join */
|
|
244
256
|
channel: string;
|
|
245
257
|
/** Authentication token for the channel. Omit to auto-generate (requires appCertificate on the session). */
|
|
246
258
|
token?: string;
|
|
247
|
-
/** The agent's RTC UID */
|
|
248
|
-
agentUid
|
|
259
|
+
/** The agent's RTC UID. Omit for server auto-assignment (legacy inline sessions use 0). */
|
|
260
|
+
agentUid?: string;
|
|
249
261
|
/** Remote user UIDs to subscribe to */
|
|
250
262
|
remoteUids: string[];
|
|
251
263
|
/** Idle timeout in seconds (0 = no auto-exit) */
|
|
@@ -270,7 +282,12 @@ export interface SessionOptions {
|
|
|
270
282
|
/** Session status */
|
|
271
283
|
export type SessionStatus = ListAgentsResponse.Data.List.Item.Status;
|
|
272
284
|
/** Session info (from get endpoint) */
|
|
273
|
-
export type SessionInfo = GetAgentsResponse
|
|
285
|
+
export type SessionInfo = GetAgentsResponse & {
|
|
286
|
+
agent_session_id?: string;
|
|
287
|
+
agent_name?: string;
|
|
288
|
+
/** Older responses may include analysis; the current contract does not promise it. */
|
|
289
|
+
analysis?: unknown;
|
|
290
|
+
};
|
|
274
291
|
/** Session list response */
|
|
275
292
|
export type SessionListResponse = ListAgentsResponse;
|
|
276
293
|
/** Session summary (list item) */
|