@xpert-ai/plugin-sdk 3.15.17 → 3.16.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 CHANGED
@@ -1,5 +1,24 @@
1
1
  # @xpert-ai/plugin-sdk
2
2
 
3
+ ## 3.16.0
4
+
5
+ ### Minor Changes
6
+
7
+ - b800da5: v3.16
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [b800da5]
12
+ - @xpert-ai/contracts@3.16.0
13
+
14
+ ## 3.15.18
15
+
16
+ ### Patch Changes
17
+
18
+ - 2f6bf18: Support localized plugin display names and descriptions across plugin metadata, the platform registry, and marketplace dialogs.
19
+ - Updated dependencies [2f6bf18]
20
+ - @xpert-ai/contracts@3.15.18
21
+
3
22
  ## 3.15.17
4
23
 
5
24
  ### Patch Changes
package/index.cjs.js CHANGED
@@ -554,9 +554,9 @@ class BaseStrategyRegistry {
554
554
  }
555
555
  const type = this.reflector.get(this.strategyKey, target);
556
556
  if (type) {
557
- const pluginName = this.reflector.get(PLUGIN_METADATA_KEY, target);
558
- var _this_reflector_get;
559
- const organizationId = (_this_reflector_get = this.reflector.get(ORGANIZATION_METADATA_KEY, target)) != null ? _this_reflector_get : pluginName ? GLOBAL_ORGANIZATION_SCOPE : BUILTIN_GLOBAL_SCOPE;
557
+ const source = this.getSource(instance);
558
+ const pluginName = source.kind === 'plugin' ? source.pluginName : undefined;
559
+ const organizationId = source.scopeKey;
560
560
  var _this_strategies_get;
561
561
  const orgMap = (_this_strategies_get = this.strategies.get(organizationId)) != null ? _this_strategies_get : new Map();
562
562
  orgMap.set(type, instance);
@@ -570,6 +570,29 @@ class BaseStrategyRegistry {
570
570
  }
571
571
  }
572
572
  }
573
+ /** Returns the explicit registry provenance attached by the plugin loader. */ getSource(instance) {
574
+ const target = resolveStrategyMetadataTarget(instance);
575
+ if (!target) {
576
+ return {
577
+ kind: 'builtin',
578
+ scopeKey: BUILTIN_GLOBAL_SCOPE
579
+ };
580
+ }
581
+ const pluginName = this.reflector.get(PLUGIN_METADATA_KEY, target);
582
+ if (!pluginName) {
583
+ var _this_reflector_get;
584
+ return {
585
+ kind: 'builtin',
586
+ scopeKey: (_this_reflector_get = this.reflector.get(ORGANIZATION_METADATA_KEY, target)) != null ? _this_reflector_get : BUILTIN_GLOBAL_SCOPE
587
+ };
588
+ }
589
+ var _this_reflector_get1;
590
+ return {
591
+ kind: 'plugin',
592
+ pluginName,
593
+ scopeKey: (_this_reflector_get1 = this.reflector.get(ORGANIZATION_METADATA_KEY, target)) != null ? _this_reflector_get1 : GLOBAL_ORGANIZATION_SCOPE
594
+ };
595
+ }
573
596
  /**
574
597
  * Remove all strategies registered by the given plugin for the given scope.
575
598
  */ remove(organizationId, pluginName) {
@@ -1180,10 +1203,6 @@ const PLUGIN_CONFIG_RESOLVER_TOKEN = 'XPERT_PLUGIN_CONFIG_RESOLVER';
1180
1203
  * System token for resolving integration read service from plugin context.
1181
1204
  */ const INTEGRATION_PERMISSION_SERVICE_TOKEN = 'XPERT_PLUGIN_INTEGRATION_PERMISSION_SERVICE';
1182
1205
 
1183
- /**
1184
- * System token for resolving analytics permission service from plugin context.
1185
- */ const ANALYTICS_PERMISSION_SERVICE_TOKEN = 'XPERT_PLUGIN_ANALYTICS_PERMISSION_SERVICE';
1186
-
1187
1206
  const PERMISSION_OPERATION_METADATA_KEY = 'XPERT_PLUGIN_PERMISSION_OPERATION';
1188
1207
  function RequirePermissionOperation(permissionType, operation) {
1189
1208
  return (_target, _propertyKey, descriptor)=>{
@@ -1241,6 +1260,14 @@ function getRequiredPermissionOperation(method, permissionType) {
1241
1260
  * Internal system token used by core to expose the speech-to-text bridge.
1242
1261
  */ const SPEECH_TO_TEXT_SERVICE_TOKEN = 'XPERT_SPEECH_TO_TEXT_SERVICE';
1243
1262
 
1263
+ const VIDEO_GENERATOR_FAMILIES = [
1264
+ 'seedance',
1265
+ 'veo',
1266
+ 'kling'
1267
+ ];
1268
+ const VIDEO_GENERATION_PERMISSION_SERVICE_TOKEN = 'XPERT_PLUGIN_VIDEO_GENERATION_PERMISSION_SERVICE';
1269
+ const VIDEO_GENERATION_SERVICE_TOKEN = 'XPERT_VIDEO_GENERATION_SERVICE';
1270
+
1244
1271
  async function createI18nInstance(pluginDir, language) {
1245
1272
  const instance = i18next.createInstance();
1246
1273
  const i18nDir = path.join(pluginDir, 'i18n');
@@ -2418,17 +2445,15 @@ class LargeLanguageModel extends AIModel {
2418
2445
  this.startedAt = performance.now();
2419
2446
  },
2420
2447
  handleLLMEnd: (output)=>{
2421
- var _output_llmOutput, _output_llmOutput1;
2422
- var _output_llmOutput_tokenUsage, _ref;
2423
- const tokenUsage = (_ref = (_output_llmOutput_tokenUsage = (_output_llmOutput = output.llmOutput) == null ? void 0 : _output_llmOutput.tokenUsage) != null ? _output_llmOutput_tokenUsage : (_output_llmOutput1 = output.llmOutput) == null ? void 0 : _output_llmOutput1.estimatedTokenUsage) != null ? _ref : calcTokenUsage(output);
2448
+ const tokenUsage = resolveTokenUsage(output);
2424
2449
  if (handleLLMTokens) {
2425
- var _output_llmOutput2;
2426
- var _output_llmOutput_totalTokens;
2450
+ const usage = this.calcResponseUsage(model, credentials, tokenUsage.promptTokens, tokenUsage.completionTokens);
2451
+ usage.totalTokens = tokenUsage.totalTokens;
2427
2452
  handleLLMTokens({
2428
2453
  copilot,
2429
2454
  model,
2430
- usage: this.calcResponseUsage(model, credentials, tokenUsage.promptTokens, tokenUsage.completionTokens),
2431
- tokenUsed: (_output_llmOutput_totalTokens = (_output_llmOutput2 = output.llmOutput) == null ? void 0 : _output_llmOutput2.totalTokens) != null ? _output_llmOutput_totalTokens : sumTokenUsage(output)
2455
+ usage,
2456
+ tokenUsed: tokenUsage.totalTokens
2432
2457
  });
2433
2458
  }
2434
2459
  }
@@ -2588,6 +2613,41 @@ function calcTokenUsage(output) {
2588
2613
  });
2589
2614
  return tokenUsage;
2590
2615
  }
2616
+ function resolveTokenUsage(output) {
2617
+ var _output_llmOutput, _output_llmOutput1, _output_llmOutput2;
2618
+ var _normalizeTokenUsage, _ref, _ref1, _ref2;
2619
+ return (_ref2 = (_ref1 = (_ref = (_normalizeTokenUsage = normalizeTokenUsage(calcTokenUsage(output))) != null ? _normalizeTokenUsage : normalizeTokenUsage((_output_llmOutput = output.llmOutput) == null ? void 0 : _output_llmOutput['tokenUsage'])) != null ? _ref : normalizeTokenUsage((_output_llmOutput1 = output.llmOutput) == null ? void 0 : _output_llmOutput1['estimatedTokenUsage'])) != null ? _ref1 : normalizeTokenUsage({
2620
+ totalTokens: (_output_llmOutput2 = output.llmOutput) == null ? void 0 : _output_llmOutput2['totalTokens']
2621
+ })) != null ? _ref2 : {
2622
+ promptTokens: 0,
2623
+ completionTokens: 0,
2624
+ totalTokens: 0
2625
+ };
2626
+ }
2627
+ function normalizeTokenUsage(candidate) {
2628
+ if (!candidate) {
2629
+ return null;
2630
+ }
2631
+ if (!isValidTokenCount(candidate.promptTokens) || !isValidTokenCount(candidate.completionTokens) || !isValidTokenCount(candidate.totalTokens)) {
2632
+ return null;
2633
+ }
2634
+ var _candidate_promptTokens;
2635
+ const promptTokens = (_candidate_promptTokens = candidate.promptTokens) != null ? _candidate_promptTokens : 0;
2636
+ var _candidate_completionTokens;
2637
+ const completionTokens = (_candidate_completionTokens = candidate.completionTokens) != null ? _candidate_completionTokens : 0;
2638
+ const totalTokens = candidate.totalTokens || promptTokens + completionTokens;
2639
+ if (promptTokens === 0 && completionTokens === 0 && totalTokens === 0) {
2640
+ return null;
2641
+ }
2642
+ return {
2643
+ promptTokens,
2644
+ completionTokens,
2645
+ totalTokens
2646
+ };
2647
+ }
2648
+ function isValidTokenCount(value) {
2649
+ return value === undefined || Number.isFinite(value) && value >= 0;
2650
+ }
2591
2651
  /**
2592
2652
  * @deprecated use calcTokenUsage
2593
2653
  */ function sumTokenUsage(output) {
@@ -2828,6 +2888,10 @@ const KnowledgebaseDocumentsRuntimeCapability = createRuntimeCapability('platfor
2828
2888
  description: 'Upload, import, create, process, inspect, and delete persistent knowledgebase documents.'
2829
2889
  });
2830
2890
 
2891
+ const ActorTokenRuntimeCapability = createRuntimeCapability('platform.actor-token', {
2892
+ description: 'Mint a short-lived host-issued actor bearer token for outbound API calls.'
2893
+ });
2894
+
2831
2895
  const ArtifactsRuntimeCapability = createRuntimeCapability('platform.artifacts', {
2832
2896
  description: 'Create, version, preview, download, share, archive, and delete platform-managed plugin and Agent artifacts.'
2833
2897
  });
@@ -4452,16 +4516,31 @@ const XPERT_REMOTE_UI_CSS = `
4452
4516
  --xui-color-foreground: #18181b;
4453
4517
  --xui-color-card: #fff;
4454
4518
  --xui-color-card-foreground: #18181b;
4519
+ --xui-color-popover: var(--xui-color-card);
4520
+ --xui-color-popover-foreground: var(--xui-color-card-foreground);
4521
+ --xui-color-secondary: #f4f4f5;
4522
+ --xui-color-secondary-foreground: #18181b;
4455
4523
  --xui-color-muted: #f4f4f5;
4456
4524
  --xui-color-muted-foreground: #71717a;
4525
+ --xui-color-accent: #f4f4f5;
4526
+ --xui-color-accent-foreground: #18181b;
4457
4527
  --xui-color-border: #e4e4e7;
4458
4528
  --xui-color-input: #d4d4d8;
4459
4529
  --xui-color-primary: #18181b;
4460
4530
  --xui-color-primary-foreground: #fff;
4531
+ --xui-color-ring: var(--xui-color-primary);
4461
4532
  --xui-color-destructive: #dc2626;
4533
+ --xui-color-destructive-foreground: #fff;
4462
4534
  --xui-color-destructive-background: #fef2f2;
4463
4535
  --xui-color-success: #047857;
4464
4536
  --xui-color-success-background: #ecfdf5;
4537
+ --xui-color-warning: #b45309;
4538
+ --xui-color-info: #2563eb;
4539
+ --xui-color-chart-1: var(--xui-color-primary);
4540
+ --xui-color-chart-2: var(--xui-color-success);
4541
+ --xui-color-chart-3: var(--xui-color-warning);
4542
+ --xui-color-chart-4: var(--xui-color-destructive);
4543
+ --xui-color-chart-5: #7c3aed;
4465
4544
  --xui-radius-sm: 6px;
4466
4545
  --xui-radius-md: 8px;
4467
4546
  --xui-radius-lg: 10px;
@@ -4756,16 +4835,31 @@ const XPERT_REMOTE_UI_BOOTSTRAP = `
4756
4835
  colorForeground: '--xui-color-foreground',
4757
4836
  colorCard: '--xui-color-card',
4758
4837
  colorCardForeground: '--xui-color-card-foreground',
4838
+ colorPopover: '--xui-color-popover',
4839
+ colorPopoverForeground: '--xui-color-popover-foreground',
4840
+ colorSecondary: '--xui-color-secondary',
4841
+ colorSecondaryForeground: '--xui-color-secondary-foreground',
4759
4842
  colorMuted: '--xui-color-muted',
4760
4843
  colorMutedForeground: '--xui-color-muted-foreground',
4844
+ colorAccent: '--xui-color-accent',
4845
+ colorAccentForeground: '--xui-color-accent-foreground',
4761
4846
  colorBorder: '--xui-color-border',
4762
4847
  colorInput: '--xui-color-input',
4763
4848
  colorPrimary: '--xui-color-primary',
4764
4849
  colorPrimaryForeground: '--xui-color-primary-foreground',
4850
+ colorRing: '--xui-color-ring',
4765
4851
  colorDestructive: '--xui-color-destructive',
4852
+ colorDestructiveForeground: '--xui-color-destructive-foreground',
4766
4853
  colorDestructiveBackground: '--xui-color-destructive-background',
4767
4854
  colorSuccess: '--xui-color-success',
4768
4855
  colorSuccessBackground: '--xui-color-success-background',
4856
+ colorWarning: '--xui-color-warning',
4857
+ colorInfo: '--xui-color-info',
4858
+ colorChart1: '--xui-color-chart-1',
4859
+ colorChart2: '--xui-color-chart-2',
4860
+ colorChart3: '--xui-color-chart-3',
4861
+ colorChart4: '--xui-color-chart-4',
4862
+ colorChart5: '--xui-color-chart-5',
4769
4863
  radiusSm: '--xui-radius-sm',
4770
4864
  radiusMd: '--xui-radius-md',
4771
4865
  radiusLg: '--xui-radius-lg',
@@ -4933,7 +5027,7 @@ exports.AGENT_MIDDLEWARE_STRATEGY = AGENT_MIDDLEWARE_STRATEGY;
4933
5027
  exports.AIModelProviderNotFoundException = AIModelProviderNotFoundException;
4934
5028
  exports.AIModelProviderStrategy = AIModelProviderStrategy;
4935
5029
  exports.AI_MODEL_PROVIDER = AI_MODEL_PROVIDER;
4936
- exports.ANALYTICS_PERMISSION_SERVICE_TOKEN = ANALYTICS_PERMISSION_SERVICE_TOKEN;
5030
+ exports.ActorTokenRuntimeCapability = ActorTokenRuntimeCapability;
4937
5031
  exports.AdapterDataSourceStrategy = AdapterDataSourceStrategy;
4938
5032
  exports.AgentMiddlewareStrategy = AgentMiddlewareStrategy;
4939
5033
  exports.AiModelNotFoundException = AiModelNotFoundException;
@@ -5063,6 +5157,9 @@ exports.TextToSpeechModel = TextToSpeechModel;
5063
5157
  exports.ToolsetStrategy = ToolsetStrategy;
5064
5158
  exports.USER_PERMISSION_SERVICE_TOKEN = USER_PERMISSION_SERVICE_TOKEN;
5065
5159
  exports.VECTOR_STORE_STRATEGY = VECTOR_STORE_STRATEGY;
5160
+ exports.VIDEO_GENERATION_PERMISSION_SERVICE_TOKEN = VIDEO_GENERATION_PERMISSION_SERVICE_TOKEN;
5161
+ exports.VIDEO_GENERATION_SERVICE_TOKEN = VIDEO_GENERATION_SERVICE_TOKEN;
5162
+ exports.VIDEO_GENERATOR_FAMILIES = VIDEO_GENERATOR_FAMILIES;
5066
5163
  exports.VIEW_EXTENSION_CACHE_SERVICE_TOKEN = VIEW_EXTENSION_CACHE_SERVICE_TOKEN;
5067
5164
  exports.VIEW_EXTENSION_PROVIDER = VIEW_EXTENSION_PROVIDER;
5068
5165
  exports.VectorStoreStrategy = VectorStoreStrategy;
@@ -5126,6 +5223,7 @@ exports.resolveSandboxServiceProxyAdapter = resolveSandboxServiceProxyAdapter;
5126
5223
  exports.resolveSandboxTerminalAdapter = resolveSandboxTerminalAdapter;
5127
5224
  exports.resolveStrategyMetadataTarget = resolveStrategyMetadataTarget;
5128
5225
  exports.resolveTenantGlobalScopeKey = resolveTenantGlobalScopeKey;
5226
+ exports.resolveTokenUsage = resolveTokenUsage;
5129
5227
  exports.runWithRequestContext = runWithRequestContext;
5130
5228
  exports.secondsToMilliseconds = secondsToMilliseconds;
5131
5229
  exports.setDefaultTenantId = setDefaultTenantId;
package/index.esm.js CHANGED
@@ -536,9 +536,9 @@ class BaseStrategyRegistry {
536
536
  }
537
537
  const type = this.reflector.get(this.strategyKey, target);
538
538
  if (type) {
539
- const pluginName = this.reflector.get(PLUGIN_METADATA_KEY, target);
540
- var _this_reflector_get;
541
- const organizationId = (_this_reflector_get = this.reflector.get(ORGANIZATION_METADATA_KEY, target)) != null ? _this_reflector_get : pluginName ? GLOBAL_ORGANIZATION_SCOPE : BUILTIN_GLOBAL_SCOPE;
539
+ const source = this.getSource(instance);
540
+ const pluginName = source.kind === 'plugin' ? source.pluginName : undefined;
541
+ const organizationId = source.scopeKey;
542
542
  var _this_strategies_get;
543
543
  const orgMap = (_this_strategies_get = this.strategies.get(organizationId)) != null ? _this_strategies_get : new Map();
544
544
  orgMap.set(type, instance);
@@ -552,6 +552,29 @@ class BaseStrategyRegistry {
552
552
  }
553
553
  }
554
554
  }
555
+ /** Returns the explicit registry provenance attached by the plugin loader. */ getSource(instance) {
556
+ const target = resolveStrategyMetadataTarget(instance);
557
+ if (!target) {
558
+ return {
559
+ kind: 'builtin',
560
+ scopeKey: BUILTIN_GLOBAL_SCOPE
561
+ };
562
+ }
563
+ const pluginName = this.reflector.get(PLUGIN_METADATA_KEY, target);
564
+ if (!pluginName) {
565
+ var _this_reflector_get;
566
+ return {
567
+ kind: 'builtin',
568
+ scopeKey: (_this_reflector_get = this.reflector.get(ORGANIZATION_METADATA_KEY, target)) != null ? _this_reflector_get : BUILTIN_GLOBAL_SCOPE
569
+ };
570
+ }
571
+ var _this_reflector_get1;
572
+ return {
573
+ kind: 'plugin',
574
+ pluginName,
575
+ scopeKey: (_this_reflector_get1 = this.reflector.get(ORGANIZATION_METADATA_KEY, target)) != null ? _this_reflector_get1 : GLOBAL_ORGANIZATION_SCOPE
576
+ };
577
+ }
555
578
  /**
556
579
  * Remove all strategies registered by the given plugin for the given scope.
557
580
  */ remove(organizationId, pluginName) {
@@ -1162,10 +1185,6 @@ const PLUGIN_CONFIG_RESOLVER_TOKEN = 'XPERT_PLUGIN_CONFIG_RESOLVER';
1162
1185
  * System token for resolving integration read service from plugin context.
1163
1186
  */ const INTEGRATION_PERMISSION_SERVICE_TOKEN = 'XPERT_PLUGIN_INTEGRATION_PERMISSION_SERVICE';
1164
1187
 
1165
- /**
1166
- * System token for resolving analytics permission service from plugin context.
1167
- */ const ANALYTICS_PERMISSION_SERVICE_TOKEN = 'XPERT_PLUGIN_ANALYTICS_PERMISSION_SERVICE';
1168
-
1169
1188
  const PERMISSION_OPERATION_METADATA_KEY = 'XPERT_PLUGIN_PERMISSION_OPERATION';
1170
1189
  function RequirePermissionOperation(permissionType, operation) {
1171
1190
  return (_target, _propertyKey, descriptor)=>{
@@ -1223,6 +1242,14 @@ function getRequiredPermissionOperation(method, permissionType) {
1223
1242
  * Internal system token used by core to expose the speech-to-text bridge.
1224
1243
  */ const SPEECH_TO_TEXT_SERVICE_TOKEN = 'XPERT_SPEECH_TO_TEXT_SERVICE';
1225
1244
 
1245
+ const VIDEO_GENERATOR_FAMILIES = [
1246
+ 'seedance',
1247
+ 'veo',
1248
+ 'kling'
1249
+ ];
1250
+ const VIDEO_GENERATION_PERMISSION_SERVICE_TOKEN = 'XPERT_PLUGIN_VIDEO_GENERATION_PERMISSION_SERVICE';
1251
+ const VIDEO_GENERATION_SERVICE_TOKEN = 'XPERT_VIDEO_GENERATION_SERVICE';
1252
+
1226
1253
  async function createI18nInstance(pluginDir, language) {
1227
1254
  const instance = createInstance();
1228
1255
  const i18nDir = path__default.join(pluginDir, 'i18n');
@@ -2400,17 +2427,15 @@ class LargeLanguageModel extends AIModel {
2400
2427
  this.startedAt = performance.now();
2401
2428
  },
2402
2429
  handleLLMEnd: (output)=>{
2403
- var _output_llmOutput, _output_llmOutput1;
2404
- var _output_llmOutput_tokenUsage, _ref;
2405
- const tokenUsage = (_ref = (_output_llmOutput_tokenUsage = (_output_llmOutput = output.llmOutput) == null ? void 0 : _output_llmOutput.tokenUsage) != null ? _output_llmOutput_tokenUsage : (_output_llmOutput1 = output.llmOutput) == null ? void 0 : _output_llmOutput1.estimatedTokenUsage) != null ? _ref : calcTokenUsage(output);
2430
+ const tokenUsage = resolveTokenUsage(output);
2406
2431
  if (handleLLMTokens) {
2407
- var _output_llmOutput2;
2408
- var _output_llmOutput_totalTokens;
2432
+ const usage = this.calcResponseUsage(model, credentials, tokenUsage.promptTokens, tokenUsage.completionTokens);
2433
+ usage.totalTokens = tokenUsage.totalTokens;
2409
2434
  handleLLMTokens({
2410
2435
  copilot,
2411
2436
  model,
2412
- usage: this.calcResponseUsage(model, credentials, tokenUsage.promptTokens, tokenUsage.completionTokens),
2413
- tokenUsed: (_output_llmOutput_totalTokens = (_output_llmOutput2 = output.llmOutput) == null ? void 0 : _output_llmOutput2.totalTokens) != null ? _output_llmOutput_totalTokens : sumTokenUsage(output)
2437
+ usage,
2438
+ tokenUsed: tokenUsage.totalTokens
2414
2439
  });
2415
2440
  }
2416
2441
  }
@@ -2570,6 +2595,41 @@ function calcTokenUsage(output) {
2570
2595
  });
2571
2596
  return tokenUsage;
2572
2597
  }
2598
+ function resolveTokenUsage(output) {
2599
+ var _output_llmOutput, _output_llmOutput1, _output_llmOutput2;
2600
+ var _normalizeTokenUsage, _ref, _ref1, _ref2;
2601
+ return (_ref2 = (_ref1 = (_ref = (_normalizeTokenUsage = normalizeTokenUsage(calcTokenUsage(output))) != null ? _normalizeTokenUsage : normalizeTokenUsage((_output_llmOutput = output.llmOutput) == null ? void 0 : _output_llmOutput['tokenUsage'])) != null ? _ref : normalizeTokenUsage((_output_llmOutput1 = output.llmOutput) == null ? void 0 : _output_llmOutput1['estimatedTokenUsage'])) != null ? _ref1 : normalizeTokenUsage({
2602
+ totalTokens: (_output_llmOutput2 = output.llmOutput) == null ? void 0 : _output_llmOutput2['totalTokens']
2603
+ })) != null ? _ref2 : {
2604
+ promptTokens: 0,
2605
+ completionTokens: 0,
2606
+ totalTokens: 0
2607
+ };
2608
+ }
2609
+ function normalizeTokenUsage(candidate) {
2610
+ if (!candidate) {
2611
+ return null;
2612
+ }
2613
+ if (!isValidTokenCount(candidate.promptTokens) || !isValidTokenCount(candidate.completionTokens) || !isValidTokenCount(candidate.totalTokens)) {
2614
+ return null;
2615
+ }
2616
+ var _candidate_promptTokens;
2617
+ const promptTokens = (_candidate_promptTokens = candidate.promptTokens) != null ? _candidate_promptTokens : 0;
2618
+ var _candidate_completionTokens;
2619
+ const completionTokens = (_candidate_completionTokens = candidate.completionTokens) != null ? _candidate_completionTokens : 0;
2620
+ const totalTokens = candidate.totalTokens || promptTokens + completionTokens;
2621
+ if (promptTokens === 0 && completionTokens === 0 && totalTokens === 0) {
2622
+ return null;
2623
+ }
2624
+ return {
2625
+ promptTokens,
2626
+ completionTokens,
2627
+ totalTokens
2628
+ };
2629
+ }
2630
+ function isValidTokenCount(value) {
2631
+ return value === undefined || Number.isFinite(value) && value >= 0;
2632
+ }
2573
2633
  /**
2574
2634
  * @deprecated use calcTokenUsage
2575
2635
  */ function sumTokenUsage(output) {
@@ -2810,6 +2870,10 @@ const KnowledgebaseDocumentsRuntimeCapability = createRuntimeCapability('platfor
2810
2870
  description: 'Upload, import, create, process, inspect, and delete persistent knowledgebase documents.'
2811
2871
  });
2812
2872
 
2873
+ const ActorTokenRuntimeCapability = createRuntimeCapability('platform.actor-token', {
2874
+ description: 'Mint a short-lived host-issued actor bearer token for outbound API calls.'
2875
+ });
2876
+
2813
2877
  const ArtifactsRuntimeCapability = createRuntimeCapability('platform.artifacts', {
2814
2878
  description: 'Create, version, preview, download, share, archive, and delete platform-managed plugin and Agent artifacts.'
2815
2879
  });
@@ -4434,16 +4498,31 @@ const XPERT_REMOTE_UI_CSS = `
4434
4498
  --xui-color-foreground: #18181b;
4435
4499
  --xui-color-card: #fff;
4436
4500
  --xui-color-card-foreground: #18181b;
4501
+ --xui-color-popover: var(--xui-color-card);
4502
+ --xui-color-popover-foreground: var(--xui-color-card-foreground);
4503
+ --xui-color-secondary: #f4f4f5;
4504
+ --xui-color-secondary-foreground: #18181b;
4437
4505
  --xui-color-muted: #f4f4f5;
4438
4506
  --xui-color-muted-foreground: #71717a;
4507
+ --xui-color-accent: #f4f4f5;
4508
+ --xui-color-accent-foreground: #18181b;
4439
4509
  --xui-color-border: #e4e4e7;
4440
4510
  --xui-color-input: #d4d4d8;
4441
4511
  --xui-color-primary: #18181b;
4442
4512
  --xui-color-primary-foreground: #fff;
4513
+ --xui-color-ring: var(--xui-color-primary);
4443
4514
  --xui-color-destructive: #dc2626;
4515
+ --xui-color-destructive-foreground: #fff;
4444
4516
  --xui-color-destructive-background: #fef2f2;
4445
4517
  --xui-color-success: #047857;
4446
4518
  --xui-color-success-background: #ecfdf5;
4519
+ --xui-color-warning: #b45309;
4520
+ --xui-color-info: #2563eb;
4521
+ --xui-color-chart-1: var(--xui-color-primary);
4522
+ --xui-color-chart-2: var(--xui-color-success);
4523
+ --xui-color-chart-3: var(--xui-color-warning);
4524
+ --xui-color-chart-4: var(--xui-color-destructive);
4525
+ --xui-color-chart-5: #7c3aed;
4447
4526
  --xui-radius-sm: 6px;
4448
4527
  --xui-radius-md: 8px;
4449
4528
  --xui-radius-lg: 10px;
@@ -4738,16 +4817,31 @@ const XPERT_REMOTE_UI_BOOTSTRAP = `
4738
4817
  colorForeground: '--xui-color-foreground',
4739
4818
  colorCard: '--xui-color-card',
4740
4819
  colorCardForeground: '--xui-color-card-foreground',
4820
+ colorPopover: '--xui-color-popover',
4821
+ colorPopoverForeground: '--xui-color-popover-foreground',
4822
+ colorSecondary: '--xui-color-secondary',
4823
+ colorSecondaryForeground: '--xui-color-secondary-foreground',
4741
4824
  colorMuted: '--xui-color-muted',
4742
4825
  colorMutedForeground: '--xui-color-muted-foreground',
4826
+ colorAccent: '--xui-color-accent',
4827
+ colorAccentForeground: '--xui-color-accent-foreground',
4743
4828
  colorBorder: '--xui-color-border',
4744
4829
  colorInput: '--xui-color-input',
4745
4830
  colorPrimary: '--xui-color-primary',
4746
4831
  colorPrimaryForeground: '--xui-color-primary-foreground',
4832
+ colorRing: '--xui-color-ring',
4747
4833
  colorDestructive: '--xui-color-destructive',
4834
+ colorDestructiveForeground: '--xui-color-destructive-foreground',
4748
4835
  colorDestructiveBackground: '--xui-color-destructive-background',
4749
4836
  colorSuccess: '--xui-color-success',
4750
4837
  colorSuccessBackground: '--xui-color-success-background',
4838
+ colorWarning: '--xui-color-warning',
4839
+ colorInfo: '--xui-color-info',
4840
+ colorChart1: '--xui-color-chart-1',
4841
+ colorChart2: '--xui-color-chart-2',
4842
+ colorChart3: '--xui-color-chart-3',
4843
+ colorChart4: '--xui-color-chart-4',
4844
+ colorChart5: '--xui-color-chart-5',
4751
4845
  radiusSm: '--xui-radius-sm',
4752
4846
  radiusMd: '--xui-radius-md',
4753
4847
  radiusLg: '--xui-radius-lg',
@@ -4892,4 +4986,4 @@ CollaborationDocumentProviderRegistry = __decorate([
4892
4986
  ])
4893
4987
  ], CollaborationDocumentProviderRegistry);
4894
4988
 
4895
- export { ACCOUNT_BINDING_PERMISSION_SERVICE_TOKEN, AGENT_CHAT_DISPATCH_ERROR_STEER_TARGET_NOT_RUNNING, AGENT_CHAT_DISPATCH_MESSAGE_TYPE, AGENT_MIDDLEWARE_STRATEGY, AIModelProviderNotFoundException, AIModelProviderRegistry, AIModelProviderStrategy, AI_MODEL_PROVIDER, ANALYTICS_PERMISSION_SERVICE_TOKEN, AdapterDataSourceStrategy, AgentMiddlewareRegistry, AgentMiddlewareStrategy, AiModelNotFoundException, ArtifactsRuntimeCapability, AssistantTaskRuntimeCapability, BOUND_IDENTITY_LOGIN_PERMISSION_SERVICE_TOKEN, BUILTIN_GLOBAL_SCOPE, BaseHTTPQueryRunner, BaseQueryRunner, BaseSQLQueryRunner, BaseSandbox, BaseStrategyRegistry, BaseTool, BaseToolset, BuiltinToolset, CHAT_CHANNEL, CHAT_CHANNEL_TEXT_LIMITS, COLLABORATION_DOCUMENT_PROVIDER, CONNECTION_COMMAND_ROUTER_TOKEN, CONNECTOR_STRATEGY, CancelConversationCommand, ChatChannel, ChatChannelRegistry, ChatOAICompatReasoningModel, CollaborationDocumentProvider, CollaborationDocumentProviderRegistry, CollaborationRuntimeCapability, CommonParameterRules, ConnectorRuntimeCapability, 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, DefaultRuntimeCapabilityRegistry as DefaultAgentMiddlewareRuntimeCapabilityRegistry, DefaultRuntimeCapabilityRegistry, DocumentSourceRegistry, DocumentSourceStrategy, DocumentTransformerRegistry, DocumentTransformerStrategy, 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, ImageUnderstandingRegistry, ImageUnderstandingStrategy, IntegrationStrategyKey, IntegrationStrategyRegistry, JUMP_TO_TARGETS, JsonSchemaValidator, KNOWLEDGE_STRATEGY, KnowledgeStrategyKey, KnowledgeStrategyRegistry, KnowledgebaseDocumentsRuntimeCapability, KnowledgebaseRuntimeCapability, LLMUsage, LargeLanguageModel, MANAGED_CONNECTION_REGISTRY_TOKEN, MANAGED_QUEUE_HANDLER_REGISTRY_TOKEN, MANAGED_QUEUE_SERVICE_TOKEN, ModelProvider, ORGANIZATION_METADATA_KEY, OpenAICompatibleReranker, PERMISSION_OPERATION_METADATA_KEY, PLUGIN_CONFIG_RESOLVER_TOKEN, PLUGIN_JOB_PROCESSOR_METADATA, PLUGIN_METADATA, PLUGIN_METADATA_KEY, PLUGIN_WEBHOOK_AUTH_METADATA_KEY, PLUGIN_WEBHOOK_AUTH_SERVICE_TOKEN, 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, RETRIEVER_STRATEGY, RequestContext, RequestContextMiddleware, RequirePermissionOperation, RerankModel, RetrieverRegistry, RetrieverStrategy, SANDBOX_JOB_ERROR_CODES, SANDBOX_JOB_PROGRESS_PREFIX, 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, SandboxJobRuntimeError, SandboxJobsRuntimeCapability, SandboxProviderRegistry, SandboxProviderStrategy, SandboxRuntimeProviderRegistry, SandboxRuntimeProviderStrategy, SandboxWorkspaceMapperRegistry, SandboxWorkspaceMapperStrategy, 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, VIEW_EXTENSION_CACHE_SERVICE_TOKEN, VIEW_EXTENSION_PROVIDER, VectorStoreRegistry, VectorStoreStrategy, ViewExtensionProvider, ViewExtensionProviderRegistry, WORKFLOW_NODE_STRATEGY, WORKFLOW_TRIGGER_STRATEGY, WORKSPACE_FILES_SOURCE, WorkflowNodeRegistry, WorkflowNodeStrategy, WorkflowTriggerRegistry, WorkflowTriggerStrategy, WorkspaceFilesRuntimeCapability, WrapWorkflowNodeExecutionCommand, XPERT_RUNTIME_CAPABILITIES_TOKEN, XpFileSystem, XpertServerPlugin, als, appendSandboxMessage, assertConnectorDefinition, buildSandboxTimeoutMessage, calcTokenUsage, calculateModelPrice, chunkText, countTokensSafe, createI18nInstance, createPluginLogger, createRuntimeCapability, defineAgentMessageType, defineChannelMessageType, derivePluginArtifactNamespace, downloadRemoteFile, formatSandboxTimeout, getDefaultTenantId, getErrorMessage, getModelContextSize, getPermissionOperationMetadata, getPositionList, getPositionMap, getRequestContext, getRequiredPermissionOperation, getTenantGlobalScopeKey, isDevelopmentSandboxRuntimeEnvironment, isRemoteFile, isSandboxBackend, isSandboxJobRuntimeError, isSandboxManagedServiceAdapter, isSandboxServiceProxyAdapter, isSandboxTerminalAdapter, isStrategyInstance, isStructuredMessageType, isTenantGlobalScopeKey, loadYamlFile, mergeCredentials, mergeParentChildChunks, normalizeContextSize, pluginArtifactTableName, renderRemoteModuleIframeHtml, renderRemoteReactIframeHtml, renderRemoteVueIframeHtml, resolveSandboxBackend, resolveSandboxExecutionOptions, resolveSandboxManagedServiceAdapter, resolveSandboxServiceProxyAdapter, resolveSandboxTerminalAdapter, resolveStrategyMetadataTarget, resolveTenantGlobalScopeKey, runWithRequestContext, secondsToMilliseconds, setDefaultTenantId, sumTokenUsage };
4989
+ export { ACCOUNT_BINDING_PERMISSION_SERVICE_TOKEN, AGENT_CHAT_DISPATCH_ERROR_STEER_TARGET_NOT_RUNNING, AGENT_CHAT_DISPATCH_MESSAGE_TYPE, AGENT_MIDDLEWARE_STRATEGY, AIModelProviderNotFoundException, AIModelProviderRegistry, AIModelProviderStrategy, AI_MODEL_PROVIDER, ActorTokenRuntimeCapability, AdapterDataSourceStrategy, AgentMiddlewareRegistry, AgentMiddlewareStrategy, AiModelNotFoundException, ArtifactsRuntimeCapability, AssistantTaskRuntimeCapability, BOUND_IDENTITY_LOGIN_PERMISSION_SERVICE_TOKEN, BUILTIN_GLOBAL_SCOPE, BaseHTTPQueryRunner, BaseQueryRunner, BaseSQLQueryRunner, BaseSandbox, BaseStrategyRegistry, BaseTool, BaseToolset, BuiltinToolset, CHAT_CHANNEL, CHAT_CHANNEL_TEXT_LIMITS, COLLABORATION_DOCUMENT_PROVIDER, CONNECTION_COMMAND_ROUTER_TOKEN, CONNECTOR_STRATEGY, CancelConversationCommand, ChatChannel, ChatChannelRegistry, ChatOAICompatReasoningModel, CollaborationDocumentProvider, CollaborationDocumentProviderRegistry, CollaborationRuntimeCapability, CommonParameterRules, ConnectorRuntimeCapability, 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, DefaultRuntimeCapabilityRegistry as DefaultAgentMiddlewareRuntimeCapabilityRegistry, DefaultRuntimeCapabilityRegistry, DocumentSourceRegistry, DocumentSourceStrategy, DocumentTransformerRegistry, DocumentTransformerStrategy, 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, ImageUnderstandingRegistry, ImageUnderstandingStrategy, IntegrationStrategyKey, IntegrationStrategyRegistry, JUMP_TO_TARGETS, JsonSchemaValidator, KNOWLEDGE_STRATEGY, KnowledgeStrategyKey, KnowledgeStrategyRegistry, KnowledgebaseDocumentsRuntimeCapability, KnowledgebaseRuntimeCapability, LLMUsage, LargeLanguageModel, MANAGED_CONNECTION_REGISTRY_TOKEN, MANAGED_QUEUE_HANDLER_REGISTRY_TOKEN, MANAGED_QUEUE_SERVICE_TOKEN, ModelProvider, ORGANIZATION_METADATA_KEY, OpenAICompatibleReranker, PERMISSION_OPERATION_METADATA_KEY, PLUGIN_CONFIG_RESOLVER_TOKEN, PLUGIN_JOB_PROCESSOR_METADATA, PLUGIN_METADATA, PLUGIN_METADATA_KEY, PLUGIN_WEBHOOK_AUTH_METADATA_KEY, PLUGIN_WEBHOOK_AUTH_SERVICE_TOKEN, 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, RETRIEVER_STRATEGY, RequestContext, RequestContextMiddleware, RequirePermissionOperation, RerankModel, RetrieverRegistry, RetrieverStrategy, SANDBOX_JOB_ERROR_CODES, SANDBOX_JOB_PROGRESS_PREFIX, 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, SandboxJobRuntimeError, SandboxJobsRuntimeCapability, SandboxProviderRegistry, SandboxProviderStrategy, SandboxRuntimeProviderRegistry, SandboxRuntimeProviderStrategy, SandboxWorkspaceMapperRegistry, SandboxWorkspaceMapperStrategy, 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, ViewExtensionProvider, ViewExtensionProviderRegistry, WORKFLOW_NODE_STRATEGY, WORKFLOW_TRIGGER_STRATEGY, WORKSPACE_FILES_SOURCE, WorkflowNodeRegistry, WorkflowNodeStrategy, WorkflowTriggerRegistry, WorkflowTriggerStrategy, WorkspaceFilesRuntimeCapability, WrapWorkflowNodeExecutionCommand, XPERT_RUNTIME_CAPABILITIES_TOKEN, XpFileSystem, XpertServerPlugin, als, appendSandboxMessage, assertConnectorDefinition, buildSandboxTimeoutMessage, calcTokenUsage, calculateModelPrice, chunkText, countTokensSafe, createI18nInstance, createPluginLogger, createRuntimeCapability, defineAgentMessageType, defineChannelMessageType, derivePluginArtifactNamespace, downloadRemoteFile, formatSandboxTimeout, getDefaultTenantId, getErrorMessage, getModelContextSize, getPermissionOperationMetadata, getPositionList, getPositionMap, getRequestContext, getRequiredPermissionOperation, getTenantGlobalScopeKey, isDevelopmentSandboxRuntimeEnvironment, isRemoteFile, isSandboxBackend, isSandboxJobRuntimeError, isSandboxManagedServiceAdapter, isSandboxServiceProxyAdapter, isSandboxTerminalAdapter, isStrategyInstance, isStructuredMessageType, isTenantGlobalScopeKey, loadYamlFile, mergeCredentials, mergeParentChildChunks, normalizeContextSize, pluginArtifactTableName, renderRemoteModuleIframeHtml, renderRemoteReactIframeHtml, renderRemoteVueIframeHtml, resolveSandboxBackend, resolveSandboxExecutionOptions, resolveSandboxManagedServiceAdapter, resolveSandboxServiceProxyAdapter, resolveSandboxTerminalAdapter, resolveStrategyMetadataTarget, resolveTenantGlobalScopeKey, resolveTokenUsage, runWithRequestContext, secondsToMilliseconds, setDefaultTenantId, sumTokenUsage };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xpert-ai/plugin-sdk",
3
- "version": "3.15.17",
3
+ "version": "3.16.0",
4
4
  "license": "AGPL-3.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@langchain/openai": "0.6.9",
20
- "@xpert-ai/contracts": "3.15.17",
20
+ "@xpert-ai/contracts": "3.16.0",
21
21
  "express": "^4.22.1",
22
22
  "js-tiktoken": "^1.0.21"
23
23
  },
@@ -26,7 +26,6 @@
26
26
  "@nestjs/common": "*",
27
27
  "@nestjs/core": "*",
28
28
  "@nestjs/cqrs": "*",
29
- "@xpert-ai/ocap-core": "3.9.1",
30
29
  "ajv": "*",
31
30
  "i18next": "*",
32
31
  "i18next-fs-backend": "*",
@@ -39,8 +39,12 @@ export type AgentMiddlewareAssistantTaskStatusInput = {
39
39
  clientMessageId?: string;
40
40
  xpertId?: string;
41
41
  };
42
+ export type AgentMiddlewareAssistantTaskCancelResult = {
43
+ canceledExecutionIds: string[];
44
+ };
42
45
  export interface AgentMiddlewareAssistantTaskApi {
43
46
  startTask(input: AgentMiddlewareAssistantTaskInput): Promise<AgentMiddlewareAssistantTaskResult>;
44
47
  getTaskStatus?(input: AgentMiddlewareAssistantTaskStatusInput): Promise<AgentMiddlewareAssistantTaskResult | null>;
48
+ cancelTask?(input: AgentMiddlewareAssistantTaskStatusInput): Promise<AgentMiddlewareAssistantTaskCancelResult>;
45
49
  }
46
50
  export declare const AssistantTaskRuntimeCapability: import("../../../core/runtime-capability").RuntimeCapabilityKey<AgentMiddlewareAssistantTaskApi>;
@@ -52,6 +52,7 @@ export declare abstract class LargeLanguageModel extends AIModel {
52
52
  private formatError;
53
53
  }
54
54
  export declare function calcTokenUsage(output: LLMResult): TTokenUsage;
55
+ export declare function resolveTokenUsage(output: LLMResult): TTokenUsage;
55
56
  /**
56
57
  * @deprecated use calcTokenUsage
57
58
  */
@@ -1,6 +1,6 @@
1
1
  import type { IssuedAuthTokens } from './auth-login';
2
2
  import type { BasePermission } from './general';
3
- export type BoundIdentityLoginPermissionOperation = 'create';
3
+ export type BoundIdentityLoginPermissionOperation = 'create' | 'provision';
4
4
  /**
5
5
  * Bound identity login permission
6
6
  * Example: { type: 'bound_identity_login', operations: ['create'], providers: ['lark'] }
@@ -20,6 +20,24 @@ export interface BoundIdentityLoginInput {
20
20
  tenantId: string;
21
21
  organizationId?: string | null;
22
22
  }
23
+ export interface VerifiedEmailLoginInput {
24
+ provider: string;
25
+ subjectId: string;
26
+ tenantId: string;
27
+ verifiedEmail: string;
28
+ displayName?: string;
29
+ avatarUrl?: string;
30
+ profile?: Record<string, unknown>;
31
+ returnTo?: string;
32
+ }
33
+ export type VerifiedEmailLoginResult = {
34
+ status: 'authenticated';
35
+ tokens: IssuedAuthTokens;
36
+ } | {
37
+ status: 'registration_required';
38
+ ticket: string;
39
+ };
23
40
  export interface BoundIdentityLoginPermissionService {
24
41
  loginWithBoundIdentity(input: BoundIdentityLoginInput): Promise<IssuedAuthTokens | null>;
42
+ loginOrPrepareVerifiedEmail(input: VerifiedEmailLoginInput): Promise<VerifiedEmailLoginResult>;
25
43
  }
@@ -6,7 +6,6 @@
6
6
  * Core system will check and inject allowed resources accordingly.
7
7
  */
8
8
  export * from './general';
9
- export * from './analytics';
10
9
  export * from './operation';
11
10
  export * from './handoff';
12
11
  export * from './account-binding';
@@ -15,18 +14,19 @@ export * from './bound-identity-login';
15
14
  export * from './sso-binding';
16
15
  export * from './user';
17
16
  export * from './speech-to-text';
17
+ export * from './video-generation';
18
18
  import type { FileSystemPermission, IntegrationPermission, KnowledgePermission, LLMPermission, VectorStorePermission } from './general';
19
- import type { AnalyticsPermission } from './analytics';
20
19
  import type { AccountBindingPermission } from './account-binding';
21
20
  import type { BoundIdentityLoginPermission } from './bound-identity-login';
22
21
  import type { HandoffPermission } from './handoff';
23
22
  import type { SpeechToTextPermission } from './speech-to-text';
24
23
  import type { SsoBindingPermission } from './sso-binding';
25
24
  import type { UserPermission } from './user';
25
+ import type { VideoGenerationPermission } from './video-generation';
26
26
  /**
27
27
  * Union type for all permissions
28
28
  */
29
- export type Permission = LLMPermission | VectorStorePermission | KnowledgePermission | FileSystemPermission | IntegrationPermission | AnalyticsPermission | AccountBindingPermission | BoundIdentityLoginPermission | SsoBindingPermission | UserPermission | HandoffPermission | SpeechToTextPermission;
29
+ export type Permission = LLMPermission | VectorStorePermission | KnowledgePermission | FileSystemPermission | IntegrationPermission | AccountBindingPermission | BoundIdentityLoginPermission | SsoBindingPermission | UserPermission | HandoffPermission | SpeechToTextPermission | VideoGenerationPermission;
30
30
  /**
31
31
  * Permissions array type
32
32
  */
@@ -0,0 +1,159 @@
1
+ import type { WorkspacePortableFileReference } from '../../runtime/capabilities/workspace-files';
2
+ export declare const VIDEO_GENERATOR_FAMILIES: readonly ["seedance", "veo", "kling"];
3
+ export type VideoGeneratorFamily = (typeof VIDEO_GENERATOR_FAMILIES)[number];
4
+ export type VideoGenerationPermissionOperation = 'list' | 'submit' | 'query' | 'cancel';
5
+ export type VideoGenerationMode = 'text_to_video' | 'image_to_video' | 'first_last_frame_to_video' | 'reference_to_video';
6
+ export type VideoGenerationReferenceKind = 'image' | 'video' | 'audio';
7
+ export type VideoGenerationReferencePurpose = 'reference' | 'first_frame' | 'last_frame';
8
+ export interface VideoGenerationPermission {
9
+ type: 'video_generation';
10
+ operations?: VideoGenerationPermissionOperation[];
11
+ scope?: string[];
12
+ description?: string;
13
+ }
14
+ export declare const VIDEO_GENERATION_PERMISSION_SERVICE_TOKEN = "XPERT_PLUGIN_VIDEO_GENERATION_PERMISSION_SERVICE";
15
+ export declare const VIDEO_GENERATION_SERVICE_TOKEN = "XPERT_VIDEO_GENERATION_SERVICE";
16
+ export interface VideoGenerationReferenceLimit {
17
+ maxItems: number;
18
+ }
19
+ export interface VideoGenerationModelInputCapabilities {
20
+ referenceImages?: VideoGenerationReferenceLimit;
21
+ referenceVideos?: VideoGenerationReferenceLimit;
22
+ referenceAudios?: VideoGenerationReferenceLimit;
23
+ initialFrame?: boolean;
24
+ lastFrame?: boolean;
25
+ }
26
+ export interface VideoGenerationModelOption {
27
+ id: string;
28
+ label: string;
29
+ /** Optional per-model restriction. Defaults to the generator-level modes. */
30
+ modes?: readonly VideoGenerationMode[];
31
+ inputs?: VideoGenerationModelInputCapabilities;
32
+ }
33
+ interface VideoGenerationToolsetCapabilityBase {
34
+ family: VideoGeneratorFamily;
35
+ displayName: string;
36
+ modes: readonly VideoGenerationMode[];
37
+ models: readonly VideoGenerationModelOption[];
38
+ defaultModel: string;
39
+ resolutions: readonly string[];
40
+ aspectRatios: readonly string[];
41
+ durationSeconds: {
42
+ min: number;
43
+ max: number;
44
+ default: number;
45
+ };
46
+ supportsAudio: boolean;
47
+ }
48
+ /** Legacy single-image protocol. Kept so already installed provider plugins remain usable. */
49
+ export interface VideoGenerationToolsetCapabilityV1 extends VideoGenerationToolsetCapabilityBase {
50
+ protocolVersion: 1;
51
+ tools: {
52
+ textToVideo?: string;
53
+ imageToVideo?: string;
54
+ query: string;
55
+ cancel?: string;
56
+ };
57
+ }
58
+ /**
59
+ * Capability-driven protocol. Submit tools consume normalized argument names:
60
+ * `input_image_file`, `first_frame_file`, `last_frame_file`, and
61
+ * `reference_{image,video,audio}_files`.
62
+ */
63
+ export interface VideoGenerationToolsetCapabilityV2 extends VideoGenerationToolsetCapabilityBase {
64
+ protocolVersion: 2;
65
+ tools: {
66
+ textToVideo?: string;
67
+ imageToVideo?: string;
68
+ firstLastFrameToVideo?: string;
69
+ referenceToVideo?: string;
70
+ query: string;
71
+ cancel?: string;
72
+ };
73
+ }
74
+ export type VideoGenerationToolsetCapability = VideoGenerationToolsetCapabilityV1 | VideoGenerationToolsetCapabilityV2;
75
+ export interface VideoGeneratorSummary {
76
+ id: string;
77
+ family: VideoGeneratorFamily;
78
+ name: string;
79
+ displayName: string;
80
+ linkedToXpert: boolean;
81
+ modes: VideoGenerationMode[];
82
+ models: VideoGenerationModelOption[];
83
+ defaultModel: string;
84
+ resolutions: string[];
85
+ aspectRatios: string[];
86
+ durationSeconds: {
87
+ min: number;
88
+ max: number;
89
+ default: number;
90
+ };
91
+ supportsAudio: boolean;
92
+ supportsCancel: boolean;
93
+ }
94
+ export interface ListVideoGeneratorsInput {
95
+ xpertId: string;
96
+ }
97
+ export interface ListVideoGeneratorsResult {
98
+ generators: VideoGeneratorSummary[];
99
+ }
100
+ export interface VideoGenerationReferenceInput {
101
+ kind: VideoGenerationReferenceKind;
102
+ purpose?: VideoGenerationReferencePurpose;
103
+ file: WorkspacePortableFileReference;
104
+ }
105
+ export interface SubmitVideoGenerationInput {
106
+ xpertId: string;
107
+ toolsetId: string;
108
+ projectId?: string | null;
109
+ prompt: string;
110
+ references?: readonly VideoGenerationReferenceInput[] | null;
111
+ /** @deprecated Use `references` with an image item. */
112
+ inputImage?: WorkspacePortableFileReference | null;
113
+ model?: string | null;
114
+ resolution?: string | null;
115
+ aspectRatio?: string | null;
116
+ durationSeconds?: number | null;
117
+ generateAudio?: boolean | null;
118
+ }
119
+ export interface SubmitVideoGenerationResult {
120
+ providerTaskId: string;
121
+ status: string;
122
+ model?: string;
123
+ mode?: VideoGenerationMode;
124
+ acceptedReferenceCount?: number;
125
+ }
126
+ export interface QueryVideoGenerationInput {
127
+ xpertId: string;
128
+ toolsetId: string;
129
+ projectId?: string | null;
130
+ providerTaskId: string;
131
+ }
132
+ export interface QueryVideoGenerationResult {
133
+ providerTaskId: string;
134
+ status: string;
135
+ completed: boolean;
136
+ failed: boolean;
137
+ model?: string;
138
+ errorCode?: string;
139
+ errorMessage?: string;
140
+ outputFile?: WorkspacePortableFileReference;
141
+ }
142
+ export interface CancelVideoGenerationInput {
143
+ xpertId: string;
144
+ toolsetId: string;
145
+ providerTaskId: string;
146
+ }
147
+ export interface CancelVideoGenerationResult {
148
+ providerTaskId: string;
149
+ supported: boolean;
150
+ cancelled: boolean;
151
+ status: string;
152
+ }
153
+ export interface VideoGenerationPermissionService {
154
+ listGenerators(input: ListVideoGeneratorsInput): Promise<ListVideoGeneratorsResult>;
155
+ submit(input: SubmitVideoGenerationInput): Promise<SubmitVideoGenerationResult>;
156
+ query(input: QueryVideoGenerationInput): Promise<QueryVideoGenerationResult>;
157
+ cancel(input: CancelVideoGenerationInput): Promise<CancelVideoGenerationResult>;
158
+ }
159
+ export {};
@@ -0,0 +1,15 @@
1
+ export type ActorTokenAct = Record<string, string | number | boolean | null | undefined>;
2
+ export interface ActorTokenRequest {
3
+ audience?: string | string[];
4
+ ttlSeconds?: number;
5
+ act?: ActorTokenAct;
6
+ }
7
+ export interface ActorTokenResult {
8
+ token: string;
9
+ expiresAt: string;
10
+ audience: string | string[];
11
+ }
12
+ export interface ActorTokenApi {
13
+ getToken(input?: ActorTokenRequest): Promise<ActorTokenResult>;
14
+ }
15
+ export declare const ActorTokenRuntimeCapability: import("../../core/runtime-capability").RuntimeCapabilityKey<ActorTokenApi>;
@@ -1,5 +1,6 @@
1
1
  export * from './knowledgebase';
2
2
  export * from './knowledgebase-documents';
3
+ export * from './actor-token';
3
4
  export * from './artifacts';
4
5
  export * from './workspace-files';
5
6
  export * from './sandbox-jobs';
@@ -10,6 +10,7 @@ export declare const WORKSPACE_FILES_SOURCE: "platform.workspace.files";
10
10
  */
11
11
  export type WorkspaceFileScope = {
12
12
  tenantId?: string | null;
13
+ organizationId?: string | null;
13
14
  userId?: string | null;
14
15
  catalog?: WorkspaceFileCatalog | null;
15
16
  scopeId?: string | null;
@@ -151,6 +152,38 @@ export type WorkspaceUnderstoodFile = WorkspaceFile & {
151
152
  capabilities?: string[];
152
153
  summary?: string;
153
154
  };
155
+ export type WorkspaceUnderstandingVectorStatus = 'pending' | 'ready' | 'failed' | 'unavailable';
156
+ export type WorkspaceUnderstandingStatusInput = WorkspaceFileScope & {
157
+ fileAssetId: string;
158
+ };
159
+ /** Compact readiness DTO for an understood file. It never contains parsed text. */
160
+ export type WorkspaceUnderstandingStatus = {
161
+ fileAssetId: string;
162
+ status: string;
163
+ parseMode: string;
164
+ capabilities: string[];
165
+ chunkCount: number;
166
+ indexedChunkCount: number;
167
+ vectorIndexStatus: WorkspaceUnderstandingVectorStatus;
168
+ errorCode?: string;
169
+ parsedAt?: string;
170
+ };
171
+ export type WorkspaceRetryUnderstandingInput = WorkspaceUnderstandingStatusInput;
172
+ export type WorkspaceUnderstandingReferenceInput = {
173
+ fileAssetId: string;
174
+ chunkId: string;
175
+ };
176
+ export type WorkspaceValidateUnderstandingReferencesInput = WorkspaceFileScope & {
177
+ references: WorkspaceUnderstandingReferenceInput[];
178
+ excerptLength?: number;
179
+ };
180
+ export type WorkspaceValidatedUnderstandingReference = {
181
+ fileAssetId: string;
182
+ chunkId: string;
183
+ orderNo: number;
184
+ anchor?: Record<string, unknown>;
185
+ excerpt: string;
186
+ };
154
187
  /**
155
188
  * Runtime capability contract for reading, writing, uploading, deleting, and
156
189
  * understanding files in Xpert workspace Volumes.
@@ -160,6 +193,12 @@ export interface WorkspaceFilesApi {
160
193
  uploadBuffer(input: WorkspaceUploadBufferInput): Promise<WorkspaceFile>;
161
194
  /** Register an existing workspace file with the platform understanding pipeline. */
162
195
  understandFile(input: WorkspaceUnderstandFileInput): Promise<WorkspaceUnderstoodFile>;
196
+ /** Return compact parsing and semantic-index readiness for one scoped FileAsset. */
197
+ getUnderstandingStatus(input: WorkspaceUnderstandingStatusInput): Promise<WorkspaceUnderstandingStatus>;
198
+ /** Retry parsing and semantic indexing for one failed scoped FileAsset. */
199
+ retryUnderstanding(input: WorkspaceRetryUnderstandingInput): Promise<WorkspaceUnderstandingStatus>;
200
+ /** Validate bounded FileAsset/chunk evidence without returning complete file contents. */
201
+ validateUnderstandingReferences(input: WorkspaceValidateUnderstandingReferencesInput): Promise<WorkspaceValidatedUnderstandingReference[]>;
163
202
  /**
164
203
  * Resolve metadata and an openable URL for an explicitly scoped workspace
165
204
  * file without reading its bytes into the API process.
@@ -1,5 +1,5 @@
1
1
  import { TSandboxProviderMeta, TSandboxWorkForType } from '@xpert-ai/contracts';
2
- import { SandboxBackendProtocol } from './protocol';
2
+ import { MaybePromise, SandboxBackendProtocol } from './protocol';
3
3
  export type SandboxWorkspaceBinding = {
4
4
  /**
5
5
  * Host-side bind source used by containerized sandboxes.
@@ -71,6 +71,11 @@ export type SandboxProviderCreateOptions = {
71
71
  export interface ISandboxProvider<T extends SandboxBackendProtocol = SandboxBackendProtocol> {
72
72
  type: string;
73
73
  meta: TSandboxProviderMeta;
74
+ /**
75
+ * Whether this provider is currently available in this deployment.
76
+ * Providers without an availability hook remain available for backward compatibility.
77
+ */
78
+ isAvailable?(): MaybePromise<boolean>;
74
79
  /**
75
80
  * Create a new sandbox instance
76
81
  *
@@ -7,6 +7,8 @@ export type SandboxTerminalExit = {
7
7
  export type SandboxTerminalOpenOptions = {
8
8
  cols: number;
9
9
  rows: number;
10
+ /** Reports terminal transport or provider failures separately from process exit. */
11
+ onError?: (error: Error) => void;
10
12
  onExit: (event: SandboxTerminalExit) => void;
11
13
  onOutput: (data: string) => void;
12
14
  };
@@ -1,6 +1,14 @@
1
1
  import { OnModuleInit, type Type } from '@nestjs/common';
2
2
  import { DiscoveryService, Reflector } from '@nestjs/core';
3
3
  import { StrategyBus } from './core/strategy-bus';
4
+ export type StrategySource = {
5
+ kind: 'builtin';
6
+ scopeKey: string;
7
+ } | {
8
+ kind: 'plugin';
9
+ pluginName: string;
10
+ scopeKey: string;
11
+ };
4
12
  export declare class BaseStrategyRegistry<S> implements OnModuleInit {
5
13
  protected readonly strategyKey: string;
6
14
  protected discoveryService: DiscoveryService;
@@ -12,6 +20,8 @@ export declare class BaseStrategyRegistry<S> implements OnModuleInit {
12
20
  constructor(strategyKey: string, discoveryService: DiscoveryService, reflector: Reflector);
13
21
  onModuleInit(): void;
14
22
  upsert(instance: unknown): void;
23
+ /** Returns the explicit registry provenance attached by the plugin loader. */
24
+ getSource(instance: S): StrategySource;
15
25
  /**
16
26
  * Remove all strategies registered by the given plugin for the given scope.
17
27
  */
@@ -2,6 +2,7 @@ import { DynamicStructuredTool } from '@langchain/core/tools';
2
2
  import { I18nObject, IconDefinition } from '@xpert-ai/contracts';
3
3
  import { ZodSchema } from 'zod';
4
4
  import { BuiltinToolset, TBuiltinToolsetParams } from './builtin';
5
+ import type { VideoGenerationToolsetCapability } from '../core/permissions/video-generation';
5
6
  export interface IToolsetStrategy<TConfig = any> {
6
7
  /**
7
8
  * Metadata about this toolset
@@ -14,6 +15,8 @@ export interface IToolsetStrategy<TConfig = any> {
14
15
  description?: I18nObject;
15
16
  configSchema: any;
16
17
  icon?: IconDefinition;
18
+ /** Optional normalized video-generation capability consumed by platform services. */
19
+ videoGeneration?: VideoGenerationToolsetCapability;
17
20
  };
18
21
  /**
19
22
  * Validate the configuration
@@ -1,4 +1,4 @@
1
- import { IconDefinition, JsonSchemaObjectType, PluginMeta, PluginTargetApp, PluginTargetAppMeta, TAvatar, type TPromptWorkflow, XpertTemplatePluginDependencies, XpertTypeEnum } from '@xpert-ai/contracts';
1
+ import { IconDefinition, I18nObject, JsonSchemaObjectType, PluginMeta, PluginTargetApp, PluginTargetAppMeta, TAvatar, type TPromptWorkflow, XpertTemplatePluginDependencies, XpertTypeEnum } from '@xpert-ai/contracts';
2
2
  import type { DynamicModule, INestApplicationContext } from '@nestjs/common';
3
3
  import { ModuleRef } from '@nestjs/core';
4
4
  import type { ZodSchema } from 'zod';
@@ -60,8 +60,8 @@ export interface XpertTemplateContribution {
60
60
  key: string;
61
61
  id?: string;
62
62
  name?: string;
63
- title?: string;
64
- description?: string;
63
+ title?: string | I18nObject;
64
+ description?: string | I18nObject;
65
65
  category?: string;
66
66
  copyright?: string | null;
67
67
  privacyPolicy?: string | null;
@@ -1,45 +0,0 @@
1
- import type { BasePermission } from './general';
2
- export type AnalyticsPermissionOperation = 'dscore' | 'query' | 'model' | 'indicator' | 'create_indicator';
3
- /**
4
- * Analytics Permission
5
- * Example: { type: 'analytics', operations: ['dscore'] }
6
- */
7
- export interface AnalyticsPermission extends BasePermission {
8
- type: 'analytics';
9
- operations?: AnalyticsPermissionOperation[];
10
- scope?: string[];
11
- }
12
- /**
13
- * System token for resolving analytics permission service from plugin context.
14
- */
15
- export declare const ANALYTICS_PERMISSION_SERVICE_TOKEN = "XPERT_PLUGIN_ANALYTICS_PERMISSION_SERVICE";
16
- export interface AnalyticsResolvedChatBIModel {
17
- chatbiModelId: string;
18
- modelId: string;
19
- modelKey?: string;
20
- cubeName: string;
21
- entityCaption?: string;
22
- entityDescription?: string;
23
- prompts?: string[];
24
- }
25
- export interface AnalyticsDSCoreInput {
26
- modelIds?: string[];
27
- indicatorDraft?: boolean;
28
- semanticModelDraft?: boolean;
29
- }
30
- export interface AnalyticsIndicatorValidationInput {
31
- modelIds?: string[];
32
- semanticModelId: string;
33
- modelKey?: string;
34
- statement: string;
35
- }
36
- /**
37
- * Analytics service exposed to plugins under permission control.
38
- */
39
- export interface AnalyticsPermissionService<TDSCoreService = unknown> {
40
- resolveChatBIModels(modelIds: string[]): Promise<AnalyticsResolvedChatBIModel[]>;
41
- getDSCoreService(input?: AnalyticsDSCoreInput): Promise<TDSCoreService>;
42
- visitChatBIModel(modelId: string, cubeName: string): Promise<void>;
43
- ensureCreateIndicatorAccess(): Promise<void>;
44
- validateIndicatorStatement(input: AnalyticsIndicatorValidationInput): Promise<void>;
45
- }