mulesoft-anypoint-cli-agent-fabric-plugin 1.4.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/GETTING_STARTED.md +396 -0
- package/README.md +61 -23
- package/TROUBLESHOOTING.md +468 -0
- package/dist/commands/agent-network/project/agent-console.d.ts +3 -2
- package/dist/commands/agent-network/project/agent-console.js +3 -1
- package/dist/commands/agent-network/project/agent-console.js.map +1 -1
- package/dist/commands/agent-network/project/broker/create.d.ts +3 -2
- package/dist/commands/agent-network/project/broker/create.js +3 -1
- package/dist/commands/agent-network/project/broker/create.js.map +1 -1
- package/dist/commands/agent-network/project/build.d.ts +4 -3
- package/dist/commands/agent-network/project/build.js +13 -8
- package/dist/commands/agent-network/project/build.js.map +1 -1
- package/dist/commands/agent-network/project/create.d.ts +11 -6
- package/dist/commands/agent-network/project/create.js +52 -16
- package/dist/commands/agent-network/project/create.js.map +1 -1
- package/dist/commands/agent-network/project/deploy.d.ts +4 -2
- package/dist/commands/agent-network/project/deploy.js +45 -26
- package/dist/commands/agent-network/project/deploy.js.map +1 -1
- package/dist/commands/agent-network/project/export-logs.d.ts +3 -2
- package/dist/commands/agent-network/project/export-logs.js +3 -2
- package/dist/commands/agent-network/project/export-logs.js.map +1 -1
- package/dist/commands/agent-network/project/mcp/introspect.d.ts +7 -3
- package/dist/commands/agent-network/project/mcp/introspect.js +14 -9
- package/dist/commands/agent-network/project/mcp/introspect.js.map +1 -1
- package/dist/commands/agent-network/project/publish.d.ts +3 -4
- package/dist/commands/agent-network/project/publish.js +11 -14
- package/dist/commands/agent-network/project/publish.js.map +1 -1
- package/dist/commands/agent-network/project/run-local.d.ts +14 -2
- package/dist/commands/agent-network/project/run-local.js +339 -60
- package/dist/commands/agent-network/project/run-local.js.map +1 -1
- package/dist/commands/agent-network/project/secrets.d.ts +3 -2
- package/dist/commands/agent-network/project/secrets.js +3 -1
- package/dist/commands/agent-network/project/secrets.js.map +1 -1
- package/dist/commands/agent-network/project/stop-local.d.ts +3 -2
- package/dist/commands/agent-network/project/stop-local.js +3 -2
- package/dist/commands/agent-network/project/stop-local.js.map +1 -1
- package/dist/commands/agent-network/project/undeploy.d.ts +3 -2
- package/dist/commands/agent-network/project/undeploy.js +19 -12
- package/dist/commands/agent-network/project/undeploy.js.map +1 -1
- package/dist/commands/agent-network/project/unpublish.d.ts +3 -2
- package/dist/commands/agent-network/project/unpublish.js +26 -19
- package/dist/commands/agent-network/project/unpublish.js.map +1 -1
- package/dist/commands/agent-network/setup/dependencies.d.ts +4 -3
- package/dist/commands/agent-network/setup/dependencies.js +7 -4
- package/dist/commands/agent-network/setup/dependencies.js.map +1 -1
- package/dist/commands/agent-network/setup/gateways.d.ts +3 -2
- package/dist/commands/agent-network/setup/gateways.js +3 -3
- package/dist/commands/agent-network/setup/gateways.js.map +1 -1
- package/dist/errors/base-error.d.ts +6 -0
- package/dist/errors/base-error.js +49 -20
- package/dist/errors/base-error.js.map +1 -1
- package/dist/errors/error-factory.d.ts +62 -4
- package/dist/errors/error-factory.js +341 -13
- package/dist/errors/error-factory.js.map +1 -1
- package/dist/helpers/connection.d.ts +6 -2
- package/dist/helpers/connection.js +13 -6
- package/dist/helpers/connection.js.map +1 -1
- package/dist/helpers/dependency-manager.d.ts +14 -5
- package/dist/helpers/dependency-manager.js +185 -51
- package/dist/helpers/dependency-manager.js.map +1 -1
- package/dist/helpers/policy-helper.js +256 -26
- package/dist/helpers/policy-helper.js.map +1 -1
- package/dist/helpers/project/constants.d.ts +1 -1
- package/dist/helpers/proxy-agent.d.ts +2 -0
- package/dist/helpers/proxy-agent.js +26 -0
- package/dist/helpers/proxy-agent.js.map +1 -0
- package/dist/helpers/proxy-fetch.d.ts +5 -0
- package/dist/helpers/proxy-fetch.js +102 -0
- package/dist/helpers/proxy-fetch.js.map +1 -0
- package/dist/helpers/request-logging.d.ts +4 -0
- package/dist/helpers/request-logging.js +96 -2
- package/dist/helpers/request-logging.js.map +1 -1
- package/dist/helpers/types.d.ts +5 -0
- package/dist/helpers/utils.d.ts +1 -0
- package/dist/helpers/utils.js +16 -1
- package/dist/helpers/utils.js.map +1 -1
- package/dist/hooks/init/check-node-version.d.ts +6 -0
- package/dist/hooks/init/check-node-version.js +34 -0
- package/dist/hooks/init/check-node-version.js.map +1 -0
- package/dist/resources/runtime-dependencies.json +5 -1
- package/dist/resources/schemas/broker-deployment-settings.schema.json +4 -0
- package/dist/resources/schemas/runtime-dependencies-schema.json +21 -0
- package/dist/types/agent-network-v2.d.ts +55 -9
- package/dist/types/agent-network-v2.js.map +1 -1
- package/dist/types/agent-network.d.ts +0 -4
- package/dist/types/agent-network.js.map +1 -1
- package/dist/types/types.d.ts +25 -3
- package/dist/utils/agent-fabric-commands.d.ts +24 -0
- package/dist/utils/agent-fabric-commands.js +39 -0
- package/dist/utils/agent-fabric-commands.js.map +1 -0
- package/dist/utils/builders/builder.d.ts +2 -0
- package/dist/utils/builders/builder.js +22 -1
- package/dist/utils/builders/builder.js.map +1 -1
- package/dist/utils/builders/common/connection-facet-helpers.d.ts +2 -0
- package/dist/utils/builders/common/connection-facet-helpers.js +4 -1
- package/dist/utils/builders/common/connection-facet-helpers.js.map +1 -1
- package/dist/utils/builders/common/network-builder-helpers.d.ts +5 -0
- package/dist/utils/builders/common/network-builder-helpers.js +8 -0
- package/dist/utils/builders/common/network-builder-helpers.js.map +1 -1
- package/dist/utils/builders/common/network-metadata.js +1 -1
- package/dist/utils/builders/common/network-metadata.js.map +1 -1
- package/dist/utils/builders/common/types.d.ts +1 -1
- package/dist/utils/builders/local-space-resolver.d.ts +13 -3
- package/dist/utils/builders/local-space-resolver.js +16 -3
- package/dist/utils/builders/local-space-resolver.js.map +1 -1
- package/dist/utils/builders/policies-factory.d.ts +6 -2
- package/dist/utils/builders/policies-factory.js +106 -8
- package/dist/utils/builders/policies-factory.js.map +1 -1
- package/dist/utils/builders/project-builder-impl.d.ts +20 -1
- package/dist/utils/builders/project-builder-impl.js +40 -4
- package/dist/utils/builders/project-builder-impl.js.map +1 -1
- package/dist/utils/builders/project-builder.d.ts +18 -3
- package/dist/utils/builders/project-builder.js +4 -2
- package/dist/utils/builders/project-builder.js.map +1 -1
- package/dist/utils/builders/remote-space-resolver.d.ts +3 -3
- package/dist/utils/builders/remote-space-resolver.js +47 -32
- package/dist/utils/builders/remote-space-resolver.js.map +1 -1
- package/dist/utils/builders/space-serializer.d.ts +2 -0
- package/dist/utils/builders/space-serializer.js +12 -2
- package/dist/utils/builders/space-serializer.js.map +1 -1
- package/dist/utils/builders/v1/broker-builder.d.ts +1 -0
- package/dist/utils/builders/v1/broker-builder.js +45 -9
- package/dist/utils/builders/v1/broker-builder.js.map +1 -1
- package/dist/utils/builders/v1/connections-builder.js +3 -0
- package/dist/utils/builders/v1/connections-builder.js.map +1 -1
- package/dist/utils/builders/v1/network-builder.js +22 -4
- package/dist/utils/builders/v1/network-builder.js.map +1 -1
- package/dist/utils/builders/v2/broker-builder.js +1 -1
- package/dist/utils/builders/v2/broker-builder.js.map +1 -1
- package/dist/utils/builders/v2/connection-interfaces.d.ts +5 -0
- package/dist/utils/builders/v2/connection-interfaces.js +68 -0
- package/dist/utils/builders/v2/connection-interfaces.js.map +1 -0
- package/dist/utils/builders/v2/connections-builder.d.ts +5 -1
- package/dist/utils/builders/v2/connections-builder.js +120 -20
- package/dist/utils/builders/v2/connections-builder.js.map +1 -1
- package/dist/utils/builders/v2/llm-builder.js +17 -6
- package/dist/utils/builders/v2/llm-builder.js.map +1 -1
- package/dist/utils/builders/v2/network-builder.js +10 -1
- package/dist/utils/builders/v2/network-builder.js.map +1 -1
- package/dist/utils/constants.d.ts +22 -1
- package/dist/utils/constants.js +26 -4
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/deployment-settings.d.ts +1 -0
- package/dist/utils/deployment-settings.js.map +1 -1
- package/dist/utils/dry-run/dry-run-render.d.ts +1 -0
- package/dist/utils/dry-run/dry-run-render.js +23 -13
- package/dist/utils/dry-run/dry-run-render.js.map +1 -1
- package/dist/utils/exchange.d.ts +1 -0
- package/dist/utils/exchange.js +20 -0
- package/dist/utils/exchange.js.map +1 -1
- package/dist/utils/facets/agent-graph-facet.d.ts +1 -1
- package/dist/utils/facets/agent-graph-facet.js +10 -9
- package/dist/utils/facets/agent-graph-facet.js.map +1 -1
- package/dist/utils/facets/api-instance-facet.d.ts +2 -0
- package/dist/utils/facets/api-instance-facet.js +75 -19
- package/dist/utils/facets/api-instance-facet.js.map +1 -1
- package/dist/utils/facets/apim-policy-helpers.d.ts +29 -2
- package/dist/utils/facets/apim-policy-helpers.js +19 -5
- package/dist/utils/facets/apim-policy-helpers.js.map +1 -1
- package/dist/utils/facets/asset-facet.d.ts +2 -0
- package/dist/utils/facets/asset-facet.js +75 -40
- package/dist/utils/facets/asset-facet.js.map +1 -1
- package/dist/utils/facets/connection-facet.d.ts +6 -0
- package/dist/utils/facets/connection-facet.js +202 -22
- package/dist/utils/facets/connection-facet.js.map +1 -1
- package/dist/utils/facets/deployment-helpers.d.ts +2 -1
- package/dist/utils/facets/deployment-helpers.js +28 -21
- package/dist/utils/facets/deployment-helpers.js.map +1 -1
- package/dist/utils/facets/deployment-runner.js +88 -6
- package/dist/utils/facets/deployment-runner.js.map +1 -1
- package/dist/utils/facets/facets.d.ts +6 -0
- package/dist/utils/facets/facets.js +56 -9
- package/dist/utils/facets/facets.js.map +1 -1
- package/dist/utils/facets/mule-application-facet.js +2 -2
- package/dist/utils/facets/mule-application-facet.js.map +1 -1
- package/dist/utils/facets/publication-metadata-patcher.d.ts +7 -1
- package/dist/utils/facets/publication-metadata-patcher.js +32 -17
- package/dist/utils/facets/publication-metadata-patcher.js.map +1 -1
- package/dist/utils/facets/secret-manager-client.d.ts +29 -0
- package/dist/utils/facets/secret-manager-client.js +172 -0
- package/dist/utils/facets/secret-manager-client.js.map +1 -0
- package/dist/utils/facets/secret-ref-validator.d.ts +11 -0
- package/dist/utils/facets/secret-ref-validator.js +80 -0
- package/dist/utils/facets/secret-ref-validator.js.map +1 -0
- package/dist/utils/facets/secret-tls-validator.d.ts +6 -0
- package/dist/utils/facets/secret-tls-validator.js +59 -0
- package/dist/utils/facets/secret-tls-validator.js.map +1 -0
- package/dist/utils/gateway.d.ts +3 -0
- package/dist/utils/gateway.js +70 -1
- package/dist/utils/gateway.js.map +1 -1
- package/dist/utils/logger.js +1 -1
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/maven-proxy.d.ts +10 -0
- package/dist/utils/maven-proxy.js +118 -0
- package/dist/utils/maven-proxy.js.map +1 -0
- package/dist/utils/registry/registry-errors.d.ts +4 -0
- package/dist/utils/registry/registry-errors.js +36 -0
- package/dist/utils/registry/registry-errors.js.map +1 -0
- package/dist/utils/registry/registry-response.d.ts +46 -0
- package/dist/utils/registry/registry-response.js +264 -0
- package/dist/utils/registry/registry-response.js.map +1 -0
- package/dist/utils/request-executor.d.ts +9 -1
- package/dist/utils/request-executor.js +6 -3
- package/dist/utils/request-executor.js.map +1 -1
- package/dist/utils/run-local/build-status.js +4 -2
- package/dist/utils/run-local/build-status.js.map +1 -1
- package/dist/utils/run-local/index.d.ts +1 -1
- package/dist/utils/run-local/index.js +2 -1
- package/dist/utils/run-local/index.js.map +1 -1
- package/dist/utils/run-local/local-a2a-upstream.d.ts +1 -0
- package/dist/utils/run-local/local-a2a-upstream.js +5 -4
- package/dist/utils/run-local/local-a2a-upstream.js.map +1 -1
- package/dist/utils/run-local/local-tls-model.d.ts +18 -0
- package/dist/utils/run-local/local-tls-model.js +97 -0
- package/dist/utils/run-local/local-tls-model.js.map +1 -0
- package/dist/utils/run-local/local-tls.d.ts +37 -0
- package/dist/utils/run-local/local-tls.js +245 -0
- package/dist/utils/run-local/local-tls.js.map +1 -0
- package/dist/utils/run-local/policy-resolver.js +5 -0
- package/dist/utils/run-local/policy-resolver.js.map +1 -1
- package/dist/utils/run-local/runtime-environment-manager.d.ts +23 -2
- package/dist/utils/run-local/runtime-environment-manager.js +236 -6
- package/dist/utils/run-local/runtime-environment-manager.js.map +1 -1
- package/dist/utils/run-local/secrets-manager.d.ts +1 -0
- package/dist/utils/run-local/secrets-manager.js +2 -1
- package/dist/utils/run-local/secrets-manager.js.map +1 -1
- package/dist/utils/sanitize.d.ts +3 -0
- package/dist/utils/sanitize.js +45 -0
- package/dist/utils/sanitize.js.map +1 -0
- package/dist/utils/variables.d.ts +28 -6
- package/dist/utils/variables.js +114 -14
- package/dist/utils/variables.js.map +1 -1
- package/package.json +12 -10
- package/scripts/extract-error-catalog.js +88 -0
- package/templates/agentic-network/agent-network.yaml.template +1 -7
- package/templates/agentic-network/brokers/broker1.agent.template +1 -1
- package/templates/agentic-network/exchange.json.template +9 -1
|
@@ -1,30 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RunLocal = exports.COMPOSE_SETTLE_TIMEOUT_MS = void 0;
|
|
4
|
+
exports.assertLocalRunSupported = assertLocalRunSupported;
|
|
5
|
+
exports.assertLocalRunSchema = assertLocalRunSchema;
|
|
4
6
|
const tslib_1 = require("tslib");
|
|
5
7
|
const core_1 = require("@oclif/core");
|
|
6
8
|
const anypoint_cli_command_lib_1 = require("anypoint-cli-command-lib");
|
|
9
|
+
const agent_fabric_commands_1 = require("../../../utils/agent-fabric-commands");
|
|
7
10
|
const node_fs_1 = require("node:fs");
|
|
8
11
|
const fs = tslib_1.__importStar(require("fs-extra"));
|
|
9
12
|
const node_net_1 = require("node:net");
|
|
13
|
+
const node_os_1 = require("node:os");
|
|
10
14
|
const node_path_1 = require("node:path");
|
|
15
|
+
const yaml_1 = require("yaml");
|
|
16
|
+
const base_error_1 = require("../../../errors/base-error");
|
|
11
17
|
const error_factory_1 = require("../../../errors/error-factory");
|
|
12
18
|
const space_serializer_1 = require("../../../utils/builders/space-serializer");
|
|
13
19
|
const facets_1 = require("../../../utils/facets/facets");
|
|
14
20
|
const project_builder_1 = require("../../../utils/builders/project-builder");
|
|
15
21
|
const project_builder_impl_1 = require("../../../utils/builders/project-builder-impl");
|
|
16
22
|
const variables_1 = require("../../../utils/variables");
|
|
23
|
+
const constants_1 = require("../../../helpers/project/constants");
|
|
17
24
|
const utils_1 = require("../../../helpers/utils");
|
|
18
|
-
const
|
|
25
|
+
const constants_2 = require("../../../utils/constants");
|
|
19
26
|
const naming_1 = require("../../../utils/naming");
|
|
20
27
|
const network_lock_1 = require("../../../utils/builders/network-lock");
|
|
21
28
|
const run_local_1 = require("../../../utils/run-local");
|
|
29
|
+
const local_tls_1 = require("../../../utils/run-local/local-tls");
|
|
30
|
+
const local_tls_model_1 = require("../../../utils/run-local/local-tls-model");
|
|
22
31
|
const GITIGNORE_FILE = '.gitignore';
|
|
23
32
|
const LOCAL_RUN_GITIGNORE_ENTRY = `${run_local_1.CHAT_ROOT_DIR}/`;
|
|
24
33
|
const LOCAL_RUN_GITIGNORE_COMMENT = '# .deployment — local render output and remote deploy descriptors; may contain secret material (e.g. the encrypted secrets store)';
|
|
25
34
|
const TARGET_DIR = 'target';
|
|
26
35
|
const VARIABLES_CACHE_FILE = 'variables.json';
|
|
27
|
-
const STORED_SECRET_PLACEHOLDER = '__KEYCHAIN__';
|
|
28
36
|
/**
|
|
29
37
|
* What the masked prompt rejects with on Ctrl+C: raw-mode stdin sees a keystroke, not a signal.
|
|
30
38
|
* The literal is thrown by the `password-prompt` package (`reject(new Error('SIGINT'))`), reached via
|
|
@@ -36,12 +44,138 @@ const RAW_MODE_SIGINT_MESSAGE = 'SIGINT';
|
|
|
36
44
|
exports.COMPOSE_SETTLE_TIMEOUT_MS = 30000;
|
|
37
45
|
/** Debounce window collapsing a burst of file-change events into a single rebuild. */
|
|
38
46
|
const WATCH_DEBOUNCE_MS = 500;
|
|
39
|
-
|
|
47
|
+
/** `exchange.json` classifier written by the v1 project template. */
|
|
48
|
+
const V1_EXCHANGE_CLASSIFIER = 'agent-network';
|
|
49
|
+
// Rejects a local run before build when exchange.json names a project local run cannot start.
|
|
50
|
+
// A missing descriptor, unreadable JSON, or a blank classifier keeps today's path so older
|
|
51
|
+
// descriptors are not rejected here (build still reports 1013 for a real unknown schema version).
|
|
52
|
+
function assertLocalRunSupported(projectPath) {
|
|
53
|
+
var _a;
|
|
54
|
+
const exchangeJsonPath = (0, node_path_1.join)(projectPath, constants_2.DESCRIPTOR_FILE);
|
|
55
|
+
if (!fs.existsSync(exchangeJsonPath)) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
let classifier;
|
|
59
|
+
try {
|
|
60
|
+
classifier = (_a = (0, utils_1.safeJsonFileParse)(exchangeJsonPath).jsonObject) === null || _a === void 0 ? void 0 : _a.classifier;
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (typeof classifier !== 'string' || classifier.trim().length === 0) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const normalized = classifier.trim();
|
|
69
|
+
if (normalized === constants_1.AgentNetworkClassifiers.AGENTIC_NETWORK) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (normalized === V1_EXCHANGE_CLASSIFIER) {
|
|
73
|
+
throw error_factory_1.ErrorFactory.v1NotSupportedForLocalRun();
|
|
74
|
+
}
|
|
75
|
+
throw error_factory_1.ErrorFactory.localRunUnsupportedProjectType(normalized);
|
|
76
|
+
}
|
|
77
|
+
const LOCAL_RUN_SCHEMA_V1 = '1.0.0';
|
|
78
|
+
function isEnoent(error) {
|
|
79
|
+
return error instanceof Error && error.code === 'ENOENT';
|
|
80
|
+
}
|
|
81
|
+
// `relative` returns `..agent.yaml` for an in-project file of that name. Only a
|
|
82
|
+
// `..` segment (or an absolute result, such as another Windows drive) is outside.
|
|
83
|
+
function pathEscapesProject(rel) {
|
|
84
|
+
return (0, node_path_1.isAbsolute)(rel) || rel.split(/[/\\]/).includes('..');
|
|
85
|
+
}
|
|
86
|
+
function declaredLocalRunMain(projectPath) {
|
|
87
|
+
var _a;
|
|
88
|
+
const exchangeJsonPath = (0, node_path_1.join)(projectPath, constants_2.DESCRIPTOR_FILE);
|
|
89
|
+
// No descriptor: build opens agent-network.yaml. Classify that file.
|
|
90
|
+
if (!fs.existsSync(exchangeJsonPath)) {
|
|
91
|
+
return 'agent-network.yaml';
|
|
92
|
+
}
|
|
93
|
+
let declared;
|
|
94
|
+
try {
|
|
95
|
+
declared = (_a = (0, utils_1.safeJsonFileParse)(exchangeJsonPath).jsonObject) === null || _a === void 0 ? void 0 : _a.main;
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
// Invalid or unreadable JSON is a descriptor failure, not a schema one.
|
|
99
|
+
// Do not invent a main and classify whatever agent-network.yaml happens to say.
|
|
100
|
+
if (error instanceof SyntaxError || isEnoent(error)) {
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
throw error;
|
|
104
|
+
}
|
|
105
|
+
if (typeof declared === 'string' && declared.trim().length > 0) {
|
|
106
|
+
return declared.trim();
|
|
107
|
+
}
|
|
108
|
+
// A descriptor with no main is 8505 later. Do not inspect a default file first.
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
function yamlInsideProject(projectPath, main) {
|
|
112
|
+
const candidate = (0, node_path_1.resolve)(projectPath, main);
|
|
113
|
+
try {
|
|
114
|
+
const root = fs.realpathSync(projectPath);
|
|
115
|
+
const real = fs.realpathSync(candidate);
|
|
116
|
+
const rel = (0, node_path_1.relative)(root, real);
|
|
117
|
+
if (pathEscapesProject(rel) || !fs.statSync(real).isFile()) {
|
|
118
|
+
return undefined;
|
|
119
|
+
}
|
|
120
|
+
return real;
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
// The main is absent. Any other I/O error is not "skip schema classification".
|
|
124
|
+
if (isEnoent(error)) {
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
127
|
+
throw error;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// APB throws UnrecognizedSpecException before the builder can raise 1013. That
|
|
131
|
+
// exception is not a BaseError, so the status file would record kind "unexpected".
|
|
132
|
+
// A document headed by agentNetwork stays on the build path so a spec error remains 1002.
|
|
133
|
+
function assertLocalRunSchema(projectPath) {
|
|
134
|
+
const main = declaredLocalRunMain(projectPath);
|
|
135
|
+
if (!main) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const yamlPath = yamlInsideProject(projectPath, main);
|
|
139
|
+
if (!yamlPath) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
let raw;
|
|
143
|
+
try {
|
|
144
|
+
raw = (0, yaml_1.parse)(fs.readFileSync(yamlPath, 'utf8'));
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
// Invalid YAML stays on the build path. A read error does not.
|
|
148
|
+
if (error instanceof yaml_1.YAMLParseError) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
throw error;
|
|
152
|
+
}
|
|
153
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
const document = raw;
|
|
157
|
+
const agentNetwork = typeof document.agentNetwork === 'string' ? document.agentNetwork.trim() : '';
|
|
158
|
+
if (agentNetwork.length > 0) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const schemaVersion = typeof document.schemaVersion === 'string' ? document.schemaVersion.trim() : '';
|
|
162
|
+
// `schemaVersion: 2.0.0` is a builder key, not a V2 document. V2 documents are
|
|
163
|
+
// headed by `agentNetwork`. Leaving this through makes APB throw a non-BaseError.
|
|
164
|
+
if (schemaVersion.length === 0) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
if (schemaVersion === LOCAL_RUN_SCHEMA_V1) {
|
|
168
|
+
throw error_factory_1.ErrorFactory.v1NotSupportedForLocalRun();
|
|
169
|
+
}
|
|
170
|
+
throw error_factory_1.ErrorFactory.unsupportedLocalRunSchema(schemaVersion);
|
|
171
|
+
}
|
|
172
|
+
class RunLocal extends agent_fabric_commands_1.AgentFabricAuthenticationCommand {
|
|
40
173
|
constructor() {
|
|
41
174
|
super(...arguments);
|
|
42
175
|
this.secretsManager = (0, run_local_1.createSecretsManager)();
|
|
43
176
|
this.runtimeManager = new run_local_1.DockerComposeEnvironmentManager();
|
|
44
177
|
this.localRunManager = new run_local_1.DefaultLocalRunManager();
|
|
178
|
+
this.localTlsEnv = {};
|
|
45
179
|
// True while a masked secret prompt is open. password-prompt resets raw mode synchronously before
|
|
46
180
|
// its Ctrl+C rejection surfaces, so this is the only signal the rebuild catch has to tell an
|
|
47
181
|
// interrupted prompt from a genuine failure once the recognized SIGINT literal drifts.
|
|
@@ -72,6 +206,8 @@ class RunLocal extends anypoint_cli_command_lib_1.AuthenticationBaseCommand {
|
|
|
72
206
|
host: flags.host,
|
|
73
207
|
dockerPort,
|
|
74
208
|
};
|
|
209
|
+
assertLocalRunSupported(projectPath);
|
|
210
|
+
assertLocalRunSchema(projectPath);
|
|
75
211
|
if (flags.build) {
|
|
76
212
|
this.buildStatus.writeRunning('building');
|
|
77
213
|
await this.buildProject(projectPath, flags.host);
|
|
@@ -110,7 +246,7 @@ class RunLocal extends anypoint_cli_command_lib_1.AuthenticationBaseCommand {
|
|
|
110
246
|
}
|
|
111
247
|
async render(options) {
|
|
112
248
|
var _a, _b;
|
|
113
|
-
const { projectPath, targetDir, localRenderDir, host, dockerPort } = options;
|
|
249
|
+
const { projectPath, targetDir, localRenderDir, host, dockerPort, properties: propertyFlags } = options;
|
|
114
250
|
const totalStart = Date.now();
|
|
115
251
|
(_a = this.buildStatus) === null || _a === void 0 ? void 0 : _a.writeRunning('rendering');
|
|
116
252
|
try {
|
|
@@ -124,13 +260,28 @@ class RunLocal extends anypoint_cli_command_lib_1.AuthenticationBaseCommand {
|
|
|
124
260
|
}
|
|
125
261
|
const localVersionVariables = RunLocal.deriveLocalVersionVariables(space);
|
|
126
262
|
(0, network_lock_1.validateNoReservedVersionVariableDeclarations)(Object.keys(variables_1.VariablesHelper.flattenVariables((_b = space.variables) !== null && _b !== void 0 ? _b : {})));
|
|
263
|
+
const tlsVariables = (0, local_tls_1.buildTlsVariableDefinitions)(space);
|
|
264
|
+
RunLocal.validateNoSecretInGatewayRoutingFields(space, tlsVariables);
|
|
127
265
|
RunLocal.validateReferencedVariablesDeclared(space, localVersionVariables);
|
|
128
|
-
|
|
129
|
-
|
|
266
|
+
this.assertNoEnvVarNameCollisions(space);
|
|
267
|
+
const knownVariables = {
|
|
268
|
+
...localVersionVariables,
|
|
269
|
+
...RunLocal.loadVariablesCache(localRenderDir),
|
|
270
|
+
...variables_1.VariablesHelper.propertiesArrayToObject(propertyFlags),
|
|
271
|
+
};
|
|
272
|
+
(0, local_tls_1.assertLocalTlsUpstreamsHttps)(space, knownVariables, true);
|
|
273
|
+
const promptTlsVariables = (0, local_tls_1.buildTlsVariableDefinitions)(space, knownVariables);
|
|
274
|
+
const sessionTls = this.localTlsSession;
|
|
130
275
|
this.localRunManager.validateExchangeAssets(space, targetDir);
|
|
131
276
|
fs.mkdirpSync(localRenderDir);
|
|
132
277
|
RunLocal.protectLocalRunInGitIgnore(projectPath);
|
|
133
|
-
const collectedProperties = await this.collectVariables(space, options);
|
|
278
|
+
const collectedProperties = await this.collectVariables(space, options, sessionTls ? {} : promptTlsVariables);
|
|
279
|
+
const resolvedVariables = { ...localVersionVariables, ...collectedProperties.properties, ...collectedProperties.securedProperties };
|
|
280
|
+
(0, local_tls_1.assertLocalTlsUpstreamsHttps)(space, resolvedVariables);
|
|
281
|
+
const localTls = sessionTls ?
|
|
282
|
+
this.reuseLocalTls(sessionTls, (0, local_tls_1.localTlsConnectionIds)(space, resolvedVariables)) :
|
|
283
|
+
(0, local_tls_1.resolveLocalTlsForSpace)(space, resolvedVariables, projectPath, name => this.secretsManager.toEnvVarName(name));
|
|
284
|
+
this.commitPendingTlsSecrets(projectPath, Object.keys(localTls));
|
|
134
285
|
const descriptor = RunLocal.loadDescriptor(projectPath);
|
|
135
286
|
const mainFile = descriptor.main;
|
|
136
287
|
if (!mainFile) {
|
|
@@ -141,9 +292,13 @@ class RunLocal extends anypoint_cli_command_lib_1.AuthenticationBaseCommand {
|
|
|
141
292
|
this.localRunManager.setup({ projectPath, targetDir, localRenderDir, space, dockerPort });
|
|
142
293
|
anypoint_cli_command_lib_1.Logger.cliEnd(`(${Date.now() - setupStart}ms) ✅`);
|
|
143
294
|
const policyResolver = new run_local_1.ExchangePolicyResolver({ req: this.req, localRenderDir, session: this.session, host });
|
|
144
|
-
const
|
|
295
|
+
const localTlsEnv = Object.assign({}, ...Object.values(localTls).map(resolution => resolution.secureEnv));
|
|
296
|
+
const bindings = Object.fromEntries(Object.entries(localTls).map(([id, resolution]) => [id, resolution.bindingConfig]));
|
|
297
|
+
const renderVariables = await this.stepRenderFacets(space, collectedProperties, localRenderDir, policyResolver, dockerPort, localVersionVariables, { bindings, variables: tlsVariables });
|
|
145
298
|
await this.stepDownloadPolicies(policyResolver, localRenderDir);
|
|
146
|
-
this.stepWriteRuntimeConfig(localRenderDir, space, mainFile, dockerPort, renderVariables);
|
|
299
|
+
this.stepWriteRuntimeConfig(localRenderDir, space, mainFile, dockerPort, renderVariables, Object.keys(localTlsEnv));
|
|
300
|
+
this.localTlsSession = { ...this.localTlsSession, ...localTls };
|
|
301
|
+
this.localTlsEnv = localTlsEnv;
|
|
147
302
|
}
|
|
148
303
|
catch (error) {
|
|
149
304
|
anypoint_cli_command_lib_1.Logger.cliEndFailed();
|
|
@@ -156,10 +311,10 @@ class RunLocal extends anypoint_cli_command_lib_1.AuthenticationBaseCommand {
|
|
|
156
311
|
async startRuntime(options) {
|
|
157
312
|
var _a, _b, _c, _d;
|
|
158
313
|
const space = this.loadBuiltSpace(options.targetDir);
|
|
159
|
-
|
|
314
|
+
this.assertNoEnvVarNameCollisions(space);
|
|
160
315
|
(_a = this.buildStatus) === null || _a === void 0 ? void 0 : _a.writeRunning('deploying');
|
|
161
316
|
this.runtimeManager.assertAgentGraphImage();
|
|
162
|
-
const env = this.runtimeManager.buildEnv(this.secretsManager, options.projectPath, space);
|
|
317
|
+
const env = this.runtimeManager.buildEnv(this.secretsManager, options.projectPath, space, this.localTlsEnv);
|
|
163
318
|
try {
|
|
164
319
|
await this.runtimeManager.start(options.localRenderDir, env);
|
|
165
320
|
// Attached compose exited cleanly (containers stopped) — treat as graceful stop.
|
|
@@ -178,7 +333,7 @@ class RunLocal extends anypoint_cli_command_lib_1.AuthenticationBaseCommand {
|
|
|
178
333
|
runWithWatch(options) {
|
|
179
334
|
// Extracted into WatchSession so each unit of the watch state machine stays independently
|
|
180
335
|
// readable; the closures previously shared ~10 mutable locals folded into one method.
|
|
181
|
-
return new WatchSession(options, this.runtimeManager, this.secretsManager, (projectPath, host) => this.buildProject(projectPath, host), opts => this.render(opts), targetDir => this.loadBuiltSpace(targetDir), () => this.maskedPromptOpen, (pending, timeoutMs) => RunLocal.settleOrTimeout(pending, timeoutMs), this.buildStatus).run();
|
|
336
|
+
return new WatchSession(options, this.runtimeManager, this.secretsManager, (projectPath, host) => this.buildProject(projectPath, host), opts => this.render(opts), targetDir => this.loadBuiltSpace(targetDir), () => this.maskedPromptOpen, (pending, timeoutMs) => RunLocal.settleOrTimeout(pending, timeoutMs), this.buildStatus, () => this.localTlsEnv).run();
|
|
182
337
|
}
|
|
183
338
|
// Never rejects, so teardown can sequence on it unconditionally. Timer unref'd to not hold the loop.
|
|
184
339
|
static settleOrTimeout(pending, timeoutMs) {
|
|
@@ -199,23 +354,71 @@ class RunLocal extends anypoint_cli_command_lib_1.AuthenticationBaseCommand {
|
|
|
199
354
|
}
|
|
200
355
|
return space;
|
|
201
356
|
}
|
|
357
|
+
assertNoEnvVarNameCollisions(space) {
|
|
358
|
+
RunLocal.validateNoEnvVarNameCollisions(space, [
|
|
359
|
+
{ fn: key => this.secretsManager.toEnvVarName(key), extraKeys: (0, local_tls_1.localTlsSecretKeys)(space) },
|
|
360
|
+
{ fn: naming_1.toAgentGraphEnvVarName },
|
|
361
|
+
]);
|
|
362
|
+
}
|
|
363
|
+
reuseLocalTls(session, connectionIds) {
|
|
364
|
+
return Object.fromEntries(connectionIds.map(id => {
|
|
365
|
+
if (!session[id]) {
|
|
366
|
+
throw error_factory_1.ErrorFactory.localTlsAddedWhileWatching(id);
|
|
367
|
+
}
|
|
368
|
+
return [id, session[id]];
|
|
369
|
+
}));
|
|
370
|
+
}
|
|
202
371
|
seedStoredSecretPlaceholders(variables, mergedDefaults, projectPath) {
|
|
203
372
|
const flatVars = variables_1.VariablesHelper.flattenVariables(variables);
|
|
204
373
|
for (const [key, varDef] of Object.entries(flatVars)) {
|
|
205
|
-
if (!variables_1.VariablesHelper.
|
|
374
|
+
if (!variables_1.VariablesHelper.isLocallySecured(varDef)) {
|
|
206
375
|
continue;
|
|
207
376
|
}
|
|
208
377
|
if (mergedDefaults[key]) {
|
|
209
378
|
continue;
|
|
210
379
|
}
|
|
211
380
|
if (this.secretsManager.exists(projectPath, key)) {
|
|
212
|
-
mergedDefaults[key] = STORED_SECRET_PLACEHOLDER;
|
|
381
|
+
mergedDefaults[key] = run_local_1.STORED_SECRET_PLACEHOLDER;
|
|
213
382
|
}
|
|
214
383
|
}
|
|
215
384
|
}
|
|
216
|
-
|
|
385
|
+
auditSecretEvent(action, projectPath, key, outcome) {
|
|
386
|
+
anypoint_cli_command_lib_1.Logger.info(JSON.stringify({
|
|
387
|
+
event: 'local-secret-change',
|
|
388
|
+
actor: (0, node_os_1.userInfo)().username,
|
|
389
|
+
action,
|
|
390
|
+
project: projectPath,
|
|
391
|
+
key,
|
|
392
|
+
outcome,
|
|
393
|
+
timestamp: new Date().toISOString(),
|
|
394
|
+
}));
|
|
395
|
+
}
|
|
396
|
+
persistSecret(projectPath, key, value) {
|
|
397
|
+
const stored = this.secretsManager.store(projectPath, key, value);
|
|
398
|
+
this.auditSecretEvent('store', projectPath, key, stored ? 'success' : 'failure');
|
|
399
|
+
if (!stored) {
|
|
400
|
+
anypoint_cli_command_lib_1.Logger.warn(`Could not persist secret '${key}' to the secrets backend; ` +
|
|
401
|
+
'it will be used for this run but will not be available on the next run.');
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
commitPendingTlsSecrets(projectPath, resolvedIds) {
|
|
405
|
+
var _a;
|
|
406
|
+
const { store, remove } = (_a = this.pendingTlsSecrets) !== null && _a !== void 0 ? _a : { store: {}, remove: [] };
|
|
407
|
+
this.pendingTlsSecrets = undefined;
|
|
408
|
+
const resolvedKeys = (0, local_tls_model_1.tlsKeysFor)(resolvedIds);
|
|
409
|
+
for (const [key, value] of Object.entries(store)) {
|
|
410
|
+
if (resolvedKeys.has(key)) {
|
|
411
|
+
this.persistSecret(projectPath, key, value);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
for (const key of remove) {
|
|
415
|
+
const deleted = this.secretsManager.delete(projectPath, key);
|
|
416
|
+
this.auditSecretEvent('delete', projectPath, key, deleted ? 'success' : 'failure');
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
hydrateOrPersistSecuredProperties(collectedProperties, projectPath, deferredKeys, pending) {
|
|
217
420
|
for (const [key, value] of Object.entries(collectedProperties.securedProperties)) {
|
|
218
|
-
if (value === STORED_SECRET_PLACEHOLDER) {
|
|
421
|
+
if (value === run_local_1.STORED_SECRET_PLACEHOLDER) {
|
|
219
422
|
// Fail loud rather than write a blank key: a null value means the keychain entry
|
|
220
423
|
// was deleted or the secrets file failed to decrypt.
|
|
221
424
|
const stored = this.secretsManager.retrieve(projectPath, key);
|
|
@@ -224,44 +427,57 @@ class RunLocal extends anypoint_cli_command_lib_1.AuthenticationBaseCommand {
|
|
|
224
427
|
}
|
|
225
428
|
collectedProperties.securedProperties[key] = stored;
|
|
226
429
|
}
|
|
227
|
-
else {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
anypoint_cli_command_lib_1.Logger.warn(`Could not persist secret '${key}' to the secrets backend; ` +
|
|
231
|
-
'it will be used for this run but will not be available on the next run.');
|
|
430
|
+
else if (key in deferredKeys) {
|
|
431
|
+
if (value !== '') {
|
|
432
|
+
pending.store[key] = value;
|
|
232
433
|
}
|
|
233
434
|
}
|
|
435
|
+
else {
|
|
436
|
+
this.persistSecret(projectPath, key, value);
|
|
437
|
+
}
|
|
234
438
|
}
|
|
235
439
|
}
|
|
236
|
-
async collectVariables(space, options) {
|
|
237
|
-
var _a, _b;
|
|
440
|
+
async collectVariables(space, options, tlsVariables) {
|
|
441
|
+
var _a, _b, _c, _d;
|
|
442
|
+
this.pendingTlsSecrets = undefined;
|
|
238
443
|
let collectedProperties = { properties: {}, securedProperties: {} };
|
|
239
|
-
|
|
240
|
-
if (!variables) {
|
|
444
|
+
if (Object.keys({ ...space.variables, ...tlsVariables }).length === 0) {
|
|
241
445
|
return collectedProperties;
|
|
242
446
|
}
|
|
243
447
|
const cachedVars = RunLocal.loadVariablesCache(options.localRenderDir);
|
|
244
448
|
const flagVars = variables_1.VariablesHelper.propertiesArrayToObject(options.properties);
|
|
245
|
-
const
|
|
246
|
-
|
|
247
|
-
|
|
449
|
+
const cachedUserVars = Object.fromEntries(Object.entries(cachedVars).filter(([key]) => !(key in tlsVariables)));
|
|
450
|
+
const mergedDefaults = { ...cachedUserVars, ...flagVars };
|
|
451
|
+
this.seedStoredSecretPlaceholders((_a = space.variables) !== null && _a !== void 0 ? _a : {}, mergedDefaults, options.projectPath);
|
|
452
|
+
const variables = { ...space.variables, ...(0, local_tls_1.withCachedTlsDefaults)(tlsVariables, cachedVars) };
|
|
453
|
+
const promptOptions = { promptSecretRefs: true };
|
|
454
|
+
const needsPrompts = variables_1.VariablesHelper.checkIfPromptsNeeded(variables, mergedDefaults, '', flagVars, promptOptions);
|
|
248
455
|
if (needsPrompts) {
|
|
249
456
|
anypoint_cli_command_lib_1.Logger.print('Please provide values for the following variables:');
|
|
250
|
-
(
|
|
457
|
+
(_b = this.buildStatus) === null || _b === void 0 ? void 0 : _b.writeRunning('waiting_for_input');
|
|
251
458
|
}
|
|
252
459
|
// Only while a prompt is actually open: a throw after a no-prompt collect must be `failed`, not Ctrl+C.
|
|
253
460
|
this.maskedPromptOpen = needsPrompts;
|
|
254
|
-
collectedProperties = await variables_1.VariablesHelper.promptForVariables(variables, mergedDefaults);
|
|
461
|
+
collectedProperties = await variables_1.VariablesHelper.promptForVariables(variables, mergedDefaults, '', flagVars, promptOptions);
|
|
255
462
|
this.maskedPromptOpen = false;
|
|
256
463
|
if (needsPrompts) {
|
|
257
|
-
(
|
|
464
|
+
(_c = this.buildStatus) === null || _c === void 0 ? void 0 : _c.writeRunning('rendering');
|
|
258
465
|
}
|
|
259
|
-
|
|
260
|
-
|
|
466
|
+
const pending = {
|
|
467
|
+
store: {},
|
|
468
|
+
remove: (0, local_tls_1.applyTlsOptionalAnswers)({ collected: collectedProperties, tlsVariables, flagVars, projectPath: options.projectPath, secretsManager: this.secretsManager }),
|
|
469
|
+
};
|
|
470
|
+
this.hydrateOrPersistSecuredProperties(collectedProperties, options.projectPath, tlsVariables, pending);
|
|
471
|
+
this.pendingTlsSecrets = pending;
|
|
472
|
+
const currentTlsIds = [...new Set([...(0, local_tls_1.localTlsConnectionIds)(space), ...Object.keys((_d = this.localTlsSession) !== null && _d !== void 0 ? _d : {})])];
|
|
473
|
+
RunLocal.saveVariablesCache(options.localRenderDir, {
|
|
474
|
+
properties: { ...(0, local_tls_1.retainedTlsAnswers)(cachedVars, currentTlsIds, collectedProperties), ...collectedProperties.properties },
|
|
475
|
+
securedProperties: collectedProperties.securedProperties,
|
|
476
|
+
});
|
|
261
477
|
return collectedProperties;
|
|
262
478
|
}
|
|
263
479
|
/** Returns the redaction map the facets rendered against. Built after the stage: facets inject variables while it runs. */
|
|
264
|
-
async stepRenderFacets(space, properties, localRenderDir, policyResolver, dockerPort, localVersionVariables
|
|
480
|
+
async stepRenderFacets(space, properties, localRenderDir, policyResolver, dockerPort, localVersionVariables, tls) {
|
|
265
481
|
anypoint_cli_command_lib_1.Logger.cliStart('Rendering gateway and agent-graph configuration');
|
|
266
482
|
const start = Date.now();
|
|
267
483
|
const stageContext = new project_builder_impl_1.DefaultStageContextBuilder(this.req)
|
|
@@ -269,13 +485,14 @@ class RunLocal extends anypoint_cli_command_lib_1.AuthenticationBaseCommand {
|
|
|
269
485
|
.withLocalRenderDir(localRenderDir)
|
|
270
486
|
.withPolicyResolver(policyResolver)
|
|
271
487
|
.withDockerPort(dockerPort)
|
|
488
|
+
.withLocalTls(tls.bindings)
|
|
272
489
|
.build();
|
|
273
490
|
for (const [key, version] of Object.entries(localVersionVariables)) {
|
|
274
491
|
stageContext.stageResultRegistry.withVariable(key, version);
|
|
275
492
|
}
|
|
276
493
|
await facets_1.ProjectFacets.execute(project_builder_1.Stages.LocalRender, space, stageContext);
|
|
277
494
|
anypoint_cli_command_lib_1.Logger.cliEnd(`(${Date.now() - start}ms) ✅`);
|
|
278
|
-
return variables_1.VariablesHelper.buildSecretRedactionMap(space.variables, variables_1.VariablesHelper.getAllVariablesFromContext(stageContext));
|
|
495
|
+
return variables_1.VariablesHelper.buildSecretRedactionMap({ ...space.variables, ...tls.variables }, variables_1.VariablesHelper.getAllVariablesFromContext(stageContext));
|
|
279
496
|
}
|
|
280
497
|
async stepDownloadPolicies(policyResolver, localRenderDir) {
|
|
281
498
|
anypoint_cli_command_lib_1.Logger.cliStart('Downloading custom policies');
|
|
@@ -288,7 +505,7 @@ class RunLocal extends anypoint_cli_command_lib_1.AuthenticationBaseCommand {
|
|
|
288
505
|
anypoint_cli_command_lib_1.Logger.cliEnd(`(${Date.now() - start}ms) ✅`);
|
|
289
506
|
}
|
|
290
507
|
}
|
|
291
|
-
stepWriteRuntimeConfig(localRenderDir, space, mainFile, dockerPort, renderVariables) {
|
|
508
|
+
stepWriteRuntimeConfig(localRenderDir, space, mainFile, dockerPort, renderVariables, tlsEnvNames) {
|
|
292
509
|
anypoint_cli_command_lib_1.Logger.cliStart('Writing runtime configuration');
|
|
293
510
|
const start = Date.now();
|
|
294
511
|
// Every secret reaches its container through env-var indirection, never baked into on-disk
|
|
@@ -304,9 +521,9 @@ class RunLocal extends anypoint_cli_command_lib_1.AuthenticationBaseCommand {
|
|
|
304
521
|
});
|
|
305
522
|
runtimeManager.addGateway({
|
|
306
523
|
side: 'egress',
|
|
307
|
-
port:
|
|
524
|
+
port: constants_2.EGRESS_GW_PORT,
|
|
308
525
|
configDir: './egress/config',
|
|
309
|
-
securedEnvPassthrough: gatewayEnvPassthrough,
|
|
526
|
+
securedEnvPassthrough: { ...gatewayEnvPassthrough, ...RunLocal.buildTlsEnvPassthrough(tlsEnvNames) },
|
|
310
527
|
});
|
|
311
528
|
runtimeManager.addStaticServer({
|
|
312
529
|
assetsDir: './exchange',
|
|
@@ -346,7 +563,7 @@ class RunLocal extends anypoint_cli_command_lib_1.AuthenticationBaseCommand {
|
|
|
346
563
|
const gatewayEnvPassthrough = {};
|
|
347
564
|
const flatVars = variables_1.VariablesHelper.flattenVariables((_a = space.variables) !== null && _a !== void 0 ? _a : {});
|
|
348
565
|
for (const [key, varDef] of Object.entries(flatVars)) {
|
|
349
|
-
if (!variables_1.VariablesHelper.
|
|
566
|
+
if (!variables_1.VariablesHelper.isLocallySecured(varDef)) {
|
|
350
567
|
continue;
|
|
351
568
|
}
|
|
352
569
|
const secureName = this.secretsManager.toEnvVarName(key);
|
|
@@ -356,17 +573,20 @@ class RunLocal extends anypoint_cli_command_lib_1.AuthenticationBaseCommand {
|
|
|
356
573
|
}
|
|
357
574
|
return { agentGraphEnvPassthrough, gatewayEnvPassthrough };
|
|
358
575
|
}
|
|
576
|
+
static buildTlsEnvPassthrough(tlsEnvNames) {
|
|
577
|
+
return Object.fromEntries(tlsEnvNames.map(name => [name, `\${${name}:-}`]));
|
|
578
|
+
}
|
|
359
579
|
/** Platforms (e.g. 'gemini') a broker's LLM connections use, for selecting its placeholder api-key env var. */
|
|
360
580
|
static resolveLlmPlatforms(space, agentGraph) {
|
|
361
581
|
var _a;
|
|
362
582
|
const platforms = new Set();
|
|
363
583
|
for (const connection of agentGraph.connections) {
|
|
364
|
-
if (connection.type !==
|
|
584
|
+
if (connection.type !== constants_2.LLM_ASSET_TYPE) {
|
|
365
585
|
continue;
|
|
366
586
|
}
|
|
367
587
|
for (const component of Object.values(space.components)) {
|
|
368
588
|
for (const asset of Object.values(component.assets)) {
|
|
369
|
-
if (asset.type ===
|
|
589
|
+
if (asset.type === constants_2.LLM_ASSET_TYPE && asset.assetId === connection.asset.assetId && ((_a = asset.properties) === null || _a === void 0 ? void 0 : _a.platform)) {
|
|
370
590
|
platforms.add(asset.properties.platform);
|
|
371
591
|
}
|
|
372
592
|
}
|
|
@@ -443,7 +663,7 @@ class RunLocal extends anypoint_cli_command_lib_1.AuthenticationBaseCommand {
|
|
|
443
663
|
});
|
|
444
664
|
}
|
|
445
665
|
static loadDescriptor(projectPath) {
|
|
446
|
-
const exchangeJsonPath = (0, node_path_1.join)(projectPath,
|
|
666
|
+
const exchangeJsonPath = (0, node_path_1.join)(projectPath, constants_2.DESCRIPTOR_FILE);
|
|
447
667
|
return (0, utils_1.safeJsonFileParse)(exchangeJsonPath).jsonObject;
|
|
448
668
|
}
|
|
449
669
|
static hasV2Components(space) {
|
|
@@ -533,10 +753,9 @@ class RunLocal extends anypoint_cli_command_lib_1.AuthenticationBaseCommand {
|
|
|
533
753
|
throw error_factory_1.ErrorFactory.secretUpstreamAddress(connection.id, inUpstream);
|
|
534
754
|
}
|
|
535
755
|
}
|
|
536
|
-
static validateNoSecretInGatewayRoutingFields(space) {
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
.filter(([, varDef]) => variables_1.VariablesHelper.isSecret(varDef))
|
|
756
|
+
static validateNoSecretInGatewayRoutingFields(space, generatedVariables = {}) {
|
|
757
|
+
const secretKeys = new Set(Object.entries(variables_1.VariablesHelper.flattenVariables({ ...space.variables, ...generatedVariables }))
|
|
758
|
+
.filter(([, varDef]) => variables_1.VariablesHelper.isLocallySecured(varDef))
|
|
540
759
|
.map(([key]) => key));
|
|
541
760
|
if (secretKeys.size === 0) {
|
|
542
761
|
return;
|
|
@@ -560,11 +779,12 @@ class RunLocal extends anypoint_cli_command_lib_1.AuthenticationBaseCommand {
|
|
|
560
779
|
static validateNoEnvVarNameCollisions(space, normalizers) {
|
|
561
780
|
var _a;
|
|
562
781
|
const secretKeys = Object.entries(variables_1.VariablesHelper.flattenVariables((_a = space.variables) !== null && _a !== void 0 ? _a : {}))
|
|
563
|
-
.filter(([, varDef]) => variables_1.VariablesHelper.
|
|
782
|
+
.filter(([, varDef]) => variables_1.VariablesHelper.isLocallySecured(varDef))
|
|
564
783
|
.map(([key]) => key);
|
|
565
|
-
for (const normalize of normalizers) {
|
|
784
|
+
for (const { fn: normalize, extraKeys = [] } of normalizers) {
|
|
785
|
+
const keys = [...secretKeys, ...extraKeys];
|
|
566
786
|
const seen = new Map();
|
|
567
|
-
for (const key of
|
|
787
|
+
for (const key of keys) {
|
|
568
788
|
const envVarName = normalize(key);
|
|
569
789
|
const existing = seen.get(envVarName);
|
|
570
790
|
if (existing !== undefined) {
|
|
@@ -588,7 +808,7 @@ RunLocal.examples = [
|
|
|
588
808
|
'$ agent-network project run-local --path ./my-project --property myAgent.url:https://api.example.com',
|
|
589
809
|
];
|
|
590
810
|
RunLocal.flags = {
|
|
591
|
-
...
|
|
811
|
+
...agent_fabric_commands_1.AgentFabricAuthenticationCommand.flags,
|
|
592
812
|
path: core_1.Flags.file({
|
|
593
813
|
description: 'The path to the project.',
|
|
594
814
|
default: '.',
|
|
@@ -620,7 +840,7 @@ RunLocal.flags = {
|
|
|
620
840
|
* thunks so no `RunLocal` member visibility has to widen.
|
|
621
841
|
*/
|
|
622
842
|
class WatchSession {
|
|
623
|
-
constructor(options, runtimeManager, secretsManager, buildProject, render, loadBuiltSpace, isMaskedPromptOpen, settleOrTimeout, buildStatus) {
|
|
843
|
+
constructor(options, runtimeManager, secretsManager, buildProject, render, loadBuiltSpace, isMaskedPromptOpen, settleOrTimeout, buildStatus, localTlsEnv) {
|
|
624
844
|
this.options = options;
|
|
625
845
|
this.runtimeManager = runtimeManager;
|
|
626
846
|
this.secretsManager = secretsManager;
|
|
@@ -630,6 +850,7 @@ class WatchSession {
|
|
|
630
850
|
this.isMaskedPromptOpen = isMaskedPromptOpen;
|
|
631
851
|
this.settleOrTimeout = settleOrTimeout;
|
|
632
852
|
this.buildStatus = buildStatus;
|
|
853
|
+
this.localTlsEnv = localTlsEnv;
|
|
633
854
|
this.pendingRebuild = false;
|
|
634
855
|
this.shuttingDown = false;
|
|
635
856
|
this.debounceTimer = null;
|
|
@@ -653,7 +874,7 @@ class WatchSession {
|
|
|
653
874
|
async run() {
|
|
654
875
|
var _a, _b;
|
|
655
876
|
const { projectPath, targetDir, localRenderDir } = this.options;
|
|
656
|
-
const env = this.runtimeManager.buildEnv(this.secretsManager, projectPath, this.loadBuiltSpace(targetDir));
|
|
877
|
+
const env = this.runtimeManager.buildEnv(this.secretsManager, projectPath, this.loadBuiltSpace(targetDir), this.localTlsEnv());
|
|
657
878
|
// With compose detached, nothing else keeps the command alive: only a signal ends the session.
|
|
658
879
|
const session = new Promise(resolveFn => {
|
|
659
880
|
this.resolveSession = resolveFn;
|
|
@@ -680,13 +901,17 @@ class WatchSession {
|
|
|
680
901
|
await session;
|
|
681
902
|
}
|
|
682
903
|
catch (error) {
|
|
683
|
-
//
|
|
684
|
-
//
|
|
685
|
-
//
|
|
686
|
-
|
|
904
|
+
// A partial `up` holds the ingress port. Name the unhealthy service only for that compose
|
|
905
|
+
// failure, and only when teardown has not already started: a signal or an image-missing
|
|
906
|
+
// BaseError must not wait on `docker compose logs` or rewrite a non-compose error.
|
|
907
|
+
const explained = this.shuttingDown || !isDetachedComposeFailure(error) ?
|
|
908
|
+
error :
|
|
909
|
+
await this.explainComposeFailure(error);
|
|
910
|
+
// Route the teardown through shutdown() so its `shuttingDown` guard owns the single `compose down`
|
|
911
|
+
// even if a signal races in; await session (rethrowing would skip it and oclif exits mid-`down`).
|
|
687
912
|
this.shutdown('error');
|
|
688
913
|
await session;
|
|
689
|
-
throw
|
|
914
|
+
throw explained;
|
|
690
915
|
}
|
|
691
916
|
}
|
|
692
917
|
finally {
|
|
@@ -735,6 +960,8 @@ class WatchSession {
|
|
|
735
960
|
async runRebuild() {
|
|
736
961
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
737
962
|
const { projectPath, targetDir, localRenderDir, host } = this.options;
|
|
963
|
+
// Set only around applyChanges, so a build or render failure does not ask docker for a diagnosis.
|
|
964
|
+
let composeApplyFailed = false;
|
|
738
965
|
anypoint_cli_command_lib_1.Logger.print('');
|
|
739
966
|
anypoint_cli_command_lib_1.Logger.info('Change detected, rebuilding...');
|
|
740
967
|
// Stopped for the whole rebuild so inherited container output can't drown a masked secret prompt.
|
|
@@ -746,12 +973,14 @@ class WatchSession {
|
|
|
746
973
|
(_c = this.buildStatus) === null || _c === void 0 ? void 0 : _c.beginWatchGeneration();
|
|
747
974
|
(_d = this.buildStatus) === null || _d === void 0 ? void 0 : _d.writeRunning('building');
|
|
748
975
|
try {
|
|
976
|
+
assertLocalRunSupported(projectPath);
|
|
977
|
+
assertLocalRunSchema(projectPath);
|
|
749
978
|
await this.buildProject(projectPath, host);
|
|
750
979
|
await this.render(this.options);
|
|
751
980
|
anypoint_cli_command_lib_1.Logger.info('Applying changes to the local environment...');
|
|
752
981
|
// Re-read: this render may have declared a variable the pre-loop env doesn't carry.
|
|
753
982
|
const space = this.loadBuiltSpace(targetDir);
|
|
754
|
-
const env = this.runtimeManager.buildEnv(this.secretsManager, projectPath, space);
|
|
983
|
+
const env = this.runtimeManager.buildEnv(this.secretsManager, projectPath, space, this.localTlsEnv());
|
|
755
984
|
if (this.shuttingDown) {
|
|
756
985
|
return;
|
|
757
986
|
}
|
|
@@ -760,7 +989,9 @@ class WatchSession {
|
|
|
760
989
|
// forward so the next rebuild diffs against the state this one just applied.
|
|
761
990
|
const { services, fingerprints } = (0, run_local_1.selectBrokersToRecreate)(space, localRenderDir, this.priorFingerprints);
|
|
762
991
|
(_e = this.buildStatus) === null || _e === void 0 ? void 0 : _e.writeRunning('deploying');
|
|
992
|
+
composeApplyFailed = true;
|
|
763
993
|
await this.trackCompose(() => this.runtimeManager.applyChanges(localRenderDir, env, services));
|
|
994
|
+
composeApplyFailed = false;
|
|
764
995
|
// Advanced only after the apply resolves: a failed recreate must leave the baseline at the
|
|
765
996
|
// last-applied state so the next rebuild re-selects the still-pending broker.
|
|
766
997
|
this.priorFingerprints = fingerprints;
|
|
@@ -781,8 +1012,13 @@ class WatchSession {
|
|
|
781
1012
|
if (this.shuttingDown) {
|
|
782
1013
|
return;
|
|
783
1014
|
}
|
|
784
|
-
|
|
785
|
-
|
|
1015
|
+
// Containers are still up on a failed apply. Read them before the session re-attaches logs,
|
|
1016
|
+
// and do not `compose down` — a rebuild failure keeps the previous environment.
|
|
1017
|
+
const reported = composeApplyFailed && isDetachedComposeFailure(error) ?
|
|
1018
|
+
await this.explainComposeFailure(error) :
|
|
1019
|
+
error;
|
|
1020
|
+
(_g = this.buildStatus) === null || _g === void 0 ? void 0 : _g.writeFailed(reported);
|
|
1021
|
+
anypoint_cli_command_lib_1.Logger.error(`Rebuild failed: ${reported instanceof Error ? reported.message : String(reported)}`);
|
|
786
1022
|
}
|
|
787
1023
|
finally {
|
|
788
1024
|
// Every way out of the rebuild left the follower stopped; a session without one stays silent.
|
|
@@ -793,6 +1029,30 @@ class WatchSession {
|
|
|
793
1029
|
}
|
|
794
1030
|
}
|
|
795
1031
|
}
|
|
1032
|
+
/**
|
|
1033
|
+
* Prints a bounded compose diagnosis, then returns `error` with the failing service names appended.
|
|
1034
|
+
* The log text stays out of build-status.json: that file stores phase and kind only.
|
|
1035
|
+
*/
|
|
1036
|
+
async explainComposeFailure(error) {
|
|
1037
|
+
let failingServices = [];
|
|
1038
|
+
let text = '';
|
|
1039
|
+
try {
|
|
1040
|
+
const diagnosis = await this.runtimeManager.diagnoseComposeFailure(this.options.localRenderDir);
|
|
1041
|
+
failingServices = diagnosis.failingServices;
|
|
1042
|
+
text = diagnosis.text;
|
|
1043
|
+
}
|
|
1044
|
+
catch {
|
|
1045
|
+
// Advisory. A docker failure here must not skip teardown or hide the original error.
|
|
1046
|
+
}
|
|
1047
|
+
// A signal during the await has already started teardown. Do not print logs for that cancel.
|
|
1048
|
+
if (this.shuttingDown) {
|
|
1049
|
+
return error;
|
|
1050
|
+
}
|
|
1051
|
+
if (text.length > 0) {
|
|
1052
|
+
anypoint_cli_command_lib_1.Logger.error(text);
|
|
1053
|
+
}
|
|
1054
|
+
return annotateComposeFailure(error, failingServices);
|
|
1055
|
+
}
|
|
796
1056
|
shutdown(reason) {
|
|
797
1057
|
var _a, _b, _c, _d, _e;
|
|
798
1058
|
// Both signals may arrive, or a second Ctrl+C: re-entry would run a concurrent `compose down`.
|
|
@@ -822,4 +1082,23 @@ class WatchSession {
|
|
|
822
1082
|
Promise.allSettled([composeTornDown, followerStopped]).finally(() => this.resolveSession());
|
|
823
1083
|
}
|
|
824
1084
|
}
|
|
1085
|
+
/** A plain `docker compose … exited with code` error. Signals and BaseError stay untouched. */
|
|
1086
|
+
function isDetachedComposeFailure(error) {
|
|
1087
|
+
return error instanceof Error &&
|
|
1088
|
+
!(error instanceof base_error_1.BaseError) &&
|
|
1089
|
+
!(0, run_local_1.isComposeSignalExit)(error) &&
|
|
1090
|
+
error.message.startsWith('docker compose ');
|
|
1091
|
+
}
|
|
1092
|
+
/** Keeps the original exit-code text and names the services `ps` reported, when it reported any. */
|
|
1093
|
+
function annotateComposeFailure(error, failingServices) {
|
|
1094
|
+
if (failingServices.length === 0 || !isDetachedComposeFailure(error)) {
|
|
1095
|
+
return error;
|
|
1096
|
+
}
|
|
1097
|
+
const note = `(${failingServices.join(', ')} failed)`;
|
|
1098
|
+
if (error.message.includes(note)) {
|
|
1099
|
+
return error;
|
|
1100
|
+
}
|
|
1101
|
+
error.message = `${error.message} ${note}`;
|
|
1102
|
+
return error;
|
|
1103
|
+
}
|
|
825
1104
|
//# sourceMappingURL=run-local.js.map
|