@xpert-ai/plugin-sdk 3.23.1 → 3.26.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.
Files changed (44) hide show
  1. package/docs/README.md +8 -0
  2. package/docs/analytics.md +42 -0
  3. package/docs/artifact-presentations.md +43 -0
  4. package/docs/mcp-client.md +63 -0
  5. package/docs/provider-credential-validation.md +34 -0
  6. package/docs/rest-client.md +24 -0
  7. package/docs/workspace-file-tools.md +6 -0
  8. package/index.cjs.js +471 -89
  9. package/index.esm.js +448 -92
  10. package/model-provider.cjs.js +10 -0
  11. package/model-provider.esm.js +9 -1
  12. package/package.json +2 -2
  13. package/src/index.d.ts +2 -0
  14. package/src/lib/agent/handoff/agent-runtime-message.contract.d.ts +76 -76
  15. package/src/lib/agent/middleware/capabilities/assistant-task.d.ts +36 -1
  16. package/src/lib/agent/runtime/dispatch.d.ts +284 -284
  17. package/src/lib/agent/runtime/index.d.ts +1 -0
  18. package/src/lib/agent/runtime/pipeline-scope.d.ts +110 -0
  19. package/src/lib/agent/runtime/types.d.ts +4 -2
  20. package/src/lib/ai-model/ai-model-provider.interface.d.ts +3 -1
  21. package/src/lib/ai-model/utils/limits.d.ts +4 -2
  22. package/src/lib/artifact-presentation/index.d.ts +35 -0
  23. package/src/lib/data/analytics/analytics-payload.d.ts +3 -0
  24. package/src/lib/data/analytics/index.d.ts +1 -0
  25. package/src/lib/data/datasource/types.d.ts +1 -1
  26. package/src/lib/project-pipeline/adapters.d.ts +87 -0
  27. package/src/lib/project-pipeline/capability.d.ts +100 -0
  28. package/src/lib/project-pipeline/index.d.ts +5 -0
  29. package/src/lib/project-pipeline/projection.d.ts +71 -0
  30. package/src/lib/project-pipeline/registry.d.ts +509 -0
  31. package/src/lib/project-pipeline/runtime-registry.d.ts +45 -0
  32. package/src/lib/project-pipeline/scoped-registry.d.ts +10 -0
  33. package/src/lib/project-task/index.d.ts +6 -0
  34. package/src/lib/project-type/index.d.ts +17 -1
  35. package/src/lib/rag/types.d.ts +1 -1
  36. package/src/lib/runtime/capabilities/artifacts.d.ts +2 -0
  37. package/src/lib/runtime/capabilities/index.d.ts +2 -0
  38. package/src/lib/runtime/capabilities/mcp-client-runtime.d.ts +41 -0
  39. package/src/lib/runtime/capabilities/rest-client-runtime.d.ts +34 -0
  40. package/src/lib/sandbox/file-edits.d.ts +4 -0
  41. package/src/lib/sandbox/protocol.d.ts +7 -1
  42. package/src/lib/sandbox/sandbox.d.ts +2 -8
  43. package/src/lib/tool-provider/adapters.d.ts +1 -1
  44. package/src/lib/tool-provider/types.d.ts +2 -0
package/index.cjs.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var common = require('@nestjs/common');
4
- var constants = require('@nestjs/common/constants');
4
+ var constants_js = require('@nestjs/common/constants.js');
5
5
  var lodashEs = require('lodash-es');
6
6
  var dispatch = require('@langchain/core/callbacks/dispatch');
7
7
  var contracts = require('@xpert-ai/contracts');
@@ -36,7 +36,6 @@ var chat_models = require('@langchain/core/language_models/chat_models');
36
36
  var env = require('@langchain/core/utils/env');
37
37
  var modelProviderHttpClient = require('./model-provider-http-client.cjs.js');
38
38
  var jsTiktoken = require('js-tiktoken');
39
- var base$1 = require('@langchain/core/language_models/base');
40
39
  var zod = require('zod');
41
40
  var results = require('./results.cjs.js');
42
41
  var connector = require('./connector.cjs.js');
@@ -94,7 +93,7 @@ var _axios__namespace = /*#__PURE__*/_interopNamespaceDefault(_axios);
94
93
  }
95
94
  }
96
95
  // Pick relevant metadata from pluginMetadata based on MODULE_METADATA values
97
- const metadata = lodashEs.pick(pluginMetadata, Object.values(constants.MODULE_METADATA));
96
+ const metadata = lodashEs.pick(pluginMetadata, Object.values(constants_js.MODULE_METADATA));
98
97
  // Apply the Module decorator with the picked metadata
99
98
  common.Module(metadata)(targetClass);
100
99
  };
@@ -1901,6 +1900,34 @@ exports.AnalyticsProviderRegistry = __decorate([
1901
1900
  ])
1902
1901
  ], exports.AnalyticsProviderRegistry);
1903
1902
 
1903
+ /** Structural feedback from the discovered provider contract. Never substitutes for provider authorization or validation. */ function validateAnalyticsPayload(payload, schema) {
1904
+ if (typeof schema !== 'boolean' && (schema === null || typeof schema !== 'object' || Array.isArray(schema))) {
1905
+ throw new Error('ANALYTICS_PAYLOAD_SCHEMA_INVALID: expected a provider JSON Schema');
1906
+ }
1907
+ // Do not coerce, remove properties, apply defaults, fetch remote refs, or treat unknown formats as authorization.
1908
+ const ajv = new Ajv({
1909
+ strict: false,
1910
+ validateFormats: false,
1911
+ allErrors: false
1912
+ });
1913
+ let validate;
1914
+ try {
1915
+ validate = ajv.compile(schema);
1916
+ } catch (e) {
1917
+ throw new Error('ANALYTICS_PAYLOAD_SCHEMA_INVALID: rediscover the provider contract; its schema could not be compiled');
1918
+ }
1919
+ if ('$async' in validate && validate.$async) {
1920
+ throw new Error('ANALYTICS_PAYLOAD_SCHEMA_INVALID: provider payload validation must use a synchronous schema');
1921
+ }
1922
+ if (!validate(payload)) {
1923
+ var _validate_errors;
1924
+ const issue = (_validate_errors = validate.errors) == null ? void 0 : _validate_errors[0];
1925
+ const location = (issue == null ? void 0 : issue.instancePath) || '/';
1926
+ var _issue_keyword;
1927
+ throw new Error(`ANALYTICS_PAYLOAD_INVALID: ${location.slice(0, 240)} (${(_issue_keyword = issue == null ? void 0 : issue.keyword) != null ? _issue_keyword : 'schema'}). Compare this field with the discovered payloadSchema and canonical Binding. Copy opaque IDs, revisions and contract hashes exactly; do not retry unchanged input.`);
1928
+ }
1929
+ }
1930
+
1904
1931
  const AI_MODEL_PROVIDER = 'AI_MODEL_PROVIDER';
1905
1932
  function AIModelProviderStrategy(provider) {
1906
1933
  var _err_stack;
@@ -4047,35 +4074,61 @@ function getModelContextSize(input) {
4047
4074
  var _input_options;
4048
4075
  return normalizeContextSize((_input_options = input.options) == null ? void 0 : _input_options[contracts.ModelPropertyKey.CONTEXT_SIZE]);
4049
4076
  }
4050
- // Backward compatibility for langchain <1.0.0
4051
- if (input.metadata && "profile" in input.metadata) {
4052
- const profile = input.metadata['profile'];
4053
- if ("maxInputTokens" in profile && (typeof profile.maxInputTokens === "number" || profile.maxInputTokens == null)) {
4054
- var _profile_maxInputTokens;
4055
- return (_profile_maxInputTokens = profile.maxInputTokens) != null ? _profile_maxInputTokens : undefined;
4056
- }
4057
- }
4058
- // Langchain v1.0.0+
4059
- if ("profile" in input && typeof input.profile === "object" && input.profile && "maxInputTokens" in input.profile && (typeof input.profile.maxInputTokens === "number" || input.profile.maxInputTokens == null)) {
4060
- var _input_profile_maxInputTokens;
4061
- return (_input_profile_maxInputTokens = input.profile.maxInputTokens) != null ? _input_profile_maxInputTokens : undefined;
4062
- }
4063
- if ("model" in input && typeof input.model === "string") {
4064
- return base$1.getModelContextSize(input.model);
4065
- }
4066
- if ("modelName" in input && typeof input.modelName === "string") {
4067
- return base$1.getModelContextSize(input.modelName);
4068
- }
4069
- return undefined;
4077
+ return getClientContextSize(input);
4078
+ }
4079
+ /** Bind the effective window to the runtime configuration and client without guessing from model names. */ function applyModelContextSize(model, configuration) {
4080
+ var _configuration_options;
4081
+ const configuredLimit = normalizeContextSize((_configuration_options = configuration.options) == null ? void 0 : _configuration_options[contracts.ModelPropertyKey.CONTEXT_SIZE]);
4082
+ const providerLimit = getClientContextSize(model);
4083
+ const limits = [
4084
+ configuredLimit,
4085
+ providerLimit
4086
+ ].filter((value)=>value !== undefined);
4087
+ if (!limits.length) return model;
4088
+ const contextSize = Math.min(...limits);
4089
+ configuration.options = _extends._extends({}, configuration.options, {
4090
+ [contracts.ModelPropertyKey.CONTEXT_SIZE]: contextSize
4091
+ });
4092
+ const metadata = 'metadata' in model && typeof model.metadata === 'object' && model.metadata !== null ? model.metadata : {};
4093
+ const legacyProfile = 'profile' in metadata && typeof metadata.profile === 'object' && metadata.profile !== null ? metadata.profile : {};
4094
+ const profile = 'profile' in model && typeof model.profile === 'object' && model.profile !== null ? model.profile : {};
4095
+ Object.assign(model, {
4096
+ metadata: _extends._extends({}, metadata, {
4097
+ profile: _extends._extends({}, legacyProfile, {
4098
+ maxInputTokens: contextSize
4099
+ })
4100
+ })
4101
+ });
4102
+ Object.defineProperty(model, 'profile', {
4103
+ configurable: true,
4104
+ enumerable: true,
4105
+ writable: true,
4106
+ value: _extends._extends({}, legacyProfile, profile, {
4107
+ maxInputTokens: contextSize
4108
+ })
4109
+ });
4110
+ return model;
4111
+ }
4112
+ function getClientContextSize(model) {
4113
+ const metadata = 'metadata' in model ? model.metadata : undefined;
4114
+ const legacyProfile = metadata && typeof metadata === 'object' && 'profile' in metadata ? metadata.profile : undefined;
4115
+ const limits = [
4116
+ readProfileContextSize(legacyProfile),
4117
+ readProfileContextSize('profile' in model ? model.profile : undefined)
4118
+ ].filter((value)=>value !== undefined);
4119
+ return limits.length ? Math.min(...limits) : undefined;
4120
+ }
4121
+ function readProfileContextSize(profile) {
4122
+ return profile && typeof profile === 'object' && 'maxInputTokens' in profile ? normalizeContextSize(profile.maxInputTokens) : undefined;
4070
4123
  }
4071
4124
  function isCopilotModel(input) {
4072
- return typeof input === "object" && input !== null && !("invoke" in input);
4125
+ return typeof input === 'object' && input !== null && !('invoke' in input);
4073
4126
  }
4074
4127
  function normalizeContextSize(value) {
4075
- if (typeof value === "number" && Number.isFinite(value) && value > 0) {
4128
+ if (typeof value === 'number' && Number.isFinite(value) && value > 0) {
4076
4129
  return Math.floor(value);
4077
4130
  }
4078
- if (typeof value === "string") {
4131
+ if (typeof value === 'string') {
4079
4132
  const parsed = Number.parseInt(value, 10);
4080
4133
  if (Number.isFinite(parsed) && parsed > 0) {
4081
4134
  return parsed;
@@ -4506,6 +4559,23 @@ function taskWaitReason(states, mode) {
4506
4559
  const AgentExecutionRunnerCapability = modelProvider.createRuntimeCapability('platform.agent_execution.runner');
4507
4560
  const AgentExecutionRunnerFactoryCapability = modelProvider.createRuntimeCapability('platform.agent_execution.runner.factory');
4508
4561
 
4562
+ /** Host-only provenance. This describes a saved operation; it never grants access by itself. */ const projectPipelineInvocationScopeSchema = v3.z.object({
4563
+ tenantId: v3.z.string().uuid(),
4564
+ organizationId: v3.z.string().uuid(),
4565
+ userId: v3.z.string().uuid(),
4566
+ projectId: v3.z.string().uuid(),
4567
+ workspaceId: v3.z.string().uuid(),
4568
+ callerType: v3.z.literal('project_pipeline'),
4569
+ callerAgentKey: v3.z.literal('pipeline_node'),
4570
+ parentExecutionId: v3.z.string(),
4571
+ pipelineOrigin: contracts.projectPipelineWorkContextSchema
4572
+ }).strict().superRefine((value, context)=>{
4573
+ if (value.parentExecutionId !== `pipeline-operation:${value.pipelineOrigin.operationId}`) context.addIssue({
4574
+ code: 'custom',
4575
+ message: 'PIPELINE_PARENT_IDENTITY_MISMATCH'
4576
+ });
4577
+ });
4578
+
4509
4579
  /** Older runtime plugins can still send this event; new emissions use ON_CHAT_EVENT. */ const RESOURCE_CARD_EVENT = 'xpert.resource_card';
4510
4580
 
4511
4581
  const ASSISTANT_CAPABILITY_PROVIDER = 'ASSISTANT_CAPABILITY_PROVIDER';
@@ -4870,6 +4940,67 @@ function resolveSandboxBackend(sandbox) {
4870
4940
  return isSandboxBackend(candidate) ? candidate : null;
4871
4941
  }
4872
4942
 
4943
+ function editCommandResult(filePath, result) {
4944
+ switch(result.exitCode){
4945
+ case 0:
4946
+ return {
4947
+ path: filePath,
4948
+ filesUpdate: null,
4949
+ occurrences: parseInt(result.output.trim(), 10) || 1
4950
+ };
4951
+ case 1:
4952
+ return {
4953
+ error: `String not found in file '${filePath}'`
4954
+ };
4955
+ case 2:
4956
+ return {
4957
+ error: `Multiple occurrences found in '${filePath}'. Use replaceAll=true to replace all.`
4958
+ };
4959
+ case 3:
4960
+ return {
4961
+ error: `Error: File '${filePath}' not found`
4962
+ };
4963
+ default:
4964
+ return {
4965
+ error: `Unknown error editing file '${filePath}'`
4966
+ };
4967
+ }
4968
+ }
4969
+ /** Stops on failure; never promises rollback or silently reapplies completed edits. */ async function sequentialFileEdits(filePath, edits, apply) {
4970
+ const results = [];
4971
+ if (!(edits == null ? void 0 : edits.length)) return {
4972
+ error: 'No edits provided',
4973
+ progress: {
4974
+ mode: 'sequential',
4975
+ appliedEdits: 0
4976
+ }
4977
+ };
4978
+ for (const edit of edits){
4979
+ const result = await apply(edit);
4980
+ results.push(result);
4981
+ if (result.error) return {
4982
+ error: `Multi-edit failed at edit ${results.length}: ${result.error}`,
4983
+ path: filePath,
4984
+ filesUpdate: null,
4985
+ results,
4986
+ progress: {
4987
+ mode: 'sequential',
4988
+ appliedEdits: results.length - 1,
4989
+ failedEdit: results.length
4990
+ }
4991
+ };
4992
+ }
4993
+ return {
4994
+ path: filePath,
4995
+ filesUpdate: null,
4996
+ results,
4997
+ progress: {
4998
+ mode: 'sequential',
4999
+ appliedEdits: results.length
5000
+ }
5001
+ };
5002
+ }
5003
+
4873
5004
  const MAX_LINE_LENGTH = 500;
4874
5005
  const MAX_GREP_LINE_LENGTH = 2000;
4875
5006
  const GREP_RESULT_LIMIT = 100;
@@ -5709,70 +5840,16 @@ try {
5709
5840
  filesUpdate: null
5710
5841
  };
5711
5842
  }
5712
- /**
5713
- * Edit a file by replacing string occurrences.
5714
- */ async edit(filePath, oldString, newString, replaceAll = false) {
5843
+ /** Edit a file by replacing string occurrences. */ async edit(filePath, oldString, newString, replaceAll = false) {
5715
5844
  const command = buildEditCommand(filePath, oldString, newString, replaceAll);
5716
5845
  const result = await this.executeOperation(command, DEFAULT_SANDBOX_FILE_OPERATION_EXECUTION_OPTIONS);
5717
- switch(result.exitCode){
5718
- case 0:
5719
- {
5720
- const occurrences = parseInt(result.output.trim(), 10) || 1;
5721
- return {
5722
- path: filePath,
5723
- filesUpdate: null,
5724
- occurrences
5725
- };
5726
- }
5727
- case 1:
5728
- return {
5729
- error: `String not found in file '${filePath}'`
5730
- };
5731
- case 2:
5732
- return {
5733
- error: `Multiple occurrences found in '${filePath}'. Use replaceAll=true to replace all.`
5734
- };
5735
- case 3:
5736
- return {
5737
- error: `Error: File '${filePath}' not found`
5738
- };
5739
- default:
5740
- return {
5741
- error: `Unknown error editing file '${filePath}'`
5742
- };
5743
- }
5846
+ return editCommandResult(filePath, result);
5744
5847
  }
5745
- /**
5746
- * Perform multiple sequential edits on a single file.
5747
- * All edits are applied sequentially, with each edit operating on the result of the previous edit.
5748
- * All edits must succeed for the operation to succeed (atomic).
5749
- */ async multiEdit(filePath, edits) {
5750
- if (!edits || edits.length === 0) {
5751
- return {
5752
- error: 'No edits provided'
5753
- };
5754
- }
5755
- const results = [];
5756
- for (const edit of edits){
5848
+ /** Earlier successful edits remain persisted if a later edit fails. */ multiEdit(filePath, edits) {
5849
+ return sequentialFileEdits(filePath, edits, (edit)=>{
5757
5850
  var _edit_replaceAll;
5758
- const result = await this.edit(filePath, edit.oldString, edit.newString, (_edit_replaceAll = edit.replaceAll) != null ? _edit_replaceAll : false);
5759
- results.push(result);
5760
- // If any edit fails, return immediately with error
5761
- if (result.error) {
5762
- return {
5763
- error: `Multi-edit failed at edit ${results.length}: ${result.error}`,
5764
- path: filePath,
5765
- filesUpdate: null,
5766
- results
5767
- };
5768
- }
5769
- }
5770
- // All edits succeeded
5771
- return {
5772
- path: filePath,
5773
- filesUpdate: null,
5774
- results
5775
- };
5851
+ return this.edit(filePath, edit.oldString, edit.newString, (_edit_replaceAll = edit.replaceAll) != null ? _edit_replaceAll : false);
5852
+ });
5776
5853
  }
5777
5854
  }
5778
5855
 
@@ -6445,6 +6522,22 @@ const ViewMiddlewareRuntimeCapability = modelProvider.createRuntimeCapability('p
6445
6522
  description: 'Resolve a View capability through its authorized Assistant middleware and scoped runtime.'
6446
6523
  });
6447
6524
 
6525
+ const ARTIFACT_PRESENTATION_PROVIDER = 'ARTIFACT_PRESENTATION_PROVIDER';
6526
+ const artifactPresentationKey = (source)=>`${source.pluginName}:${source.resourceType}`;
6527
+ /** Registers a read-only renderer for an explicit Artifact source, independently of Workbench actions. */ const ArtifactPresentationProvider = (source)=>common.applyDecorators(common.SetMetadata(ARTIFACT_PRESENTATION_PROVIDER, artifactPresentationKey(source)), common.SetMetadata(STRATEGY_META_KEY, ARTIFACT_PRESENTATION_PROVIDER));
6528
+ exports.ArtifactPresentationRegistry = class ArtifactPresentationRegistry extends BaseStrategyRegistry {
6529
+ constructor(discovery, reflector){
6530
+ super(ARTIFACT_PRESENTATION_PROVIDER, discovery, reflector);
6531
+ }
6532
+ };
6533
+ exports.ArtifactPresentationRegistry = __decorate([
6534
+ common.Injectable(),
6535
+ __metadata("design:paramtypes", [
6536
+ core.DiscoveryService,
6537
+ core.Reflector
6538
+ ])
6539
+ ], exports.ArtifactPresentationRegistry);
6540
+
6448
6541
  /** Platform-owned real-time collaboration capability available to scoped plugin runtimes. */ const CollaborationRuntimeCapability = modelProvider.createRuntimeCapability('platform.collaboration', {
6449
6542
  description: 'Create, synchronize, persist, authorize, and observe platform-managed real-time collaboration documents.'
6450
6543
  });
@@ -7074,8 +7167,8 @@ function agentContent(content) {
7074
7167
  }
7075
7168
 
7076
7169
  class DecoratedToolsetStrategy {
7077
- validateConfig() {
7078
- return Promise.resolve();
7170
+ async validateConfig(config) {
7171
+ await (this.instance.validateConfig == null ? void 0 : this.instance.validateConfig.call(this.instance, config));
7079
7172
  }
7080
7173
  async create(toolset, params) {
7081
7174
  return new DecoratedBuiltinToolset(this.instance, this.descriptor, toolset, params, this.pluginName, this.pluginVersion);
@@ -10321,9 +10414,272 @@ exports.ProjectTaskProviderRegistry = __decorate([
10321
10414
  ])
10322
10415
  ], exports.ProjectTaskProviderRegistry);
10323
10416
  const ProjectTasksRuntimeCapability = modelProvider.createRuntimeCapability('platform.project.tasks', {
10324
- description: 'Read project task graphs, manage schedules, and resolve exact execution conversations.'
10417
+ description: 'Read project task graphs, request background synchronization, manage schedules, and resolve exact execution conversations.'
10325
10418
  });
10326
10419
 
10420
+ const PROJECT_PIPELINE_CONTRIBUTION = 'PROJECT_PIPELINE_CONTRIBUTION';
10421
+ const ProjectPipelineContributor = (key)=>common.applyDecorators(common.SetMetadata(PROJECT_PIPELINE_CONTRIBUTION, key), common.SetMetadata(STRATEGY_META_KEY, PROJECT_PIPELINE_CONTRIBUTION));
10422
+ exports.ProjectPipelineContributionRegistry = class ProjectPipelineContributionRegistry extends BaseStrategyRegistry {
10423
+ upsert(instance) {
10424
+ const target = resolveStrategyMetadataTarget(instance);
10425
+ const key = target ? this.reflector.get(PROJECT_PIPELINE_CONTRIBUTION, target) : undefined;
10426
+ if (!key) return;
10427
+ const contribution = contracts.projectPipelineContributionSchema.parse(instance);
10428
+ if (key !== contribution.key) throw new Error('PIPELINE_CONTRIBUTION_KEY_MISMATCH');
10429
+ // Parsing above validates the original object's public fields before preserving loader provenance.
10430
+ const original = instance;
10431
+ this.registerParsed(key, original, contribution, this.getSource(original));
10432
+ }
10433
+ register(key, contribution, source) {
10434
+ return this.registerParsed(key, contribution, contracts.projectPipelineContributionSchema.parse(contribution), source);
10435
+ }
10436
+ registerParsed(key, contribution, validated, source) {
10437
+ // Parsed metadata is immutable and source-local: sharing a cached object would overwrite
10438
+ // the loader provenance held by the base registry when another scope registers it.
10439
+ const identity = JSON.stringify([
10440
+ source.kind,
10441
+ source.scopeKey,
10442
+ source.kind === 'plugin' ? source.pluginName : null
10443
+ ]);
10444
+ var _this_parsedContributions_get;
10445
+ const cache = (_this_parsedContributions_get = this.parsedContributions.get(contribution)) != null ? _this_parsedContributions_get : new Map();
10446
+ const cached = cache.get(identity);
10447
+ const parsed = cached && JSON.stringify(cached) === JSON.stringify(validated) ? cached : validated;
10448
+ if (parsed.key !== key) throw new Error('PIPELINE_CONTRIBUTION_KEY_MISMATCH');
10449
+ freezeMetadata(parsed);
10450
+ const previous = super.register(key, parsed, source);
10451
+ cache.set(identity, parsed);
10452
+ this.parsedContributions.set(contribution, cache);
10453
+ return previous;
10454
+ }
10455
+ assertCanRegister(key, contribution, source) {
10456
+ var _this_strategies_get;
10457
+ const existing = (_this_strategies_get = this.strategies.get(source.scopeKey)) == null ? void 0 : _this_strategies_get.get(key);
10458
+ if (existing) {
10459
+ const owner = this.getSource(existing);
10460
+ if (owner.kind !== source.kind || owner.kind === 'plugin' && source.kind === 'plugin' && owner.pluginName !== source.pluginName) {
10461
+ throw new Error('PIPELINE_CONTRIBUTION_OWNER_CONFLICT');
10462
+ }
10463
+ for (const previous of existing.configurations){
10464
+ const replacement = contribution.configurations.find((item)=>item.template.key === previous.template.key && item.template.version === previous.template.version);
10465
+ if (replacement && canonicalJson(previous.template) !== canonicalJson(replacement.template)) {
10466
+ throw new Error('PIPELINE_DEFINITION_VERSION_IMMUTABLE');
10467
+ }
10468
+ }
10469
+ }
10470
+ super.assertCanRegister(key, contribution, source);
10471
+ }
10472
+ /** Explicit actor scope prevents a delegated call from inheriting an unrelated ambient tenant. */ listForActor(actor) {
10473
+ if (!actor.tenantId) return [];
10474
+ const tenantScope = actor.tenantId === getDefaultTenantId() ? GLOBAL_ORGANIZATION_SCOPE : getTenantGlobalScopeKey(actor.tenantId);
10475
+ const scopes = [
10476
+ ...new Set([
10477
+ actor.organizationId || tenantScope,
10478
+ tenantScope,
10479
+ SYSTEM_GLOBAL_SCOPE,
10480
+ BUILTIN_GLOBAL_SCOPE
10481
+ ])
10482
+ ];
10483
+ const effective = new Map();
10484
+ for (const scope of scopes){
10485
+ var _this_strategies_get;
10486
+ for (const [key, value] of (_this_strategies_get = this.strategies.get(scope)) != null ? _this_strategies_get : []){
10487
+ if (!effective.has(key)) effective.set(key, value);
10488
+ }
10489
+ }
10490
+ return Array.from(effective.values());
10491
+ }
10492
+ constructor(discovery, reflector){
10493
+ super(PROJECT_PIPELINE_CONTRIBUTION, discovery, reflector);
10494
+ this.parsedContributions = new WeakMap();
10495
+ }
10496
+ };
10497
+ exports.ProjectPipelineContributionRegistry = __decorate([
10498
+ common.Injectable(),
10499
+ __metadata("design:paramtypes", [
10500
+ core.DiscoveryService,
10501
+ core.Reflector
10502
+ ])
10503
+ ], exports.ProjectPipelineContributionRegistry);
10504
+ /** Only validated JSON metadata is frozen; live adapter instances retain their own lifecycle. */ function freezeMetadata(value) {
10505
+ if (value === null || typeof value !== 'object' || Object.isFrozen(value)) return;
10506
+ for (const child of Object.values(value))freezeMetadata(child);
10507
+ Object.freeze(value);
10508
+ }
10509
+ function canonicalJson(value) {
10510
+ if (value === null || typeof value !== 'object') return JSON.stringify(value);
10511
+ if (Array.isArray(value)) return `[${value.map(canonicalJson).join(',')}]`;
10512
+ return `{${Object.keys(value).sort().filter((key)=>value[key] !== undefined).map((key)=>`${JSON.stringify(key)}:${canonicalJson(value[key])}`).join(',')}}`;
10513
+ }
10514
+
10515
+ const ProjectPipelinePortfolioRuntimeCapability = modelProvider.createRuntimeCapability('platform.project.pipeline_portfolio', {
10516
+ description: 'Compare explicitly selected authorized Projects in one consistent snapshot.'
10517
+ });
10518
+ const ProjectPipelineAnalyticsRuntimeCapability = modelProvider.createRuntimeCapability('platform.project.pipeline_analytics', {
10519
+ description: 'Read Project-scoped cross-instance execution cohorts without replaying provider callbacks.'
10520
+ });
10521
+ const ProjectPipelineProviderActionsRuntimeCapability = modelProvider.createRuntimeCapability('platform.project.pipeline_provider_actions', {
10522
+ description: 'Submit version-bound provider actions through a durable, inspect-only recovery outbox.'
10523
+ });
10524
+ const ProjectPipelineEvidenceRuntimeCapability = modelProvider.createRuntimeCapability('platform.project.pipeline_evidence', {
10525
+ description: 'Read authorized, versioned pipeline evidence through its registered resolver.'
10526
+ });
10527
+ const ProjectPipelineCatalogRuntimeCapability = modelProvider.createRuntimeCapability('platform.project.pipeline_catalog', {
10528
+ description: 'Discover plugin-declared configuration forms and save authorized Project bindings.'
10529
+ });
10530
+ const ProjectPipelineConfigurationRuntimeCapability = modelProvider.createRuntimeCapability('platform.project.pipeline_configuration', {
10531
+ description: 'Check generic project pipeline configuration and registered extension dependencies without starting work.'
10532
+ });
10533
+ const ProjectPipelinesRuntimeCapability = modelProvider.createRuntimeCapability('platform.project.pipelines', {
10534
+ description: 'Read saved pipeline graphs and enqueue instance-scoped provider projections.'
10535
+ });
10536
+ const ProjectPipelineCommandsRuntimeCapability = modelProvider.createRuntimeCapability('platform.project.pipeline_commands', {
10537
+ description: 'Configure and start managed pipelines, and submit authorized version-bound human decisions.'
10538
+ });
10539
+
10540
+ function pipelineActorScopeKeys(actor) {
10541
+ if (!actor.tenantId) return [];
10542
+ const tenant = actor.tenantId === getDefaultTenantId() ? GLOBAL_ORGANIZATION_SCOPE : getTenantGlobalScopeKey(actor.tenantId);
10543
+ return [
10544
+ ...new Set([
10545
+ actor.organizationId || tenant,
10546
+ tenant,
10547
+ SYSTEM_GLOBAL_SCOPE,
10548
+ BUILTIN_GLOBAL_SCOPE
10549
+ ])
10550
+ ];
10551
+ }
10552
+ /** Public capabilities resolve from their explicit, authorized actor, never another ambient request. */ class ProjectPipelineScopedRegistry extends BaseStrategyRegistry {
10553
+ assertCanRegister(key, instance, source) {
10554
+ var _this_strategies_get;
10555
+ const existing = (_this_strategies_get = this.strategies.get(source.scopeKey)) == null ? void 0 : _this_strategies_get.get(key);
10556
+ if (existing) {
10557
+ const owner = this.getSource(existing);
10558
+ if (owner.kind !== source.kind || owner.kind === 'plugin' && source.kind === 'plugin' && owner.pluginName !== source.pluginName) throw new Error('PIPELINE_ADAPTER_OWNER_CONFLICT');
10559
+ }
10560
+ // Live adapters cannot be cloned safely. Require a distinct instance for each provenance
10561
+ // so registration in one scope cannot silently change ownership in another.
10562
+ for (const [scope, entries] of this.strategies){
10563
+ if (![
10564
+ ...entries.values()
10565
+ ].includes(instance)) continue;
10566
+ const owner = this.getSource(instance);
10567
+ if (scope !== source.scopeKey || owner.kind !== source.kind || owner.kind === 'plugin' && source.kind === 'plugin' && owner.pluginName !== source.pluginName) throw new Error('PIPELINE_ADAPTER_SOURCE_CONFLICT');
10568
+ }
10569
+ super.assertCanRegister(key, instance, source);
10570
+ }
10571
+ upsert(instance) {
10572
+ const target = resolveStrategyMetadataTarget(instance);
10573
+ const key = target ? this.reflector.get(this.strategyKey, target) : undefined;
10574
+ if (key) this.register(key, instance, this.getSource(instance));
10575
+ }
10576
+ listForActor(actor) {
10577
+ const effective = new Map();
10578
+ var _this_strategies_get;
10579
+ for (const scope of pipelineActorScopeKeys(actor))for (const [key, adapter] of (_this_strategies_get = this.strategies.get(scope)) != null ? _this_strategies_get : []){
10580
+ if (!effective.has(key)) effective.set(key, adapter);
10581
+ }
10582
+ return [
10583
+ ...effective.values()
10584
+ ];
10585
+ }
10586
+ getForActor(key, actor) {
10587
+ for (const scope of pipelineActorScopeKeys(actor)){
10588
+ var _this_strategies_get;
10589
+ const adapter = (_this_strategies_get = this.strategies.get(scope)) == null ? void 0 : _this_strategies_get.get(key);
10590
+ if (adapter) return adapter;
10591
+ }
10592
+ throw new Error('PIPELINE_ADAPTER_UNAVAILABLE');
10593
+ }
10594
+ }
10595
+
10596
+ const PROJECT_PIPELINE_PROJECTION_PROVIDER = 'PROJECT_PIPELINE_PROJECTION_PROVIDER';
10597
+ const ProjectPipelineProjectionProvider = (key)=>common.applyDecorators(common.SetMetadata(PROJECT_PIPELINE_PROJECTION_PROVIDER, key), common.SetMetadata(STRATEGY_META_KEY, PROJECT_PIPELINE_PROJECTION_PROVIDER));
10598
+ exports.ProjectPipelineProjectionProviderRegistry = class ProjectPipelineProjectionProviderRegistry extends ProjectPipelineScopedRegistry {
10599
+ register(key, provider, source) {
10600
+ contracts.projectPipelineRefSchema.parse(key);
10601
+ if (provider.key !== key) throw new Error('PIPELINE_PROVIDER_KEY_MISMATCH');
10602
+ // Registration checks the extension shape without executing business callbacks. A future
10603
+ // protocol must be negotiated explicitly rather than silently treated as a legacy provider.
10604
+ if (provider.nativeTaskProtocol !== undefined && provider.nativeTaskProtocol !== 1) throw new Error('PIPELINE_PROVIDER_PROTOCOL_UNSUPPORTED');
10605
+ if (typeof provider.snapshot !== 'function') throw new Error('PIPELINE_PROVIDER_CONTRACT_INVALID');
10606
+ for (const name of [
10607
+ 'linked',
10608
+ 'describeNode',
10609
+ 'actions',
10610
+ 'executeAction',
10611
+ 'inspectAction'
10612
+ ]){
10613
+ if (provider[name] !== undefined && typeof provider[name] !== 'function') throw new Error('PIPELINE_PROVIDER_CONTRACT_INVALID');
10614
+ }
10615
+ if (provider.executeAction === undefined !== (provider.inspectAction === undefined) || provider.actions !== undefined && provider.executeAction === undefined) throw new Error('PIPELINE_PROVIDER_CONTRACT_INVALID');
10616
+ return super.register(key, provider, source);
10617
+ }
10618
+ constructor(discovery, reflector){
10619
+ super(PROJECT_PIPELINE_PROJECTION_PROVIDER, discovery, reflector);
10620
+ }
10621
+ };
10622
+ exports.ProjectPipelineProjectionProviderRegistry = __decorate([
10623
+ common.Injectable(),
10624
+ __metadata("design:paramtypes", [
10625
+ core.DiscoveryService,
10626
+ core.Reflector
10627
+ ])
10628
+ ], exports.ProjectPipelineProjectionProviderRegistry);
10629
+
10630
+ const PROJECT_PIPELINE_RUNTIME_ADAPTER = 'PROJECT_PIPELINE_RUNTIME_ADAPTER';
10631
+ const ProjectPipelineRuntimeAdapterProvider = (kind, ref)=>common.applyDecorators(common.SetMetadata(PROJECT_PIPELINE_RUNTIME_ADAPTER, `${kind}:${contracts.projectPipelineRefSchema.parse(ref)}`), common.SetMetadata(STRATEGY_META_KEY, PROJECT_PIPELINE_RUNTIME_ADAPTER));
10632
+ exports.ProjectPipelineRuntimeAdapterRegistry = class ProjectPipelineRuntimeAdapterRegistry extends ProjectPipelineScopedRegistry {
10633
+ register(key, adapter, source) {
10634
+ contracts.projectPipelineRefSchema.parse(adapter.ref);
10635
+ if (key !== `${adapter.kind}:${adapter.ref}`) throw new Error('PIPELINE_ADAPTER_KEY_MISMATCH');
10636
+ switch(adapter.kind){
10637
+ case 'resource':
10638
+ if (typeof adapter.resolve !== 'function') throw new Error('PIPELINE_ADAPTER_CONTRACT_INVALID');
10639
+ break;
10640
+ case 'assistant_operation':
10641
+ case 'runtime_operation':
10642
+ if (typeof adapter.prepare !== 'function' || typeof adapter.collect !== 'function') throw new Error('PIPELINE_ADAPTER_CONTRACT_INVALID');
10643
+ break;
10644
+ case 'schema':
10645
+ if (typeof adapter.parse !== 'function') throw new Error('PIPELINE_ADAPTER_CONTRACT_INVALID');
10646
+ break;
10647
+ case 'subject':
10648
+ if (typeof adapter.resolve !== 'function' || typeof adapter.checkCurrent !== 'function') throw new Error('PIPELINE_ADAPTER_CONTRACT_INVALID');
10649
+ break;
10650
+ case 'evidence':
10651
+ if (typeof adapter.read !== 'function') throw new Error('PIPELINE_ADAPTER_CONTRACT_INVALID');
10652
+ break;
10653
+ case 'operation':
10654
+ case 'subscription':
10655
+ if (typeof adapter.execute !== 'function' || typeof adapter.inspect !== 'function') throw new Error('PIPELINE_ADAPTER_CONTRACT_INVALID');
10656
+ break;
10657
+ case 'completion':
10658
+ case 'policy':
10659
+ if (typeof adapter.evaluate !== 'function') throw new Error('PIPELINE_ADAPTER_CONTRACT_INVALID');
10660
+ break;
10661
+ default:
10662
+ throw new Error('PIPELINE_ADAPTER_CONTRACT_INVALID');
10663
+ }
10664
+ return super.register(key, adapter, source);
10665
+ }
10666
+ resolve(kind, ref, actor) {
10667
+ const adapter = this.getForActor(`${kind}:${ref}`, actor);
10668
+ if (adapter.kind !== kind || adapter.ref !== ref) throw new Error('PIPELINE_ADAPTER_KEY_MISMATCH');
10669
+ return adapter;
10670
+ }
10671
+ constructor(discovery, reflector){
10672
+ super(PROJECT_PIPELINE_RUNTIME_ADAPTER, discovery, reflector);
10673
+ }
10674
+ };
10675
+ exports.ProjectPipelineRuntimeAdapterRegistry = __decorate([
10676
+ common.Injectable(),
10677
+ __metadata("design:paramtypes", [
10678
+ core.DiscoveryService,
10679
+ core.Reflector
10680
+ ])
10681
+ ], exports.ProjectPipelineRuntimeAdapterRegistry);
10682
+
10327
10683
  /** Import official resource packages for the authenticated organization administrator. Does not authorize workspaces. */ class ImportDefaultAgentPluginsCommand extends cqrs.Command {
10328
10684
  }
10329
10685
  ImportDefaultAgentPluginsCommand.type = '[Agent Plugins] Import defaults';
@@ -10359,6 +10715,10 @@ Object.defineProperty(exports, "parseResourceCard", {
10359
10715
  enumerable: true,
10360
10716
  get: function () { return contracts.parseResourceCard; }
10361
10717
  });
10718
+ Object.defineProperty(exports, "projectPipelineContributionSchema", {
10719
+ enumerable: true,
10720
+ get: function () { return contracts.projectPipelineContributionSchema; }
10721
+ });
10362
10722
  Object.defineProperty(exports, "resourceCardId", {
10363
10723
  enumerable: true,
10364
10724
  get: function () { return contracts.resourceCardId; }
@@ -10372,10 +10732,12 @@ exports.BaseToolset = modelProvider.BaseToolset;
10372
10732
  exports.BuiltinToolset = modelProvider.BuiltinToolset;
10373
10733
  exports.DefaultAgentMiddlewareRuntimeCapabilityRegistry = modelProvider.DefaultRuntimeCapabilityRegistry;
10374
10734
  exports.DefaultRuntimeCapabilityRegistry = modelProvider.DefaultRuntimeCapabilityRegistry;
10735
+ exports.McpClientRuntimeCapability = modelProvider.McpClientRuntimeCapability;
10375
10736
  exports.ModelProviderBuiltinToolset = modelProvider.ModelProviderBuiltinToolset;
10376
10737
  exports.ProjectAccessRuntimeCapability = modelProvider.ProjectAccessRuntimeCapability;
10377
10738
  exports.ProjectProvisioningRuntimeCapability = modelProvider.ProjectProvisioningRuntimeCapability;
10378
10739
  exports.RUNTIME_CAPABILITY_PROVIDER = modelProvider.RUNTIME_CAPABILITY_PROVIDER;
10740
+ exports.RestClientRuntimeCapability = modelProvider.RestClientRuntimeCapability;
10379
10741
  exports.RuntimeCapabilityProvider = modelProvider.RuntimeCapabilityProvider;
10380
10742
  exports.SANDBOX_JOB_ERROR_CODES = modelProvider.SANDBOX_JOB_ERROR_CODES;
10381
10743
  exports.SANDBOX_JOB_INVOCATION_PREFIX = modelProvider.SANDBOX_JOB_INVOCATION_PREFIX;
@@ -10432,6 +10794,7 @@ exports.AIModelProviderNotFoundException = AIModelProviderNotFoundException;
10432
10794
  exports.AIModelProviderStrategy = AIModelProviderStrategy;
10433
10795
  exports.AI_MODEL_PROVIDER = AI_MODEL_PROVIDER;
10434
10796
  exports.ANALYTICS_PROVIDER = ANALYTICS_PROVIDER;
10797
+ exports.ARTIFACT_PRESENTATION_PROVIDER = ARTIFACT_PRESENTATION_PROVIDER;
10435
10798
  exports.ASSISTANT_CAPABILITY_PROVIDER = ASSISTANT_CAPABILITY_PROVIDER;
10436
10799
  exports.AdapterDataSourceStrategy = AdapterDataSourceStrategy;
10437
10800
  exports.AgentExecutionRunnerCapability = AgentExecutionRunnerCapability;
@@ -10443,6 +10806,7 @@ exports.AgentRuntimeStrategy = AgentRuntimeStrategy;
10443
10806
  exports.AiModelNotFoundException = AiModelNotFoundException;
10444
10807
  exports.AnalyticsProvider = AnalyticsProvider;
10445
10808
  exports.AnalyticsRuntimeCapability = AnalyticsRuntimeCapability;
10809
+ exports.ArtifactPresentationProvider = ArtifactPresentationProvider;
10446
10810
  exports.AssistantCapabilityProvider = AssistantCapabilityProvider;
10447
10811
  exports.AssistantTaskRuntimeCapability = AssistantTaskRuntimeCapability;
10448
10812
  exports.BOUND_IDENTITY_LOGIN_PERMISSION_SERVICE_TOKEN = BOUND_IDENTITY_LOGIN_PERMISSION_SERVICE_TOKEN;
@@ -10543,6 +10907,9 @@ exports.PLUGIN_METADATA_KEY = PLUGIN_METADATA_KEY;
10543
10907
  exports.PLUGIN_VERSION_METADATA_KEY = PLUGIN_VERSION_METADATA_KEY;
10544
10908
  exports.PLUGIN_WEBHOOK_AUTH_METADATA_KEY = PLUGIN_WEBHOOK_AUTH_METADATA_KEY;
10545
10909
  exports.PLUGIN_WEBHOOK_AUTH_SERVICE_TOKEN = PLUGIN_WEBHOOK_AUTH_SERVICE_TOKEN;
10910
+ exports.PROJECT_PIPELINE_CONTRIBUTION = PROJECT_PIPELINE_CONTRIBUTION;
10911
+ exports.PROJECT_PIPELINE_PROJECTION_PROVIDER = PROJECT_PIPELINE_PROJECTION_PROVIDER;
10912
+ exports.PROJECT_PIPELINE_RUNTIME_ADAPTER = PROJECT_PIPELINE_RUNTIME_ADAPTER;
10546
10913
  exports.PROJECT_TASK_PROVIDER = PROJECT_TASK_PROVIDER;
10547
10914
  exports.PROJECT_TYPE_PROVIDER = PROJECT_TYPE_PROVIDER;
10548
10915
  exports.PROVIDE_AI_MODEL_LLM = PROVIDE_AI_MODEL_LLM;
@@ -10553,6 +10920,17 @@ exports.PROVIDE_AI_MODEL_TEXT_EMBEDDING = PROVIDE_AI_MODEL_TEXT_EMBEDDING;
10553
10920
  exports.PROVIDE_AI_MODEL_TTS = PROVIDE_AI_MODEL_TTS;
10554
10921
  exports.PluginJobProcessor = PluginJobProcessor;
10555
10922
  exports.PluginWebhookAuth = PluginWebhookAuth;
10923
+ exports.ProjectPipelineAnalyticsRuntimeCapability = ProjectPipelineAnalyticsRuntimeCapability;
10924
+ exports.ProjectPipelineCatalogRuntimeCapability = ProjectPipelineCatalogRuntimeCapability;
10925
+ exports.ProjectPipelineCommandsRuntimeCapability = ProjectPipelineCommandsRuntimeCapability;
10926
+ exports.ProjectPipelineConfigurationRuntimeCapability = ProjectPipelineConfigurationRuntimeCapability;
10927
+ exports.ProjectPipelineContributor = ProjectPipelineContributor;
10928
+ exports.ProjectPipelineEvidenceRuntimeCapability = ProjectPipelineEvidenceRuntimeCapability;
10929
+ exports.ProjectPipelinePortfolioRuntimeCapability = ProjectPipelinePortfolioRuntimeCapability;
10930
+ exports.ProjectPipelineProjectionProvider = ProjectPipelineProjectionProvider;
10931
+ exports.ProjectPipelineProviderActionsRuntimeCapability = ProjectPipelineProviderActionsRuntimeCapability;
10932
+ exports.ProjectPipelineRuntimeAdapterProvider = ProjectPipelineRuntimeAdapterProvider;
10933
+ exports.ProjectPipelinesRuntimeCapability = ProjectPipelinesRuntimeCapability;
10556
10934
  exports.ProjectTaskProvider = ProjectTaskProvider;
10557
10935
  exports.ProjectTasksRuntimeCapability = ProjectTasksRuntimeCapability;
10558
10936
  exports.ProjectTypeProvider = ProjectTypeProvider;
@@ -10631,6 +11009,8 @@ exports.agentRuntimeResultConsumptionKey = agentRuntimeResultConsumptionKey;
10631
11009
  exports.als = als;
10632
11010
  exports.appendSandboxMessage = appendSandboxMessage;
10633
11011
  exports.applyModelConfiguration = applyModelConfiguration;
11012
+ exports.applyModelContextSize = applyModelContextSize;
11013
+ exports.artifactPresentationKey = artifactPresentationKey;
10634
11014
  exports.buildSandboxTimeoutMessage = buildSandboxTimeoutMessage;
10635
11015
  exports.calcTokenUsage = calcTokenUsage;
10636
11016
  exports.calculateLLMUsagePrice = calculateLLMUsagePrice;
@@ -10691,6 +11071,7 @@ exports.normalizeTokenUsage = normalizeTokenUsage;
10691
11071
  exports.pluginArtifactTableName = pluginArtifactTableName;
10692
11072
  exports.prepareToolResult = prepareToolResult;
10693
11073
  exports.processAsyncAIGCManagedJob = processAsyncAIGCManagedJob;
11074
+ exports.projectPipelineInvocationScopeSchema = projectPipelineInvocationScopeSchema;
10694
11075
  exports.renderRemoteModuleIframeHtml = renderRemoteModuleIframeHtml;
10695
11076
  exports.renderRemoteReactIframeHtml = renderRemoteReactIframeHtml;
10696
11077
  exports.renderRemoteVueIframeHtml = renderRemoteVueIframeHtml;
@@ -10712,3 +11093,4 @@ exports.setDefaultTenantId = setDefaultTenantId;
10712
11093
  exports.sumTokenUsage = sumTokenUsage;
10713
11094
  exports.taskWaitReason = taskWaitReason;
10714
11095
  exports.textTokenBoundaries = textTokenBoundaries;
11096
+ exports.validateAnalyticsPayload = validateAnalyticsPayload;