@nextpa/chat-core 0.1.0 → 0.1.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 +27 -4
- package/dist/constants/defaults.d.ts +1 -1
- package/dist/core/chat-manager.d.ts +2 -2
- package/dist/core/chat-manager.js +1 -1
- package/dist/core/config-manager.d.ts +2 -2
- package/dist/core/config-manager.js +2 -2
- package/dist/core/connection-manager.d.ts +4 -4
- package/dist/core/connection-manager.js +7 -7
- package/dist/core/connection-retry-handler.js +1 -1
- package/dist/core/consent-manager.d.ts +1 -1
- package/dist/core/consent-manager.js +2 -2
- package/dist/core/conversation-persistence.d.ts +3 -3
- package/dist/core/conversation-persistence.js +3 -3
- package/dist/core/event-emitter.js +1 -1
- package/dist/core/index.d.ts +9 -9
- package/dist/core/index.js +7 -7
- package/dist/core/local-storage-persistence.d.ts +1 -1
- package/dist/core/local-storage-persistence.js +1 -1
- package/dist/core/navigation-manager.d.ts +1 -1
- package/dist/core/navigation-manager.js +3 -3
- package/dist/core/popover-manager.d.ts +1 -1
- package/dist/core/session-beacon.js +1 -1
- package/dist/core/text-connection-manager.d.ts +4 -4
- package/dist/core/text-connection-manager.js +5 -5
- package/dist/core/text-mode-manager.d.ts +7 -7
- package/dist/core/text-mode-manager.js +4 -4
- package/dist/core/text-types.d.ts +2 -2
- package/dist/core/text-widget-controller.d.ts +4 -4
- package/dist/core/text-widget-controller.js +9 -9
- package/dist/core/theme-manager.d.ts +1 -1
- package/dist/core/theme-manager.js +2 -2
- package/dist/core/types.d.ts +3 -3
- package/dist/core/voice-state-manager.d.ts +5 -5
- package/dist/core/voice-state-manager.js +3 -3
- package/dist/core/widget-controller.d.ts +3 -3
- package/dist/core/widget-controller.js +13 -13
- package/dist/core/widget-core.d.ts +11 -11
- package/dist/core/widget-core.js +9 -9
- package/dist/google.js +3 -3
- package/dist/index.d.ts +25 -25
- package/dist/index.js +22 -22
- package/dist/openai.js +2 -2
- package/dist/services/api.d.ts +1 -1
- package/dist/services/api.js +2 -2
- package/dist/services/index.d.ts +3 -3
- package/dist/services/index.js +3 -3
- package/dist/services/page-interaction/content-extractor.d.ts +1 -1
- package/dist/services/page-interaction/content-extractor.js +1 -1
- package/dist/services/page-interaction/dom-executor.d.ts +1 -1
- package/dist/services/page-interaction/dom-executor.js +1 -1
- package/dist/services/page-interaction/dom-extractor.d.ts +1 -1
- package/dist/services/page-interaction/dom-extractor.js +2 -2
- package/dist/services/page-interaction/extension-bridge.d.ts +1 -1
- package/dist/services/page-interaction/iframe-navigation-manager.js +2 -2
- package/dist/services/page-interaction/index.d.ts +5 -5
- package/dist/services/page-interaction/index.js +4 -4
- package/dist/services/page-interaction/page-interaction-handler.d.ts +1 -1
- package/dist/services/page-interaction/page-interaction-handler.js +4 -4
- package/dist/services/realtime/google/google-audio.js +1 -1
- package/dist/services/realtime/google/google-provider.d.ts +1 -1
- package/dist/services/realtime/google/google-provider.js +3 -3
- package/dist/services/realtime/google/google-tool-mapper.d.ts +1 -1
- package/dist/services/realtime/google/index.d.ts +1 -1
- package/dist/services/realtime/google/index.js +1 -1
- package/dist/services/realtime/openai/index.d.ts +1 -1
- package/dist/services/realtime/openai/index.js +1 -1
- package/dist/services/realtime/openai/openai-provider.d.ts +1 -1
- package/dist/services/realtime/openai/openai-provider.js +3 -3
- package/dist/services/realtime/openai/openai-tool-mapper.d.ts +1 -1
- package/dist/services/realtime/provider-factory.d.ts +1 -1
- package/dist/services/realtime/types.d.ts +1 -1
- package/dist/services/realtime/vertexai/index.d.ts +1 -1
- package/dist/services/realtime/vertexai/index.js +1 -1
- package/dist/services/realtime/vertexai/vertexai-provider.d.ts +1 -1
- package/dist/services/realtime/vertexai/vertexai-provider.js +3 -3
- package/dist/services/realtime/voice-session-tracker.d.ts +1 -1
- package/dist/services/realtime/voice-session-tracker.js +1 -1
- package/dist/services/signalr.js +1 -1
- package/dist/services/voice-health-watchdog.d.ts +1 -1
- package/dist/services/voice-health-watchdog.js +1 -1
- package/dist/services/webrtc-event-handler.d.ts +3 -3
- package/dist/services/webrtc-greeting.d.ts +2 -2
- package/dist/services/webrtc-greeting.js +1 -1
- package/dist/services/webrtc-microphone.d.ts +1 -1
- package/dist/services/webrtc-microphone.js +1 -1
- package/dist/services/webrtc.d.ts +2 -2
- package/dist/services/webrtc.js +6 -6
- package/dist/utils/connect-chime.js +2 -2
- package/dist/utils/language-detection.js +1 -1
- package/dist/utils/styles.d.ts +1 -1
- package/dist/utils/theme-detection.js +1 -1
- package/dist/utils/ui-sounds.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -46,8 +46,31 @@ runs via side-effect modules and would be tree-shaken away
|
|
|
46
46
|
|
|
47
47
|
## Targets
|
|
48
48
|
|
|
49
|
-
- `nx test chat-core` — unit tests (Vitest)
|
|
49
|
+
- `nx test chat-core` — unit tests (Vitest); builds first, because one of them
|
|
50
|
+
loads the built package the way a consumer outside this workspace does
|
|
50
51
|
- `nx run chat-core:typecheck` — `tsc --noEmit`
|
|
51
|
-
- `nx run chat-core:build` — emits ESM + `.d.ts` to `dist
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
- `nx run chat-core:build` — emits ESM + `.d.ts` to `dist/`, where the `exports`
|
|
53
|
+
map points, and then resolves every emitted relative specifier to a file
|
|
54
|
+
|
|
55
|
+
## How it is consumed, and why the build has a second step
|
|
56
|
+
|
|
57
|
+
Inside this workspace the widget and the extension reach the **sources** through
|
|
58
|
+
a tsconfig path alias and a Vite alias, so a change needs no release to be seen.
|
|
59
|
+
Everything outside it resolves the **published package** from npmjs.com.
|
|
60
|
+
|
|
61
|
+
Those two paths do not accept the same import specifiers. `tsc` emits relative
|
|
62
|
+
specifiers exactly as the sources write them, and with classic node module
|
|
63
|
+
resolution the sources may leave off the extension and name a directory
|
|
64
|
+
(`./core`). A bundler resolves both; Node's ESM loader resolves neither, so the
|
|
65
|
+
emitted artifact would throw `Directory import … is not supported` on the first
|
|
66
|
+
`import` from any consumer that is not bundling. The second build step rewrites
|
|
67
|
+
those specifiers in `dist/` to name a file (`./core/index.js`), which every
|
|
68
|
+
consumer accepts. The sources are left alone, so nothing about how the widget and
|
|
69
|
+
the extension build changes.
|
|
70
|
+
|
|
71
|
+
`tests/published-package.test.ts` is the guard: it loads every entry point the
|
|
72
|
+
`exports` map offers in a real Node process. A specifier the step cannot resolve
|
|
73
|
+
fails the build instead of shipping.
|
|
74
|
+
|
|
75
|
+
Releasing is a git tag — see `.claude/docs/scripts.md`, *Chat-Core Package
|
|
76
|
+
Release*.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { WidgetConfig, WidgetDesignTokens } from '../types';
|
|
1
|
+
import type { WidgetConfig, WidgetDesignTokens } from '../types/index.js';
|
|
2
2
|
export declare const DEFAULT_DESIGN_TOKENS: WidgetDesignTokens;
|
|
3
3
|
export declare const DEFAULT_LOGO_DATA_URL: string;
|
|
4
4
|
export declare let isDemoMode: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ChatMessage, FeedbackRating } from '../types';
|
|
2
|
-
import { EventEmitter } from './event-emitter';
|
|
1
|
+
import type { ChatMessage, FeedbackRating } from '../types/index.js';
|
|
2
|
+
import { EventEmitter } from './event-emitter.js';
|
|
3
3
|
interface ChatEvents {
|
|
4
4
|
messageAdded: (message: ChatMessage) => void;
|
|
5
5
|
messagesCleared: () => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { WidgetConfig } from '../types';
|
|
2
|
-
import type { WidgetApiClient } from '../services/api';
|
|
1
|
+
import type { WidgetConfig } from '../types/index.js';
|
|
2
|
+
import type { WidgetApiClient } from '../services/api.js';
|
|
3
3
|
export declare class ConfigManager {
|
|
4
4
|
private config;
|
|
5
5
|
private readonly apiClient;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getDemoConfig, isDemoMode } from '../constants/defaults';
|
|
2
|
-
import { logger } from '../utils/logger';
|
|
1
|
+
import { getDemoConfig, isDemoMode } from '../constants/defaults.js';
|
|
2
|
+
import { logger } from '../utils/logger.js';
|
|
3
3
|
export class ConfigManager {
|
|
4
4
|
config = null;
|
|
5
5
|
apiClient;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ConnectionState, FunctionCall, VoiceUsage, WidgetConfig } from '../types';
|
|
2
|
-
import type { WidgetApiClient } from '../services/api';
|
|
3
|
-
import type { DocumentProvider, WindowProvider, ExternalExecutor } from '../services/page-interaction/page-interaction-handler';
|
|
4
|
-
import { EventEmitter } from './event-emitter';
|
|
1
|
+
import type { ConnectionState, FunctionCall, VoiceUsage, WidgetConfig } from '../types/index.js';
|
|
2
|
+
import type { WidgetApiClient } from '../services/api.js';
|
|
3
|
+
import type { DocumentProvider, WindowProvider, ExternalExecutor } from '../services/page-interaction/page-interaction-handler.js';
|
|
4
|
+
import { EventEmitter } from './event-emitter.js';
|
|
5
5
|
interface ConnectionEvents {
|
|
6
6
|
connectionStateChanged: (state: ConnectionState) => void;
|
|
7
7
|
unexpectedDisconnect: () => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { VoiceSessionTracker } from '../services/realtime/voice-session-tracker';
|
|
2
|
-
import { isDemoMode } from '../constants/defaults';
|
|
3
|
-
import { logger } from '../utils/logger';
|
|
4
|
-
import { EventEmitter } from './event-emitter';
|
|
1
|
+
import { VoiceSessionTracker } from '../services/realtime/voice-session-tracker.js';
|
|
2
|
+
import { isDemoMode } from '../constants/defaults.js';
|
|
3
|
+
import { logger } from '../utils/logger.js';
|
|
4
|
+
import { EventEmitter } from './event-emitter.js';
|
|
5
5
|
const MIN_TRANSCRIPT_LENGTH = 2;
|
|
6
6
|
const DEMO_CONNECTION_DELAY_MS = 500;
|
|
7
7
|
export class ConnectionManager extends EventEmitter {
|
|
@@ -26,8 +26,8 @@ export class ConnectionManager extends EventEmitter {
|
|
|
26
26
|
}
|
|
27
27
|
logger.debug('[ConnectionManager] Lazy loading WebRTC and SignalR services...');
|
|
28
28
|
const [{ WebRtcService }, { SignalRService }] = await Promise.all([
|
|
29
|
-
import('../services/webrtc'),
|
|
30
|
-
import('../services/signalr'),
|
|
29
|
+
import('../services/webrtc.js'),
|
|
30
|
+
import('../services/signalr.js'),
|
|
31
31
|
]);
|
|
32
32
|
this.webrtcService = new WebRtcService();
|
|
33
33
|
this.signalRService = new SignalRService();
|
|
@@ -157,7 +157,7 @@ export class ConnectionManager extends EventEmitter {
|
|
|
157
157
|
async setupSignalRAndPageInteraction(signalR, bearerToken) {
|
|
158
158
|
const claims = this.apiClient.getTokenClaims();
|
|
159
159
|
signalR.setRegistrationInfo(this.apiClient.getClientId(), claims.tenantId ?? '00000000-0000-0000-0000-000000000000', claims.userId ?? '00000000-0000-0000-0000-000000000000');
|
|
160
|
-
const { PageInteractionHandler } = await import('../services/page-interaction/page-interaction-handler');
|
|
160
|
+
const { PageInteractionHandler } = await import('../services/page-interaction/page-interaction-handler.js');
|
|
161
161
|
this.pageInteractionHandler = new PageInteractionHandler(() => signalR.getConnection() ?? null);
|
|
162
162
|
if (this.pendingExternalExecutor) {
|
|
163
163
|
this.pageInteractionHandler.setExternalExecutor(this.pendingExternalExecutor);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { hasUserConsented, setUserConsent } from '../utils/consent';
|
|
2
|
-
import { logger } from '../utils/logger';
|
|
1
|
+
import { hasUserConsented, setUserConsent } from '../utils/consent.js';
|
|
2
|
+
import { logger } from '../utils/logger.js';
|
|
3
3
|
export class ConsentManager {
|
|
4
4
|
_hasConsented = false;
|
|
5
5
|
_showTermsModal = false;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { VoiceUsage } from '../types';
|
|
2
|
-
import type { WidgetApiClient } from '../services/api';
|
|
3
|
-
import type { ChatManager } from './chat-manager';
|
|
1
|
+
import type { VoiceUsage } from '../types/index.js';
|
|
2
|
+
import type { WidgetApiClient } from '../services/api.js';
|
|
3
|
+
import type { ChatManager } from './chat-manager.js';
|
|
4
4
|
export declare class ConversationPersistence {
|
|
5
5
|
private readonly apiClient;
|
|
6
6
|
private readonly logPrefix;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { isDemoMode } from '../constants/defaults';
|
|
2
|
-
import { logger } from '../utils/logger';
|
|
3
|
-
import { LocalStoragePersistence } from './local-storage-persistence';
|
|
1
|
+
import { isDemoMode } from '../constants/defaults.js';
|
|
2
|
+
import { logger } from '../utils/logger.js';
|
|
3
|
+
import { LocalStoragePersistence } from './local-storage-persistence.js';
|
|
4
4
|
export class ConversationPersistence {
|
|
5
5
|
apiClient;
|
|
6
6
|
logPrefix;
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { WidgetController } from './widget-controller';
|
|
2
|
-
export { TextWidgetController } from './text-widget-controller';
|
|
3
|
-
export { ConfigManager } from './config-manager';
|
|
4
|
-
export { ChatManager } from './chat-manager';
|
|
5
|
-
export { ConnectionManager } from './connection-manager';
|
|
6
|
-
export { TextConnectionManager } from './text-connection-manager';
|
|
7
|
-
export { EventEmitter } from './event-emitter';
|
|
8
|
-
export type { WidgetState, WidgetControllerOptions, WidgetEvents } from './types';
|
|
9
|
-
export type { TextWidgetState } from './text-types';
|
|
1
|
+
export { WidgetController } from './widget-controller.js';
|
|
2
|
+
export { TextWidgetController } from './text-widget-controller.js';
|
|
3
|
+
export { ConfigManager } from './config-manager.js';
|
|
4
|
+
export { ChatManager } from './chat-manager.js';
|
|
5
|
+
export { ConnectionManager } from './connection-manager.js';
|
|
6
|
+
export { TextConnectionManager } from './text-connection-manager.js';
|
|
7
|
+
export { EventEmitter } from './event-emitter.js';
|
|
8
|
+
export type { WidgetState, WidgetControllerOptions, WidgetEvents } from './types.js';
|
|
9
|
+
export type { TextWidgetState } from './text-types.js';
|
package/dist/core/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { WidgetController } from './widget-controller';
|
|
2
|
-
export { TextWidgetController } from './text-widget-controller';
|
|
3
|
-
export { ConfigManager } from './config-manager';
|
|
4
|
-
export { ChatManager } from './chat-manager';
|
|
5
|
-
export { ConnectionManager } from './connection-manager';
|
|
6
|
-
export { TextConnectionManager } from './text-connection-manager';
|
|
7
|
-
export { EventEmitter } from './event-emitter';
|
|
1
|
+
export { WidgetController } from './widget-controller.js';
|
|
2
|
+
export { TextWidgetController } from './text-widget-controller.js';
|
|
3
|
+
export { ConfigManager } from './config-manager.js';
|
|
4
|
+
export { ChatManager } from './chat-manager.js';
|
|
5
|
+
export { ConnectionManager } from './connection-manager.js';
|
|
6
|
+
export { TextConnectionManager } from './text-connection-manager.js';
|
|
7
|
+
export { EventEmitter } from './event-emitter.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DocumentProvider, WindowProvider } from '../services/page-interaction/page-interaction-handler';
|
|
1
|
+
import type { DocumentProvider, WindowProvider } from '../services/page-interaction/page-interaction-handler.js';
|
|
2
2
|
type StateChangeCallback = () => void;
|
|
3
3
|
type DocumentProviderCallback = (getDoc: DocumentProvider, getWin: WindowProvider) => void;
|
|
4
4
|
export declare class NavigationManager {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { logger } from '../utils/logger';
|
|
2
|
-
import { IframeNavigationManager } from '../services/page-interaction/iframe-navigation-manager';
|
|
3
|
-
import { resolveSameOriginTarget } from '../core/link-target';
|
|
1
|
+
import { logger } from '../utils/logger.js';
|
|
2
|
+
import { IframeNavigationManager } from '../services/page-interaction/iframe-navigation-manager.js';
|
|
3
|
+
import { resolveSameOriginTarget } from '../core/link-target.js';
|
|
4
4
|
const RECONNECT_MAX_AGE_MS = 30_000;
|
|
5
5
|
const RECONNECT_STORAGE_KEY = 'nextpa-widget-reconnect';
|
|
6
6
|
export class NavigationManager {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ConnectionState } from '../types';
|
|
2
|
-
import type { WidgetApiClient } from '../services/api';
|
|
3
|
-
import { type DocumentProvider, type WindowProvider, type ExternalExecutor } from '../services/page-interaction/page-interaction-handler';
|
|
4
|
-
import { EventEmitter } from './event-emitter';
|
|
1
|
+
import type { ConnectionState } from '../types/index.js';
|
|
2
|
+
import type { WidgetApiClient } from '../services/api.js';
|
|
3
|
+
import { type DocumentProvider, type WindowProvider, type ExternalExecutor } from '../services/page-interaction/page-interaction-handler.js';
|
|
4
|
+
import { EventEmitter } from './event-emitter.js';
|
|
5
5
|
interface TextStreamDelta {
|
|
6
6
|
readonly delta: string;
|
|
7
7
|
readonly messageId: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { PageInteractionHandler } from '../services/page-interaction/page-interaction-handler';
|
|
2
|
-
import { isDemoMode } from '../constants/defaults';
|
|
3
|
-
import { logger } from '../utils/logger';
|
|
4
|
-
import { EventEmitter } from './event-emitter';
|
|
1
|
+
import { PageInteractionHandler } from '../services/page-interaction/page-interaction-handler.js';
|
|
2
|
+
import { isDemoMode } from '../constants/defaults.js';
|
|
3
|
+
import { logger } from '../utils/logger.js';
|
|
4
|
+
import { EventEmitter } from './event-emitter.js';
|
|
5
5
|
const DEMO_CONNECTION_DELAY_MS = 300;
|
|
6
6
|
// Safety cap: if a greeting never streams (error / no response), release held user messages anyway.
|
|
7
7
|
const GREETING_HOLD_TIMEOUT_MS = 15_000;
|
|
@@ -27,7 +27,7 @@ export class TextConnectionManager extends EventEmitter {
|
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
29
|
logger.debug('[TextConnectionManager] Lazy loading SignalR service...');
|
|
30
|
-
const { SignalRService } = await import('../services/signalr');
|
|
30
|
+
const { SignalRService } = await import('../services/signalr.js');
|
|
31
31
|
this.signalRService = new SignalRService();
|
|
32
32
|
this.setupEventHandlers();
|
|
33
33
|
this.serviceInitialized = true;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { WidgetApiClient } from '../services/api';
|
|
2
|
-
import type { ConnectionState } from '../types';
|
|
3
|
-
import type { DocumentProvider, WindowProvider, ExternalExecutor } from '../services/page-interaction/page-interaction-handler';
|
|
4
|
-
import type { TextConnectionManager } from './text-connection-manager';
|
|
5
|
-
import type { ChatManager } from './chat-manager';
|
|
6
|
-
import type { ConversationPersistence } from './conversation-persistence';
|
|
7
|
-
import type { NavigationManager } from './navigation-manager';
|
|
1
|
+
import type { WidgetApiClient } from '../services/api.js';
|
|
2
|
+
import type { ConnectionState } from '../types/index.js';
|
|
3
|
+
import type { DocumentProvider, WindowProvider, ExternalExecutor } from '../services/page-interaction/page-interaction-handler.js';
|
|
4
|
+
import type { TextConnectionManager } from './text-connection-manager.js';
|
|
5
|
+
import type { ChatManager } from './chat-manager.js';
|
|
6
|
+
import type { ConversationPersistence } from './conversation-persistence.js';
|
|
7
|
+
import type { NavigationManager } from './navigation-manager.js';
|
|
8
8
|
type StateChangeCallback = () => void;
|
|
9
9
|
type TextEventDeps = {
|
|
10
10
|
chatManager: ChatManager;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { logger } from '../utils/logger';
|
|
2
|
-
import { resolveToolCallState } from '../utils/tool-status';
|
|
3
|
-
import { GreetingGate } from './greeting-gate';
|
|
1
|
+
import { logger } from '../utils/logger.js';
|
|
2
|
+
import { resolveToolCallState } from '../utils/tool-status.js';
|
|
3
|
+
import { GreetingGate } from './greeting-gate.js';
|
|
4
4
|
export class TextModeManager {
|
|
5
5
|
isStreaming = false;
|
|
6
6
|
streamContent = '';
|
|
@@ -31,7 +31,7 @@ export class TextModeManager {
|
|
|
31
31
|
async ensureConnection() {
|
|
32
32
|
if (this.connectionManager)
|
|
33
33
|
return this.connectionManager;
|
|
34
|
-
const { TextConnectionManager: TextConnMgr } = await import('./text-connection-manager');
|
|
34
|
+
const { TextConnectionManager: TextConnMgr } = await import('./text-connection-manager.js');
|
|
35
35
|
this.connectionManager = new TextConnMgr(this.apiClient);
|
|
36
36
|
if (this.pendingExternalExecutor) {
|
|
37
37
|
this.connectionManager.setExternalExecutor(this.pendingExternalExecutor);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ChatMessage, ConnectionState, WidgetConfig } from '../types';
|
|
2
|
-
import type { ResolvedTheme } from '../utils/theme-detection';
|
|
1
|
+
import type { ChatMessage, ConnectionState, WidgetConfig } from '../types/index.js';
|
|
2
|
+
import type { ResolvedTheme } from '../utils/theme-detection.js';
|
|
3
3
|
export interface TextWidgetState {
|
|
4
4
|
config: WidgetConfig | null;
|
|
5
5
|
resolvedTheme: ResolvedTheme;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { EventEmitter } from './event-emitter';
|
|
2
|
-
import type { WidgetControllerOptions } from './types';
|
|
3
|
-
import type { ConnectOptions } from '../types';
|
|
4
|
-
import type { TextWidgetState } from './text-types';
|
|
1
|
+
import { EventEmitter } from './event-emitter.js';
|
|
2
|
+
import type { WidgetControllerOptions } from './types.js';
|
|
3
|
+
import type { ConnectOptions } from '../types/index.js';
|
|
4
|
+
import type { TextWidgetState } from './text-types.js';
|
|
5
5
|
interface TextWidgetControllerEvents {
|
|
6
6
|
stateChanged: (state: TextWidgetState) => void;
|
|
7
7
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { isDemoMode } from '../constants/defaults';
|
|
2
|
-
import { logger } from '../utils/logger';
|
|
3
|
-
import { resolveToolCallState } from '../utils/tool-status';
|
|
4
|
-
import { initExtensionBridge, refreshExtensionContext } from '../services/page-interaction/extension-bridge';
|
|
5
|
-
import { TextConnectionManager } from './text-connection-manager';
|
|
6
|
-
import { EventEmitter } from './event-emitter';
|
|
7
|
-
import { SessionBeacon } from './session-beacon';
|
|
8
|
-
import { WidgetCore } from './widget-core';
|
|
9
|
-
import { GreetingGate } from './greeting-gate';
|
|
1
|
+
import { isDemoMode } from '../constants/defaults.js';
|
|
2
|
+
import { logger } from '../utils/logger.js';
|
|
3
|
+
import { resolveToolCallState } from '../utils/tool-status.js';
|
|
4
|
+
import { initExtensionBridge, refreshExtensionContext } from '../services/page-interaction/extension-bridge.js';
|
|
5
|
+
import { TextConnectionManager } from './text-connection-manager.js';
|
|
6
|
+
import { EventEmitter } from './event-emitter.js';
|
|
7
|
+
import { SessionBeacon } from './session-beacon.js';
|
|
8
|
+
import { WidgetCore } from './widget-core.js';
|
|
9
|
+
import { GreetingGate } from './greeting-gate.js';
|
|
10
10
|
const LOG_PREFIX = '[TextWidgetController]';
|
|
11
11
|
const DEMO_MESSAGE_DELAY_MS = 1000;
|
|
12
12
|
export class TextWidgetController extends EventEmitter {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { detectHostTheme, observeThemeChanges } from '../utils/theme-detection';
|
|
2
|
-
import { logger } from '../utils/logger';
|
|
1
|
+
import { detectHostTheme, observeThemeChanges } from '../utils/theme-detection.js';
|
|
2
|
+
import { logger } from '../utils/logger.js';
|
|
3
3
|
export class ThemeManager {
|
|
4
4
|
_resolvedTheme = 'dark';
|
|
5
5
|
observerCleanup = null;
|
package/dist/core/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ChatMessage, ConnectionState, WidgetConfig } from '../types';
|
|
2
|
-
import type { ResolvedTheme } from '../utils/theme-detection';
|
|
3
|
-
import type { WidgetApiClient, WidgetTokenProvider } from '../services/api';
|
|
1
|
+
import type { ChatMessage, ConnectionState, WidgetConfig } from '../types/index.js';
|
|
2
|
+
import type { ResolvedTheme } from '../utils/theme-detection.js';
|
|
3
|
+
import type { WidgetApiClient, WidgetTokenProvider } from '../services/api.js';
|
|
4
4
|
export type ChatMode = 'voice' | 'text';
|
|
5
5
|
export interface WidgetState {
|
|
6
6
|
config: WidgetConfig | null;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { WidgetApiClient } from '../services/api';
|
|
2
|
-
import type { ConnectionManager } from './connection-manager';
|
|
3
|
-
import type { ChatManager } from './chat-manager';
|
|
4
|
-
import type { ConversationPersistence } from './conversation-persistence';
|
|
5
|
-
import type { NavigationManager } from './navigation-manager';
|
|
1
|
+
import type { WidgetApiClient } from '../services/api.js';
|
|
2
|
+
import type { ConnectionManager } from './connection-manager.js';
|
|
3
|
+
import type { ChatManager } from './chat-manager.js';
|
|
4
|
+
import type { ConversationPersistence } from './conversation-persistence.js';
|
|
5
|
+
import type { NavigationManager } from './navigation-manager.js';
|
|
6
6
|
type StateChangeCallback = () => void;
|
|
7
7
|
type VoiceEventDeps = {
|
|
8
8
|
connectionManager: ConnectionManager;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { logger } from '../utils/logger';
|
|
2
|
-
import { getToolStatusLabel, getSynthesizingStatus, resolveToolCallState } from '../utils/tool-status';
|
|
3
|
-
import { startThinkingAudio, stopThinkingAudio } from '../services/thinking-audio-pulse';
|
|
1
|
+
import { logger } from '../utils/logger.js';
|
|
2
|
+
import { getToolStatusLabel, getSynthesizingStatus, resolveToolCallState } from '../utils/tool-status.js';
|
|
3
|
+
import { startThinkingAudio, stopThinkingAudio } from '../services/thinking-audio-pulse.js';
|
|
4
4
|
const STOP_CONVERSATION_TIMEOUT_MS = 30_000;
|
|
5
5
|
export class VoiceStateManager {
|
|
6
6
|
isUserSpeaking = false;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { EventEmitter } from './event-emitter';
|
|
2
|
-
import type { WidgetState, WidgetControllerOptions } from './types';
|
|
3
|
-
import type { ConnectOptions } from '../types';
|
|
1
|
+
import { EventEmitter } from './event-emitter.js';
|
|
2
|
+
import type { WidgetState, WidgetControllerOptions } from './types.js';
|
|
3
|
+
import type { ConnectOptions } from '../types/index.js';
|
|
4
4
|
interface WidgetControllerEvents {
|
|
5
5
|
stateChanged: (state: WidgetState) => void;
|
|
6
6
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { isDemoMode } from '../constants/defaults';
|
|
2
|
-
import { logger } from '../utils/logger';
|
|
3
|
-
import { primeAudioOnGesture } from '../utils/audio-context';
|
|
4
|
-
import { playConnectChime } from '../utils/connect-chime';
|
|
5
|
-
import { playEndCallSound, playMuteSound, playUnmuteSound } from '../utils/ui-sounds';
|
|
6
|
-
import { initExtensionBridge, refreshExtensionContext } from '../services/page-interaction/extension-bridge';
|
|
7
|
-
import { ConnectionManager } from './connection-manager';
|
|
8
|
-
import { EventEmitter } from './event-emitter';
|
|
9
|
-
import { WidgetCore } from './widget-core';
|
|
10
|
-
import { VoiceStateManager } from './voice-state-manager';
|
|
11
|
-
import { TextModeManager } from './text-mode-manager';
|
|
12
|
-
import { ConnectionRetryHandler } from './connection-retry-handler';
|
|
13
|
-
import { SessionBeacon } from './session-beacon';
|
|
1
|
+
import { isDemoMode } from '../constants/defaults.js';
|
|
2
|
+
import { logger } from '../utils/logger.js';
|
|
3
|
+
import { primeAudioOnGesture } from '../utils/audio-context.js';
|
|
4
|
+
import { playConnectChime } from '../utils/connect-chime.js';
|
|
5
|
+
import { playEndCallSound, playMuteSound, playUnmuteSound } from '../utils/ui-sounds.js';
|
|
6
|
+
import { initExtensionBridge, refreshExtensionContext } from '../services/page-interaction/extension-bridge.js';
|
|
7
|
+
import { ConnectionManager } from './connection-manager.js';
|
|
8
|
+
import { EventEmitter } from './event-emitter.js';
|
|
9
|
+
import { WidgetCore } from './widget-core.js';
|
|
10
|
+
import { VoiceStateManager } from './voice-state-manager.js';
|
|
11
|
+
import { TextModeManager } from './text-mode-manager.js';
|
|
12
|
+
import { ConnectionRetryHandler } from './connection-retry-handler.js';
|
|
13
|
+
import { SessionBeacon } from './session-beacon.js';
|
|
14
14
|
const LOG_PREFIX = '[WidgetController]';
|
|
15
15
|
const DEMO_MESSAGE_DELAY_MS = 1000;
|
|
16
16
|
const TEXT_STOP_DELAY_MS = 3000;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { WidgetApiClient } from '../services/api';
|
|
2
|
-
import type { DocumentProvider, WindowProvider } from '../services/page-interaction/page-interaction-handler';
|
|
3
|
-
import { ConfigManager } from './config-manager';
|
|
4
|
-
import { ChatManager } from './chat-manager';
|
|
5
|
-
import { ThemeManager } from './theme-manager';
|
|
6
|
-
import { ConsentManager } from './consent-manager';
|
|
7
|
-
import { PopoverManager } from './popover-manager';
|
|
8
|
-
import { NavigationManager } from './navigation-manager';
|
|
9
|
-
import { ConversationPersistence } from './conversation-persistence';
|
|
10
|
-
import type { WidgetConfig } from '../types';
|
|
11
|
-
import type { WidgetControllerOptions } from './types';
|
|
1
|
+
import { WidgetApiClient } from '../services/api.js';
|
|
2
|
+
import type { DocumentProvider, WindowProvider } from '../services/page-interaction/page-interaction-handler.js';
|
|
3
|
+
import { ConfigManager } from './config-manager.js';
|
|
4
|
+
import { ChatManager } from './chat-manager.js';
|
|
5
|
+
import { ThemeManager } from './theme-manager.js';
|
|
6
|
+
import { ConsentManager } from './consent-manager.js';
|
|
7
|
+
import { PopoverManager } from './popover-manager.js';
|
|
8
|
+
import { NavigationManager } from './navigation-manager.js';
|
|
9
|
+
import { ConversationPersistence } from './conversation-persistence.js';
|
|
10
|
+
import type { WidgetConfig } from '../types/index.js';
|
|
11
|
+
import type { WidgetControllerOptions } from './types.js';
|
|
12
12
|
type StateChangeCallback = () => void;
|
|
13
13
|
type DocumentProviderCallback = (getDoc: DocumentProvider, getWin: WindowProvider) => void;
|
|
14
14
|
type ConnectCallback = () => void;
|
package/dist/core/widget-core.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { WidgetApiClient } from '../services/api';
|
|
2
|
-
import { logger } from '../utils/logger';
|
|
3
|
-
import { ConfigManager } from './config-manager';
|
|
4
|
-
import { ChatManager } from './chat-manager';
|
|
5
|
-
import { ThemeManager } from './theme-manager';
|
|
6
|
-
import { ConsentManager } from './consent-manager';
|
|
7
|
-
import { PopoverManager } from './popover-manager';
|
|
8
|
-
import { NavigationManager } from './navigation-manager';
|
|
9
|
-
import { ConversationPersistence } from './conversation-persistence';
|
|
1
|
+
import { WidgetApiClient } from '../services/api.js';
|
|
2
|
+
import { logger } from '../utils/logger.js';
|
|
3
|
+
import { ConfigManager } from './config-manager.js';
|
|
4
|
+
import { ChatManager } from './chat-manager.js';
|
|
5
|
+
import { ThemeManager } from './theme-manager.js';
|
|
6
|
+
import { ConsentManager } from './consent-manager.js';
|
|
7
|
+
import { PopoverManager } from './popover-manager.js';
|
|
8
|
+
import { NavigationManager } from './navigation-manager.js';
|
|
9
|
+
import { ConversationPersistence } from './conversation-persistence.js';
|
|
10
10
|
const DEMO_RESPONSE_DELAY_MS = 300;
|
|
11
11
|
export class WidgetCore {
|
|
12
12
|
apiClient;
|
package/dist/google.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { registerRealtimeProvider } from './services/realtime/provider-factory';
|
|
1
|
+
import { registerRealtimeProvider } from './services/realtime/provider-factory.js';
|
|
2
2
|
// Subpath entry (@nextpa/chat-core/google): importing it registers both Google
|
|
3
3
|
// Live API providers as lazy loaders — VertexAI shares ~90% of the Google Dev
|
|
4
4
|
// implementation, so one subpath covers both. The SDKs stay in async chunks.
|
|
5
5
|
registerRealtimeProvider('google', async () => {
|
|
6
|
-
const { GoogleRealtimeProvider } = await import('./services/realtime/google');
|
|
6
|
+
const { GoogleRealtimeProvider } = await import('./services/realtime/google/index.js');
|
|
7
7
|
return new GoogleRealtimeProvider();
|
|
8
8
|
});
|
|
9
9
|
registerRealtimeProvider('vertexai', async () => {
|
|
10
|
-
const { VertexAiRealtimeProvider } = await import('./services/realtime/vertexai');
|
|
10
|
+
const { VertexAiRealtimeProvider } = await import('./services/realtime/vertexai/index.js');
|
|
11
11
|
return new VertexAiRealtimeProvider();
|
|
12
12
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -10,28 +10,28 @@
|
|
|
10
10
|
* via the subpath entries ("@nextpa/chat-core/openai", "@nextpa/chat-core/google")
|
|
11
11
|
* which the consuming app imports for the providers it uses.
|
|
12
12
|
*/
|
|
13
|
-
export { WidgetController, TextWidgetController, ConfigManager, ChatManager, ConnectionManager, TextConnectionManager, EventEmitter, type WidgetState, type WidgetControllerOptions, type WidgetEvents, type TextWidgetState, } from './core';
|
|
14
|
-
export { resolveSameOriginTarget } from './core/link-target';
|
|
15
|
-
export { WidgetApiClient, type WidgetApiClientOptions, type WidgetTokenProvider, type WidgetTokenRequestContext, type WidgetTokenResult, } from './services/api';
|
|
16
|
-
export { WebRtcService } from './services/webrtc';
|
|
17
|
-
export type { SignalRService, SignalREvents } from './services/signalr';
|
|
18
|
-
export { VoiceSessionTracker } from './services/realtime/voice-session-tracker';
|
|
19
|
-
export { startThinkingAudio, stopThinkingAudio } from './services/thinking-audio-pulse';
|
|
20
|
-
export { PageInteractionHandler, type DocumentProvider, type ExternalExecutor, type WindowProvider, } from './services/page-interaction/page-interaction-handler';
|
|
21
|
-
export { initExtensionBridge, refreshExtensionContext, } from './services/page-interaction/extension-bridge';
|
|
22
|
-
export { IframeNavigationManager } from './services/page-interaction/iframe-navigation-manager';
|
|
23
|
-
export { generateSelector } from './services/page-interaction/selector-generator';
|
|
24
|
-
export { NEXTPA_IFRAME_NAME } from './services/page-interaction/constants';
|
|
25
|
-
export { createRealtimeProvider, registerRealtimeProvider, type RealtimeProviderLoader, } from './services/realtime/provider-factory';
|
|
26
|
-
export type * from './services/realtime/types';
|
|
27
|
-
export type * from './types';
|
|
28
|
-
export { getDemoConfig, isDemoMode, setDemoMode, DEFAULT_LOGO_DATA_URL, DEFAULT_DESIGN_TOKENS, } from './constants/defaults';
|
|
29
|
-
export { MicLevelAnalyser } from './utils/mic-level-analyser';
|
|
30
|
-
export { logger, type LogLevel } from './utils/logger';
|
|
31
|
-
export { primeAudioOnGesture } from './utils/audio-context';
|
|
32
|
-
export { detectHostLanguage } from './utils/language-detection';
|
|
33
|
-
export { isGerman } from './utils/tool-status';
|
|
34
|
-
export { getMessageBubbleClasses, getMinimizedWidthClasses, getPlacementClasses, } from './utils/styles';
|
|
35
|
-
export { PROACTIVE_OPEN_WIDGET_EVENT, type ProactiveOpenWidgetEvent, type ProactiveOpenWidgetEventDetail, } from './utils/proactive-events';
|
|
36
|
-
export { CONNECT_CHIME_VARIANTS, getActiveConnectChimeVariant, setActiveConnectChimeVariant, playConnectChimeVariant, type ConnectChimeVariantId, type ConnectChimeVariant, } from './utils/connect-chime';
|
|
37
|
-
export { playMuteSound, playUnmuteSound, playEndCallSound } from './utils/ui-sounds';
|
|
13
|
+
export { WidgetController, TextWidgetController, ConfigManager, ChatManager, ConnectionManager, TextConnectionManager, EventEmitter, type WidgetState, type WidgetControllerOptions, type WidgetEvents, type TextWidgetState, } from './core/index.js';
|
|
14
|
+
export { resolveSameOriginTarget } from './core/link-target.js';
|
|
15
|
+
export { WidgetApiClient, type WidgetApiClientOptions, type WidgetTokenProvider, type WidgetTokenRequestContext, type WidgetTokenResult, } from './services/api.js';
|
|
16
|
+
export { WebRtcService } from './services/webrtc.js';
|
|
17
|
+
export type { SignalRService, SignalREvents } from './services/signalr.js';
|
|
18
|
+
export { VoiceSessionTracker } from './services/realtime/voice-session-tracker.js';
|
|
19
|
+
export { startThinkingAudio, stopThinkingAudio } from './services/thinking-audio-pulse.js';
|
|
20
|
+
export { PageInteractionHandler, type DocumentProvider, type ExternalExecutor, type WindowProvider, } from './services/page-interaction/page-interaction-handler.js';
|
|
21
|
+
export { initExtensionBridge, refreshExtensionContext, } from './services/page-interaction/extension-bridge.js';
|
|
22
|
+
export { IframeNavigationManager } from './services/page-interaction/iframe-navigation-manager.js';
|
|
23
|
+
export { generateSelector } from './services/page-interaction/selector-generator.js';
|
|
24
|
+
export { NEXTPA_IFRAME_NAME } from './services/page-interaction/constants.js';
|
|
25
|
+
export { createRealtimeProvider, registerRealtimeProvider, type RealtimeProviderLoader, } from './services/realtime/provider-factory.js';
|
|
26
|
+
export type * from './services/realtime/types.js';
|
|
27
|
+
export type * from './types/index.js';
|
|
28
|
+
export { getDemoConfig, isDemoMode, setDemoMode, DEFAULT_LOGO_DATA_URL, DEFAULT_DESIGN_TOKENS, } from './constants/defaults.js';
|
|
29
|
+
export { MicLevelAnalyser } from './utils/mic-level-analyser.js';
|
|
30
|
+
export { logger, type LogLevel } from './utils/logger.js';
|
|
31
|
+
export { primeAudioOnGesture } from './utils/audio-context.js';
|
|
32
|
+
export { detectHostLanguage } from './utils/language-detection.js';
|
|
33
|
+
export { isGerman } from './utils/tool-status.js';
|
|
34
|
+
export { getMessageBubbleClasses, getMinimizedWidthClasses, getPlacementClasses, } from './utils/styles.js';
|
|
35
|
+
export { PROACTIVE_OPEN_WIDGET_EVENT, type ProactiveOpenWidgetEvent, type ProactiveOpenWidgetEventDetail, } from './utils/proactive-events.js';
|
|
36
|
+
export { CONNECT_CHIME_VARIANTS, getActiveConnectChimeVariant, setActiveConnectChimeVariant, playConnectChimeVariant, type ConnectChimeVariantId, type ConnectChimeVariant, } from './utils/connect-chime.js';
|
|
37
|
+
export { playMuteSound, playUnmuteSound, playEndCallSound } from './utils/ui-sounds.js';
|