@vfarcic/dot-ai 0.195.0 → 1.0.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/README.md +2 -7
- package/dist/core/capability-scan-workflow.d.ts +4 -3
- package/dist/core/capability-scan-workflow.d.ts.map +1 -1
- package/dist/core/capability-scan-workflow.js +34 -39
- package/dist/core/circuit-breaker.d.ts +1 -0
- package/dist/core/circuit-breaker.d.ts.map +1 -1
- package/dist/core/circuit-breaker.js +11 -3
- package/dist/core/command-executor.d.ts +10 -1
- package/dist/core/command-executor.d.ts.map +1 -1
- package/dist/core/command-executor.js +63 -48
- package/dist/core/crd-availability.d.ts +6 -1
- package/dist/core/crd-availability.d.ts.map +1 -1
- package/dist/core/crd-availability.js +59 -49
- package/dist/core/deploy-operation.d.ts +17 -3
- package/dist/core/deploy-operation.d.ts.map +1 -1
- package/dist/core/deploy-operation.js +72 -21
- package/dist/core/discovery.d.ts +16 -43
- package/dist/core/discovery.d.ts.map +1 -1
- package/dist/core/discovery.js +128 -277
- package/dist/core/index.d.ts +10 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +20 -9
- package/dist/core/pattern-operations.d.ts +3 -1
- package/dist/core/pattern-operations.d.ts.map +1 -1
- package/dist/core/pattern-operations.js +3 -2
- package/dist/core/plugin-client.d.ts +53 -0
- package/dist/core/plugin-client.d.ts.map +1 -0
- package/dist/core/plugin-client.js +148 -0
- package/dist/core/plugin-manager.d.ts +119 -0
- package/dist/core/plugin-manager.d.ts.map +1 -0
- package/dist/core/plugin-manager.js +366 -0
- package/dist/core/plugin-types.d.ts +100 -0
- package/dist/core/plugin-types.d.ts.map +1 -0
- package/dist/core/plugin-types.js +10 -0
- package/dist/core/policy-operations.d.ts +15 -7
- package/dist/core/policy-operations.d.ts.map +1 -1
- package/dist/core/policy-operations.js +59 -31
- package/dist/core/resource-tools.d.ts +2 -90
- package/dist/core/resource-tools.d.ts.map +1 -1
- package/dist/core/resource-tools.js +4 -178
- package/dist/core/schema.d.ts +18 -2
- package/dist/core/schema.d.ts.map +1 -1
- package/dist/core/schema.js +118 -16
- package/dist/core/telemetry/client.d.ts +7 -0
- package/dist/core/telemetry/client.d.ts.map +1 -1
- package/dist/core/telemetry/client.js +51 -51
- package/dist/core/telemetry/index.d.ts +1 -1
- package/dist/core/telemetry/index.d.ts.map +1 -1
- package/dist/core/telemetry/index.js +2 -1
- package/dist/core/telemetry/types.d.ts +1 -3
- package/dist/core/telemetry/types.d.ts.map +1 -1
- package/dist/core/tracing/index.d.ts +0 -1
- package/dist/core/tracing/index.d.ts.map +1 -1
- package/dist/core/tracing/index.js +1 -4
- package/dist/core/unified-creation-session.d.ts +6 -1
- package/dist/core/unified-creation-session.d.ts.map +1 -1
- package/dist/core/unified-creation-session.js +19 -11
- package/dist/interfaces/mcp.d.ts +8 -2
- package/dist/interfaces/mcp.d.ts.map +1 -1
- package/dist/interfaces/mcp.js +85 -34
- package/dist/interfaces/resource-sync-handler.d.ts.map +1 -1
- package/dist/interfaces/resource-sync-handler.js +37 -17
- package/dist/interfaces/rest-api.d.ts +4 -1
- package/dist/interfaces/rest-api.d.ts.map +1 -1
- package/dist/interfaces/rest-api.js +172 -49
- package/dist/mcp/server.js +39 -54
- package/dist/tools/deploy-manifests.d.ts +3 -1
- package/dist/tools/deploy-manifests.d.ts.map +1 -1
- package/dist/tools/deploy-manifests.js +112 -13
- package/dist/tools/generate-manifests.d.ts +3 -1
- package/dist/tools/generate-manifests.d.ts.map +1 -1
- package/dist/tools/generate-manifests.js +107 -33
- package/dist/tools/operate-analysis.d.ts +5 -1
- package/dist/tools/operate-analysis.d.ts.map +1 -1
- package/dist/tools/operate-analysis.js +37 -7
- package/dist/tools/operate-execution.d.ts +3 -1
- package/dist/tools/operate-execution.d.ts.map +1 -1
- package/dist/tools/operate-execution.js +6 -4
- package/dist/tools/operate.d.ts +7 -2
- package/dist/tools/operate.d.ts.map +1 -1
- package/dist/tools/operate.js +10 -6
- package/dist/tools/organizational-data.d.ts +3 -2
- package/dist/tools/organizational-data.d.ts.map +1 -1
- package/dist/tools/organizational-data.js +15 -13
- package/dist/tools/query.d.ts +5 -1
- package/dist/tools/query.d.ts.map +1 -1
- package/dist/tools/query.js +26 -18
- package/dist/tools/recommend.d.ts +3 -1
- package/dist/tools/recommend.d.ts.map +1 -1
- package/dist/tools/recommend.js +7 -7
- package/dist/tools/remediate.d.ts +5 -2
- package/dist/tools/remediate.d.ts.map +1 -1
- package/dist/tools/remediate.js +69 -20
- package/dist/tools/version.d.ts +20 -5
- package/dist/tools/version.d.ts.map +1 -1
- package/dist/tools/version.js +169 -161
- package/package.json +1 -1
- package/prompts/helm-generation.md +9 -0
- package/dist/core/cluster-utils.d.ts +0 -12
- package/dist/core/cluster-utils.d.ts.map +0 -1
- package/dist/core/cluster-utils.js +0 -27
- package/dist/core/helm-utils.d.ts +0 -66
- package/dist/core/helm-utils.d.ts.map +0 -1
- package/dist/core/helm-utils.js +0 -196
- package/dist/core/kubectl-tools.d.ts +0 -71
- package/dist/core/kubectl-tools.d.ts.map +0 -1
- package/dist/core/kubectl-tools.js +0 -546
- package/dist/core/kubernetes-utils.d.ts +0 -38
- package/dist/core/kubernetes-utils.d.ts.map +0 -1
- package/dist/core/kubernetes-utils.js +0 -288
- package/dist/core/tracing/k8s-tracing.d.ts +0 -57
- package/dist/core/tracing/k8s-tracing.d.ts.map +0 -1
- package/dist/core/tracing/k8s-tracing.js +0 -155
- package/scripts/toolhive.nu +0 -21
|
@@ -41,6 +41,12 @@ Generate a values.yaml file for Helm chart installation based on the user's conf
|
|
|
41
41
|
- Strings: use quotes only when necessary (values with special chars)
|
|
42
42
|
- Arrays/Lists: proper YAML list format
|
|
43
43
|
- Nested objects: proper YAML indentation
|
|
44
|
+
- **Enum/constrained values**: Many charts define fields with limited valid values
|
|
45
|
+
* Look for comments like "# Valid values: 'soft', 'hard', ''" or "# Options: ClusterIP, NodePort, LoadBalancer"
|
|
46
|
+
* Look for fields with empty string defaults like `podAntiAffinity: ""` - these often have schema constraints
|
|
47
|
+
* Common constrained fields: `podAntiAffinity` (soft/hard/""), `service.type`, `pullPolicy`, `strategy.type`
|
|
48
|
+
* ONLY use values explicitly listed as valid in the chart's values.yaml or comments
|
|
49
|
+
* When in doubt, use the default value from the chart rather than inventing a value
|
|
44
50
|
|
|
45
51
|
4. **Include Only Values That Differ From Defaults**:
|
|
46
52
|
- Compare each user answer to the chart's default values above
|
|
@@ -62,6 +68,9 @@ If this is a retry (previous attempt and error details provided above):
|
|
|
62
68
|
* Non-existent value path in the chart
|
|
63
69
|
* Invalid YAML syntax
|
|
64
70
|
* Template rendering errors from invalid combinations
|
|
71
|
+
* **Schema validation errors** - "value must be one of X, Y, Z" means you used an invalid enum value
|
|
72
|
+
- For schema errors, check the chart's values.yaml comments for valid options
|
|
73
|
+
- Use the exact valid value from the error message (e.g., if error says "must be one of '', 'soft', 'hard'", use one of those exact values)
|
|
65
74
|
- Make targeted corrections to fix the identified issues
|
|
66
75
|
|
|
67
76
|
### Response Requirements:
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cluster Connection Utilities
|
|
3
|
-
*
|
|
4
|
-
* Provides reusable functions for lazy cluster connectivity checking
|
|
5
|
-
*/
|
|
6
|
-
import { Logger } from './error-handling';
|
|
7
|
-
import { DotAI } from './index';
|
|
8
|
-
/**
|
|
9
|
-
* Ensures cluster connectivity and throws proper MCP-compatible errors
|
|
10
|
-
*/
|
|
11
|
-
export declare function ensureClusterConnection(dotAI: DotAI, logger: Logger, requestId: string, component: string): Promise<void>;
|
|
12
|
-
//# sourceMappingURL=cluster-utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cluster-utils.d.ts","sourceRoot":"","sources":["../../src/core/cluster-utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAA8C,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACtF,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC;;GAEG;AACH,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC,CAqBf"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Cluster Connection Utilities
|
|
4
|
-
*
|
|
5
|
-
* Provides reusable functions for lazy cluster connectivity checking
|
|
6
|
-
*/
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.ensureClusterConnection = ensureClusterConnection;
|
|
9
|
-
const error_handling_1 = require("./error-handling");
|
|
10
|
-
/**
|
|
11
|
-
* Ensures cluster connectivity and throws proper MCP-compatible errors
|
|
12
|
-
*/
|
|
13
|
-
async function ensureClusterConnection(dotAI, logger, requestId, component) {
|
|
14
|
-
logger.debug('Checking cluster connectivity', { requestId, component });
|
|
15
|
-
try {
|
|
16
|
-
await dotAI.discovery.connect();
|
|
17
|
-
logger.debug('Cluster connectivity verified', { requestId, component });
|
|
18
|
-
}
|
|
19
|
-
catch (clusterError) {
|
|
20
|
-
const errorMessage = clusterError instanceof Error ? clusterError.message : String(clusterError);
|
|
21
|
-
throw error_handling_1.ErrorHandler.createError(error_handling_1.ErrorCategory.KUBERNETES, error_handling_1.ErrorSeverity.HIGH, `Cluster connection failed: ${errorMessage}\n\nTroubleshooting:\n- Check KUBECONFIG environment variable\n- Verify cluster is running: kubectl cluster-info\n- Test kubectl connectivity: kubectl get nodes\n- Ensure cluster is accessible from this environment`, {
|
|
22
|
-
operation: 'cluster_connectivity_check',
|
|
23
|
-
component,
|
|
24
|
-
requestId
|
|
25
|
-
}, clusterError instanceof Error ? clusterError : new Error(String(clusterError)));
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Helm Utilities - Shared functions for Helm chart operations
|
|
3
|
-
*/
|
|
4
|
-
import { HelmChartInfo } from './helm-types';
|
|
5
|
-
/**
|
|
6
|
-
* Sanitize input for safe shell command usage.
|
|
7
|
-
* Validates that input contains only safe characters to prevent command injection.
|
|
8
|
-
* @throws Error if input contains potentially dangerous characters
|
|
9
|
-
*/
|
|
10
|
-
export declare function sanitizeShellArg(arg: string, fieldName?: string): string;
|
|
11
|
-
/**
|
|
12
|
-
* Validate and sanitize HelmChartInfo for safe shell command usage
|
|
13
|
-
*/
|
|
14
|
-
export declare function sanitizeChartInfo(chart: HelmChartInfo): {
|
|
15
|
-
repositoryName: string;
|
|
16
|
-
repository: string;
|
|
17
|
-
chartName: string;
|
|
18
|
-
version?: string;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Build the Helm command from chart info and deployment options
|
|
22
|
-
*/
|
|
23
|
-
export declare function buildHelmCommand(chart: HelmChartInfo, releaseName: string, namespace: string, valuesPath?: string): string;
|
|
24
|
-
/**
|
|
25
|
-
* Ensure Helm repository is added and updated
|
|
26
|
-
*/
|
|
27
|
-
export declare function ensureHelmRepo(chart: HelmChartInfo): Promise<void>;
|
|
28
|
-
/**
|
|
29
|
-
* Execute a Helm command with proper error handling
|
|
30
|
-
*/
|
|
31
|
-
export declare function executeHelmCommand(command: string, options?: {
|
|
32
|
-
timeout?: number;
|
|
33
|
-
maxBuffer?: number;
|
|
34
|
-
}): Promise<{
|
|
35
|
-
stdout: string;
|
|
36
|
-
stderr: string;
|
|
37
|
-
}>;
|
|
38
|
-
/**
|
|
39
|
-
* Get the path for Helm values file
|
|
40
|
-
*/
|
|
41
|
-
export declare function getHelmValuesPath(solutionId: string): string;
|
|
42
|
-
/**
|
|
43
|
-
* Check if Helm values file exists for a solution
|
|
44
|
-
*/
|
|
45
|
-
export declare function helmValuesExist(solutionId: string): boolean;
|
|
46
|
-
/**
|
|
47
|
-
* Ensure tmp directory exists
|
|
48
|
-
*/
|
|
49
|
-
export declare function ensureTmpDir(): string;
|
|
50
|
-
/**
|
|
51
|
-
* Result of Helm command execution
|
|
52
|
-
*/
|
|
53
|
-
export interface HelmExecutionResult {
|
|
54
|
-
success: boolean;
|
|
55
|
-
output: string;
|
|
56
|
-
error?: string;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Run Helm dry-run validation
|
|
60
|
-
*/
|
|
61
|
-
export declare function validateHelmDryRun(chart: HelmChartInfo, releaseName: string, namespace: string, valuesPath: string): Promise<HelmExecutionResult>;
|
|
62
|
-
/**
|
|
63
|
-
* Deploy a Helm chart
|
|
64
|
-
*/
|
|
65
|
-
export declare function deployHelmRelease(chart: HelmChartInfo, releaseName: string, namespace: string, valuesPath: string | undefined, timeout: number): Promise<HelmExecutionResult>;
|
|
66
|
-
//# sourceMappingURL=helm-utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helm-utils.d.ts","sourceRoot":"","sources":["../../src/core/helm-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,GAAE,MAAmB,GAAG,MAAM,CAOpF;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,aAAa,GAAG;IACvD,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAOA;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,aAAa,EACpB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,UAAU,CAAC,EAAE,MAAM,GAClB,MAAM,CAwBR;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAKxE;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;IACR,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GACA,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAO7C;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAG5D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAE3D;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAMrC;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,aAAa,EACpB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,mBAAmB,CAAC,CAyB9B;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,aAAa,EACpB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,mBAAmB,CAAC,CA6B9B"}
|
package/dist/core/helm-utils.js
DELETED
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Helm Utilities - Shared functions for Helm chart operations
|
|
4
|
-
*/
|
|
5
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
-
}
|
|
11
|
-
Object.defineProperty(o, k2, desc);
|
|
12
|
-
}) : (function(o, m, k, k2) {
|
|
13
|
-
if (k2 === undefined) k2 = k;
|
|
14
|
-
o[k2] = m[k];
|
|
15
|
-
}));
|
|
16
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
-
}) : function(o, v) {
|
|
19
|
-
o["default"] = v;
|
|
20
|
-
});
|
|
21
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
-
var ownKeys = function(o) {
|
|
23
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
-
var ar = [];
|
|
25
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
-
return ar;
|
|
27
|
-
};
|
|
28
|
-
return ownKeys(o);
|
|
29
|
-
};
|
|
30
|
-
return function (mod) {
|
|
31
|
-
if (mod && mod.__esModule) return mod;
|
|
32
|
-
var result = {};
|
|
33
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
-
__setModuleDefault(result, mod);
|
|
35
|
-
return result;
|
|
36
|
-
};
|
|
37
|
-
})();
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.sanitizeShellArg = sanitizeShellArg;
|
|
40
|
-
exports.sanitizeChartInfo = sanitizeChartInfo;
|
|
41
|
-
exports.buildHelmCommand = buildHelmCommand;
|
|
42
|
-
exports.ensureHelmRepo = ensureHelmRepo;
|
|
43
|
-
exports.executeHelmCommand = executeHelmCommand;
|
|
44
|
-
exports.getHelmValuesPath = getHelmValuesPath;
|
|
45
|
-
exports.helmValuesExist = helmValuesExist;
|
|
46
|
-
exports.ensureTmpDir = ensureTmpDir;
|
|
47
|
-
exports.validateHelmDryRun = validateHelmDryRun;
|
|
48
|
-
exports.deployHelmRelease = deployHelmRelease;
|
|
49
|
-
const path = __importStar(require("path"));
|
|
50
|
-
const fs = __importStar(require("fs"));
|
|
51
|
-
const platform_utils_1 = require("./platform-utils");
|
|
52
|
-
/**
|
|
53
|
-
* Sanitize input for safe shell command usage.
|
|
54
|
-
* Validates that input contains only safe characters to prevent command injection.
|
|
55
|
-
* @throws Error if input contains potentially dangerous characters
|
|
56
|
-
*/
|
|
57
|
-
function sanitizeShellArg(arg, fieldName = 'argument') {
|
|
58
|
-
// Allow alphanumeric, dash, underscore, dot, forward slash, colon (for URLs), and @ (for versions)
|
|
59
|
-
// This covers valid Helm chart names, repo names, URLs, and version strings
|
|
60
|
-
if (!/^[a-zA-Z0-9\-_./:\\@]+$/.test(arg)) {
|
|
61
|
-
throw new Error(`Invalid characters in ${fieldName}: "${arg}". Only alphanumeric characters, dashes, underscores, dots, forward slashes, colons, and @ are allowed.`);
|
|
62
|
-
}
|
|
63
|
-
return arg;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Validate and sanitize HelmChartInfo for safe shell command usage
|
|
67
|
-
*/
|
|
68
|
-
function sanitizeChartInfo(chart) {
|
|
69
|
-
return {
|
|
70
|
-
repositoryName: sanitizeShellArg(chart.repositoryName, 'repository name'),
|
|
71
|
-
repository: sanitizeShellArg(chart.repository, 'repository URL'),
|
|
72
|
-
chartName: sanitizeShellArg(chart.chartName, 'chart name'),
|
|
73
|
-
version: chart.version ? sanitizeShellArg(chart.version, 'version') : undefined
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Build the Helm command from chart info and deployment options
|
|
78
|
-
*/
|
|
79
|
-
function buildHelmCommand(chart, releaseName, namespace, valuesPath) {
|
|
80
|
-
// Sanitize all inputs to prevent command injection
|
|
81
|
-
const safeChart = sanitizeChartInfo(chart);
|
|
82
|
-
const safeReleaseName = sanitizeShellArg(releaseName, 'release name');
|
|
83
|
-
const safeNamespace = sanitizeShellArg(namespace, 'namespace');
|
|
84
|
-
const parts = [
|
|
85
|
-
'helm upgrade --install',
|
|
86
|
-
safeReleaseName,
|
|
87
|
-
`${safeChart.repositoryName}/${safeChart.chartName}`,
|
|
88
|
-
`--namespace ${safeNamespace}`,
|
|
89
|
-
'--create-namespace'
|
|
90
|
-
];
|
|
91
|
-
if (safeChart.version) {
|
|
92
|
-
parts.push(`--version ${safeChart.version}`);
|
|
93
|
-
}
|
|
94
|
-
if (valuesPath) {
|
|
95
|
-
// Values path is internally generated, but sanitize anyway
|
|
96
|
-
parts.push(`-f ${sanitizeShellArg(valuesPath, 'values path')}`);
|
|
97
|
-
}
|
|
98
|
-
return parts.join(' ');
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Ensure Helm repository is added and updated
|
|
102
|
-
*/
|
|
103
|
-
async function ensureHelmRepo(chart) {
|
|
104
|
-
// Sanitize chart info to prevent command injection
|
|
105
|
-
const safeChart = sanitizeChartInfo(chart);
|
|
106
|
-
await (0, platform_utils_1.execAsync)(`helm repo add ${safeChart.repositoryName} ${safeChart.repository} 2>/dev/null || true`);
|
|
107
|
-
await (0, platform_utils_1.execAsync)('helm repo update 2>/dev/null || true');
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Execute a Helm command with proper error handling
|
|
111
|
-
*/
|
|
112
|
-
async function executeHelmCommand(command, options) {
|
|
113
|
-
const execOptions = {
|
|
114
|
-
maxBuffer: options?.maxBuffer || 10 * 1024 * 1024,
|
|
115
|
-
timeout: options?.timeout
|
|
116
|
-
};
|
|
117
|
-
return await (0, platform_utils_1.execAsync)(command, execOptions);
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Get the path for Helm values file
|
|
121
|
-
*/
|
|
122
|
-
function getHelmValuesPath(solutionId) {
|
|
123
|
-
const tmpDir = path.join(process.cwd(), 'tmp');
|
|
124
|
-
return path.join(tmpDir, `${solutionId}-values.yaml`);
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Check if Helm values file exists for a solution
|
|
128
|
-
*/
|
|
129
|
-
function helmValuesExist(solutionId) {
|
|
130
|
-
return fs.existsSync(getHelmValuesPath(solutionId));
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Ensure tmp directory exists
|
|
134
|
-
*/
|
|
135
|
-
function ensureTmpDir() {
|
|
136
|
-
const tmpDir = path.join(process.cwd(), 'tmp');
|
|
137
|
-
if (!fs.existsSync(tmpDir)) {
|
|
138
|
-
fs.mkdirSync(tmpDir, { recursive: true });
|
|
139
|
-
}
|
|
140
|
-
return tmpDir;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Run Helm dry-run validation
|
|
144
|
-
*/
|
|
145
|
-
async function validateHelmDryRun(chart, releaseName, namespace, valuesPath) {
|
|
146
|
-
try {
|
|
147
|
-
await ensureHelmRepo(chart);
|
|
148
|
-
const dryRunCommand = buildHelmCommand(chart, releaseName, namespace, valuesPath) + ' --dry-run';
|
|
149
|
-
const { stdout, stderr } = await executeHelmCommand(dryRunCommand);
|
|
150
|
-
return {
|
|
151
|
-
success: true,
|
|
152
|
-
output: stdout + (stderr ? `\n${stderr}` : '')
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
catch (error) {
|
|
156
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
157
|
-
let cleanError = errorMessage;
|
|
158
|
-
if (error instanceof Error && 'stderr' in error) {
|
|
159
|
-
cleanError = error.stderr || errorMessage;
|
|
160
|
-
}
|
|
161
|
-
return {
|
|
162
|
-
success: false,
|
|
163
|
-
output: '',
|
|
164
|
-
error: cleanError
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Deploy a Helm chart
|
|
170
|
-
*/
|
|
171
|
-
async function deployHelmRelease(chart, releaseName, namespace, valuesPath, timeout) {
|
|
172
|
-
try {
|
|
173
|
-
await ensureHelmRepo(chart);
|
|
174
|
-
const helmCommand = buildHelmCommand(chart, releaseName, namespace, valuesPath) +
|
|
175
|
-
` --timeout ${timeout}s --wait`;
|
|
176
|
-
const { stdout, stderr } = await executeHelmCommand(helmCommand, {
|
|
177
|
-
timeout: (timeout + 30) * 1000 // Add buffer for command overhead
|
|
178
|
-
});
|
|
179
|
-
return {
|
|
180
|
-
success: true,
|
|
181
|
-
output: stdout + (stderr ? `\n\nStderr:\n${stderr}` : '')
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
catch (error) {
|
|
185
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
186
|
-
let cleanError = errorMessage;
|
|
187
|
-
if (error instanceof Error && 'stderr' in error) {
|
|
188
|
-
cleanError = error.stderr || errorMessage;
|
|
189
|
-
}
|
|
190
|
-
return {
|
|
191
|
-
success: false,
|
|
192
|
-
output: '',
|
|
193
|
-
error: cleanError
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Kubectl Tools for AI-Powered Investigation
|
|
3
|
-
*
|
|
4
|
-
* Shared tool definitions and executor for kubectl operations.
|
|
5
|
-
* Used by remediation, diagnostics, and other investigation workflows.
|
|
6
|
-
*
|
|
7
|
-
* PRD #143: Tool-Based Remediation with Observability Data Sources
|
|
8
|
-
*/
|
|
9
|
-
import { AITool } from './ai-provider.interface';
|
|
10
|
-
/**
|
|
11
|
-
* Tool: kubectl_api_resources
|
|
12
|
-
* Get list of all available Kubernetes API resources in the cluster
|
|
13
|
-
*/
|
|
14
|
-
export declare const KUBECTL_API_RESOURCES_TOOL: AITool;
|
|
15
|
-
/**
|
|
16
|
-
* Tool: kubectl_get
|
|
17
|
-
* Get Kubernetes resources with their current state
|
|
18
|
-
*/
|
|
19
|
-
export declare const KUBECTL_GET_TOOL: AITool;
|
|
20
|
-
/**
|
|
21
|
-
* Tool: kubectl_describe
|
|
22
|
-
* Get detailed information about Kubernetes resources
|
|
23
|
-
*/
|
|
24
|
-
export declare const KUBECTL_DESCRIBE_TOOL: AITool;
|
|
25
|
-
/**
|
|
26
|
-
* Tool: kubectl_logs
|
|
27
|
-
* Get container logs from pods
|
|
28
|
-
*/
|
|
29
|
-
export declare const KUBECTL_LOGS_TOOL: AITool;
|
|
30
|
-
/**
|
|
31
|
-
* Tool: kubectl_events
|
|
32
|
-
* Get Kubernetes events for troubleshooting
|
|
33
|
-
*/
|
|
34
|
-
export declare const KUBECTL_EVENTS_TOOL: AITool;
|
|
35
|
-
/**
|
|
36
|
-
* Tool: kubectl_patch_dryrun
|
|
37
|
-
* Validate patch commands with dry-run before execution
|
|
38
|
-
*/
|
|
39
|
-
export declare const KUBECTL_PATCH_DRYRUN_TOOL: AITool;
|
|
40
|
-
/**
|
|
41
|
-
* Tool: kubectl_apply_dryrun
|
|
42
|
-
* Validate apply commands with dry-run before execution
|
|
43
|
-
*/
|
|
44
|
-
export declare const KUBECTL_APPLY_DRYRUN_TOOL: AITool;
|
|
45
|
-
/**
|
|
46
|
-
* Tool: kubectl_delete_dryrun
|
|
47
|
-
* Validate delete commands with dry-run before execution
|
|
48
|
-
*/
|
|
49
|
-
export declare const KUBECTL_DELETE_DRYRUN_TOOL: AITool;
|
|
50
|
-
/**
|
|
51
|
-
* Tool: kubectl_get_crd_schema
|
|
52
|
-
* Get the OpenAPI v3 schema for a Custom Resource Definition
|
|
53
|
-
*/
|
|
54
|
-
export declare const KUBECTL_GET_CRD_SCHEMA_TOOL: AITool;
|
|
55
|
-
/**
|
|
56
|
-
* Tool: kubectl_get_resource_json
|
|
57
|
-
* Get a single Kubernetes resource as structured JSON
|
|
58
|
-
*/
|
|
59
|
-
export declare const KUBECTL_GET_RESOURCE_JSON_TOOL: AITool;
|
|
60
|
-
/**
|
|
61
|
-
* Tool executor for kubectl-based tools
|
|
62
|
-
* Handles execution and error handling for all kubectl tool calls
|
|
63
|
-
*/
|
|
64
|
-
export declare function executeKubectlTools(toolName: string, input: any): Promise<any>;
|
|
65
|
-
/**
|
|
66
|
-
* All kubectl investigation tools (read-only operations + dry-run validation)
|
|
67
|
-
* Used during investigation phase for gathering cluster state information and validating solutions
|
|
68
|
-
* Convenient array for passing to toolLoop()
|
|
69
|
-
*/
|
|
70
|
-
export declare const KUBECTL_INVESTIGATION_TOOLS: AITool[];
|
|
71
|
-
//# sourceMappingURL=kubectl-tools.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"kubectl-tools.d.ts","sourceRoot":"","sources":["../../src/core/kubectl-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAIjD;;;GAGG;AACH,eAAO,MAAM,0BAA0B,EAAE,MAQxC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAsB9B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,MAiBnC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAsB/B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAkBjC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,yBAAyB,EAAE,MAyBvC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,yBAAyB,EAAE,MAiBvC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,0BAA0B,EAAE,MAiBxC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,2BAA2B,EAAE,MAazC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,8BAA8B,EAAE,MAqB5C,CAAC;AAEF;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CA0UpF;AAED;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,EAAE,MAAM,EAW/C,CAAC"}
|