@xpert-ai/plugin-sdk 3.34.0 → 3.36.0
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/agent-results.cjs.js +5 -1
- package/agent-results.esm.js +2 -2
- package/analytics-result.cjs.js +64 -27
- package/analytics-result.esm.js +62 -28
- package/analytics.cjs.js +157 -15
- package/analytics.esm.js +154 -17
- package/artifact-document.cjs.js +9 -3
- package/artifact-document.esm.js +9 -3
- package/collaboration-client.cjs.js +274 -140
- package/collaboration-client.esm.js +273 -141
- package/docs/README.md +23 -0
- package/index.cjs.js +214 -9
- package/index.esm.js +193 -15
- package/model-provider.cjs.js +8 -0
- package/model-provider.esm.js +7 -1
- package/package.json +8 -2
- package/remote-component.cjs.default.js +1 -0
- package/remote-component.cjs.js +143 -0
- package/remote-component.cjs.mjs +2 -0
- package/remote-component.d.ts +1 -0
- package/remote-component.esm.js +139 -0
- package/results.cjs.js +2 -6
- package/results.esm.js +2 -6
- package/src/analytics.d.ts +2 -0
- package/src/collaboration-client.d.ts +1 -0
- package/src/index.d.ts +1 -0
- package/src/lib/agent/handoff/agent-runtime-message.contract.d.ts +24 -24
- package/src/lib/agent/middleware/strategy.interface.d.ts +2 -0
- package/src/lib/agent/runtime/capability.d.ts +2 -0
- package/src/lib/agent/runtime/cli-model-profile.d.ts +14 -1
- package/src/lib/agent/runtime/dispatch.d.ts +298 -75
- package/src/lib/agent/runtime/execution-runner.d.ts +24 -5
- package/src/lib/agent/runtime/pipeline-scope.d.ts +4 -4
- package/src/lib/agent/runtime/results.d.ts +16 -219
- package/src/lib/agent/runtime/strategy.d.ts +3 -0
- package/src/lib/agent/runtime/types.d.ts +21 -0
- package/src/lib/agent-event/index.d.ts +55 -0
- package/src/lib/agent-event/journal.d.ts +30 -0
- package/src/lib/artifact-document/dependencies.d.ts +13 -13
- package/src/lib/artifact-document/protocol.d.ts +2 -2
- package/src/lib/artifact-document/scheduler.d.ts +3 -0
- package/src/lib/assistant-capability/middleware.d.ts +2 -1
- package/src/lib/collaboration/client.d.ts +6 -59
- package/src/lib/collaboration/index.d.ts +1 -0
- package/src/lib/collaboration/operations-client.d.ts +23 -0
- package/src/lib/collaboration/presence.d.ts +36 -0
- package/src/lib/collaboration/provider.registry.d.ts +2 -2
- package/src/lib/collaboration/transport.d.ts +24 -0
- package/src/lib/collaboration/types.d.ts +57 -5
- package/src/lib/content-resource/catalog.d.ts +23 -1
- package/src/lib/content-resource/editor.d.ts +36 -1
- package/src/lib/data/analytics/analysis-evidence.d.ts +757 -0
- package/src/lib/data/analytics/analytics-certification.d.ts +64 -0
- package/src/lib/data/analytics/analytics-provider.d.ts +9 -0
- package/src/lib/data/analytics/analytics-value.d.ts +5 -0
- package/src/lib/data/analytics/index.d.ts +1 -0
- package/src/lib/evolution/runtime-capability.d.ts +1 -0
- package/src/lib/project-pipeline/adapters.d.ts +9 -2
- package/src/lib/project-pipeline/registry.d.ts +53 -50
- package/src/lib/project-task/acceptance.d.ts +29 -0
- package/src/lib/project-task/index.d.ts +6 -0
- package/src/lib/runtime/capabilities/index.d.ts +2 -0
- package/src/lib/runtime/capabilities/plugin-test-access.d.ts +14 -0
- package/src/lib/runtime/capabilities/project-configuration.d.ts +166 -0
- package/src/lib/view-extension/provider.interface.d.ts +51 -0
- package/src/remote-component.d.ts +13 -0
package/index.esm.js
CHANGED
|
@@ -2,8 +2,8 @@ import { Module, applyDecorators, SetMetadata, HttpException, HttpStatus, BadReq
|
|
|
2
2
|
import { MODULE_METADATA } from '@nestjs/common/constants.js';
|
|
3
3
|
import { pick } from 'lodash-es';
|
|
4
4
|
import { dispatchCustomEvent } from '@langchain/core/callbacks/dispatch';
|
|
5
|
-
import { ChatMessageEventTypeEnum, createResourceCardContent, LanguagesEnum, parseAnalyticsDiagnostic, ParameterType, AiModelTypeEnum, PriceType, FetchFrom, ModelPropertyKey, readModelConfiguration, ModelFeature, isDiscoverableModelType, configurationFromModel, SecretTokenBindingType, projectTaskExecutionContextSchema, projectTaskExecutionReferenceSchema, agentRuntimeProgressSchema, agentInvocationTerminalStatusSchema, projectPipelineWorkContextSchema, WorkflowNodeTypeEnum, iconDefinitionSchema, MCP_REQUIRED_CONTEXTS, MCP_CAPABILITY_APPROVAL_MODES, MCP_TOOL_RISKS, MCP_TOOL_SIDE_EFFECTS, MCP_TOOL_IDEMPOTENCY, MCP_CAPABILITY_VISIBILITIES, PLUGIN_COMPONENT_TYPE, projectPipelineContributionSchema, projectPipelineRefSchema } from '@xpert-ai/contracts';
|
|
6
|
-
export { ASSISTANT_CHAT_SEND_MESSAGE_COMMAND, ASSISTANT_CONTEXT_SET_COMMAND, agentOutputDeliverySchema, agentResultPathSchema, configurationFromModel, createResourceCardContent, parseResourceCard, projectPipelineContributionSchema, resourceCardId } from '@xpert-ai/contracts';
|
|
5
|
+
import { ChatMessageEventTypeEnum, createResourceCardContent, LanguagesEnum, parseAnalyticsDiagnostic, ParameterType, AiModelTypeEnum, PriceType, FetchFrom, ModelPropertyKey, readModelConfiguration, ModelFeature, isDiscoverableModelType, configurationFromModel, SecretTokenBindingType, projectTaskExecutionContextSchema, projectTaskExecutionReferenceSchema, agentRuntimeProgressSchema, agentInvocationTerminalStatusSchema, projectPipelineWorkContextSchema, WorkflowNodeTypeEnum, iconDefinitionSchema, MCP_REQUIRED_CONTEXTS, MCP_CAPABILITY_APPROVAL_MODES, MCP_TOOL_RISKS, MCP_TOOL_SIDE_EFFECTS, MCP_TOOL_IDEMPOTENCY, MCP_CAPABILITY_VISIBILITIES, PLUGIN_COMPONENT_TYPE, projectPipelineContributionSchema, projectPipelineRefSchema, pluginAgentEventSchema, agentEventDecisionSchema } from '@xpert-ai/contracts';
|
|
6
|
+
export { ASSISTANT_CHAT_SEND_MESSAGE_COMMAND, ASSISTANT_CONTEXT_SET_COMMAND, agentDeliveryRecoverySchema, agentEventDecisionSchema, agentEventRefSchema, agentOutputDeliverySchema, agentResultPathSchema, configurationFromModel, createResourceCardContent, parseResourceCard, pluginAgentEventSchema, projectPipelineContributionSchema, resourceCardId } from '@xpert-ai/contracts';
|
|
7
7
|
import { DiscoveryService, Reflector } from '@nestjs/core';
|
|
8
8
|
import { Subject, filter } from 'rxjs';
|
|
9
9
|
import { _ as _extends } from './_extends.esm.js';
|
|
@@ -16,7 +16,7 @@ import fs__default from 'fs';
|
|
|
16
16
|
import http from 'http';
|
|
17
17
|
import https from 'https';
|
|
18
18
|
import { c as createRuntimeCapability, B as BuiltinToolset, W as WorkspaceFilesRuntimeCapability } from './model-provider.esm.js';
|
|
19
|
-
export { A as ActorTokenRuntimeCapability, a as ActorTokenRuntimeFactoryCapability, b as ArtifactContentRuntimeCapability, d as ArtifactDraftsRuntimeCapability, e as ArtifactLibraryRuntimeCapability, f as ArtifactUseGrantsRuntimeCapability, g as ArtifactsRuntimeCapability, h as AssistantMiddlewareAccessRuntimeCapability, i as BaseTool, j as BaseToolset, D as DefaultAgentMiddlewareRuntimeCapabilityRegistry, D as DefaultRuntimeCapabilityRegistry, k as McpClientRuntimeCapability, M as ModelProviderBuiltinToolset, P as
|
|
19
|
+
export { A as ActorTokenRuntimeCapability, a as ActorTokenRuntimeFactoryCapability, b as ArtifactContentRuntimeCapability, d as ArtifactDraftsRuntimeCapability, e as ArtifactLibraryRuntimeCapability, f as ArtifactUseGrantsRuntimeCapability, g as ArtifactsRuntimeCapability, h as AssistantMiddlewareAccessRuntimeCapability, i as BaseTool, j as BaseToolset, D as DefaultAgentMiddlewareRuntimeCapabilityRegistry, D as DefaultRuntimeCapabilityRegistry, k as McpClientRuntimeCapability, M as ModelProviderBuiltinToolset, P as PluginTestAccessCapability, l as ProjectAccessRuntimeCapability, m as ProjectConfigurationRuntimeCapability, n as ProjectFilesRuntimeCapability, o as ProjectKnowledgeRuntimeCapability, p as ProjectProvisioningRuntimeCapability, R as RUNTIME_CAPABILITY_PROVIDER, q as RestClientRuntimeCapability, r as RuntimeCapabilityProvider, S as SANDBOX_JOB_ERROR_CODES, s as SANDBOX_JOB_INVOCATION_PREFIX, t as SANDBOX_JOB_PROGRESS_PREFIX, u as SandboxJobRuntimeError, v as SandboxJobsRuntimeCapability, T as ToolImagesRuntimeCapability, w as WORKSPACE_FILES_SOURCE, X as XPERT_RUNTIME_CAPABILITIES_TOKEN, x as isSandboxJobRuntimeError, y as workspaceFileMutationMetadata, z as workspaceFileMutationPath, C as workspaceRelativeDirectoryPathSchema, E as workspaceRelativeFilePathSchema } from './model-provider.esm.js';
|
|
20
20
|
import fsPromises from 'fs/promises';
|
|
21
21
|
import * as path from 'path';
|
|
22
22
|
import path__default, { join } from 'path';
|
|
@@ -29,7 +29,7 @@ import Ajv from 'ajv';
|
|
|
29
29
|
import schemaDraft04 from 'ajv/dist/refs/json-schema-draft-06.json';
|
|
30
30
|
import * as _axios from 'axios';
|
|
31
31
|
export { DataSourceRuntimeCapability } from './data-workbench.esm.js';
|
|
32
|
-
export {
|
|
32
|
+
export { c as analyticsBindingObjectSchema, d as analyticsBindingSchema, a as analyticsCertificationSchema, e as analyticsControlsSchema, f as analyticsDiscoveryRequestObjectSchema, g as analyticsDiscoveryRequestSchema, h as analyticsDiscoveryResultSchema, b as analyticsFieldSchema, j as analyticsOptionsSchema, k as analyticsParameterSchema, l as analyticsQueryRequestSchema, m as analyticsSourceKey, n as analyticsSourceRefSchema, o as normalizeAnalyticsResult, p as parseAnalyticsCertification, r as resolveAnalyticsParameters, v as validateAnalyticsBinding } from './analytics-result.esm.js';
|
|
33
33
|
import { BaseCallbackHandler } from '@langchain/core/callbacks/base';
|
|
34
34
|
import { ChatGenerationChunk } from '@langchain/core/outputs';
|
|
35
35
|
import { isBaseMessage, isAIMessage, isAIMessageChunk, AIMessage } from '@langchain/core/messages';
|
|
@@ -40,12 +40,12 @@ import { getEnvironmentVariable } from '@langchain/core/utils/env';
|
|
|
40
40
|
export { ModelProviderHttpClient, ModelProviderHttpError } from './model-provider-http-client.esm.js';
|
|
41
41
|
import { getEncodingNameForModel, encodingForModel, getEncoding } from 'js-tiktoken';
|
|
42
42
|
import { z as z$1 } from 'zod';
|
|
43
|
-
export { A as
|
|
43
|
+
export { A as AGENT_TASK_REPORT_MAX_BYTES, a as AGENT_TASK_RESULTS_FEATURE, b as agentResultItemSchema } from './results.esm.js';
|
|
44
44
|
import { assertConnectorDefinition } from './connector.esm.js';
|
|
45
45
|
export { CONNECTOR_AUTHORIZATION_MODES, CONNECTOR_SCOPE_TYPES, getConnectorAuthMethods, getConnectorAuthorizationModes } from './connector.esm.js';
|
|
46
46
|
import { isAbsolute, relative, resolve, sep } from 'node:path';
|
|
47
47
|
import { _ as _object_without_properties_loose$2 } from './_object_without_properties_loose.esm.js';
|
|
48
|
-
export { base64ToBytes, bytesToBase64, createCollaborationClient, createCollaborationPresenceStore, createSocketIoTransportAdapter, createYjsDocumentAdapter } from './collaboration-client.esm.js';
|
|
48
|
+
export { base64ToBytes, bytesToBase64, createCollaborationClient, createCollaborationPresenceStore, createOperationCollaborationClient, createSocketIoTransportAdapter, createYjsDocumentAdapter, parseCollaborationPresence } from './collaboration-client.esm.js';
|
|
49
49
|
import { createHash } from 'crypto';
|
|
50
50
|
import { tool } from '@langchain/core/tools';
|
|
51
51
|
|
|
@@ -4779,11 +4779,11 @@ while True:
|
|
|
4779
4779
|
function middleware(node) {
|
|
4780
4780
|
return node.type === 'workflow' && node.entity.type === WorkflowNodeTypeEnum.MIDDLEWARE;
|
|
4781
4781
|
}
|
|
4782
|
-
function hasAssistantMiddleware(draft, provider)
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4782
|
+
function hasAssistantMiddleware(draft, provider, agentKey = (()=>{
|
|
4783
|
+
var _draft_team_agent;
|
|
4784
|
+
return (_draft_team_agent = draft.team.agent) == null ? void 0 : _draft_team_agent.key;
|
|
4785
|
+
})()) {
|
|
4786
|
+
return draft.nodes.some((node)=>middleware(node) && node.entity.provider === provider && draft.connections.some((edge)=>edge.type === 'workflow' && edge.from === agentKey && edge.to.split('/')[0] === node.key));
|
|
4787
4787
|
}
|
|
4788
4788
|
/** Compose only the draft graph. The platform records the contribution for safe removal.
|
|
4789
4789
|
* No Project, permission, external resource or implicit replacement is created here. */ function applyAssistantMiddleware(draft, input) {
|
|
@@ -4823,8 +4823,9 @@ function hasAssistantMiddleware(draft, provider) {
|
|
|
4823
4823
|
required: true
|
|
4824
4824
|
});
|
|
4825
4825
|
var _agent_entity_options_middlewares_order;
|
|
4826
|
-
agent.entity.options = _extends({}, agent.entity.options, {
|
|
4827
|
-
parallelToolCalls: false
|
|
4826
|
+
agent.entity.options = _extends({}, agent.entity.options, input.preserveToolConcurrency ? {} : {
|
|
4827
|
+
parallelToolCalls: false
|
|
4828
|
+
}, {
|
|
4828
4829
|
middlewares: _extends({}, (_agent_entity_options = agent.entity.options) == null ? void 0 : _agent_entity_options.middlewares, {
|
|
4829
4830
|
order: [
|
|
4830
4831
|
...(_agent_entity_options_middlewares_order = (_agent_entity_options1 = agent.entity.options) == null ? void 0 : (_agent_entity_options_middlewares = _agent_entity_options1.middlewares) == null ? void 0 : _agent_entity_options_middlewares.order) != null ? _agent_entity_options_middlewares_order : [],
|
|
@@ -7177,6 +7178,9 @@ EvolutionTargetProviderRegistry = __decorate([
|
|
|
7177
7178
|
], EvolutionTargetProviderRegistry);
|
|
7178
7179
|
|
|
7179
7180
|
const EVOLUTION_RUNTIME_SERVICE_TOKEN = 'XPERT_EVOLUTION_RUNTIME_SERVICE';
|
|
7181
|
+
const ExecutionReviewRuntimeCapability = createRuntimeCapability('platform.agent-evolution.execution-review', {
|
|
7182
|
+
description: 'Human review of executions within the authorized project and Assistant.'
|
|
7183
|
+
});
|
|
7180
7184
|
/** Capability for inspecting and publishing source baselines within an authorized organization. */ const EvolutionBaselineRuntimeCapability = createRuntimeCapability('platform.agent-evolution.baselines', {
|
|
7181
7185
|
description: 'Inspect and initialize organization rule baselines with administrator authorization and revision checks.'
|
|
7182
7186
|
});
|
|
@@ -11040,7 +11044,7 @@ ProjectTaskProviderRegistry = __decorate([
|
|
|
11040
11044
|
])
|
|
11041
11045
|
], ProjectTaskProviderRegistry);
|
|
11042
11046
|
const ProjectTasksRuntimeCapability = createRuntimeCapability('platform.project.tasks', {
|
|
11043
|
-
description: 'Read project task graphs, request background synchronization, manage schedules, and resolve exact execution conversations.'
|
|
11047
|
+
description: 'Read project task graphs and acceptance receipts, request background synchronization, manage schedules, and resolve exact execution conversations.'
|
|
11044
11048
|
});
|
|
11045
11049
|
|
|
11046
11050
|
class UnavailablePipelineContribution {
|
|
@@ -11401,4 +11405,178 @@ Reflect.defineMetadata('__command__', {
|
|
|
11401
11405
|
id: ImportDefaultAgentPluginsCommand.type
|
|
11402
11406
|
}, ImportDefaultAgentPluginsCommand);
|
|
11403
11407
|
|
|
11404
|
-
export { ACCOUNT_BINDING_PERMISSION_SERVICE_TOKEN, AGENT_CHAT_DISPATCH_ERROR_STEER_TARGET_NOT_RUNNING, AGENT_CHAT_DISPATCH_MESSAGE_TYPE, AGENT_MIDDLEWARE_STRATEGY, AGENT_PROCESS_SUPERVISOR, AGENT_RUNTIME_EVENT_MESSAGE_TYPE, AGENT_RUNTIME_STRATEGY, AIModel, AIModelProviderNotFoundException, AIModelProviderRegistry, AIModelProviderStrategy, AI_MODEL_PROVIDER, ANALYTICS_PROVIDER, ARTIFACT_PRESENTATION_PROVIDER, ARTIFACT_TYPE_PROVIDER, ASSISTANT_CAPABILITY_PROVIDER, AdapterDataSourceStrategy, AgentExecutionRunnerCapability, AgentExecutionRunnerFactoryCapability, AgentInvocationRuntimeCapability, AgentMiddlewareRegistry, AgentMiddlewareStrategy, AgentRuntimeDeploymentCapability, AgentRuntimeFactoryCapability, AgentRuntimeRegistry, AgentRuntimeStrategy, AiModelNotFoundException, AnalyticsDefinitionAuthoringCapability, AnalyticsProvider, AnalyticsProviderError, AnalyticsProviderRegistry, AnalyticsRuntimeCapability, ArtifactPresentationProvider, ArtifactPresentationRegistry, ArtifactTypeProvider, ArtifactTypeRegistry, AssistantCapabilityProvider, AssistantCapabilityProviderRegistry, AssistantTaskRuntimeCapability, BOUND_IDENTITY_LOGIN_PERMISSION_SERVICE_TOKEN, BUILTIN_GLOBAL_SCOPE, BaseHTTPQueryRunner, BaseQueryRunner, BaseSQLQueryRunner, BaseSandbox, BaseStrategyRegistry, BuiltinToolset, CHAT_CHANNEL, CHAT_CHANNEL_TEXT_LIMITS, CLI_MODEL_TOKEN_REFERENCE, COLLABORATION_DOCUMENT_PROVIDER, CONNECTION_COMMAND_ROUTER_TOKEN, CONNECTOR_STRATEGY, CONTENT_RESOURCE_PROVIDER, CancelConversationCommand, ChatChannel, ChatChannelRegistry, ChatOAICompatReasoningModel, CliModelProfilesCapability, CollaborationDocumentProvider, CollaborationDocumentProviderRegistry, CollaborationRuntimeCapability, CommonParameterRules, ConnectorDocumentsRuntimeCapability, ConnectorRuntimeCapability, ConnectorRuntimeFactoryCapability, ConnectorStrategyKey, ConnectorStrategyRegistry, ContentDocumentsRuntimeCapability, ContentEditorProvider, ContentEditorRegistry, ContentEditorsRuntimeCapability, ContentReferencesRuntimeCapability, ContentResourceProvider, ContentResourceProviderRegistry, ContentResourcesRuntimeCapability, CreateModelClientCommand, CredentialsValidateFailedError, DATASOURCE_STRATEGY, DBCreateTableMode, DBProtocolEnum, DBSyntaxEnum, DBTableAction, DBTableDataAction, DEFAULT_EXECUTION_CONFIG, DEFAULT_SANDBOX_EXECUTION_MAX_OUTPUT_BYTES, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS, DEFAULT_SANDBOX_FILE_OPERATION_TIMEOUT_MS, DEFAULT_SANDBOX_FILE_OPERATION_TIMEOUT_SEC, DEFAULT_SANDBOX_FILE_SEARCH_EXECUTION_OPTIONS, DEFAULT_SANDBOX_FILE_SEARCH_TIMEOUT_MS, DEFAULT_SANDBOX_FILE_SEARCH_TIMEOUT_SEC, DEFAULT_SANDBOX_SHELL_EXECUTION_OPTIONS, DEFAULT_SANDBOX_SHELL_TIMEOUT_MS, DEFAULT_SANDBOX_SHELL_TIMEOUT_SEC, DOCUMENT_SOURCE_STRATEGY, DOCUMENT_TRANSFORMER_STRATEGY, DataSourceStrategy, DataSourceStrategyRegistry, DecoratedAgentMiddlewareStrategy, DecoratedToolsetStrategy, DocumentSourceRegistry, DocumentSourceStrategy, DocumentTransformerRegistry, DocumentTransformerStrategy, EVOLUTION_RUNTIME_SERVICE_TOKEN, EVOLUTION_TARGET_PROVIDER, EvolutionBaselineRuntimeCapability, EvolutionChangeRuntimeCapability, EvolutionRuntimeCapability, EvolutionTargetProviderRegistry, EvolutionTargetProviderStrategy, ExecutionObservabilityRuntimeCapability, FILE_ARTIFACT_TYPE, FILE_STORAGE_PROVIDER, FILE_UPLOAD_TARGET_STRATEGY, FileRuntimeCapability, FileStorageProvider, FileStorageProviderRegistry, FileUploadTargetRegistry, FileUploadTargetStrategy, GLOBAL_ORGANIZATION_SCOPE, HANDOFF_PERMISSION_SERVICE_TOKEN, HANDOFF_PROCESSOR_STRATEGY, HANDOFF_QUEUE_SERVICE_TOKEN, HandoffProcessorRegistry, HandoffProcessorStrategy, IMAGE_UNDERSTANDING_STRATEGY, INTEGRATION_PERMISSION_SERVICE_TOKEN, INTEGRATION_STRATEGY, ImageGenerationModel, ImageUnderstandingRegistry, ImageUnderstandingStrategy, ImportDefaultAgentPluginsCommand, IntegrationStrategyKey, IntegrationStrategyRegistry, JUMP_TO_TARGETS, JsonSchemaValidator, KEYWORD_ANALYZER_STRATEGY, KNOWLEDGE_STRATEGY, KeywordAnalyzerRegistry, KeywordAnalyzerStrategy, KnowledgeDocumentVisualAssetsRuntimeCapability, KnowledgeDocumentVisualAssetsRuntimeFactoryCapability, KnowledgeGraphRuntimeCapability, KnowledgeStrategyKey, KnowledgeStrategyRegistry, KnowledgebaseDocumentsRuntimeCapability, KnowledgebaseProvisioningRuntimeCapability, KnowledgebaseRuntimeCapability, LLMUsage, LargeLanguageModel, ListAnalyticsSourcesCommand, MANAGED_CONNECTION_REGISTRY_TOKEN, MANAGED_QUEUE_HANDLER_REGISTRY_TOKEN, MANAGED_QUEUE_SERVICE_TOKEN, MCP_CAPABILITY_CHANGE_EVENT_TYPES, MODEL_OUTPUT_VALIDATION_ERROR_CODE, ModelExecutionEnvironmentCapability, ModelOutputValidationError, ModelProvider, ORGANIZATION_METADATA_KEY, OpenAICompatibleEmbeddings, OpenAICompatibleReranker, PERMISSION_OPERATION_METADATA_KEY, PLUGIN_CONFIG_RESOLVER_TOKEN, PLUGIN_JOB_PROCESSOR_METADATA, PLUGIN_METADATA, PLUGIN_METADATA_KEY, PLUGIN_VERSION_METADATA_KEY, PLUGIN_WEBHOOK_AUTH_METADATA_KEY, PLUGIN_WEBHOOK_AUTH_SERVICE_TOKEN, PROJECT_PIPELINE_CONTRIBUTION, PROJECT_PIPELINE_PROJECTION_PROVIDER, PROJECT_PIPELINE_RUNTIME_ADAPTER, PROJECT_TASK_PROVIDER, PROJECT_TYPE_PROVIDER, PROVIDE_AI_MODEL_LLM, PROVIDE_AI_MODEL_MODERATION, PROVIDE_AI_MODEL_RERANK, PROVIDE_AI_MODEL_SPEECH2TEXT, PROVIDE_AI_MODEL_TEXT_EMBEDDING, PROVIDE_AI_MODEL_TTS, PluginJobProcessor, PluginWebhookAuth, PluginWebhookAuthGuard, ProjectPipelineAnalyticsRuntimeCapability, ProjectPipelineCatalogRuntimeCapability, ProjectPipelineCommandsRuntimeCapability, ProjectPipelineConfigurationRuntimeCapability, ProjectPipelineContributionRegistry, ProjectPipelineContributor, ProjectPipelineEvidenceRuntimeCapability, ProjectPipelinePortfolioRuntimeCapability, ProjectPipelineProjectionProvider, ProjectPipelineProjectionProviderRegistry, ProjectPipelineProviderActionsRuntimeCapability, ProjectPipelineRuntimeAdapterProvider, ProjectPipelineRuntimeAdapterRegistry, ProjectPipelinesRuntimeCapability, ProjectTaskProvider, ProjectTaskProviderRegistry, ProjectTasksRuntimeCapability, ProjectTypeProvider, ProjectTypeProviderRegistry, RESOURCE_CARD_EVENT, RESOURCE_CARD_PROVIDER, RETRIEVER_STRATEGY, RequestContext, RequestContextMiddleware, RequirePermissionOperation, RerankModel, ResolveAnalyticsSourceCommand, ResolveConnectorIntegrationQuery, ResourceCardProvider, ResourceCardProviderRegistry, RetrieverRegistry, RetrieverStrategy, SANDBOX_PROVIDER, SANDBOX_RUNTIME_PROVIDER, SANDBOX_SHELL_TIMEOUT_LIMITS_SEC, SANDBOX_WORKSPACE_MAPPER, SKILL_SOURCE_PROVIDER, SPEECH_TO_TEXT_PERMISSION_SERVICE_TOKEN, SPEECH_TO_TEXT_SERVICE_TOKEN, SSOProviderRegistry, SSOProviderStrategyKey, SSO_BINDING_PERMISSION_SERVICE_TOKEN, SSO_PROVIDER, STRATEGY_META_KEY, SYSTEM_GLOBAL_SCOPE, SandboxProviderRegistry, SandboxProviderStrategy, SandboxRuntimeProviderRegistry, SandboxRuntimeProviderStrategy, SandboxWorkspaceMapperRegistry, SandboxWorkspaceMapperStrategy, ShellModelExecutionSourceCapability, SkillSourceProviderRegistry, SkillSourceProviderStrategy, Speech2TextChatModel, SpeechToTextModel, StrategyBus, TENANT_GLOBAL_SCOPE_PREFIX, TENANT_GLOBAL_SCOPE_SUFFIX, TEXT_SPLITTER_STRATEGY, TOOLSET_STRATEGY, TextEmbeddingModelManager, TextSplitterRegistry, TextSplitterStrategy, TextToSpeechModel, ToolsetRegistry, ToolsetStrategy, USER_PERMISSION_SERVICE_TOKEN, VECTOR_STORE_STRATEGY, VIDEO_GENERATION_PERMISSION_SERVICE_TOKEN, VIDEO_GENERATION_SERVICE_TOKEN, VIDEO_GENERATOR_FAMILIES, VIEW_EXTENSION_CACHE_SERVICE_TOKEN, VIEW_EXTENSION_PROVIDER, VectorStoreRegistry, VectorStoreStrategy, VideoGenerationModel, ViewExtensionProvider, ViewExtensionProviderRegistry, ViewMiddlewareRuntimeCapability, WORKFLOW_NODE_STRATEGY, WORKFLOW_TRIGGER_STRATEGY, WorkflowNodeRegistry, WorkflowNodeStrategy, WorkflowTriggerRegistry, WorkflowTriggerStrategy, WorkspaceFilesRuntimeCapability, WrapWorkflowNodeExecutionCommand, XPERT_AGENT_MIDDLEWARE_RUNTIME_TOKEN, XPERT_TOOL_METHOD_METADATA, XPERT_TOOL_PROVIDER, XPERT_TOOL_PROVIDER_METADATA, XPERT_TOOL_RESULT_FORMAT_VERSION, XpFileSystem, XpertPrompt, XpertResource, XpertResourceTemplate, XpertServerPlugin, XpertTool, XpertToolProvider, XpertToolProviderCoordinator, XpertToolProviderRegistry, agentInvocationDispatchContextSchema, agentRuntimeConsumptionStateSchema, agentRuntimeDeliveryStateSchema, agentRuntimeDeploymentSpecSchema, agentRuntimeEventMessageId, agentRuntimeEventSchema, agentRuntimeReplyTargetSchema, agentRuntimeResultClaimSchema, agentRuntimeResultConsumptionKey, als, appendSandboxMessage, applyAssistantMiddleware, applyModelConfiguration, applyModelContextSize, artifactPresentationKey, artifactTypeKey, assertConnectorDefinition, assertXpertToolProviderClaims, buildSandboxTimeoutMessage, calcTokenUsage, calculateLLMUsagePrice, calculateModelPrice, calculateModelUsageCharge, canonicalEvolutionJson, chunkText, countTextTokens, countTokensSafe, createI18nInstance, createMutationEvidence, createPluginLogger, createRuntimeCapability, defineAgentMessageType, defineChannelMessageType, defineMcpApp, defineMcpCapabilities, defineMcpPrompt, defineMcpResource, defineMcpResourceTemplate, defineXpertTool, derivePluginArtifactNamespace, describeXpertToolProvider, discoverOpenAIModels, downloadRemoteFile, emitResourceCard, formatSandboxTimeout, getDefaultTenantId, getErrorMessage, getModelContextSize, getPermissionOperationMetadata, getPositionList, getPositionMap, getRequestContext, getRequiredPermissionOperation, getTenantGlobalScopeKey, getXpertToolMethod, hasAssistantMiddleware, hashEvolutionValue, isAgentInvocationTerminal, isDevelopmentSandboxRuntimeEnvironment, isExecutionObservationSession, isFileContentEditor, isModelOutputValidationError, isModelUsagePricingConfig, isPluginArtifactNamespace, isRemoteFile, isResourceContentEditor, isSandboxBackend, isSandboxManagedServiceAdapter, isSandboxServiceProxyAdapter, isSandboxTerminalAdapter, isStrategyInstance, isStructuredMessageType, isTenantGlobalScopeKey, isTextContentEditor, jsonEncodedSchema, knowledgebaseActions, loadYamlFile, managedAgentRuntimeSchema, mergeCredentials, mergeModelRequirements, mergeParentChildChunks, nativeModelTransport, normalizeContextSize, normalizeTokenUsage, pluginArtifactTableName, prepareToolResult, processAsyncAIGCManagedJob, projectPipelineInvocationScopeSchema, readAnalyticsProviderDiagnostic, renderRemoteModuleIframeHtml, renderRemoteReactIframeHtml, renderRemoteVueIframeHtml, resolveModelUsagePricingSnapshot, resolveSandboxBackend, resolveSandboxExecutionOptions, resolveSandboxManagedServiceAdapter, resolveSandboxServiceProxyAdapter, resolveSandboxTerminalAdapter, resolveStrategyMetadataTarget, resolveTenantGlobalScopeKey, resolveTokenUsage, resolveTokenUsageCandidates, resolveXpertMcpExtensions, runWithRequestContext, runtimeToolProviderComponent, secondsToMilliseconds, setDefaultTenantId, sumTokenUsage, supportsContentModel, taskWaitReason, textTokenBoundaries, validateAnalyticsPayload };
|
|
11408
|
+
function agentEventDigest(value) {
|
|
11409
|
+
const sorted = JSON.stringify(value, (_key, item)=>{
|
|
11410
|
+
if (item && typeof item === 'object' && !Array.isArray(item)) return Object.fromEntries(Object.entries(item).sort(([a], [b])=>a < b ? -1 : a > b ? 1 : 0));
|
|
11411
|
+
return item;
|
|
11412
|
+
});
|
|
11413
|
+
return createHash$1('sha256').update(sorted).digest('hex');
|
|
11414
|
+
}
|
|
11415
|
+
/** PostgreSQL source journal scoped to one plugin's own route and fact tables. */ class PluginEventJournal {
|
|
11416
|
+
async lock(tx, origin) {
|
|
11417
|
+
await tx.query('SELECT pg_advisory_xact_lock(hashtextextended($1,0))', [
|
|
11418
|
+
JSON.stringify([
|
|
11419
|
+
this.routes,
|
|
11420
|
+
origin.tenantId,
|
|
11421
|
+
origin.organizationId,
|
|
11422
|
+
origin.ref
|
|
11423
|
+
])
|
|
11424
|
+
]);
|
|
11425
|
+
}
|
|
11426
|
+
async configure(tx, ctx, enabled) {
|
|
11427
|
+
const origin = {
|
|
11428
|
+
tenantId: ctx.tenantId,
|
|
11429
|
+
organizationId: ctx.organizationId,
|
|
11430
|
+
ref: ctx.sourceBindingRef
|
|
11431
|
+
};
|
|
11432
|
+
await this.lock(tx, origin);
|
|
11433
|
+
const [route] = await tx.query(`SELECT * FROM ${this.routes} WHERE tenant=$1 AND org=$2 AND ref=$3`, [
|
|
11434
|
+
origin.tenantId,
|
|
11435
|
+
origin.organizationId,
|
|
11436
|
+
origin.ref
|
|
11437
|
+
]);
|
|
11438
|
+
if (route && (route.binding !== ctx.bindingId || route.revision > ctx.bindingRevision)) throw new Error('source_binding_changed');
|
|
11439
|
+
await tx.query(`INSERT INTO ${this.routes}(binding,tenant,org,ref,revision,enabled) VALUES($1,$2,$3,$4,$5,$6)
|
|
11440
|
+
ON CONFLICT(binding) DO UPDATE SET revision=EXCLUDED.revision,enabled=EXCLUDED.enabled`, [
|
|
11441
|
+
ctx.bindingId,
|
|
11442
|
+
ctx.tenantId,
|
|
11443
|
+
ctx.organizationId,
|
|
11444
|
+
ctx.sourceBindingRef,
|
|
11445
|
+
ctx.bindingRevision,
|
|
11446
|
+
enabled
|
|
11447
|
+
]);
|
|
11448
|
+
}
|
|
11449
|
+
async route(tx, origin) {
|
|
11450
|
+
await this.lock(tx, origin);
|
|
11451
|
+
const [route] = await tx.query(`SELECT * FROM ${this.routes} WHERE tenant=$1 AND org=$2 AND ref=$3`, [
|
|
11452
|
+
origin.tenantId,
|
|
11453
|
+
origin.organizationId,
|
|
11454
|
+
origin.ref
|
|
11455
|
+
]);
|
|
11456
|
+
return route;
|
|
11457
|
+
}
|
|
11458
|
+
async capture(tx, route, data, snapshot, factKey, revision) {
|
|
11459
|
+
const event = pluginAgentEventSchema.parse(_extends({}, data, {
|
|
11460
|
+
bindingRevision: route.revision,
|
|
11461
|
+
fact: {
|
|
11462
|
+
key: factKey,
|
|
11463
|
+
revision,
|
|
11464
|
+
sha256: agentEventDigest(snapshot)
|
|
11465
|
+
}
|
|
11466
|
+
}));
|
|
11467
|
+
const [existing] = await tx.query(`SELECT event FROM ${this.facts} WHERE binding=$1 AND source=$2`, [
|
|
11468
|
+
route.binding,
|
|
11469
|
+
event.sourceEventId
|
|
11470
|
+
]);
|
|
11471
|
+
if (existing) {
|
|
11472
|
+
if (existing.event.type !== event.type || existing.event.schemaVersion !== event.schemaVersion || existing.event.fact.key !== event.fact.key || existing.event.fact.revision !== event.fact.revision || existing.event.fact.sha256 !== event.fact.sha256 || existing.event.subject.key !== event.subject.key || existing.event.subject.kind !== event.subject.kind) throw new Error('event_source_conflict');
|
|
11473
|
+
return true;
|
|
11474
|
+
}
|
|
11475
|
+
if (!route.enabled) return false;
|
|
11476
|
+
await tx.query(`INSERT INTO ${this.facts}(id,binding,source,event,snapshot) VALUES($1,$2,$3,$4,$5)`, [
|
|
11477
|
+
randomUUID(),
|
|
11478
|
+
route.binding,
|
|
11479
|
+
event.sourceEventId,
|
|
11480
|
+
event,
|
|
11481
|
+
JSON.stringify(snapshot)
|
|
11482
|
+
]);
|
|
11483
|
+
return true;
|
|
11484
|
+
}
|
|
11485
|
+
async drain(db, ctx, publisher, limit) {
|
|
11486
|
+
const scope = [
|
|
11487
|
+
ctx.bindingId,
|
|
11488
|
+
ctx.tenantId,
|
|
11489
|
+
ctx.organizationId,
|
|
11490
|
+
ctx.sourceBindingRef,
|
|
11491
|
+
ctx.bindingRevision
|
|
11492
|
+
];
|
|
11493
|
+
// The current worker may reconcile older facts (including a lost receipt ACK), never a later revision.
|
|
11494
|
+
const routeScope = 'r.binding=$1 AND r.tenant=$2 AND r.org=$3 AND r.ref=$4 AND r.revision=$5';
|
|
11495
|
+
const facts = await db.query(`SELECT f.id,f.event FROM ${this.facts} f JOIN ${this.routes} r USING(binding)
|
|
11496
|
+
WHERE ${routeScope} AND (f.event->>'bindingRevision')::numeric <= r.revision AND f.receipt IS NULL
|
|
11497
|
+
AND (f.error IS NULL OR (f.error='binding_changed' AND f.event->>'bindingRevision'=r.revision::text))
|
|
11498
|
+
ORDER BY f.seq LIMIT $6`, [
|
|
11499
|
+
...scope,
|
|
11500
|
+
limit
|
|
11501
|
+
]);
|
|
11502
|
+
for (const fact of facts){
|
|
11503
|
+
ctx.signal.throwIfAborted();
|
|
11504
|
+
const result = await publisher.publish(fact.event);
|
|
11505
|
+
if (result.status === 'rejected') {
|
|
11506
|
+
// The host may already have advanced or may still be enabling this revision.
|
|
11507
|
+
if (result.code === 'binding_changed' && fact.event.bindingRevision === ctx.bindingRevision) return {
|
|
11508
|
+
more: false
|
|
11509
|
+
};
|
|
11510
|
+
await db.query(`WITH current_route AS (SELECT r.binding FROM ${this.routes} r WHERE ${routeScope} FOR SHARE)
|
|
11511
|
+
UPDATE ${this.facts} f SET error=$7 FROM current_route r
|
|
11512
|
+
WHERE f.binding=r.binding AND f.id=$6 AND f.receipt IS NULL`, [
|
|
11513
|
+
...scope,
|
|
11514
|
+
fact.id,
|
|
11515
|
+
result.code
|
|
11516
|
+
]);
|
|
11517
|
+
} else {
|
|
11518
|
+
// A committed host receipt remains authoritative even if the route changed while awaiting its ACK.
|
|
11519
|
+
await db.query(`UPDATE ${this.facts} SET receipt=$2,error=NULL WHERE id=$1 AND binding=$3 AND (receipt IS NULL OR receipt=$2)`, [
|
|
11520
|
+
fact.id,
|
|
11521
|
+
result.receiptId,
|
|
11522
|
+
ctx.bindingId
|
|
11523
|
+
]);
|
|
11524
|
+
}
|
|
11525
|
+
}
|
|
11526
|
+
return {
|
|
11527
|
+
more: facts.length === limit
|
|
11528
|
+
};
|
|
11529
|
+
}
|
|
11530
|
+
async decide(tx, ctx, delivery, apply) {
|
|
11531
|
+
const [fact] = await tx.query(`SELECT f.* FROM ${this.facts} f JOIN ${this.routes} r USING(binding)
|
|
11532
|
+
WHERE r.binding=$1 AND r.tenant=$2 AND r.org=$3 AND r.ref=$4 AND r.revision=$5 AND f.source=$6
|
|
11533
|
+
FOR SHARE OF r FOR UPDATE OF f`, [
|
|
11534
|
+
ctx.bindingId,
|
|
11535
|
+
ctx.tenantId,
|
|
11536
|
+
ctx.organizationId,
|
|
11537
|
+
ctx.sourceBindingRef,
|
|
11538
|
+
ctx.bindingRevision,
|
|
11539
|
+
delivery.event.sourceEventId
|
|
11540
|
+
]);
|
|
11541
|
+
if (!fact || fact.event.bindingRevision !== ctx.bindingRevision || agentEventDigest(fact.event) !== agentEventDigest(delivery.event) || agentEventDigest(fact.snapshot) !== delivery.event.fact.sha256 || fact.receipt && fact.receipt !== delivery.receiptId) return {
|
|
11542
|
+
status: 'blocked',
|
|
11543
|
+
reasonCode: 'source_binding_changed'
|
|
11544
|
+
};
|
|
11545
|
+
if (fact.decision) return agentEventDecisionSchema.parse(fact.decision);
|
|
11546
|
+
const partition = JSON.stringify([
|
|
11547
|
+
ctx.bindingId,
|
|
11548
|
+
delivery.event.subject.kind,
|
|
11549
|
+
delivery.event.subject.key
|
|
11550
|
+
]);
|
|
11551
|
+
await tx.query('SELECT pg_advisory_xact_lock(hashtextextended($1,0))', [
|
|
11552
|
+
partition
|
|
11553
|
+
]);
|
|
11554
|
+
const [newer] = await tx.query(`SELECT EXISTS(SELECT 1 FROM ${this.facts} WHERE binding=$1
|
|
11555
|
+
AND event->'subject'=$2::jsonb AND fence>$3::bigint) AS exists`, [
|
|
11556
|
+
ctx.bindingId,
|
|
11557
|
+
JSON.stringify(delivery.event.subject),
|
|
11558
|
+
delivery.fence
|
|
11559
|
+
]);
|
|
11560
|
+
if (newer.exists) throw new Error('stale_event_fence');
|
|
11561
|
+
ctx.signal.throwIfAborted();
|
|
11562
|
+
const result = agentEventDecisionSchema.parse(await apply(fact.snapshot));
|
|
11563
|
+
ctx.signal.throwIfAborted();
|
|
11564
|
+
await tx.query(`UPDATE ${this.facts} SET decision=$2,receipt=$3,fence=$4 WHERE id=$1`, [
|
|
11565
|
+
fact.id,
|
|
11566
|
+
result,
|
|
11567
|
+
delivery.receiptId,
|
|
11568
|
+
delivery.fence
|
|
11569
|
+
]);
|
|
11570
|
+
return result;
|
|
11571
|
+
}
|
|
11572
|
+
constructor(prefix){
|
|
11573
|
+
if (!/^[a-z][a-z0-9_]{1,45}$/.test(prefix)) throw new Error('invalid_event_journal_prefix');
|
|
11574
|
+
this.routes = prefix + '_route';
|
|
11575
|
+
this.facts = prefix + '_fact';
|
|
11576
|
+
}
|
|
11577
|
+
}
|
|
11578
|
+
|
|
11579
|
+
const AGENT_EVENT_SOURCE = 'XPERT_AGENT_EVENT_SOURCE_V1';
|
|
11580
|
+
const AgentEventSourceStrategy = (key)=>applyDecorators(SetMetadata(AGENT_EVENT_SOURCE, key), SetMetadata(STRATEGY_META_KEY, AGENT_EVENT_SOURCE));
|
|
11581
|
+
|
|
11582
|
+
export { ACCOUNT_BINDING_PERMISSION_SERVICE_TOKEN, AGENT_CHAT_DISPATCH_ERROR_STEER_TARGET_NOT_RUNNING, AGENT_CHAT_DISPATCH_MESSAGE_TYPE, AGENT_EVENT_SOURCE, AGENT_MIDDLEWARE_STRATEGY, AGENT_PROCESS_SUPERVISOR, AGENT_RUNTIME_EVENT_MESSAGE_TYPE, AGENT_RUNTIME_STRATEGY, AIModel, AIModelProviderNotFoundException, AIModelProviderRegistry, AIModelProviderStrategy, AI_MODEL_PROVIDER, ANALYTICS_PROVIDER, ARTIFACT_PRESENTATION_PROVIDER, ARTIFACT_TYPE_PROVIDER, ASSISTANT_CAPABILITY_PROVIDER, AdapterDataSourceStrategy, AgentEventSourceStrategy, AgentExecutionRunnerCapability, AgentExecutionRunnerFactoryCapability, AgentInvocationRuntimeCapability, AgentMiddlewareRegistry, AgentMiddlewareStrategy, AgentRuntimeDeploymentCapability, AgentRuntimeFactoryCapability, AgentRuntimeRegistry, AgentRuntimeStrategy, AiModelNotFoundException, AnalyticsDefinitionAuthoringCapability, AnalyticsProvider, AnalyticsProviderError, AnalyticsProviderRegistry, AnalyticsRuntimeCapability, ArtifactPresentationProvider, ArtifactPresentationRegistry, ArtifactTypeProvider, ArtifactTypeRegistry, AssistantCapabilityProvider, AssistantCapabilityProviderRegistry, AssistantTaskRuntimeCapability, BOUND_IDENTITY_LOGIN_PERMISSION_SERVICE_TOKEN, BUILTIN_GLOBAL_SCOPE, BaseHTTPQueryRunner, BaseQueryRunner, BaseSQLQueryRunner, BaseSandbox, BaseStrategyRegistry, BuiltinToolset, CHAT_CHANNEL, CHAT_CHANNEL_TEXT_LIMITS, CLI_MODEL_TOKEN_REFERENCE, COLLABORATION_DOCUMENT_PROVIDER, CONNECTION_COMMAND_ROUTER_TOKEN, CONNECTOR_STRATEGY, CONTENT_RESOURCE_PROVIDER, CancelConversationCommand, ChatChannel, ChatChannelRegistry, ChatOAICompatReasoningModel, CliModelProfilesCapability, CollaborationDocumentProvider, CollaborationDocumentProviderRegistry, CollaborationRuntimeCapability, CommonParameterRules, ConnectorDocumentsRuntimeCapability, ConnectorRuntimeCapability, ConnectorRuntimeFactoryCapability, ConnectorStrategyKey, ConnectorStrategyRegistry, ContentDocumentsRuntimeCapability, ContentEditorProvider, ContentEditorRegistry, ContentEditorsRuntimeCapability, ContentReferencesRuntimeCapability, ContentResourceProvider, ContentResourceProviderRegistry, ContentResourcesRuntimeCapability, CreateModelClientCommand, CredentialsValidateFailedError, DATASOURCE_STRATEGY, DBCreateTableMode, DBProtocolEnum, DBSyntaxEnum, DBTableAction, DBTableDataAction, DEFAULT_EXECUTION_CONFIG, DEFAULT_SANDBOX_EXECUTION_MAX_OUTPUT_BYTES, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS, DEFAULT_SANDBOX_FILE_OPERATION_TIMEOUT_MS, DEFAULT_SANDBOX_FILE_OPERATION_TIMEOUT_SEC, DEFAULT_SANDBOX_FILE_SEARCH_EXECUTION_OPTIONS, DEFAULT_SANDBOX_FILE_SEARCH_TIMEOUT_MS, DEFAULT_SANDBOX_FILE_SEARCH_TIMEOUT_SEC, DEFAULT_SANDBOX_SHELL_EXECUTION_OPTIONS, DEFAULT_SANDBOX_SHELL_TIMEOUT_MS, DEFAULT_SANDBOX_SHELL_TIMEOUT_SEC, DOCUMENT_SOURCE_STRATEGY, DOCUMENT_TRANSFORMER_STRATEGY, DataSourceStrategy, DataSourceStrategyRegistry, DecoratedAgentMiddlewareStrategy, DecoratedToolsetStrategy, DocumentSourceRegistry, DocumentSourceStrategy, DocumentTransformerRegistry, DocumentTransformerStrategy, EVOLUTION_RUNTIME_SERVICE_TOKEN, EVOLUTION_TARGET_PROVIDER, EvolutionBaselineRuntimeCapability, EvolutionChangeRuntimeCapability, EvolutionRuntimeCapability, EvolutionTargetProviderRegistry, EvolutionTargetProviderStrategy, ExecutionObservabilityRuntimeCapability, ExecutionReviewRuntimeCapability, FILE_ARTIFACT_TYPE, FILE_STORAGE_PROVIDER, FILE_UPLOAD_TARGET_STRATEGY, FileRuntimeCapability, FileStorageProvider, FileStorageProviderRegistry, FileUploadTargetRegistry, FileUploadTargetStrategy, GLOBAL_ORGANIZATION_SCOPE, HANDOFF_PERMISSION_SERVICE_TOKEN, HANDOFF_PROCESSOR_STRATEGY, HANDOFF_QUEUE_SERVICE_TOKEN, HandoffProcessorRegistry, HandoffProcessorStrategy, IMAGE_UNDERSTANDING_STRATEGY, INTEGRATION_PERMISSION_SERVICE_TOKEN, INTEGRATION_STRATEGY, ImageGenerationModel, ImageUnderstandingRegistry, ImageUnderstandingStrategy, ImportDefaultAgentPluginsCommand, IntegrationStrategyKey, IntegrationStrategyRegistry, JUMP_TO_TARGETS, JsonSchemaValidator, KEYWORD_ANALYZER_STRATEGY, KNOWLEDGE_STRATEGY, KeywordAnalyzerRegistry, KeywordAnalyzerStrategy, KnowledgeDocumentVisualAssetsRuntimeCapability, KnowledgeDocumentVisualAssetsRuntimeFactoryCapability, KnowledgeGraphRuntimeCapability, KnowledgeStrategyKey, KnowledgeStrategyRegistry, KnowledgebaseDocumentsRuntimeCapability, KnowledgebaseProvisioningRuntimeCapability, KnowledgebaseRuntimeCapability, LLMUsage, LargeLanguageModel, ListAnalyticsSourcesCommand, MANAGED_CONNECTION_REGISTRY_TOKEN, MANAGED_QUEUE_HANDLER_REGISTRY_TOKEN, MANAGED_QUEUE_SERVICE_TOKEN, MCP_CAPABILITY_CHANGE_EVENT_TYPES, MODEL_OUTPUT_VALIDATION_ERROR_CODE, ModelExecutionEnvironmentCapability, ModelOutputValidationError, ModelProvider, ORGANIZATION_METADATA_KEY, OpenAICompatibleEmbeddings, OpenAICompatibleReranker, PERMISSION_OPERATION_METADATA_KEY, PLUGIN_CONFIG_RESOLVER_TOKEN, PLUGIN_JOB_PROCESSOR_METADATA, PLUGIN_METADATA, PLUGIN_METADATA_KEY, PLUGIN_VERSION_METADATA_KEY, PLUGIN_WEBHOOK_AUTH_METADATA_KEY, PLUGIN_WEBHOOK_AUTH_SERVICE_TOKEN, PROJECT_PIPELINE_CONTRIBUTION, PROJECT_PIPELINE_PROJECTION_PROVIDER, PROJECT_PIPELINE_RUNTIME_ADAPTER, PROJECT_TASK_PROVIDER, PROJECT_TYPE_PROVIDER, PROVIDE_AI_MODEL_LLM, PROVIDE_AI_MODEL_MODERATION, PROVIDE_AI_MODEL_RERANK, PROVIDE_AI_MODEL_SPEECH2TEXT, PROVIDE_AI_MODEL_TEXT_EMBEDDING, PROVIDE_AI_MODEL_TTS, PluginEventJournal, PluginJobProcessor, PluginWebhookAuth, PluginWebhookAuthGuard, ProjectPipelineAnalyticsRuntimeCapability, ProjectPipelineCatalogRuntimeCapability, ProjectPipelineCommandsRuntimeCapability, ProjectPipelineConfigurationRuntimeCapability, ProjectPipelineContributionRegistry, ProjectPipelineContributor, ProjectPipelineEvidenceRuntimeCapability, ProjectPipelinePortfolioRuntimeCapability, ProjectPipelineProjectionProvider, ProjectPipelineProjectionProviderRegistry, ProjectPipelineProviderActionsRuntimeCapability, ProjectPipelineRuntimeAdapterProvider, ProjectPipelineRuntimeAdapterRegistry, ProjectPipelinesRuntimeCapability, ProjectTaskProvider, ProjectTaskProviderRegistry, ProjectTasksRuntimeCapability, ProjectTypeProvider, ProjectTypeProviderRegistry, RESOURCE_CARD_EVENT, RESOURCE_CARD_PROVIDER, RETRIEVER_STRATEGY, RequestContext, RequestContextMiddleware, RequirePermissionOperation, RerankModel, ResolveAnalyticsSourceCommand, ResolveConnectorIntegrationQuery, ResourceCardProvider, ResourceCardProviderRegistry, RetrieverRegistry, RetrieverStrategy, SANDBOX_PROVIDER, SANDBOX_RUNTIME_PROVIDER, SANDBOX_SHELL_TIMEOUT_LIMITS_SEC, SANDBOX_WORKSPACE_MAPPER, SKILL_SOURCE_PROVIDER, SPEECH_TO_TEXT_PERMISSION_SERVICE_TOKEN, SPEECH_TO_TEXT_SERVICE_TOKEN, SSOProviderRegistry, SSOProviderStrategyKey, SSO_BINDING_PERMISSION_SERVICE_TOKEN, SSO_PROVIDER, STRATEGY_META_KEY, SYSTEM_GLOBAL_SCOPE, SandboxProviderRegistry, SandboxProviderStrategy, SandboxRuntimeProviderRegistry, SandboxRuntimeProviderStrategy, SandboxWorkspaceMapperRegistry, SandboxWorkspaceMapperStrategy, ShellModelExecutionSourceCapability, SkillSourceProviderRegistry, SkillSourceProviderStrategy, Speech2TextChatModel, SpeechToTextModel, StrategyBus, TENANT_GLOBAL_SCOPE_PREFIX, TENANT_GLOBAL_SCOPE_SUFFIX, TEXT_SPLITTER_STRATEGY, TOOLSET_STRATEGY, TextEmbeddingModelManager, TextSplitterRegistry, TextSplitterStrategy, TextToSpeechModel, ToolsetRegistry, ToolsetStrategy, USER_PERMISSION_SERVICE_TOKEN, VECTOR_STORE_STRATEGY, VIDEO_GENERATION_PERMISSION_SERVICE_TOKEN, VIDEO_GENERATION_SERVICE_TOKEN, VIDEO_GENERATOR_FAMILIES, VIEW_EXTENSION_CACHE_SERVICE_TOKEN, VIEW_EXTENSION_PROVIDER, VectorStoreRegistry, VectorStoreStrategy, VideoGenerationModel, ViewExtensionProvider, ViewExtensionProviderRegistry, ViewMiddlewareRuntimeCapability, WORKFLOW_NODE_STRATEGY, WORKFLOW_TRIGGER_STRATEGY, WorkflowNodeRegistry, WorkflowNodeStrategy, WorkflowTriggerRegistry, WorkflowTriggerStrategy, WorkspaceFilesRuntimeCapability, WrapWorkflowNodeExecutionCommand, XPERT_AGENT_MIDDLEWARE_RUNTIME_TOKEN, XPERT_TOOL_METHOD_METADATA, XPERT_TOOL_PROVIDER, XPERT_TOOL_PROVIDER_METADATA, XPERT_TOOL_RESULT_FORMAT_VERSION, XpFileSystem, XpertPrompt, XpertResource, XpertResourceTemplate, XpertServerPlugin, XpertTool, XpertToolProvider, XpertToolProviderCoordinator, XpertToolProviderRegistry, agentEventDigest, agentInvocationDispatchContextSchema, agentRuntimeConsumptionStateSchema, agentRuntimeDeliveryStateSchema, agentRuntimeDeploymentSpecSchema, agentRuntimeEventMessageId, agentRuntimeEventSchema, agentRuntimeReplyTargetSchema, agentRuntimeResultClaimSchema, agentRuntimeResultConsumptionKey, als, appendSandboxMessage, applyAssistantMiddleware, applyModelConfiguration, applyModelContextSize, artifactPresentationKey, artifactTypeKey, assertConnectorDefinition, assertXpertToolProviderClaims, buildSandboxTimeoutMessage, calcTokenUsage, calculateLLMUsagePrice, calculateModelPrice, calculateModelUsageCharge, canonicalEvolutionJson, chunkText, countTextTokens, countTokensSafe, createI18nInstance, createMutationEvidence, createPluginLogger, createRuntimeCapability, defineAgentMessageType, defineChannelMessageType, defineMcpApp, defineMcpCapabilities, defineMcpPrompt, defineMcpResource, defineMcpResourceTemplate, defineXpertTool, derivePluginArtifactNamespace, describeXpertToolProvider, discoverOpenAIModels, downloadRemoteFile, emitResourceCard, formatSandboxTimeout, getDefaultTenantId, getErrorMessage, getModelContextSize, getPermissionOperationMetadata, getPositionList, getPositionMap, getRequestContext, getRequiredPermissionOperation, getTenantGlobalScopeKey, getXpertToolMethod, hasAssistantMiddleware, hashEvolutionValue, isAgentInvocationTerminal, isDevelopmentSandboxRuntimeEnvironment, isExecutionObservationSession, isFileContentEditor, isModelOutputValidationError, isModelUsagePricingConfig, isPluginArtifactNamespace, isRemoteFile, isResourceContentEditor, isSandboxBackend, isSandboxManagedServiceAdapter, isSandboxServiceProxyAdapter, isSandboxTerminalAdapter, isStrategyInstance, isStructuredMessageType, isTenantGlobalScopeKey, isTextContentEditor, jsonEncodedSchema, knowledgebaseActions, loadYamlFile, managedAgentRuntimeSchema, mergeCredentials, mergeModelRequirements, mergeParentChildChunks, nativeModelTransport, normalizeContextSize, normalizeTokenUsage, pluginArtifactTableName, prepareToolResult, processAsyncAIGCManagedJob, projectPipelineInvocationScopeSchema, readAnalyticsProviderDiagnostic, renderRemoteModuleIframeHtml, renderRemoteReactIframeHtml, renderRemoteVueIframeHtml, resolveModelUsagePricingSnapshot, resolveSandboxBackend, resolveSandboxExecutionOptions, resolveSandboxManagedServiceAdapter, resolveSandboxServiceProxyAdapter, resolveSandboxTerminalAdapter, resolveStrategyMetadataTarget, resolveTenantGlobalScopeKey, resolveTokenUsage, resolveTokenUsageCandidates, resolveXpertMcpExtensions, runWithRequestContext, runtimeToolProviderComponent, secondsToMilliseconds, setDefaultTenantId, sumTokenUsage, supportsContentModel, taskWaitReason, textTokenBoundaries, validateAnalyticsPayload };
|
package/model-provider.cjs.js
CHANGED
|
@@ -277,6 +277,8 @@ const ProjectAccessRuntimeCapability = createRuntimeCapability('platform.project
|
|
|
277
277
|
description: 'Resolve Project membership and Assistant execution access for platform and plugin operations.'
|
|
278
278
|
});
|
|
279
279
|
|
|
280
|
+
const PluginTestAccessCapability = createRuntimeCapability('platform.plugin.test-access');
|
|
281
|
+
|
|
280
282
|
const ProjectFilesRuntimeCapability = createRuntimeCapability('platform.project.files', {
|
|
281
283
|
description: 'Authorized Project file tree and conflict-aware atomic file writes.'
|
|
282
284
|
});
|
|
@@ -301,6 +303,10 @@ const RestClientRuntimeCapability = createRuntimeCapability('platform.rest.clien
|
|
|
301
303
|
description: 'Governed JSON access through saved OpenAPI connections and platform-managed authentication.'
|
|
302
304
|
});
|
|
303
305
|
|
|
306
|
+
const ProjectConfigurationRuntimeCapability = createRuntimeCapability('platform.project.configuration', {
|
|
307
|
+
description: 'Authorized Project configuration, membership, skills, connectors and automation operations.'
|
|
308
|
+
});
|
|
309
|
+
|
|
304
310
|
/** Portable Agent input; filesystem containment and authorization remain with the host. */ const workspaceRelativeFilePathSchema = v3.z.string().min(1).max(1024).refine((value)=>!/[\\\x00-\x1f\x7f]/.test(value) && !/^[A-Za-z]:/.test(value) && value.split('/').every((part)=>part.length > 0 && part === part.trim() && part !== '.' && part !== '..'), 'Use a workspace-relative file path with non-empty segments; no absolute paths, traversal or surrounding whitespace.');
|
|
305
311
|
/** Directory discovery also accepts the workspace root and a trailing directory slash. */ const workspaceRelativeDirectoryPathSchema = v3.z.string().transform((value)=>value.endsWith('/') ? value.slice(0, -1) : value).pipe(v3.z.union([
|
|
306
312
|
v3.z.literal('.'),
|
|
@@ -453,7 +459,9 @@ exports.BuiltinToolset = BuiltinToolset;
|
|
|
453
459
|
exports.DefaultRuntimeCapabilityRegistry = DefaultRuntimeCapabilityRegistry;
|
|
454
460
|
exports.McpClientRuntimeCapability = McpClientRuntimeCapability;
|
|
455
461
|
exports.ModelProviderBuiltinToolset = ModelProviderBuiltinToolset;
|
|
462
|
+
exports.PluginTestAccessCapability = PluginTestAccessCapability;
|
|
456
463
|
exports.ProjectAccessRuntimeCapability = ProjectAccessRuntimeCapability;
|
|
464
|
+
exports.ProjectConfigurationRuntimeCapability = ProjectConfigurationRuntimeCapability;
|
|
457
465
|
exports.ProjectFilesRuntimeCapability = ProjectFilesRuntimeCapability;
|
|
458
466
|
exports.ProjectKnowledgeRuntimeCapability = ProjectKnowledgeRuntimeCapability;
|
|
459
467
|
exports.ProjectProvisioningRuntimeCapability = ProjectProvisioningRuntimeCapability;
|
package/model-provider.esm.js
CHANGED
|
@@ -275,6 +275,8 @@ const ProjectAccessRuntimeCapability = createRuntimeCapability('platform.project
|
|
|
275
275
|
description: 'Resolve Project membership and Assistant execution access for platform and plugin operations.'
|
|
276
276
|
});
|
|
277
277
|
|
|
278
|
+
const PluginTestAccessCapability = createRuntimeCapability('platform.plugin.test-access');
|
|
279
|
+
|
|
278
280
|
const ProjectFilesRuntimeCapability = createRuntimeCapability('platform.project.files', {
|
|
279
281
|
description: 'Authorized Project file tree and conflict-aware atomic file writes.'
|
|
280
282
|
});
|
|
@@ -299,6 +301,10 @@ const RestClientRuntimeCapability = createRuntimeCapability('platform.rest.clien
|
|
|
299
301
|
description: 'Governed JSON access through saved OpenAPI connections and platform-managed authentication.'
|
|
300
302
|
});
|
|
301
303
|
|
|
304
|
+
const ProjectConfigurationRuntimeCapability = createRuntimeCapability('platform.project.configuration', {
|
|
305
|
+
description: 'Authorized Project configuration, membership, skills, connectors and automation operations.'
|
|
306
|
+
});
|
|
307
|
+
|
|
302
308
|
/** Portable Agent input; filesystem containment and authorization remain with the host. */ const workspaceRelativeFilePathSchema = z.string().min(1).max(1024).refine((value)=>!/[\\\x00-\x1f\x7f]/.test(value) && !/^[A-Za-z]:/.test(value) && value.split('/').every((part)=>part.length > 0 && part === part.trim() && part !== '.' && part !== '..'), 'Use a workspace-relative file path with non-empty segments; no absolute paths, traversal or surrounding whitespace.');
|
|
303
309
|
/** Directory discovery also accepts the workspace root and a trailing directory slash. */ const workspaceRelativeDirectoryPathSchema = z.string().transform((value)=>value.endsWith('/') ? value.slice(0, -1) : value).pipe(z.union([
|
|
304
310
|
z.literal('.'),
|
|
@@ -437,4 +443,4 @@ function normalizeWorkspaceScope(scope) {
|
|
|
437
443
|
} : {});
|
|
438
444
|
}
|
|
439
445
|
|
|
440
|
-
export { ActorTokenRuntimeCapability as A, BuiltinToolset as B, DefaultRuntimeCapabilityRegistry as D, ModelProviderBuiltinToolset as M,
|
|
446
|
+
export { ActorTokenRuntimeCapability as A, BuiltinToolset as B, workspaceRelativeDirectoryPathSchema as C, DefaultRuntimeCapabilityRegistry as D, workspaceRelativeFilePathSchema as E, ModelProviderBuiltinToolset as M, PluginTestAccessCapability as P, RUNTIME_CAPABILITY_PROVIDER as R, SANDBOX_JOB_ERROR_CODES as S, ToolImagesRuntimeCapability as T, WorkspaceFilesRuntimeCapability as W, XPERT_RUNTIME_CAPABILITIES_TOKEN as X, ActorTokenRuntimeFactoryCapability as a, ArtifactContentRuntimeCapability as b, createRuntimeCapability as c, ArtifactDraftsRuntimeCapability as d, ArtifactLibraryRuntimeCapability as e, ArtifactUseGrantsRuntimeCapability as f, ArtifactsRuntimeCapability as g, AssistantMiddlewareAccessRuntimeCapability as h, BaseTool as i, BaseToolset as j, McpClientRuntimeCapability as k, ProjectAccessRuntimeCapability as l, ProjectConfigurationRuntimeCapability as m, ProjectFilesRuntimeCapability as n, ProjectKnowledgeRuntimeCapability as o, ProjectProvisioningRuntimeCapability as p, RestClientRuntimeCapability as q, RuntimeCapabilityProvider as r, SANDBOX_JOB_INVOCATION_PREFIX as s, SANDBOX_JOB_PROGRESS_PREFIX as t, SandboxJobRuntimeError as u, SandboxJobsRuntimeCapability as v, WORKSPACE_FILES_SOURCE as w, isSandboxJobRuntimeError as x, workspaceFileMutationMetadata as y, workspaceFileMutationPath as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xpert-ai/plugin-sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.36.0",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -37,6 +37,12 @@
|
|
|
37
37
|
"import": "./data-workbench.cjs.mjs",
|
|
38
38
|
"default": "./data-workbench.cjs.js"
|
|
39
39
|
},
|
|
40
|
+
"./remote-component": {
|
|
41
|
+
"module": "./remote-component.esm.js",
|
|
42
|
+
"types": "./remote-component.d.ts",
|
|
43
|
+
"import": "./remote-component.cjs.mjs",
|
|
44
|
+
"default": "./remote-component.cjs.js"
|
|
45
|
+
},
|
|
40
46
|
"./artifact-document": {
|
|
41
47
|
"module": "./artifact-document.esm.js",
|
|
42
48
|
"types": "./artifact-document.d.ts",
|
|
@@ -74,7 +80,7 @@
|
|
|
74
80
|
},
|
|
75
81
|
"dependencies": {
|
|
76
82
|
"@langchain/openai": "0.6.9",
|
|
77
|
-
"@xpert-ai/contracts": "3.
|
|
83
|
+
"@xpert-ai/contracts": "3.36.0",
|
|
78
84
|
"express": "^4.22.1",
|
|
79
85
|
"js-tiktoken": "^1.0.21"
|
|
80
86
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
exports._default = require('./remote-component.cjs.js').default;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _extends = require('./_extends.cjs.js');
|
|
4
|
+
var contextEvent = require('@xpert-ai/contracts/context-event');
|
|
5
|
+
var v3 = require('zod/v3');
|
|
6
|
+
|
|
7
|
+
const channel = 'xpertai.remote_component';
|
|
8
|
+
const envelope = v3.z.object({
|
|
9
|
+
channel: v3.z.literal(channel),
|
|
10
|
+
protocolVersion: v3.z.literal(1),
|
|
11
|
+
type: v3.z.string(),
|
|
12
|
+
instanceId: v3.z.string().min(1),
|
|
13
|
+
scopeRevision: v3.z.number().int().nonnegative().optional(),
|
|
14
|
+
event: v3.z.unknown().optional(),
|
|
15
|
+
requestId: v3.z.string().optional(),
|
|
16
|
+
data: v3.z.unknown().optional(),
|
|
17
|
+
result: v3.z.unknown().optional(),
|
|
18
|
+
message: v3.z.string().optional(),
|
|
19
|
+
locale: v3.z.string().optional(),
|
|
20
|
+
theme: v3.z.object({
|
|
21
|
+
mode: v3.z.string().optional(),
|
|
22
|
+
density: v3.z.enum([
|
|
23
|
+
'default',
|
|
24
|
+
'compact'
|
|
25
|
+
]).optional(),
|
|
26
|
+
tokens: v3.z.record(v3.z.union([
|
|
27
|
+
v3.z.string(),
|
|
28
|
+
v3.z.number()
|
|
29
|
+
])).optional()
|
|
30
|
+
}).optional()
|
|
31
|
+
});
|
|
32
|
+
let scope;
|
|
33
|
+
let disconnect;
|
|
34
|
+
const pending = new Map();
|
|
35
|
+
function invalidate(message) {
|
|
36
|
+
for (const call of pending.values()){
|
|
37
|
+
window.clearTimeout(call.timer);
|
|
38
|
+
call.reject(new Error(message));
|
|
39
|
+
}
|
|
40
|
+
pending.clear();
|
|
41
|
+
}
|
|
42
|
+
/** Subscribe before rendering. The returned cleanup releases the listener and all outstanding requests. */ function connect(init, contextChanged) {
|
|
43
|
+
disconnect == null ? void 0 : disconnect();
|
|
44
|
+
const receive = (event)=>{
|
|
45
|
+
if (event.source !== window.parent) return;
|
|
46
|
+
const parsed = envelope.safeParse(event.data);
|
|
47
|
+
if (!parsed.success) return;
|
|
48
|
+
const message = parsed.data;
|
|
49
|
+
if (message.type === 'init') {
|
|
50
|
+
var _message_scopeRevision, _scope_revision;
|
|
51
|
+
if ((scope == null ? void 0 : scope.instanceId) === message.instanceId && ((_message_scopeRevision = message.scopeRevision) != null ? _message_scopeRevision : -1) < ((_scope_revision = scope.revision) != null ? _scope_revision : -1)) return;
|
|
52
|
+
const changed = (scope == null ? void 0 : scope.instanceId) !== message.instanceId || (scope == null ? void 0 : scope.revision) !== message.scopeRevision;
|
|
53
|
+
if (changed) {
|
|
54
|
+
invalidate('View context changed');
|
|
55
|
+
scope = {
|
|
56
|
+
instanceId: message.instanceId,
|
|
57
|
+
revision: message.scopeRevision
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
var _message_locale;
|
|
61
|
+
init({
|
|
62
|
+
locale: (_message_locale = message.locale) != null ? _message_locale : 'en-US',
|
|
63
|
+
theme: message.theme
|
|
64
|
+
}, changed);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (!scope || message.instanceId !== scope.instanceId) return;
|
|
68
|
+
if (message.type === 'hostEvent') {
|
|
69
|
+
const context = contextEvent.viewContextEventSchema.safeParse(message.event);
|
|
70
|
+
var _scope_revision1;
|
|
71
|
+
if (context.success && context.data.data.revision > ((_scope_revision1 = scope.revision) != null ? _scope_revision1 : -1)) {
|
|
72
|
+
invalidate('View context changed');
|
|
73
|
+
scope = {
|
|
74
|
+
instanceId: scope.instanceId,
|
|
75
|
+
revision: context.data.data.revision
|
|
76
|
+
};
|
|
77
|
+
contextChanged();
|
|
78
|
+
}
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (!message.requestId || message.scopeRevision !== undefined && message.scopeRevision !== scope.revision) return;
|
|
82
|
+
const call = pending.get(message.requestId);
|
|
83
|
+
if (!call) return;
|
|
84
|
+
pending.delete(message.requestId);
|
|
85
|
+
window.clearTimeout(call.timer);
|
|
86
|
+
var _message_message;
|
|
87
|
+
if (message.type === 'error') call.reject(new Error((_message_message = message.message) != null ? _message_message : 'Request failed'));
|
|
88
|
+
else call.resolve('data' in message ? message.data : message.result);
|
|
89
|
+
};
|
|
90
|
+
window.addEventListener('message', receive);
|
|
91
|
+
window.parent.postMessage({
|
|
92
|
+
channel,
|
|
93
|
+
protocolVersion: 1,
|
|
94
|
+
type: 'ready'
|
|
95
|
+
}, '*');
|
|
96
|
+
const close = ()=>{
|
|
97
|
+
if (disconnect !== close) return;
|
|
98
|
+
disconnect = undefined;
|
|
99
|
+
window.removeEventListener('message', receive);
|
|
100
|
+
scope = undefined;
|
|
101
|
+
invalidate('View closed');
|
|
102
|
+
};
|
|
103
|
+
disconnect = close;
|
|
104
|
+
return close;
|
|
105
|
+
}
|
|
106
|
+
function request(type, body = {}) {
|
|
107
|
+
if (!scope) return Promise.reject(new Error('View is not connected'));
|
|
108
|
+
const { instanceId, revision } = scope;
|
|
109
|
+
const requestId = crypto.randomUUID();
|
|
110
|
+
return new Promise((resolve, reject)=>{
|
|
111
|
+
const timer = window.setTimeout(()=>{
|
|
112
|
+
pending.delete(requestId);
|
|
113
|
+
reject(new Error('Request timed out'));
|
|
114
|
+
}, 30000);
|
|
115
|
+
pending.set(requestId, {
|
|
116
|
+
resolve,
|
|
117
|
+
reject,
|
|
118
|
+
timer
|
|
119
|
+
});
|
|
120
|
+
try {
|
|
121
|
+
window.parent.postMessage(_extends._extends({}, body, {
|
|
122
|
+
channel,
|
|
123
|
+
protocolVersion: 1,
|
|
124
|
+
instanceId,
|
|
125
|
+
scopeRevision: revision,
|
|
126
|
+
type,
|
|
127
|
+
requestId
|
|
128
|
+
}), '*');
|
|
129
|
+
} catch (error) {
|
|
130
|
+
window.clearTimeout(timer);
|
|
131
|
+
pending.delete(requestId);
|
|
132
|
+
reject(error);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
/** Bind a request before asynchronous preparation, so a context switch cannot redirect it. */ function scopedRequest() {
|
|
137
|
+
const captured = scope;
|
|
138
|
+
return (type, body)=>captured && captured === scope ? request(type, body) : Promise.reject(new Error('View context changed'));
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
exports.connect = connect;
|
|
142
|
+
exports.request = request;
|
|
143
|
+
exports.scopedRequest = scopedRequest;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/remote-component";
|