@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
|
@@ -0,0 +1,944 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { REALTIME_CHANNEL_CONTRACT_VERSION, } from '@memberjunction/ai-core-plus';
|
|
8
|
+
import { LogError, RunView } from '@memberjunction/core';
|
|
9
|
+
import { ArtifactPermissionEngine, MJEnvironmentEntityExtended, } from '@memberjunction/core-entities';
|
|
10
|
+
import { EscapeSQLString, RegisterClass, SafeJSONParse, UUIDsEqual } from '@memberjunction/global';
|
|
11
|
+
import { ChannelFrameCapture } from '@memberjunction/ng-realtime-channels';
|
|
12
|
+
import { BaseRealtimeChannelClient, } from '@memberjunction/realtime-runtime';
|
|
13
|
+
import { ArtifactWorkspaceEngine } from './artifact-workspace-engine';
|
|
14
|
+
import { ARTIFACT_WORKSPACE_CHANNEL_KEY, ARTIFACT_WORKSPACE_CLIENT_PLUGIN_CLASS, DEFAULT_ARTIFACT_WORKSPACE_CONFIG, IsCollaborativeArtifactDescriptor, IsComponentArtifactDescriptor, } from './artifact-workspace-types';
|
|
15
|
+
import { RealtimeArtifactWorkspaceSurfaceComponent } from './realtime-artifact-workspace-surface.component';
|
|
16
|
+
const UUID_PATTERN = /^\{?[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\}?$/i;
|
|
17
|
+
function readString(bag, key) {
|
|
18
|
+
const value = bag[key];
|
|
19
|
+
return typeof value === 'string' && value.trim().length > 0 ? value.trim() : undefined;
|
|
20
|
+
}
|
|
21
|
+
function readNumber(bag, key) {
|
|
22
|
+
const value = bag[key];
|
|
23
|
+
return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
|
|
24
|
+
}
|
|
25
|
+
function failure(code, error, details) {
|
|
26
|
+
return details
|
|
27
|
+
? { Success: false, ErrorCode: code, Error: error, Details: details }
|
|
28
|
+
: { Success: false, ErrorCode: code, Error: error };
|
|
29
|
+
}
|
|
30
|
+
function parseArtifactWorkspaceConfig(raw) {
|
|
31
|
+
const cfg = { ...DEFAULT_ARTIFACT_WORKSPACE_CONFIG };
|
|
32
|
+
if (raw) {
|
|
33
|
+
if (typeof raw['autoOpenDelegatedArtifacts'] === 'boolean') {
|
|
34
|
+
cfg.AutoOpenDelegatedArtifacts = raw['autoOpenDelegatedArtifacts'];
|
|
35
|
+
}
|
|
36
|
+
if (typeof raw['swapToNewerVersions'] === 'boolean') {
|
|
37
|
+
cfg.SwapToNewerVersions = raw['swapToNewerVersions'];
|
|
38
|
+
}
|
|
39
|
+
if (typeof raw['maxInstances'] === 'number') {
|
|
40
|
+
cfg.MaxInstances = raw['maxInstances'];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return cfg;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The `ArtifactWorkspace` realtime channel: displays and focuses collaborative artifacts
|
|
47
|
+
* (`Markdown Document`, `Excel Spreadsheet`, `Presentation`, `Whiteboard Diagram`, etc.)
|
|
48
|
+
* beside a live co-agent conversation, and reacts automatically when delegated background
|
|
49
|
+
* agents produce or revise artifacts.
|
|
50
|
+
*
|
|
51
|
+
* Strictly partitioned from `InteractiveComponent`, which owns React/Angular `Component`
|
|
52
|
+
* artifacts and their derived spec methods.
|
|
53
|
+
*/
|
|
54
|
+
function anchorToJson(anchor) {
|
|
55
|
+
const out = { domain: anchor.domain };
|
|
56
|
+
if (anchor.heading !== undefined)
|
|
57
|
+
out['heading'] = anchor.heading;
|
|
58
|
+
if (anchor.blockId !== undefined)
|
|
59
|
+
out['blockId'] = anchor.blockId;
|
|
60
|
+
if (anchor.quote !== undefined)
|
|
61
|
+
out['quote'] = anchor.quote;
|
|
62
|
+
if (anchor.sheet !== undefined)
|
|
63
|
+
out['sheet'] = anchor.sheet;
|
|
64
|
+
if (anchor.range !== undefined)
|
|
65
|
+
out['range'] = anchor.range;
|
|
66
|
+
if (anchor.slideNumber !== undefined)
|
|
67
|
+
out['slideNumber'] = anchor.slideNumber;
|
|
68
|
+
if (anchor.slideId !== undefined)
|
|
69
|
+
out['slideId'] = anchor.slideId;
|
|
70
|
+
if (anchor.elementId !== undefined)
|
|
71
|
+
out['elementId'] = anchor.elementId;
|
|
72
|
+
return out;
|
|
73
|
+
}
|
|
74
|
+
function inferSelectionDomain(args, artifactTypeName) {
|
|
75
|
+
if (readString(args, 'sheet') || readString(args, 'range')) {
|
|
76
|
+
return 'spreadsheet';
|
|
77
|
+
}
|
|
78
|
+
if (readNumber(args, 'slideNumber') !== undefined || readString(args, 'elementId')) {
|
|
79
|
+
const t = artifactTypeName?.trim().toLowerCase() ?? '';
|
|
80
|
+
return t.includes('whiteboard') ? 'whiteboard' : 'slides';
|
|
81
|
+
}
|
|
82
|
+
const t = artifactTypeName?.trim().toLowerCase() ?? '';
|
|
83
|
+
if (t.includes('spreadsheet') || t.includes('excel'))
|
|
84
|
+
return 'spreadsheet';
|
|
85
|
+
if (t.includes('presentation') || t.includes('slide'))
|
|
86
|
+
return 'slides';
|
|
87
|
+
if (t.includes('whiteboard'))
|
|
88
|
+
return 'whiteboard';
|
|
89
|
+
return 'document';
|
|
90
|
+
}
|
|
91
|
+
const VALID_VIEW_MODES = new Set([
|
|
92
|
+
'edit',
|
|
93
|
+
'suggest',
|
|
94
|
+
'diff',
|
|
95
|
+
'present',
|
|
96
|
+
]);
|
|
97
|
+
function readViewMode(bag, key) {
|
|
98
|
+
const raw = readString(bag, key);
|
|
99
|
+
if (!raw)
|
|
100
|
+
return undefined;
|
|
101
|
+
return VALID_VIEW_MODES.has(raw)
|
|
102
|
+
? raw
|
|
103
|
+
: undefined;
|
|
104
|
+
}
|
|
105
|
+
let ArtifactWorkspaceChannel = class ArtifactWorkspaceChannel extends BaseRealtimeChannelClient {
|
|
106
|
+
Engine = new ArtifactWorkspaceEngine(DEFAULT_ARTIFACT_WORKSPACE_CONFIG.MaxInstances);
|
|
107
|
+
Config = { ...DEFAULT_ARTIFACT_WORKSPACE_CONFIG };
|
|
108
|
+
surface = null;
|
|
109
|
+
pendingRehydration = null;
|
|
110
|
+
engineChangedSub = null;
|
|
111
|
+
suppressStateSave = false;
|
|
112
|
+
disposed = false;
|
|
113
|
+
get ChannelName() {
|
|
114
|
+
return ARTIFACT_WORKSPACE_CHANNEL_KEY;
|
|
115
|
+
}
|
|
116
|
+
get InstanceId() {
|
|
117
|
+
return 'all';
|
|
118
|
+
}
|
|
119
|
+
get TabTitle() {
|
|
120
|
+
return 'Workspace';
|
|
121
|
+
}
|
|
122
|
+
get TabIcon() {
|
|
123
|
+
return 'fa-solid fa-file-lines';
|
|
124
|
+
}
|
|
125
|
+
GetToolDefinitions() {
|
|
126
|
+
return [];
|
|
127
|
+
}
|
|
128
|
+
GetOnboardingDetails() {
|
|
129
|
+
return {
|
|
130
|
+
Heading: 'Artifact Workspace',
|
|
131
|
+
Description: 'Open and collaborate on live Docs, Spreadsheets, Slide Decks, and Whiteboards side-by-side with your co-agent.',
|
|
132
|
+
Tips: [
|
|
133
|
+
'Agents automatically surface newly created or updated Docs, Sheets, and Slides here.',
|
|
134
|
+
'You and the agent see active document focus and edits in real time.',
|
|
135
|
+
],
|
|
136
|
+
IconClass: 'fa-solid fa-file-lines',
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
GetDescriptor() {
|
|
140
|
+
const verbs = [
|
|
141
|
+
{
|
|
142
|
+
Name: 'focus',
|
|
143
|
+
Description: 'Brings an already-open workspace artifact tab into the foreground.',
|
|
144
|
+
ParametersSchema: {
|
|
145
|
+
type: 'object',
|
|
146
|
+
properties: {
|
|
147
|
+
artifactId: { type: 'string', description: 'Artifact ID to focus.' },
|
|
148
|
+
},
|
|
149
|
+
additionalProperties: false,
|
|
150
|
+
},
|
|
151
|
+
InvokableBy: 'agent',
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
Name: 'show_version',
|
|
155
|
+
Description: 'Switches an open workspace artifact tab to display another saved version.',
|
|
156
|
+
ParametersSchema: {
|
|
157
|
+
type: 'object',
|
|
158
|
+
properties: {
|
|
159
|
+
artifactId: { type: 'string', description: 'Optional artifact ID; defaults to the active workspace tab.' },
|
|
160
|
+
versionId: { type: 'string', description: 'Artifact version ID to display.' },
|
|
161
|
+
versionNumber: { type: 'number', description: 'Optional version number.' },
|
|
162
|
+
},
|
|
163
|
+
required: ['versionId'],
|
|
164
|
+
additionalProperties: false,
|
|
165
|
+
},
|
|
166
|
+
InvokableBy: 'agent',
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
Name: 'refresh',
|
|
170
|
+
Description: 'Refreshes the active or named workspace artifact viewer after external mutations.',
|
|
171
|
+
ParametersSchema: {
|
|
172
|
+
type: 'object',
|
|
173
|
+
properties: {
|
|
174
|
+
artifactId: { type: 'string', description: 'Artifact ID to refresh.' },
|
|
175
|
+
versionNumber: { type: 'number', description: 'Latest version number if known.' },
|
|
176
|
+
},
|
|
177
|
+
additionalProperties: false,
|
|
178
|
+
},
|
|
179
|
+
InvokableBy: 'agent',
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
Name: 'close',
|
|
183
|
+
Description: 'Closes an open workspace artifact tab.',
|
|
184
|
+
ParametersSchema: {
|
|
185
|
+
type: 'object',
|
|
186
|
+
properties: {
|
|
187
|
+
artifactId: { type: 'string', description: 'Optional artifact ID to close; defaults to the active tab.' },
|
|
188
|
+
},
|
|
189
|
+
additionalProperties: false,
|
|
190
|
+
},
|
|
191
|
+
InvokableBy: 'agent',
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
Name: 'navigate_to_anchor',
|
|
195
|
+
Description: 'Scrolls/focuses a specific worksheet range, slide number, heading, or block inside an open workspace artifact.',
|
|
196
|
+
ParametersSchema: {
|
|
197
|
+
type: 'object',
|
|
198
|
+
properties: {
|
|
199
|
+
artifactId: { type: 'string', description: 'Optional artifact ID; defaults to the active tab.' },
|
|
200
|
+
sheet: { type: 'string', description: 'Target worksheet tab name.' },
|
|
201
|
+
range: { type: 'string', description: 'Target A1 cell or range.' },
|
|
202
|
+
slideNumber: { type: 'number', description: '1-based target slide number.' },
|
|
203
|
+
elementId: { type: 'string', description: 'Target slide or whiteboard element ID.' },
|
|
204
|
+
heading: { type: 'string', description: 'Target Markdown heading text.' },
|
|
205
|
+
blockId: { type: 'string', description: 'Target block or section identifier.' },
|
|
206
|
+
highlightMs: { type: 'number', description: 'Optional temporary highlight duration in milliseconds.' },
|
|
207
|
+
},
|
|
208
|
+
additionalProperties: false,
|
|
209
|
+
},
|
|
210
|
+
InvokableBy: 'agent',
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
Name: 'set_view_mode',
|
|
214
|
+
Description: 'Switches the display mode of an open workspace artifact viewer.',
|
|
215
|
+
ParametersSchema: {
|
|
216
|
+
type: 'object',
|
|
217
|
+
properties: {
|
|
218
|
+
artifactId: { type: 'string', description: 'Optional artifact ID; defaults to the active tab.' },
|
|
219
|
+
mode: {
|
|
220
|
+
type: 'string',
|
|
221
|
+
enum: ['edit', 'suggest', 'diff', 'present'],
|
|
222
|
+
description: 'Target viewer mode.',
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
required: ['mode'],
|
|
226
|
+
additionalProperties: false,
|
|
227
|
+
},
|
|
228
|
+
InvokableBy: 'agent',
|
|
229
|
+
},
|
|
230
|
+
];
|
|
231
|
+
return {
|
|
232
|
+
Key: this.ChannelName,
|
|
233
|
+
Version: REALTIME_CHANNEL_CONTRACT_VERSION,
|
|
234
|
+
DisplayName: 'Artifact Workspace',
|
|
235
|
+
OwningPackage: '@memberjunction/ng-conversations',
|
|
236
|
+
Instructions: 'Shows collaborative Docs (Markdown Document), Spreadsheets (Excel Spreadsheet), Slide Decks (Presentation), ' +
|
|
237
|
+
'and Whiteboards beside the conversation. Open with artifactId, artifactVersionId, or name; use focus, refresh, ' +
|
|
238
|
+
'show_version, and close to manage workspace tabs. For Component artifacts, use InteractiveComponent instead.',
|
|
239
|
+
Nouns: [
|
|
240
|
+
{
|
|
241
|
+
Name: 'artifacts',
|
|
242
|
+
Description: 'The workspace artifacts currently open, plus activeInstanceId.',
|
|
243
|
+
Schema: { type: 'object', additionalProperties: { type: 'object' } },
|
|
244
|
+
},
|
|
245
|
+
],
|
|
246
|
+
Verbs: verbs,
|
|
247
|
+
Inputs: {
|
|
248
|
+
type: 'object',
|
|
249
|
+
properties: {
|
|
250
|
+
artifactId: { type: 'string', description: 'ID of the collaborative artifact to open.' },
|
|
251
|
+
artifactVersionId: { type: 'string', description: 'Optional specific artifact version ID.' },
|
|
252
|
+
versionNumber: { type: 'number', description: 'Optional version number to show.' },
|
|
253
|
+
name: {
|
|
254
|
+
type: 'string',
|
|
255
|
+
description: 'Optional display title (used to look up the artifact when artifactId/artifactVersionId is omitted).',
|
|
256
|
+
},
|
|
257
|
+
artifactTypeName: { type: 'string', description: 'Optional canonical artifact type name.' },
|
|
258
|
+
driverClass: { type: 'string', description: 'Optional driver class name.' },
|
|
259
|
+
},
|
|
260
|
+
additionalProperties: false,
|
|
261
|
+
},
|
|
262
|
+
Events: [
|
|
263
|
+
{ Name: 'opened', Description: 'A workspace artifact tab was opened.' },
|
|
264
|
+
{ Name: 'focused', Description: 'A workspace artifact tab gained focus.' },
|
|
265
|
+
{ Name: 'version_changed', Description: 'A workspace tab switched to a different version.' },
|
|
266
|
+
{
|
|
267
|
+
Name: 'newer_version_available',
|
|
268
|
+
Description: 'A newer version of an open workspace artifact is available while SwapToNewerVersions is disabled.',
|
|
269
|
+
},
|
|
270
|
+
{ Name: 'refreshed', Description: 'A workspace tab refreshed its rendered artifact.' },
|
|
271
|
+
{ Name: 'selection_changed', Description: 'User moved active cursor, range, or slide selection inside a workspace artifact.' },
|
|
272
|
+
{ Name: 'navigated_to_anchor', Description: 'Workspace viewer focused a requested section, range, or slide.' },
|
|
273
|
+
{ Name: 'view_mode_changed', Description: 'Workspace artifact view mode changed.' },
|
|
274
|
+
{ Name: 'closed', Description: 'A workspace artifact tab was closed.' },
|
|
275
|
+
],
|
|
276
|
+
DisplayPolicy: 'on-demand',
|
|
277
|
+
DefaultAvailability: 'all-sessions',
|
|
278
|
+
MaxExposure: 'pixels',
|
|
279
|
+
MultiInstance: true,
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
OnInitialize() {
|
|
283
|
+
this.Config = parseArtifactWorkspaceConfig(this.Context?.ChannelConfig);
|
|
284
|
+
this.Engine.SetMaxInstances(this.Config.MaxInstances);
|
|
285
|
+
this.engineChangedSub?.unsubscribe();
|
|
286
|
+
this.engineChangedSub = this.Engine.Changed$.subscribe((change) => {
|
|
287
|
+
if (!this.suppressStateSave && change.Kind !== 'refresh' && change.Kind !== 'rehydrating') {
|
|
288
|
+
this.persistWorkspaceState();
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
if (ChannelFrameCapture.Instance.Capturer) {
|
|
292
|
+
this.EnableVisualPerception({ GetLatestFrame: () => this.CaptureActiveFrame() });
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
async CaptureActiveFrame() {
|
|
296
|
+
const capturer = ChannelFrameCapture.Instance.Capturer;
|
|
297
|
+
if (!capturer ||
|
|
298
|
+
this.Exposure !== 'pixels' ||
|
|
299
|
+
!this.Context?.Client?.IsTrackEstablished('video', 'inbound')) {
|
|
300
|
+
return null;
|
|
301
|
+
}
|
|
302
|
+
const element = this.surface?.GetActiveElement() ?? null;
|
|
303
|
+
if (!element) {
|
|
304
|
+
return null;
|
|
305
|
+
}
|
|
306
|
+
try {
|
|
307
|
+
return await capturer(element);
|
|
308
|
+
}
|
|
309
|
+
catch (error) {
|
|
310
|
+
LogError(`[RealtimeChannel:${ARTIFACT_WORKSPACE_CHANNEL_KEY}] Frame capture failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
311
|
+
return null;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
GetSurfaceComponent() {
|
|
315
|
+
return RealtimeArtifactWorkspaceSurfaceComponent;
|
|
316
|
+
}
|
|
317
|
+
BindSurface(instance) {
|
|
318
|
+
this.surface = instance;
|
|
319
|
+
instance.Engine = this.Engine;
|
|
320
|
+
instance.AgentName = this.Context?.AgentName ?? 'The agent';
|
|
321
|
+
instance.Provider = this.Context?.Provider ?? null;
|
|
322
|
+
instance.CurrentUser = this.Context?.Provider?.CurrentUser ?? null;
|
|
323
|
+
const configuredEnvId = this.Context?.ChannelConfig?.['environmentId'];
|
|
324
|
+
instance.EnvironmentID =
|
|
325
|
+
typeof configuredEnvId === 'string' && configuredEnvId.trim().length > 0
|
|
326
|
+
? configuredEnvId.trim()
|
|
327
|
+
: MJEnvironmentEntityExtended.DefaultEnvironmentID;
|
|
328
|
+
instance.OnUserSelected = (instanceId) => {
|
|
329
|
+
this.EmitChannelEvent('focused', { instanceId, by: 'user' }, undefined, instanceId);
|
|
330
|
+
this.RecordChange({ Author: 'user' });
|
|
331
|
+
void this.NotifyVisualChange();
|
|
332
|
+
};
|
|
333
|
+
instance.OnUserClosed = (instanceId) => {
|
|
334
|
+
this.EmitChannelEvent('closed', { instanceId, by: 'user' }, undefined, instanceId);
|
|
335
|
+
this.RecordChange({ Author: 'user' });
|
|
336
|
+
};
|
|
337
|
+
instance.OnUserVersionSaved = (instanceId, event) => {
|
|
338
|
+
const rec = this.Engine.Get(instanceId);
|
|
339
|
+
this.EmitChannelEvent('version_changed', {
|
|
340
|
+
artifactId: event.ArtifactID,
|
|
341
|
+
artifactVersionId: event.VersionID ?? rec?.ArtifactVersionID ?? null,
|
|
342
|
+
versionNumber: event.VersionNumber,
|
|
343
|
+
by: 'user',
|
|
344
|
+
}, undefined, instanceId);
|
|
345
|
+
this.RecordChange({ Author: 'user' });
|
|
346
|
+
};
|
|
347
|
+
instance.OnUserSelectionChanged = (delta) => {
|
|
348
|
+
this.EmitSelectionDelta(delta);
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
EmitSelectionDelta(delta) {
|
|
352
|
+
this.Engine.UpdateSelection(delta.instanceId, delta.anchor);
|
|
353
|
+
const payload = {
|
|
354
|
+
instanceId: delta.instanceId,
|
|
355
|
+
artifactId: delta.artifactId,
|
|
356
|
+
anchor: anchorToJson(delta.anchor),
|
|
357
|
+
};
|
|
358
|
+
if (delta.artifactTypeName) {
|
|
359
|
+
payload['artifactTypeName'] = delta.artifactTypeName;
|
|
360
|
+
}
|
|
361
|
+
this.EmitChannelEvent('selection_changed', payload, undefined, delta.instanceId);
|
|
362
|
+
this.RecordChange({ Author: 'user' });
|
|
363
|
+
void this.NotifyVisualChange();
|
|
364
|
+
}
|
|
365
|
+
UnbindSurface() {
|
|
366
|
+
this.surface = null;
|
|
367
|
+
}
|
|
368
|
+
Dispose() {
|
|
369
|
+
this.disposed = true;
|
|
370
|
+
this.engineChangedSub?.unsubscribe();
|
|
371
|
+
this.engineChangedSub = null;
|
|
372
|
+
this.surface = null;
|
|
373
|
+
this.Engine.Dispose();
|
|
374
|
+
super.Dispose();
|
|
375
|
+
}
|
|
376
|
+
persistWorkspaceState() {
|
|
377
|
+
const serialized = this.SerializeState() ?? JSON.stringify({ activeArtifactId: null, instances: [] });
|
|
378
|
+
this.Context?.RequestSave(serialized);
|
|
379
|
+
}
|
|
380
|
+
SerializeState() {
|
|
381
|
+
const instances = this.Engine.Instances.map((r) => ({
|
|
382
|
+
ArtifactID: r.ArtifactID,
|
|
383
|
+
ArtifactVersionID: r.ArtifactVersionID,
|
|
384
|
+
VersionNumber: r.VersionNumber,
|
|
385
|
+
Name: r.Name,
|
|
386
|
+
ArtifactTypeName: r.ArtifactTypeName,
|
|
387
|
+
DriverClass: r.DriverClass,
|
|
388
|
+
}));
|
|
389
|
+
if (instances.length === 0) {
|
|
390
|
+
return null;
|
|
391
|
+
}
|
|
392
|
+
return JSON.stringify({
|
|
393
|
+
activeArtifactId: this.Engine.Instances.find((r) => r.InstanceID === this.Engine.ActiveID)?.ArtifactID ?? null,
|
|
394
|
+
instances,
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
RestoreState(stateJson) {
|
|
398
|
+
const parsed = SafeJSONParse(stateJson);
|
|
399
|
+
if (!parsed || !Array.isArray(parsed.instances) || parsed.instances.length === 0) {
|
|
400
|
+
return false;
|
|
401
|
+
}
|
|
402
|
+
const validItems = parsed.instances.filter((item) => item != null &&
|
|
403
|
+
typeof item === 'object' &&
|
|
404
|
+
Boolean(item.ArtifactID) &&
|
|
405
|
+
!IsComponentArtifactDescriptor(item.ArtifactTypeName, item.DriverClass));
|
|
406
|
+
if (validItems.length === 0) {
|
|
407
|
+
return false;
|
|
408
|
+
}
|
|
409
|
+
this.suppressStateSave = true;
|
|
410
|
+
try {
|
|
411
|
+
for (const existing of [...this.Engine.Instances]) {
|
|
412
|
+
this.Engine.Remove(existing.InstanceID);
|
|
413
|
+
}
|
|
414
|
+
for (const item of validItems) {
|
|
415
|
+
// Force CanEdit: false until async rehydration verifies permissions against the backend
|
|
416
|
+
this.Engine.AddOrFocus({ ...item, CanEdit: false });
|
|
417
|
+
}
|
|
418
|
+
if (parsed.activeArtifactId) {
|
|
419
|
+
const active = this.Engine.FindByArtifact(parsed.activeArtifactId);
|
|
420
|
+
if (active) {
|
|
421
|
+
this.Engine.SetActive(active.InstanceID);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
finally {
|
|
426
|
+
this.suppressStateSave = false;
|
|
427
|
+
}
|
|
428
|
+
const provider = this.Context?.Provider;
|
|
429
|
+
if (provider?.CurrentUser) {
|
|
430
|
+
this.Engine.SetRehydrating(true);
|
|
431
|
+
}
|
|
432
|
+
this.pendingRehydration = this.rehydrateRestoredInstances();
|
|
433
|
+
return true;
|
|
434
|
+
}
|
|
435
|
+
WaitForRehydration() {
|
|
436
|
+
return this.pendingRehydration ?? Promise.resolve();
|
|
437
|
+
}
|
|
438
|
+
async rehydrateRestoredInstances() {
|
|
439
|
+
const provider = this.Context?.Provider;
|
|
440
|
+
const user = provider?.CurrentUser;
|
|
441
|
+
if (!provider || !user) {
|
|
442
|
+
this.Engine.SetRehydrating(false);
|
|
443
|
+
this.pendingRehydration = null;
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
try {
|
|
447
|
+
const snapshot = [...this.Engine.Instances];
|
|
448
|
+
for (const record of snapshot) {
|
|
449
|
+
if (this.disposed) {
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
const resolved = await this.resolveArtifactMetadata({
|
|
453
|
+
artifactId: record.ArtifactID,
|
|
454
|
+
artifactVersionId: record.ArtifactVersionID,
|
|
455
|
+
versionNumber: record.VersionNumber,
|
|
456
|
+
name: undefined,
|
|
457
|
+
fallbackName: record.Name,
|
|
458
|
+
artifactTypeName: record.ArtifactTypeName,
|
|
459
|
+
driverClass: record.DriverClass,
|
|
460
|
+
});
|
|
461
|
+
if (this.disposed) {
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
this.suppressStateSave = true;
|
|
465
|
+
try {
|
|
466
|
+
if ('Success' in resolved) {
|
|
467
|
+
this.Engine.Remove(record.InstanceID);
|
|
468
|
+
continue;
|
|
469
|
+
}
|
|
470
|
+
this.Engine.UpdateRecordMetadata(record.InstanceID, {
|
|
471
|
+
ArtifactVersionID: resolved.ArtifactVersionID,
|
|
472
|
+
VersionNumber: resolved.VersionNumber,
|
|
473
|
+
Name: resolved.Name,
|
|
474
|
+
ArtifactTypeName: resolved.ArtifactTypeName,
|
|
475
|
+
DriverClass: resolved.DriverClass,
|
|
476
|
+
CanEdit: resolved.CanEdit,
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
finally {
|
|
480
|
+
this.suppressStateSave = false;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
finally {
|
|
485
|
+
if (!this.disposed) {
|
|
486
|
+
this.Engine.SetRehydrating(false);
|
|
487
|
+
}
|
|
488
|
+
this.pendingRehydration = null;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
GetState() {
|
|
492
|
+
const artifacts = {};
|
|
493
|
+
for (const record of this.Engine.Instances) {
|
|
494
|
+
artifacts[record.InstanceID] = {
|
|
495
|
+
artifactId: record.ArtifactID,
|
|
496
|
+
artifactVersionId: record.ArtifactVersionID ?? null,
|
|
497
|
+
versionNumber: record.VersionNumber ?? null,
|
|
498
|
+
name: record.Name,
|
|
499
|
+
artifactTypeName: record.ArtifactTypeName ?? null,
|
|
500
|
+
driverClass: record.DriverClass ?? null,
|
|
501
|
+
active: this.Engine.ActiveID === record.InstanceID,
|
|
502
|
+
viewMode: record.ViewMode ?? 'edit',
|
|
503
|
+
selection: record.Selection ? anchorToJson(record.Selection) : null,
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
const activeRecord = this.Engine.ActiveID ? this.Engine.Get(this.Engine.ActiveID) : undefined;
|
|
507
|
+
const activeSelection = activeRecord?.Selection
|
|
508
|
+
? {
|
|
509
|
+
instanceId: activeRecord.InstanceID,
|
|
510
|
+
artifactId: activeRecord.ArtifactID,
|
|
511
|
+
...(activeRecord.ArtifactTypeName ? { artifactTypeName: activeRecord.ArtifactTypeName } : {}),
|
|
512
|
+
anchor: anchorToJson(activeRecord.Selection),
|
|
513
|
+
}
|
|
514
|
+
: null;
|
|
515
|
+
return {
|
|
516
|
+
activeInstanceId: this.Engine.ActiveID,
|
|
517
|
+
activeSelection,
|
|
518
|
+
artifacts,
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
async OnOpen(inputs) {
|
|
522
|
+
const suppliedArtifactId = readString(inputs, 'artifactId');
|
|
523
|
+
const suppliedVersionId = readString(inputs, 'artifactVersionId');
|
|
524
|
+
const suppliedName = readString(inputs, 'name');
|
|
525
|
+
if (!suppliedArtifactId && !suppliedVersionId && !suppliedName) {
|
|
526
|
+
return failure('invalid_params', 'Provide artifactId, artifactVersionId, or name to open a workspace artifact.');
|
|
527
|
+
}
|
|
528
|
+
const suppliedType = readString(inputs, 'artifactTypeName');
|
|
529
|
+
const suppliedDriver = readString(inputs, 'driverClass');
|
|
530
|
+
if (IsComponentArtifactDescriptor(suppliedType, suppliedDriver)) {
|
|
531
|
+
return failure('use_interactive_component', 'Component artifacts must be opened with InteractiveComponent rather than ArtifactWorkspace.');
|
|
532
|
+
}
|
|
533
|
+
const resolved = await this.resolveArtifactMetadata({
|
|
534
|
+
artifactId: suppliedArtifactId,
|
|
535
|
+
artifactVersionId: suppliedVersionId,
|
|
536
|
+
versionNumber: readNumber(inputs, 'versionNumber'),
|
|
537
|
+
name: suppliedName,
|
|
538
|
+
artifactTypeName: suppliedType,
|
|
539
|
+
driverClass: suppliedDriver,
|
|
540
|
+
});
|
|
541
|
+
if ('Success' in resolved) {
|
|
542
|
+
return resolved;
|
|
543
|
+
}
|
|
544
|
+
if (IsComponentArtifactDescriptor(resolved.ArtifactTypeName, resolved.DriverClass)) {
|
|
545
|
+
return failure('use_interactive_component', `"${resolved.Name}" is a Component artifact; open it via InteractiveComponent.`);
|
|
546
|
+
}
|
|
547
|
+
const alreadyOpen = this.Engine.FindByArtifact(resolved.ArtifactID);
|
|
548
|
+
const record = this.Engine.AddOrFocus(resolved);
|
|
549
|
+
this.EmitChannelEvent(alreadyOpen ? 'focused' : 'opened', { artifactId: record.ArtifactID, name: record.Name }, undefined, record.InstanceID);
|
|
550
|
+
this.RecordChange({ Author: 'agent' });
|
|
551
|
+
void this.ConfirmVisualChange();
|
|
552
|
+
return {
|
|
553
|
+
Success: true,
|
|
554
|
+
Instance: record.InstanceID,
|
|
555
|
+
Result: {
|
|
556
|
+
instanceId: record.InstanceID,
|
|
557
|
+
opened: !alreadyOpen,
|
|
558
|
+
alreadyOpen: Boolean(alreadyOpen),
|
|
559
|
+
artifactId: record.ArtifactID,
|
|
560
|
+
artifactVersionId: record.ArtifactVersionID ?? null,
|
|
561
|
+
versionNumber: record.VersionNumber ?? null,
|
|
562
|
+
name: record.Name,
|
|
563
|
+
artifactTypeName: record.ArtifactTypeName ?? null,
|
|
564
|
+
},
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
AcceptsDelegationArtifacts(artifacts, config) {
|
|
568
|
+
if (artifacts.some((a) => Boolean(this.Engine.FindByArtifact(a.ArtifactID)))) {
|
|
569
|
+
return true;
|
|
570
|
+
}
|
|
571
|
+
const parsedConfig = parseArtifactWorkspaceConfig(config);
|
|
572
|
+
if (!parsedConfig.AutoOpenDelegatedArtifacts) {
|
|
573
|
+
return false;
|
|
574
|
+
}
|
|
575
|
+
return artifacts.some((a) => !IsComponentArtifactDescriptor(a.ArtifactTypeName, a.DriverClass) &&
|
|
576
|
+
IsCollaborativeArtifactDescriptor(a.ArtifactTypeName, a.DriverClass));
|
|
577
|
+
}
|
|
578
|
+
async OnDelegationArtifacts(artifacts) {
|
|
579
|
+
if (this.disposed) {
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
for (const artifact of artifacts) {
|
|
583
|
+
if (IsComponentArtifactDescriptor(artifact.ArtifactTypeName, artifact.DriverClass)) {
|
|
584
|
+
continue;
|
|
585
|
+
}
|
|
586
|
+
const existing = this.Engine.FindByArtifact(artifact.ArtifactID);
|
|
587
|
+
if (existing) {
|
|
588
|
+
await this.handleDelegatedUpdateForExistingTab(existing, artifact);
|
|
589
|
+
}
|
|
590
|
+
else if (this.Config.AutoOpenDelegatedArtifacts &&
|
|
591
|
+
IsCollaborativeArtifactDescriptor(artifact.ArtifactTypeName, artifact.DriverClass)) {
|
|
592
|
+
await this.Open({
|
|
593
|
+
artifactId: artifact.ArtifactID,
|
|
594
|
+
artifactVersionId: artifact.ArtifactVersionID,
|
|
595
|
+
name: artifact.Name,
|
|
596
|
+
...(artifact.ArtifactTypeName ? { artifactTypeName: artifact.ArtifactTypeName } : {}),
|
|
597
|
+
...(artifact.DriverClass ? { driverClass: artifact.DriverClass } : {}),
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
async handleDelegatedUpdateForExistingTab(existing, artifact) {
|
|
603
|
+
const sameVersion = Boolean(existing.ArtifactVersionID) &&
|
|
604
|
+
UUIDsEqual(existing.ArtifactVersionID, artifact.ArtifactVersionID);
|
|
605
|
+
if (sameVersion) {
|
|
606
|
+
this.Engine.SetActive(existing.InstanceID);
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
609
|
+
if (!this.Config.SwapToNewerVersions) {
|
|
610
|
+
this.EmitChannelEvent('newer_version_available', { current: existing.ArtifactVersionID ?? null, available: artifact.ArtifactVersionID }, undefined, existing.InstanceID);
|
|
611
|
+
if (this.Exposure !== 'none') {
|
|
612
|
+
this.Context?.SendContextNote(`[ArtifactWorkspace:${existing.InstanceID}] newer_version_available for "${existing.Name}" (${artifact.ArtifactVersionID}).`);
|
|
613
|
+
}
|
|
614
|
+
return;
|
|
615
|
+
}
|
|
616
|
+
const resolved = await this.resolveArtifactMetadata({
|
|
617
|
+
artifactId: artifact.ArtifactID,
|
|
618
|
+
artifactVersionId: artifact.ArtifactVersionID,
|
|
619
|
+
name: artifact.Name,
|
|
620
|
+
artifactTypeName: artifact.ArtifactTypeName ?? existing.ArtifactTypeName,
|
|
621
|
+
driverClass: artifact.DriverClass ?? existing.DriverClass,
|
|
622
|
+
});
|
|
623
|
+
if ('Success' in resolved) {
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
existing.CanEdit = resolved.CanEdit;
|
|
627
|
+
this.Engine.SwapVersion(existing.InstanceID, resolved.ArtifactVersionID ?? artifact.ArtifactVersionID, resolved.VersionNumber, resolved.Name);
|
|
628
|
+
this.Engine.SetActive(existing.InstanceID);
|
|
629
|
+
this.EmitChannelEvent('version_changed', {
|
|
630
|
+
artifactId: existing.ArtifactID,
|
|
631
|
+
artifactVersionId: existing.ArtifactVersionID ?? artifact.ArtifactVersionID,
|
|
632
|
+
versionNumber: existing.VersionNumber ?? null,
|
|
633
|
+
}, undefined, existing.InstanceID);
|
|
634
|
+
this.RecordChange({ Author: 'system' });
|
|
635
|
+
}
|
|
636
|
+
async ApplyVerb(verb, args, actor, instanceId) {
|
|
637
|
+
const normalized = verb.trim().toLowerCase();
|
|
638
|
+
const record = this.resolveTargetRecord(args, instanceId);
|
|
639
|
+
if (!record) {
|
|
640
|
+
return failure('unknown_instance', 'No matching workspace artifact tab is open.');
|
|
641
|
+
}
|
|
642
|
+
if (normalized === 'focus') {
|
|
643
|
+
this.Engine.SetActive(record.InstanceID);
|
|
644
|
+
this.EmitChannelEvent('focused', { artifactId: record.ArtifactID }, undefined, record.InstanceID);
|
|
645
|
+
this.RecordChange({ Author: actor });
|
|
646
|
+
return { Success: true, Instance: record.InstanceID, Result: { focused: true, artifactId: record.ArtifactID } };
|
|
647
|
+
}
|
|
648
|
+
if (normalized === 'show_version') {
|
|
649
|
+
const versionId = readString(args, 'versionId');
|
|
650
|
+
if (!versionId) {
|
|
651
|
+
return failure('invalid_params', 'show_version requires versionId.');
|
|
652
|
+
}
|
|
653
|
+
let versionNumber = readNumber(args, 'versionNumber');
|
|
654
|
+
const provider = this.Context?.Provider;
|
|
655
|
+
const user = provider?.CurrentUser;
|
|
656
|
+
if (provider && user) {
|
|
657
|
+
const cleanVersionId = versionId.replace(/[{}]/g, '');
|
|
658
|
+
if (!UUID_PATTERN.test(cleanVersionId)) {
|
|
659
|
+
return failure('invalid_params', 'show_version requires a valid UUID versionId.');
|
|
660
|
+
}
|
|
661
|
+
const rv = RunView.FromMetadataProvider(provider);
|
|
662
|
+
const verRes = await rv.RunView({
|
|
663
|
+
EntityName: 'MJ: Artifact Versions',
|
|
664
|
+
ExtraFilter: `ID='${EscapeSQLString(cleanVersionId)}'`,
|
|
665
|
+
MaxRows: 1,
|
|
666
|
+
ResultType: 'entity_object',
|
|
667
|
+
}, user);
|
|
668
|
+
const ver = verRes.Success ? verRes.Results[0] : undefined;
|
|
669
|
+
if (!ver) {
|
|
670
|
+
return failure('not_found', `Artifact version ${cleanVersionId} was not found.`);
|
|
671
|
+
}
|
|
672
|
+
if (!UUIDsEqual(ver.ArtifactID, record.ArtifactID)) {
|
|
673
|
+
return failure('invalid_params', `Artifact version ${cleanVersionId} does not belong to artifact ${record.ArtifactID}.`);
|
|
674
|
+
}
|
|
675
|
+
versionNumber = versionNumber ?? ver.VersionNumber;
|
|
676
|
+
}
|
|
677
|
+
this.Engine.SwapVersion(record.InstanceID, versionId, versionNumber);
|
|
678
|
+
this.EmitChannelEvent('version_changed', {
|
|
679
|
+
artifactId: record.ArtifactID,
|
|
680
|
+
artifactVersionId: versionId,
|
|
681
|
+
versionNumber: record.VersionNumber ?? null,
|
|
682
|
+
}, undefined, record.InstanceID);
|
|
683
|
+
this.RecordChange({ Author: actor });
|
|
684
|
+
return {
|
|
685
|
+
Success: true,
|
|
686
|
+
Instance: record.InstanceID,
|
|
687
|
+
Result: {
|
|
688
|
+
artifactId: record.ArtifactID,
|
|
689
|
+
artifactVersionId: versionId,
|
|
690
|
+
versionNumber: record.VersionNumber ?? null,
|
|
691
|
+
},
|
|
692
|
+
};
|
|
693
|
+
}
|
|
694
|
+
if (normalized === 'refresh') {
|
|
695
|
+
const versionNumber = readNumber(args, 'versionNumber');
|
|
696
|
+
this.Engine.TriggerRefresh(record.ArtifactID, versionNumber);
|
|
697
|
+
this.EmitChannelEvent('refreshed', { artifactId: record.ArtifactID, versionNumber: versionNumber ?? record.VersionNumber ?? null }, undefined, record.InstanceID);
|
|
698
|
+
this.RecordChange({ Author: actor });
|
|
699
|
+
return {
|
|
700
|
+
Success: true,
|
|
701
|
+
Instance: record.InstanceID,
|
|
702
|
+
Result: { refreshed: true, artifactId: record.ArtifactID },
|
|
703
|
+
};
|
|
704
|
+
}
|
|
705
|
+
if (normalized === 'navigate_to_anchor') {
|
|
706
|
+
const sheet = readString(args, 'sheet');
|
|
707
|
+
const range = readString(args, 'range');
|
|
708
|
+
const slideNumber = readNumber(args, 'slideNumber');
|
|
709
|
+
const elementId = readString(args, 'elementId');
|
|
710
|
+
const heading = readString(args, 'heading');
|
|
711
|
+
const blockId = readString(args, 'blockId');
|
|
712
|
+
const highlightMs = readNumber(args, 'highlightMs');
|
|
713
|
+
const anchor = {
|
|
714
|
+
domain: inferSelectionDomain(args, record.ArtifactTypeName),
|
|
715
|
+
...(sheet ? { sheet } : {}),
|
|
716
|
+
...(range ? { range } : {}),
|
|
717
|
+
...(slideNumber !== undefined ? { slideNumber } : {}),
|
|
718
|
+
...(elementId ? { elementId } : {}),
|
|
719
|
+
...(heading ? { heading } : {}),
|
|
720
|
+
...(blockId ? { blockId } : {}),
|
|
721
|
+
};
|
|
722
|
+
this.Engine.SetActive(record.InstanceID);
|
|
723
|
+
this.Engine.UpdateSelection(record.InstanceID, anchor);
|
|
724
|
+
this.Engine.RequestNavigateToAnchor({
|
|
725
|
+
InstanceID: record.InstanceID,
|
|
726
|
+
ArtifactID: record.ArtifactID,
|
|
727
|
+
...(sheet ? { Sheet: sheet } : {}),
|
|
728
|
+
...(range ? { Range: range } : {}),
|
|
729
|
+
...(slideNumber !== undefined ? { SlideNumber: slideNumber } : {}),
|
|
730
|
+
...(elementId ? { ElementID: elementId } : {}),
|
|
731
|
+
...(heading ? { Heading: heading } : {}),
|
|
732
|
+
...(blockId ? { BlockID: blockId } : {}),
|
|
733
|
+
...(highlightMs !== undefined ? { HighlightMs: highlightMs } : {}),
|
|
734
|
+
});
|
|
735
|
+
this.EmitChannelEvent('navigated_to_anchor', { artifactId: record.ArtifactID, anchor: anchorToJson(anchor) }, undefined, record.InstanceID);
|
|
736
|
+
this.RecordChange({ Author: actor });
|
|
737
|
+
return {
|
|
738
|
+
Success: true,
|
|
739
|
+
Instance: record.InstanceID,
|
|
740
|
+
Result: { artifactId: record.ArtifactID, anchor: anchorToJson(anchor) },
|
|
741
|
+
};
|
|
742
|
+
}
|
|
743
|
+
if (normalized === 'set_view_mode') {
|
|
744
|
+
const mode = readViewMode(args, 'mode');
|
|
745
|
+
if (!mode) {
|
|
746
|
+
return failure('invalid_params', 'set_view_mode requires mode to be one of: edit, suggest, diff, present.');
|
|
747
|
+
}
|
|
748
|
+
this.Engine.SetViewMode(record.InstanceID, mode);
|
|
749
|
+
this.EmitChannelEvent('view_mode_changed', { artifactId: record.ArtifactID, mode }, undefined, record.InstanceID);
|
|
750
|
+
this.RecordChange({ Author: actor });
|
|
751
|
+
return {
|
|
752
|
+
Success: true,
|
|
753
|
+
Instance: record.InstanceID,
|
|
754
|
+
Result: { artifactId: record.ArtifactID, mode },
|
|
755
|
+
};
|
|
756
|
+
}
|
|
757
|
+
if (normalized === 'close') {
|
|
758
|
+
const artifactId = record.ArtifactID;
|
|
759
|
+
this.Engine.Remove(record.InstanceID);
|
|
760
|
+
this.EmitChannelEvent('closed', { artifactId }, undefined, record.InstanceID);
|
|
761
|
+
this.RecordChange({ Author: actor });
|
|
762
|
+
return { Success: true, Instance: record.InstanceID, Result: { closed: true, artifactId } };
|
|
763
|
+
}
|
|
764
|
+
return failure('verb_failed', `Unknown ArtifactWorkspace verb "${verb}".`);
|
|
765
|
+
}
|
|
766
|
+
resolveTargetRecord(args, instanceId) {
|
|
767
|
+
if (instanceId) {
|
|
768
|
+
return this.Engine.Get(instanceId);
|
|
769
|
+
}
|
|
770
|
+
const artifactId = readString(args, 'artifactId');
|
|
771
|
+
if (artifactId) {
|
|
772
|
+
return this.Engine.FindByArtifact(artifactId);
|
|
773
|
+
}
|
|
774
|
+
if (this.Engine.ActiveID) {
|
|
775
|
+
return this.Engine.Get(this.Engine.ActiveID);
|
|
776
|
+
}
|
|
777
|
+
return this.Engine.Instances[0];
|
|
778
|
+
}
|
|
779
|
+
async resolveArtifactMetadata(params) {
|
|
780
|
+
const provider = this.Context?.Provider ?? undefined;
|
|
781
|
+
const user = provider?.CurrentUser;
|
|
782
|
+
// Fail closed (`CanEdit: false`) when provider or user context is absent
|
|
783
|
+
if (params.artifactId && params.name && (!provider || !user)) {
|
|
784
|
+
return {
|
|
785
|
+
ArtifactID: params.artifactId,
|
|
786
|
+
ArtifactVersionID: params.artifactVersionId,
|
|
787
|
+
VersionNumber: params.versionNumber,
|
|
788
|
+
Name: params.name,
|
|
789
|
+
ArtifactTypeName: params.artifactTypeName,
|
|
790
|
+
DriverClass: params.driverClass,
|
|
791
|
+
CanEdit: false,
|
|
792
|
+
};
|
|
793
|
+
}
|
|
794
|
+
if (!provider || !user) {
|
|
795
|
+
if (params.artifactId) {
|
|
796
|
+
return {
|
|
797
|
+
ArtifactID: params.artifactId,
|
|
798
|
+
ArtifactVersionID: params.artifactVersionId,
|
|
799
|
+
VersionNumber: params.versionNumber,
|
|
800
|
+
Name: params.name ?? params.fallbackName ?? 'Artifact',
|
|
801
|
+
ArtifactTypeName: params.artifactTypeName,
|
|
802
|
+
DriverClass: params.driverClass,
|
|
803
|
+
CanEdit: false,
|
|
804
|
+
};
|
|
805
|
+
}
|
|
806
|
+
return failure('open_failed', 'ArtifactWorkspace cannot resolve versionId without a signed-in session.');
|
|
807
|
+
}
|
|
808
|
+
const rv = RunView.FromMetadataProvider(provider);
|
|
809
|
+
let resolvedArtifactId = params.artifactId?.replace(/[{}]/g, '');
|
|
810
|
+
const resolvedVersionId = params.artifactVersionId?.replace(/[{}]/g, '');
|
|
811
|
+
let resolvedVersionNumber = params.versionNumber;
|
|
812
|
+
let resolvedName = params.name;
|
|
813
|
+
if (resolvedVersionId && UUID_PATTERN.test(resolvedVersionId)) {
|
|
814
|
+
const verRes = await rv.RunView({
|
|
815
|
+
EntityName: 'MJ: Artifact Versions',
|
|
816
|
+
ExtraFilter: `ID='${EscapeSQLString(resolvedVersionId)}'`,
|
|
817
|
+
MaxRows: 1,
|
|
818
|
+
ResultType: 'entity_object',
|
|
819
|
+
}, user);
|
|
820
|
+
const ver = verRes.Success ? verRes.Results[0] : undefined;
|
|
821
|
+
if (ver) {
|
|
822
|
+
if (resolvedArtifactId && !UUIDsEqual(ver.ArtifactID, resolvedArtifactId)) {
|
|
823
|
+
return failure('invalid_params', `Artifact version ${resolvedVersionId} does not belong to artifact ${resolvedArtifactId}.`);
|
|
824
|
+
}
|
|
825
|
+
resolvedArtifactId = resolvedArtifactId || ver.ArtifactID;
|
|
826
|
+
resolvedVersionNumber = resolvedVersionNumber ?? ver.VersionNumber;
|
|
827
|
+
resolvedName = resolvedName || ver.Name || undefined;
|
|
828
|
+
}
|
|
829
|
+
else if (!resolvedArtifactId) {
|
|
830
|
+
return failure('not_found', `Artifact version ${resolvedVersionId} was not found.`);
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
if (!resolvedArtifactId && !resolvedVersionId && resolvedName) {
|
|
834
|
+
const byName = await this.resolveArtifactByName(rv, provider, user, resolvedName);
|
|
835
|
+
if ('Success' in byName) {
|
|
836
|
+
return byName;
|
|
837
|
+
}
|
|
838
|
+
return {
|
|
839
|
+
ArtifactID: byName.ArtifactEntity.ID,
|
|
840
|
+
ArtifactVersionID: undefined,
|
|
841
|
+
VersionNumber: resolvedVersionNumber,
|
|
842
|
+
Name: byName.ArtifactEntity.Name || resolvedName || params.fallbackName || 'Artifact',
|
|
843
|
+
ArtifactTypeName: params.artifactTypeName || byName.ArtifactEntity.Type || undefined,
|
|
844
|
+
DriverClass: params.driverClass,
|
|
845
|
+
CanEdit: byName.CanEdit,
|
|
846
|
+
};
|
|
847
|
+
}
|
|
848
|
+
if (!resolvedArtifactId || !UUID_PATTERN.test(resolvedArtifactId)) {
|
|
849
|
+
return failure('invalid_params', 'A valid artifactId (or artifactVersionId) is required.');
|
|
850
|
+
}
|
|
851
|
+
const artRes = await rv.RunView({
|
|
852
|
+
EntityName: 'MJ: Artifacts',
|
|
853
|
+
ExtraFilter: `ID='${EscapeSQLString(resolvedArtifactId)}'`,
|
|
854
|
+
MaxRows: 1,
|
|
855
|
+
ResultType: 'entity_object',
|
|
856
|
+
}, user);
|
|
857
|
+
const artifactEntity = artRes.Success ? artRes.Results[0] : undefined;
|
|
858
|
+
if (!artifactEntity) {
|
|
859
|
+
return failure('not_found', `Artifact ${resolvedArtifactId} was not found or is inaccessible.`);
|
|
860
|
+
}
|
|
861
|
+
let canEdit = false;
|
|
862
|
+
try {
|
|
863
|
+
const perms = await ArtifactPermissionEngine.Instance.ResolvePermissions(provider, resolvedArtifactId, user);
|
|
864
|
+
if (!perms.CanRead) {
|
|
865
|
+
return failure('access_denied', `Access denied for artifact ${resolvedArtifactId}.`);
|
|
866
|
+
}
|
|
867
|
+
canEdit = perms.CanEdit;
|
|
868
|
+
}
|
|
869
|
+
catch {
|
|
870
|
+
return failure('access_denied', `Unable to verify read permissions for artifact ${resolvedArtifactId}.`);
|
|
871
|
+
}
|
|
872
|
+
return {
|
|
873
|
+
ArtifactID: artifactEntity.ID,
|
|
874
|
+
ArtifactVersionID: resolvedVersionId,
|
|
875
|
+
VersionNumber: resolvedVersionNumber,
|
|
876
|
+
Name: resolvedName || artifactEntity.Name || params.fallbackName || 'Artifact',
|
|
877
|
+
ArtifactTypeName: params.artifactTypeName || artifactEntity.Type || undefined,
|
|
878
|
+
DriverClass: params.driverClass,
|
|
879
|
+
CanEdit: canEdit,
|
|
880
|
+
};
|
|
881
|
+
}
|
|
882
|
+
/**
|
|
883
|
+
* Resolves a readable artifact by exact or partial display name when `artifactId` and
|
|
884
|
+
* `artifactVersionId` are omitted. Prefers collaborative (non-Component) artifacts ordered most
|
|
885
|
+
* recently updated first; falls back to Component matches so `OnOpen` can emit the specific
|
|
886
|
+
* `use_interactive_component` guidance.
|
|
887
|
+
*/
|
|
888
|
+
async resolveArtifactByName(rv, provider, user, name) {
|
|
889
|
+
const escapedExact = EscapeSQLString(name);
|
|
890
|
+
const escapedLike = EscapeSQLString(name.replace(/([\\_%[])/g, '\\$1'));
|
|
891
|
+
const configuredEnvId = readString(this.Context?.ChannelConfig ?? {}, 'environmentId');
|
|
892
|
+
const environmentId = EscapeSQLString(configuredEnvId || MJEnvironmentEntityExtended.DefaultEnvironmentID);
|
|
893
|
+
const scopeClause = `(Visibility IS NULL OR Visibility <> 'System Only') AND EnvironmentID='${environmentId}'`;
|
|
894
|
+
const filters = [
|
|
895
|
+
`Name='${escapedExact}' AND ${scopeClause}`,
|
|
896
|
+
`Name LIKE '%${escapedLike}%' ESCAPE '\\' AND ${scopeClause}`,
|
|
897
|
+
];
|
|
898
|
+
let componentFallback = null;
|
|
899
|
+
for (const extraFilter of filters) {
|
|
900
|
+
const res = await rv.RunView({
|
|
901
|
+
EntityName: 'MJ: Artifacts',
|
|
902
|
+
ExtraFilter: extraFilter,
|
|
903
|
+
OrderBy: '__mj_UpdatedAt DESC',
|
|
904
|
+
MaxRows: 15,
|
|
905
|
+
ResultType: 'entity_object',
|
|
906
|
+
}, user);
|
|
907
|
+
if (!res.Success || !res.Results?.length) {
|
|
908
|
+
continue;
|
|
909
|
+
}
|
|
910
|
+
for (const candidate of res.Results) {
|
|
911
|
+
try {
|
|
912
|
+
const perms = await ArtifactPermissionEngine.Instance.ResolvePermissions(provider, candidate.ID, user);
|
|
913
|
+
if (!perms.CanRead) {
|
|
914
|
+
continue;
|
|
915
|
+
}
|
|
916
|
+
if (!IsComponentArtifactDescriptor(candidate.Type ?? undefined, undefined)) {
|
|
917
|
+
return { ArtifactEntity: candidate, CanEdit: perms.CanEdit };
|
|
918
|
+
}
|
|
919
|
+
if (!componentFallback) {
|
|
920
|
+
componentFallback = { ArtifactEntity: candidate, CanEdit: perms.CanEdit };
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
catch {
|
|
924
|
+
// Permission resolution failure skips this candidate rather than widening access.
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
if (componentFallback) {
|
|
929
|
+
return componentFallback;
|
|
930
|
+
}
|
|
931
|
+
return failure('not_found', `Artifact named "${name}" was not found or is inaccessible.`);
|
|
932
|
+
}
|
|
933
|
+
};
|
|
934
|
+
ArtifactWorkspaceChannel = __decorate([
|
|
935
|
+
RegisterClass(BaseRealtimeChannelClient, ARTIFACT_WORKSPACE_CLIENT_PLUGIN_CLASS)
|
|
936
|
+
], ArtifactWorkspaceChannel);
|
|
937
|
+
export { ArtifactWorkspaceChannel };
|
|
938
|
+
/**
|
|
939
|
+
* Tree-shaking prevention for ClassFactory discovery of `RealtimeArtifactWorkspaceChannel`.
|
|
940
|
+
*/
|
|
941
|
+
export function LoadRealtimeArtifactWorkspaceChannel() {
|
|
942
|
+
// Intentional no-op; module import triggers @RegisterClass.
|
|
943
|
+
}
|
|
944
|
+
//# sourceMappingURL=artifact-workspace-channel.js.map
|