mulesoft-anypoint-cli-agent-fabric-plugin 1.0.11 → 1.1.1-beta
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/LICENSE.txt +89 -0
- package/README.md +51 -27
- package/dist/commands/agent-network/project/build.d.ts +1 -1
- package/dist/commands/agent-network/project/build.js +21 -14
- package/dist/commands/agent-network/project/build.js.map +1 -1
- package/dist/commands/agent-network/project/create.d.ts +4 -1
- package/dist/commands/agent-network/project/create.js +67 -39
- package/dist/commands/agent-network/project/create.js.map +1 -1
- package/dist/commands/agent-network/project/deploy.d.ts +8 -4
- package/dist/commands/agent-network/project/deploy.js +195 -78
- package/dist/commands/agent-network/project/deploy.js.map +1 -1
- package/dist/commands/agent-network/project/mcp/introspect.d.ts +226 -0
- package/dist/commands/agent-network/project/mcp/introspect.js +910 -0
- package/dist/commands/agent-network/project/mcp/introspect.js.map +1 -0
- package/dist/commands/agent-network/project/publish.d.ts +2 -4
- package/dist/commands/agent-network/project/publish.js +44 -50
- package/dist/commands/agent-network/project/publish.js.map +1 -1
- package/dist/commands/agent-network/project/undeploy.d.ts +29 -0
- package/dist/commands/agent-network/project/undeploy.js +142 -0
- package/dist/commands/agent-network/project/undeploy.js.map +1 -0
- package/dist/commands/agent-network/project/unpublish.d.ts +28 -0
- package/dist/commands/agent-network/project/unpublish.js +143 -0
- package/dist/commands/agent-network/project/unpublish.js.map +1 -0
- package/dist/commands/agent-network/setup/dependencies.js +11 -8
- package/dist/commands/agent-network/setup/dependencies.js.map +1 -1
- package/dist/commands/agent-network/setup/gateways.d.ts +10 -4
- package/dist/commands/agent-network/setup/gateways.js +160 -97
- package/dist/commands/agent-network/setup/gateways.js.map +1 -1
- package/dist/errors/base-error.js +5 -0
- package/dist/errors/base-error.js.map +1 -1
- package/dist/errors/error-factory.d.ts +80 -16
- package/dist/errors/error-factory.js +348 -69
- package/dist/errors/error-factory.js.map +1 -1
- package/dist/helpers/connection-id.js +6 -2
- package/dist/helpers/connection-id.js.map +1 -1
- package/dist/helpers/connection.d.ts +20 -0
- package/dist/helpers/connection.js +93 -0
- package/dist/helpers/connection.js.map +1 -0
- package/dist/helpers/dependency-manager.d.ts +2 -2
- package/dist/helpers/dependency-manager.js +18 -12
- package/dist/helpers/dependency-manager.js.map +1 -1
- package/dist/helpers/entitlement-utils.js +8 -3
- package/dist/helpers/entitlement-utils.js.map +1 -1
- package/dist/helpers/policy-helper.d.ts +27 -29
- package/dist/helpers/policy-helper.js +125 -55
- package/dist/helpers/policy-helper.js.map +1 -1
- package/dist/helpers/project/api-project-dependency-fetcher.js +18 -14
- package/dist/helpers/project/api-project-dependency-fetcher.js.map +1 -1
- package/dist/helpers/project/constants.d.ts +4 -4
- package/dist/helpers/project/constants.js +10 -3
- package/dist/helpers/project/constants.js.map +1 -1
- package/dist/helpers/project/debug-messages.js +5 -0
- package/dist/helpers/project/debug-messages.js.map +1 -1
- package/dist/helpers/project/templates.js +6 -1
- package/dist/helpers/project/templates.js.map +1 -1
- package/dist/helpers/project/uris.js +5 -0
- package/dist/helpers/project/uris.js.map +1 -1
- package/dist/helpers/project/validation-commons.d.ts +4 -0
- package/dist/helpers/project/validation-commons.js +33 -5
- package/dist/helpers/project/validation-commons.js.map +1 -1
- package/dist/helpers/request-logging.d.ts +36 -0
- package/dist/helpers/request-logging.js +185 -0
- package/dist/helpers/request-logging.js.map +1 -0
- package/dist/helpers/request-utils.d.ts +1 -1
- package/dist/helpers/request-utils.js +6 -1
- package/dist/helpers/request-utils.js.map +1 -1
- package/dist/helpers/types.js +5 -0
- package/dist/helpers/types.js.map +1 -1
- package/dist/helpers/utils.d.ts +23 -15
- package/dist/helpers/utils.js +206 -104
- package/dist/helpers/utils.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +18 -9
- package/dist/index.js.map +1 -1
- package/dist/resources/mcp-server-schema.json +574 -0
- package/dist/types/agent-network-v2.d.ts +379 -0
- package/dist/types/agent-network-v2.js +28 -0
- package/dist/types/agent-network-v2.js.map +1 -0
- package/dist/types/agent-network.d.ts +226 -219
- package/dist/types/agent-network.js +16 -14
- package/dist/types/agent-network.js.map +1 -1
- package/dist/types/types.d.ts +57 -17
- package/dist/types/types.js +5 -0
- package/dist/types/types.js.map +1 -1
- package/dist/utils/access-management.js +7 -1
- package/dist/utils/access-management.js.map +1 -1
- package/dist/utils/builders/builder.d.ts +12 -0
- package/dist/utils/builders/builder.js +215 -11
- package/dist/utils/builders/builder.js.map +1 -1
- package/dist/utils/builders/common/agent-metadata.d.ts +21 -0
- package/dist/utils/builders/common/agent-metadata.js +73 -0
- package/dist/utils/builders/common/agent-metadata.js.map +1 -0
- package/dist/utils/builders/common/asset-file-resolver.d.ts +3 -0
- package/dist/utils/builders/common/asset-file-resolver.js +33 -0
- package/dist/utils/builders/common/asset-file-resolver.js.map +1 -0
- package/dist/utils/builders/common/connection-facet-helpers.d.ts +26 -0
- package/dist/utils/builders/common/connection-facet-helpers.js +47 -0
- package/dist/utils/builders/common/connection-facet-helpers.js.map +1 -0
- package/dist/utils/builders/common/connection-metadata.d.ts +5 -0
- package/dist/utils/builders/common/connection-metadata.js +25 -0
- package/dist/utils/builders/common/connection-metadata.js.map +1 -0
- package/dist/utils/builders/common/network-builder-helpers.d.ts +7 -0
- package/dist/utils/builders/common/network-builder-helpers.js +25 -0
- package/dist/utils/builders/common/network-builder-helpers.js.map +1 -0
- package/dist/utils/builders/common/network-metadata.d.ts +5 -0
- package/dist/utils/builders/common/network-metadata.js +26 -0
- package/dist/utils/builders/common/network-metadata.js.map +1 -0
- package/dist/utils/builders/common/registry-entry.d.ts +2 -0
- package/dist/utils/builders/common/registry-entry.js +21 -0
- package/dist/utils/builders/common/registry-entry.js.map +1 -0
- package/dist/utils/builders/common/types.d.ts +38 -0
- package/dist/utils/builders/common/types.js +8 -0
- package/dist/utils/builders/common/types.js.map +1 -0
- package/dist/utils/builders/network-lock.d.ts +38 -0
- package/dist/utils/builders/network-lock.js +108 -0
- package/dist/utils/builders/network-lock.js.map +1 -0
- package/dist/utils/builders/policies-factory.d.ts +8 -1
- package/dist/utils/builders/policies-factory.js +43 -10
- package/dist/utils/builders/policies-factory.js.map +1 -1
- package/dist/utils/builders/project-builder-impl.d.ts +70 -17
- package/dist/utils/builders/project-builder-impl.js +189 -28
- package/dist/utils/builders/project-builder-impl.js.map +1 -1
- package/dist/utils/builders/project-builder.d.ts +75 -11
- package/dist/utils/builders/project-builder.js +18 -3
- package/dist/utils/builders/project-builder.js.map +1 -1
- package/dist/utils/builders/remote-space-resolver.d.ts +21 -0
- package/dist/utils/builders/remote-space-resolver.js +232 -0
- package/dist/utils/builders/remote-space-resolver.js.map +1 -0
- package/dist/utils/builders/space-serializer.d.ts +16 -2
- package/dist/utils/builders/space-serializer.js +136 -29
- package/dist/utils/builders/space-serializer.js.map +1 -1
- package/dist/utils/builders/tooling-metadata.d.ts +8 -0
- package/dist/utils/builders/tooling-metadata.js +69 -0
- package/dist/utils/builders/tooling-metadata.js.map +1 -0
- package/dist/utils/builders/v1/agent-builder.d.ts +15 -0
- package/dist/utils/builders/v1/agent-builder.js +78 -0
- package/dist/utils/builders/v1/agent-builder.js.map +1 -0
- package/dist/utils/builders/{broker-builder.d.ts → v1/broker-builder.d.ts} +8 -1
- package/dist/utils/builders/v1/broker-builder.js +259 -0
- package/dist/utils/builders/v1/broker-builder.js.map +1 -0
- package/dist/utils/builders/{connections-builder.d.ts → v1/connections-builder.d.ts} +4 -3
- package/dist/utils/builders/v1/connections-builder.js +189 -0
- package/dist/utils/builders/v1/connections-builder.js.map +1 -0
- package/dist/utils/builders/{llm-builder.d.ts → v1/llm-builder.d.ts} +5 -2
- package/dist/utils/builders/v1/llm-builder.js +76 -0
- package/dist/utils/builders/v1/llm-builder.js.map +1 -0
- package/dist/utils/builders/{mcp-builder.d.ts → v1/mcp-builder.d.ts} +5 -2
- package/dist/utils/builders/v1/mcp-builder.js +64 -0
- package/dist/utils/builders/v1/mcp-builder.js.map +1 -0
- package/dist/utils/builders/{network-builder.d.ts → v1/network-builder.d.ts} +2 -1
- package/dist/utils/builders/v1/network-builder.js +79 -0
- package/dist/utils/builders/v1/network-builder.js.map +1 -0
- package/dist/utils/builders/{path.d.ts → v1/path.d.ts} +1 -1
- package/dist/utils/builders/{path.js → v1/path.js} +6 -1
- package/dist/utils/builders/v1/path.js.map +1 -0
- package/dist/utils/builders/v2/agent-builder.d.ts +17 -0
- package/dist/utils/builders/v2/agent-builder.js +142 -0
- package/dist/utils/builders/v2/agent-builder.js.map +1 -0
- package/dist/utils/builders/v2/broker-builder.d.ts +21 -0
- package/dist/utils/builders/v2/broker-builder.js +168 -0
- package/dist/utils/builders/v2/broker-builder.js.map +1 -0
- package/dist/utils/builders/v2/connections-builder.d.ts +18 -0
- package/dist/utils/builders/v2/connections-builder.js +196 -0
- package/dist/utils/builders/v2/connections-builder.js.map +1 -0
- package/dist/utils/builders/v2/llm-builder.d.ts +11 -0
- package/dist/utils/builders/v2/llm-builder.js +68 -0
- package/dist/utils/builders/v2/llm-builder.js.map +1 -0
- package/dist/utils/builders/v2/mcp-builder.d.ts +10 -0
- package/dist/utils/builders/v2/mcp-builder.js +66 -0
- package/dist/utils/builders/v2/mcp-builder.js.map +1 -0
- package/dist/utils/builders/v2/network-builder.d.ts +14 -0
- package/dist/utils/builders/v2/network-builder.js +123 -0
- package/dist/utils/builders/v2/network-builder.js.map +1 -0
- package/dist/utils/builders/v2/path.d.ts +12 -0
- package/dist/utils/builders/v2/path.js +46 -0
- package/dist/utils/builders/v2/path.js.map +1 -0
- package/dist/utils/constants.d.ts +42 -2
- package/dist/utils/constants.js +61 -5
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/exchange.d.ts +5 -6
- package/dist/utils/exchange.js +83 -73
- package/dist/utils/exchange.js.map +1 -1
- package/dist/utils/facets/abstract-facet.d.ts +4 -28
- package/dist/utils/facets/abstract-facet.js +10 -29
- package/dist/utils/facets/abstract-facet.js.map +1 -1
- package/dist/utils/facets/agent-graph-facet.d.ts +17 -0
- package/dist/utils/facets/agent-graph-facet.js +276 -0
- package/dist/utils/facets/agent-graph-facet.js.map +1 -0
- package/dist/utils/facets/api-instance-facet.d.ts +4 -2
- package/dist/utils/facets/api-instance-facet.js +54 -32
- package/dist/utils/facets/api-instance-facet.js.map +1 -1
- package/dist/utils/facets/apim-policy-helpers.d.ts +24 -0
- package/dist/utils/facets/apim-policy-helpers.js +43 -0
- package/dist/utils/facets/apim-policy-helpers.js.map +1 -0
- package/dist/utils/facets/asset-facet.d.ts +7 -3
- package/dist/utils/facets/asset-facet.js +158 -82
- package/dist/utils/facets/asset-facet.js.map +1 -1
- package/dist/utils/facets/connection-facet.d.ts +4 -2
- package/dist/utils/facets/connection-facet.js +54 -32
- package/dist/utils/facets/connection-facet.js.map +1 -1
- package/dist/utils/facets/deployment-helpers.d.ts +28 -1
- package/dist/utils/facets/deployment-helpers.js +87 -4
- package/dist/utils/facets/deployment-helpers.js.map +1 -1
- package/dist/utils/facets/deployment-runner.d.ts +12 -0
- package/dist/utils/facets/deployment-runner.js +62 -0
- package/dist/utils/facets/deployment-runner.js.map +1 -0
- package/dist/utils/facets/facets.d.ts +4 -0
- package/dist/utils/facets/facets.js +98 -7
- package/dist/utils/facets/facets.js.map +1 -1
- package/dist/utils/facets/mule-application-facet.d.ts +3 -7
- package/dist/utils/facets/mule-application-facet.js +54 -85
- package/dist/utils/facets/mule-application-facet.js.map +1 -1
- package/dist/utils/facets/publication-metadata-patcher.d.ts +2 -0
- package/dist/utils/facets/publication-metadata-patcher.js +68 -0
- package/dist/utils/facets/publication-metadata-patcher.js.map +1 -0
- package/dist/utils/facets/publication-rank.d.ts +4 -0
- package/dist/utils/facets/publication-rank.js +33 -0
- package/dist/utils/facets/publication-rank.js.map +1 -0
- package/dist/utils/facets/undeploy-helpers.d.ts +6 -0
- package/dist/utils/facets/undeploy-helpers.js +73 -0
- package/dist/utils/facets/undeploy-helpers.js.map +1 -0
- package/dist/utils/facets/unpublish-preflight.d.ts +2 -0
- package/dist/utils/facets/unpublish-preflight.js +59 -0
- package/dist/utils/facets/unpublish-preflight.js.map +1 -0
- package/dist/utils/files.d.ts +0 -1
- package/dist/utils/files.js +15 -2
- package/dist/utils/files.js.map +1 -1
- package/dist/utils/gateway-mode.d.ts +22 -0
- package/dist/utils/gateway-mode.js +43 -0
- package/dist/utils/gateway-mode.js.map +1 -0
- package/dist/utils/gateway.d.ts +24 -6
- package/dist/utils/gateway.js +115 -35
- package/dist/utils/gateway.js.map +1 -1
- package/dist/utils/logger.d.ts +1 -0
- package/dist/utils/logger.js +25 -14
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/mcp/mcp-metadata-mapper.d.ts +26 -0
- package/dist/utils/mcp/mcp-metadata-mapper.js +58 -0
- package/dist/utils/mcp/mcp-metadata-mapper.js.map +1 -0
- package/dist/utils/mcp/project-registrar.d.ts +21 -0
- package/dist/utils/mcp/project-registrar.js +96 -0
- package/dist/utils/mcp/project-registrar.js.map +1 -0
- package/dist/utils/mcp/registry-key.d.ts +7 -0
- package/dist/utils/mcp/registry-key.js +72 -0
- package/dist/utils/mcp/registry-key.js.map +1 -0
- package/dist/utils/naming.js +7 -3
- package/dist/utils/naming.js.map +1 -1
- package/dist/utils/promise/promiseCreator.js +5 -0
- package/dist/utils/promise/promiseCreator.js.map +1 -1
- package/dist/utils/report/junit-report.js +5 -0
- package/dist/utils/report/junit-report.js.map +1 -1
- package/dist/utils/report/validation-report.js +5 -0
- package/dist/utils/report/validation-report.js.map +1 -1
- package/dist/utils/request-executor.d.ts +17 -0
- package/dist/utils/request-executor.js +121 -0
- package/dist/utils/request-executor.js.map +1 -0
- package/dist/utils/uris.d.ts +4 -4
- package/dist/utils/uris.js +19 -6
- package/dist/utils/uris.js.map +1 -1
- package/dist/utils/variables.d.ts +3 -4
- package/dist/utils/variables.js +25 -9
- package/dist/utils/variables.js.map +1 -1
- package/dist/utils/zip-utils.d.ts +8 -0
- package/dist/utils/zip-utils.js +24 -0
- package/dist/utils/zip-utils.js.map +1 -0
- package/package.json +22 -11
- package/scripts/resolve-version.sh +89 -0
- package/scripts/resolve-version.test.sh +81 -0
- package/scripts/test-publish-npm.sh +130 -0
- package/templates/{agent-network.yaml.template → agent-network/agent-network.yaml.template} +1 -1
- package/templates/{exchange.json.template → agent-network/exchange.json.template} +1 -0
- package/templates/agentic-network/agent-network.yaml.template +93 -0
- package/templates/agentic-network/brokers/broker1.agent.template +102 -0
- package/templates/agentic-network/exchange.json.template +37 -0
- package/dist/utils/builders/agent-builder.d.ts +0 -11
- package/dist/utils/builders/agent-builder.js +0 -79
- package/dist/utils/builders/agent-builder.js.map +0 -1
- package/dist/utils/builders/broker-builder.js +0 -292
- package/dist/utils/builders/broker-builder.js.map +0 -1
- package/dist/utils/builders/connections-builder.js +0 -233
- package/dist/utils/builders/connections-builder.js.map +0 -1
- package/dist/utils/builders/llm-builder.js +0 -64
- package/dist/utils/builders/llm-builder.js.map +0 -1
- package/dist/utils/builders/mcp-builder.js +0 -48
- package/dist/utils/builders/mcp-builder.js.map +0 -1
- package/dist/utils/builders/network-builder.js +0 -77
- package/dist/utils/builders/network-builder.js.map +0 -1
- package/dist/utils/builders/path.js.map +0 -1
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2026, Salesforce, Inc.
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
* For full license text, see the LICENSE.txt file
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.BrokerBuilder = exports.BrokersAppProcessor = exports.BROKER_COMPONENT_PREFIX = void 0;
|
|
9
|
+
const tslib_1 = require("tslib");
|
|
10
|
+
const node_path_1 = require("node:path");
|
|
11
|
+
const project_builder_1 = require("../project-builder");
|
|
12
|
+
const utils_1 = require("../../../helpers/utils");
|
|
13
|
+
const connection_metadata_1 = require("../common/connection-metadata");
|
|
14
|
+
const constants_1 = require("../../constants");
|
|
15
|
+
const error_factory_1 = require("../../../errors/error-factory");
|
|
16
|
+
const node_child_process_1 = require("node:child_process");
|
|
17
|
+
const fs = tslib_1.__importStar(require("node:fs"));
|
|
18
|
+
const agent_network_1 = require("../../../types/agent-network");
|
|
19
|
+
const policies_factory_1 = require("../policies-factory");
|
|
20
|
+
const policy_helper_1 = require("../../../helpers/policy-helper");
|
|
21
|
+
const entitlement_utils_1 = require("../../../helpers/entitlement-utils");
|
|
22
|
+
const variables_1 = require("../../variables");
|
|
23
|
+
const agent_metadata_1 = require("../common/agent-metadata");
|
|
24
|
+
const dependency_manager_1 = require("../../../helpers/dependency-manager");
|
|
25
|
+
const gateway_1 = require("../../gateway");
|
|
26
|
+
const logger_1 = require("../../logger");
|
|
27
|
+
const files_1 = require("../../files");
|
|
28
|
+
var ConnectionKinds = agent_network_1.AgentNetwork.ConnectionKinds;
|
|
29
|
+
exports.BROKER_COMPONENT_PREFIX = 'broker-';
|
|
30
|
+
const CLIENT_PREFIX = 'client-';
|
|
31
|
+
/**
|
|
32
|
+
* Process the "brokers" mule application defined in an agent network project.
|
|
33
|
+
*/
|
|
34
|
+
class BrokersAppProcessor {
|
|
35
|
+
handles(path, model) {
|
|
36
|
+
return path.isBrokersPath();
|
|
37
|
+
}
|
|
38
|
+
async deployments(model, path, context, space) {
|
|
39
|
+
var _a, _b, _c, _d, _e;
|
|
40
|
+
const brokers = model;
|
|
41
|
+
const descriptor = context.exchangeDescriptor();
|
|
42
|
+
const assetId = descriptor.assetId;
|
|
43
|
+
logger_1.Log.info(` Building deployment configuration for Application ${assetId}...`);
|
|
44
|
+
const networkComponent = space.getComponent(assetId);
|
|
45
|
+
if (!networkComponent) {
|
|
46
|
+
throw new Error('Unable to find component ' + assetId);
|
|
47
|
+
}
|
|
48
|
+
if (assetId.length > constants_1.MAX_AMC_DEPLOYMENT_NAME_LENGTH) {
|
|
49
|
+
throw error_factory_1.ErrorFactory.assetIdTooLongForDeployment(assetId, constants_1.MAX_AMC_DEPLOYMENT_NAME_LENGTH);
|
|
50
|
+
}
|
|
51
|
+
const muleAppAssetId = this.muleAppAssetId(descriptor);
|
|
52
|
+
const muleDeployment = networkComponent.addMuleDeployment(muleAppAssetId);
|
|
53
|
+
muleDeployment.name(assetId);
|
|
54
|
+
muleDeployment.asset({ assetId: muleAppAssetId, groupId: descriptor.groupId });
|
|
55
|
+
for (const [key, broker] of Object.entries(brokers || {})) {
|
|
56
|
+
networkComponent.addClient(CLIENT_PREFIX + key);
|
|
57
|
+
for (const link of (broker.spec.links || [])) {
|
|
58
|
+
muleDeployment.requiresConnection((0, utils_1.resolveReference)(link.agent.ref, descriptor), 'a2a', (_a = link.agent.connection) === null || _a === void 0 ? void 0 : _a.ref.name);
|
|
59
|
+
}
|
|
60
|
+
for (const tool of (broker.spec.tools || [])) {
|
|
61
|
+
muleDeployment.requiresConnection((0, utils_1.resolveReference)(tool.mcp.ref, descriptor), 'mcp', (_b = tool.mcp.connection) === null || _b === void 0 ? void 0 : _b.ref.name);
|
|
62
|
+
}
|
|
63
|
+
broker.spec.llm && muleDeployment.requiresConnection((0, utils_1.resolveReference)(broker.spec.llm.ref, descriptor), 'llm', (_c = broker.spec.llm.connection) === null || _c === void 0 ? void 0 : _c.ref.name);
|
|
64
|
+
}
|
|
65
|
+
muleDeployment.muleVersion(gateway_1.GatewayUtils.DEFAULT_MULE_VERSION);
|
|
66
|
+
if ((_d = descriptor === null || descriptor === void 0 ? void 0 : descriptor.metadata) === null || _d === void 0 ? void 0 : _d.variables) {
|
|
67
|
+
const variables = variables_1.VariablesHelper.flattenVariables((_e = descriptor === null || descriptor === void 0 ? void 0 : descriptor.metadata) === null || _e === void 0 ? void 0 : _e.variables);
|
|
68
|
+
muleDeployment.variables(variables);
|
|
69
|
+
}
|
|
70
|
+
const hasTracingEnabled = await entitlement_utils_1.EntitlementUtils.hasTracingEntitlement(context.req, descriptor.groupId, false);
|
|
71
|
+
if (hasTracingEnabled) {
|
|
72
|
+
muleDeployment.tracing(true);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
muleAppAssetId(descriptor) {
|
|
76
|
+
return descriptor.assetId + constants_1.MULE_APPLICATION_SUFFIX;
|
|
77
|
+
}
|
|
78
|
+
validateJavaHome(javaHome) {
|
|
79
|
+
if (javaHome) {
|
|
80
|
+
logger_1.Log.debug(`JAVA_HOME: ${javaHome}`);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
logger_1.Log.error('JAVA_HOME is not set.');
|
|
84
|
+
}
|
|
85
|
+
if (!files_1.FileValidator.isValidPath(javaHome)) {
|
|
86
|
+
throw error_factory_1.ErrorFactory.invalidVariablePath('javaHome', javaHome);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async build(model, path, context, space) {
|
|
90
|
+
var _a;
|
|
91
|
+
const descriptor = context.exchangeDescriptor();
|
|
92
|
+
const assetId = descriptor.assetId;
|
|
93
|
+
const version = descriptor.version;
|
|
94
|
+
logger_1.Log.info(` Building Application ${assetId}...`);
|
|
95
|
+
// Build the Mule application JAR for the brokers component
|
|
96
|
+
const muleAppDir = await this.buildMuleApplication(context);
|
|
97
|
+
const muleAppAssetId = this.muleAppAssetId(descriptor);
|
|
98
|
+
const muleApplication = (0, node_path_1.join)(muleAppDir, constants_1.TARGET_DIR, `${assetId}-${version}-${constants_1.MULE_APPLICATION_JAR}`);
|
|
99
|
+
const muleAppContent = fs.readFileSync(muleApplication); // Validate that the file exists
|
|
100
|
+
// Define the mule application asset on its own component
|
|
101
|
+
const muleAppComponentId = constants_1.MULE_APP_COMPONENT_PREFIX + descriptor.assetId;
|
|
102
|
+
const muleAppComponent = space.addComponent(muleAppComponentId);
|
|
103
|
+
muleAppComponent.version(descriptor.version);
|
|
104
|
+
const asset = muleAppComponent.addAsset(muleAppAssetId);
|
|
105
|
+
asset.type(constants_1.MULE_APP_ASSET_TYPE);
|
|
106
|
+
asset.addFile('mule-application', 'jar', muleAppContent);
|
|
107
|
+
if (descriptor.description) {
|
|
108
|
+
asset.description(descriptor.description);
|
|
109
|
+
}
|
|
110
|
+
asset.tags((_a = descriptor.tags) !== null && _a !== void 0 ? _a : []);
|
|
111
|
+
asset.main(constants_1.MULE_APPLICATION_JAR);
|
|
112
|
+
}
|
|
113
|
+
async buildMuleApplication(context) {
|
|
114
|
+
const basePath = context.projectDir;
|
|
115
|
+
const exchangeJsonPath = (0, node_path_1.join)(basePath, constants_1.DESCRIPTOR_FILE);
|
|
116
|
+
const javaHome = process.env.JAVA_HOME;
|
|
117
|
+
this.validateJavaHome(javaHome);
|
|
118
|
+
const mvnSettingsXmlPath = (0, node_path_1.join)(basePath, '.mvn', 'settings.xml');
|
|
119
|
+
const jarPath = (0, node_path_1.join)(context.cacheDir, constants_1.BUILD_JAR_FILENAME);
|
|
120
|
+
const muleAppDir = (0, node_path_1.join)(context.targetDir, constants_1.MULE_BROKER_APP);
|
|
121
|
+
const muleGenerationDependencies = await dependency_manager_1.DependencyManager.retrieveMuleGenerationDependencies();
|
|
122
|
+
const versionsParameter = muleGenerationDependencies.map(({ name, version }) => [name, version].join('=')).join(',');
|
|
123
|
+
const mainFilePath = (0, node_path_1.join)(context.projectDir, context.exchangeDescriptor().main || 'agent-network.yaml');
|
|
124
|
+
const javaExecutable = context.isWindows ? (0, utils_1.quoteValue)(`${javaHome}\\bin\\java.exe`) : `${javaHome}/bin/java`;
|
|
125
|
+
let arg = context.isWindows ?
|
|
126
|
+
['-jar', (0, utils_1.quoteValue)(jarPath), 'generate', (0, utils_1.quoteValue)(mainFilePath), (0, utils_1.quoteValue)(exchangeJsonPath), context.anypointLowerEnv.toString(), (0, utils_1.quoteValue)((0, utils_1.resolveExchangeModuleDir)()), (0, utils_1.quoteValue)(muleAppDir)] :
|
|
127
|
+
['-jar', jarPath, 'generate', mainFilePath, exchangeJsonPath, context.anypointLowerEnv.toString(), (0, utils_1.resolveExchangeModuleDir)(), muleAppDir];
|
|
128
|
+
if (versionsParameter.length > 0) {
|
|
129
|
+
arg = [...arg, (context.isWindows ? (0, utils_1.quoteValue)(versionsParameter) : versionsParameter)];
|
|
130
|
+
}
|
|
131
|
+
const appGenerationResult = (0, node_child_process_1.spawnSync)(javaExecutable, arg, {
|
|
132
|
+
cwd: basePath,
|
|
133
|
+
stdio: 'inherit',
|
|
134
|
+
shell: context.isWindows, // needed for .cmd on Windows
|
|
135
|
+
});
|
|
136
|
+
if (appGenerationResult.status !== 0) {
|
|
137
|
+
throw error_factory_1.ErrorFactory.validatingAgentNetworkError(appGenerationResult.status);
|
|
138
|
+
}
|
|
139
|
+
const wrapperCmd = context.isWindows ? 'mvnw.cmd' : './mvnw';
|
|
140
|
+
const wrapperPath = (0, node_path_1.join)(muleAppDir, wrapperCmd);
|
|
141
|
+
if (!fs.existsSync(wrapperPath)) {
|
|
142
|
+
throw error_factory_1.ErrorFactory.wrapperNotFoundError(context.projectDir, wrapperPath);
|
|
143
|
+
}
|
|
144
|
+
const mavenParameters = ['clean', 'package'];
|
|
145
|
+
if (context.debugMode) {
|
|
146
|
+
mavenParameters.push('-X');
|
|
147
|
+
}
|
|
148
|
+
if (context.forceUpdate) {
|
|
149
|
+
mavenParameters.push('-U');
|
|
150
|
+
}
|
|
151
|
+
if (fs.existsSync(mvnSettingsXmlPath)) {
|
|
152
|
+
const quotedSettingsXmlPath = (0, utils_1.quoteValue)(mvnSettingsXmlPath);
|
|
153
|
+
mavenParameters.push('-s', quotedSettingsXmlPath);
|
|
154
|
+
}
|
|
155
|
+
const mavenExecutable = context.isWindows ? (0, utils_1.quoteValue)(wrapperPath) : wrapperPath;
|
|
156
|
+
const result = (0, node_child_process_1.spawnSync)(mavenExecutable, mavenParameters, {
|
|
157
|
+
cwd: muleAppDir,
|
|
158
|
+
stdio: 'inherit',
|
|
159
|
+
shell: context.isWindows, // needed for .cmd on Windows
|
|
160
|
+
});
|
|
161
|
+
if (result.status !== 0) {
|
|
162
|
+
throw error_factory_1.ErrorFactory.buildBrokersAppError(result.status);
|
|
163
|
+
}
|
|
164
|
+
return muleAppDir;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
exports.BrokersAppProcessor = BrokersAppProcessor;
|
|
168
|
+
/**
|
|
169
|
+
* Works
|
|
170
|
+
*/
|
|
171
|
+
class BrokerBuilder {
|
|
172
|
+
handles(path, model) {
|
|
173
|
+
return path.isBroker();
|
|
174
|
+
}
|
|
175
|
+
async deployments(model, path, context, space) {
|
|
176
|
+
const assetId = path.componentName() || '';
|
|
177
|
+
logger_1.Log.info(` Building deployment configuration for Broker ${assetId}...`);
|
|
178
|
+
const broker = model;
|
|
179
|
+
const brokerName = assetId;
|
|
180
|
+
const descriptor = context.exchangeDescriptor();
|
|
181
|
+
const muleAppAssetId = descriptor.assetId + constants_1.MULE_APPLICATION_SUFFIX;
|
|
182
|
+
const componentId = this.getComponentId(assetId);
|
|
183
|
+
const brokerComponent = space.getComponent(componentId);
|
|
184
|
+
if (!brokerComponent) {
|
|
185
|
+
throw new Error('Unable to find component ' + componentId);
|
|
186
|
+
}
|
|
187
|
+
const brokersComponent = descriptor.assetId;
|
|
188
|
+
const muleAppBrokersComponentId = `components.${brokersComponent}.muleApplications.${muleAppAssetId}`;
|
|
189
|
+
brokerComponent.addComponentDependency(muleAppBrokersComponentId);
|
|
190
|
+
const agentInstance = brokerComponent.addAPIInstance(brokerName, { groupId: descriptor.groupId, assetId });
|
|
191
|
+
agentInstance.type(constants_1.A2A);
|
|
192
|
+
agentInstance.label(`[Broker] ${brokerName}`);
|
|
193
|
+
agentInstance.description(broker.card.description || '');
|
|
194
|
+
agentInstance.path(`${brokerName}`);
|
|
195
|
+
agentInstance.upstreamUrl(`\${${muleAppBrokersComponentId}.url}/${brokerName}`);
|
|
196
|
+
agentInstance.metadata({
|
|
197
|
+
connectionId: `${descriptor.groupId}:${descriptor.assetId}`,
|
|
198
|
+
source: (0, utils_1.templatedAgentNetworkSource)(descriptor.groupId, descriptor.assetId),
|
|
199
|
+
protectionDirection: project_builder_1.InstanceProtectionDirection.Ingress,
|
|
200
|
+
});
|
|
201
|
+
const customPolicies = policy_helper_1.PolicyHelper.resolveCustomPolicies(broker.spec.policies, descriptor, context.projectDir);
|
|
202
|
+
const instanceIdVariable = `\${${componentId}.apiInstances.${brokerName}.id}`;
|
|
203
|
+
const policies = await Promise.all([
|
|
204
|
+
(0, policies_factory_1.createAgentCardPolicy)(context.mulesoftOrg),
|
|
205
|
+
(0, policies_factory_1.createTracingPolicy)(context.mulesoftOrg, `[Agent] ${brokerName}`, instanceIdVariable, constants_1.A2A),
|
|
206
|
+
(0, policies_factory_1.createAPIDInjectionPolicy)(context.mulesoftOrg, instanceIdVariable),
|
|
207
|
+
]);
|
|
208
|
+
agentInstance.inboundPolicies([
|
|
209
|
+
...policies,
|
|
210
|
+
...customPolicies,
|
|
211
|
+
]);
|
|
212
|
+
}
|
|
213
|
+
async build(model, path, context, space) {
|
|
214
|
+
const descriptor = context.exchangeDescriptor();
|
|
215
|
+
const assetId = path.componentName() || '';
|
|
216
|
+
const broker = model;
|
|
217
|
+
logger_1.Log.info(` Building Broker ${assetId}...`);
|
|
218
|
+
const brokerComponent = space.addComponent(this.getComponentId(assetId));
|
|
219
|
+
brokerComponent.version(descriptor.version);
|
|
220
|
+
const agentAsset = brokerComponent.addAsset(assetId);
|
|
221
|
+
agentAsset.type(constants_1.AGENT_ASSET_TYPE);
|
|
222
|
+
const assetName = broker.card.name || assetId;
|
|
223
|
+
agentAsset.name(assetName);
|
|
224
|
+
agentAsset.tags([constants_1.BROKER_TAG]);
|
|
225
|
+
agentAsset.properties({
|
|
226
|
+
protocol: constants_1.A2A,
|
|
227
|
+
platform: constants_1.MULESOFT_PLATFORM,
|
|
228
|
+
kind: constants_1.BROKER_TAG,
|
|
229
|
+
source: (0, utils_1.sourceUrnFromDescriptor)(descriptor),
|
|
230
|
+
});
|
|
231
|
+
agentAsset.addFile('a2a-card', constants_1.JSON_EXTENSION, Buffer.from(JSON.stringify(broker.card, null, 2)));
|
|
232
|
+
(0, agent_metadata_1.addAgentMetadataFile)(agentAsset, (0, agent_metadata_1.buildAgentMetadata)(this.metadataInput(broker, descriptor, assetId, context.registryEntries)));
|
|
233
|
+
}
|
|
234
|
+
brokerEntryMetadata(broker, descriptor, assetId, registryEntries) {
|
|
235
|
+
return (0, agent_metadata_1.buildBrokerMetadata)(this.metadataInput(broker, descriptor, assetId, registryEntries));
|
|
236
|
+
}
|
|
237
|
+
metadataInput(broker, descriptor, assetId, registryEntries) {
|
|
238
|
+
var _a, _b;
|
|
239
|
+
const connections = [
|
|
240
|
+
...(((_a = broker.spec.links) === null || _a === void 0 ? void 0 : _a.map(link => (0, connection_metadata_1.resolveConnectionMetadata)(ConnectionKinds.Agent, link.agent.ref, descriptor, registryEntries))) || []),
|
|
241
|
+
...(((_b = broker.spec.tools) === null || _b === void 0 ? void 0 : _b.map(link => (0, connection_metadata_1.resolveConnectionMetadata)(ConnectionKinds.Mcp, link.mcp.ref, descriptor, registryEntries, link.mcp.allowed))) || []),
|
|
242
|
+
...(broker.spec.llm ? [(0, connection_metadata_1.resolveConnectionMetadata)(ConnectionKinds.Llm, broker.spec.llm.ref, descriptor, registryEntries)] : []),
|
|
243
|
+
];
|
|
244
|
+
return {
|
|
245
|
+
protocol: constants_1.A2A,
|
|
246
|
+
platform: constants_1.MULESOFT_PLATFORM,
|
|
247
|
+
kind: constants_1.BROKER_TAG,
|
|
248
|
+
assetId,
|
|
249
|
+
name: broker.card.name || assetId,
|
|
250
|
+
descriptor,
|
|
251
|
+
connections,
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
getComponentId(assetId) {
|
|
255
|
+
return exports.BROKER_COMPONENT_PREFIX + assetId;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
exports.BrokerBuilder = BrokerBuilder;
|
|
259
|
+
//# sourceMappingURL=broker-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"broker-builder.js","sourceRoot":"","sources":["../../../../src/utils/builders/v1/broker-builder.ts"],"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,EAAE,eAAe,CAAC,CAAC,KAAI,EAAE,CAAC;YACxI,GAAG,CAAC,CAAA,MAAA,MAAM,CAAC,IAAI,CAAC,KAAK,0CAAE,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAA,+CAAyB,EAAC,eAAe,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,UAAU,EAAE,eAAe,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,KAAI,EAAE,CAAC;YACtJ,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,+CAAyB,EAAC,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,UAAU,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SAC/H,CAAA;QACD,OAAO;YACL,QAAQ,EAAE,eAAG;YACb,QAAQ,EAAE,6BAAiB;YAC3B,IAAI,EAAE,sBAAU;YAChB,OAAO;YACP,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,OAAO;YACjC,UAAU;YACV,WAAW;SACZ,CAAA;IACH,CAAC;IAEO,cAAc,CAAC,OAAe;QACpC,OAAO,+BAAuB,GAAG,OAAO,CAAA;IAC1C,CAAC;CACF;AAhGD,sCAgGC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { ANProcessor, PolicyBinding, ProjectContext, SpaceBuilder } from '
|
|
1
|
+
import { ANProcessor, PolicyBinding, ProjectContext, SpaceBuilder } from '../project-builder';
|
|
2
2
|
import { Path } from './path';
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
3
|
+
import { AgentNetwork } from '../../../types/agent-network';
|
|
4
|
+
import LLMConnection = AgentNetwork.LLMConnection;
|
|
5
|
+
import { ExchangeDescriptor, GAV } from '../../../types/types';
|
|
5
6
|
/**
|
|
6
7
|
* Works over the agent defined in an agent network project.
|
|
7
8
|
* It creates the agent asset component with its respective files and metadata.
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2026, Salesforce, Inc.
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
* For full license text, see the LICENSE.txt file
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.MCPConnectionBuilder = exports.LLMConnectionBuilder = exports.AgentConnectionBuilder = void 0;
|
|
9
|
+
const tslib_1 = require("tslib");
|
|
10
|
+
const constants_1 = require("../../constants");
|
|
11
|
+
const agent_network_1 = require("../../../types/agent-network");
|
|
12
|
+
var ConnectionKinds = agent_network_1.AgentNetwork.ConnectionKinds;
|
|
13
|
+
const policies_factory_1 = require("../policies-factory");
|
|
14
|
+
const utils_1 = require("../../../helpers/utils");
|
|
15
|
+
const error_factory_1 = require("../../../errors/error-factory");
|
|
16
|
+
const policy_helper_1 = require("../../../helpers/policy-helper");
|
|
17
|
+
const fs = tslib_1.__importStar(require("fs-extra"));
|
|
18
|
+
const node_path_1 = require("node:path");
|
|
19
|
+
const logger_1 = require("../../logger");
|
|
20
|
+
const connection_facet_helpers_1 = require("../common/connection-facet-helpers");
|
|
21
|
+
/**
|
|
22
|
+
* Works over the agent defined in an agent network project.
|
|
23
|
+
* It creates the agent asset component with its respective files and metadata.
|
|
24
|
+
*/
|
|
25
|
+
class AgentConnectionBuilder {
|
|
26
|
+
handles(path, model) {
|
|
27
|
+
return path.isConnection() && model.kind === ConnectionKinds.Agent;
|
|
28
|
+
}
|
|
29
|
+
async deployments(model, path, context, space) {
|
|
30
|
+
const descriptor = context.exchangeDescriptor();
|
|
31
|
+
const connectionName = path.componentName() || '';
|
|
32
|
+
const connection = model;
|
|
33
|
+
logger_1.Log.info(` Building deployment configuration for Agent connection ${connectionName}...`);
|
|
34
|
+
const networkId = descriptor.assetId;
|
|
35
|
+
const { connectionFacet, label } = (0, connection_facet_helpers_1.setupConnectionFacet)({
|
|
36
|
+
ref: connection.ref,
|
|
37
|
+
connectionName,
|
|
38
|
+
type: constants_1.A2A,
|
|
39
|
+
labelPrefix: '[Agent]',
|
|
40
|
+
upstreamUrl: connection.spec.url || '',
|
|
41
|
+
description: connection.description,
|
|
42
|
+
context,
|
|
43
|
+
space,
|
|
44
|
+
});
|
|
45
|
+
const customPolicies = policy_helper_1.PolicyHelper.resolveCustomPolicies(connection.spec.policies, descriptor, context.projectDir);
|
|
46
|
+
const policies = await Promise.all([
|
|
47
|
+
(0, policies_factory_1.createAgentCardPolicy)(context.mulesoftOrg),
|
|
48
|
+
(0, policies_factory_1.createConnectionPolicy)(context.mulesoftOrg),
|
|
49
|
+
(0, policies_factory_1.createTracingPolicy)(context.mulesoftOrg, label, `\${${networkId}.connections.${connectionName}.id}`, constants_1.A2A),
|
|
50
|
+
]);
|
|
51
|
+
connectionFacet.inboundPolicies([
|
|
52
|
+
...policies,
|
|
53
|
+
...customPolicies,
|
|
54
|
+
]);
|
|
55
|
+
if (connection.spec.authentication) {
|
|
56
|
+
const authPolicies = await (0, policies_factory_1.createAuthenticationPolicy)(context.mulesoftOrg, connection.spec.authentication);
|
|
57
|
+
connectionFacet.outboundPolicies([...authPolicies]);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
async build(model, path, context, space) {
|
|
61
|
+
// intentionally empty
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.AgentConnectionBuilder = AgentConnectionBuilder;
|
|
65
|
+
class LLMConnectionBuilder {
|
|
66
|
+
handles(path, model) {
|
|
67
|
+
return path.isConnection() && model.kind === ConnectionKinds.Llm;
|
|
68
|
+
}
|
|
69
|
+
build(model, path, context, space) {
|
|
70
|
+
// intentionally empty
|
|
71
|
+
}
|
|
72
|
+
async deployments(model, path, context, space) {
|
|
73
|
+
const descriptor = context.exchangeDescriptor();
|
|
74
|
+
const connectionName = path.componentName() || '';
|
|
75
|
+
const connection = model;
|
|
76
|
+
logger_1.Log.info(` Building deployment configuration for LLM connection ${connectionName}...`);
|
|
77
|
+
const networkId = descriptor.assetId;
|
|
78
|
+
const { connectionFacet, reference, label } = (0, connection_facet_helpers_1.setupConnectionFacet)({
|
|
79
|
+
ref: connection.ref,
|
|
80
|
+
connectionName,
|
|
81
|
+
type: constants_1.LLM_ASSET_TYPE,
|
|
82
|
+
labelPrefix: '[LLM]',
|
|
83
|
+
upstreamUrl: connection.spec.url,
|
|
84
|
+
description: connection.description,
|
|
85
|
+
context,
|
|
86
|
+
space,
|
|
87
|
+
});
|
|
88
|
+
const customPolicies = policy_helper_1.PolicyHelper.resolveCustomPolicies(connection.spec.policies, descriptor, context.projectDir);
|
|
89
|
+
const policies = await Promise.all([
|
|
90
|
+
(0, policies_factory_1.createTracingPolicy)(context.mulesoftOrg, label, `\${${networkId}.connections.${connectionName}.id}`, constants_1.LLM_ASSET_TYPE),
|
|
91
|
+
(0, policies_factory_1.createConnectionPolicy)(context.mulesoftOrg),
|
|
92
|
+
]);
|
|
93
|
+
connectionFacet.inboundPolicies([
|
|
94
|
+
...policies,
|
|
95
|
+
...customPolicies,
|
|
96
|
+
]);
|
|
97
|
+
const transcodingPolicy = await this.createTranscodingPolicy(connection, reference, context, space);
|
|
98
|
+
connectionFacet.outboundPolicies([transcodingPolicy]);
|
|
99
|
+
}
|
|
100
|
+
resolveAssetFile(asset, classifier, extension, exchange, space) {
|
|
101
|
+
if (asset.groupId === exchange.groupId) {
|
|
102
|
+
// we try to resolve it with
|
|
103
|
+
const foundAsset = space.searchAsset(asset.assetId);
|
|
104
|
+
if (foundAsset) {
|
|
105
|
+
const inMemoryFile = foundAsset.getFile(classifier, extension);
|
|
106
|
+
if (inMemoryFile) {
|
|
107
|
+
const buffer = Buffer.from(inMemoryFile);
|
|
108
|
+
return buffer.toString(constants_1.UTF8);
|
|
109
|
+
}
|
|
110
|
+
logger_1.Log.error(`File not found ${classifier}.${extension} was not found`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
const file = (0, node_path_1.join)((0, utils_1.resolveExchangeModuleDir)(), asset.groupId, asset.assetId, asset.version, `${classifier}.${extension}`);
|
|
114
|
+
if (fs.existsSync(file)) {
|
|
115
|
+
return fs.readFileSync(file, constants_1.UTF8);
|
|
116
|
+
}
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
async createTranscodingPolicy(connection, llmRef, context, space) {
|
|
120
|
+
const llmMetadataContent = this.resolveAssetFile(llmRef, constants_1.LLM_METADATA_CLASSIFIER, constants_1.JSON_EXTENSION, context.exchangeDescriptor(), space);
|
|
121
|
+
if (!llmMetadataContent) {
|
|
122
|
+
throw error_factory_1.ErrorFactory.unableToResolve(llmRef);
|
|
123
|
+
}
|
|
124
|
+
const llmMetadata = JSON.parse(llmMetadataContent);
|
|
125
|
+
let policyRef = llmMetadata.policyRef;
|
|
126
|
+
let metadata = null;
|
|
127
|
+
if (!policyRef) {
|
|
128
|
+
const resolved = await policy_helper_1.PolicyHelper.resolveDefaultPolicyByPlatform(llmMetadata.platform, context.mulesoftOrg);
|
|
129
|
+
if (!resolved) {
|
|
130
|
+
throw error_factory_1.ErrorFactory.noTranscodingFoundFor(llmMetadata.platform);
|
|
131
|
+
}
|
|
132
|
+
policyRef = resolved.gav;
|
|
133
|
+
metadata = resolved.metadata;
|
|
134
|
+
}
|
|
135
|
+
const configuration = metadata ?
|
|
136
|
+
await policy_helper_1.PolicyHelper.applySchemaDefaults(policyRef.groupId, policyRef.assetId, metadata, connection.spec.configuration) :
|
|
137
|
+
connection.spec.configuration;
|
|
138
|
+
return {
|
|
139
|
+
policyRef: {
|
|
140
|
+
groupId: policyRef.groupId,
|
|
141
|
+
assetId: policyRef.assetId,
|
|
142
|
+
version: policyRef.version,
|
|
143
|
+
},
|
|
144
|
+
configuration,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
exports.LLMConnectionBuilder = LLMConnectionBuilder;
|
|
149
|
+
class MCPConnectionBuilder {
|
|
150
|
+
handles(path, model) {
|
|
151
|
+
return path.isConnection() && model.kind === ConnectionKinds.Mcp;
|
|
152
|
+
}
|
|
153
|
+
async deployments(model, path, context, space) {
|
|
154
|
+
const descriptor = context.exchangeDescriptor();
|
|
155
|
+
const connectionName = path.componentName() || '';
|
|
156
|
+
const connection = model;
|
|
157
|
+
logger_1.Log.info(` Building deployment configuration for MCP connection ${connectionName}...`);
|
|
158
|
+
const networkId = descriptor.assetId;
|
|
159
|
+
const { connectionFacet, label } = (0, connection_facet_helpers_1.setupConnectionFacet)({
|
|
160
|
+
ref: connection.ref,
|
|
161
|
+
connectionName,
|
|
162
|
+
type: constants_1.MCP,
|
|
163
|
+
labelPrefix: '[MCP Server]',
|
|
164
|
+
upstreamUrl: connection.spec.url || '',
|
|
165
|
+
description: connection.description,
|
|
166
|
+
context,
|
|
167
|
+
space,
|
|
168
|
+
});
|
|
169
|
+
const customPolicies = policy_helper_1.PolicyHelper.resolveCustomPolicies(connection.spec.policies, descriptor, context.projectDir);
|
|
170
|
+
const policies = await Promise.all([
|
|
171
|
+
(0, policies_factory_1.createMCPSupportPolicy)(context.mulesoftOrg),
|
|
172
|
+
(0, policies_factory_1.createTracingPolicy)(context.mulesoftOrg, label, `\${${networkId}.connections.${connectionName}.id}`, constants_1.MCP),
|
|
173
|
+
(0, policies_factory_1.createConnectionPolicy)(context.mulesoftOrg),
|
|
174
|
+
]);
|
|
175
|
+
connectionFacet.inboundPolicies([
|
|
176
|
+
...policies,
|
|
177
|
+
...customPolicies,
|
|
178
|
+
]);
|
|
179
|
+
if (connection.spec.authentication) {
|
|
180
|
+
const authPolicies = await (0, policies_factory_1.createAuthenticationPolicy)(context.mulesoftOrg, connection.spec.authentication);
|
|
181
|
+
connectionFacet.outboundPolicies([...authPolicies]);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
async build(model, path, context, space) {
|
|
185
|
+
// intentionally empty
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
exports.MCPConnectionBuilder = MCPConnectionBuilder;
|
|
189
|
+
//# sourceMappingURL=connections-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connections-builder.js","sourceRoot":"","sources":["../../../../src/utils/builders/v1/connections-builder.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;AASH,+CAAuG;AACvG,gEAAyD;AAGzD,IAAO,eAAe,GAAG,4BAAY,CAAC,eAAe,CAAA;AAIrD,0DAM4B;AAE5B,kDAA+D;AAC/D,iEAA0D;AAC1D,kEAAmF;AACnF,qDAA8B;AAC9B,yCAA8B;AAC9B,yCAAgC;AAChC,iFAAuE;AAEvE;;;GAGG;AACH,MAAa,sBAAsB;IACjC,OAAO,CAAC,IAAU,EAAE,KAAU;QAC5B,OAAO,IAAI,CAAC,YAAY,EAAE,IAAK,KAAoB,CAAC,IAAI,KAAK,eAAe,CAAC,KAAK,CAAA;IACpF,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,KAAU,EAAE,IAAU,EAAE,OAAuB,EAAE,KAAmB;QACpF,MAAM,UAAU,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAA;QAC/C,MAAM,cAAc,GAAG,IAAI,CAAC,aAAa,EAAE,IAAI,EAAE,CAAA;QACjD,MAAM,UAAU,GAAG,KAAwB,CAAA;QAC3C,YAAG,CAAC,IAAI,CAAC,4DAA4D,cAAc,KAAK,CAAC,CAAA;QACzF,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,CAAA;QACpC,MAAM,EAAC,eAAe,EAAE,KAAK,EAAC,GAAG,IAAA,+CAAoB,EAAC;YACpD,GAAG,EAAE,UAAU,CAAC,GAAG;YACnB,cAAc;YACd,IAAI,EAAE,eAAG;YACT,WAAW,EAAE,SAAS;YACtB,WAAW,EAAE,UAAU,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE;YACtC,WAAW,EAAE,UAAU,CAAC,WAAW;YACnC,OAAO;YACP,KAAK;SACN,CAAC,CAAA;QACF,MAAM,c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AAC,CAAA;YAC1G,eAAe,CAAC,gBAAgB,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAA;QACrD,CAAC;IACH,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,KAAU,EAAE,IAAU,EAAE,OAAuB,EAAE,KAAmB;QAC9E,sBAAsB;IACxB,CAAC;CACF;AA1CD,oDA0CC"}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ProjectContext, RegistryElementProcessor, SpaceBuilder } from '../project-builder';
|
|
2
2
|
import { Path } from './path';
|
|
3
|
+
import { RegistryEntry } from '../../../types/types';
|
|
3
4
|
export declare const LLM_COMPONENT_PREFIX = "llm-";
|
|
4
5
|
/**
|
|
5
6
|
* Works over the agent defined in an agent network project.
|
|
6
7
|
* It creates the agent asset component with its respective files and metadata.
|
|
7
8
|
*/
|
|
8
|
-
export declare class LLMBuilder implements
|
|
9
|
+
export declare class LLMBuilder implements RegistryElementProcessor {
|
|
9
10
|
handles(path: Path, model: any): boolean;
|
|
11
|
+
buildRegistryEntry(model: any, id: string, context: ProjectContext): RegistryEntry;
|
|
10
12
|
deployments(model: any, path: Path, context: ProjectContext, space: SpaceBuilder): void;
|
|
11
13
|
build(model: any, path: Path, context: ProjectContext, space: SpaceBuilder): Promise<void>;
|
|
14
|
+
private getLlmName;
|
|
12
15
|
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2026, Salesforce, Inc.
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
* For full license text, see the LICENSE.txt file
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.LLMBuilder = exports.LLM_COMPONENT_PREFIX = void 0;
|
|
9
|
+
const constants_1 = require("../../constants");
|
|
10
|
+
const agent_network_1 = require("../../../types/agent-network");
|
|
11
|
+
const policy_helper_1 = require("../../../helpers/policy-helper");
|
|
12
|
+
const logger_1 = require("../../logger");
|
|
13
|
+
const utils_1 = require("../../../helpers/utils");
|
|
14
|
+
const registry_entry_1 = require("../common/registry-entry");
|
|
15
|
+
var ConnectionKinds = agent_network_1.AgentNetwork.ConnectionKinds;
|
|
16
|
+
exports.LLM_COMPONENT_PREFIX = 'llm-';
|
|
17
|
+
/**
|
|
18
|
+
* Works over the agent defined in an agent network project.
|
|
19
|
+
* It creates the agent asset component with its respective files and metadata.
|
|
20
|
+
*/
|
|
21
|
+
class LLMBuilder {
|
|
22
|
+
handles(path, model) {
|
|
23
|
+
return path.isLLMProvider();
|
|
24
|
+
}
|
|
25
|
+
buildRegistryEntry(model, id, context) {
|
|
26
|
+
const llm = model;
|
|
27
|
+
return (0, registry_entry_1.buildRegistryEntry)(ConnectionKinds.Llm, this.getLlmName(llm, id), context.exchangeDescriptor(), id);
|
|
28
|
+
}
|
|
29
|
+
deployments(model, path, context, space) {
|
|
30
|
+
// intentionally empty
|
|
31
|
+
}
|
|
32
|
+
async build(model, path, context, space) {
|
|
33
|
+
var _a, _b;
|
|
34
|
+
const descriptor = context.exchangeDescriptor();
|
|
35
|
+
const assetId = path.componentName() || '';
|
|
36
|
+
const llmProvider = model;
|
|
37
|
+
logger_1.Log.info(` Building LLM ${assetId}...`);
|
|
38
|
+
const llmComponent = space.addComponent(exports.LLM_COMPONENT_PREFIX + assetId);
|
|
39
|
+
const platform = ((_b = (_a = llmProvider.metadata) === null || _a === void 0 ? void 0 : _a.platform) === null || _b === void 0 ? void 0 : _b.toLowerCase()) || constants_1.OTHER;
|
|
40
|
+
llmComponent.version(descriptor.version);
|
|
41
|
+
const llmAsset = llmComponent.addAsset(assetId);
|
|
42
|
+
llmAsset.type(constants_1.LLM_ASSET_TYPE);
|
|
43
|
+
llmAsset.name(this.getLlmName(llmProvider, assetId));
|
|
44
|
+
llmAsset.description(llmProvider.description || '');
|
|
45
|
+
llmAsset.tags(llmProvider.tags || []);
|
|
46
|
+
const sourceUrn = (0, utils_1.sourceUrnFromDescriptor)(descriptor);
|
|
47
|
+
llmAsset.properties({
|
|
48
|
+
platform: platform,
|
|
49
|
+
source: sourceUrn,
|
|
50
|
+
});
|
|
51
|
+
let policyGav = {};
|
|
52
|
+
if (policy_helper_1.PolicyHelper.isValidPlatform(platform)) {
|
|
53
|
+
const [policyName, minorVersion] = policy_helper_1.LLM_PLATFORM_POLICIES[platform];
|
|
54
|
+
const policyVersion = await policy_helper_1.PolicyHelper.fetchPolicyPatchVersion(context.mulesoftOrg, policyName, minorVersion);
|
|
55
|
+
policyGav = { groupId: context.mulesoftOrg, assetId: policyName, version: policyVersion };
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
const policyRef = llmProvider.metadata.transcoder.ref;
|
|
59
|
+
policyGav = (0, utils_1.resolveReference)(policyRef, descriptor);
|
|
60
|
+
}
|
|
61
|
+
// Create metadata descriptor
|
|
62
|
+
const metadata = {
|
|
63
|
+
platform: platform,
|
|
64
|
+
policyRef: policyGav,
|
|
65
|
+
provenance: {
|
|
66
|
+
id: sourceUrn,
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
llmAsset.addFile(constants_1.LLM_METADATA_CLASSIFIER, constants_1.JSON_EXTENSION, Buffer.from(JSON.stringify(metadata, null, 2)));
|
|
70
|
+
}
|
|
71
|
+
getLlmName(llmProvider, assetId) {
|
|
72
|
+
return llmProvider.label || assetId || '';
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.LLMBuilder = LLMBuilder;
|
|
76
|
+
//# sourceMappingURL=llm-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-builder.js","sourceRoot":"","sources":["../../../../src/utils/builders/v1/llm-builder.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAIH,+CAA8F;AAC9F,gEAAyD;AACzD,kEAAkF;AAClF,yCAAgC;AAChC,kDAAgF;AAEhF,6DAA2D;AAE3D,IAAO,eAAe,GAAG,4BAAY,CAAC,eAA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AAE,CAAC,CAAC,CAAC,CAAC,CAAA;IAC3G,CAAC;IAEO,UAAU,CAAC,WAAqC,EAAE,OAAe;QACvE,OAAO,WAAW,CAAC,KAAK,IAAI,OAAO,IAAI,EAAE,CAAA;IAC3C,CAAC;CACF;AA5DD,gCA4DC"}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ProjectContext, RegistryElementProcessor, SpaceBuilder } from '../project-builder';
|
|
2
2
|
import { Path } from './path';
|
|
3
|
+
import { RegistryEntry } from '../../../types/types';
|
|
3
4
|
export declare const MCP_COMPONENT_PREFIX = "mcp-";
|
|
4
5
|
/**
|
|
5
6
|
* Works over the agent defined in an agent network project.
|
|
6
7
|
* It creates the agent asset component with its respective files and metadata.
|
|
7
8
|
*/
|
|
8
|
-
export declare class MCPBuilder implements
|
|
9
|
+
export declare class MCPBuilder implements RegistryElementProcessor {
|
|
9
10
|
handles(path: Path, model: any): boolean;
|
|
10
11
|
deployments(model: any, path: Path, context: ProjectContext, space: SpaceBuilder): void;
|
|
12
|
+
buildRegistryEntry(model: any, id: string, context: ProjectContext): RegistryEntry;
|
|
11
13
|
build(model: any, path: Path, context: ProjectContext, space: SpaceBuilder): Promise<void>;
|
|
14
|
+
private getMcpName;
|
|
12
15
|
}
|