@alfe.ai/agent-api-client 0.2.3 → 0.4.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 +16 -0
- package/dist/index.cjs +186 -1
- package/dist/index.d.cts +192 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +192 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +186 -1
- package/dist/index.js.map +1 -1
- package/package.json +10 -1
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,15 @@ interface AgentApiClientConfig {
|
|
|
6
6
|
apiKey: string;
|
|
7
7
|
apiUrl: string;
|
|
8
8
|
}
|
|
9
|
+
interface RemoteSessionInfo {
|
|
10
|
+
sessionId: string;
|
|
11
|
+
agentId: string;
|
|
12
|
+
surface: "browser" | "terminal";
|
|
13
|
+
status: "agent_driving" | "awaiting_human" | "human_in_control" | "resuming" | "completed" | "expired" | "failed";
|
|
14
|
+
url?: string;
|
|
15
|
+
instructions?: string;
|
|
16
|
+
requestedAt?: string;
|
|
17
|
+
}
|
|
9
18
|
interface SyncAgentInfo {
|
|
10
19
|
agentId: string;
|
|
11
20
|
tenantId: string;
|
|
@@ -146,6 +155,79 @@ interface KnowledgeDoc {
|
|
|
146
155
|
createdAt: string;
|
|
147
156
|
updatedAt: string;
|
|
148
157
|
}
|
|
158
|
+
/** Voice settings — core agent config. Mirrors `VoiceConfig` in `@alfe/types`. */
|
|
159
|
+
interface AgentVoiceConfig {
|
|
160
|
+
/** ElevenLabs voice ID; platform default when unset. */
|
|
161
|
+
voiceId?: string;
|
|
162
|
+
ttsModel?: string;
|
|
163
|
+
enabled?: boolean;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* The agent's own public identity, as returned by `updateSelf`, `generateAvatar`,
|
|
167
|
+
* `presignAvatar`'s finalize (`finalizeAvatar`). This is the public agent
|
|
168
|
+
* projection; only the identity-relevant fields are typed here — the response
|
|
169
|
+
* carries the full public agent record.
|
|
170
|
+
*/
|
|
171
|
+
interface AgentSelf {
|
|
172
|
+
agentId: string;
|
|
173
|
+
tenantId: string;
|
|
174
|
+
name: string;
|
|
175
|
+
avatarUrl?: string;
|
|
176
|
+
voiceConfig?: AgentVoiceConfig;
|
|
177
|
+
status: string;
|
|
178
|
+
}
|
|
179
|
+
/** Result of `presignAvatar` — the agent PUTs bytes to `uploadUrl`, then finalizes with `s3Key`. */
|
|
180
|
+
interface AgentAvatarPresign {
|
|
181
|
+
/** Presigned PUT URL to upload the image bytes to. */
|
|
182
|
+
uploadUrl: string;
|
|
183
|
+
/** Object key — echoed back to `finalizeAvatar`. */
|
|
184
|
+
s3Key: string;
|
|
185
|
+
/** Stable public URL the avatar will be served from once finalized. */
|
|
186
|
+
publicUrl: string;
|
|
187
|
+
/** ISO expiry of the presigned PUT URL. */
|
|
188
|
+
expiresAt: string;
|
|
189
|
+
}
|
|
190
|
+
/** A voice in the platform catalogue (ElevenLabs), from `listVoices`. */
|
|
191
|
+
interface AgentVoice {
|
|
192
|
+
id: string;
|
|
193
|
+
name: string;
|
|
194
|
+
previewUrl: string;
|
|
195
|
+
description: string;
|
|
196
|
+
labels: Record<string, string>;
|
|
197
|
+
category: string;
|
|
198
|
+
}
|
|
199
|
+
/** The ElevenLabs models with a pricing row — the TTS endpoint rejects any other value. */
|
|
200
|
+
type VoiceTtsModel = "eleven_turbo_v2_5" | "eleven_multilingual_v2";
|
|
201
|
+
interface VoiceTtsArgs {
|
|
202
|
+
/** Text to synthesize (1–5000 chars — the endpoint enforces this). */
|
|
203
|
+
text: string;
|
|
204
|
+
/** ElevenLabs voice id; platform default when unset. */
|
|
205
|
+
voiceId?: string;
|
|
206
|
+
/** TTS model; `eleven_turbo_v2_5` (lower latency) when unset. */
|
|
207
|
+
model?: VoiceTtsModel;
|
|
208
|
+
}
|
|
209
|
+
/** Raw synthesized audio plus its PCM framing (from the response headers). */
|
|
210
|
+
interface VoiceTtsResult {
|
|
211
|
+
/** Raw little-endian PCM samples — no container. Wrap in WAV to make a playable file. */
|
|
212
|
+
audio: Buffer;
|
|
213
|
+
/** Samples per second (e.g. 24000). */
|
|
214
|
+
sampleRate: number;
|
|
215
|
+
/** Channel count (mono = 1). */
|
|
216
|
+
channels: number;
|
|
217
|
+
/** Bits per sample (e.g. 16). */
|
|
218
|
+
bitDepth: number;
|
|
219
|
+
}
|
|
220
|
+
interface VoiceSttArgs {
|
|
221
|
+
/** Raw linear16 (16-bit little-endian) mono PCM samples — no WAV/container header. */
|
|
222
|
+
audio: Uint8Array;
|
|
223
|
+
/** Sample rate of `audio` in Hz (8000–48000). */
|
|
224
|
+
sampleRate: number;
|
|
225
|
+
}
|
|
226
|
+
interface VoiceSttResult {
|
|
227
|
+
text: string;
|
|
228
|
+
/** Deepgram confidence in (0,1]. */
|
|
229
|
+
confidence: number;
|
|
230
|
+
}
|
|
149
231
|
declare class AgentApiClient {
|
|
150
232
|
private readonly apiKey;
|
|
151
233
|
private readonly apiUrl;
|
|
@@ -283,7 +365,7 @@ declare class AgentApiClient {
|
|
|
283
365
|
* @deprecated Returns a single primary credential blob (legacy "pick-the-
|
|
284
366
|
* default-connection" shape). Use `getGithubAccounts()` for the multi-
|
|
285
367
|
* account shape required by Pattern A — explicit selector args on every
|
|
286
|
-
* tool. Retained because the `@alfe.ai/
|
|
368
|
+
* tool. Retained because the `@alfe.ai/github-mcp` proxy is the
|
|
287
369
|
* only consumer that knows about Pattern A; legacy env-interpolation
|
|
288
370
|
* callers will keep hitting `/credentials` until they move to the proxy.
|
|
289
371
|
*/
|
|
@@ -512,6 +594,45 @@ declare class AgentApiClient {
|
|
|
512
594
|
accessToken: string;
|
|
513
595
|
expiresAt: string;
|
|
514
596
|
}>;
|
|
597
|
+
/**
|
|
598
|
+
* @deprecated Returns a single primary credential blob. Use
|
|
599
|
+
* `getSalesforceAccounts()` for the multi-account shape required by
|
|
600
|
+
* Pattern A.
|
|
601
|
+
*/
|
|
602
|
+
getSalesforceCredentials(): Promise<{
|
|
603
|
+
accessToken: string;
|
|
604
|
+
accessTokenExpiresAt: string;
|
|
605
|
+
instanceUrl: string;
|
|
606
|
+
orgId: string;
|
|
607
|
+
}>;
|
|
608
|
+
/**
|
|
609
|
+
* Pattern A: multi-account credential fetch for Salesforce. Returns every
|
|
610
|
+
* agent-scoped Salesforce connection. One OAuth grant maps to one org, so
|
|
611
|
+
* `accounts[i].accountIdentifier` (and `orgId`) is the Salesforce org id —
|
|
612
|
+
* the selector every credential-touching tool requires.
|
|
613
|
+
*/
|
|
614
|
+
getSalesforceAccounts(): Promise<{
|
|
615
|
+
accounts: {
|
|
616
|
+
connectionId: string;
|
|
617
|
+
accountIdentifier: string;
|
|
618
|
+
displayName: string | null;
|
|
619
|
+
connectedAt: string;
|
|
620
|
+
accessToken: string;
|
|
621
|
+
accessTokenExpiresAt: string;
|
|
622
|
+
instanceUrl: string;
|
|
623
|
+
orgId: string;
|
|
624
|
+
}[];
|
|
625
|
+
}>;
|
|
626
|
+
/**
|
|
627
|
+
* Refresh the access token for a specific Salesforce org. Salesforce
|
|
628
|
+
* tokens aren't interchangeable across orgs, so the connection is targeted
|
|
629
|
+
* by `accountIdentifier` (the org id) — mirrors `refreshXeroAccountToken`.
|
|
630
|
+
*/
|
|
631
|
+
refreshSalesforceAccountToken(orgId: string): Promise<{
|
|
632
|
+
accessToken: string;
|
|
633
|
+
accessTokenExpiresAt: string;
|
|
634
|
+
expiresAt: string;
|
|
635
|
+
}>;
|
|
515
636
|
/**
|
|
516
637
|
* Microsoft 365 (delegated OAuth) credential fetch — single-account shape.
|
|
517
638
|
*
|
|
@@ -630,6 +751,35 @@ declare class AgentApiClient {
|
|
|
630
751
|
}): Promise<{
|
|
631
752
|
recorded: boolean;
|
|
632
753
|
}>;
|
|
754
|
+
/** Update the agent's own name and/or voice config. Returns the updated agent. */
|
|
755
|
+
updateSelf(update: {
|
|
756
|
+
name?: string;
|
|
757
|
+
voiceConfig?: AgentVoiceConfig;
|
|
758
|
+
}): Promise<AgentSelf>;
|
|
759
|
+
/**
|
|
760
|
+
* Generate the agent's own avatar from a text prompt. The image is generated,
|
|
761
|
+
* stored, and set on the agent server-side; returns the updated agent.
|
|
762
|
+
*/
|
|
763
|
+
generateAvatar(args: {
|
|
764
|
+
prompt: string;
|
|
765
|
+
}): Promise<AgentSelf>;
|
|
766
|
+
/**
|
|
767
|
+
* Get a presigned PUT URL to upload a new avatar image. Upload the bytes to
|
|
768
|
+
* `uploadUrl`, then call `finalizeAvatar(s3Key)` to set it on the agent.
|
|
769
|
+
*/
|
|
770
|
+
presignAvatar(args: {
|
|
771
|
+
mimeType: string;
|
|
772
|
+
size: number;
|
|
773
|
+
}): Promise<AgentAvatarPresign>;
|
|
774
|
+
/**
|
|
775
|
+
* Finalize an avatar upload — validates ownership + size, then sets the
|
|
776
|
+
* agent's `avatarUrl` server-side. Returns the updated agent.
|
|
777
|
+
*/
|
|
778
|
+
finalizeAvatar(s3Key: string): Promise<AgentSelf>;
|
|
779
|
+
/** List the platform voice catalogue (ElevenLabs) so the agent can pick its own voice. */
|
|
780
|
+
listVoices(): Promise<{
|
|
781
|
+
voices: AgentVoice[];
|
|
782
|
+
}>;
|
|
633
783
|
/**
|
|
634
784
|
* Mint a fresh AES-256 data key for a specific (secret, field) pair. The
|
|
635
785
|
* encryption context is rebuilt server-side from `auth.tenantId` + the body
|
|
@@ -1124,8 +1274,48 @@ declare class AgentApiClient {
|
|
|
1124
1274
|
operation: string;
|
|
1125
1275
|
summary?: string;
|
|
1126
1276
|
}): Promise<void>;
|
|
1277
|
+
requestBrowserTakeover(args: {
|
|
1278
|
+
instructions: string;
|
|
1279
|
+
url?: string;
|
|
1280
|
+
conversationId?: string;
|
|
1281
|
+
}): Promise<{
|
|
1282
|
+
sessionId: string;
|
|
1283
|
+
status: string;
|
|
1284
|
+
}>;
|
|
1285
|
+
getRemoteSession(sessionId: string): Promise<RemoteSessionInfo>;
|
|
1286
|
+
completeRemoteSession(sessionId: string): Promise<{
|
|
1287
|
+
ok: boolean;
|
|
1288
|
+
}>;
|
|
1289
|
+
/**
|
|
1290
|
+
* Issue a request that returns the raw `Response` (no JSON parsing, no
|
|
1291
|
+
* forced Content-Type). The caller sets `Content-Type`/`Accept` on `headers`
|
|
1292
|
+
* and reads the body itself (`arrayBuffer()` / `json()`).
|
|
1293
|
+
*
|
|
1294
|
+
* A single retry fires only on the same transient statuses `request()`
|
|
1295
|
+
* retries (authorizer-timeout 500 + LB 502/503/504) and transient network
|
|
1296
|
+
* errors — before the route handler runs — so re-issuing a POST does not
|
|
1297
|
+
* risk a duplicate side effect. Voice TTS/STT are effectively idempotent
|
|
1298
|
+
* (re-synthesize / re-transcribe) and meter server-side keyed on the
|
|
1299
|
+
* gateway requestId, so a retried transcription doesn't double-bill.
|
|
1300
|
+
*/
|
|
1301
|
+
private rawFetch;
|
|
1302
|
+
/**
|
|
1303
|
+
* Text-to-speech. Returns raw PCM audio bytes plus their framing — the
|
|
1304
|
+
* voice service defaults to 24 kHz / mono / 16-bit. Wrap in a WAV container
|
|
1305
|
+
* to produce a playable file. Metered per character against the tenant
|
|
1306
|
+
* credit pool server-side; TTS completes regardless of metering outcome.
|
|
1307
|
+
*/
|
|
1308
|
+
tts(args: VoiceTtsArgs): Promise<VoiceTtsResult>;
|
|
1309
|
+
/**
|
|
1310
|
+
* Speech-to-text. Accepts raw linear16 (16-bit LE) mono PCM — NOT a WAV or
|
|
1311
|
+
* other container (the endpoint transcribes with a fixed linear16 encoding,
|
|
1312
|
+
* so a container header would be transcribed as noise). Strip any WAV header
|
|
1313
|
+
* and pass `sampleRate` from it before calling. Metered by transcribed
|
|
1314
|
+
* duration against the tenant credit pool server-side.
|
|
1315
|
+
*/
|
|
1316
|
+
stt(args: VoiceSttArgs): Promise<VoiceSttResult>;
|
|
1127
1317
|
}
|
|
1128
1318
|
//# sourceMappingURL=index.d.ts.map
|
|
1129
1319
|
//#endregion
|
|
1130
|
-
export { AgentApiClient, AgentApiClientConfig, type ChangelogAction, type ChangelogActor, type ChangelogEntry, type EncryptedEnvelopeV1, type Field, type FieldEnvelope, type FieldFormat, type FieldSensitivity, type FieldView, type GeneratedDataKey, type IntegrationConfigResult, type IntegrationConfigSchemaField, type IntegrationInstall, KnowledgeDoc, KnowledgeFact, KnowledgeProfile, KnowledgeProfileLink, KnowledgeScope, KnowledgeScopeType, KnowledgeSearchHit, KnowledgeSearchResult, type RegistryEntry, type ScopeInfo, type SecretAggregate, type SecretCategory, type SecretMetadata, type SecretScope, SharedFileEntry, SyncAgentInfo, SyncAgentStats, SyncConfirmedUpload, SyncFileEntry, SyncManifest, SyncManifestEntry, SyncPresignedUrl, SyncReconstructBundle, SyncReconstructFile, SyncSessionContent, SyncSessionEntry };
|
|
1320
|
+
export { AgentApiClient, AgentApiClientConfig, AgentAvatarPresign, AgentSelf, AgentVoice, AgentVoiceConfig, type ChangelogAction, type ChangelogActor, type ChangelogEntry, type EncryptedEnvelopeV1, type Field, type FieldEnvelope, type FieldFormat, type FieldSensitivity, type FieldView, type GeneratedDataKey, type IntegrationConfigResult, type IntegrationConfigSchemaField, type IntegrationInstall, KnowledgeDoc, KnowledgeFact, KnowledgeProfile, KnowledgeProfileLink, KnowledgeScope, KnowledgeScopeType, KnowledgeSearchHit, KnowledgeSearchResult, type RegistryEntry, RemoteSessionInfo, type ScopeInfo, type SecretAggregate, type SecretCategory, type SecretMetadata, type SecretScope, SharedFileEntry, SyncAgentInfo, SyncAgentStats, SyncConfirmedUpload, SyncFileEntry, SyncManifest, SyncManifestEntry, SyncPresignedUrl, SyncReconstructBundle, SyncReconstructFile, SyncSessionContent, SyncSessionEntry, VoiceSttArgs, VoiceSttResult, VoiceTtsArgs, VoiceTtsModel, VoiceTtsResult };
|
|
1131
1321
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"index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;;;;;;;;;;;;;MA2BD;;;;;;;;;;;MAeC;;;;;;;;;;MAqBA;;;;;;;;;;;;;;;;;;;;;;;;MAsBA;;;;;;;;;;;;MAsBA;;;;wDAYwD;;;;uCAWjB;;;;;;;;;;;oBAOnB;;;;;;;;kCAOc;;;iBAMjB;;;;;;;;;;;;;;;MAcjB;;;;;;2BAiB2B;;;;+BAII;;;;;;;;;;MAY/B;;;;MAUA;;;;;MAWA;;;;;;;;;gBA2BmC;;MACpC,QAAQ;;gBAaS;YAAkB;;;6BAMzB,sCAEV,QAAQ;;4BAQE;;;MAGV;WAAiB;;;;;;;;;6BAiBP,oDAGV,QAAQ;;6BASE,sDAGV;;;;2BASU;;;MAGV;WAAiB;;;;;;;;0BAgBP,wDAGV;;;;;;;;;;;2BAqBU;;;MAKV;;;iCAgCkC;;;;;;;;;;;MAcjC;;;;;MAqBA;;;;uCAOuC,QAAQ;4CAIH;;;;;;;;;;;;;;;;;;;;;;YA0EhC,eAAe,QAAQ;;;;;;;;YAyBvB,eAAe,QAAQ"}
|
package/dist/index.js
CHANGED
|
@@ -202,7 +202,7 @@ var AgentApiClient = class {
|
|
|
202
202
|
* @deprecated Returns a single primary credential blob (legacy "pick-the-
|
|
203
203
|
* default-connection" shape). Use `getGithubAccounts()` for the multi-
|
|
204
204
|
* account shape required by Pattern A — explicit selector args on every
|
|
205
|
-
* tool. Retained because the `@alfe.ai/
|
|
205
|
+
* tool. Retained because the `@alfe.ai/github-mcp` proxy is the
|
|
206
206
|
* only consumer that knows about Pattern A; legacy env-interpolation
|
|
207
207
|
* callers will keep hitting `/credentials` until they move to the proxy.
|
|
208
208
|
*/
|
|
@@ -446,6 +446,52 @@ var AgentApiClient = class {
|
|
|
446
446
|
return this.request("/agent/connect/myob/refresh", { method: "POST" });
|
|
447
447
|
}
|
|
448
448
|
/**
|
|
449
|
+
* @deprecated Returns a single primary credential blob. Use
|
|
450
|
+
* `getSalesforceAccounts()` for the multi-account shape required by
|
|
451
|
+
* Pattern A.
|
|
452
|
+
*/
|
|
453
|
+
async getSalesforceCredentials() {
|
|
454
|
+
const raw = await this.request("/agent/connect/salesforce/credentials");
|
|
455
|
+
return {
|
|
456
|
+
accessToken: raw.accessToken,
|
|
457
|
+
accessTokenExpiresAt: raw.accessTokenExpiresAt ?? "",
|
|
458
|
+
instanceUrl: raw.instanceUrl ?? "",
|
|
459
|
+
orgId: raw.orgId ?? ""
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Pattern A: multi-account credential fetch for Salesforce. Returns every
|
|
464
|
+
* agent-scoped Salesforce connection. One OAuth grant maps to one org, so
|
|
465
|
+
* `accounts[i].accountIdentifier` (and `orgId`) is the Salesforce org id —
|
|
466
|
+
* the selector every credential-touching tool requires.
|
|
467
|
+
*/
|
|
468
|
+
async getSalesforceAccounts() {
|
|
469
|
+
return { accounts: (await this.request("/agent/connect/salesforce/accounts")).accounts.map((a) => ({
|
|
470
|
+
connectionId: a.connectionId,
|
|
471
|
+
accountIdentifier: a.accountIdentifier,
|
|
472
|
+
displayName: a.displayName,
|
|
473
|
+
connectedAt: a.connectedAt,
|
|
474
|
+
accessToken: a.accessToken,
|
|
475
|
+
accessTokenExpiresAt: a.accessTokenExpiresAt ?? "",
|
|
476
|
+
instanceUrl: a.instanceUrl ?? "",
|
|
477
|
+
orgId: a.orgId ?? a.accountIdentifier
|
|
478
|
+
})) };
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* Refresh the access token for a specific Salesforce org. Salesforce
|
|
482
|
+
* tokens aren't interchangeable across orgs, so the connection is targeted
|
|
483
|
+
* by `accountIdentifier` (the org id) — mirrors `refreshXeroAccountToken`.
|
|
484
|
+
*/
|
|
485
|
+
async refreshSalesforceAccountToken(orgId) {
|
|
486
|
+
const path = `/agent/connect/salesforce/accounts/${encodeURIComponent(orgId)}/refresh`;
|
|
487
|
+
const raw = await this.request(path, { method: "POST" });
|
|
488
|
+
return {
|
|
489
|
+
accessToken: raw.accessToken,
|
|
490
|
+
accessTokenExpiresAt: raw.accessTokenExpiresAt ?? "",
|
|
491
|
+
expiresAt: raw.expiresAt ?? ""
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
449
495
|
* Microsoft 365 (delegated OAuth) credential fetch — single-account shape.
|
|
450
496
|
*
|
|
451
497
|
* @deprecated Use `getMicrosoftAccounts()` and dispatch via the `email`
|
|
@@ -549,6 +595,47 @@ var AgentApiClient = class {
|
|
|
549
595
|
body: JSON.stringify(data)
|
|
550
596
|
});
|
|
551
597
|
}
|
|
598
|
+
/** Update the agent's own name and/or voice config. Returns the updated agent. */
|
|
599
|
+
async updateSelf(update) {
|
|
600
|
+
return this.request("/agent/self", {
|
|
601
|
+
method: "PATCH",
|
|
602
|
+
body: JSON.stringify(update)
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
/**
|
|
606
|
+
* Generate the agent's own avatar from a text prompt. The image is generated,
|
|
607
|
+
* stored, and set on the agent server-side; returns the updated agent.
|
|
608
|
+
*/
|
|
609
|
+
async generateAvatar(args) {
|
|
610
|
+
return this.request("/agent/avatar/generate", {
|
|
611
|
+
method: "POST",
|
|
612
|
+
body: JSON.stringify(args)
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* Get a presigned PUT URL to upload a new avatar image. Upload the bytes to
|
|
617
|
+
* `uploadUrl`, then call `finalizeAvatar(s3Key)` to set it on the agent.
|
|
618
|
+
*/
|
|
619
|
+
async presignAvatar(args) {
|
|
620
|
+
return this.request("/agent/avatar/presign", {
|
|
621
|
+
method: "POST",
|
|
622
|
+
body: JSON.stringify(args)
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* Finalize an avatar upload — validates ownership + size, then sets the
|
|
627
|
+
* agent's `avatarUrl` server-side. Returns the updated agent.
|
|
628
|
+
*/
|
|
629
|
+
async finalizeAvatar(s3Key) {
|
|
630
|
+
return this.request("/agent/avatar", {
|
|
631
|
+
method: "POST",
|
|
632
|
+
body: JSON.stringify({ s3Key })
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
/** List the platform voice catalogue (ElevenLabs) so the agent can pick its own voice. */
|
|
636
|
+
async listVoices() {
|
|
637
|
+
return this.request("/agent/voices");
|
|
638
|
+
}
|
|
552
639
|
/**
|
|
553
640
|
* Mint a fresh AES-256 data key for a specific (secret, field) pair. The
|
|
554
641
|
* encryption context is rebuilt server-side from `auth.tenantId` + the body
|
|
@@ -944,6 +1031,104 @@ var AgentApiClient = class {
|
|
|
944
1031
|
body: JSON.stringify(entry)
|
|
945
1032
|
}).catch(() => {});
|
|
946
1033
|
}
|
|
1034
|
+
async requestBrowserTakeover(args) {
|
|
1035
|
+
return this.request("/agent/remote/takeover", {
|
|
1036
|
+
method: "POST",
|
|
1037
|
+
body: JSON.stringify(args)
|
|
1038
|
+
});
|
|
1039
|
+
}
|
|
1040
|
+
async getRemoteSession(sessionId) {
|
|
1041
|
+
return this.request(`/agent/remote/sessions/${encodeURIComponent(sessionId)}`);
|
|
1042
|
+
}
|
|
1043
|
+
async completeRemoteSession(sessionId) {
|
|
1044
|
+
return this.request(`/agent/remote/sessions/${encodeURIComponent(sessionId)}/complete`, {
|
|
1045
|
+
method: "POST",
|
|
1046
|
+
body: JSON.stringify({})
|
|
1047
|
+
});
|
|
1048
|
+
}
|
|
1049
|
+
/**
|
|
1050
|
+
* Issue a request that returns the raw `Response` (no JSON parsing, no
|
|
1051
|
+
* forced Content-Type). The caller sets `Content-Type`/`Accept` on `headers`
|
|
1052
|
+
* and reads the body itself (`arrayBuffer()` / `json()`).
|
|
1053
|
+
*
|
|
1054
|
+
* A single retry fires only on the same transient statuses `request()`
|
|
1055
|
+
* retries (authorizer-timeout 500 + LB 502/503/504) and transient network
|
|
1056
|
+
* errors — before the route handler runs — so re-issuing a POST does not
|
|
1057
|
+
* risk a duplicate side effect. Voice TTS/STT are effectively idempotent
|
|
1058
|
+
* (re-synthesize / re-transcribe) and meter server-side keyed on the
|
|
1059
|
+
* gateway requestId, so a retried transcription doesn't double-bill.
|
|
1060
|
+
*/
|
|
1061
|
+
async rawFetch(path, init) {
|
|
1062
|
+
const url = `${this.apiUrl}${path}`;
|
|
1063
|
+
init.headers.set("Authorization", `Bearer ${this.apiKey}`);
|
|
1064
|
+
let lastError;
|
|
1065
|
+
for (let attempt = 1; attempt <= 2; attempt++) try {
|
|
1066
|
+
const res = await fetch(url, {
|
|
1067
|
+
method: init.method,
|
|
1068
|
+
headers: init.headers,
|
|
1069
|
+
body: init.body,
|
|
1070
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
1071
|
+
});
|
|
1072
|
+
if (!res.ok) {
|
|
1073
|
+
await res.text();
|
|
1074
|
+
const error = /* @__PURE__ */ new Error(`Agent API request failed (${String(res.status)})`);
|
|
1075
|
+
if (attempt === 1 && RETRYABLE_STATUS.has(res.status)) {
|
|
1076
|
+
lastError = error;
|
|
1077
|
+
await sleep(RETRY_DELAY_MS);
|
|
1078
|
+
continue;
|
|
1079
|
+
}
|
|
1080
|
+
throw error;
|
|
1081
|
+
}
|
|
1082
|
+
return res;
|
|
1083
|
+
} catch (err) {
|
|
1084
|
+
if (attempt === 1 && isRetryableNetworkError(err)) {
|
|
1085
|
+
lastError = err;
|
|
1086
|
+
await sleep(RETRY_DELAY_MS);
|
|
1087
|
+
continue;
|
|
1088
|
+
}
|
|
1089
|
+
throw err;
|
|
1090
|
+
}
|
|
1091
|
+
throw lastError instanceof Error ? lastError : new Error(String(lastError));
|
|
1092
|
+
}
|
|
1093
|
+
/**
|
|
1094
|
+
* Text-to-speech. Returns raw PCM audio bytes plus their framing — the
|
|
1095
|
+
* voice service defaults to 24 kHz / mono / 16-bit. Wrap in a WAV container
|
|
1096
|
+
* to produce a playable file. Metered per character against the tenant
|
|
1097
|
+
* credit pool server-side; TTS completes regardless of metering outcome.
|
|
1098
|
+
*/
|
|
1099
|
+
async tts(args) {
|
|
1100
|
+
const headers = new Headers();
|
|
1101
|
+
headers.set("Content-Type", "application/json");
|
|
1102
|
+
headers.set("Accept", "audio/pcm");
|
|
1103
|
+
const res = await this.rawFetch("/voice/tts", {
|
|
1104
|
+
method: "POST",
|
|
1105
|
+
headers,
|
|
1106
|
+
body: JSON.stringify(args)
|
|
1107
|
+
});
|
|
1108
|
+
return {
|
|
1109
|
+
audio: Buffer.from(await res.arrayBuffer()),
|
|
1110
|
+
sampleRate: parseInt(res.headers.get("x-sample-rate") ?? "24000", 10),
|
|
1111
|
+
channels: parseInt(res.headers.get("x-channels") ?? "1", 10),
|
|
1112
|
+
bitDepth: parseInt(res.headers.get("x-bit-depth") ?? "16", 10)
|
|
1113
|
+
};
|
|
1114
|
+
}
|
|
1115
|
+
/**
|
|
1116
|
+
* Speech-to-text. Accepts raw linear16 (16-bit LE) mono PCM — NOT a WAV or
|
|
1117
|
+
* other container (the endpoint transcribes with a fixed linear16 encoding,
|
|
1118
|
+
* so a container header would be transcribed as noise). Strip any WAV header
|
|
1119
|
+
* and pass `sampleRate` from it before calling. Metered by transcribed
|
|
1120
|
+
* duration against the tenant credit pool server-side.
|
|
1121
|
+
*/
|
|
1122
|
+
async stt(args) {
|
|
1123
|
+
const headers = new Headers();
|
|
1124
|
+
headers.set("Content-Type", "application/octet-stream");
|
|
1125
|
+
headers.set("x-sample-rate", String(args.sampleRate));
|
|
1126
|
+
return (await (await this.rawFetch("/voice/stt", {
|
|
1127
|
+
method: "POST",
|
|
1128
|
+
headers,
|
|
1129
|
+
body: args.audio
|
|
1130
|
+
})).json()).data;
|
|
1131
|
+
}
|
|
947
1132
|
};
|
|
948
1133
|
//#endregion
|
|
949
1134
|
export { AgentApiClient };
|