@memberjunction/ng-conversations 6.2.0-edge.2 → 6.2.0-edge.4
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 +4 -7
- package/dist/lib/components/collection/collection-view.component.d.ts.map +1 -1
- package/dist/lib/components/collection/collection-view.component.js +1 -0
- package/dist/lib/components/collection/collection-view.component.js.map +1 -1
- package/dist/lib/components/composer/ai-composer.component.d.ts +14 -2
- package/dist/lib/components/composer/ai-composer.component.d.ts.map +1 -1
- package/dist/lib/components/composer/ai-composer.component.js +35 -4
- package/dist/lib/components/composer/ai-composer.component.js.map +1 -1
- package/dist/lib/components/conversation/conversation-chat-area.component.d.ts +632 -55
- package/dist/lib/components/conversation/conversation-chat-area.component.d.ts.map +1 -1
- package/dist/lib/components/conversation/conversation-chat-area.component.js +2748 -624
- package/dist/lib/components/conversation/conversation-chat-area.component.js.map +1 -1
- package/dist/lib/components/conversation/forks-popover.component.d.ts +37 -0
- package/dist/lib/components/conversation/forks-popover.component.d.ts.map +1 -0
- package/dist/lib/components/conversation/forks-popover.component.js +164 -0
- package/dist/lib/components/conversation/forks-popover.component.js.map +1 -0
- package/dist/lib/components/export/export-modal.component.d.ts +7 -2
- package/dist/lib/components/export/export-modal.component.d.ts.map +1 -1
- package/dist/lib/components/export/export-modal.component.js +16 -3
- package/dist/lib/components/export/export-modal.component.js.map +1 -1
- package/dist/lib/components/message/conversation-message-rating.component.d.ts.map +1 -1
- package/dist/lib/components/message/conversation-message-rating.component.js +11 -9
- package/dist/lib/components/message/conversation-message-rating.component.js.map +1 -1
- package/dist/lib/components/message/message-input.component.d.ts +121 -11
- package/dist/lib/components/message/message-input.component.d.ts.map +1 -1
- package/dist/lib/components/message/message-input.component.js +307 -106
- package/dist/lib/components/message/message-input.component.js.map +1 -1
- package/dist/lib/components/message/message-item.component.d.ts +178 -5
- package/dist/lib/components/message/message-item.component.d.ts.map +1 -1
- package/dist/lib/components/message/message-item.component.js +919 -306
- package/dist/lib/components/message/message-item.component.js.map +1 -1
- package/dist/lib/components/message/message-list.component.d.ts +92 -21
- package/dist/lib/components/message/message-list.component.d.ts.map +1 -1
- package/dist/lib/components/message/message-list.component.js +337 -52
- package/dist/lib/components/message/message-list.component.js.map +1 -1
- package/dist/lib/components/realtime/avatar/realtime-avatar-channel.d.ts +34 -0
- package/dist/lib/components/realtime/avatar/realtime-avatar-channel.d.ts.map +1 -0
- package/dist/lib/components/realtime/avatar/realtime-avatar-channel.js +75 -0
- package/dist/lib/components/realtime/avatar/realtime-avatar-channel.js.map +1 -0
- package/dist/lib/components/realtime/avatar/realtime-avatar-surface.component.d.ts +80 -0
- package/dist/lib/components/realtime/avatar/realtime-avatar-surface.component.d.ts.map +1 -0
- package/dist/lib/components/realtime/avatar/realtime-avatar-surface.component.js +202 -0
- package/dist/lib/components/realtime/avatar/realtime-avatar-surface.component.js.map +1 -0
- package/dist/lib/components/realtime/capture/realtime-camera-check-card.component.d.ts +45 -0
- package/dist/lib/components/realtime/capture/realtime-camera-check-card.component.d.ts.map +1 -0
- package/dist/lib/components/realtime/capture/realtime-camera-check-card.component.js +123 -0
- package/dist/lib/components/realtime/capture/realtime-camera-check-card.component.js.map +1 -0
- package/dist/lib/components/realtime/capture/realtime-capture-channel.d.ts +90 -0
- package/dist/lib/components/realtime/capture/realtime-capture-channel.d.ts.map +1 -0
- package/dist/lib/components/realtime/capture/realtime-capture-channel.js +223 -0
- package/dist/lib/components/realtime/capture/realtime-capture-channel.js.map +1 -0
- package/dist/lib/components/realtime/capture/realtime-capture-model.d.ts +98 -0
- package/dist/lib/components/realtime/capture/realtime-capture-model.d.ts.map +1 -0
- package/dist/lib/components/realtime/capture/realtime-capture-model.js +161 -0
- package/dist/lib/components/realtime/capture/realtime-capture-model.js.map +1 -0
- package/dist/lib/components/realtime/capture/realtime-capture-surface.component.d.ts +48 -0
- package/dist/lib/components/realtime/capture/realtime-capture-surface.component.d.ts.map +1 -0
- package/dist/lib/components/realtime/capture/realtime-capture-surface.component.js +205 -0
- package/dist/lib/components/realtime/capture/realtime-capture-surface.component.js.map +1 -0
- package/dist/lib/components/realtime/channels/client-context-channel.d.ts +19 -2
- package/dist/lib/components/realtime/channels/client-context-channel.d.ts.map +1 -1
- package/dist/lib/components/realtime/channels/client-context-channel.js +83 -9
- package/dist/lib/components/realtime/channels/client-context-channel.js.map +1 -1
- package/dist/lib/components/realtime/channels/realtime-channel-pane.component.d.ts +30 -9
- package/dist/lib/components/realtime/channels/realtime-channel-pane.component.d.ts.map +1 -1
- package/dist/lib/components/realtime/channels/realtime-channel-pane.component.js +78 -14
- package/dist/lib/components/realtime/channels/realtime-channel-pane.component.js.map +1 -1
- package/dist/lib/components/realtime/identity-verification/identity-verification-channel.d.ts +71 -0
- package/dist/lib/components/realtime/identity-verification/identity-verification-channel.d.ts.map +1 -0
- package/dist/lib/components/realtime/identity-verification/identity-verification-channel.js +259 -0
- package/dist/lib/components/realtime/identity-verification/identity-verification-channel.js.map +1 -0
- package/dist/lib/components/realtime/identity-verification/identity-verification-model.d.ts +129 -0
- package/dist/lib/components/realtime/identity-verification/identity-verification-model.d.ts.map +1 -0
- package/dist/lib/components/realtime/identity-verification/identity-verification-model.js +373 -0
- package/dist/lib/components/realtime/identity-verification/identity-verification-model.js.map +1 -0
- package/dist/lib/components/realtime/identity-verification/identity-verification-surface.component.d.ts +77 -0
- package/dist/lib/components/realtime/identity-verification/identity-verification-surface.component.d.ts.map +1 -0
- package/dist/lib/components/realtime/identity-verification/identity-verification-surface.component.js +420 -0
- package/dist/lib/components/realtime/identity-verification/identity-verification-surface.component.js.map +1 -0
- package/dist/lib/components/realtime/interactive-component/component-contract.d.ts +83 -0
- package/dist/lib/components/realtime/interactive-component/component-contract.d.ts.map +1 -0
- package/dist/lib/components/realtime/interactive-component/component-contract.js +292 -0
- package/dist/lib/components/realtime/interactive-component/component-contract.js.map +1 -0
- package/dist/lib/components/realtime/interactive-component/component-data-state.d.ts +39 -0
- package/dist/lib/components/realtime/interactive-component/component-data-state.d.ts.map +1 -0
- package/dist/lib/components/realtime/interactive-component/component-data-state.js +152 -0
- package/dist/lib/components/realtime/interactive-component/component-data-state.js.map +1 -0
- package/dist/lib/components/realtime/interactive-component/component-instance-engine.d.ts +109 -0
- package/dist/lib/components/realtime/interactive-component/component-instance-engine.d.ts.map +1 -0
- package/dist/lib/components/realtime/interactive-component/component-instance-engine.js +146 -0
- package/dist/lib/components/realtime/interactive-component/component-instance-engine.js.map +1 -0
- package/dist/lib/components/realtime/interactive-component/component-spec-content.d.ts +19 -0
- package/dist/lib/components/realtime/interactive-component/component-spec-content.d.ts.map +1 -0
- package/dist/lib/components/realtime/interactive-component/component-spec-content.js +39 -0
- package/dist/lib/components/realtime/interactive-component/component-spec-content.js.map +1 -0
- package/dist/lib/components/realtime/interactive-component/interactive-component-channel.d.ts +183 -0
- package/dist/lib/components/realtime/interactive-component/interactive-component-channel.d.ts.map +1 -0
- package/dist/lib/components/realtime/interactive-component/interactive-component-channel.js +761 -0
- package/dist/lib/components/realtime/interactive-component/interactive-component-channel.js.map +1 -0
- package/dist/lib/components/realtime/interactive-component/interactive-component-config.d.ts +25 -0
- package/dist/lib/components/realtime/interactive-component/interactive-component-config.d.ts.map +1 -0
- package/dist/lib/components/realtime/interactive-component/interactive-component-config.js +57 -0
- package/dist/lib/components/realtime/interactive-component/interactive-component-config.js.map +1 -0
- package/dist/lib/components/realtime/interactive-component/interactive-component-host.component.d.ts +40 -0
- package/dist/lib/components/realtime/interactive-component/interactive-component-host.component.d.ts.map +1 -0
- package/dist/lib/components/realtime/interactive-component/interactive-component-host.component.js +97 -0
- package/dist/lib/components/realtime/interactive-component/interactive-component-host.component.js.map +1 -0
- package/dist/lib/components/realtime/interactive-component/interactive-component-types.d.ts +144 -0
- package/dist/lib/components/realtime/interactive-component/interactive-component-types.d.ts.map +1 -0
- package/dist/lib/components/realtime/interactive-component/interactive-component-types.js +57 -0
- package/dist/lib/components/realtime/interactive-component/interactive-component-types.js.map +1 -0
- package/dist/lib/components/realtime/interactive-component/react-component-handle.d.ts +36 -0
- package/dist/lib/components/realtime/interactive-component/react-component-handle.d.ts.map +1 -0
- package/dist/lib/components/realtime/interactive-component/react-component-handle.js +55 -0
- package/dist/lib/components/realtime/interactive-component/react-component-handle.js.map +1 -0
- package/dist/lib/components/realtime/interactive-component/realtime-interactive-component-surface.component.d.ts +55 -0
- package/dist/lib/components/realtime/interactive-component/realtime-interactive-component-surface.component.d.ts.map +1 -0
- package/dist/lib/components/realtime/interactive-component/realtime-interactive-component-surface.component.js +210 -0
- package/dist/lib/components/realtime/interactive-component/realtime-interactive-component-surface.component.js.map +1 -0
- package/dist/lib/components/realtime/interactive-component/run-view-component-artifact-source.d.ts +32 -0
- package/dist/lib/components/realtime/interactive-component/run-view-component-artifact-source.d.ts.map +1 -0
- package/dist/lib/components/realtime/interactive-component/run-view-component-artifact-source.js +90 -0
- package/dist/lib/components/realtime/interactive-component/run-view-component-artifact-source.js.map +1 -0
- package/dist/lib/components/realtime/media/media-channel.d.ts +7 -0
- package/dist/lib/components/realtime/media/media-channel.d.ts.map +1 -1
- package/dist/lib/components/realtime/media/media-channel.js +28 -1
- package/dist/lib/components/realtime/media/media-channel.js.map +1 -1
- package/dist/lib/components/realtime/realtime-agent-banner.component.d.ts +8 -1
- package/dist/lib/components/realtime/realtime-agent-banner.component.d.ts.map +1 -1
- package/dist/lib/components/realtime/realtime-agent-banner.component.js +89 -71
- package/dist/lib/components/realtime/realtime-agent-banner.component.js.map +1 -1
- package/dist/lib/components/realtime/realtime-agent-orb.component.d.ts +21 -0
- package/dist/lib/components/realtime/realtime-agent-orb.component.d.ts.map +1 -0
- package/dist/lib/components/realtime/realtime-agent-orb.component.js +49 -0
- package/dist/lib/components/realtime/realtime-agent-orb.component.js.map +1 -0
- package/dist/lib/components/realtime/realtime-agent-picker.component.d.ts +44 -11
- package/dist/lib/components/realtime/realtime-agent-picker.component.d.ts.map +1 -1
- package/dist/lib/components/realtime/realtime-agent-picker.component.js +162 -50
- package/dist/lib/components/realtime/realtime-agent-picker.component.js.map +1 -1
- package/dist/lib/components/realtime/realtime-audio-visuals.d.ts +8 -2
- package/dist/lib/components/realtime/realtime-audio-visuals.d.ts.map +1 -1
- package/dist/lib/components/realtime/realtime-audio-visuals.js +14 -18
- package/dist/lib/components/realtime/realtime-audio-visuals.js.map +1 -1
- package/dist/lib/components/realtime/realtime-composer.component.d.ts +42 -2
- package/dist/lib/components/realtime/realtime-composer.component.d.ts.map +1 -1
- package/dist/lib/components/realtime/realtime-composer.component.js +137 -102
- package/dist/lib/components/realtime/realtime-composer.component.js.map +1 -1
- package/dist/lib/components/realtime/realtime-perception-chip.component.d.ts +71 -0
- package/dist/lib/components/realtime/realtime-perception-chip.component.d.ts.map +1 -0
- package/dist/lib/components/realtime/realtime-perception-chip.component.js +221 -0
- package/dist/lib/components/realtime/realtime-perception-chip.component.js.map +1 -0
- package/dist/lib/components/realtime/realtime-session-overlay.component.d.ts +264 -22
- package/dist/lib/components/realtime/realtime-session-overlay.component.d.ts.map +1 -1
- package/dist/lib/components/realtime/realtime-session-overlay.component.js +851 -135
- package/dist/lib/components/realtime/realtime-session-overlay.component.js.map +1 -1
- package/dist/lib/components/realtime/realtime-surface-placement-prefs.d.ts +14 -0
- package/dist/lib/components/realtime/realtime-surface-placement-prefs.d.ts.map +1 -0
- package/dist/lib/components/realtime/realtime-surface-placement-prefs.js +14 -0
- package/dist/lib/components/realtime/realtime-surface-placement-prefs.js.map +1 -0
- package/dist/lib/components/realtime/realtime-surface-stage.model.d.ts +74 -0
- package/dist/lib/components/realtime/realtime-surface-stage.model.d.ts.map +1 -0
- package/dist/lib/components/realtime/realtime-surface-stage.model.js +171 -0
- package/dist/lib/components/realtime/realtime-surface-stage.model.js.map +1 -0
- package/dist/lib/components/realtime/realtime-surface-tabs.component.d.ts +71 -13
- package/dist/lib/components/realtime/realtime-surface-tabs.component.d.ts.map +1 -1
- package/dist/lib/components/realtime/realtime-surface-tabs.component.js +232 -73
- package/dist/lib/components/realtime/realtime-surface-tabs.component.js.map +1 -1
- package/dist/lib/components/realtime/realtime-surface-tabs.model.d.ts +5 -0
- package/dist/lib/components/realtime/realtime-surface-tabs.model.d.ts.map +1 -1
- package/dist/lib/components/realtime/realtime-surface-tabs.model.js +8 -0
- package/dist/lib/components/realtime/realtime-surface-tabs.model.js.map +1 -1
- package/dist/lib/components/realtime/realtime-ui-config.d.ts +12 -2
- package/dist/lib/components/realtime/realtime-ui-config.d.ts.map +1 -1
- package/dist/lib/components/realtime/realtime-ui-config.js +5 -1
- package/dist/lib/components/realtime/realtime-ui-config.js.map +1 -1
- package/dist/lib/components/realtime/remote-browser/remote-browser-channel.d.ts +10 -1
- package/dist/lib/components/realtime/remote-browser/remote-browser-channel.d.ts.map +1 -1
- package/dist/lib/components/realtime/remote-browser/remote-browser-channel.js +42 -2
- package/dist/lib/components/realtime/remote-browser/remote-browser-channel.js.map +1 -1
- package/dist/lib/components/realtime/remote-browser/remote-browser-surface.component.d.ts +20 -3
- package/dist/lib/components/realtime/remote-browser/remote-browser-surface.component.d.ts.map +1 -1
- package/dist/lib/components/realtime/remote-browser/remote-browser-surface.component.js +44 -10
- package/dist/lib/components/realtime/remote-browser/remote-browser-surface.component.js.map +1 -1
- package/dist/lib/components/realtime/whiteboard/whiteboard-channel.d.ts +28 -44
- package/dist/lib/components/realtime/whiteboard/whiteboard-channel.d.ts.map +1 -1
- package/dist/lib/components/realtime/whiteboard/whiteboard-channel.js +76 -162
- package/dist/lib/components/realtime/whiteboard/whiteboard-channel.js.map +1 -1
- package/dist/lib/components/search/search-panel.component.d.ts +2 -0
- package/dist/lib/components/search/search-panel.component.d.ts.map +1 -1
- package/dist/lib/components/search/search-panel.component.js +25 -12
- package/dist/lib/components/search/search-panel.component.js.map +1 -1
- package/dist/lib/components/workspace/conversation-workspace.component.d.ts +22 -31
- package/dist/lib/components/workspace/conversation-workspace.component.d.ts.map +1 -1
- package/dist/lib/components/workspace/conversation-workspace.component.js +50 -63
- package/dist/lib/components/workspace/conversation-workspace.component.js.map +1 -1
- package/dist/lib/conversations.module.d.ts +30 -29
- package/dist/lib/conversations.module.d.ts.map +1 -1
- package/dist/lib/conversations.module.js +27 -5
- package/dist/lib/conversations.module.js.map +1 -1
- package/dist/lib/events/chat-events.d.ts +25 -0
- package/dist/lib/events/chat-events.d.ts.map +1 -1
- package/dist/lib/events/chat-events.js +36 -0
- package/dist/lib/events/chat-events.js.map +1 -1
- package/dist/lib/models/agent-turn.model.d.ts +5 -0
- package/dist/lib/models/agent-turn.model.d.ts.map +1 -1
- package/dist/lib/models/agent-turn.model.js.map +1 -1
- package/dist/lib/services/agent-state.service.d.ts +34 -8
- package/dist/lib/services/agent-state.service.d.ts.map +1 -1
- package/dist/lib/services/agent-state.service.js +82 -29
- package/dist/lib/services/agent-state.service.js.map +1 -1
- package/dist/lib/services/artifact-state.service.d.ts +0 -9
- package/dist/lib/services/artifact-state.service.d.ts.map +1 -1
- package/dist/lib/services/artifact-state.service.js +1 -32
- package/dist/lib/services/artifact-state.service.js.map +1 -1
- package/dist/lib/services/browser-realtime-media-host.d.ts +12 -0
- package/dist/lib/services/browser-realtime-media-host.d.ts.map +1 -1
- package/dist/lib/services/browser-realtime-media-host.js +19 -0
- package/dist/lib/services/browser-realtime-media-host.js.map +1 -1
- package/dist/lib/services/browser-recording-unload-guard.d.ts +30 -0
- package/dist/lib/services/browser-recording-unload-guard.d.ts.map +1 -0
- package/dist/lib/services/browser-recording-unload-guard.js +43 -0
- package/dist/lib/services/browser-recording-unload-guard.js.map +1 -0
- package/dist/lib/services/conversation-agent.service.d.ts +35 -11
- package/dist/lib/services/conversation-agent.service.d.ts.map +1 -1
- package/dist/lib/services/conversation-agent.service.js +65 -20
- package/dist/lib/services/conversation-agent.service.js.map +1 -1
- package/dist/lib/services/conversation-detail-window.store.d.ts +22 -4
- package/dist/lib/services/conversation-detail-window.store.d.ts.map +1 -1
- package/dist/lib/services/conversation-detail-window.store.js +50 -9
- package/dist/lib/services/conversation-detail-window.store.js.map +1 -1
- package/dist/lib/services/conversation-naming.d.ts +72 -22
- package/dist/lib/services/conversation-naming.d.ts.map +1 -1
- package/dist/lib/services/conversation-naming.js +84 -10
- package/dist/lib/services/conversation-naming.js.map +1 -1
- package/dist/lib/services/data-cache.service.d.ts +13 -5
- package/dist/lib/services/data-cache.service.d.ts.map +1 -1
- package/dist/lib/services/data-cache.service.js +39 -19
- package/dist/lib/services/data-cache.service.js.map +1 -1
- package/dist/lib/services/export.service.d.ts +26 -9
- package/dist/lib/services/export.service.d.ts.map +1 -1
- package/dist/lib/services/export.service.js +61 -18
- package/dist/lib/services/export.service.js.map +1 -1
- package/dist/lib/services/realtime-audio-recorder.d.ts +33 -5
- package/dist/lib/services/realtime-audio-recorder.d.ts.map +1 -1
- package/dist/lib/services/realtime-audio-recorder.js +71 -11
- package/dist/lib/services/realtime-audio-recorder.js.map +1 -1
- package/dist/lib/services/realtime-pairing.d.ts +10 -5
- package/dist/lib/services/realtime-pairing.d.ts.map +1 -1
- package/dist/lib/services/realtime-pairing.js +15 -6
- package/dist/lib/services/realtime-pairing.js.map +1 -1
- package/dist/lib/services/realtime-session.service.d.ts +3 -2
- package/dist/lib/services/realtime-session.service.d.ts.map +1 -1
- package/dist/lib/services/realtime-session.service.js +7 -2
- package/dist/lib/services/realtime-session.service.js.map +1 -1
- package/dist/lib/services/search.service.d.ts +7 -2
- package/dist/lib/services/search.service.d.ts.map +1 -1
- package/dist/lib/services/search.service.js +13 -4
- package/dist/lib/services/search.service.js.map +1 -1
- package/dist/lib/util/frame-zone.d.ts +10 -0
- package/dist/lib/util/frame-zone.d.ts.map +1 -0
- package/dist/lib/util/frame-zone.js +10 -0
- package/dist/lib/util/frame-zone.js.map +1 -0
- package/dist/lib/utils/conversation-branching.d.ts +4 -0
- package/dist/lib/utils/conversation-branching.d.ts.map +1 -0
- package/dist/lib/utils/conversation-branching.js +5 -0
- package/dist/lib/utils/conversation-branching.js.map +1 -0
- package/dist/lib/utils/conversation-forks.d.ts +315 -0
- package/dist/lib/utils/conversation-forks.d.ts.map +1 -0
- package/dist/lib/utils/conversation-forks.js +456 -0
- package/dist/lib/utils/conversation-forks.js.map +1 -0
- package/dist/public-api.d.ts +23 -1
- package/dist/public-api.d.ts.map +1 -1
- package/dist/public-api.js +30 -1
- package/dist/public-api.js.map +1 -1
- package/package.json +37 -32
- package/dist/lib/components/thread/thread-panel.component.d.ts +0 -126
- package/dist/lib/components/thread/thread-panel.component.d.ts.map +0 -1
- package/dist/lib/components/thread/thread-panel.component.js +0 -440
- package/dist/lib/components/thread/thread-panel.component.js.map +0 -1
package/dist/lib/components/realtime/interactive-component/run-view-component-artifact-source.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The database-backed {@link IComponentArtifactSource}: loads component artifacts through the
|
|
3
|
+
* SESSION'S OWN provider and the signed-in user's own read access.
|
|
4
|
+
*
|
|
5
|
+
* Nothing here widens access. The channel runs in the user's browser, the provider is the one that
|
|
6
|
+
* authenticates their session, and an artifact is loaded only if the user may read it by the same rules the
|
|
7
|
+
* rest of the conversation UI applies (owner, an explicit grant, or a collection they can read).
|
|
8
|
+
*
|
|
9
|
+
* @module @memberjunction/ng-conversations
|
|
10
|
+
*/
|
|
11
|
+
import { LogError, RunView } from '@memberjunction/core';
|
|
12
|
+
import { UUIDsEqual } from '@memberjunction/global';
|
|
13
|
+
import { ArtifactPermissionService } from '../../../services/artifact-permission.service';
|
|
14
|
+
import { CollectionPermissionService } from '../../../services/collection-permission.service';
|
|
15
|
+
import { ParseComponentSpecContent } from './component-spec-content';
|
|
16
|
+
import { ComponentArtifactError, } from './interactive-component-types';
|
|
17
|
+
/** A UUID in any case, with or without braces. Ids reach SQL filters, so anything else is refused before it is built into one. */
|
|
18
|
+
const UUID_PATTERN = /^\{?[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\}?$/i;
|
|
19
|
+
/** The artifact type name that marks a component artifact. */
|
|
20
|
+
const COMPONENT_ARTIFACT_TYPE = 'Component';
|
|
21
|
+
/** Validates an id the model supplied. */
|
|
22
|
+
function requireUuid(value, what) {
|
|
23
|
+
const trimmed = value.trim();
|
|
24
|
+
if (!UUID_PATTERN.test(trimmed)) {
|
|
25
|
+
throw new ComponentArtifactError('invalid_id', `"${value}" is not a valid ${what} id.`);
|
|
26
|
+
}
|
|
27
|
+
return trimmed.replace(/[{}]/g, '');
|
|
28
|
+
}
|
|
29
|
+
/** Loads component artifacts with the user's own access. */
|
|
30
|
+
export class RunViewComponentArtifactSource {
|
|
31
|
+
provider;
|
|
32
|
+
user;
|
|
33
|
+
permissions;
|
|
34
|
+
/**
|
|
35
|
+
* @param provider The session's metadata provider (the one that authenticates the user).
|
|
36
|
+
* @param user The signed-in user.
|
|
37
|
+
*/
|
|
38
|
+
constructor(provider, user) {
|
|
39
|
+
this.provider = provider;
|
|
40
|
+
this.user = user;
|
|
41
|
+
this.permissions = new ArtifactPermissionService(new CollectionPermissionService());
|
|
42
|
+
this.permissions.Provider = provider;
|
|
43
|
+
}
|
|
44
|
+
/** @inheritdoc */
|
|
45
|
+
async LoadVersion(versionId) {
|
|
46
|
+
const id = requireUuid(versionId, 'artifact version');
|
|
47
|
+
const version = await this.queryOne('MJ: Artifact Versions', `ID='${id}'`, 'artifact version');
|
|
48
|
+
return this.resolve(version);
|
|
49
|
+
}
|
|
50
|
+
/** @inheritdoc */
|
|
51
|
+
async LoadLatest(artifactId) {
|
|
52
|
+
const id = requireUuid(artifactId, 'artifact');
|
|
53
|
+
const version = await this.queryOne('MJ: Artifact Versions', `ArtifactID='${id}'`, 'artifact', 'VersionNumber DESC');
|
|
54
|
+
return this.resolve(version);
|
|
55
|
+
}
|
|
56
|
+
/** Loads one row by filter, mapping an empty result to `not_found` and a failed query to `load_failed`. */
|
|
57
|
+
async queryOne(entityName, filter, what, orderBy) {
|
|
58
|
+
const rv = RunView.FromMetadataProvider(this.provider);
|
|
59
|
+
const result = await rv.RunView({ EntityName: entityName, ExtraFilter: filter, OrderBy: orderBy, MaxRows: 1, ResultType: 'entity_object' }, this.user);
|
|
60
|
+
if (!result.Success) {
|
|
61
|
+
LogError(`[InteractiveComponent] Loading ${what} failed: ${result.ErrorMessage}`);
|
|
62
|
+
throw new ComponentArtifactError('load_failed', `The ${what} could not be loaded.`);
|
|
63
|
+
}
|
|
64
|
+
if (!result.Results || result.Results.length === 0) {
|
|
65
|
+
throw new ComponentArtifactError('not_found', `No ${what} with that id exists, or you cannot see it.`);
|
|
66
|
+
}
|
|
67
|
+
return result.Results[0];
|
|
68
|
+
}
|
|
69
|
+
/** Checks access and type, then parses the content. */
|
|
70
|
+
async resolve(version) {
|
|
71
|
+
const artifactId = version.ArtifactID;
|
|
72
|
+
const canRead = await this.permissions.CheckPermission(artifactId, this.user.ID, 'read', this.user);
|
|
73
|
+
if (!canRead) {
|
|
74
|
+
throw new ComponentArtifactError('access_denied', 'You do not have access to that artifact.');
|
|
75
|
+
}
|
|
76
|
+
const artifact = await this.queryOne('MJ: Artifacts', `ID='${requireUuid(artifactId, 'artifact')}'`, 'artifact');
|
|
77
|
+
if (!UUIDsEqual(artifact.ID, artifactId) || artifact.Type !== COMPONENT_ARTIFACT_TYPE) {
|
|
78
|
+
throw new ComponentArtifactError('not_a_component', `"${artifact.Name}" is a ${artifact.Type} artifact, not an interactive component.`);
|
|
79
|
+
}
|
|
80
|
+
const name = version.Name ?? artifact.Name;
|
|
81
|
+
return {
|
|
82
|
+
ArtifactID: artifact.ID,
|
|
83
|
+
VersionID: version.ID,
|
|
84
|
+
VersionNumber: version.VersionNumber,
|
|
85
|
+
Name: name,
|
|
86
|
+
Spec: ParseComponentSpecContent(version.Content, `"${name}"`),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=run-view-component-artifact-source.js.map
|
package/dist/lib/components/realtime/interactive-component/run-view-component-artifact-source.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-view-component-artifact-source.js","sourceRoot":"","sources":["../../../../../src/lib/components/realtime/interactive-component/run-view-component-artifact-source.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAqB,QAAQ,EAAE,OAAO,EAAY,MAAM,sBAAsB,CAAC;AAEtF,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,+CAA+C,CAAC;AAC1F,OAAO,EAAE,2BAA2B,EAAE,MAAM,iDAAiD,CAAC;AAC9F,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EACH,sBAAsB,GAGzB,MAAM,+BAA+B,CAAC;AAEvC,kIAAkI;AAClI,MAAM,YAAY,GAAG,uEAAuE,CAAC;AAE7F,8DAA8D;AAC9D,MAAM,uBAAuB,GAAG,WAAW,CAAC;AAE5C,0CAA0C;AAC1C,SAAS,WAAW,CAAC,KAAa,EAAE,IAAY;IAC5C,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,sBAAsB,CAAC,YAAY,EAAE,IAAI,KAAK,oBAAoB,IAAI,MAAM,CAAC,CAAC;IAC5F,CAAC;IACD,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AACxC,CAAC;AAED,4DAA4D;AAC5D,MAAM,OAAO,8BAA8B;IAQlB;IACA;IARJ,WAAW,CAA4B;IAExD;;;OAGG;IACH,YACqB,QAA2B,EAC3B,IAAc;QADd,aAAQ,GAAR,QAAQ,CAAmB;QAC3B,SAAI,GAAJ,IAAI,CAAU;QAE/B,IAAI,CAAC,WAAW,GAAG,IAAI,yBAAyB,CAAC,IAAI,2BAA2B,EAAE,CAAC,CAA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E,OAAO,CAAC,aAAa;YACpC,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,yBAAyB,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,IAAI,GAAG,CAAC;SAChE,CAAC;IACN,CAAC;CACJ","sourcesContent":["/**\n * @fileoverview The database-backed {@link IComponentArtifactSource}: loads component artifacts through the\n * SESSION'S OWN provider and the signed-in user's own read access.\n *\n * Nothing here widens access. The channel runs in the user's browser, the provider is the one that\n * authenticates their session, and an artifact is loaded only if the user may read it by the same rules the\n * rest of the conversation UI applies (owner, an explicit grant, or a collection they can read).\n *\n * @module @memberjunction/ng-conversations\n */\n\nimport { IMetadataProvider, LogError, RunView, UserInfo } from '@memberjunction/core';\nimport { MJArtifactEntity, MJArtifactVersionEntity } from '@memberjunction/core-entities';\nimport { UUIDsEqual } from '@memberjunction/global';\nimport { ArtifactPermissionService } from '../../../services/artifact-permission.service';\nimport { CollectionPermissionService } from '../../../services/collection-permission.service';\nimport { ParseComponentSpecContent } from './component-spec-content';\nimport {\n ComponentArtifactError,\n type IComponentArtifactSource,\n type ResolvedComponentArtifact,\n} from './interactive-component-types';\n\n/** A UUID in any case, with or without braces. Ids reach SQL filters, so anything else is refused before it is built into one. */\nconst UUID_PATTERN = /^\\{?[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\\}?$/i;\n\n/** The artifact type name that marks a component artifact. */\nconst COMPONENT_ARTIFACT_TYPE = 'Component';\n\n/** Validates an id the model supplied. */\nfunction requireUuid(value: string, what: string): string {\n const trimmed = value.trim();\n if (!UUID_PATTERN.test(trimmed)) {\n throw new ComponentArtifactError('invalid_id', `\"${value}\" is not a valid ${what} id.`);\n }\n return trimmed.replace(/[{}]/g, '');\n}\n\n/** Loads component artifacts with the user's own access. */\nexport class RunViewComponentArtifactSource implements IComponentArtifactSource {\n private readonly permissions: ArtifactPermissionService;\n\n /**\n * @param provider The session's metadata provider (the one that authenticates the user).\n * @param user The signed-in user.\n */\n public constructor(\n private readonly provider: IMetadataProvider,\n private readonly user: UserInfo\n ) {\n this.permissions = new ArtifactPermissionService(new CollectionPermissionService());\n this.permissions.Provider = provider;\n }\n\n /** @inheritdoc */\n public async LoadVersion(versionId: string): Promise<ResolvedComponentArtifact> {\n const id = requireUuid(versionId, 'artifact version');\n const version = await this.queryOne<MJArtifactVersionEntity>('MJ: Artifact Versions', `ID='${id}'`, 'artifact version');\n return this.resolve(version);\n }\n\n /** @inheritdoc */\n public async LoadLatest(artifactId: string): Promise<ResolvedComponentArtifact> {\n const id = requireUuid(artifactId, 'artifact');\n const version = await this.queryOne<MJArtifactVersionEntity>(\n 'MJ: Artifact Versions',\n `ArtifactID='${id}'`,\n 'artifact',\n 'VersionNumber DESC'\n );\n return this.resolve(version);\n }\n\n /** Loads one row by filter, mapping an empty result to `not_found` and a failed query to `load_failed`. */\n private async queryOne<T>(entityName: string, filter: string, what: string, orderBy?: string): Promise<T> {\n const rv = RunView.FromMetadataProvider(this.provider);\n const result = await rv.RunView<T>(\n { EntityName: entityName, ExtraFilter: filter, OrderBy: orderBy, MaxRows: 1, ResultType: 'entity_object' },\n this.user\n );\n if (!result.Success) {\n LogError(`[InteractiveComponent] Loading ${what} failed: ${result.ErrorMessage}`);\n throw new ComponentArtifactError('load_failed', `The ${what} could not be loaded.`);\n }\n if (!result.Results || result.Results.length === 0) {\n throw new ComponentArtifactError('not_found', `No ${what} with that id exists, or you cannot see it.`);\n }\n return result.Results[0];\n }\n\n /** Checks access and type, then parses the content. */\n private async resolve(version: MJArtifactVersionEntity): Promise<ResolvedComponentArtifact> {\n const artifactId = version.ArtifactID;\n const canRead = await this.permissions.CheckPermission(artifactId, this.user.ID, 'read', this.user);\n if (!canRead) {\n throw new ComponentArtifactError('access_denied', 'You do not have access to that artifact.');\n }\n const artifact = await this.queryOne<MJArtifactEntity>('MJ: Artifacts', `ID='${requireUuid(artifactId, 'artifact')}'`, 'artifact');\n if (!UUIDsEqual(artifact.ID, artifactId) || artifact.Type !== COMPONENT_ARTIFACT_TYPE) {\n throw new ComponentArtifactError('not_a_component', `\"${artifact.Name}\" is a ${artifact.Type} artifact, not an interactive component.`);\n }\n const name = version.Name ?? artifact.Name;\n return {\n ArtifactID: artifact.ID,\n VersionID: version.ID,\n VersionNumber: version.VersionNumber,\n Name: name,\n Spec: ParseComponentSpecContent(version.Content, `\"${name}\"`),\n };\n }\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Type } from '@angular/core';
|
|
2
2
|
import { RealtimeToolDefinition } from '@memberjunction/ai';
|
|
3
|
+
import { type RealtimeChannelDescriptor } from '@memberjunction/ai-core-plus';
|
|
3
4
|
import { BaseRealtimeChannelClient } from '@memberjunction/realtime-runtime';
|
|
4
5
|
import { ChannelOnboardingDetails } from '@memberjunction/realtime-runtime';
|
|
5
6
|
import { MediaChannelState } from './media-channel-state';
|
|
@@ -34,6 +35,12 @@ export declare class RealtimeMediaChannel extends BaseRealtimeChannelClient<Real
|
|
|
34
35
|
get TabTitle(): string;
|
|
35
36
|
get TabIcon(): string;
|
|
36
37
|
GetToolDefinitions(): RealtimeToolDefinition[];
|
|
38
|
+
/**
|
|
39
|
+
* The media surface's self-description: what it holds, and every `Media_*` tool as a verb (so a tool a
|
|
40
|
+
* subclass adds shows up here too). The model reads its state (what is on screen) but is never shown
|
|
41
|
+
* pixels of it, so its exposure ceiling is `state`.
|
|
42
|
+
*/
|
|
43
|
+
GetDescriptor(): RealtimeChannelDescriptor;
|
|
37
44
|
GetSurfaceComponent(): Type<RealtimeMediaSurfaceComponent>;
|
|
38
45
|
/** First-run intro shown the first time the user opens the Media tab (once per user). */
|
|
39
46
|
GetOnboardingDetails(): ChannelOnboardingDetails;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media-channel.d.ts","sourceRoot":"","sources":["../../../../../src/lib/components/realtime/media/media-channel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,M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AAa,IAAI,IAAI;IAIrC;;;;;;OAMG;IACI,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;IA2BjE,+GAA+G;IAC/G,OAAO,CAAC,cAAc;IAyBtB,2BAA2B;IAC3B,OAAO,CAAC,eAAe;IAavB,qDAAqD;IACrD,OAAO,CAAC,cAAc;IAatB,mFAAmF;IACnF,OAAO,CAAC,cAAc;IAqBtB,wBAAwB;IACxB,OAAO,CAAC,aAAa;IAMrB,4FAA4F;IAC5E,cAAc,IAAI,MAAM,GAAG,IAAI;IAI/C;;;;OAIG;IACa,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAIxC,OAAO,IAAI,IAAI;IAO/B,sFAAsF;IACtF,OAAO,CAAC,IAAI;IAIZ;;;OAGG;IACH,OAAO,CAAC,IAAI;CAKb;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CAE/C"}
|
|
@@ -5,7 +5,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { RegisterClass } from '@memberjunction/global';
|
|
8
|
-
import {
|
|
8
|
+
import { REALTIME_CHANNEL_CONTRACT_VERSION } from '@memberjunction/ai-core-plus';
|
|
9
|
+
import { BaseRealtimeChannelClient, BuildToolBackedVerbs } from '@memberjunction/realtime-runtime';
|
|
9
10
|
import { MEDIA_TOOL_DEFINITIONS, MEDIA_TOOL_NAMES, MEDIA_TOOL_PREFIX } from './media-channel-tools';
|
|
10
11
|
import { MediaChannelState } from './media-channel-state';
|
|
11
12
|
import { RealtimeMediaSurfaceComponent } from './realtime-media-surface.component';
|
|
@@ -59,6 +60,32 @@ let RealtimeMediaChannel = class RealtimeMediaChannel extends BaseRealtimeChanne
|
|
|
59
60
|
GetToolDefinitions() {
|
|
60
61
|
return MEDIA_TOOL_DEFINITIONS;
|
|
61
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* The media surface's self-description: what it holds, and every `Media_*` tool as a verb (so a tool a
|
|
65
|
+
* subclass adds shows up here too). The model reads its state (what is on screen) but is never shown
|
|
66
|
+
* pixels of it, so its exposure ceiling is `state`.
|
|
67
|
+
*/
|
|
68
|
+
GetDescriptor() {
|
|
69
|
+
return {
|
|
70
|
+
Key: this.ChannelName,
|
|
71
|
+
Version: REALTIME_CHANNEL_CONTRACT_VERSION,
|
|
72
|
+
DisplayName: this.TabTitle,
|
|
73
|
+
OwningPackage: '@memberjunction/ng-conversations',
|
|
74
|
+
Instructions: 'A shared surface where you can show the user images, videos, audio clips, PDFs and web pages. ' +
|
|
75
|
+
'Each item opens in its own tab; you can switch between them and highlight a region to point at it.',
|
|
76
|
+
Nouns: [
|
|
77
|
+
{
|
|
78
|
+
Name: 'items',
|
|
79
|
+
Description: 'The media items currently shared, each with its type, title and source.',
|
|
80
|
+
Schema: { type: 'array', items: { type: 'object' } }
|
|
81
|
+
}
|
|
82
|
+
],
|
|
83
|
+
Verbs: BuildToolBackedVerbs(this.GetToolDefinitions(), this.ToolNamePrefix),
|
|
84
|
+
DisplayPolicy: 'open-on-start',
|
|
85
|
+
DefaultAvailability: 'all-sessions',
|
|
86
|
+
MaxExposure: 'state'
|
|
87
|
+
};
|
|
88
|
+
}
|
|
62
89
|
GetSurfaceComponent() {
|
|
63
90
|
return RealtimeMediaSurfaceComponent;
|
|
64
91
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media-channel.js","sourceRoot":"","sources":["../../../../../src/lib/components/realtime/media/media-channel.ts"],"names":[],"mappings":";;;;;;AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAE7E,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACpG,OAAO,EAAE,iBA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AE,KAAK,EAAE,CAAC,CAAC;IACnD,CAAC;IAED;;;OAGG;IACK,IAAI,CAAC,OAAe;QAC1B,IAAI,CAAC,OAAO,EAAE,eAAe,CAC3B,WAAW,OAAO,mFAAmF,CACtG,CAAC;IACJ,CAAC;CACF,CAAA;AAjOY,oBAAoB;IADhC,aAAa,CAAC,yBAAyB,EAAE,sBAAsB,CAAC;GACpD,oBAAoB,CAiOhC;;AAED;;;;GAIG;AACH,MAAM,UAAU,wBAAwB;IACtC,uEAAuE;AACzE,CAAC","sourcesContent":["import type { Type } from '@angular/core';\nimport { Subscription } from 'rxjs';\nimport { RegisterClass } from '@memberjunction/global';\nimport { RealtimeToolDefinition } from '@memberjunction/ai';\nimport { BaseRealtimeChannelClient } from '@memberjunction/realtime-runtime';\nimport { ChannelOnboardingDetails } from '@memberjunction/realtime-runtime';\nimport { MEDIA_TOOL_DEFINITIONS, MEDIA_TOOL_NAMES, MEDIA_TOOL_PREFIX } from './media-channel-tools';\nimport { MediaChannelState, MediaHighlight, MediaItemType } from './media-channel-state';\nimport { RealtimeMediaSurfaceComponent } from './realtime-media-surface.component';\n\n/** A JSON-serializable value (the building block of a parsed tool-args object). */\ntype ToolArgValue = string | number | boolean | null | ToolArgValue[] | { [key: string]: ToolArgValue };\n\n/** Coerces a parsed arg to a non-empty string, or `undefined` when absent / wrong-typed. */\nfunction asString(value: ToolArgValue | undefined): string | undefined {\n return typeof value === 'string' && value.length > 0 ? value : undefined;\n}\n\n/** Coerces a parsed arg to a finite number, or `undefined` when absent / wrong-typed. */\nfunction asNumber(value: ToolArgValue | undefined): number | undefined {\n return typeof value === 'number' && Number.isFinite(value) ? value : undefined;\n}\n\n/** The media types `Media_ShowMedia` accepts (validated before mutating state). */\nconst VALID_MEDIA_TYPES: MediaItemType[] = ['image', 'video', 'audio', 'pdf', 'web'];\n\n/**\n * The shared MEDIA SURFACE as a pluggable interactive channel — a {@link BaseRealtimeChannelClient}\n * resolved from the `MJ: AI Agent Channels` registry row whose `ClientPluginClass` is\n * `'RealtimeMediaChannel'`. One instance per session (created via ClassFactory at session start).\n *\n * It owns a {@link MediaChannelState} engine and contributes the channel's full contract:\n *\n * - **Action**: the `Media_*` client-executed tool set ({@link MEDIA_TOOL_DEFINITIONS});\n * {@link ApplyAgentTool} parses the args, mutates the state engine, returns a short JSON result\n * string, and sends the model a `[media]` background context note (so it stays aware of what's\n * on screen). Works with NO surface bound — the tools mutate the state engine directly.\n * - **Surface**: {@link RealtimeMediaSurfaceComponent}, created dynamically by the overlay's\n * channel tab; {@link BindSurface} hands it the shared state engine + agent name.\n * - **State of record**: every mutation requests a debounced save of {@link MediaChannelState.ToJSON}\n * under channel name `'Media'`; a prior session's media is rehydrated via {@link RestoreState}.\n *\n * Modeled directly on `RealtimeWhiteboardChannel`.\n */\n@RegisterClass(BaseRealtimeChannelClient, 'RealtimeMediaChannel')\nexport class RealtimeMediaChannel extends BaseRealtimeChannelClient<RealtimeMediaSurfaceComponent> {\n /** The media state of record — created fresh with the plugin (one per session). */\n public readonly State = new MediaChannelState();\n\n /** The live bound surface, when the channel tab's pane is instantiated. */\n private surface: RealtimeMediaSurfaceComponent | null = null;\n /** Media-mutation subscription driving the debounced state-of-record save. */\n private stateChangedSub: Subscription | null = null;\n\n public get ChannelName(): string {\n return 'Media';\n }\n\n public get ToolNamePrefix(): string {\n return MEDIA_TOOL_PREFIX;\n }\n\n public get TabTitle(): string {\n return 'Media';\n }\n\n public get TabIcon(): string {\n return 'fa-solid fa-images';\n }\n\n public GetToolDefinitions(): RealtimeToolDefinition[] {\n return MEDIA_TOOL_DEFINITIONS;\n }\n\n public override GetSurfaceComponent(): Type<RealtimeMediaSurfaceComponent> {\n return RealtimeMediaSurfaceComponent;\n }\n\n /** First-run intro shown the first time the user opens the Media tab (once per user). */\n public override GetOnboardingDetails(): ChannelOnboardingDetails {\n return {\n Heading: 'Media',\n Description:\n 'A shared surface where the agent can show you visuals during the call — images, videos, ' +\n 'audio clips, PDFs and web pages. Each item opens in its own tab; the agent can switch ' +\n 'between them and highlight regions to point at exactly what it means.',\n Tips: [\n 'Switch between shared items using the tabs along the top.',\n 'The agent can highlight part of an image or page to draw your eye to it.',\n 'Open any item in a new browser tab or download it from the toolbar.',\n ],\n IconClass: 'fa-solid fa-images',\n };\n }\n\n /** Persist the media surface (host-debounced) on EVERY mutation — agent tools and tab changes. */\n protected override OnInitialize(): void {\n this.stateChangedSub = this.State.Changed$.subscribe(() => {\n this.Context?.RequestSave(this.State.ToJSON());\n });\n }\n\n /**\n * Wires the dynamically-created media surface (before first CD): shared state engine + agent name,\n * plus the live session's MJ provider so FileID-backed items stream securely (mj-storage-media-player\n * + CreateMediaAccessToken) under the SAME authenticated, multi-provider-safe provider.\n */\n public BindSurface(instance: RealtimeMediaSurfaceComponent): void {\n this.surface = instance;\n instance.State = this.State;\n instance.AgentName = this.Context?.AgentName ?? 'The agent';\n instance.Provider = this.Context?.Provider ?? null;\n }\n\n public override UnbindSurface(): void {\n this.surface = null;\n }\n\n /**\n * Executes one `Media_*` tool call LOCALLY: parse args, mutate the state engine, push a `[media]`\n * background context note so the agent stays aware of the surface, and return a short JSON result\n * string for the model. Never throws — malformed args resolve to a `{ success: false, error }`\n * payload the model can narrate. Works with or without a bound surface (it mutates the state engine,\n * which the surface observes).\n */\n public ApplyAgentTool(toolName: string, argsJson: string): string {\n let args: Record<string, ToolArgValue> = {};\n try {\n const parsed = argsJson ? (JSON.parse(argsJson) as unknown) : {};\n if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {\n args = parsed as Record<string, ToolArgValue>;\n }\n } catch {\n return this.fail(`Could not parse arguments for ${toolName}.`);\n }\n\n switch (toolName) {\n case MEDIA_TOOL_NAMES.ShowMedia:\n return this.applyShowMedia(args);\n case MEDIA_TOOL_NAMES.CloseMedia:\n return this.applyCloseMedia(args);\n case MEDIA_TOOL_NAMES.PlayMedia:\n return this.applyPlayMedia(args);\n case MEDIA_TOOL_NAMES.Highlight:\n return this.applyHighlight(args);\n case MEDIA_TOOL_NAMES.ClearAll:\n return this.applyClearAll();\n default:\n return this.fail(`Unknown Media tool \"${toolName}\".`);\n }\n }\n\n /** Adds a media item and makes it active. Source is a public `url` OR an MJStorage `fileId` (>=1 required). */\n private applyShowMedia(args: Record<string, ToolArgValue>): string {\n const mediaType = asString(args['mediaType']);\n const url = asString(args['url']);\n const fileId = asString(args['fileId']);\n const displayName = asString(args['displayName']);\n if (!mediaType || !VALID_MEDIA_TYPES.includes(mediaType as MediaItemType)) {\n return this.fail('Media_ShowMedia requires a \"mediaType\" of image | video | audio | pdf | web.');\n }\n if (!url && !fileId) {\n return this.fail('Media_ShowMedia requires a source — provide a \"url\" (external/public) OR a \"fileId\" (an MJ: Files id).');\n }\n if (!displayName) {\n return this.fail('Media_ShowMedia requires a \"displayName\".');\n }\n const item = this.State.AddItem({\n Type: mediaType as MediaItemType,\n Url: url,\n FileID: fileId,\n DisplayName: displayName,\n Caption: asString(args['caption']),\n });\n this.note(`now showing ${mediaType} \"${displayName}\"`);\n return JSON.stringify({ success: true, id: item.Id, active: true });\n }\n\n /** Closes a media item. */\n private applyCloseMedia(args: Record<string, ToolArgValue>): string {\n const id = asString(args['id']);\n if (!id) {\n return this.fail('Media_CloseMedia requires an \"id\".');\n }\n const removed = this.State.RemoveItem(id);\n if (!removed) {\n return this.fail(`No media item with id \"${id}\".`);\n }\n this.note(`closed media item \"${id}\"`);\n return JSON.stringify({ success: true, id });\n }\n\n /** Activates + requests playback of a media item. */\n private applyPlayMedia(args: Record<string, ToolArgValue>): string {\n const id = asString(args['id']);\n if (!id) {\n return this.fail('Media_PlayMedia requires an \"id\".');\n }\n const ok = this.State.RequestPlay(id);\n if (!ok) {\n return this.fail(`No media item with id \"${id}\".`);\n }\n this.note(`playing media item \"${id}\"`);\n return JSON.stringify({ success: true, id });\n }\n\n /** Draws (or, with absent dims, clears) a fractional highlight on a media item. */\n private applyHighlight(args: Record<string, ToolArgValue>): string {\n const id = asString(args['id']);\n if (!id) {\n return this.fail('Media_Highlight requires an \"id\".');\n }\n const x = asNumber(args['x']);\n const y = asNumber(args['y']);\n const w = asNumber(args['w']);\n const h = asNumber(args['h']);\n if (x === undefined || y === undefined || w === undefined || h === undefined) {\n return this.fail('Media_Highlight requires numeric fractional x, y, w, h (0..1).');\n }\n const highlight: MediaHighlight = { X: x, Y: y, W: w, H: h, Label: asString(args['label']) };\n const ok = this.State.Highlight(id, highlight);\n if (!ok) {\n return this.fail(`No media item with id \"${id}\".`);\n }\n this.note(`highlighted a region of media item \"${id}\"`);\n return JSON.stringify({ success: true, id });\n }\n\n /** Clears all media. */\n private applyClearAll(): string {\n this.State.Clear();\n this.note('cleared all media');\n return JSON.stringify({ success: true });\n }\n\n /** The Media channel's serialized state of record (persisted under {@link ChannelName}). */\n public override SerializeState(): string | null {\n return this.State.ToJSON();\n }\n\n /**\n * Rehydrates a prior session's saved media into THIS session's state engine (in place — the\n * {@link State} instance and its subscriptions are preserved). Tolerant: malformed JSON returns\n * `false` and the surface stays empty.\n */\n public override RestoreState(stateJson: string): boolean {\n return this.State.LoadFromJSON(stateJson);\n }\n\n public override Dispose(): void {\n this.stateChangedSub?.unsubscribe();\n this.stateChangedSub = null;\n this.surface = null;\n super.Dispose();\n }\n\n /** Builds a model-readable failure payload (never thrown — returned to the model). */\n private fail(error: string): string {\n return JSON.stringify({ success: false, error });\n }\n\n /**\n * Pushes a background context note so the agent stays aware of the surface state. Framed as\n * background (like the whiteboard's scene-delta notes) so the model doesn't narrate every change.\n */\n private note(summary: string): void {\n this.Context?.SendContextNote(\n `[media] ${summary} (background context — do NOT narrate routine changes; mention only if relevant).`,\n );\n }\n}\n\n/**\n * Tree-shaking prevention: the Media channel is resolved dynamically through the ClassFactory (by the\n * registry row's `ClientPluginClass` key), so this static call keeps its `@RegisterClass` side effect\n * from being eliminated by the bundler. Called alongside `LoadRealtimeWhiteboardChannel()`.\n */\nexport function LoadRealtimeMediaChannel(): void {\n // intentional no-op — the import side effect performs the registration\n}\n"]}
|
|
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ACH,MAAM,UAAU,wBAAwB;IACtC,uEAAuE;AACzE,CAAC","sourcesContent":["import type { Type } from '@angular/core';\nimport { Subscription } from 'rxjs';\nimport { RegisterClass } from '@memberjunction/global';\nimport { RealtimeToolDefinition } from '@memberjunction/ai';\nimport { REALTIME_CHANNEL_CONTRACT_VERSION, type RealtimeChannelDescriptor } from '@memberjunction/ai-core-plus';\nimport { BaseRealtimeChannelClient, BuildToolBackedVerbs } from '@memberjunction/realtime-runtime';\nimport { ChannelOnboardingDetails } from '@memberjunction/realtime-runtime';\nimport { MEDIA_TOOL_DEFINITIONS, MEDIA_TOOL_NAMES, MEDIA_TOOL_PREFIX } from './media-channel-tools';\nimport { MediaChannelState, MediaHighlight, MediaItemType } from './media-channel-state';\nimport { RealtimeMediaSurfaceComponent } from './realtime-media-surface.component';\n\n/** A JSON-serializable value (the building block of a parsed tool-args object). */\ntype ToolArgValue = string | number | boolean | null | ToolArgValue[] | { [key: string]: ToolArgValue };\n\n/** Coerces a parsed arg to a non-empty string, or `undefined` when absent / wrong-typed. */\nfunction asString(value: ToolArgValue | undefined): string | undefined {\n return typeof value === 'string' && value.length > 0 ? value : undefined;\n}\n\n/** Coerces a parsed arg to a finite number, or `undefined` when absent / wrong-typed. */\nfunction asNumber(value: ToolArgValue | undefined): number | undefined {\n return typeof value === 'number' && Number.isFinite(value) ? value : undefined;\n}\n\n/** The media types `Media_ShowMedia` accepts (validated before mutating state). */\nconst VALID_MEDIA_TYPES: MediaItemType[] = ['image', 'video', 'audio', 'pdf', 'web'];\n\n/**\n * The shared MEDIA SURFACE as a pluggable interactive channel — a {@link BaseRealtimeChannelClient}\n * resolved from the `MJ: AI Agent Channels` registry row whose `ClientPluginClass` is\n * `'RealtimeMediaChannel'`. One instance per session (created via ClassFactory at session start).\n *\n * It owns a {@link MediaChannelState} engine and contributes the channel's full contract:\n *\n * - **Action**: the `Media_*` client-executed tool set ({@link MEDIA_TOOL_DEFINITIONS});\n * {@link ApplyAgentTool} parses the args, mutates the state engine, returns a short JSON result\n * string, and sends the model a `[media]` background context note (so it stays aware of what's\n * on screen). Works with NO surface bound — the tools mutate the state engine directly.\n * - **Surface**: {@link RealtimeMediaSurfaceComponent}, created dynamically by the overlay's\n * channel tab; {@link BindSurface} hands it the shared state engine + agent name.\n * - **State of record**: every mutation requests a debounced save of {@link MediaChannelState.ToJSON}\n * under channel name `'Media'`; a prior session's media is rehydrated via {@link RestoreState}.\n *\n * Modeled directly on `RealtimeWhiteboardChannel`.\n */\n@RegisterClass(BaseRealtimeChannelClient, 'RealtimeMediaChannel')\nexport class RealtimeMediaChannel extends BaseRealtimeChannelClient<RealtimeMediaSurfaceComponent> {\n /** The media state of record — created fresh with the plugin (one per session). */\n public readonly State = new MediaChannelState();\n\n /** The live bound surface, when the channel tab's pane is instantiated. */\n private surface: RealtimeMediaSurfaceComponent | null = null;\n /** Media-mutation subscription driving the debounced state-of-record save. */\n private stateChangedSub: Subscription | null = null;\n\n public get ChannelName(): string {\n return 'Media';\n }\n\n public get ToolNamePrefix(): string {\n return MEDIA_TOOL_PREFIX;\n }\n\n public get TabTitle(): string {\n return 'Media';\n }\n\n public get TabIcon(): string {\n return 'fa-solid fa-images';\n }\n\n public GetToolDefinitions(): RealtimeToolDefinition[] {\n return MEDIA_TOOL_DEFINITIONS;\n }\n\n /**\n * The media surface's self-description: what it holds, and every `Media_*` tool as a verb (so a tool a\n * subclass adds shows up here too). The model reads its state (what is on screen) but is never shown\n * pixels of it, so its exposure ceiling is `state`.\n */\n public override GetDescriptor(): RealtimeChannelDescriptor {\n return {\n Key: this.ChannelName,\n Version: REALTIME_CHANNEL_CONTRACT_VERSION,\n DisplayName: this.TabTitle,\n OwningPackage: '@memberjunction/ng-conversations',\n Instructions:\n 'A shared surface where you can show the user images, videos, audio clips, PDFs and web pages. ' +\n 'Each item opens in its own tab; you can switch between them and highlight a region to point at it.',\n Nouns: [\n {\n Name: 'items',\n Description: 'The media items currently shared, each with its type, title and source.',\n Schema: { type: 'array', items: { type: 'object' } }\n }\n ],\n Verbs: BuildToolBackedVerbs(this.GetToolDefinitions(), this.ToolNamePrefix),\n DisplayPolicy: 'open-on-start',\n DefaultAvailability: 'all-sessions',\n MaxExposure: 'state'\n };\n }\n\n public override GetSurfaceComponent(): Type<RealtimeMediaSurfaceComponent> {\n return RealtimeMediaSurfaceComponent;\n }\n\n /** First-run intro shown the first time the user opens the Media tab (once per user). */\n public override GetOnboardingDetails(): ChannelOnboardingDetails {\n return {\n Heading: 'Media',\n Description:\n 'A shared surface where the agent can show you visuals during the call — images, videos, ' +\n 'audio clips, PDFs and web pages. Each item opens in its own tab; the agent can switch ' +\n 'between them and highlight regions to point at exactly what it means.',\n Tips: [\n 'Switch between shared items using the tabs along the top.',\n 'The agent can highlight part of an image or page to draw your eye to it.',\n 'Open any item in a new browser tab or download it from the toolbar.',\n ],\n IconClass: 'fa-solid fa-images',\n };\n }\n\n /** Persist the media surface (host-debounced) on EVERY mutation — agent tools and tab changes. */\n protected override OnInitialize(): void {\n this.stateChangedSub = this.State.Changed$.subscribe(() => {\n this.Context?.RequestSave(this.State.ToJSON());\n });\n }\n\n /**\n * Wires the dynamically-created media surface (before first CD): shared state engine + agent name,\n * plus the live session's MJ provider so FileID-backed items stream securely (mj-storage-media-player\n * + CreateMediaAccessToken) under the SAME authenticated, multi-provider-safe provider.\n */\n public BindSurface(instance: RealtimeMediaSurfaceComponent): void {\n this.surface = instance;\n instance.State = this.State;\n instance.AgentName = this.Context?.AgentName ?? 'The agent';\n instance.Provider = this.Context?.Provider ?? null;\n }\n\n public override UnbindSurface(): void {\n this.surface = null;\n }\n\n /**\n * Executes one `Media_*` tool call LOCALLY: parse args, mutate the state engine, push a `[media]`\n * background context note so the agent stays aware of the surface, and return a short JSON result\n * string for the model. Never throws — malformed args resolve to a `{ success: false, error }`\n * payload the model can narrate. Works with or without a bound surface (it mutates the state engine,\n * which the surface observes).\n */\n public ApplyAgentTool(toolName: string, argsJson: string): string {\n let args: Record<string, ToolArgValue> = {};\n try {\n const parsed = argsJson ? (JSON.parse(argsJson) as unknown) : {};\n if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {\n args = parsed as Record<string, ToolArgValue>;\n }\n } catch {\n return this.fail(`Could not parse arguments for ${toolName}.`);\n }\n\n switch (toolName) {\n case MEDIA_TOOL_NAMES.ShowMedia:\n return this.applyShowMedia(args);\n case MEDIA_TOOL_NAMES.CloseMedia:\n return this.applyCloseMedia(args);\n case MEDIA_TOOL_NAMES.PlayMedia:\n return this.applyPlayMedia(args);\n case MEDIA_TOOL_NAMES.Highlight:\n return this.applyHighlight(args);\n case MEDIA_TOOL_NAMES.ClearAll:\n return this.applyClearAll();\n default:\n return this.fail(`Unknown Media tool \"${toolName}\".`);\n }\n }\n\n /** Adds a media item and makes it active. Source is a public `url` OR an MJStorage `fileId` (>=1 required). */\n private applyShowMedia(args: Record<string, ToolArgValue>): string {\n const mediaType = asString(args['mediaType']);\n const url = asString(args['url']);\n const fileId = asString(args['fileId']);\n const displayName = asString(args['displayName']);\n if (!mediaType || !VALID_MEDIA_TYPES.includes(mediaType as MediaItemType)) {\n return this.fail('Media_ShowMedia requires a \"mediaType\" of image | video | audio | pdf | web.');\n }\n if (!url && !fileId) {\n return this.fail('Media_ShowMedia requires a source — provide a \"url\" (external/public) OR a \"fileId\" (an MJ: Files id).');\n }\n if (!displayName) {\n return this.fail('Media_ShowMedia requires a \"displayName\".');\n }\n const item = this.State.AddItem({\n Type: mediaType as MediaItemType,\n Url: url,\n FileID: fileId,\n DisplayName: displayName,\n Caption: asString(args['caption']),\n });\n this.note(`now showing ${mediaType} \"${displayName}\"`);\n return JSON.stringify({ success: true, id: item.Id, active: true });\n }\n\n /** Closes a media item. */\n private applyCloseMedia(args: Record<string, ToolArgValue>): string {\n const id = asString(args['id']);\n if (!id) {\n return this.fail('Media_CloseMedia requires an \"id\".');\n }\n const removed = this.State.RemoveItem(id);\n if (!removed) {\n return this.fail(`No media item with id \"${id}\".`);\n }\n this.note(`closed media item \"${id}\"`);\n return JSON.stringify({ success: true, id });\n }\n\n /** Activates + requests playback of a media item. */\n private applyPlayMedia(args: Record<string, ToolArgValue>): string {\n const id = asString(args['id']);\n if (!id) {\n return this.fail('Media_PlayMedia requires an \"id\".');\n }\n const ok = this.State.RequestPlay(id);\n if (!ok) {\n return this.fail(`No media item with id \"${id}\".`);\n }\n this.note(`playing media item \"${id}\"`);\n return JSON.stringify({ success: true, id });\n }\n\n /** Draws (or, with absent dims, clears) a fractional highlight on a media item. */\n private applyHighlight(args: Record<string, ToolArgValue>): string {\n const id = asString(args['id']);\n if (!id) {\n return this.fail('Media_Highlight requires an \"id\".');\n }\n const x = asNumber(args['x']);\n const y = asNumber(args['y']);\n const w = asNumber(args['w']);\n const h = asNumber(args['h']);\n if (x === undefined || y === undefined || w === undefined || h === undefined) {\n return this.fail('Media_Highlight requires numeric fractional x, y, w, h (0..1).');\n }\n const highlight: MediaHighlight = { X: x, Y: y, W: w, H: h, Label: asString(args['label']) };\n const ok = this.State.Highlight(id, highlight);\n if (!ok) {\n return this.fail(`No media item with id \"${id}\".`);\n }\n this.note(`highlighted a region of media item \"${id}\"`);\n return JSON.stringify({ success: true, id });\n }\n\n /** Clears all media. */\n private applyClearAll(): string {\n this.State.Clear();\n this.note('cleared all media');\n return JSON.stringify({ success: true });\n }\n\n /** The Media channel's serialized state of record (persisted under {@link ChannelName}). */\n public override SerializeState(): string | null {\n return this.State.ToJSON();\n }\n\n /**\n * Rehydrates a prior session's saved media into THIS session's state engine (in place — the\n * {@link State} instance and its subscriptions are preserved). Tolerant: malformed JSON returns\n * `false` and the surface stays empty.\n */\n public override RestoreState(stateJson: string): boolean {\n return this.State.LoadFromJSON(stateJson);\n }\n\n public override Dispose(): void {\n this.stateChangedSub?.unsubscribe();\n this.stateChangedSub = null;\n this.surface = null;\n super.Dispose();\n }\n\n /** Builds a model-readable failure payload (never thrown — returned to the model). */\n private fail(error: string): string {\n return JSON.stringify({ success: false, error });\n }\n\n /**\n * Pushes a background context note so the agent stays aware of the surface state. Framed as\n * background (like the whiteboard's scene-delta notes) so the model doesn't narrate every change.\n */\n private note(summary: string): void {\n this.Context?.SendContextNote(\n `[media] ${summary} (background context — do NOT narrate routine changes; mention only if relevant).`,\n );\n }\n}\n\n/**\n * Tree-shaking prevention: the Media channel is resolved dynamically through the ClassFactory (by the\n * registry row's `ClientPluginClass` key), so this static call keeps its `@RegisterClass` side effect\n * from being eliminated by the bundler. Called alongside `LoadRealtimeWhiteboardChannel()`.\n */\nexport function LoadRealtimeMediaChannel(): void {\n // intentional no-op — the import side effect performs the registration\n}\n"]}
|
|
@@ -35,6 +35,11 @@ export declare class RealtimeAgentBannerComponent {
|
|
|
35
35
|
Compact: boolean;
|
|
36
36
|
/** Display name of the agent the voice session fronts (e.g. "Sage"). */
|
|
37
37
|
AgentName: string;
|
|
38
|
+
/**
|
|
39
|
+
* What the state label says in the `'error'` state when the call said why it ended (`DescribeCallEnd`'s `Label`, such
|
|
40
|
+
* as "Time limit reached"); `null` keeps "Connection error".
|
|
41
|
+
*/
|
|
42
|
+
ErrorLabel: string | null;
|
|
38
43
|
/**
|
|
39
44
|
* Display name of the realtime model the live session runs on (e.g. "GPT Realtime 2").
|
|
40
45
|
* Rendered as a subtle suffix in the identity line; hidden when null/empty.
|
|
@@ -67,6 +72,8 @@ export declare class RealtimeAgentBannerComponent {
|
|
|
67
72
|
ShowDensityPicker: boolean;
|
|
68
73
|
/** Whether the Minimize control renders (live sessions only). */
|
|
69
74
|
ShowMinimize: boolean;
|
|
75
|
+
/** Review only: whether the "Start live session" action renders. */
|
|
76
|
+
ShowStartLive: boolean;
|
|
70
77
|
/** The user's current interface-density override (selected state in the gear popover). */
|
|
71
78
|
Density: RealtimeUxDensity;
|
|
72
79
|
/** Emitted with the session record's ID when the dev "Open session" link is clicked. */
|
|
@@ -113,6 +120,6 @@ export declare class RealtimeAgentBannerComponent {
|
|
|
113
120
|
/** True while the state pill should show a spinner instead of the waveform. */
|
|
114
121
|
IsBusy(state: RealtimeConnectionState): boolean;
|
|
115
122
|
static ɵfac: i0.ɵɵFactoryDeclaration<RealtimeAgentBannerComponent, never>;
|
|
116
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<RealtimeAgentBannerComponent, "mj-realtime-agent-banner", never, { "State": { "alias": "State"; "required": true; }; "Compact": { "alias": "Compact"; "required": false; }; "AgentName": { "alias": "AgentName"; "required": false; }; "ModelName": { "alias": "ModelName"; "required": false; }; "DevMode": { "alias": "DevMode"; "required": false; }; "SessionID": { "alias": "SessionID"; "required": false; }; "ReviewMode": { "alias": "ReviewMode"; "required": false; }; "ReviewStartedAt": { "alias": "ReviewStartedAt"; "required": false; }; "ReviewClosedAt": { "alias": "ReviewClosedAt"; "required": false; }; "ReviewCloseReason": { "alias": "ReviewCloseReason"; "required": false; }; "ShowGear": { "alias": "ShowGear"; "required": false; }; "ShowDensityPicker": { "alias": "ShowDensityPicker"; "required": false; }; "ShowMinimize": { "alias": "ShowMinimize"; "required": false; }; "Density": { "alias": "Density"; "required": false; }; }, { "OpenSessionRequested": "OpenSessionRequested"; "DevModeToggled": "DevModeToggled"; "DensityChanged": "DensityChanged"; "MinimizeRequested": "MinimizeRequested"; "StartLiveRequested": "StartLiveRequested"; "CloseRequested": "CloseRequested"; }, never, never, true, never>;
|
|
123
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<RealtimeAgentBannerComponent, "mj-realtime-agent-banner", never, { "State": { "alias": "State"; "required": true; }; "Compact": { "alias": "Compact"; "required": false; }; "AgentName": { "alias": "AgentName"; "required": false; }; "ErrorLabel": { "alias": "ErrorLabel"; "required": false; }; "ModelName": { "alias": "ModelName"; "required": false; }; "DevMode": { "alias": "DevMode"; "required": false; }; "SessionID": { "alias": "SessionID"; "required": false; }; "ReviewMode": { "alias": "ReviewMode"; "required": false; }; "ReviewStartedAt": { "alias": "ReviewStartedAt"; "required": false; }; "ReviewClosedAt": { "alias": "ReviewClosedAt"; "required": false; }; "ReviewCloseReason": { "alias": "ReviewCloseReason"; "required": false; }; "ShowGear": { "alias": "ShowGear"; "required": false; }; "ShowDensityPicker": { "alias": "ShowDensityPicker"; "required": false; }; "ShowMinimize": { "alias": "ShowMinimize"; "required": false; }; "ShowStartLive": { "alias": "ShowStartLive"; "required": false; }; "Density": { "alias": "Density"; "required": false; }; }, { "OpenSessionRequested": "OpenSessionRequested"; "DevModeToggled": "DevModeToggled"; "DensityChanged": "DensityChanged"; "MinimizeRequested": "MinimizeRequested"; "StartLiveRequested": "StartLiveRequested"; "CloseRequested": "CloseRequested"; }, never, never, true, never>;
|
|
117
124
|
}
|
|
118
125
|
//# sourceMappingURL=realtime-agent-banner.component.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"realtime-agent-banner.component.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/realtime/realtime-agent-banner.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,YAAY,EAA+B,MAAM,eAAe,CAAC;AAErF,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;;AAE1D;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAOa,4BAA4B;IACvC,gFAAgF;IACrD,KAAK,EAAG,uBAAuB,CAAC;IAE3D;;;;;;;OAOG;IACM,OAAO,UAAS;IAEzB,wEAAwE;IAC/D,SAAS,SAAe;IAEjC;;;OAGG;IACM,SAAS,EAAE,MAAM,GAAG,IAAI,CAAQ;IAEzC,yFAAyF;IAChF,OAAO,UAAS;IAEzB,wFAAwF;IAC/E,SAAS,EAAE,MAAM,GAAG,IAAI,CAAQ;IAEzC;;;;OAIG;IACM,UAAU,UAAS;IAE5B,wEAAwE;IAC/D,eAAe,EAAE,IAAI,GAAG,IAAI,CAAQ;IAE7C,kFAAkF;IACzE,cAAc,EAAE,IAAI,GAAG,IAAI,CAAQ;IAE5C,+GAA+G;IACtG,iBAAiB,EAAE,MAAM,GAAG,I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;
|
|
1
|
+
{"version":3,"file":"realtime-agent-banner.component.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/realtime/realtime-agent-banner.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,YAAY,EAA+B,MAAM,eAAe,CAAC;AAErF,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;;AAE1D;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAOa,4BAA4B;IACvC,gFAAgF;IACrD,KAAK,EAAG,uBAAuB,CAAC;IAE3D;;;;;;;OAOG;IACM,OAAO,UAAS;IAEzB,wEAAwE;IAC/D,SAAS,SAAe;IAEjC;;;OAGG;IACM,UAAU,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE1C;;;OAGG;IACM,SAAS,EAAE,MAAM,GAAG,IAAI,CAAQ;IAEzC,yFAAyF;IAChF,OAAO,UAAS;IAEzB,wFAAwF;IAC/E,SAAS,EAAE,MAAM,GAAG,IAAI,CAAQ;IAEzC;;;;OAIG;IACM,UAAU,UAAS;IAE5B,wEAAwE;IAC/D,eAAe,EAAE,IAAI,GAAG,IAAI,CAAQ;IAE7C,kFAAkF;IACzE,cAAc,EAAE,IAAI,GAAG,IAAI,CAAQ;IAE5C,+GAA+G;IACtG,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAQ;IAMjD,0FAA0F;IACjF,QAAQ,UAAS;IAE1B;;;;;OAKG;IACM,iBAAiB,UAAQ;IAElC,iEAAiE;IACxD,YAAY,UAAS;IAE9B,oEAAoE;IAC3D,aAAa,UAAQ;IAE9B,0FAA0F;IACjF,OAAO,EAAE,iBAAiB,CAAU;IAE7C,wFAAwF;IAC9E,oBAAoB,uBAA8B;IAE5D,2EAA2E;IACjE,cAAc,wBAA+B;IAEvD,4EAA4E;IAClE,cAAc,kCAAyC;IAEjE,2EAA2E;IACjE,iBAAiB,qBAA4B;IAEvD,qFAAqF;IAC3E,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