@xpert-ai/plugin-sdk 3.19.0 → 3.21.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/CHANGELOG.md +124 -0
- package/README.md +55 -0
- package/RESOURCE-CARDS-VALIDATION.md +51 -0
- package/RESOURCE-CARDS.md +361 -0
- package/TOOL-IMAGES.md +85 -0
- package/agent-results.cjs.default.js +1 -0
- package/agent-results.cjs.js +20 -0
- package/agent-results.cjs.mjs +2 -0
- package/agent-results.d.ts +1 -0
- package/agent-results.esm.js +4 -0
- package/index.cjs.js +494 -115
- package/index.esm.js +444 -114
- package/model-provider.cjs.js +45 -68
- package/model-provider.esm.js +46 -64
- package/package.json +8 -2
- package/results.cjs.js +50 -0
- package/results.esm.js +46 -0
- package/src/agent-results.d.ts +2 -0
- package/src/index.d.ts +3 -0
- package/src/lib/agent/handoff/agent-chat.contract.d.ts +10 -1
- package/src/lib/agent/handoff/agent-runtime-message.contract.d.ts +319 -0
- package/src/lib/agent/handoff/index.d.ts +1 -0
- package/src/lib/agent/index.d.ts +1 -0
- package/src/lib/agent/middleware/index.d.ts +1 -0
- package/src/lib/agent/middleware/model-requirements.d.ts +9 -0
- package/src/lib/agent/middleware/strategy.interface.d.ts +4 -0
- package/src/lib/agent/middleware/types.d.ts +7 -0
- package/src/lib/agent/resource-card.d.ts +3 -0
- package/src/lib/agent/runtime/activity.d.ts +6 -0
- package/src/lib/agent/runtime/capability.d.ts +13 -5
- package/src/lib/agent/runtime/cli-model-profile.d.ts +62 -0
- package/src/lib/agent/runtime/dispatch.d.ts +517 -0
- package/src/lib/agent/runtime/execution-runner.d.ts +66 -0
- package/src/lib/agent/runtime/index.d.ts +7 -0
- package/src/lib/agent/runtime/model-execution.d.ts +15 -0
- package/src/lib/agent/runtime/results.d.ts +335 -0
- package/src/lib/agent/runtime/strategy.d.ts +3 -0
- package/src/lib/agent/runtime/task-wait.d.ts +35 -0
- package/src/lib/agent/runtime/types.d.ts +35 -11
- package/src/lib/agent-plugin/import-default-agent-plugins.command.d.ts +6 -0
- package/src/lib/ai-model/ai-model-provider.interface.d.ts +2 -0
- package/src/lib/ai-model/ai-model.d.ts +2 -0
- package/src/lib/ai-model/index.d.ts +3 -0
- package/src/lib/ai-model/llm.d.ts +4 -2
- package/src/lib/ai-model/native-model.d.ts +22 -0
- package/src/lib/ai-model/realtime.d.ts +36 -0
- package/src/lib/ai-model/token-usage.d.ts +13 -0
- package/src/lib/core/context/request-context.d.ts +1 -0
- package/src/lib/mcp/app.d.ts +4 -1
- package/src/lib/project-task/index.d.ts +8 -1
- package/src/lib/project-type/index.d.ts +8 -1
- package/src/lib/rag/capability/index.d.ts +5 -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/{runtime/capabilities → rag/capability}/knowledgebase-documents.d.ts +9 -1
- package/src/lib/{runtime/capabilities → rag/capability}/knowledgebase.d.ts +4 -0
- package/src/lib/rag/index.d.ts +1 -0
- package/src/lib/resource-card-provider/index.d.ts +3 -0
- package/src/lib/resource-card-provider/provider.decorator.d.ts +4 -0
- package/src/lib/resource-card-provider/provider.registry.d.ts +14 -0
- package/src/lib/resource-card-provider/types.d.ts +36 -0
- package/src/lib/resource-card.d.ts +6 -0
- package/src/lib/runtime/capabilities/index.d.ts +1 -4
- package/src/lib/runtime/capabilities/project-provisioning.d.ts +10 -0
- package/src/lib/runtime/capabilities/tool-images.d.ts +24 -0
- package/src/lib/runtime/capabilities/workspace-files.d.ts +8 -2
- package/src/lib/sandbox/execution-environment.d.ts +2 -0
- package/src/lib/sandbox/execution.d.ts +10 -0
- package/src/lib/sandbox/managed-service.d.ts +1 -0
- /package/src/lib/{runtime/capabilities → rag/capability}/knowledge-graph.d.ts +0 -0
package/index.esm.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { Module,
|
|
1
|
+
import { Module, applyDecorators, SetMetadata, HttpException, HttpStatus, BadRequestException, Injectable, Inject, Logger, Optional, UnauthorizedException, NotFoundException, ForbiddenException } from '@nestjs/common';
|
|
2
2
|
import { MODULE_METADATA } from '@nestjs/common/constants';
|
|
3
3
|
import { pick } from 'lodash-es';
|
|
4
|
-
import {
|
|
4
|
+
import { dispatchCustomEvent } from '@langchain/core/callbacks/dispatch';
|
|
5
|
+
import { ChatMessageEventTypeEnum, createResourceCardContent, LanguagesEnum, ParameterType, AiModelTypeEnum, PriceType, FetchFrom, ModelFeature, ModelPropertyKey, projectTaskExecutionContextSchema, projectTaskExecutionReferenceSchema, agentRuntimeProgressSchema, agentInvocationTerminalStatusSchema, MCP_REQUIRED_CONTEXTS, MCP_CAPABILITY_APPROVAL_MODES, MCP_TOOL_RISKS, MCP_TOOL_SIDE_EFFECTS, MCP_TOOL_IDEMPOTENCY, MCP_CAPABILITY_VISIBILITIES, PLUGIN_COMPONENT_TYPE } from '@xpert-ai/contracts';
|
|
6
|
+
export { ASSISTANT_CHAT_SEND_MESSAGE_COMMAND, ASSISTANT_CONTEXT_SET_COMMAND, agentOutputDeliverySchema, agentResultPathSchema, createResourceCardContent, parseResourceCard, resourceCardId } from '@xpert-ai/contracts';
|
|
5
7
|
import { DiscoveryService, Reflector } from '@nestjs/core';
|
|
6
8
|
import { Subject, filter } from 'rxjs';
|
|
7
|
-
import {
|
|
8
|
-
export { ASSISTANT_CHAT_SEND_MESSAGE_COMMAND, ASSISTANT_CONTEXT_SET_COMMAND } from '@xpert-ai/contracts';
|
|
9
|
+
import { _ as _extends } from './_extends.esm.js';
|
|
9
10
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
10
11
|
import { ExtractJwt } from 'passport-jwt';
|
|
11
12
|
import { randomUUID, createHash } from 'node:crypto';
|
|
@@ -15,7 +16,7 @@ import fs__default from 'fs';
|
|
|
15
16
|
import http from 'http';
|
|
16
17
|
import https from 'https';
|
|
17
18
|
import { c as createRuntimeCapability, B as BuiltinToolset, W as WorkspaceFilesRuntimeCapability } from './model-provider.esm.js';
|
|
18
|
-
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';
|
|
19
20
|
import fsPromises from 'fs/promises';
|
|
20
21
|
import * as path from 'path';
|
|
21
22
|
import path__default, { join } from 'path';
|
|
@@ -29,7 +30,7 @@ import * as _axios from 'axios';
|
|
|
29
30
|
export { DataSourceRuntimeCapability, SqlDatabaseWorkbenchAdapter, quoteDatabaseIdentifier, requireReadStatement, splitWorkbenchSql } from './data-workbench.esm.js';
|
|
30
31
|
import { BaseCallbackHandler } from '@langchain/core/callbacks/base';
|
|
31
32
|
import { ChatGenerationChunk } from '@langchain/core/outputs';
|
|
32
|
-
import { isAIMessageChunk, AIMessage } from '@langchain/core/messages';
|
|
33
|
+
import { isBaseMessage, isAIMessage, isAIMessageChunk, AIMessage } from '@langchain/core/messages';
|
|
33
34
|
import { ChatOpenAICompletions } from '@langchain/openai';
|
|
34
35
|
import { Document } from '@langchain/core/documents';
|
|
35
36
|
import { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
|
@@ -37,11 +38,12 @@ import { getEnvironmentVariable } from '@langchain/core/utils/env';
|
|
|
37
38
|
export { ModelProviderHttpClient, ModelProviderHttpError } from './model-provider-http-client.esm.js';
|
|
38
39
|
import { getEncodingNameForModel, encodingForModel, getEncoding } from 'js-tiktoken';
|
|
39
40
|
import { getModelContextSize as getModelContextSize$1 } from '@langchain/core/language_models/base';
|
|
41
|
+
import { z, ZodError, ZodFirstPartyTypeKind } from 'zod/v3';
|
|
42
|
+
export { A as AGENT_TASK_RESULTS_FEATURE, a as agentResultItemSchema, b as agentTaskResultSchema } from './results.esm.js';
|
|
40
43
|
import { assertConnectorDefinition } from './connector.esm.js';
|
|
41
44
|
export { CONNECTOR_AUTHORIZATION_MODES, CONNECTOR_SCOPE_TYPES, getConnectorAuthMethods, getConnectorAuthorizationModes } from './connector.esm.js';
|
|
42
45
|
export { base64ToBytes, bytesToBase64, createCollaborationClient, createCollaborationPresenceStore, createSocketIoTransportAdapter, createYjsDocumentAdapter } from './collaboration-client.esm.js';
|
|
43
46
|
import { tool } from '@langchain/core/tools';
|
|
44
|
-
import { ZodError, z, ZodFirstPartyTypeKind } from 'zod/v3';
|
|
45
47
|
|
|
46
48
|
/**
|
|
47
49
|
* Metadata keys used in plugins for defining various aspects like entities, subscribers, and configurations.
|
|
@@ -105,6 +107,10 @@ function assertPluginArtifactNamePart(value, label) {
|
|
|
105
107
|
}
|
|
106
108
|
}
|
|
107
109
|
|
|
110
|
+
/** Call after the business mutation commits. A display failure must not retry that mutation. */ async function emitResourceCard(card, config) {
|
|
111
|
+
await dispatchCustomEvent(ChatMessageEventTypeEnum.ON_CHAT_EVENT, createResourceCardContent(card), config);
|
|
112
|
+
}
|
|
113
|
+
|
|
108
114
|
const ORGANIZATION_METADATA_KEY = 'xpert:organizationId';
|
|
109
115
|
const PLUGIN_METADATA_KEY = 'xpert:pluginName';
|
|
110
116
|
const PLUGIN_VERSION_METADATA_KEY = 'xpert:pluginVersion';
|
|
@@ -141,27 +147,13 @@ function resolveTenantGlobalScopeKey(tenantId) {
|
|
|
141
147
|
return GLOBAL_ORGANIZATION_SCOPE;
|
|
142
148
|
}
|
|
143
149
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
};
|
|
152
|
-
return {
|
|
153
|
-
child (meta) {
|
|
154
|
-
return createPluginLogger(scope, _extends({}, baseMeta, meta));
|
|
155
|
-
},
|
|
156
|
-
debug: (msg, meta)=>wrap('debug', msg, meta),
|
|
157
|
-
log: (msg, meta)=>wrap('log', msg, meta),
|
|
158
|
-
warn: (msg, meta)=>wrap('warn', msg, meta),
|
|
159
|
-
error: (msg, meta)=>wrap('error', msg, meta)
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
const INTEGRATION_STRATEGY = 'INTEGRATION_STRATEGY';
|
|
164
|
-
const IntegrationStrategyKey = (provider)=>applyDecorators(SetMetadata(INTEGRATION_STRATEGY, provider), SetMetadata(STRATEGY_META_KEY, INTEGRATION_STRATEGY));
|
|
150
|
+
const RESOURCE_CARD_PROVIDER = 'RESOURCE_CARD_PROVIDER';
|
|
151
|
+
/** Register exact resource types whose message cards opt in to live refresh. */ const ResourceCardProvider = (...resources)=>{
|
|
152
|
+
if (!resources.length || resources.some(({ namespace, type })=>!(namespace == null ? void 0 : namespace.trim()) || !(type == null ? void 0 : type.trim()))) {
|
|
153
|
+
throw new Error('ResourceCardProvider requires explicit resource namespaces and types');
|
|
154
|
+
}
|
|
155
|
+
return applyDecorators(SetMetadata(RESOURCE_CARD_PROVIDER, resources), SetMetadata(STRATEGY_META_KEY, RESOURCE_CARD_PROVIDER));
|
|
156
|
+
};
|
|
165
157
|
|
|
166
158
|
function __decorate(decorators, target, key, desc) {
|
|
167
159
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -190,14 +182,15 @@ class RequestContext {
|
|
|
190
182
|
const session = getRequestContext();
|
|
191
183
|
return session;
|
|
192
184
|
}
|
|
193
|
-
static currentApiKey() {
|
|
185
|
+
/** @deprecated For resource authorization use currentApiPrincipal()?.resourceScope; retained for credential metadata. */ static currentApiKey() {
|
|
194
186
|
var _RequestContext_currentApiPrincipal;
|
|
195
187
|
var _RequestContext_currentApiPrincipal_apiKey;
|
|
196
188
|
return (_RequestContext_currentApiPrincipal_apiKey = (_RequestContext_currentApiPrincipal = RequestContext.currentApiPrincipal()) == null ? void 0 : _RequestContext_currentApiPrincipal.apiKey) != null ? _RequestContext_currentApiPrincipal_apiKey : null;
|
|
197
189
|
}
|
|
198
190
|
static currentApiPrincipal() {
|
|
199
191
|
const user = RequestContext.currentUser();
|
|
200
|
-
|
|
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;
|
|
201
194
|
}
|
|
202
195
|
static currentRequest() {
|
|
203
196
|
const requestContext = RequestContext.currentRequestContext();
|
|
@@ -746,6 +739,102 @@ __decorate([
|
|
|
746
739
|
return typeof constructor === 'function' ? constructor : null;
|
|
747
740
|
}
|
|
748
741
|
|
|
742
|
+
var ResourceCardProviderRegistry_1;
|
|
743
|
+
const resourceTypeKey = ({ namespace, type })=>JSON.stringify([
|
|
744
|
+
namespace,
|
|
745
|
+
type
|
|
746
|
+
]);
|
|
747
|
+
function isProvider(value) {
|
|
748
|
+
return !!value && typeof value === 'object' && 'resolveMany' in value && typeof value.resolveMany === 'function';
|
|
749
|
+
}
|
|
750
|
+
let ResourceCardProviderRegistry = ResourceCardProviderRegistry_1 = class ResourceCardProviderRegistry extends BaseStrategyRegistry {
|
|
751
|
+
onModuleInit() {
|
|
752
|
+
this.subscription = this.bus.events$.pipe(filter((event)=>!event.strategyType || event.strategyType === RESOURCE_CARD_PROVIDER)).subscribe((event)=>{
|
|
753
|
+
try {
|
|
754
|
+
if (event.type === 'UPSERT') this.upsert(event.entry.instance);
|
|
755
|
+
else this.remove(event.orgId, event.pluginName);
|
|
756
|
+
} catch (e) {
|
|
757
|
+
// Reject the conflicting provider without terminating the lifecycle subscription.
|
|
758
|
+
this.resourceLogger.warn('Rejected invalid or conflicting resource card provider registration');
|
|
759
|
+
}
|
|
760
|
+
});
|
|
761
|
+
for (const { instance } of this.discoveryService.getProviders())if (instance) this.upsert(instance);
|
|
762
|
+
}
|
|
763
|
+
onModuleDestroy() {
|
|
764
|
+
var _this_subscription;
|
|
765
|
+
(_this_subscription = this.subscription) == null ? void 0 : _this_subscription.unsubscribe();
|
|
766
|
+
}
|
|
767
|
+
remove(scopeKey, pluginName) {
|
|
768
|
+
for (const entry of this.listAllRegistrations()){
|
|
769
|
+
if (entry.source.kind === 'plugin' && entry.source.pluginName === pluginName && entry.source.scopeKey === scopeKey) {
|
|
770
|
+
this.unregister(entry.type, entry.source, entry.strategy);
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
upsert(instance) {
|
|
775
|
+
const target = resolveStrategyMetadataTarget(instance);
|
|
776
|
+
const resources = target && this.reflector.get(RESOURCE_CARD_PROVIDER, target);
|
|
777
|
+
if (!resources) return;
|
|
778
|
+
if (!isProvider(instance)) throw new Error('ResourceCardProvider must implement resolveMany');
|
|
779
|
+
const source = this.getSource(instance);
|
|
780
|
+
const keys = resources.map(resourceTypeKey);
|
|
781
|
+
// A route belongs to one plugin across scopes; a different plugin cannot shadow it.
|
|
782
|
+
// Preflight the whole batch so a conflicting multi-type provider is never partly installed.
|
|
783
|
+
for (const key of keys){
|
|
784
|
+
for (const existing of this.listAllRegistrations().filter((entry)=>entry.type === key)){
|
|
785
|
+
const samePlugin = source.kind === 'plugin' && existing.source.kind === 'plugin' && source.pluginName === existing.source.pluginName;
|
|
786
|
+
if (existing.strategy !== instance && !samePlugin) {
|
|
787
|
+
throw new Error(`Resource card type ${key} is already registered`);
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
this.assertCanRegister(key, instance, source);
|
|
791
|
+
}
|
|
792
|
+
for (const key of keys)this.register(key, instance, source);
|
|
793
|
+
}
|
|
794
|
+
find(resource, organizationId) {
|
|
795
|
+
const key = resourceTypeKey(resource);
|
|
796
|
+
for (const scopeKey of this.resolveStrategyScopeKeys(organizationId)){
|
|
797
|
+
var _this_strategies_get;
|
|
798
|
+
const provider = (_this_strategies_get = this.strategies.get(scopeKey)) == null ? void 0 : _this_strategies_get.get(key);
|
|
799
|
+
if (provider) return provider;
|
|
800
|
+
}
|
|
801
|
+
return undefined;
|
|
802
|
+
}
|
|
803
|
+
constructor(discovery, reflector){
|
|
804
|
+
super(RESOURCE_CARD_PROVIDER, discovery, reflector);
|
|
805
|
+
this.resourceLogger = new Logger(ResourceCardProviderRegistry_1.name);
|
|
806
|
+
}
|
|
807
|
+
};
|
|
808
|
+
ResourceCardProviderRegistry = ResourceCardProviderRegistry_1 = __decorate([
|
|
809
|
+
Injectable(),
|
|
810
|
+
__metadata("design:paramtypes", [
|
|
811
|
+
DiscoveryService,
|
|
812
|
+
Reflector
|
|
813
|
+
])
|
|
814
|
+
], ResourceCardProviderRegistry);
|
|
815
|
+
|
|
816
|
+
function createPluginLogger(scope, baseMeta = {}) {
|
|
817
|
+
const nestLogger = new Logger(scope);
|
|
818
|
+
const wrap = (level, msg, meta)=>{
|
|
819
|
+
var // Maintain alignment with the Nest Logger interface
|
|
820
|
+
_nestLogger_level;
|
|
821
|
+
const payload = meta ? _extends({}, baseMeta, meta) : baseMeta;
|
|
822
|
+
(_nestLogger_level = nestLogger[level]) == null ? void 0 : _nestLogger_level.call(nestLogger, msg + (Object.keys(payload).length ? ` ${JSON.stringify(payload)}` : ''));
|
|
823
|
+
};
|
|
824
|
+
return {
|
|
825
|
+
child (meta) {
|
|
826
|
+
return createPluginLogger(scope, _extends({}, baseMeta, meta));
|
|
827
|
+
},
|
|
828
|
+
debug: (msg, meta)=>wrap('debug', msg, meta),
|
|
829
|
+
log: (msg, meta)=>wrap('log', msg, meta),
|
|
830
|
+
warn: (msg, meta)=>wrap('warn', msg, meta),
|
|
831
|
+
error: (msg, meta)=>wrap('error', msg, meta)
|
|
832
|
+
};
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
const INTEGRATION_STRATEGY = 'INTEGRATION_STRATEGY';
|
|
836
|
+
const IntegrationStrategyKey = (provider)=>applyDecorators(SetMetadata(INTEGRATION_STRATEGY, provider), SetMetadata(STRATEGY_META_KEY, INTEGRATION_STRATEGY));
|
|
837
|
+
|
|
749
838
|
let IntegrationStrategyRegistry = class IntegrationStrategyRegistry extends BaseStrategyRegistry {
|
|
750
839
|
constructor(discoveryService, reflector){
|
|
751
840
|
super(INTEGRATION_STRATEGY, discoveryService, reflector);
|
|
@@ -1016,6 +1105,28 @@ KeywordAnalyzerRegistry = __decorate([
|
|
|
1016
1105
|
])
|
|
1017
1106
|
], KeywordAnalyzerRegistry);
|
|
1018
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
|
+
const KnowledgeGraphRuntimeCapability = createRuntimeCapability('platform.knowledge-graph', {
|
|
1116
|
+
description: 'Publish, inspect, and retract source-owned structured knowledge graphs without model extraction.'
|
|
1117
|
+
});
|
|
1118
|
+
|
|
1119
|
+
const KnowledgebaseDocumentsRuntimeCapability = createRuntimeCapability('platform.knowledgebase.documents', {
|
|
1120
|
+
description: 'Upload, import, create, process, reprocess, inspect, and delete persistent knowledgebase documents.'
|
|
1121
|
+
});
|
|
1122
|
+
|
|
1123
|
+
const KnowledgeDocumentVisualAssetsRuntimeCapability = createRuntimeCapability('platform.knowledgebase.visual-assets', {
|
|
1124
|
+
description: 'Issue execution-scoped logical KnowledgeDocument image paths and inject validated images without exposing host storage paths.'
|
|
1125
|
+
});
|
|
1126
|
+
const KnowledgeDocumentVisualAssetsRuntimeFactoryCapability = createRuntimeCapability('platform.knowledge-document.visual-assets.factory', {
|
|
1127
|
+
description: 'Create a visual-assets API with an execution-local image allow-list and authorized workspace writer.'
|
|
1128
|
+
});
|
|
1129
|
+
|
|
1019
1130
|
const TOOLSET_STRATEGY = 'TOOLSET_STRATEGY';
|
|
1020
1131
|
/**
|
|
1021
1132
|
* Decorator to mark a provider as a Toolset Strategy
|
|
@@ -2598,6 +2709,9 @@ function normalizeCurrency(currency) {
|
|
|
2598
2709
|
|
|
2599
2710
|
var AIModel_1;
|
|
2600
2711
|
let AIModel = AIModel_1 = class AIModel {
|
|
2712
|
+
getRealtimeModel(_copilotModel) {
|
|
2713
|
+
throw new Error('Unsupported realtime model');
|
|
2714
|
+
}
|
|
2601
2715
|
getChatModel(copilotModel, options) {
|
|
2602
2716
|
throw new Error(`Unsupport chat model!`);
|
|
2603
2717
|
}
|
|
@@ -2841,6 +2955,75 @@ function _class_private_field_loose_key(name) {
|
|
|
2841
2955
|
return "__private_" + id++ + "_" + name;
|
|
2842
2956
|
}
|
|
2843
2957
|
|
|
2958
|
+
function resolveTokenUsageCandidates(input) {
|
|
2959
|
+
const candidates = [
|
|
2960
|
+
{
|
|
2961
|
+
value: input.canonical,
|
|
2962
|
+
source: 'provider'
|
|
2963
|
+
},
|
|
2964
|
+
{
|
|
2965
|
+
value: input.actual,
|
|
2966
|
+
source: 'provider'
|
|
2967
|
+
},
|
|
2968
|
+
{
|
|
2969
|
+
value: input.estimated,
|
|
2970
|
+
source: 'estimated'
|
|
2971
|
+
},
|
|
2972
|
+
{
|
|
2973
|
+
value: {
|
|
2974
|
+
totalTokens: input.legacyTotal
|
|
2975
|
+
},
|
|
2976
|
+
source: 'legacy'
|
|
2977
|
+
}
|
|
2978
|
+
];
|
|
2979
|
+
for (const candidate of candidates){
|
|
2980
|
+
const usage = normalizeTokenUsage(candidate.value);
|
|
2981
|
+
if (usage) return {
|
|
2982
|
+
usage,
|
|
2983
|
+
source: candidate.source
|
|
2984
|
+
};
|
|
2985
|
+
}
|
|
2986
|
+
return {
|
|
2987
|
+
usage: {
|
|
2988
|
+
promptTokens: 0,
|
|
2989
|
+
completionTokens: 0,
|
|
2990
|
+
totalTokens: 0
|
|
2991
|
+
},
|
|
2992
|
+
source: 'unavailable'
|
|
2993
|
+
};
|
|
2994
|
+
}
|
|
2995
|
+
function normalizeTokenUsage(candidate) {
|
|
2996
|
+
if (!candidate) return null;
|
|
2997
|
+
const counts = [
|
|
2998
|
+
candidate.promptTokens,
|
|
2999
|
+
candidate.completionTokens,
|
|
3000
|
+
candidate.totalTokens,
|
|
3001
|
+
candidate.cacheReadInputTokens,
|
|
3002
|
+
candidate.cacheWriteInputTokens,
|
|
3003
|
+
candidate.reasoningTokens
|
|
3004
|
+
];
|
|
3005
|
+
if (counts.some((count)=>count !== undefined && (!Number.isSafeInteger(count) || count < 0))) return null;
|
|
3006
|
+
var _candidate_promptTokens;
|
|
3007
|
+
const promptTokens = (_candidate_promptTokens = candidate.promptTokens) != null ? _candidate_promptTokens : 0;
|
|
3008
|
+
var _candidate_completionTokens;
|
|
3009
|
+
const completionTokens = (_candidate_completionTokens = candidate.completionTokens) != null ? _candidate_completionTokens : 0;
|
|
3010
|
+
const totalTokens = candidate.totalTokens || promptTokens + completionTokens;
|
|
3011
|
+
if (!Number.isSafeInteger(totalTokens) || totalTokens <= 0 || totalTokens < promptTokens + completionTokens) return null;
|
|
3012
|
+
var _candidate_cacheReadInputTokens, _candidate_cacheWriteInputTokens, _candidate_reasoningTokens;
|
|
3013
|
+
if (((_candidate_cacheReadInputTokens = candidate.cacheReadInputTokens) != null ? _candidate_cacheReadInputTokens : 0) + ((_candidate_cacheWriteInputTokens = candidate.cacheWriteInputTokens) != null ? _candidate_cacheWriteInputTokens : 0) > promptTokens || ((_candidate_reasoningTokens = candidate.reasoningTokens) != null ? _candidate_reasoningTokens : 0) > completionTokens) return null;
|
|
3014
|
+
return _extends({
|
|
3015
|
+
promptTokens,
|
|
3016
|
+
completionTokens,
|
|
3017
|
+
totalTokens
|
|
3018
|
+
}, candidate.cacheReadInputTokens ? {
|
|
3019
|
+
cacheReadInputTokens: candidate.cacheReadInputTokens
|
|
3020
|
+
} : {}, candidate.cacheWriteInputTokens ? {
|
|
3021
|
+
cacheWriteInputTokens: candidate.cacheWriteInputTokens
|
|
3022
|
+
} : {}, candidate.reasoningTokens ? {
|
|
3023
|
+
reasoningTokens: candidate.reasoningTokens
|
|
3024
|
+
} : {});
|
|
3025
|
+
}
|
|
3026
|
+
|
|
2844
3027
|
var _a;
|
|
2845
3028
|
class LLMUsage {
|
|
2846
3029
|
static emptyUsage() {
|
|
@@ -2886,6 +3069,18 @@ class LargeLanguageModel extends AIModel {
|
|
|
2886
3069
|
_commonParameterRules(model) {
|
|
2887
3070
|
return CommonParameterRules;
|
|
2888
3071
|
}
|
|
3072
|
+
/** Price already normalized provider facts without starting another inference or writing a ledger. */ priceActualTokenUsage(model, tokenUsage, context = {}) {
|
|
3073
|
+
var _this_getModelSchema;
|
|
3074
|
+
const usage = normalizeTokenUsage(tokenUsage);
|
|
3075
|
+
if (!usage) throw new Error('Actual token usage is required');
|
|
3076
|
+
const priced = this.calcResponseUsage(model, {}, usage.promptTokens, usage.completionTokens, performance.now(), usage, _extends({}, context, {
|
|
3077
|
+
inputTokensIncludeCache: true
|
|
3078
|
+
}));
|
|
3079
|
+
return _extends({}, priced, usage, !((_this_getModelSchema = this.getModelSchema(model, {})) == null ? void 0 : _this_getModelSchema.pricing) ? {
|
|
3080
|
+
pricingStatus: 'unpriced',
|
|
3081
|
+
totalPrice: undefined
|
|
3082
|
+
} : {});
|
|
3083
|
+
}
|
|
2889
3084
|
calcResponseUsage(model, credentials, promptTokens, completionTokens, startedAt = this.startedAt, tokenUsage, pricingContext = {}) {
|
|
2890
3085
|
var _this_getModelSchema;
|
|
2891
3086
|
const resolvedTokenUsage = tokenUsage != null ? tokenUsage : {
|
|
@@ -3033,12 +3228,15 @@ class LargeLanguageModel extends AIModel {
|
|
|
3033
3228
|
callback
|
|
3034
3229
|
];
|
|
3035
3230
|
}
|
|
3036
|
-
createHandleLLMErrorCallbacks(
|
|
3231
|
+
createHandleLLMErrorCallbacks(_fields, logger) {
|
|
3037
3232
|
return {
|
|
3038
|
-
handleLLMError: (
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
(logger != null ? logger : _class_private_field_loose_base(this, _logger)[_logger]).error(
|
|
3233
|
+
handleLLMError: (error)=>{
|
|
3234
|
+
// Provider errors and constructor fields can contain credentials or request bodies.
|
|
3235
|
+
const errorType = error instanceof Error && /^[A-Za-z]{1,60}$/.test(error.name) ? error.name : 'Error';
|
|
3236
|
+
(logger != null ? logger : _class_private_field_loose_base(this, _logger)[_logger]).error({
|
|
3237
|
+
event: 'model_provider_request_failed',
|
|
3238
|
+
errorType
|
|
3239
|
+
});
|
|
3042
3240
|
}
|
|
3043
3241
|
};
|
|
3044
3242
|
}
|
|
@@ -3248,97 +3446,59 @@ function isAbortError(error) {
|
|
|
3248
3446
|
return error.name === 'AbortError' || /\babort(?:ed)?\b/i.test(error.message);
|
|
3249
3447
|
}
|
|
3250
3448
|
function calcTokenUsage(output) {
|
|
3251
|
-
|
|
3252
|
-
const tokenUsage = {
|
|
3449
|
+
const result = {
|
|
3253
3450
|
promptTokens: 0,
|
|
3254
3451
|
completionTokens: 0,
|
|
3255
3452
|
totalTokens: 0
|
|
3256
3453
|
};
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
if (message.
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
cacheReadInputTokens
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
}
|
|
3272
|
-
});
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3454
|
+
var _output_generations;
|
|
3455
|
+
for (const choices of (_output_generations = output.generations) != null ? _output_generations : []){
|
|
3456
|
+
// Each inner array contains choices from one request, not independent provider attempts.
|
|
3457
|
+
const usage = choices.map((choice)=>{
|
|
3458
|
+
var _metadata_input_token_details, _metadata_input_token_details1, _metadata_output_token_details;
|
|
3459
|
+
if (!('message' in choice) || !isBaseMessage(choice.message) || !isAIMessage(choice.message)) return null;
|
|
3460
|
+
const metadata = choice.message.usage_metadata;
|
|
3461
|
+
return metadata ? normalizeTokenUsage({
|
|
3462
|
+
promptTokens: metadata.input_tokens,
|
|
3463
|
+
completionTokens: metadata.output_tokens,
|
|
3464
|
+
totalTokens: metadata.total_tokens,
|
|
3465
|
+
cacheReadInputTokens: (_metadata_input_token_details = metadata.input_token_details) == null ? void 0 : _metadata_input_token_details.cache_read,
|
|
3466
|
+
cacheWriteInputTokens: (_metadata_input_token_details1 = metadata.input_token_details) == null ? void 0 : _metadata_input_token_details1.cache_creation,
|
|
3467
|
+
reasoningTokens: (_metadata_output_token_details = metadata.output_token_details) == null ? void 0 : _metadata_output_token_details.reasoning
|
|
3468
|
+
}) : null;
|
|
3469
|
+
}).find((candidate)=>candidate !== null);
|
|
3470
|
+
if (!usage) continue;
|
|
3471
|
+
result.promptTokens += usage.promptTokens;
|
|
3472
|
+
result.completionTokens += usage.completionTokens;
|
|
3473
|
+
result.totalTokens += usage.totalTokens;
|
|
3474
|
+
for (const key of [
|
|
3475
|
+
'cacheReadInputTokens',
|
|
3476
|
+
'cacheWriteInputTokens',
|
|
3477
|
+
'reasoningTokens'
|
|
3478
|
+
]){
|
|
3479
|
+
var _result_key;
|
|
3480
|
+
if (usage[key] !== undefined) result[key] = ((_result_key = result[key]) != null ? _result_key : 0) + usage[key];
|
|
3481
|
+
}
|
|
3482
|
+
}
|
|
3483
|
+
return result;
|
|
3277
3484
|
}
|
|
3278
3485
|
function resolveTokenUsage(output) {
|
|
3279
3486
|
return resolveTokenUsageWithAuthority(output).usage;
|
|
3280
3487
|
}
|
|
3281
3488
|
function resolveTokenUsageWithAuthority(output) {
|
|
3282
3489
|
var _output_llmOutput, _output_llmOutput1, _output_llmOutput2;
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3490
|
+
const resolved = resolveTokenUsageCandidates({
|
|
3491
|
+
canonical: calcTokenUsage(output),
|
|
3492
|
+
actual: (_output_llmOutput = output.llmOutput) == null ? void 0 : _output_llmOutput['tokenUsage'],
|
|
3493
|
+
estimated: (_output_llmOutput1 = output.llmOutput) == null ? void 0 : _output_llmOutput1['estimatedTokenUsage'],
|
|
3494
|
+
legacyTotal: (_output_llmOutput2 = output.llmOutput) == null ? void 0 : _output_llmOutput2['totalTokens']
|
|
3286
3495
|
});
|
|
3287
|
-
if (actualUsage) {
|
|
3288
|
-
return {
|
|
3289
|
-
usage: actualUsage
|
|
3290
|
-
};
|
|
3291
|
-
}
|
|
3292
|
-
const estimatedUsage = normalizeTokenUsage((_output_llmOutput2 = output.llmOutput) == null ? void 0 : _output_llmOutput2['estimatedTokenUsage']);
|
|
3293
|
-
if (estimatedUsage) {
|
|
3294
|
-
return {
|
|
3295
|
-
usage: estimatedUsage,
|
|
3296
|
-
type: 'estimated'
|
|
3297
|
-
};
|
|
3298
|
-
}
|
|
3299
|
-
return {
|
|
3300
|
-
usage: {
|
|
3301
|
-
promptTokens: 0,
|
|
3302
|
-
completionTokens: 0,
|
|
3303
|
-
totalTokens: 0
|
|
3304
|
-
}
|
|
3305
|
-
};
|
|
3306
|
-
}
|
|
3307
|
-
function normalizeTokenUsage(candidate) {
|
|
3308
|
-
if (!candidate) {
|
|
3309
|
-
return null;
|
|
3310
|
-
}
|
|
3311
|
-
if (!isValidTokenCount(candidate.promptTokens) || !isValidTokenCount(candidate.completionTokens) || !isValidTokenCount(candidate.totalTokens)) {
|
|
3312
|
-
return null;
|
|
3313
|
-
}
|
|
3314
|
-
var _candidate_promptTokens;
|
|
3315
|
-
const promptTokens = (_candidate_promptTokens = candidate.promptTokens) != null ? _candidate_promptTokens : 0;
|
|
3316
|
-
var _candidate_completionTokens;
|
|
3317
|
-
const completionTokens = (_candidate_completionTokens = candidate.completionTokens) != null ? _candidate_completionTokens : 0;
|
|
3318
|
-
const totalTokens = candidate.totalTokens || promptTokens + completionTokens;
|
|
3319
|
-
if (promptTokens === 0 && completionTokens === 0 && totalTokens === 0) {
|
|
3320
|
-
return null;
|
|
3321
|
-
}
|
|
3322
|
-
var _candidate_cacheReadInputTokens;
|
|
3323
|
-
const cacheReadInputTokens = (_candidate_cacheReadInputTokens = candidate.cacheReadInputTokens) != null ? _candidate_cacheReadInputTokens : 0;
|
|
3324
|
-
var _candidate_cacheWriteInputTokens;
|
|
3325
|
-
const cacheWriteInputTokens = (_candidate_cacheWriteInputTokens = candidate.cacheWriteInputTokens) != null ? _candidate_cacheWriteInputTokens : 0;
|
|
3326
|
-
if (!isValidTokenCount(cacheReadInputTokens) || !isValidTokenCount(cacheWriteInputTokens)) {
|
|
3327
|
-
return null;
|
|
3328
|
-
}
|
|
3329
3496
|
return _extends({
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
}, cacheReadInputTokens > 0 ? {
|
|
3334
|
-
cacheReadInputTokens
|
|
3335
|
-
} : {}, cacheWriteInputTokens > 0 ? {
|
|
3336
|
-
cacheWriteInputTokens
|
|
3497
|
+
usage: resolved.usage
|
|
3498
|
+
}, resolved.source === 'estimated' ? {
|
|
3499
|
+
type: 'estimated'
|
|
3337
3500
|
} : {});
|
|
3338
3501
|
}
|
|
3339
|
-
function isValidTokenCount(value) {
|
|
3340
|
-
return value === undefined || Number.isFinite(value) && value >= 0;
|
|
3341
|
-
}
|
|
3342
3502
|
function normalizeCacheTokenAccounting(tokenUsage, context) {
|
|
3343
3503
|
if (context.inputTokensIncludeCache !== false) return tokenUsage;
|
|
3344
3504
|
var _tokenUsage_cacheReadInputTokens, _tokenUsage_cacheWriteInputTokens;
|
|
@@ -3789,6 +3949,37 @@ Reflect.defineMetadata(COMMAND_METADATA$1, {
|
|
|
3789
3949
|
id: CreateModelClientCommand.type
|
|
3790
3950
|
}, CreateModelClientCommand);
|
|
3791
3951
|
|
|
3952
|
+
/** A single fetch is one billable attempt. No SDK retries or redirects to another credential origin. */ function nativeModelTransport(input) {
|
|
3953
|
+
const base = new URL(input.baseUrl);
|
|
3954
|
+
if (![
|
|
3955
|
+
'http:',
|
|
3956
|
+
'https:'
|
|
3957
|
+
].includes(base.protocol) || base.username || base.password || base.search || base.hash) throw new Error('Invalid native model endpoint');
|
|
3958
|
+
const suffix = input.protocol === 'openai_responses' ? '/responses' : '/v1/messages';
|
|
3959
|
+
const url = `${base.href.replace(/\/$/, '')}${suffix}`;
|
|
3960
|
+
return (body, forwarded, signal)=>{
|
|
3961
|
+
const headers = new Headers({
|
|
3962
|
+
'content-type': 'application/json'
|
|
3963
|
+
});
|
|
3964
|
+
if (input.protocol === 'anthropic_messages') {
|
|
3965
|
+
headers.set('anthropic-version', '2023-06-01');
|
|
3966
|
+
for (const [name, value] of Object.entries(forwarded)){
|
|
3967
|
+
// Native Anthropic feature/version headers must survive protocol evolution.
|
|
3968
|
+
if (/^anthropic-[a-z0-9-]+$/.test(name)) headers.set(name, value);
|
|
3969
|
+
}
|
|
3970
|
+
headers.set('x-api-key', input.authorization);
|
|
3971
|
+
} else headers.set('authorization', input.authorization);
|
|
3972
|
+
var _input_fetch;
|
|
3973
|
+
return ((_input_fetch = input.fetch) != null ? _input_fetch : fetch)(url, {
|
|
3974
|
+
method: 'POST',
|
|
3975
|
+
headers,
|
|
3976
|
+
body: JSON.stringify(body),
|
|
3977
|
+
signal,
|
|
3978
|
+
redirect: 'error'
|
|
3979
|
+
});
|
|
3980
|
+
};
|
|
3981
|
+
}
|
|
3982
|
+
|
|
3792
3983
|
const SKILL_SOURCE_PROVIDER = 'SKILL_SOURCE_PROVIDER';
|
|
3793
3984
|
const SkillSourceProviderStrategy = (provider)=>applyDecorators(SetMetadata(SKILL_SOURCE_PROVIDER, provider), SetMetadata(STRATEGY_META_KEY, SKILL_SOURCE_PROVIDER));
|
|
3794
3985
|
|
|
@@ -3863,6 +4054,18 @@ function isModelOutputValidationError(error) {
|
|
|
3863
4054
|
return candidate.code === MODEL_OUTPUT_VALIDATION_ERROR_CODE && candidate.retryable === true && ((_candidate_repairContext = candidate.repairContext) == null ? void 0 : _candidate_repairContext.kind) === 'invalid_tool_calls' && Array.isArray(candidate.repairContext.issues);
|
|
3864
4055
|
}
|
|
3865
4056
|
|
|
4057
|
+
/** Combine middleware contributions without mutating or weakening existing requirements. */ function mergeModelRequirements(...requirements) {
|
|
4058
|
+
const features = [
|
|
4059
|
+
...new Set(requirements.flatMap((item)=>{
|
|
4060
|
+
var _item_features;
|
|
4061
|
+
return (_item_features = item == null ? void 0 : item.features) != null ? _item_features : [];
|
|
4062
|
+
}))
|
|
4063
|
+
];
|
|
4064
|
+
return features.length ? {
|
|
4065
|
+
features
|
|
4066
|
+
} : undefined;
|
|
4067
|
+
}
|
|
4068
|
+
|
|
3866
4069
|
const SEGMENT_PATTERN = /^[a-z][a-z0-9_-]*$/i;
|
|
3867
4070
|
const VERSION_PATTERN = /^v[1-9][0-9]*$/;
|
|
3868
4071
|
function assertSegment(input, name) {
|
|
@@ -3908,6 +4111,96 @@ function assertSegment(input, name) {
|
|
|
3908
4111
|
const AGENT_CHAT_DISPATCH_MESSAGE_TYPE = defineAgentMessageType('chat_dispatch', 1);
|
|
3909
4112
|
const AGENT_CHAT_DISPATCH_ERROR_STEER_TARGET_NOT_RUNNING = 'steer_target_not_running';
|
|
3910
4113
|
|
|
4114
|
+
/** Captured by an authorized host command. Describing a recipient never authorizes delivery. */ const replyConversation = {
|
|
4115
|
+
conversationId: z.string().uuid(),
|
|
4116
|
+
threadId: z.string().trim().min(1).max(256)
|
|
4117
|
+
};
|
|
4118
|
+
const agentRuntimeReplyTargetSchema = z.discriminatedUnion('type', [
|
|
4119
|
+
z.object(_extends({}, replyConversation, {
|
|
4120
|
+
type: z.literal('xpert').optional(),
|
|
4121
|
+
xpertId: z.string().uuid(),
|
|
4122
|
+
agentKey: z.string().trim().min(1).max(256)
|
|
4123
|
+
})).strict(),
|
|
4124
|
+
z.object(_extends({}, replyConversation, {
|
|
4125
|
+
type: z.literal('project_agent'),
|
|
4126
|
+
projectId: z.string().uuid(),
|
|
4127
|
+
agentKey: z.literal('general_agent')
|
|
4128
|
+
})).strict()
|
|
4129
|
+
]);
|
|
4130
|
+
/** Persist with the immutable invocation request before launch. No credentials or arbitrary routing headers. */ const agentInvocationDispatchContextSchema = z.object({
|
|
4131
|
+
version: z.literal(1),
|
|
4132
|
+
requestId: z.string().uuid(),
|
|
4133
|
+
sourceMessageId: z.string().trim().min(1).max(256),
|
|
4134
|
+
replyTo: agentRuntimeReplyTargetSchema,
|
|
4135
|
+
projectTask: projectTaskExecutionContextSchema.optional()
|
|
4136
|
+
}).strict();
|
|
4137
|
+
|
|
4138
|
+
const AGENT_RUNTIME_EVENT_MESSAGE_TYPE = defineAgentMessageType('runtime_event', 1);
|
|
4139
|
+
const reference = {
|
|
4140
|
+
version: z.literal(1),
|
|
4141
|
+
invocationId: z.string().uuid(),
|
|
4142
|
+
/** Revision of the persisted observation, never a queue delivery attempt. */ revision: z.number().int().nonnegative(),
|
|
4143
|
+
projectTask: projectTaskExecutionReferenceSchema.optional()
|
|
4144
|
+
};
|
|
4145
|
+
/** Host-produced references. Consumers reload and authorize the invocation and its pinned observation. */ const agentRuntimeEventSchema = z.discriminatedUnion('kind', [
|
|
4146
|
+
z.object(_extends({}, reference, {
|
|
4147
|
+
kind: z.literal('progress'),
|
|
4148
|
+
progress: agentRuntimeProgressSchema
|
|
4149
|
+
})).strict(),
|
|
4150
|
+
z.object(_extends({}, reference, {
|
|
4151
|
+
kind: z.literal('result'),
|
|
4152
|
+
status: agentInvocationTerminalStatusSchema
|
|
4153
|
+
})).strict(),
|
|
4154
|
+
z.object(_extends({}, reference, {
|
|
4155
|
+
kind: z.literal('input_request'),
|
|
4156
|
+
interactionId: z.string().trim().min(1).max(256)
|
|
4157
|
+
})).strict()
|
|
4158
|
+
]);
|
|
4159
|
+
/** Same observation always has the same HandoffMessage.id across retries and process restarts. */ function agentRuntimeEventMessageId(event) {
|
|
4160
|
+
return `runtime-${event.invocationId}-${event.kind}-${event.revision}`;
|
|
4161
|
+
}
|
|
4162
|
+
/** Transport states are deliberately separate from Task and Invocation status. */ const agentRuntimeDeliveryStateSchema = z.enum([
|
|
4163
|
+
'pending',
|
|
4164
|
+
'received',
|
|
4165
|
+
'blocked',
|
|
4166
|
+
'failed'
|
|
4167
|
+
]);
|
|
4168
|
+
const agentRuntimeConsumptionStateSchema = z.enum([
|
|
4169
|
+
'pending',
|
|
4170
|
+
'processing',
|
|
4171
|
+
'processed',
|
|
4172
|
+
'blocked',
|
|
4173
|
+
'failed'
|
|
4174
|
+
]);
|
|
4175
|
+
/** Store under a unique scoped key in the same transaction as the continuation reservation. */ const agentRuntimeResultClaimSchema = z.object({
|
|
4176
|
+
invocationId: z.string().uuid(),
|
|
4177
|
+
resultRevision: z.number().int().nonnegative(),
|
|
4178
|
+
recipient: agentRuntimeReplyTargetSchema,
|
|
4179
|
+
consumer: z.discriminatedUnion('type', [
|
|
4180
|
+
z.object({
|
|
4181
|
+
type: z.literal('follow_up'),
|
|
4182
|
+
executionId: z.string().uuid()
|
|
4183
|
+
}).strict(),
|
|
4184
|
+
z.object({
|
|
4185
|
+
type: z.literal('wait'),
|
|
4186
|
+
executionId: z.string().uuid(),
|
|
4187
|
+
callId: z.string().trim().min(1).max(1024)
|
|
4188
|
+
}).strict()
|
|
4189
|
+
])
|
|
4190
|
+
}).strict();
|
|
4191
|
+
/**
|
|
4192
|
+
* Wait and asynchronous reply compete for this same key, regardless of delivery revision.
|
|
4193
|
+
* The storage key must additionally include tenant, organization and owner from trusted scope.
|
|
4194
|
+
*/ function agentRuntimeResultConsumptionKey(invocationId, recipient) {
|
|
4195
|
+
return JSON.stringify([
|
|
4196
|
+
invocationId,
|
|
4197
|
+
recipient.conversationId,
|
|
4198
|
+
recipient.threadId,
|
|
4199
|
+
recipient.type === 'project_agent' ? `project:${recipient.projectId}` : recipient.xpertId,
|
|
4200
|
+
recipient.agentKey
|
|
4201
|
+
]);
|
|
4202
|
+
}
|
|
4203
|
+
|
|
3911
4204
|
/**
|
|
3912
4205
|
* Handoff Processor meta key。
|
|
3913
4206
|
*/ const HANDOFF_PROCESSOR_STRATEGY = 'HANDOFF_PROCESSOR_STRATEGY';
|
|
@@ -3983,6 +4276,30 @@ AgentRuntimeRegistry = __decorate([
|
|
|
3983
4276
|
});
|
|
3984
4277
|
/** Platform factory capability. The wire key is stable across SDK naming changes. */ const AgentRuntimeFactoryCapability = createRuntimeCapability('platform.agent_invocation.factory');
|
|
3985
4278
|
|
|
4279
|
+
/**
|
|
4280
|
+
* Keeps shared OS model authorization independent of Pro Computer/Docker lifecycle details.
|
|
4281
|
+
* Grant issuance, authentication, revalidation and renewal delegate environment checks to this host adapter.
|
|
4282
|
+
* Implementations validate ownership and instance identity so a replaced runtime cannot keep its old grant.
|
|
4283
|
+
* Execution validity is independent of desktop viewing sessions; managed runners may also require an operation lease.
|
|
4284
|
+
* Other environments can supply their own checks without changing the grant service.
|
|
4285
|
+
* This capability validates the bound environment; model selection and usage accounting remain separate concerns.
|
|
4286
|
+
*/ const ModelExecutionEnvironmentCapability = createRuntimeCapability('platform.model_execution.environment');
|
|
4287
|
+
|
|
4288
|
+
/** Configuration adapters describe secrets by reference; only the host materializes credentials. */ const CLI_MODEL_TOKEN_REFERENCE = '${XPERT_EXECUTION_TOKEN}';
|
|
4289
|
+
const CliModelProfilesCapability = createRuntimeCapability('platform.cli_model_profiles');
|
|
4290
|
+
/** Additional execution sources can validate lifecycle without making OS depend on Pro entities. */ const ShellModelExecutionSourceCapability = createRuntimeCapability('platform.model_execution.shell_source');
|
|
4291
|
+
|
|
4292
|
+
function taskWaitReason(states, mode) {
|
|
4293
|
+
if (states.length && (mode === 'all' ? states.every((state)=>state === 'completed') : states.includes('completed'))) return 'completed';
|
|
4294
|
+
if (states.includes('attention')) return 'attention';
|
|
4295
|
+
return undefined;
|
|
4296
|
+
}
|
|
4297
|
+
|
|
4298
|
+
const AgentExecutionRunnerCapability = createRuntimeCapability('platform.agent_execution.runner');
|
|
4299
|
+
const AgentExecutionRunnerFactoryCapability = createRuntimeCapability('platform.agent_execution.runner.factory');
|
|
4300
|
+
|
|
4301
|
+
/** Older runtime plugins can still send this event; new emissions use ON_CHAT_EVENT. */ const RESOURCE_CARD_EVENT = 'xpert.resource_card';
|
|
4302
|
+
|
|
3986
4303
|
const ASSISTANT_CAPABILITY_PROVIDER = 'ASSISTANT_CAPABILITY_PROVIDER';
|
|
3987
4304
|
const AssistantCapabilityProvider = (key)=>applyDecorators(SetMetadata(ASSISTANT_CAPABILITY_PROVIDER, key), SetMetadata(STRATEGY_META_KEY, ASSISTANT_CAPABILITY_PROVIDER));
|
|
3988
4305
|
let AssistantCapabilityProviderRegistry = class AssistantCapabilityProviderRegistry extends BaseStrategyRegistry {
|
|
@@ -4295,7 +4612,9 @@ function resolveSandboxExecutionOptions(options, defaults = DEFAULT_SANDBOX_SHEL
|
|
|
4295
4612
|
return _extends({
|
|
4296
4613
|
timeoutMs,
|
|
4297
4614
|
maxOutputBytes
|
|
4298
|
-
}, (options == null ? void 0 : options.
|
|
4615
|
+
}, (options == null ? void 0 : options.executionScope) ? {
|
|
4616
|
+
executionScope: options.executionScope
|
|
4617
|
+
} : {}, (options == null ? void 0 : options.signal) ? {
|
|
4299
4618
|
signal: options.signal
|
|
4300
4619
|
} : {});
|
|
4301
4620
|
}
|
|
@@ -5436,6 +5755,7 @@ ViewExtensionProviderRegistry = __decorate([
|
|
|
5436
5755
|
|
|
5437
5756
|
const XPERT_REMOTE_UI_CSS = `
|
|
5438
5757
|
:root {
|
|
5758
|
+
font-size: var(--xui-density-root-font-size, 16px);
|
|
5439
5759
|
color-scheme: light;
|
|
5440
5760
|
--xui-font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
5441
5761
|
--xui-color-background: #fff;
|
|
@@ -5470,6 +5790,7 @@ const XPERT_REMOTE_UI_CSS = `
|
|
|
5470
5790
|
--xui-radius-sm: 6px;
|
|
5471
5791
|
--xui-radius-md: 8px;
|
|
5472
5792
|
--xui-radius-lg: 10px;
|
|
5793
|
+
--xui-font-size: 14px;
|
|
5473
5794
|
--xui-font-size-xs: 0.75rem;
|
|
5474
5795
|
--xui-font-size-sm: 0.8125rem;
|
|
5475
5796
|
--xui-font-size-md: 0.875rem;
|
|
@@ -5757,6 +6078,7 @@ const XPERT_REMOTE_UI_BOOTSTRAP = `
|
|
|
5757
6078
|
var VERSION = 1
|
|
5758
6079
|
var TOKEN_MAP = {
|
|
5759
6080
|
fontFamily: '--xui-font-family',
|
|
6081
|
+
densityRootFontSize: '--xui-density-root-font-size',
|
|
5760
6082
|
colorBackground: '--xui-color-background',
|
|
5761
6083
|
colorForeground: '--xui-color-foreground',
|
|
5762
6084
|
colorCard: '--xui-color-card',
|
|
@@ -5789,6 +6111,7 @@ const XPERT_REMOTE_UI_BOOTSTRAP = `
|
|
|
5789
6111
|
radiusSm: '--xui-radius-sm',
|
|
5790
6112
|
radiusMd: '--xui-radius-md',
|
|
5791
6113
|
radiusLg: '--xui-radius-lg',
|
|
6114
|
+
fontSize: '--xui-font-size',
|
|
5792
6115
|
fontSizeXs: '--xui-font-size-xs',
|
|
5793
6116
|
fontSizeSm: '--xui-font-size-sm',
|
|
5794
6117
|
fontSizeMd: '--xui-font-size-md',
|
|
@@ -9802,4 +10125,11 @@ const ProjectTasksRuntimeCapability = createRuntimeCapability('platform.project.
|
|
|
9802
10125
|
description: 'Read project task graphs, manage schedules, and resolve exact execution conversations.'
|
|
9803
10126
|
});
|
|
9804
10127
|
|
|
9805
|
-
|
|
10128
|
+
/** Import official resource packages for the authenticated organization administrator. Does not authorize workspaces. */ class ImportDefaultAgentPluginsCommand extends Command {
|
|
10129
|
+
}
|
|
10130
|
+
ImportDefaultAgentPluginsCommand.type = '[Agent Plugins] Import defaults';
|
|
10131
|
+
Reflect.defineMetadata('__command__', {
|
|
10132
|
+
id: ImportDefaultAgentPluginsCommand.type
|
|
10133
|
+
}, ImportDefaultAgentPluginsCommand);
|
|
10134
|
+
|
|
10135
|
+
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, 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 };
|