@pagelines/sdk 1.0.878 → 1.0.880
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 +68 -68
- package/dist/BotProvider.js +777 -0
- package/dist/BotProvider.js.map +1 -0
- package/dist/{AgentWidgetInline.js → BotWidgetInline.js} +8 -8
- package/dist/BotWidgetInline.js.map +1 -0
- package/dist/{AgentWidgetModal.js → BotWidgetModal.js} +7 -7
- package/dist/BotWidgetModal.js.map +1 -0
- package/dist/{AgentWrap.js → BotWrap.js} +1174 -1145
- package/dist/BotWrap.js.map +1 -0
- package/dist/{agent/AgentController.d.ts → bot/BotController.d.ts} +35 -18
- package/dist/bot/index.d.ts +14 -0
- package/dist/{agent → bot}/schema.d.ts +6 -6
- package/dist/{agent/ui/AgentAvatar.vue.d.ts → bot/ui/BotAvatar.vue.d.ts} +6 -6
- package/dist/{agent/ui/AgentChat.vue.d.ts → bot/ui/BotChat.vue.d.ts} +5 -5
- package/dist/{agent/ui/AgentProvider.vue.d.ts → bot/ui/BotProvider.vue.d.ts} +3 -3
- package/dist/{agent/ui/AgentWrap.vue.d.ts → bot/ui/BotWrap.vue.d.ts} +3 -4
- package/dist/{agent/ui/ElAgentAbout.vue.d.ts → bot/ui/ElBotAbout.vue.d.ts} +2 -2
- package/dist/{agent/ui/ElAgentChat.vue.d.ts → bot/ui/ElBotChat.vue.d.ts} +5 -5
- package/dist/{agent/ui/ElAgentChatPreview.vue.d.ts → bot/ui/ElBotChatPreview.vue.d.ts} +1 -1
- package/dist/{agent/ui/ElAgentHeader.vue.d.ts → bot/ui/ElBotHeader.vue.d.ts} +2 -2
- package/dist/{agent/ui/ElAgentModeSidebar.vue.d.ts → bot/ui/ElBotModeSidebar.vue.d.ts} +2 -2
- package/dist/{agent/ui/ElAgentSidebar.vue.d.ts → bot/ui/ElBotSidebar.vue.d.ts} +2 -2
- package/dist/bot/ui/ElCreateBot.vue.d.ts +12 -0
- package/dist/{agent → bot}/ui/ElModeHeader.vue.d.ts +2 -2
- package/dist/{agent → bot}/ui/ElProvisioningStatus.vue.d.ts +1 -1
- package/dist/{agent → bot}/ui/VoiceMode.vue.d.ts +4 -4
- package/dist/{agent → bot}/utils.d.ts +5 -5
- package/dist/{agent → bot}/voice/provider.d.ts +2 -2
- package/dist/{agent → bot}/voice/providers/livekit/provider.d.ts +4 -4
- package/dist/{agent → bot}/voice/voice-session-client.d.ts +1 -1
- package/dist/{agent → bot}/work-journal.d.ts +1 -1
- package/dist/{agent.js → bot.js} +83 -80
- package/dist/bot.js.map +1 -0
- package/dist/clients/BillingClient.d.ts +1 -1
- package/dist/clients/BotClient.d.ts +26 -0
- package/dist/clients/ChatClient.d.ts +6 -5
- package/dist/clients/ComputerClient.d.ts +16 -0
- package/dist/clients/UserClient.d.ts +4 -7
- package/dist/clients/types.d.ts +7 -2
- package/dist/contract/build.d.ts +1 -2
- package/dist/index.d.ts +3 -2
- package/dist/provider.js +1 -1
- package/dist/provider.js.map +1 -1
- package/dist/provider2.js +14 -14
- package/dist/provider2.js.map +1 -1
- package/dist/sdk.css +1 -1
- package/dist/sdk.js +4 -4
- package/dist/sdkClient.d.ts +33 -376
- package/dist/sdkClient.js +168 -170
- package/dist/sdkClient.js.map +1 -1
- package/dist/useWidgetState.js +9 -9
- package/dist/useWidgetState.js.map +1 -1
- package/dist/widget/PLWidget.d.ts +6 -6
- package/dist/widget/composables/useWidgetState.d.ts +3 -402
- package/dist/widget/index.d.ts +2 -2
- package/dist/widget/mode.d.ts +2 -2
- package/dist/widget/ui/{AgentWidgetInline.vue.d.ts → BotWidgetInline.vue.d.ts} +2 -2
- package/dist/widget/ui/{AgentWidgetModal.vue.d.ts → BotWidgetModal.vue.d.ts} +2 -2
- package/dist/widget/ui/{AgentWidgetPopup.vue.d.ts → BotWidgetPopup.vue.d.ts} +4 -4
- package/dist/widget.js +206 -206
- package/dist/widget.js.map +1 -1
- package/package.json +5 -5
- package/dist/AgentProvider.js +0 -764
- package/dist/AgentProvider.js.map +0 -1
- package/dist/AgentWidgetInline.js.map +0 -1
- package/dist/AgentWidgetModal.js.map +0 -1
- package/dist/AgentWrap.js.map +0 -1
- package/dist/agent/index.d.ts +0 -14
- package/dist/agent/ui/ElCreateAgent.vue.d.ts +0 -277
- package/dist/agent.js.map +0 -1
- package/dist/clients/AgentClient.d.ts +0 -48
- /package/dist/{agent → bot}/VoiceRecorderController.d.ts +0 -0
- /package/dist/{agent/ui/AgentInputEmail.vue.d.ts → bot/ui/BotInputEmail.vue.d.ts} +0 -0
- /package/dist/{agent/ui/AgentInputOneTimeCode.vue.d.ts → bot/ui/BotInputOneTimeCode.vue.d.ts} +0 -0
- /package/dist/{agent/ui/AgentSidebarClose.vue.d.ts → bot/ui/BotSidebarClose.vue.d.ts} +0 -0
- /package/dist/{agent/ui/AgentToolActivityGroup.vue.d.ts → bot/ui/BotToolActivityGroup.vue.d.ts} +0 -0
- /package/dist/{agent/ui/AgentWidget.vue.d.ts → bot/ui/BotWidget.vue.d.ts} +0 -0
- /package/dist/{agent → bot}/ui/ChatCardBlock.vue.d.ts +0 -0
- /package/dist/{agent → bot}/ui/ChatRichText.vue.d.ts +0 -0
- /package/dist/{agent → bot}/ui/ChatScroller.vue.d.ts +0 -0
- /package/dist/{agent → bot}/ui/ChatVisualBlock.vue.d.ts +0 -0
- /package/dist/{agent → bot}/ui/ElAuthGate.vue.d.ts +0 -0
- /package/dist/{agent → bot}/ui/ElAuthPanel.vue.d.ts +0 -0
- /package/dist/{agent/ui/ElAgentButton.vue.d.ts → bot/ui/ElBotButton.vue.d.ts} +0 -0
- /package/dist/{agent → bot}/ui/ElSidebar.vue.d.ts +0 -0
- /package/dist/{agent → bot}/ui/VoiceHistogramController.d.ts +0 -0
- /package/dist/{agent → bot}/ui/chat-diagram-layout.d.ts +0 -0
- /package/dist/{agent → bot}/ui/chat-visual-format.d.ts +0 -0
- /package/dist/{agent → bot}/ui/voice-mode-presentation.d.ts +0 -0
- /package/dist/{agent → bot}/voice/voice-error-copy.d.ts +0 -0
- /package/dist/{agent → bot}/voice/voice-work-state.d.ts +0 -0
- /package/dist/widget/ui/{AgentWidgetOnboard.vue.d.ts → BotWidgetOnboard.vue.d.ts} +0 -0
package/dist/contract/build.d.ts
CHANGED
|
@@ -25,8 +25,7 @@ export interface WireContract {
|
|
|
25
25
|
*
|
|
26
26
|
* Schema discovery walks every export of `@pagelines/core`, picks values
|
|
27
27
|
* that are Zod schemas, and derives the contract name from the export
|
|
28
|
-
* name (`
|
|
29
|
-
* `EnrichedAgent`). `*Wire` namespace exports get the same treatment for
|
|
28
|
+
* name (`zComputer` → `Computer`). `*Wire` namespace exports get the same treatment for
|
|
30
29
|
* their immediate children. Anything else is ignored — types, constants
|
|
31
30
|
* like `ERROR_CODES`, helper functions all skip naturally.
|
|
32
31
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { PageLinesSDK } from './sdkClient';
|
|
2
2
|
export { PageLinesSDK };
|
|
3
3
|
export type { PageLinesSDKSettings } from './sdkClient';
|
|
4
|
-
export {
|
|
4
|
+
export { BotClient } from './clients/BotClient';
|
|
5
|
+
export { ComputerClient } from './clients/ComputerClient';
|
|
5
6
|
export { AuthClient } from './clients/AuthClient';
|
|
6
7
|
export { BillingClient } from './clients/BillingClient';
|
|
7
8
|
export { ChatClient } from './clients/ChatClient';
|
|
8
9
|
export { UserClient } from './clients/UserClient';
|
|
9
10
|
export type { SDKContext } from './clients/types';
|
|
10
11
|
export { MediaSchema } from '@pagelines/core';
|
|
11
|
-
export type {
|
|
12
|
+
export type { Bot, User, EnrichedUser, MediaObject, ApiResponse, } from '@pagelines/core';
|
|
12
13
|
export { SOCIAL_PLATFORMS } from './constants/socialPlatforms';
|
|
13
14
|
export type { SocialPlatform } from './constants/socialPlatforms';
|
package/dist/provider.js
CHANGED
package/dist/provider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","names":[],"sources":["../
|
|
1
|
+
{"version":3,"file":"provider.js","names":[],"sources":["../bot/voice/provider.ts"],"sourcesContent":["import type { VoiceSessionMint } from '@pagelines/core'\n\nexport interface VoiceLevelEvent {\n source: 'mic' | 'playback'\n /** Normalized 0..1 signal level. */\n level: number\n /** Speech-spectrum energies, low pitch first. */\n bands?: readonly number[]\n}\n\n/** One speech/noise boundary shared by audible UI state and work-cue ducking. */\nexport function isVoiceAudible(level: number): boolean {\n return level >= 0.08\n}\n\nexport interface VoiceSessionError {\n code: string\n message: string\n}\n\nexport type VoiceDisconnectCause = 'bot' | 'error' | 'network' | 'unknown'\n\n/**\n * Who the transport says is talking. Raw energy is not a speech signal — room\n * tone and the speaker's own playback both read as audible — so ducking,\n * tone, and which meter the surface follows come from here.\n */\nexport interface VoiceSpeakingState {\n user: boolean\n bot: boolean\n}\n\nexport interface VoiceProviderClient {\n connect: (handlers: {\n onDisconnected: (cause: VoiceDisconnectCause) => void\n onError: (error: VoiceSessionError) => void\n onThinkingChange?: (thinking: boolean) => void\n onSpeakingChange?: (state: VoiceSpeakingState) => void\n }) => Promise<void>\n disconnect: () => Promise<void>\n /** Loudest source by default; `prefer` pins a meter while someone is known to be speaking. */\n sampleLevel: (prefer?: VoiceLevelEvent['source']) => VoiceLevelEvent | undefined\n /** Self-mute without ending the live session. */\n setMuted?: (muted: boolean) => Promise<void>\n /**\n * Hand the provider text the caller typed during a live call, as though\n * they had said it — the assistant answers aloud and the turn lands in the\n * transcript through the normal provider path. Optional: a provider that\n * cannot inject text simply omits it and the surface hides the affordance.\n */\n sendUserMessage?: (text: string) => void\n}\n\nexport type CreateVoiceProviderClient = (mint: VoiceSessionMint) => Promise<VoiceProviderClient>\n\n/** Keep the realtime SDK out of the initial chat bundle. */\nexport const createVoiceProviderClient: CreateVoiceProviderClient = async (mint) => {\n const { LiveKitVoiceProvider } = await import('./providers/livekit/provider')\n return new LiveKitVoiceProvider(mint)\n}\n\nexport const VOICE_SPECTRUM_BANDS = 9\n\n/** Log-spaced speech spectrum for transports that expose FFT bins. */\nexport function voiceSpectrum(frequencies: Uint8Array, sampleRate: number, fftSize: number, bandCount = VOICE_SPECTRUM_BANDS): readonly number[] {\n if (!Number.isFinite(sampleRate) || sampleRate <= 0 || !Number.isFinite(fftSize) || fftSize <= 0 || bandCount <= 0)\n return []\n\n const hzPerBin = sampleRate / fftSize\n const fromHz = 80\n const ratio = 4_000 / fromHz\n const bands: number[] = []\n for (let band = 0; band < bandCount; band++) {\n const start = Math.max(0, Math.ceil((fromHz * ratio ** (band / bandCount)) / hzPerBin))\n const end = Math.min(frequencies.length, Math.ceil((fromHz * ratio ** ((band + 1) / bandCount)) / hzPerBin))\n if (end <= start) {\n bands.push(0)\n continue\n }\n let squared = 0\n for (let index = start; index < end; index++)\n squared += (frequencies[index] / 255) ** 2\n bands.push(Math.sqrt(squared / (end - start)))\n }\n return bands\n}\n\n/** Equal-width bands for SDKs that already expose voice-range FFT bins. */\nexport function voiceRangeSpectrum(frequencies: Uint8Array, bandCount = VOICE_SPECTRUM_BANDS): readonly number[] {\n if (!frequencies.length || bandCount <= 0)\n return []\n return Array.from({ length: bandCount }, (_, band) => {\n const start = Math.floor((band * frequencies.length) / bandCount)\n const end = Math.max(start + 1, Math.floor(((band + 1) * frequencies.length) / bandCount))\n let squared = 0\n for (let index = start; index < Math.min(end, frequencies.length); index++)\n squared += (frequencies[index] / 255) ** 2\n return Math.sqrt(squared / Math.max(1, Math.min(end, frequencies.length) - start))\n })\n}\n"],"mappings":";;AAWA,SAAgB,eAAe,GAAwB;CACrD,OAAO,KAAS;AAClB;AA2CA,IAAa,4BAAuD,OAAO,MAAS;CAClF,IAAM,EAAE,4BAAyB,MAAM,OAAO;CAC9C,OAAO,IAAI,EAAqB,CAAI;AACtC;AAKA,SAAgB,cAAc,GAAyB,GAAoB,GAAiB,IAAA,GAAqD;CAC/I,IAAI,CAAC,OAAO,SAAS,CAAU,KAAK,KAAc,KAAK,CAAC,OAAO,SAAS,CAAO,KAAK,KAAW,KAAK,KAAa,GAC/G,OAAO,CAAC;CAEV,IAAM,IAAW,IAAa,GAGxB,IAAkB,CAAC;CACzB,KAAK,IAAI,IAAO,GAAG,IAAO,GAAW,KAAQ;EAC3C,IAAM,IAAQ,KAAK,IAAI,GAAG,KAAK,KAAM,KAAS,OAAU,IAAO,KAAc,CAAQ,CAAC,GAChF,IAAM,KAAK,IAAI,EAAY,QAAQ,KAAK,KAAM,KAAS,QAAW,IAAO,KAAK,KAAc,CAAQ,CAAC;EAC3G,IAAI,KAAO,GAAO;GAChB,EAAM,KAAK,CAAC;GACZ;EACF;EACA,IAAI,IAAU;EACd,KAAK,IAAI,IAAQ,GAAO,IAAQ,GAAK,KACnC,MAAY,EAAY,KAAS,QAAQ;EAC3C,EAAM,KAAK,KAAK,KAAK,KAAW,IAAM,EAAM,CAAC;CAC/C;CACA,OAAO;AACT"}
|
package/dist/provider2.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./rolldown-runtime.js";
|
|
2
|
-
import {
|
|
2
|
+
import { c as e } from "./sdkClient.js";
|
|
3
3
|
import { r as t } from "./provider.js";
|
|
4
4
|
//#region ../../node_modules/.pnpm/livekit-client@2.21.0_@types+dom-mediacapture-record@1.0.22/node_modules/livekit-client/dist/livekit-client.esm.mjs
|
|
5
5
|
function _mergeNamespaces(e, t) {
|
|
@@ -18330,26 +18330,26 @@ var JWSSignatureVerificationFailed = class extends JOSEError {
|
|
|
18330
18330
|
};
|
|
18331
18331
|
_defineProperty(JWSSignatureVerificationFailed, "code", "ERR_JWS_SIGNATURE_VERIFICATION_FAILED");
|
|
18332
18332
|
//#endregion
|
|
18333
|
-
//#region
|
|
18334
|
-
var $a = 1e4, eo = "lk.
|
|
18333
|
+
//#region bot/voice/providers/livekit/provider.ts
|
|
18334
|
+
var $a = 1e4, eo = "lk.bot.state", LiveKitVoiceProvider = class {
|
|
18335
18335
|
constructor(t, n = {}) {
|
|
18336
|
-
e(this, "mint", void 0), e(this, "room", void 0), e(this, "createAnalyser", void 0), e(this, "handlers", void 0), e(this, "cancelReadyWait", void 0), e(this, "analysers", []), e(this, "levelSources", []), e(this, "attachedElements", []), e(this, "closing", !1), e(this, "userSpeaking", !1), e(this, "
|
|
18336
|
+
e(this, "mint", void 0), e(this, "room", void 0), e(this, "createAnalyser", void 0), e(this, "handlers", void 0), e(this, "cancelReadyWait", void 0), e(this, "analysers", []), e(this, "levelSources", []), e(this, "attachedElements", []), e(this, "closing", !1), e(this, "userSpeaking", !1), e(this, "botActiveSpeaker", !1), e(this, "botStateSpeaking", !1), e(this, "lastSpeaking", void 0), this.mint = t, this.room = n.createRoom?.() ?? new Za(), this.createAnalyser = n.createAnalyser;
|
|
18337
18337
|
}
|
|
18338
18338
|
async connect(e) {
|
|
18339
18339
|
this.handlers = e, this.room.on(P.TrackSubscribed, (e) => {
|
|
18340
18340
|
e.kind === z.Kind.Audio && this.attachRemoteAudio(e);
|
|
18341
18341
|
}), this.room.on(P.ParticipantAttributesChanged, (e, t) => {
|
|
18342
|
-
if (!t.
|
|
18342
|
+
if (!t.isBot) return;
|
|
18343
18343
|
let n = t.attributes[eo];
|
|
18344
|
-
this.handlers?.onThinkingChange?.(n === "thinking"), this.
|
|
18344
|
+
this.handlers?.onThinkingChange?.(n === "thinking"), this.botStateSpeaking = n === "speaking", this.publishSpeaking();
|
|
18345
18345
|
}), this.room.on(P.ActiveSpeakersChanged, (e) => {
|
|
18346
|
-
this.userSpeaking = e.some((e) => e.isLocal), this.
|
|
18346
|
+
this.userSpeaking = e.some((e) => e.isLocal), this.botActiveSpeaker = e.some((e) => e.isBot), this.publishSpeaking();
|
|
18347
18347
|
}), this.room.on(P.Disconnected, (e) => {
|
|
18348
18348
|
this.closing || this.handlers?.onDisconnected(disconnectCause(e));
|
|
18349
18349
|
});
|
|
18350
18350
|
let t = "VOICE_CONNECT_FAILED";
|
|
18351
18351
|
try {
|
|
18352
|
-
if (await this.room.connect(this.mint.url, this.mint.token), this.closing || (t = "VOICE_MIC_UNAVAILABLE", await this.setMuted(!1), this.closing) || (t = "
|
|
18352
|
+
if (await this.room.connect(this.mint.url, this.mint.token), this.closing || (t = "VOICE_MIC_UNAVAILABLE", await this.setMuted(!1), this.closing) || (t = "VOICE_BOT_UNAVAILABLE", await this.waitForBotReady(), this.closing)) return;
|
|
18353
18353
|
t = "VOICE_PLAYBACK_UNAVAILABLE", await this.room.startAudio();
|
|
18354
18354
|
} catch (e) {
|
|
18355
18355
|
let n = e instanceof Error ? e : /* @__PURE__ */ Error("Could not open the voice connection.");
|
|
@@ -18393,14 +18393,14 @@ var $a = 1e4, eo = "lk.agent.state", LiveKitVoiceProvider = class {
|
|
|
18393
18393
|
publishSpeaking() {
|
|
18394
18394
|
let e = {
|
|
18395
18395
|
user: this.userSpeaking,
|
|
18396
|
-
|
|
18396
|
+
bot: this.botActiveSpeaker || this.botStateSpeaking
|
|
18397
18397
|
};
|
|
18398
|
-
this.lastSpeaking?.user === e.user && this.lastSpeaking?.
|
|
18398
|
+
this.lastSpeaking?.user === e.user && this.lastSpeaking?.bot === e.bot || (this.lastSpeaking = e, this.handlers?.onSpeakingChange?.(e));
|
|
18399
18399
|
}
|
|
18400
|
-
async
|
|
18400
|
+
async waitForBotReady() {
|
|
18401
18401
|
let ready = (e) => {
|
|
18402
18402
|
let t = e.attributes[eo];
|
|
18403
|
-
return e.
|
|
18403
|
+
return e.isBot && (t === "listening" || t === "thinking" || t === "speaking");
|
|
18404
18404
|
};
|
|
18405
18405
|
[...this.room.remoteParticipants.values()].some(ready) || await new Promise((e, t) => {
|
|
18406
18406
|
let n = !1, finish = (i) => {
|
|
@@ -18409,7 +18409,7 @@ var $a = 1e4, eo = "lk.agent.state", LiveKitVoiceProvider = class {
|
|
|
18409
18409
|
ready(e) && finish();
|
|
18410
18410
|
}, onAttributes = (e, t) => {
|
|
18411
18411
|
ready(t) && finish();
|
|
18412
|
-
}, r = setTimeout(() => finish(Object.assign(/* @__PURE__ */ Error("The voice assistant did not become ready."), { code: "
|
|
18412
|
+
}, r = setTimeout(() => finish(Object.assign(/* @__PURE__ */ Error("The voice assistant did not become ready."), { code: "VOICE_BOT_UNAVAILABLE" })), $a);
|
|
18413
18413
|
this.room.on(P.ParticipantConnected, onParticipant), this.room.on(P.ParticipantAttributesChanged, onAttributes), this.cancelReadyWait = () => finish();
|
|
18414
18414
|
});
|
|
18415
18415
|
}
|
|
@@ -18453,7 +18453,7 @@ var $a = 1e4, eo = "lk.agent.state", LiveKitVoiceProvider = class {
|
|
|
18453
18453
|
}
|
|
18454
18454
|
};
|
|
18455
18455
|
function disconnectCause(e) {
|
|
18456
|
-
return e === S.ROOM_DELETED || e === S.PARTICIPANT_REMOVED ? "
|
|
18456
|
+
return e === S.ROOM_DELETED || e === S.PARTICIPANT_REMOVED ? "bot" : e === void 0 || e === S.UNKNOWN_REASON ? "unknown" : "network";
|
|
18457
18457
|
}
|
|
18458
18458
|
//#endregion
|
|
18459
18459
|
export { LiveKitVoiceProvider };
|