@xpert-ai/plugin-sdk 3.20.0 → 3.21.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/{CHANGELOG.md → docs/CHANGELOG.md} +20 -0
- package/{README.md → docs/README.md} +10 -8
- package/docs/en/KNOWLEDGEBASE_API.md +42 -0
- package/docs/en/PERMISSIONS.md +173 -0
- package/{RESOURCE-CARDS.md → docs/en/RESOURCE-CARDS.md} +5 -5
- package/docs/en/SCHEMA_SPECIFICATION.md +325 -0
- package/{TOOL-IMAGES.md → docs/en/TOOL-IMAGES.md} +1 -1
- package/docs/en/structured-knowledge-graph.md +60 -0
- package/docs/en/video-generation-protocol.md +86 -0
- package/docs/en/view-extension-protocol.md +413 -0
- package/index.cjs.js +53 -8
- package/index.esm.js +47 -4
- package/model-provider.cjs.js +40 -68
- package/model-provider.esm.js +42 -64
- package/package.json +2 -2
- package/src/index.d.ts +1 -0
- package/src/lib/agent/handoff/agent-chat.contract.d.ts +4 -0
- package/src/lib/agent-plugin/import-default-agent-plugins.command.d.ts +6 -0
- package/src/lib/core/context/request-context.d.ts +1 -0
- package/src/lib/rag/capability/index.d.ts +6 -0
- package/src/lib/{runtime/capabilities → rag/capability}/knowledge-document-visual-assets.d.ts +2 -2
- package/src/lib/rag/capability/knowledge-upload-sessions.d.ts +71 -0
- package/src/lib/rag/capability/knowledgebase-catalog.d.ts +78 -0
- package/src/lib/{runtime/capabilities → rag/capability}/knowledgebase-documents.d.ts +9 -1
- package/src/lib/{runtime/capabilities → rag/capability}/knowledgebase.d.ts +69 -0
- package/src/lib/rag/index.d.ts +1 -0
- package/src/lib/runtime/capabilities/index.d.ts +0 -4
- package/src/lib/runtime/capabilities/workspace-files.d.ts +8 -2
- package/PERMISSIONS.md +0 -181
- package/SCHEMA_SPECIFICATION.md +0 -335
- /package/{MIDDLEWARE_APPS.md → docs/en/MIDDLEWARE_APPS.md} +0 -0
- /package/{RESOURCE-CARDS-VALIDATION.md → docs/en/RESOURCE-CARDS-VALIDATION.md} +0 -0
- /package/{runtime-capabilities.md → docs/en/runtime-capabilities.md} +0 -0
- /package/src/lib/{runtime/capabilities → rag/capability}/knowledge-graph.d.ts +0 -0
package/index.esm.js
CHANGED
|
@@ -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 ArtifactsRuntimeCapability, d as BaseTool, e as BaseToolset, D as DefaultAgentMiddlewareRuntimeCapabilityRegistry, D as DefaultRuntimeCapabilityRegistry,
|
|
19
|
+
export { A as ActorTokenRuntimeCapability, a as ActorTokenRuntimeFactoryCapability, b as ArtifactsRuntimeCapability, d as BaseTool, e as BaseToolset, D as DefaultAgentMiddlewareRuntimeCapabilityRegistry, D as DefaultRuntimeCapabilityRegistry, M as ModelProviderBuiltinToolset, P as ProjectAccessRuntimeCapability, f as ProjectProvisioningRuntimeCapability, R as RUNTIME_CAPABILITY_PROVIDER, g as RuntimeCapabilityProvider, S as SANDBOX_JOB_ERROR_CODES, h as SANDBOX_JOB_PROGRESS_PREFIX, i as SandboxJobRuntimeError, j as SandboxJobsRuntimeCapability, T as ToolImagesRuntimeCapability, k as WORKSPACE_FILES_SOURCE, X as XPERT_RUNTIME_CAPABILITIES_TOKEN, l as isSandboxJobRuntimeError } 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';
|
|
@@ -182,14 +182,15 @@ class RequestContext {
|
|
|
182
182
|
const session = getRequestContext();
|
|
183
183
|
return session;
|
|
184
184
|
}
|
|
185
|
-
static currentApiKey() {
|
|
185
|
+
/** @deprecated For resource authorization use currentApiPrincipal()?.resourceScope; retained for credential metadata. */ static currentApiKey() {
|
|
186
186
|
var _RequestContext_currentApiPrincipal;
|
|
187
187
|
var _RequestContext_currentApiPrincipal_apiKey;
|
|
188
188
|
return (_RequestContext_currentApiPrincipal_apiKey = (_RequestContext_currentApiPrincipal = RequestContext.currentApiPrincipal()) == null ? void 0 : _RequestContext_currentApiPrincipal.apiKey) != null ? _RequestContext_currentApiPrincipal_apiKey : null;
|
|
189
189
|
}
|
|
190
190
|
static currentApiPrincipal() {
|
|
191
191
|
const user = RequestContext.currentUser();
|
|
192
|
-
|
|
192
|
+
// Conversation-scoped client secrets carry no synthetic API key.
|
|
193
|
+
return (user == null ? void 0 : user.apiKey) || (user == null ? void 0 : user.principalType) === 'client_secret' || (user == null ? void 0 : user.principalType) === 'api_key' ? user : null;
|
|
193
194
|
}
|
|
194
195
|
static currentRequest() {
|
|
195
196
|
const requestContext = RequestContext.currentRequestContext();
|
|
@@ -1104,6 +1105,41 @@ KeywordAnalyzerRegistry = __decorate([
|
|
|
1104
1105
|
])
|
|
1105
1106
|
], KeywordAnalyzerRegistry);
|
|
1106
1107
|
|
|
1108
|
+
const KnowledgebaseRuntimeCapability = createRuntimeCapability('platform.knowledgebase', {
|
|
1109
|
+
description: 'List, search, and write chunks in platform knowledgebases.'
|
|
1110
|
+
});
|
|
1111
|
+
const KnowledgebaseProvisioningRuntimeCapability = createRuntimeCapability('platform.knowledgebase.provisioning', {
|
|
1112
|
+
description: 'Idempotently provision managed platform knowledgebases and connect them to an Agent.'
|
|
1113
|
+
});
|
|
1114
|
+
|
|
1115
|
+
/** Knowledgebase discovery is scoped to the authenticated runtime, never caller-supplied identities. */ const knowledgebaseActions = [
|
|
1116
|
+
'knowledgebase.read',
|
|
1117
|
+
'knowledgebase.manage',
|
|
1118
|
+
'content.search',
|
|
1119
|
+
'documents.read',
|
|
1120
|
+
'documents.create',
|
|
1121
|
+
'documents.update',
|
|
1122
|
+
'documents.delete',
|
|
1123
|
+
'documents.process',
|
|
1124
|
+
'chunks.write',
|
|
1125
|
+
'chunks.delete'
|
|
1126
|
+
];
|
|
1127
|
+
|
|
1128
|
+
const KnowledgeGraphRuntimeCapability = createRuntimeCapability('platform.knowledge-graph', {
|
|
1129
|
+
description: 'Publish, inspect, and retract source-owned structured knowledge graphs without model extraction.'
|
|
1130
|
+
});
|
|
1131
|
+
|
|
1132
|
+
const KnowledgebaseDocumentsRuntimeCapability = createRuntimeCapability('platform.knowledgebase.documents', {
|
|
1133
|
+
description: 'Upload, import, create, process, reprocess, inspect, and delete persistent knowledgebase documents.'
|
|
1134
|
+
});
|
|
1135
|
+
|
|
1136
|
+
const KnowledgeDocumentVisualAssetsRuntimeCapability = createRuntimeCapability('platform.knowledgebase.visual-assets', {
|
|
1137
|
+
description: 'Issue execution-scoped logical KnowledgeDocument image paths and inject validated images without exposing host storage paths.'
|
|
1138
|
+
});
|
|
1139
|
+
const KnowledgeDocumentVisualAssetsRuntimeFactoryCapability = createRuntimeCapability('platform.knowledge-document.visual-assets.factory', {
|
|
1140
|
+
description: 'Create a visual-assets API with an execution-local image allow-list and authorized workspace writer.'
|
|
1141
|
+
});
|
|
1142
|
+
|
|
1107
1143
|
const TOOLSET_STRATEGY = 'TOOLSET_STRATEGY';
|
|
1108
1144
|
/**
|
|
1109
1145
|
* Decorator to mark a provider as a Toolset Strategy
|
|
@@ -10102,4 +10138,11 @@ const ProjectTasksRuntimeCapability = createRuntimeCapability('platform.project.
|
|
|
10102
10138
|
description: 'Read project task graphs, manage schedules, and resolve exact execution conversations.'
|
|
10103
10139
|
});
|
|
10104
10140
|
|
|
10105
|
-
|
|
10141
|
+
/** Import official resource packages for the authenticated organization administrator. Does not authorize workspaces. */ class ImportDefaultAgentPluginsCommand extends Command {
|
|
10142
|
+
}
|
|
10143
|
+
ImportDefaultAgentPluginsCommand.type = '[Agent Plugins] Import defaults';
|
|
10144
|
+
Reflect.defineMetadata('__command__', {
|
|
10145
|
+
id: ImportDefaultAgentPluginsCommand.type
|
|
10146
|
+
}, ImportDefaultAgentPluginsCommand);
|
|
10147
|
+
|
|
10148
|
+
export { ACCOUNT_BINDING_PERMISSION_SERVICE_TOKEN, AGENT_CHAT_DISPATCH_ERROR_STEER_TARGET_NOT_RUNNING, AGENT_CHAT_DISPATCH_MESSAGE_TYPE, AGENT_MIDDLEWARE_STRATEGY, AGENT_RUNTIME_EVENT_MESSAGE_TYPE, AGENT_RUNTIME_STRATEGY, AIModel, AIModelProviderNotFoundException, AIModelProviderRegistry, AIModelProviderStrategy, AI_MODEL_PROVIDER, ASSISTANT_CAPABILITY_PROVIDER, AdapterDataSourceStrategy, AgentExecutionRunnerCapability, AgentExecutionRunnerFactoryCapability, AgentInvocationRuntimeCapability, AgentMiddlewareRegistry, AgentMiddlewareStrategy, AgentRuntimeFactoryCapability, AgentRuntimeRegistry, AgentRuntimeStrategy, AiModelNotFoundException, 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, CancelConversationCommand, ChatChannel, ChatChannelRegistry, ChatOAICompatReasoningModel, CliModelProfilesCapability, CollaborationDocumentProvider, CollaborationDocumentProviderRegistry, CollaborationRuntimeCapability, CommonParameterRules, ConnectorRuntimeCapability, ConnectorRuntimeFactoryCapability, ConnectorStrategyKey, ConnectorStrategyRegistry, 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, 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, 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, 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_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, ProjectTaskProvider, ProjectTaskProviderRegistry, ProjectTasksRuntimeCapability, ProjectTypeProvider, ProjectTypeProviderRegistry, RESOURCE_CARD_EVENT, RESOURCE_CARD_PROVIDER, RETRIEVER_STRATEGY, RequestContext, RequestContextMiddleware, RequirePermissionOperation, RerankModel, 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, 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, agentRuntimeEventMessageId, agentRuntimeEventSchema, agentRuntimeReplyTargetSchema, agentRuntimeResultClaimSchema, agentRuntimeResultConsumptionKey, als, appendSandboxMessage, assertConnectorDefinition, buildSandboxTimeoutMessage, calcTokenUsage, calculateLLMUsagePrice, calculateModelPrice, calculateModelUsageCharge, chunkText, countTextTokens, countTokensSafe, createI18nInstance, createPluginLogger, createRuntimeCapability, defineAgentMessageType, defineChannelMessageType, defineMcpApp, defineMcpCapabilities, defineMcpPrompt, defineMcpResource, defineMcpResourceTemplate, defineXpertTool, derivePluginArtifactNamespace, describeXpertToolProvider, downloadRemoteFile, emitResourceCard, formatSandboxTimeout, getDefaultTenantId, getErrorMessage, getModelContextSize, getPermissionOperationMetadata, getPositionList, getPositionMap, getRequestContext, getRequiredPermissionOperation, getTenantGlobalScopeKey, getXpertToolMethod, isAgentInvocationTerminal, isDevelopmentSandboxRuntimeEnvironment, isModelOutputValidationError, isModelUsagePricingConfig, isRemoteFile, isSandboxBackend, isSandboxManagedServiceAdapter, isSandboxServiceProxyAdapter, isSandboxTerminalAdapter, isStrategyInstance, isStructuredMessageType, isTenantGlobalScopeKey, knowledgebaseActions, loadYamlFile, mergeCredentials, mergeModelRequirements, mergeParentChildChunks, nativeModelTransport, normalizeContextSize, normalizeTokenUsage, pluginArtifactTableName, prepareToolResult, processAsyncAIGCManagedJob, renderRemoteModuleIframeHtml, renderRemoteReactIframeHtml, renderRemoteVueIframeHtml, resolveModelUsagePricingSnapshot, resolveSandboxBackend, resolveSandboxExecutionOptions, resolveSandboxManagedServiceAdapter, resolveSandboxServiceProxyAdapter, resolveSandboxTerminalAdapter, resolveStrategyMetadataTarget, resolveTenantGlobalScopeKey, resolveTokenUsage, resolveTokenUsageCandidates, resolveXpertMcpExtensions, runWithRequestContext, runtimeToolProviderComponent, secondsToMilliseconds, setDefaultTenantId, sumTokenUsage, taskWaitReason, textTokenBoundaries };
|
package/model-provider.cjs.js
CHANGED
|
@@ -6,6 +6,46 @@ var common = require('@nestjs/common');
|
|
|
6
6
|
var tools = require('@langchain/core/tools');
|
|
7
7
|
var v3 = require('zod/v3');
|
|
8
8
|
|
|
9
|
+
function createRuntimeCapability(id, options = {}) {
|
|
10
|
+
return Object.freeze({
|
|
11
|
+
id,
|
|
12
|
+
description: options.description
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
const XPERT_RUNTIME_CAPABILITIES_TOKEN = 'XPERT_RUNTIME_CAPABILITIES';
|
|
16
|
+
/** Metadata key under which RuntimeCapabilityProviderExplorer discovers capability providers. */ const RUNTIME_CAPABILITY_PROVIDER = 'XPERT_RUNTIME_CAPABILITY_PROVIDER';
|
|
17
|
+
/** Tags a Nest provider as the platform implementation of a runtime capability. */ const RuntimeCapabilityProvider = (capability)=>common.SetMetadata(RUNTIME_CAPABILITY_PROVIDER, capability);
|
|
18
|
+
class DefaultRuntimeCapabilityRegistry {
|
|
19
|
+
register(key, implementation) {
|
|
20
|
+
this.capabilities.set(runtimeCapabilityId(key), implementation);
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
has(key) {
|
|
24
|
+
var _this_parent;
|
|
25
|
+
return this.capabilities.has(runtimeCapabilityId(key)) || ((_this_parent = this.parent) == null ? void 0 : _this_parent.get(key)) !== undefined;
|
|
26
|
+
}
|
|
27
|
+
get(key) {
|
|
28
|
+
var _this_parent;
|
|
29
|
+
const id = runtimeCapabilityId(key);
|
|
30
|
+
return this.capabilities.has(id) ? this.capabilities.get(id) : (_this_parent = this.parent) == null ? void 0 : _this_parent.get(key);
|
|
31
|
+
}
|
|
32
|
+
require(key) {
|
|
33
|
+
const implementation = this.get(key);
|
|
34
|
+
if (!implementation) {
|
|
35
|
+
throw new Error(`Runtime capability '${runtimeCapabilityId(key)}' is not available`);
|
|
36
|
+
}
|
|
37
|
+
return implementation;
|
|
38
|
+
}
|
|
39
|
+
constructor(entries = [], parent){
|
|
40
|
+
this.capabilities = new Map();
|
|
41
|
+
this.parent = parent;
|
|
42
|
+
entries.forEach(([key, implementation])=>this.register(key, implementation));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function runtimeCapabilityId(key) {
|
|
46
|
+
return typeof key === 'string' ? key : key.id;
|
|
47
|
+
}
|
|
48
|
+
|
|
9
49
|
/**
|
|
10
50
|
* Base ability for all toolsets
|
|
11
51
|
*/ class BaseToolset extends tools.BaseToolkit {
|
|
@@ -147,68 +187,6 @@ class BuiltinToolset extends BaseToolset {
|
|
|
147
187
|
}
|
|
148
188
|
BuiltinToolset.provider = '';
|
|
149
189
|
|
|
150
|
-
function createRuntimeCapability(id, options = {}) {
|
|
151
|
-
return Object.freeze({
|
|
152
|
-
id,
|
|
153
|
-
description: options.description
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
const XPERT_RUNTIME_CAPABILITIES_TOKEN = 'XPERT_RUNTIME_CAPABILITIES';
|
|
157
|
-
/** Metadata key under which RuntimeCapabilityProviderExplorer discovers capability providers. */ const RUNTIME_CAPABILITY_PROVIDER = 'XPERT_RUNTIME_CAPABILITY_PROVIDER';
|
|
158
|
-
/** Tags a Nest provider as the platform implementation of a runtime capability. */ const RuntimeCapabilityProvider = (capability)=>common.SetMetadata(RUNTIME_CAPABILITY_PROVIDER, capability);
|
|
159
|
-
class DefaultRuntimeCapabilityRegistry {
|
|
160
|
-
register(key, implementation) {
|
|
161
|
-
this.capabilities.set(runtimeCapabilityId(key), implementation);
|
|
162
|
-
return this;
|
|
163
|
-
}
|
|
164
|
-
has(key) {
|
|
165
|
-
var _this_parent;
|
|
166
|
-
return this.capabilities.has(runtimeCapabilityId(key)) || ((_this_parent = this.parent) == null ? void 0 : _this_parent.get(key)) !== undefined;
|
|
167
|
-
}
|
|
168
|
-
get(key) {
|
|
169
|
-
var _this_parent;
|
|
170
|
-
const id = runtimeCapabilityId(key);
|
|
171
|
-
return this.capabilities.has(id) ? this.capabilities.get(id) : (_this_parent = this.parent) == null ? void 0 : _this_parent.get(key);
|
|
172
|
-
}
|
|
173
|
-
require(key) {
|
|
174
|
-
const implementation = this.get(key);
|
|
175
|
-
if (!implementation) {
|
|
176
|
-
throw new Error(`Runtime capability '${runtimeCapabilityId(key)}' is not available`);
|
|
177
|
-
}
|
|
178
|
-
return implementation;
|
|
179
|
-
}
|
|
180
|
-
constructor(entries = [], parent){
|
|
181
|
-
this.capabilities = new Map();
|
|
182
|
-
this.parent = parent;
|
|
183
|
-
entries.forEach(([key, implementation])=>this.register(key, implementation));
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
function runtimeCapabilityId(key) {
|
|
187
|
-
return typeof key === 'string' ? key : key.id;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
const KnowledgebaseRuntimeCapability = createRuntimeCapability('platform.knowledgebase', {
|
|
191
|
-
description: 'List, search, and write chunks in platform knowledgebases.'
|
|
192
|
-
});
|
|
193
|
-
const KnowledgebaseProvisioningRuntimeCapability = createRuntimeCapability('platform.knowledgebase.provisioning', {
|
|
194
|
-
description: 'Idempotently provision managed platform knowledgebases and connect them to an Agent.'
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
const KnowledgeGraphRuntimeCapability = createRuntimeCapability('platform.knowledge-graph', {
|
|
198
|
-
description: 'Publish, inspect, and retract source-owned structured knowledge graphs without model extraction.'
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
const KnowledgebaseDocumentsRuntimeCapability = createRuntimeCapability('platform.knowledgebase.documents', {
|
|
202
|
-
description: 'Upload, import, create, process, reprocess, inspect, and delete persistent knowledgebase documents.'
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
const KnowledgeDocumentVisualAssetsRuntimeCapability = createRuntimeCapability('platform.knowledgebase.visual-assets', {
|
|
206
|
-
description: 'Issue execution-scoped logical KnowledgeDocument image paths and inject validated images without exposing host storage paths.'
|
|
207
|
-
});
|
|
208
|
-
const KnowledgeDocumentVisualAssetsRuntimeFactoryCapability = createRuntimeCapability('platform.knowledge-document.visual-assets.factory', {
|
|
209
|
-
description: 'Create a visual-assets API with an execution-local image allow-list and authorized workspace writer.'
|
|
210
|
-
});
|
|
211
|
-
|
|
212
190
|
const ActorTokenRuntimeCapability = createRuntimeCapability('platform.actor-token', {
|
|
213
191
|
description: 'Mint a short-lived host-issued actor bearer token for outbound API calls.'
|
|
214
192
|
});
|
|
@@ -397,12 +375,6 @@ exports.BaseTool = BaseTool;
|
|
|
397
375
|
exports.BaseToolset = BaseToolset;
|
|
398
376
|
exports.BuiltinToolset = BuiltinToolset;
|
|
399
377
|
exports.DefaultRuntimeCapabilityRegistry = DefaultRuntimeCapabilityRegistry;
|
|
400
|
-
exports.KnowledgeDocumentVisualAssetsRuntimeCapability = KnowledgeDocumentVisualAssetsRuntimeCapability;
|
|
401
|
-
exports.KnowledgeDocumentVisualAssetsRuntimeFactoryCapability = KnowledgeDocumentVisualAssetsRuntimeFactoryCapability;
|
|
402
|
-
exports.KnowledgeGraphRuntimeCapability = KnowledgeGraphRuntimeCapability;
|
|
403
|
-
exports.KnowledgebaseDocumentsRuntimeCapability = KnowledgebaseDocumentsRuntimeCapability;
|
|
404
|
-
exports.KnowledgebaseProvisioningRuntimeCapability = KnowledgebaseProvisioningRuntimeCapability;
|
|
405
|
-
exports.KnowledgebaseRuntimeCapability = KnowledgebaseRuntimeCapability;
|
|
406
378
|
exports.ModelProviderBuiltinToolset = ModelProviderBuiltinToolset;
|
|
407
379
|
exports.ProjectAccessRuntimeCapability = ProjectAccessRuntimeCapability;
|
|
408
380
|
exports.ProjectProvisioningRuntimeCapability = ProjectProvisioningRuntimeCapability;
|
package/model-provider.esm.js
CHANGED
|
@@ -1,9 +1,49 @@
|
|
|
1
1
|
import { _ as _extends } from './_extends.esm.js';
|
|
2
2
|
import { AiModelTypeEnum } from '@xpert-ai/contracts';
|
|
3
|
-
import {
|
|
3
|
+
import { SetMetadata, Logger } from '@nestjs/common';
|
|
4
4
|
import { BaseToolkit, StructuredTool } from '@langchain/core/tools';
|
|
5
5
|
import { z } from 'zod/v3';
|
|
6
6
|
|
|
7
|
+
function createRuntimeCapability(id, options = {}) {
|
|
8
|
+
return Object.freeze({
|
|
9
|
+
id,
|
|
10
|
+
description: options.description
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
const XPERT_RUNTIME_CAPABILITIES_TOKEN = 'XPERT_RUNTIME_CAPABILITIES';
|
|
14
|
+
/** Metadata key under which RuntimeCapabilityProviderExplorer discovers capability providers. */ const RUNTIME_CAPABILITY_PROVIDER = 'XPERT_RUNTIME_CAPABILITY_PROVIDER';
|
|
15
|
+
/** Tags a Nest provider as the platform implementation of a runtime capability. */ const RuntimeCapabilityProvider = (capability)=>SetMetadata(RUNTIME_CAPABILITY_PROVIDER, capability);
|
|
16
|
+
class DefaultRuntimeCapabilityRegistry {
|
|
17
|
+
register(key, implementation) {
|
|
18
|
+
this.capabilities.set(runtimeCapabilityId(key), implementation);
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
has(key) {
|
|
22
|
+
var _this_parent;
|
|
23
|
+
return this.capabilities.has(runtimeCapabilityId(key)) || ((_this_parent = this.parent) == null ? void 0 : _this_parent.get(key)) !== undefined;
|
|
24
|
+
}
|
|
25
|
+
get(key) {
|
|
26
|
+
var _this_parent;
|
|
27
|
+
const id = runtimeCapabilityId(key);
|
|
28
|
+
return this.capabilities.has(id) ? this.capabilities.get(id) : (_this_parent = this.parent) == null ? void 0 : _this_parent.get(key);
|
|
29
|
+
}
|
|
30
|
+
require(key) {
|
|
31
|
+
const implementation = this.get(key);
|
|
32
|
+
if (!implementation) {
|
|
33
|
+
throw new Error(`Runtime capability '${runtimeCapabilityId(key)}' is not available`);
|
|
34
|
+
}
|
|
35
|
+
return implementation;
|
|
36
|
+
}
|
|
37
|
+
constructor(entries = [], parent){
|
|
38
|
+
this.capabilities = new Map();
|
|
39
|
+
this.parent = parent;
|
|
40
|
+
entries.forEach(([key, implementation])=>this.register(key, implementation));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function runtimeCapabilityId(key) {
|
|
44
|
+
return typeof key === 'string' ? key : key.id;
|
|
45
|
+
}
|
|
46
|
+
|
|
7
47
|
/**
|
|
8
48
|
* Base ability for all toolsets
|
|
9
49
|
*/ class BaseToolset extends BaseToolkit {
|
|
@@ -145,68 +185,6 @@ class BuiltinToolset extends BaseToolset {
|
|
|
145
185
|
}
|
|
146
186
|
BuiltinToolset.provider = '';
|
|
147
187
|
|
|
148
|
-
function createRuntimeCapability(id, options = {}) {
|
|
149
|
-
return Object.freeze({
|
|
150
|
-
id,
|
|
151
|
-
description: options.description
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
const XPERT_RUNTIME_CAPABILITIES_TOKEN = 'XPERT_RUNTIME_CAPABILITIES';
|
|
155
|
-
/** Metadata key under which RuntimeCapabilityProviderExplorer discovers capability providers. */ const RUNTIME_CAPABILITY_PROVIDER = 'XPERT_RUNTIME_CAPABILITY_PROVIDER';
|
|
156
|
-
/** Tags a Nest provider as the platform implementation of a runtime capability. */ const RuntimeCapabilityProvider = (capability)=>SetMetadata(RUNTIME_CAPABILITY_PROVIDER, capability);
|
|
157
|
-
class DefaultRuntimeCapabilityRegistry {
|
|
158
|
-
register(key, implementation) {
|
|
159
|
-
this.capabilities.set(runtimeCapabilityId(key), implementation);
|
|
160
|
-
return this;
|
|
161
|
-
}
|
|
162
|
-
has(key) {
|
|
163
|
-
var _this_parent;
|
|
164
|
-
return this.capabilities.has(runtimeCapabilityId(key)) || ((_this_parent = this.parent) == null ? void 0 : _this_parent.get(key)) !== undefined;
|
|
165
|
-
}
|
|
166
|
-
get(key) {
|
|
167
|
-
var _this_parent;
|
|
168
|
-
const id = runtimeCapabilityId(key);
|
|
169
|
-
return this.capabilities.has(id) ? this.capabilities.get(id) : (_this_parent = this.parent) == null ? void 0 : _this_parent.get(key);
|
|
170
|
-
}
|
|
171
|
-
require(key) {
|
|
172
|
-
const implementation = this.get(key);
|
|
173
|
-
if (!implementation) {
|
|
174
|
-
throw new Error(`Runtime capability '${runtimeCapabilityId(key)}' is not available`);
|
|
175
|
-
}
|
|
176
|
-
return implementation;
|
|
177
|
-
}
|
|
178
|
-
constructor(entries = [], parent){
|
|
179
|
-
this.capabilities = new Map();
|
|
180
|
-
this.parent = parent;
|
|
181
|
-
entries.forEach(([key, implementation])=>this.register(key, implementation));
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
function runtimeCapabilityId(key) {
|
|
185
|
-
return typeof key === 'string' ? key : key.id;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
const KnowledgebaseRuntimeCapability = createRuntimeCapability('platform.knowledgebase', {
|
|
189
|
-
description: 'List, search, and write chunks in platform knowledgebases.'
|
|
190
|
-
});
|
|
191
|
-
const KnowledgebaseProvisioningRuntimeCapability = createRuntimeCapability('platform.knowledgebase.provisioning', {
|
|
192
|
-
description: 'Idempotently provision managed platform knowledgebases and connect them to an Agent.'
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
const KnowledgeGraphRuntimeCapability = createRuntimeCapability('platform.knowledge-graph', {
|
|
196
|
-
description: 'Publish, inspect, and retract source-owned structured knowledge graphs without model extraction.'
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
const KnowledgebaseDocumentsRuntimeCapability = createRuntimeCapability('platform.knowledgebase.documents', {
|
|
200
|
-
description: 'Upload, import, create, process, reprocess, inspect, and delete persistent knowledgebase documents.'
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
const KnowledgeDocumentVisualAssetsRuntimeCapability = createRuntimeCapability('platform.knowledgebase.visual-assets', {
|
|
204
|
-
description: 'Issue execution-scoped logical KnowledgeDocument image paths and inject validated images without exposing host storage paths.'
|
|
205
|
-
});
|
|
206
|
-
const KnowledgeDocumentVisualAssetsRuntimeFactoryCapability = createRuntimeCapability('platform.knowledge-document.visual-assets.factory', {
|
|
207
|
-
description: 'Create a visual-assets API with an execution-local image allow-list and authorized workspace writer.'
|
|
208
|
-
});
|
|
209
|
-
|
|
210
188
|
const ActorTokenRuntimeCapability = createRuntimeCapability('platform.actor-token', {
|
|
211
189
|
description: 'Mint a short-lived host-issued actor bearer token for outbound API calls.'
|
|
212
190
|
});
|
|
@@ -388,4 +366,4 @@ function normalizeWorkspaceScope(scope) {
|
|
|
388
366
|
} : {});
|
|
389
367
|
}
|
|
390
368
|
|
|
391
|
-
export { ActorTokenRuntimeCapability as A, BuiltinToolset as B, DefaultRuntimeCapabilityRegistry as D,
|
|
369
|
+
export { ActorTokenRuntimeCapability as A, BuiltinToolset as B, DefaultRuntimeCapabilityRegistry as D, ModelProviderBuiltinToolset as M, ProjectAccessRuntimeCapability 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, ArtifactsRuntimeCapability as b, createRuntimeCapability as c, BaseTool as d, BaseToolset as e, ProjectProvisioningRuntimeCapability as f, RuntimeCapabilityProvider as g, SANDBOX_JOB_PROGRESS_PREFIX as h, SandboxJobRuntimeError as i, SandboxJobsRuntimeCapability as j, WORKSPACE_FILES_SOURCE as k, isSandboxJobRuntimeError as l };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xpert-ai/plugin-sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.21.1",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@langchain/openai": "0.6.9",
|
|
65
|
-
"@xpert-ai/contracts": "3.
|
|
65
|
+
"@xpert-ai/contracts": "3.21.0",
|
|
66
66
|
"express": "^4.22.1",
|
|
67
67
|
"js-tiktoken": "^1.0.21"
|
|
68
68
|
},
|
package/src/index.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ export declare const AGENT_CHAT_DISPATCH_MESSAGE_TYPE: import("./message-type").
|
|
|
3
3
|
export declare const AGENT_CHAT_DISPATCH_ERROR_STEER_TARGET_NOT_RUNNING = "steer_target_not_running";
|
|
4
4
|
export interface AgentChatHandoffMessageCallbackTarget {
|
|
5
5
|
transport?: 'handoff-message';
|
|
6
|
+
/** Defaults to all events; lifecycle emits only terminal callbacks, leaving tokens in the run stream. */
|
|
7
|
+
events?: 'all' | 'lifecycle';
|
|
6
8
|
messageType: string;
|
|
7
9
|
headers?: Record<string, string>;
|
|
8
10
|
context?: Record<string, unknown>;
|
|
@@ -16,6 +18,8 @@ export type AgentChatRuntimePrincipal = TChatRuntimePrincipal;
|
|
|
16
18
|
export interface AgentChatDispatchPayload extends Record<string, unknown> {
|
|
17
19
|
request: TChatRequest;
|
|
18
20
|
options: TChatOptions & TChatSourceAuditOptions & {
|
|
21
|
+
/** Host-created group recipient receipt; the runtime must reauthorize it before execution. */
|
|
22
|
+
groupDeliveryId?: string;
|
|
19
23
|
/** Host-resolved runtime branch, independent of the conversation root. */
|
|
20
24
|
threadId?: string;
|
|
21
25
|
isDerivedThread?: boolean;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Command } from '@nestjs/cqrs';
|
|
2
|
+
import type { DefaultAgentPluginsImportResult } from '@xpert-ai/contracts';
|
|
3
|
+
/** Import official resource packages for the authenticated organization administrator. Does not authorize workspaces. */
|
|
4
|
+
export declare class ImportDefaultAgentPluginsCommand extends Command<DefaultAgentPluginsImportResult> {
|
|
5
|
+
static readonly type = "[Agent Plugins] Import defaults";
|
|
6
|
+
}
|
|
@@ -10,6 +10,7 @@ export declare class RequestContext {
|
|
|
10
10
|
readonly extras: Record<string, any>;
|
|
11
11
|
constructor(request: IncomingMessage, response: ServerResponse, reqId: string, userId?: string, extras?: Record<string, any>);
|
|
12
12
|
static currentRequestContext(): RequestContext;
|
|
13
|
+
/** @deprecated For resource authorization use currentApiPrincipal()?.resourceScope; retained for credential metadata. */
|
|
13
14
|
static currentApiKey(): IApiKey | null;
|
|
14
15
|
static currentApiPrincipal(): IApiPrincipal | null;
|
|
15
16
|
static currentRequest(): IncomingMessage;
|
package/src/lib/{runtime/capabilities → rag/capability}/knowledge-document-visual-assets.d.ts
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { RuntimeIdentityScope } from '
|
|
2
|
-
import type { WorkspaceFilesApi, WorkspacePortableFileReference } from '
|
|
1
|
+
import type { RuntimeIdentityScope } from '../../runtime/runtime-scope';
|
|
2
|
+
import type { WorkspaceFilesApi, WorkspacePortableFileReference } from '../../runtime/capabilities/workspace-files';
|
|
3
3
|
export type KnowledgeDocumentVisualCandidateReason = 'same_block' | 'same_chunk' | 'same_page' | 'adjacent_page' | 'visual_summary_match' | 'visual_only_fallback';
|
|
4
4
|
export type KnowledgeDocumentVisualTextAnchor = {
|
|
5
5
|
page?: number;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/** Persisted upload progress within one knowledgebase; completion does not imply document import or processing. */
|
|
2
|
+
export type KnowledgeUploadSession = {
|
|
3
|
+
/** Host-generated session UUID, used together with the owning knowledgebaseId. */
|
|
4
|
+
id: string;
|
|
5
|
+
/** Display file name; not a storage path. */
|
|
6
|
+
name: string;
|
|
7
|
+
/** Expected total file size in bytes. */
|
|
8
|
+
size: number;
|
|
9
|
+
/** Host-selected part size in bytes; only the final part may be shorter. */
|
|
10
|
+
chunkSize: number;
|
|
11
|
+
/** Persisted zero-based part indexes, sorted in ascending order; gaps identify missing parts. */
|
|
12
|
+
received: number[];
|
|
13
|
+
/** Lowercase hexadecimal SHA-256 of each received part, keyed by its decimal index. */
|
|
14
|
+
partHashes: Record<string, string>;
|
|
15
|
+
/** True after complete() verifies all expected parts and records the whole-file hash. */
|
|
16
|
+
complete: boolean;
|
|
17
|
+
/** Lowercase hexadecimal SHA-256 of the whole file, available after successful completion. */
|
|
18
|
+
sha256?: string;
|
|
19
|
+
};
|
|
20
|
+
/** Server-only staged uploads exposed through Documents.uploads. Every operation revalidates Knowledge write access. */
|
|
21
|
+
export interface KnowledgeUploadSessionsApi {
|
|
22
|
+
/**
|
|
23
|
+
* Create a new upload session without creating or processing a document.
|
|
24
|
+
* size is the total byte count (positive, currently at most 2 GiB); use the returned chunkSize for part boundaries.
|
|
25
|
+
*/
|
|
26
|
+
create(input: {
|
|
27
|
+
knowledgebaseId: string;
|
|
28
|
+
name: string;
|
|
29
|
+
size: number;
|
|
30
|
+
}): Promise<KnowledgeUploadSession>;
|
|
31
|
+
/** Read persisted progress and part hashes to resume an existing session, including after a server restart. */
|
|
32
|
+
status(input: {
|
|
33
|
+
knowledgebaseId: string;
|
|
34
|
+
sessionId: string;
|
|
35
|
+
}): Promise<KnowledgeUploadSession>;
|
|
36
|
+
/**
|
|
37
|
+
* Persist one zero-based part; parts may arrive out of order.
|
|
38
|
+
* buffer must match the expected part length and sha256 must be its lowercase hexadecimal SHA-256.
|
|
39
|
+
* Retrying identical bytes is safe; conflicting bytes for an existing index are rejected.
|
|
40
|
+
*/
|
|
41
|
+
append(input: {
|
|
42
|
+
knowledgebaseId: string;
|
|
43
|
+
sessionId: string;
|
|
44
|
+
index: number;
|
|
45
|
+
buffer: Buffer;
|
|
46
|
+
sha256: string;
|
|
47
|
+
}): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Verify all parts and their lengths, then record the whole-file SHA-256 and mark the session complete.
|
|
50
|
+
* Incomplete uploads fail; repeated completion is safe. Does not import documents or start processing.
|
|
51
|
+
*/
|
|
52
|
+
complete(input: {
|
|
53
|
+
knowledgebaseId: string;
|
|
54
|
+
sessionId: string;
|
|
55
|
+
}): Promise<KnowledgeUploadSession>;
|
|
56
|
+
/**
|
|
57
|
+
* Read bytes from a completed upload, including ranges that cross part boundaries, for streaming ZIP readers.
|
|
58
|
+
* offset is zero-based; length is nonnegative, at most chunkSize, and offset + length must not exceed size.
|
|
59
|
+
*/
|
|
60
|
+
read(input: {
|
|
61
|
+
knowledgebaseId: string;
|
|
62
|
+
sessionId: string;
|
|
63
|
+
offset: number;
|
|
64
|
+
length: number;
|
|
65
|
+
}): Promise<Buffer>;
|
|
66
|
+
/** Delete an existing session and its staged bytes; previously imported documents are unaffected. */
|
|
67
|
+
remove(input: {
|
|
68
|
+
knowledgebaseId: string;
|
|
69
|
+
sessionId: string;
|
|
70
|
+
}): Promise<void>;
|
|
71
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/** Knowledgebase discovery is scoped to the authenticated runtime, never caller-supplied identities. */
|
|
2
|
+
export declare const knowledgebaseActions: readonly ["knowledgebase.read", "knowledgebase.manage", "content.search", "documents.read", "documents.create", "documents.update", "documents.delete", "documents.process", "chunks.write", "chunks.delete"];
|
|
3
|
+
export type KnowledgebaseAction = (typeof knowledgebaseActions)[number];
|
|
4
|
+
export type KnowledgebaseQuery = {
|
|
5
|
+
scope: {
|
|
6
|
+
kind: 'workspace';
|
|
7
|
+
workspaceId: string;
|
|
8
|
+
relation: 'owned' | 'available';
|
|
9
|
+
} | {
|
|
10
|
+
kind: 'organization';
|
|
11
|
+
} | {
|
|
12
|
+
kind: 'tenant';
|
|
13
|
+
};
|
|
14
|
+
filter?: {
|
|
15
|
+
/** Literal name/description substring, not content retrieval. */
|
|
16
|
+
text?: string;
|
|
17
|
+
visibility?: 'private' | 'organization' | 'public';
|
|
18
|
+
applicationTags?: {
|
|
19
|
+
allOf: string[];
|
|
20
|
+
};
|
|
21
|
+
publication?: 'published' | 'unpublished';
|
|
22
|
+
};
|
|
23
|
+
access?: {
|
|
24
|
+
requireAll: KnowledgebaseAction[];
|
|
25
|
+
};
|
|
26
|
+
page?: {
|
|
27
|
+
limit?: number;
|
|
28
|
+
cursor?: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export type KnowledgebaseSummary = {
|
|
32
|
+
id: string;
|
|
33
|
+
name: string;
|
|
34
|
+
description: string | null;
|
|
35
|
+
workspaceId: string | null;
|
|
36
|
+
visibility: 'private' | 'organization' | 'public';
|
|
37
|
+
applicationTags: string[];
|
|
38
|
+
type: string | null;
|
|
39
|
+
status: string | null;
|
|
40
|
+
published: boolean;
|
|
41
|
+
documentNum: number;
|
|
42
|
+
chunkNum: number;
|
|
43
|
+
};
|
|
44
|
+
export type KnowledgebasePage = {
|
|
45
|
+
items: KnowledgebaseSummary[];
|
|
46
|
+
/** Follow even when items is empty; authorization is re-evaluated on every page. */
|
|
47
|
+
nextCursor: string | null;
|
|
48
|
+
};
|
|
49
|
+
export type KnowledgebaseDetail = KnowledgebaseSummary & {
|
|
50
|
+
capabilities: {
|
|
51
|
+
documentIngestion: boolean;
|
|
52
|
+
};
|
|
53
|
+
configuration: {
|
|
54
|
+
embeddingConfigured: boolean;
|
|
55
|
+
};
|
|
56
|
+
processing: {
|
|
57
|
+
blocked: boolean;
|
|
58
|
+
reason: 'rebuilding' | 'embedding_not_configured' | 'unsupported_type' | null;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
export type KnowledgebaseGetInput = {
|
|
62
|
+
knowledgebaseId: string;
|
|
63
|
+
};
|
|
64
|
+
export type KnowledgebaseAccessInput = {
|
|
65
|
+
knowledgebaseIds: string[];
|
|
66
|
+
actions: KnowledgebaseAction[];
|
|
67
|
+
};
|
|
68
|
+
export type KnowledgebaseAccessResult = {
|
|
69
|
+
items: Array<{
|
|
70
|
+
knowledgebaseId: string;
|
|
71
|
+
/** Missing and inaccessible resources have the same unavailable result. */
|
|
72
|
+
status: 'available' | 'unavailable';
|
|
73
|
+
actions: Array<{
|
|
74
|
+
action: KnowledgebaseAction;
|
|
75
|
+
allowed: boolean;
|
|
76
|
+
}>;
|
|
77
|
+
}>;
|
|
78
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type I18nObject, type DocumentTextParserConfig, type DocumentSheetParserConfig, JSONValue } from '@xpert-ai/contracts';
|
|
2
|
-
import type { WorkspacePortableFileReference } from '
|
|
2
|
+
import type { WorkspacePortableFileReference } from '../../runtime/capabilities/workspace-files';
|
|
3
|
+
import type { KnowledgeUploadSessionsApi } from './knowledge-upload-sessions';
|
|
3
4
|
export type KnowledgebaseDocumentFile = {
|
|
4
5
|
buffer: Buffer;
|
|
5
6
|
originalname?: string;
|
|
@@ -60,6 +61,9 @@ export type KnowledgebaseListDocumentsInput = {
|
|
|
60
61
|
page?: number;
|
|
61
62
|
pageSize?: number;
|
|
62
63
|
search?: string;
|
|
64
|
+
/** Literal substring search; paths include the logical folder and imported originalRelativePath. */
|
|
65
|
+
searchFields?: Array<'name' | 'path'>;
|
|
66
|
+
mimeTypes?: string[];
|
|
63
67
|
includeFolders?: boolean;
|
|
64
68
|
/** List direct children of this folder. Use null for the knowledgebase root. */
|
|
65
69
|
parentId?: string | null;
|
|
@@ -110,6 +114,8 @@ export type KnowledgebaseUploadedFile = {
|
|
|
110
114
|
};
|
|
111
115
|
export type KnowledgebaseCreateDocumentsInput = {
|
|
112
116
|
knowledgebaseId: string;
|
|
117
|
+
/** Retry key, scoped to this Knowledge base. Repeated creation returns the original documents. */
|
|
118
|
+
idempotencyKey?: string;
|
|
113
119
|
documents: KnowledgebaseDocumentDraft[];
|
|
114
120
|
parserConfig?: KnowledgebaseDocumentParserConfig;
|
|
115
121
|
metadata?: KnowledgebaseDocumentMetadata;
|
|
@@ -266,6 +272,8 @@ export type KnowledgebaseProcessingOptionsResult = {
|
|
|
266
272
|
parserConfig: DocumentTextParserConfig & Partial<DocumentSheetParserConfig>;
|
|
267
273
|
};
|
|
268
274
|
export interface KnowledgebaseDocumentsApi {
|
|
275
|
+
/** Stage resumable uploads without starting document processing. */
|
|
276
|
+
readonly uploads: KnowledgeUploadSessionsApi;
|
|
269
277
|
getProcessingOptions(input: KnowledgebaseProcessingOptionsInput): Promise<KnowledgebaseProcessingOptionsResult>;
|
|
270
278
|
readText(input: KnowledgebaseReadTextInput): Promise<KnowledgebaseReadTextResult>;
|
|
271
279
|
/** Missing/stale conversion snapshots fail explicitly; this never falls back to indexed chunks. */
|