@memberjunction/ng-conversations 6.2.2 → 6.3.0-edge.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 +49 -24
- package/dist/assets/edge-ai.worker.js +32515 -0
- package/dist/lib/components/artifact/artifact-share-modal.component.d.ts +39 -6
- package/dist/lib/components/artifact/artifact-share-modal.component.d.ts.map +1 -1
- package/dist/lib/components/artifact/artifact-share-modal.component.js +620 -74
- package/dist/lib/components/artifact/artifact-share-modal.component.js.map +1 -1
- package/dist/lib/components/collection/artifact-create-modal.component.js +4 -4
- package/dist/lib/components/collection/artifact-create-modal.component.js.map +1 -1
- package/dist/lib/components/collection/collection-form-modal.component.js +3 -3
- package/dist/lib/components/collection/collection-form-modal.component.js.map +1 -1
- package/dist/lib/components/collection/collection-tree.component.d.ts.map +1 -1
- package/dist/lib/components/collection/collection-tree.component.js +19 -18
- package/dist/lib/components/collection/collection-tree.component.js.map +1 -1
- package/dist/lib/components/collection/collection-view.component.d.ts +6 -4
- package/dist/lib/components/collection/collection-view.component.d.ts.map +1 -1
- package/dist/lib/components/collection/collection-view.component.js +35 -17
- package/dist/lib/components/collection/collection-view.component.js.map +1 -1
- package/dist/lib/components/collection/collections-full-view.component.d.ts +1 -0
- package/dist/lib/components/collection/collections-full-view.component.d.ts.map +1 -1
- package/dist/lib/components/collection/collections-full-view.component.js +109 -107
- package/dist/lib/components/collection/collections-full-view.component.js.map +1 -1
- package/dist/lib/components/conversation/conversation-chat-area.component.d.ts +76 -11
- package/dist/lib/components/conversation/conversation-chat-area.component.d.ts.map +1 -1
- package/dist/lib/components/conversation/conversation-chat-area.component.js +236 -50
- package/dist/lib/components/conversation/conversation-chat-area.component.js.map +1 -1
- package/dist/lib/components/conversation/conversation-list.component.d.ts +49 -1
- package/dist/lib/components/conversation/conversation-list.component.d.ts.map +1 -1
- package/dist/lib/components/conversation/conversation-list.component.js +151 -41
- package/dist/lib/components/conversation/conversation-list.component.js.map +1 -1
- package/dist/lib/components/conversation/conversation-remote-browser-controller.d.ts +11 -3
- package/dist/lib/components/conversation/conversation-remote-browser-controller.d.ts.map +1 -1
- package/dist/lib/components/conversation/conversation-remote-browser-controller.js +40 -4
- package/dist/lib/components/conversation/conversation-remote-browser-controller.js.map +1 -1
- 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 +13 -2
- package/dist/lib/components/export/export-modal.component.js.map +1 -1
- package/dist/lib/components/library/library-create-dialog.component.d.ts +136 -0
- package/dist/lib/components/library/library-create-dialog.component.d.ts.map +1 -0
- package/dist/lib/components/library/library-create-dialog.component.js +1620 -0
- package/dist/lib/components/library/library-create-dialog.component.js.map +1 -0
- package/dist/lib/components/library/library-full-view.component.d.ts +10 -4
- package/dist/lib/components/library/library-full-view.component.d.ts.map +1 -1
- package/dist/lib/components/library/library-full-view.component.js +216 -40
- package/dist/lib/components/library/library-full-view.component.js.map +1 -1
- package/dist/lib/components/library/library-remote-drive-pane.component.d.ts +97 -0
- package/dist/lib/components/library/library-remote-drive-pane.component.d.ts.map +1 -0
- package/dist/lib/components/library/library-remote-drive-pane.component.js +1229 -0
- package/dist/lib/components/library/library-remote-drive-pane.component.js.map +1 -0
- package/dist/lib/components/library/library-workspace.component.d.ts +265 -0
- package/dist/lib/components/library/library-workspace.component.d.ts.map +1 -0
- package/dist/lib/components/library/library-workspace.component.js +4420 -0
- package/dist/lib/components/library/library-workspace.component.js.map +1 -0
- package/dist/lib/components/library/library.models.d.ts +162 -0
- package/dist/lib/components/library/library.models.d.ts.map +1 -0
- package/dist/lib/components/library/library.models.js +2 -0
- package/dist/lib/components/library/library.models.js.map +1 -0
- package/dist/lib/components/message/conversation-message-rating.component.d.ts +5 -0
- package/dist/lib/components/message/conversation-message-rating.component.d.ts.map +1 -1
- package/dist/lib/components/message/conversation-message-rating.component.js +72 -16
- package/dist/lib/components/message/conversation-message-rating.component.js.map +1 -1
- package/dist/lib/components/message/message-input.component.d.ts +26 -14
- package/dist/lib/components/message/message-input.component.d.ts.map +1 -1
- package/dist/lib/components/message/message-input.component.js +91 -56
- package/dist/lib/components/message/message-input.component.js.map +1 -1
- package/dist/lib/components/message/message-item.component.d.ts +35 -1
- package/dist/lib/components/message/message-item.component.d.ts.map +1 -1
- package/dist/lib/components/message/message-item.component.js +583 -392
- package/dist/lib/components/message/message-item.component.js.map +1 -1
- package/dist/lib/components/message/message-list.component.d.ts.map +1 -1
- package/dist/lib/components/message/message-list.component.js +2 -0
- package/dist/lib/components/message/message-list.component.js.map +1 -1
- package/dist/lib/components/navigation/conversation-navigation.component.js +9 -9
- package/dist/lib/components/navigation/conversation-navigation.component.js.map +1 -1
- package/dist/lib/components/overlay/chat-overlay.component.d.ts +94 -6
- package/dist/lib/components/overlay/chat-overlay.component.d.ts.map +1 -1
- package/dist/lib/components/overlay/chat-overlay.component.js +249 -59
- package/dist/lib/components/overlay/chat-overlay.component.js.map +1 -1
- package/dist/lib/components/project/project-form-modal.component.d.ts +6 -0
- package/dist/lib/components/project/project-form-modal.component.d.ts.map +1 -1
- package/dist/lib/components/project/project-form-modal.component.js +81 -61
- package/dist/lib/components/project/project-form-modal.component.js.map +1 -1
- package/dist/lib/components/project/project-selector.component.d.ts +5 -0
- package/dist/lib/components/project/project-selector.component.d.ts.map +1 -1
- package/dist/lib/components/project/project-selector.component.js +11 -4
- package/dist/lib/components/project/project-selector.component.js.map +1 -1
- package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-channel.d.ts +55 -0
- package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-channel.d.ts.map +1 -0
- package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-channel.js +944 -0
- package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-channel.js.map +1 -0
- package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-engine.d.ts +66 -0
- package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-engine.d.ts.map +1 -0
- package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-engine.js +253 -0
- package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-engine.js.map +1 -0
- package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-types.d.ts +80 -0
- package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-types.d.ts.map +1 -0
- package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-types.js +49 -0
- package/dist/lib/components/realtime/artifact-workspace/artifact-workspace-types.js.map +1 -0
- package/dist/lib/components/realtime/artifact-workspace/realtime-artifact-workspace-surface.component.d.ts +54 -0
- package/dist/lib/components/realtime/artifact-workspace/realtime-artifact-workspace-surface.component.d.ts.map +1 -0
- package/dist/lib/components/realtime/artifact-workspace/realtime-artifact-workspace-surface.component.js +386 -0
- package/dist/lib/components/realtime/artifact-workspace/realtime-artifact-workspace-surface.component.js.map +1 -0
- package/dist/lib/components/realtime/channels/client-context-channel.d.ts +20 -4
- package/dist/lib/components/realtime/channels/client-context-channel.d.ts.map +1 -1
- package/dist/lib/components/realtime/channels/client-context-channel.js +62 -8
- package/dist/lib/components/realtime/channels/client-context-channel.js.map +1 -1
- package/dist/lib/components/realtime/interactive-component/interactive-component-channel.d.ts +1 -0
- package/dist/lib/components/realtime/interactive-component/interactive-component-channel.d.ts.map +1 -1
- package/dist/lib/components/realtime/interactive-component/interactive-component-channel.js +15 -2
- package/dist/lib/components/realtime/interactive-component/interactive-component-channel.js.map +1 -1
- package/dist/lib/components/realtime/realtime-agent-banner.component.js +2 -2
- package/dist/lib/components/realtime/realtime-agent-banner.component.js.map +1 -1
- package/dist/lib/components/realtime/realtime-agent-picker.component.d.ts.map +1 -1
- package/dist/lib/components/realtime/realtime-agent-picker.component.js +3 -3
- package/dist/lib/components/realtime/realtime-agent-picker.component.js.map +1 -1
- package/dist/lib/components/realtime/realtime-composer.component.js +5 -3
- package/dist/lib/components/realtime/realtime-composer.component.js.map +1 -1
- package/dist/lib/components/realtime/realtime-session-overlay.component.d.ts +81 -32
- package/dist/lib/components/realtime/realtime-session-overlay.component.d.ts.map +1 -1
- package/dist/lib/components/realtime/realtime-session-overlay.component.js +506 -185
- package/dist/lib/components/realtime/realtime-session-overlay.component.js.map +1 -1
- package/dist/lib/components/realtime/realtime-session-thread.component.d.ts.map +1 -1
- package/dist/lib/components/realtime/realtime-session-thread.component.js +89 -4
- package/dist/lib/components/realtime/realtime-session-thread.component.js.map +1 -1
- package/dist/lib/components/realtime/realtime-surface-stage.model.d.ts.map +1 -1
- package/dist/lib/components/realtime/realtime-surface-stage.model.js +2 -1
- package/dist/lib/components/realtime/realtime-surface-stage.model.js.map +1 -1
- package/dist/lib/components/realtime/realtime-surface-tab-style.d.ts +4 -4
- package/dist/lib/components/realtime/realtime-surface-tab-style.d.ts.map +1 -1
- package/dist/lib/components/realtime/realtime-surface-tab-style.js +5 -5
- package/dist/lib/components/realtime/realtime-surface-tab-style.js.map +1 -1
- package/dist/lib/components/realtime/realtime-surface-tabs.model.d.ts +7 -9
- package/dist/lib/components/realtime/realtime-surface-tabs.model.d.ts.map +1 -1
- package/dist/lib/components/realtime/realtime-surface-tabs.model.js +12 -13
- package/dist/lib/components/realtime/realtime-surface-tabs.model.js.map +1 -1
- package/dist/lib/components/realtime/remote-browser/remote-browser-channel.d.ts +27 -0
- 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 +141 -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 +101 -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 +503 -55
- package/dist/lib/components/realtime/remote-browser/remote-browser-surface.component.js.map +1 -1
- package/dist/lib/components/realtime/remote-browser/remote-browser-tools.d.ts.map +1 -1
- package/dist/lib/components/realtime/remote-browser/remote-browser-tools.js +2 -2
- package/dist/lib/components/realtime/remote-browser/remote-browser-tools.js.map +1 -1
- package/dist/lib/components/realtime/whiteboard/whiteboard-artifact-viewer.component.d.ts +48 -5
- package/dist/lib/components/realtime/whiteboard/whiteboard-artifact-viewer.component.d.ts.map +1 -1
- package/dist/lib/components/realtime/whiteboard/whiteboard-artifact-viewer.component.js +249 -53
- package/dist/lib/components/realtime/whiteboard/whiteboard-artifact-viewer.component.js.map +1 -1
- package/dist/lib/components/realtime/whiteboard/whiteboard-channel.d.ts.map +1 -1
- package/dist/lib/components/realtime/whiteboard/whiteboard-channel.js +1 -1
- package/dist/lib/components/realtime/whiteboard/whiteboard-channel.js.map +1 -1
- package/dist/lib/components/search/search-panel.component.d.ts +10 -0
- package/dist/lib/components/search/search-panel.component.d.ts.map +1 -1
- package/dist/lib/components/search/search-panel.component.js +25 -3
- package/dist/lib/components/search/search-panel.component.js.map +1 -1
- package/dist/lib/components/sidebar/conversation-sidebar.component.d.ts +28 -1
- package/dist/lib/components/sidebar/conversation-sidebar.component.d.ts.map +1 -1
- package/dist/lib/components/sidebar/conversation-sidebar.component.js +51 -6
- package/dist/lib/components/sidebar/conversation-sidebar.component.js.map +1 -1
- package/dist/lib/components/task/tasks-full-view.component.d.ts +31 -8
- package/dist/lib/components/task/tasks-full-view.component.d.ts.map +1 -1
- package/dist/lib/components/task/tasks-full-view.component.js +692 -497
- package/dist/lib/components/task/tasks-full-view.component.js.map +1 -1
- package/dist/lib/components/workspace/conversation-workspace.component.d.ts.map +1 -1
- package/dist/lib/components/workspace/conversation-workspace.component.js +15 -2
- package/dist/lib/components/workspace/conversation-workspace.component.js.map +1 -1
- package/dist/lib/conversations.module.d.ts +66 -61
- package/dist/lib/conversations.module.d.ts.map +1 -1
- package/dist/lib/conversations.module.js +60 -1
- package/dist/lib/conversations.module.js.map +1 -1
- package/dist/lib/events/chat-events.d.ts +45 -0
- package/dist/lib/events/chat-events.d.ts.map +1 -1
- package/dist/lib/events/chat-events.js +64 -0
- package/dist/lib/events/chat-events.js.map +1 -1
- package/dist/lib/models/agent-turn.model.d.ts +7 -1
- 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.map +1 -1
- package/dist/lib/services/agent-state.service.js +14 -3
- package/dist/lib/services/agent-state.service.js.map +1 -1
- package/dist/lib/services/artifact-permission.service.d.ts.map +1 -1
- package/dist/lib/services/artifact-permission.service.js +14 -3
- package/dist/lib/services/artifact-permission.service.js.map +1 -1
- package/dist/lib/services/artifact-state.service.d.ts.map +1 -1
- package/dist/lib/services/artifact-state.service.js +43 -11
- package/dist/lib/services/artifact-state.service.js.map +1 -1
- package/dist/lib/services/conversation-agent.service.d.ts +8 -3
- package/dist/lib/services/conversation-agent.service.d.ts.map +1 -1
- package/dist/lib/services/conversation-agent.service.js +9 -3
- package/dist/lib/services/conversation-agent.service.js.map +1 -1
- package/dist/lib/services/conversation-tasks-filter.d.ts +59 -2
- package/dist/lib/services/conversation-tasks-filter.d.ts.map +1 -1
- package/dist/lib/services/conversation-tasks-filter.js +222 -18
- package/dist/lib/services/conversation-tasks-filter.js.map +1 -1
- package/dist/lib/services/edge-ai/edge-agent-pre-discovery.service.d.ts +85 -0
- package/dist/lib/services/edge-ai/edge-agent-pre-discovery.service.d.ts.map +1 -0
- package/dist/lib/services/edge-ai/edge-agent-pre-discovery.service.js +257 -0
- package/dist/lib/services/edge-ai/edge-agent-pre-discovery.service.js.map +1 -0
- package/dist/lib/services/edge-ai/edge-ai-protocol.d.ts +85 -0
- package/dist/lib/services/edge-ai/edge-ai-protocol.d.ts.map +1 -0
- package/dist/lib/services/edge-ai/edge-ai-protocol.js +10 -0
- package/dist/lib/services/edge-ai/edge-ai-protocol.js.map +1 -0
- package/dist/lib/services/edge-ai/edge-ai-worker-host.d.ts +90 -0
- package/dist/lib/services/edge-ai/edge-ai-worker-host.d.ts.map +1 -0
- package/dist/lib/services/edge-ai/edge-ai-worker-host.js +386 -0
- package/dist/lib/services/edge-ai/edge-ai-worker-host.js.map +1 -0
- package/dist/lib/services/edge-ai/edge-ai.worker.d.ts +13 -0
- package/dist/lib/services/edge-ai/edge-ai.worker.d.ts.map +1 -0
- package/dist/lib/services/edge-ai/edge-ai.worker.js +201 -0
- package/dist/lib/services/edge-ai/edge-ai.worker.js.map +1 -0
- package/dist/lib/services/export.service.d.ts +64 -0
- package/dist/lib/services/export.service.d.ts.map +1 -1
- package/dist/lib/services/export.service.js +185 -6
- package/dist/lib/services/export.service.js.map +1 -1
- package/dist/lib/services/library-creation.service.d.ts +304 -0
- package/dist/lib/services/library-creation.service.d.ts.map +1 -0
- package/dist/lib/services/library-creation.service.js +1244 -0
- package/dist/lib/services/library-creation.service.js.map +1 -0
- package/dist/lib/services/realtime-audio-recorder.d.ts +10 -8
- package/dist/lib/services/realtime-audio-recorder.d.ts.map +1 -1
- package/dist/lib/services/realtime-audio-recorder.js +28 -12
- package/dist/lib/services/realtime-audio-recorder.js.map +1 -1
- package/dist/lib/services/realtime-pairing.d.ts +3 -3
- package/dist/lib/services/realtime-pairing.js +4 -4
- package/dist/lib/services/realtime-pairing.js.map +1 -1
- package/dist/lib/services/realtime-session-review.service.d.ts +14 -0
- package/dist/lib/services/realtime-session-review.service.d.ts.map +1 -1
- package/dist/lib/services/realtime-session-review.service.js +46 -4
- package/dist/lib/services/realtime-session-review.service.js.map +1 -1
- package/dist/lib/services/realtime-session.service.d.ts +10 -3
- package/dist/lib/services/realtime-session.service.d.ts.map +1 -1
- package/dist/lib/services/realtime-session.service.js +8 -3
- package/dist/lib/services/realtime-session.service.js.map +1 -1
- package/dist/lib/services/search.service.d.ts +19 -2
- package/dist/lib/services/search.service.d.ts.map +1 -1
- package/dist/lib/services/search.service.js +99 -36
- package/dist/lib/services/search.service.js.map +1 -1
- package/dist/lib/utils/agent-artifact-summary.d.ts +1 -1
- package/dist/lib/utils/agent-artifact-summary.d.ts.map +1 -1
- package/dist/lib/utils/agent-artifact-summary.js +1 -1
- package/dist/lib/utils/agent-artifact-summary.js.map +1 -1
- package/dist/lib/utils/decision-routing.d.ts +5 -2
- package/dist/lib/utils/decision-routing.d.ts.map +1 -1
- package/dist/lib/utils/decision-routing.js +9 -4
- package/dist/lib/utils/decision-routing.js.map +1 -1
- package/dist/public-api.d.ts +13 -0
- package/dist/public-api.d.ts.map +1 -1
- package/dist/public-api.js +15 -1
- package/dist/public-api.js.map +1 -1
- package/package.json +42 -37
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { RealtimeToolDefinition } from '@memberjunction/ai';
|
|
2
2
|
import { type RealtimeChannelDescriptor } from '@memberjunction/ai-core-plus';
|
|
3
3
|
import { BaseRealtimeChannelClient } from '@memberjunction/realtime-runtime';
|
|
4
|
+
/** Coalescing window (ms) that collapses synchronous/rapid navigation + dashboard hydration bursts into one wire note. */
|
|
5
|
+
export declare const CLIENT_CONTEXT_COALESCE_MS = 250;
|
|
6
|
+
/** Replaceable reconnect-memory state key for the active application screen context. */
|
|
7
|
+
export declare const APP_CONTEXT_MEMORY_STATE_KEY = "app-context";
|
|
4
8
|
/** The stable name of the single proxy tool this channel registers with the realtime provider. */
|
|
5
9
|
export declare const CONTEXT_TOOL_NAME = "ContextTool";
|
|
6
10
|
/**
|
|
@@ -10,6 +14,12 @@ export declare const CONTEXT_TOOL_NAME = "ContextTool";
|
|
|
10
14
|
export declare class ClientContextChannel extends BaseRealtimeChannelClient<object> {
|
|
11
15
|
/** Subscription to the host app-context stream (perception); cleared on {@link Dispose}. */
|
|
12
16
|
private appContextSub;
|
|
17
|
+
/** Last snapshot known by the live model (seeded from initial BehaviorSubject value or last flushed update). */
|
|
18
|
+
private baselineSnapshot;
|
|
19
|
+
/** Latest snapshot buffered inside the active coalescing window. */
|
|
20
|
+
private pendingSnapshot;
|
|
21
|
+
/** Active burst-coalescing timer; cleared on flush or {@link Dispose}. */
|
|
22
|
+
private coalesceTimer;
|
|
13
23
|
/** Matches the seeded `MJ: AI Agent Channels` row's `Name`. */
|
|
14
24
|
get ChannelName(): string;
|
|
15
25
|
/** Routing prefix — the single `ContextTool` matches `ContextTool`.startsWith(prefix). */
|
|
@@ -42,16 +52,22 @@ export declare class ClientContextChannel extends BaseRealtimeChannelClient<obje
|
|
|
42
52
|
/** Headless — no surface to bind. */
|
|
43
53
|
BindSurface(): void;
|
|
44
54
|
/**
|
|
45
|
-
* Subscribes to the host's live app-context stream and streams each
|
|
46
|
-
* compact context note
|
|
47
|
-
*
|
|
55
|
+
* Subscribes to the host's live app-context stream and streams each coalesced delta to the model as a
|
|
56
|
+
* compact context note while keeping only the latest full snapshot in reconnect memory under
|
|
57
|
+
* `StateKey: 'app-context'`. Null-safe — hosts that supply no `AppContext$` (custom apps) simply get
|
|
58
|
+
* no streaming, and the session-start prompt injection still applies.
|
|
48
59
|
*/
|
|
49
60
|
protected OnInitialize(): void;
|
|
61
|
+
/**
|
|
62
|
+
* Immediately flushes any buffered `AppContext$` update, emitting a compact delta on the live wire
|
|
63
|
+
* and recording the full latest snapshot under `StateKey: 'app-context'` for reconnect continuity.
|
|
64
|
+
*/
|
|
65
|
+
FlushPending(): void;
|
|
50
66
|
/** Tolerantly parses the `{ action, params, target? }` arguments. */
|
|
51
67
|
private parseArgs;
|
|
52
68
|
/** Reads a `target` — `{ channel, instance? }` — or `null` when absent or unusable (the call is then an app action). */
|
|
53
69
|
private parseTarget;
|
|
54
|
-
/** Unsubscribes the app-context stream and tears down. */
|
|
70
|
+
/** Unsubscribes the app-context stream, cancels any pending coalescer timer, and tears down. */
|
|
55
71
|
Dispose(): void;
|
|
56
72
|
}
|
|
57
73
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-context-channel.d.ts","sourceRoot":"","sources":["../../../../../src/lib/components/realtime/channels/client-context-channel.ts"],"names":[],"mappings":"AA8BA,OAAO,EAAc,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,
|
|
1
|
+
{"version":3,"file":"client-context-channel.d.ts","sourceRoot":"","sources":["../../../../../src/lib/components/realtime/channels/client-context-channel.ts"],"names":[],"mappings":"AA8BA,OAAO,EAAc,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAKL,KAAK,yBAAyB,EAC/B,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAE,yBAAyB,EAAoC,MAAM,kCAAkC,CAAC;AAE/G,0HAA0H;AAC1H,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAE9C,wFAAwF;AACxF,eAAO,MAAM,4BAA4B,gBAAgB,CAAC;AAE1D,kGAAkG;AAClG,eAAO,MAAM,iBAAiB,gBAAgB,CAAC;AAsC/C;;;GAGG;AACH,qBACa,oBAAqB,SAAQ,yBAAyB,CAAC,MAAM,CAAC;IACzE,4FAA4F;IAC5F,OAAO,CAAC,aAAa,CAA6B;IAClD,gHAAgH;IAChH,OAAO,CAAC,gBAAgB,CAAmC;IAC3D,oEAAoE;IACpE,OAAO,CAAC,eAAe,CAAmC;IAC1D,0EAA0E;IAC1E,OAAO,CAAC,aAAa,CAA8C;IAEnE,+DAA+D;IAC/D,IAAW,WAAW,IAAI,MAAM,CAE/B;IAED,0FAA0F;IAC1F,IAAW,cAAc,IAAI,MAAM,CAElC;IAED,kFAAkF;IAClF,IAAW,QAAQ,IAAI,MAAM,CAE5B;IACD,IAAW,OAAO,IAAI,MAAM,CAE3B;IAED,6CAA6C;IACtC,kBAAkB,IAAI,sBAAsB,EAAE;IAIrD;;;;OAIG;IACa,aAAa,IAAI,yBAAyB;IAgB1D;;;;;;;;OAQG;IACU,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAwBhF,+FAA+F;YACjF,kBAAkB;IAchC,+GAA+G;IAC/G,OAAO,CAAC,wBAAwB;IAahC,qCAAqC;IAC9B,WAAW,IAAI,IAAI;IAI1B;;;;;OAKG;cACgB,YAAY,IAAI,IAAI;IA0BvC;;;OAGG;IACI,YAAY,IAAI,IAAI;IA0B3B,qEAAqE;IACrE,OAAO,CAAC,SAAS;IAkBjB,wHAAwH;IACxH,OAAO,CAAC,WAAW;IAanB,gGAAgG;IAChF,OAAO,IAAI,IAAI;CAWhC;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CAE/C"}
|
|
@@ -34,9 +34,13 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
34
34
|
* @module @memberjunction/ng-conversations
|
|
35
35
|
*/
|
|
36
36
|
import { RegisterClass } from '@memberjunction/global';
|
|
37
|
-
import { FormatAppContextNote, REALTIME_CHANNEL_CONTRACT_VERSION } from '@memberjunction/ai-core-plus';
|
|
37
|
+
import { DiffAppContextSnapshot, FormatAppContextNote, REALTIME_CHANNEL_CONTRACT_VERSION, } from '@memberjunction/ai-core-plus';
|
|
38
38
|
import { distinctUntilChanged } from 'rxjs/operators';
|
|
39
39
|
import { BaseRealtimeChannelClient } from '@memberjunction/realtime-runtime';
|
|
40
|
+
/** Coalescing window (ms) that collapses synchronous/rapid navigation + dashboard hydration bursts into one wire note. */
|
|
41
|
+
export const CLIENT_CONTEXT_COALESCE_MS = 250;
|
|
42
|
+
/** Replaceable reconnect-memory state key for the active application screen context. */
|
|
43
|
+
export const APP_CONTEXT_MEMORY_STATE_KEY = 'app-context';
|
|
40
44
|
/** The stable name of the single proxy tool this channel registers with the realtime provider. */
|
|
41
45
|
export const CONTEXT_TOOL_NAME = 'ContextTool';
|
|
42
46
|
/** The single stable proxy tool — declared once; the live catalog of valid `action`s rides context. */
|
|
@@ -80,6 +84,12 @@ const CONTEXT_TOOL_DEFINITION = {
|
|
|
80
84
|
let ClientContextChannel = class ClientContextChannel extends BaseRealtimeChannelClient {
|
|
81
85
|
/** Subscription to the host app-context stream (perception); cleared on {@link Dispose}. */
|
|
82
86
|
appContextSub = null;
|
|
87
|
+
/** Last snapshot known by the live model (seeded from initial BehaviorSubject value or last flushed update). */
|
|
88
|
+
baselineSnapshot = null;
|
|
89
|
+
/** Latest snapshot buffered inside the active coalescing window. */
|
|
90
|
+
pendingSnapshot = null;
|
|
91
|
+
/** Active burst-coalescing timer; cleared on flush or {@link Dispose}. */
|
|
92
|
+
coalesceTimer = null;
|
|
83
93
|
/** Matches the seeded `MJ: AI Agent Channels` row's `Name`. */
|
|
84
94
|
get ChannelName() {
|
|
85
95
|
return 'ClientContextChannel';
|
|
@@ -178,26 +188,64 @@ let ClientContextChannel = class ClientContextChannel extends BaseRealtimeChanne
|
|
|
178
188
|
/* no-op: this channel renders no surface */
|
|
179
189
|
}
|
|
180
190
|
/**
|
|
181
|
-
* Subscribes to the host's live app-context stream and streams each
|
|
182
|
-
* compact context note
|
|
183
|
-
*
|
|
191
|
+
* Subscribes to the host's live app-context stream and streams each coalesced delta to the model as a
|
|
192
|
+
* compact context note while keeping only the latest full snapshot in reconnect memory under
|
|
193
|
+
* `StateKey: 'app-context'`. Null-safe — hosts that supply no `AppContext$` (custom apps) simply get
|
|
194
|
+
* no streaming, and the session-start prompt injection still applies.
|
|
184
195
|
*/
|
|
185
196
|
OnInitialize() {
|
|
186
197
|
const stream = this.Context?.AppContext$;
|
|
187
198
|
if (!stream) {
|
|
188
199
|
return;
|
|
189
200
|
}
|
|
201
|
+
let subscribingSynchronously = true;
|
|
190
202
|
this.appContextSub = stream
|
|
191
203
|
.pipe(distinctUntilChanged((a, b) => JSON.stringify(a) === JSON.stringify(b)))
|
|
192
204
|
.subscribe((snapshot) => {
|
|
193
205
|
if (!snapshot) {
|
|
194
206
|
return;
|
|
195
207
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
208
|
+
if (subscribingSynchronously) {
|
|
209
|
+
// BehaviorSubject's current value was already injected into SystemPrompt at session mint:
|
|
210
|
+
// record it as the diff baseline without sending a duplicate t=0 wire note.
|
|
211
|
+
this.baselineSnapshot = snapshot;
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
this.pendingSnapshot = snapshot;
|
|
215
|
+
if (this.coalesceTimer === null) {
|
|
216
|
+
this.coalesceTimer = setTimeout(() => this.FlushPending(), CLIENT_CONTEXT_COALESCE_MS);
|
|
199
217
|
}
|
|
200
218
|
});
|
|
219
|
+
subscribingSynchronously = false;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Immediately flushes any buffered `AppContext$` update, emitting a compact delta on the live wire
|
|
223
|
+
* and recording the full latest snapshot under `StateKey: 'app-context'` for reconnect continuity.
|
|
224
|
+
*/
|
|
225
|
+
FlushPending() {
|
|
226
|
+
if (this.coalesceTimer !== null) {
|
|
227
|
+
clearTimeout(this.coalesceTimer);
|
|
228
|
+
this.coalesceTimer = null;
|
|
229
|
+
}
|
|
230
|
+
const latest = this.pendingSnapshot;
|
|
231
|
+
this.pendingSnapshot = null;
|
|
232
|
+
if (!latest) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
const delta = DiffAppContextSnapshot(this.baselineSnapshot, latest);
|
|
236
|
+
this.baselineSnapshot = latest;
|
|
237
|
+
if (!delta) {
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
const wireNote = FormatAppContextNote(delta);
|
|
241
|
+
if (!wireNote) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
const fullMemoryNote = FormatAppContextNote(latest);
|
|
245
|
+
this.Context?.SendContextNote(wireNote, {
|
|
246
|
+
StateKey: APP_CONTEXT_MEMORY_STATE_KEY,
|
|
247
|
+
...(fullMemoryNote && fullMemoryNote !== wireNote ? { MemoryText: fullMemoryNote } : {}),
|
|
248
|
+
});
|
|
201
249
|
}
|
|
202
250
|
/** Tolerantly parses the `{ action, params, target? }` arguments. */
|
|
203
251
|
parseArgs(argsJson) {
|
|
@@ -226,8 +274,14 @@ let ClientContextChannel = class ClientContextChannel extends BaseRealtimeChanne
|
|
|
226
274
|
const instance = typeof target.instance === 'string' && target.instance.trim().length > 0 ? target.instance.trim() : undefined;
|
|
227
275
|
return instance ? { channel, instance } : { channel };
|
|
228
276
|
}
|
|
229
|
-
/** Unsubscribes the app-context stream and tears down. */
|
|
277
|
+
/** Unsubscribes the app-context stream, cancels any pending coalescer timer, and tears down. */
|
|
230
278
|
Dispose() {
|
|
279
|
+
if (this.coalesceTimer !== null) {
|
|
280
|
+
clearTimeout(this.coalesceTimer);
|
|
281
|
+
this.coalesceTimer = null;
|
|
282
|
+
}
|
|
283
|
+
this.pendingSnapshot = null;
|
|
284
|
+
this.baselineSnapshot = null;
|
|
231
285
|
this.appContextSub?.unsubscribe();
|
|
232
286
|
this.appContextSub = null;
|
|
233
287
|
super.Dispose();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-context-channel.js","sourceRoot":"","sources":["../../../../../src/lib/components/realtime/channels/client-context-channel.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,EAAE,oBAAoB,EAAE,iCAAiC,EAAkC,MAAM,8BAA8B,CAAC;AAEvI,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,yBAAyB,EAAoC,MAAM,kCAAkC,CAAC;AAE/G,kGAAkG;AAClG,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAAC;AAE/C,uGAAuG;AACvG,MAAM,uBAAuB,GAA2B;IACtD,IAAI,EAAE,iBAAiB;IACvB,WAAW,EACT,8FAA8F;QAC9F,mGAAmG;QACnG,oGAAoG;QACpG,mGAAmG;QACnG,iGAAiG;QACjG,oGAAoG;QACpG,mBAAmB;IACrB,gBAAgB,EAAE;QAChB,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,yFAAyF;aACvG;YACD,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAA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CAAC,yBAAyB,EAAE,sBAAsB,CAAC;GACpD,oBAAoB,CAiLhC;;AAED;;;;GAIG;AACH,MAAM,UAAU,wBAAwB;IACtC,gFAAgF;AAClF,CAAC","sourcesContent":["/**\n * @fileoverview The headless **Client Context** channel — the browser half of the live wire that\n * keeps the realtime co-agent continuously aware of the user's app context and lets it act in the\n * app through a single stable proxy tool.\n *\n * Paired with `ClientContextChannelServer` (`@memberjunction/ai-agents`) via the seeded\n * `MJ: AI Agent Channels` row (`Name: 'ClientContextChannel'`, `IsHeadless: 1`,\n * `ClientPluginClass: 'ClientContextChannel'`).\n *\n * Two responsibilities, both client-side (no server round-trip in the client-direct topology):\n *\n * 1. **Perception (streaming).** It subscribes to the host's live app-context stream\n * ({@link RealtimeChannelContext.AppContext$}, fed by Explorer from `NavigationService`) and, on\n * every change, pushes a compact `SendContextNote` so the model always knows where the user is,\n * what they see, and which tools/agents are available — the *continuous* half of client-context\n * delivery (the session-start half is injected into the companion prompt server-side at mint).\n *\n * 2. **Action (the `ContextTool` proxy).** It declares ONE stable tool, `ContextTool`, so the\n * provider tool surface never changes mid-session (which connect-bound providers reject). The\n * model invokes any currently-available surface client tool via `ContextTool({ action, params })`;\n * the channel routes that to the host's {@link RealtimeChannelContext.ExecuteClientTool} (which runs\n * the surface handler the host registered from `SetAgentClientTools`) and returns a structured\n * result the model narrates.\n *\n * **Headless:** no surface component — it never mounts a tab (`GetSurfaceComponent` stays `null`;\n * `BindSurface` is a no-op). It is a wire, not a panel.\n *\n * @module @memberjunction/ng-conversations\n */\nimport { RegisterClass } from '@memberjunction/global';\nimport { JSONObject, RealtimeToolDefinition } from '@memberjunction/ai';\nimport { FormatAppContextNote, REALTIME_CHANNEL_CONTRACT_VERSION, type RealtimeChannelDescriptor } from '@memberjunction/ai-core-plus';\nimport { Subscription } from 'rxjs';\nimport { distinctUntilChanged } from 'rxjs/operators';\nimport { BaseRealtimeChannelClient, type RealtimeContextActionResult } from '@memberjunction/realtime-runtime';\n\n/** The stable name of the single proxy tool this channel registers with the realtime provider. */\nexport const CONTEXT_TOOL_NAME = 'ContextTool';\n\n/** The single stable proxy tool — declared once; the live catalog of valid `action`s rides context. */\nconst CONTEXT_TOOL_DEFINITION: RealtimeToolDefinition = {\n Name: CONTEXT_TOOL_NAME,\n Description:\n \"Perform an action in the application the user is currently in, or on one of the interactive \" +\n \"channels listed in your channel notes. The set of valid actions (the client tools and the things \" +\n \"you can do on the current surface) is provided to you continuously as context — only call actions \" +\n \"listed as currently available. Pass the action name and its parameters. To act on an interactive \" +\n \"channel instead of the app, also pass `target` naming the channel (and, for a channel that has \" +\n \"several, the instance); to open a channel that is available but not open yet, use action \\\"open\\\" \" +\n \"with that target.\",\n ParametersSchema: {\n type: 'object',\n properties: {\n action: {\n type: 'string',\n description: 'The name of a currently-available action/tool to run (from the context you were given).'\n },\n params: {\n type: 'object',\n description: \"The action's parameters, matching its advertised input schema.\"\n },\n target: {\n type: 'object',\n description: 'Set this to act on an interactive channel rather than the app. Omit it for app actions.',\n properties: {\n channel: { type: 'string', description: 'The channel to address (from your channel notes).' },\n instance: { type: 'string', description: 'Which instance, for a channel that has several. Usually omitted.' }\n },\n required: ['channel']\n }\n },\n required: ['action']\n }\n};\n\n/**\n * The headless Client Context channel client. One instance per realtime session (created by the\n * session service from the `MJ: AI Agent Channels` registry — never construct directly).\n */\n@RegisterClass(BaseRealtimeChannelClient, 'ClientContextChannel')\nexport class ClientContextChannel extends BaseRealtimeChannelClient<object> {\n /** Subscription to the host app-context stream (perception); cleared on {@link Dispose}. */\n private appContextSub: Subscription | null = null;\n\n /** Matches the seeded `MJ: AI Agent Channels` row's `Name`. */\n public get ChannelName(): string {\n return 'ClientContextChannel';\n }\n\n /** Routing prefix — the single `ContextTool` matches `ContextTool`.startsWith(prefix). */\n public get ToolNamePrefix(): string {\n return CONTEXT_TOOL_NAME;\n }\n\n /** Headless — never rendered, but the abstract contract requires a label/icon. */\n public get TabTitle(): string {\n return 'App Context';\n }\n public get TabIcon(): string {\n return 'fa-solid fa-satellite-dish';\n }\n\n /** Declares the single stable proxy tool. */\n public GetToolDefinitions(): RealtimeToolDefinition[] {\n return [CONTEXT_TOOL_DEFINITION];\n }\n\n /**\n * The channel's self-description. It has NO verbs of its own: it is the door, not a room — `ContextTool`\n * runs app client tools, or addresses another channel through `target`. Declaring that explicitly keeps\n * it from being addressed as if it were a channel with things to do.\n */\n public override GetDescriptor(): RealtimeChannelDescriptor {\n return {\n Key: this.ChannelName,\n Version: REALTIME_CHANNEL_CONTRACT_VERSION,\n DisplayName: this.TabTitle,\n Instructions:\n 'Keeps you aware of where the user is in the app and lets you act there through ContextTool. ' +\n 'It is not itself something to operate.',\n Nouns: [],\n Verbs: [],\n DisplayPolicy: 'headless',\n DefaultAvailability: 'all-sessions',\n MaxExposure: 'state'\n };\n }\n\n /**\n * Routes a `ContextTool({ action, params, target? })` call. With a `target` the call is handed to the\n * runtime, which validates it against the addressed channel's verb schema (a malformed call comes back\n * as a structured, model-recoverable error) and opens an `on-demand` channel when asked; without one it\n * runs the host's registered surface client tool, exactly as before.\n *\n * Tolerant: malformed args, a missing host executor, or an unknown/throwing tool all serialize to\n * a structured `{ success: false, output }` the model narrates (never throws).\n */\n public async ApplyAgentTool(toolName: string, argsJson: string): Promise<string> {\n if (toolName !== CONTEXT_TOOL_NAME) {\n return JSON.stringify({ success: false, output: `Unknown context tool \"${toolName}\".` });\n }\n const parsed = this.parseArgs(argsJson);\n if (!parsed.action) {\n return JSON.stringify({ success: false, output: 'ContextTool requires an \"action\" naming the tool to run.' });\n }\n if (parsed.target) {\n return this.applyChannelAction(parsed.action, parsed.params, parsed.target);\n }\n const executor = this.Context?.ExecuteClientTool;\n if (!executor) {\n return JSON.stringify({\n success: false,\n output: 'No app surface is available to perform that action right now.'\n });\n }\n const result = await executor(parsed.action, parsed.params);\n return result.Success\n ? JSON.stringify({ success: true, output: result.Result ?? 'Done.' })\n : JSON.stringify({ success: false, output: result.ErrorMessage ?? 'The action could not be performed.' });\n }\n\n /** Runs a channel-addressed call through the runtime and serializes its structured outcome. */\n private async applyChannelAction(\n action: string,\n params: Record<string, unknown>,\n target: { channel: string; instance?: string }\n ): Promise<string> {\n const dispatch = this.Context?.DispatchContextAction;\n if (!dispatch) {\n return JSON.stringify({ success: false, output: 'Channel actions are not available in this session.' });\n }\n // The params came off the wire as JSON, so they are JSON by construction.\n const outcome = await dispatch({ Target: { Channel: target.channel, Instance: target.instance }, Action: action, Params: params as JSONObject });\n return JSON.stringify(this.serializeDispatchOutcome(outcome));\n }\n\n /** The model-facing shape of a dispatch outcome: success carries the result; a refusal carries what to fix. */\n private serializeDispatchOutcome(outcome: RealtimeContextActionResult): Record<string, unknown> {\n if (outcome.Success) {\n return { success: true, output: outcome.Result ?? 'Done.' };\n }\n return {\n success: false,\n output: outcome.ErrorMessage ?? 'The action could not be performed.',\n errorCode: outcome.ErrorCode,\n ...(outcome.Details ? { details: outcome.Details } : {}),\n ...(outcome.Available ? { available: outcome.Available } : {})\n };\n }\n\n /** Headless — no surface to bind. */\n public BindSurface(): void {\n /* no-op: this channel renders no surface */\n }\n\n /**\n * Subscribes to the host's live app-context stream and streams each change to the model as a\n * compact context note (the perception half). Null-safe — hosts that supply no `AppContext$`\n * (custom apps) simply get no streaming, and the session-start prompt injection still applies.\n */\n protected override OnInitialize(): void {\n const stream = this.Context?.AppContext$;\n if (!stream) {\n return;\n }\n this.appContextSub = stream\n .pipe(distinctUntilChanged((a, b) => JSON.stringify(a) === JSON.stringify(b)))\n .subscribe((snapshot) => {\n if (!snapshot) {\n return;\n }\n const note = FormatAppContextNote(snapshot);\n if (note) {\n this.Context?.SendContextNote(note);\n }\n });\n }\n\n /** Tolerantly parses the `{ action, params, target? }` arguments. */\n private parseArgs(argsJson: string): {\n action: string | null;\n params: Record<string, unknown>;\n target: { channel: string; instance?: string } | null;\n } {\n try {\n const parsed = JSON.parse(argsJson) as { action?: unknown; params?: unknown; target?: unknown };\n const action = typeof parsed.action === 'string' && parsed.action.trim().length > 0 ? parsed.action.trim() : null;\n const params =\n parsed.params && typeof parsed.params === 'object' && !Array.isArray(parsed.params)\n ? (parsed.params as Record<string, unknown>)\n : {};\n return { action, params, target: this.parseTarget(parsed.target) };\n } catch {\n return { action: null, params: {}, target: null };\n }\n }\n\n /** Reads a `target` — `{ channel, instance? }` — or `null` when absent or unusable (the call is then an app action). */\n private parseTarget(raw: unknown): { channel: string; instance?: string } | null {\n if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {\n return null;\n }\n const target = raw as { channel?: unknown; instance?: unknown };\n const channel = typeof target.channel === 'string' ? target.channel.trim() : '';\n if (channel.length === 0) {\n return null;\n }\n const instance = typeof target.instance === 'string' && target.instance.trim().length > 0 ? target.instance.trim() : undefined;\n return instance ? { channel, instance } : { channel };\n }\n\n /** Unsubscribes the app-context stream and tears down. */\n public override Dispose(): void {\n this.appContextSub?.unsubscribe();\n this.appContextSub = null;\n super.Dispose();\n }\n}\n\n/**\n * Tree-shaking prevention for {@link ClientContextChannel}'s `@RegisterClass` registration. Called\n * from a static code path in `conversations.module.ts` so the registration always executes —\n * mirroring every other realtime channel client.\n */\nexport function LoadClientContextChannel(): void {\n // no-op — the import + call create a static reference bundlers cannot eliminate\n}\n"]}
|
|
1
|
+
{"version":3,"file":"client-context-channel.js","sourceRoot":"","sources":["../../../../../src/lib/components/realtime/channels/client-context-channel.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,iCAAiC,GAGlC,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,yBAAyB,EAAoC,MAAM,kCAAkC,CAAC;AAE/G,0HAA0H;AAC1H,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAG,CAAC;AAE9C,w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M,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,QAAQ,GAAG,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QAC/H,OAAO,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC;IACxD,CAAC;IAED,gGAAgG;IAChF,OAAO;QACrB,IAAI,IAAI,CAAC,aAAa,KAAK,IAAI,EAAE,CAAC;YAChC,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YACjC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC5B,CAAC;QACD,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;QAC5B,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;QAC7B,IAAI,CAAC,aAAa,EAAE,WAAW,EAAE,CAAC;QAClC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC1B,KAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;CACF,CAAA;AApOY,oBAAoB;IADhC,aAAa,CAAC,yBAAyB,EAAE,sBAAsB,CAAC;GACpD,oBAAoB,CAoOhC;;AAED;;;;GAIG;AACH,MAAM,UAAU,wBAAwB;IACtC,gFAAgF;AAClF,CAAC","sourcesContent":["/**\n * @fileoverview The headless **Client Context** channel — the browser half of the live wire that\n * keeps the realtime co-agent continuously aware of the user's app context and lets it act in the\n * app through a single stable proxy tool.\n *\n * Paired with `ClientContextChannelServer` (`@memberjunction/ai-agents`) via the seeded\n * `MJ: AI Agent Channels` row (`Name: 'ClientContextChannel'`, `IsHeadless: 1`,\n * `ClientPluginClass: 'ClientContextChannel'`).\n *\n * Two responsibilities, both client-side (no server round-trip in the client-direct topology):\n *\n * 1. **Perception (streaming).** It subscribes to the host's live app-context stream\n * ({@link RealtimeChannelContext.AppContext$}, fed by Explorer from `NavigationService`) and, on\n * every change, pushes a compact `SendContextNote` so the model always knows where the user is,\n * what they see, and which tools/agents are available — the *continuous* half of client-context\n * delivery (the session-start half is injected into the companion prompt server-side at mint).\n *\n * 2. **Action (the `ContextTool` proxy).** It declares ONE stable tool, `ContextTool`, so the\n * provider tool surface never changes mid-session (which connect-bound providers reject). The\n * model invokes any currently-available surface client tool via `ContextTool({ action, params })`;\n * the channel routes that to the host's {@link RealtimeChannelContext.ExecuteClientTool} (which runs\n * the surface handler the host registered from `SetAgentClientTools`) and returns a structured\n * result the model narrates.\n *\n * **Headless:** no surface component — it never mounts a tab (`GetSurfaceComponent` stays `null`;\n * `BindSurface` is a no-op). It is a wire, not a panel.\n *\n * @module @memberjunction/ng-conversations\n */\nimport { RegisterClass } from '@memberjunction/global';\nimport { JSONObject, RealtimeToolDefinition } from '@memberjunction/ai';\nimport {\n DiffAppContextSnapshot,\n FormatAppContextNote,\n REALTIME_CHANNEL_CONTRACT_VERSION,\n type AppContextSnapshot,\n type RealtimeChannelDescriptor,\n} from '@memberjunction/ai-core-plus';\nimport { Subscription } from 'rxjs';\nimport { distinctUntilChanged } from 'rxjs/operators';\nimport { BaseRealtimeChannelClient, type RealtimeContextActionResult } from '@memberjunction/realtime-runtime';\n\n/** Coalescing window (ms) that collapses synchronous/rapid navigation + dashboard hydration bursts into one wire note. */\nexport const CLIENT_CONTEXT_COALESCE_MS = 250;\n\n/** Replaceable reconnect-memory state key for the active application screen context. */\nexport const APP_CONTEXT_MEMORY_STATE_KEY = 'app-context';\n\n/** The stable name of the single proxy tool this channel registers with the realtime provider. */\nexport const CONTEXT_TOOL_NAME = 'ContextTool';\n\n/** The single stable proxy tool — declared once; the live catalog of valid `action`s rides context. */\nconst CONTEXT_TOOL_DEFINITION: RealtimeToolDefinition = {\n Name: CONTEXT_TOOL_NAME,\n Description:\n \"Perform an action in the application the user is currently in, or on one of the interactive \" +\n \"channels listed in your channel notes. The set of valid actions (the client tools and the things \" +\n \"you can do on the current surface) is provided to you continuously as context — only call actions \" +\n \"listed as currently available. Pass the action name and its parameters. To act on an interactive \" +\n \"channel instead of the app, also pass `target` naming the channel (and, for a channel that has \" +\n \"several, the instance); to open a channel that is available but not open yet, use action \\\"open\\\" \" +\n \"with that target.\",\n ParametersSchema: {\n type: 'object',\n properties: {\n action: {\n type: 'string',\n description: 'The name of a currently-available action/tool to run (from the context you were given).'\n },\n params: {\n type: 'object',\n description: \"The action's parameters, matching its advertised input schema.\"\n },\n target: {\n type: 'object',\n description: 'Set this to act on an interactive channel rather than the app. Omit it for app actions.',\n properties: {\n channel: { type: 'string', description: 'The channel to address (from your channel notes).' },\n instance: { type: 'string', description: 'Which instance, for a channel that has several. Usually omitted.' }\n },\n required: ['channel']\n }\n },\n required: ['action']\n }\n};\n\n/**\n * The headless Client Context channel client. One instance per realtime session (created by the\n * session service from the `MJ: AI Agent Channels` registry — never construct directly).\n */\n@RegisterClass(BaseRealtimeChannelClient, 'ClientContextChannel')\nexport class ClientContextChannel extends BaseRealtimeChannelClient<object> {\n /** Subscription to the host app-context stream (perception); cleared on {@link Dispose}. */\n private appContextSub: Subscription | null = null;\n /** Last snapshot known by the live model (seeded from initial BehaviorSubject value or last flushed update). */\n private baselineSnapshot: AppContextSnapshot | null = null;\n /** Latest snapshot buffered inside the active coalescing window. */\n private pendingSnapshot: AppContextSnapshot | null = null;\n /** Active burst-coalescing timer; cleared on flush or {@link Dispose}. */\n private coalesceTimer: ReturnType<typeof setTimeout> | null = null;\n\n /** Matches the seeded `MJ: AI Agent Channels` row's `Name`. */\n public get ChannelName(): string {\n return 'ClientContextChannel';\n }\n\n /** Routing prefix — the single `ContextTool` matches `ContextTool`.startsWith(prefix). */\n public get ToolNamePrefix(): string {\n return CONTEXT_TOOL_NAME;\n }\n\n /** Headless — never rendered, but the abstract contract requires a label/icon. */\n public get TabTitle(): string {\n return 'App Context';\n }\n public get TabIcon(): string {\n return 'fa-solid fa-satellite-dish';\n }\n\n /** Declares the single stable proxy tool. */\n public GetToolDefinitions(): RealtimeToolDefinition[] {\n return [CONTEXT_TOOL_DEFINITION];\n }\n\n /**\n * The channel's self-description. It has NO verbs of its own: it is the door, not a room — `ContextTool`\n * runs app client tools, or addresses another channel through `target`. Declaring that explicitly keeps\n * it from being addressed as if it were a channel with things to do.\n */\n public override GetDescriptor(): RealtimeChannelDescriptor {\n return {\n Key: this.ChannelName,\n Version: REALTIME_CHANNEL_CONTRACT_VERSION,\n DisplayName: this.TabTitle,\n Instructions:\n 'Keeps you aware of where the user is in the app and lets you act there through ContextTool. ' +\n 'It is not itself something to operate.',\n Nouns: [],\n Verbs: [],\n DisplayPolicy: 'headless',\n DefaultAvailability: 'all-sessions',\n MaxExposure: 'state'\n };\n }\n\n /**\n * Routes a `ContextTool({ action, params, target? })` call. With a `target` the call is handed to the\n * runtime, which validates it against the addressed channel's verb schema (a malformed call comes back\n * as a structured, model-recoverable error) and opens an `on-demand` channel when asked; without one it\n * runs the host's registered surface client tool, exactly as before.\n *\n * Tolerant: malformed args, a missing host executor, or an unknown/throwing tool all serialize to\n * a structured `{ success: false, output }` the model narrates (never throws).\n */\n public async ApplyAgentTool(toolName: string, argsJson: string): Promise<string> {\n if (toolName !== CONTEXT_TOOL_NAME) {\n return JSON.stringify({ success: false, output: `Unknown context tool \"${toolName}\".` });\n }\n const parsed = this.parseArgs(argsJson);\n if (!parsed.action) {\n return JSON.stringify({ success: false, output: 'ContextTool requires an \"action\" naming the tool to run.' });\n }\n if (parsed.target) {\n return this.applyChannelAction(parsed.action, parsed.params, parsed.target);\n }\n const executor = this.Context?.ExecuteClientTool;\n if (!executor) {\n return JSON.stringify({\n success: false,\n output: 'No app surface is available to perform that action right now.'\n });\n }\n const result = await executor(parsed.action, parsed.params);\n return result.Success\n ? JSON.stringify({ success: true, output: result.Result ?? 'Done.' })\n : JSON.stringify({ success: false, output: result.ErrorMessage ?? 'The action could not be performed.' });\n }\n\n /** Runs a channel-addressed call through the runtime and serializes its structured outcome. */\n private async applyChannelAction(\n action: string,\n params: Record<string, unknown>,\n target: { channel: string; instance?: string }\n ): Promise<string> {\n const dispatch = this.Context?.DispatchContextAction;\n if (!dispatch) {\n return JSON.stringify({ success: false, output: 'Channel actions are not available in this session.' });\n }\n // The params came off the wire as JSON, so they are JSON by construction.\n const outcome = await dispatch({ Target: { Channel: target.channel, Instance: target.instance }, Action: action, Params: params as JSONObject });\n return JSON.stringify(this.serializeDispatchOutcome(outcome));\n }\n\n /** The model-facing shape of a dispatch outcome: success carries the result; a refusal carries what to fix. */\n private serializeDispatchOutcome(outcome: RealtimeContextActionResult): Record<string, unknown> {\n if (outcome.Success) {\n return { success: true, output: outcome.Result ?? 'Done.' };\n }\n return {\n success: false,\n output: outcome.ErrorMessage ?? 'The action could not be performed.',\n errorCode: outcome.ErrorCode,\n ...(outcome.Details ? { details: outcome.Details } : {}),\n ...(outcome.Available ? { available: outcome.Available } : {})\n };\n }\n\n /** Headless — no surface to bind. */\n public BindSurface(): void {\n /* no-op: this channel renders no surface */\n }\n\n /**\n * Subscribes to the host's live app-context stream and streams each coalesced delta to the model as a\n * compact context note while keeping only the latest full snapshot in reconnect memory under\n * `StateKey: 'app-context'`. Null-safe — hosts that supply no `AppContext$` (custom apps) simply get\n * no streaming, and the session-start prompt injection still applies.\n */\n protected override OnInitialize(): void {\n const stream = this.Context?.AppContext$;\n if (!stream) {\n return;\n }\n let subscribingSynchronously = true;\n this.appContextSub = stream\n .pipe(distinctUntilChanged((a, b) => JSON.stringify(a) === JSON.stringify(b)))\n .subscribe((snapshot) => {\n if (!snapshot) {\n return;\n }\n if (subscribingSynchronously) {\n // BehaviorSubject's current value was already injected into SystemPrompt at session mint:\n // record it as the diff baseline without sending a duplicate t=0 wire note.\n this.baselineSnapshot = snapshot;\n return;\n }\n this.pendingSnapshot = snapshot;\n if (this.coalesceTimer === null) {\n this.coalesceTimer = setTimeout(() => this.FlushPending(), CLIENT_CONTEXT_COALESCE_MS);\n }\n });\n subscribingSynchronously = false;\n }\n\n /**\n * Immediately flushes any buffered `AppContext$` update, emitting a compact delta on the live wire\n * and recording the full latest snapshot under `StateKey: 'app-context'` for reconnect continuity.\n */\n public FlushPending(): void {\n if (this.coalesceTimer !== null) {\n clearTimeout(this.coalesceTimer);\n this.coalesceTimer = null;\n }\n const latest = this.pendingSnapshot;\n this.pendingSnapshot = null;\n if (!latest) {\n return;\n }\n const delta = DiffAppContextSnapshot(this.baselineSnapshot, latest);\n this.baselineSnapshot = latest;\n if (!delta) {\n return;\n }\n const wireNote = FormatAppContextNote(delta);\n if (!wireNote) {\n return;\n }\n const fullMemoryNote = FormatAppContextNote(latest);\n this.Context?.SendContextNote(wireNote, {\n StateKey: APP_CONTEXT_MEMORY_STATE_KEY,\n ...(fullMemoryNote && fullMemoryNote !== wireNote ? { MemoryText: fullMemoryNote } : {}),\n });\n }\n\n /** Tolerantly parses the `{ action, params, target? }` arguments. */\n private parseArgs(argsJson: string): {\n action: string | null;\n params: Record<string, unknown>;\n target: { channel: string; instance?: string } | null;\n } {\n try {\n const parsed = JSON.parse(argsJson) as { action?: unknown; params?: unknown; target?: unknown };\n const action = typeof parsed.action === 'string' && parsed.action.trim().length > 0 ? parsed.action.trim() : null;\n const params =\n parsed.params && typeof parsed.params === 'object' && !Array.isArray(parsed.params)\n ? (parsed.params as Record<string, unknown>)\n : {};\n return { action, params, target: this.parseTarget(parsed.target) };\n } catch {\n return { action: null, params: {}, target: null };\n }\n }\n\n /** Reads a `target` — `{ channel, instance? }` — or `null` when absent or unusable (the call is then an app action). */\n private parseTarget(raw: unknown): { channel: string; instance?: string } | null {\n if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {\n return null;\n }\n const target = raw as { channel?: unknown; instance?: unknown };\n const channel = typeof target.channel === 'string' ? target.channel.trim() : '';\n if (channel.length === 0) {\n return null;\n }\n const instance = typeof target.instance === 'string' && target.instance.trim().length > 0 ? target.instance.trim() : undefined;\n return instance ? { channel, instance } : { channel };\n }\n\n /** Unsubscribes the app-context stream, cancels any pending coalescer timer, and tears down. */\n public override Dispose(): void {\n if (this.coalesceTimer !== null) {\n clearTimeout(this.coalesceTimer);\n this.coalesceTimer = null;\n }\n this.pendingSnapshot = null;\n this.baselineSnapshot = null;\n this.appContextSub?.unsubscribe();\n this.appContextSub = null;\n super.Dispose();\n }\n}\n\n/**\n * Tree-shaking prevention for {@link ClientContextChannel}'s `@RegisterClass` registration. Called\n * from a static code path in `conversations.module.ts` so the registration always executes —\n * mirroring every other realtime channel client.\n */\nexport function LoadClientContextChannel(): void {\n // no-op — the import + call create a static reference bundlers cannot eliminate\n}\n"]}
|
package/dist/lib/components/realtime/interactive-component/interactive-component-channel.d.ts
CHANGED
|
@@ -123,6 +123,7 @@ export declare class InteractiveComponentChannel extends BaseRealtimeChannelClie
|
|
|
123
123
|
* configuration says not to swap, the agent is told one exists); with auto-open on, a component that is not open is opened.
|
|
124
124
|
*/
|
|
125
125
|
OnDelegationArtifacts(artifacts: readonly ParsedDelegationArtifact[]): Promise<void>;
|
|
126
|
+
private isDelegatedArtifactCandidate;
|
|
126
127
|
/** Opens a delegated artifact; one that is not a component is ignored (expected), anything else is logged. */
|
|
127
128
|
private autoOpen;
|
|
128
129
|
/** Moves an open instance to the version a delegated run produced, when that version is newer. */
|
package/dist/lib/components/realtime/interactive-component/interactive-component-channel.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive-component-channel.d.ts","sourceRoot":"","sources":["../../../../../src/lib/components/realtime/interactive-component/interactive-component-channel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAEH,KAAK,oBAAoB,EAEzB,KAAK,yBAAyB,EAGjC,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EACH,yBAAyB,EAGzB,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EACjC,MAAM,kCAAkC,CAAC;AAG1C,OAAO,EAAE,uBAAuB,EAAoD,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"interactive-component-channel.d.ts","sourceRoot":"","sources":["../../../../../src/lib/components/realtime/interactive-component/interactive-component-channel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAEH,KAAK,oBAAoB,EAEzB,KAAK,yBAAyB,EAGjC,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EACH,yBAAyB,EAGzB,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EACjC,MAAM,kCAAkC,CAAC;AAG1C,OAAO,EAAE,uBAAuB,EAAoD,MAAM,6BAA6B,CAAC;AAOxH,OAAO,EAAE,4CAA4C,EAAE,MAAM,oDAAoD,CAAC;AAElH,OAAO,EAMH,KAAK,iBAAiB,EAEtB,KAAK,wBAAwB,EAE7B,KAAK,0BAA0B,EAElC,MAAM,+BAA+B,CAAC;AA2CvC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBACa,2BAA4B,SAAQ,yBAAyB,CAAC,4CAA4C,CAAC;IACpH,oCAAoC;IACpC,SAAgB,MAAM,0BAAkF;IAExG,2FAA2F;IACpF,MAAM,EAAE,0BAA0B,CAA+C;IAExF,gGAAgG;IAChG,SAAS,CAAC,oBAAoB,SAA2B;IACzD,iFAAiF;IACjF,SAAS,CAAC,YAAY,SAAkB;IAExC,OAAO,CAAC,cAAc,CAAyC;IAC/D,OAAO,CAAC,OAAO,CAA6D;IAC5E,OAAO,CAAC,WAAW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C,cAAc;IAUtB;;;;OAIG;IACa,0BAA0B,CAAC,SAAS,EAAE,SAAS,wBAAwB,EAAE,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO;IAQvH;;;OAGG;IACmB,qBAAqB,CAAC,SAAS,EAAE,SAAS,wBAAwB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAgB1G,OAAO,CAAC,4BAA4B;IAUpC,8GAA8G;YAChG,QAAQ;IAOtB,kGAAkG;YACpF,gBAAgB;IA+B9B,yHAAyH;IACzH,OAAO,CAAC,WAAW;IAkBnB;;;OAGG;IACmB,SAAS,CAC3B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,UAAU,EAChB,KAAK,EAAE,oBAAoB,EAC3B,UAAU,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,yBAAyB,CAAC;IAmBrC;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAMzB;;;OAGG;IACH,OAAO,CAAC,eAAe;IAwBvB,qCAAqC;IACrC,OAAO,CAAC,QAAQ;IAIhB,2EAA2E;YAC7D,WAAW;IAqBzB,eAAe;IACf,OAAO,CAAC,aAAa;IAQrB,qDAAqD;YACvC,aAAa;IAgC3B,kFAAkF;YACpE,aAAa;IAa3B,6FAA6F;YAC/E,UAAU;IA8CxB,6CAA6C;IAC7C,OAAO,CAAC,QAAQ;IAehB,+FAA+F;IAC/F,OAAO,CAAC,WAAW;IAenB;;;OAGG;IACI,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,iBAAiB,GAAG,IAAI;IA4BjF,yCAAyC;IACzC,OAAO,CAAC,UAAU;IAOlB;;;OAGG;IACH,OAAO,CAAC,cAAc;CASzB;AAED;;;;GAIG;AACH,wBAAgB,uCAAuC,IAAI,IAAI,CAE9D"}
|
|
@@ -13,6 +13,7 @@ import { SummarizeDataState, ToBoundedJson } from './component-data-state';
|
|
|
13
13
|
import { ComponentInstanceEngine, InstanceLimitError } from './component-instance-engine';
|
|
14
14
|
import { ParseInteractiveComponentConfig } from './interactive-component-config';
|
|
15
15
|
import { ChannelFrameCapture } from '@memberjunction/ng-realtime-channels';
|
|
16
|
+
import { IsCollaborativeArtifactDescriptor, IsComponentArtifactDescriptor, } from '../artifact-workspace/artifact-workspace-types';
|
|
16
17
|
import { RealtimeInteractiveComponentSurfaceComponent } from './realtime-interactive-component-surface.component';
|
|
17
18
|
import { RunViewComponentArtifactSource } from './run-view-component-artifact-source';
|
|
18
19
|
import { BUILTIN_VERBS, ComponentArtifactError, DEFAULT_INTERACTIVE_COMPONENT_CONFIG, INTERACTIVE_COMPONENT_CHANNEL_KEY, INTERACTIVE_COMPONENT_CLIENT_PLUGIN_CLASS, } from './interactive-component-types';
|
|
@@ -427,7 +428,8 @@ let InteractiveComponentChannel = class InteractiveComponentChannel extends Base
|
|
|
427
428
|
if (artifacts.some((a) => this.Engine.FindByArtifact(a.ArtifactID))) {
|
|
428
429
|
return true;
|
|
429
430
|
}
|
|
430
|
-
|
|
431
|
+
const candidateArtifacts = artifacts.filter((a) => this.isDelegatedArtifactCandidate(a));
|
|
432
|
+
return candidateArtifacts.length > 0 && ParseInteractiveComponentConfig(config).Config.AutoOpenDelegatedComponents;
|
|
431
433
|
}
|
|
432
434
|
/**
|
|
433
435
|
* Takes a delegated run's artifacts: an artifact that is already open moves to its newer version (or, when the
|
|
@@ -438,12 +440,23 @@ let InteractiveComponentChannel = class InteractiveComponentChannel extends Base
|
|
|
438
440
|
const open = this.Engine.FindByArtifact(artifact.ArtifactID);
|
|
439
441
|
if (open) {
|
|
440
442
|
await this.takeNewerVersion(open, artifact);
|
|
443
|
+
continue;
|
|
441
444
|
}
|
|
442
|
-
|
|
445
|
+
if (!this.isDelegatedArtifactCandidate(artifact)) {
|
|
446
|
+
continue;
|
|
447
|
+
}
|
|
448
|
+
if (this.Config.AutoOpenDelegatedComponents) {
|
|
443
449
|
await this.autoOpen(artifact);
|
|
444
450
|
}
|
|
445
451
|
}
|
|
446
452
|
}
|
|
453
|
+
isDelegatedArtifactCandidate(artifact) {
|
|
454
|
+
if (IsCollaborativeArtifactDescriptor(artifact.ArtifactTypeName, artifact.DriverClass)) {
|
|
455
|
+
return false;
|
|
456
|
+
}
|
|
457
|
+
return (IsComponentArtifactDescriptor(artifact.ArtifactTypeName, artifact.DriverClass) ||
|
|
458
|
+
(!artifact.ArtifactTypeName?.trim() && !artifact.DriverClass?.trim()));
|
|
459
|
+
}
|
|
447
460
|
/** Opens a delegated artifact; one that is not a component is ignored (expected), anything else is logged. */
|
|
448
461
|
async autoOpen(artifact) {
|
|
449
462
|
const opened = await this.Open({ artifactVersionId: artifact.ArtifactVersionID });
|