@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.
Files changed (114) hide show
  1. package/README.md +2 -7
  2. package/dist/core/capability-scan-workflow.d.ts +4 -3
  3. package/dist/core/capability-scan-workflow.d.ts.map +1 -1
  4. package/dist/core/capability-scan-workflow.js +34 -39
  5. package/dist/core/circuit-breaker.d.ts +1 -0
  6. package/dist/core/circuit-breaker.d.ts.map +1 -1
  7. package/dist/core/circuit-breaker.js +11 -3
  8. package/dist/core/command-executor.d.ts +10 -1
  9. package/dist/core/command-executor.d.ts.map +1 -1
  10. package/dist/core/command-executor.js +63 -48
  11. package/dist/core/crd-availability.d.ts +6 -1
  12. package/dist/core/crd-availability.d.ts.map +1 -1
  13. package/dist/core/crd-availability.js +59 -49
  14. package/dist/core/deploy-operation.d.ts +17 -3
  15. package/dist/core/deploy-operation.d.ts.map +1 -1
  16. package/dist/core/deploy-operation.js +72 -21
  17. package/dist/core/discovery.d.ts +16 -43
  18. package/dist/core/discovery.d.ts.map +1 -1
  19. package/dist/core/discovery.js +128 -277
  20. package/dist/core/index.d.ts +10 -2
  21. package/dist/core/index.d.ts.map +1 -1
  22. package/dist/core/index.js +20 -9
  23. package/dist/core/pattern-operations.d.ts +3 -1
  24. package/dist/core/pattern-operations.d.ts.map +1 -1
  25. package/dist/core/pattern-operations.js +3 -2
  26. package/dist/core/plugin-client.d.ts +53 -0
  27. package/dist/core/plugin-client.d.ts.map +1 -0
  28. package/dist/core/plugin-client.js +148 -0
  29. package/dist/core/plugin-manager.d.ts +119 -0
  30. package/dist/core/plugin-manager.d.ts.map +1 -0
  31. package/dist/core/plugin-manager.js +366 -0
  32. package/dist/core/plugin-types.d.ts +100 -0
  33. package/dist/core/plugin-types.d.ts.map +1 -0
  34. package/dist/core/plugin-types.js +10 -0
  35. package/dist/core/policy-operations.d.ts +15 -7
  36. package/dist/core/policy-operations.d.ts.map +1 -1
  37. package/dist/core/policy-operations.js +59 -31
  38. package/dist/core/resource-tools.d.ts +2 -90
  39. package/dist/core/resource-tools.d.ts.map +1 -1
  40. package/dist/core/resource-tools.js +4 -178
  41. package/dist/core/schema.d.ts +18 -2
  42. package/dist/core/schema.d.ts.map +1 -1
  43. package/dist/core/schema.js +118 -16
  44. package/dist/core/telemetry/client.d.ts +7 -0
  45. package/dist/core/telemetry/client.d.ts.map +1 -1
  46. package/dist/core/telemetry/client.js +51 -51
  47. package/dist/core/telemetry/index.d.ts +1 -1
  48. package/dist/core/telemetry/index.d.ts.map +1 -1
  49. package/dist/core/telemetry/index.js +2 -1
  50. package/dist/core/telemetry/types.d.ts +1 -3
  51. package/dist/core/telemetry/types.d.ts.map +1 -1
  52. package/dist/core/tracing/index.d.ts +0 -1
  53. package/dist/core/tracing/index.d.ts.map +1 -1
  54. package/dist/core/tracing/index.js +1 -4
  55. package/dist/core/unified-creation-session.d.ts +6 -1
  56. package/dist/core/unified-creation-session.d.ts.map +1 -1
  57. package/dist/core/unified-creation-session.js +19 -11
  58. package/dist/interfaces/mcp.d.ts +8 -2
  59. package/dist/interfaces/mcp.d.ts.map +1 -1
  60. package/dist/interfaces/mcp.js +85 -34
  61. package/dist/interfaces/resource-sync-handler.d.ts.map +1 -1
  62. package/dist/interfaces/resource-sync-handler.js +37 -17
  63. package/dist/interfaces/rest-api.d.ts +4 -1
  64. package/dist/interfaces/rest-api.d.ts.map +1 -1
  65. package/dist/interfaces/rest-api.js +172 -49
  66. package/dist/mcp/server.js +39 -54
  67. package/dist/tools/deploy-manifests.d.ts +3 -1
  68. package/dist/tools/deploy-manifests.d.ts.map +1 -1
  69. package/dist/tools/deploy-manifests.js +112 -13
  70. package/dist/tools/generate-manifests.d.ts +3 -1
  71. package/dist/tools/generate-manifests.d.ts.map +1 -1
  72. package/dist/tools/generate-manifests.js +107 -33
  73. package/dist/tools/operate-analysis.d.ts +5 -1
  74. package/dist/tools/operate-analysis.d.ts.map +1 -1
  75. package/dist/tools/operate-analysis.js +37 -7
  76. package/dist/tools/operate-execution.d.ts +3 -1
  77. package/dist/tools/operate-execution.d.ts.map +1 -1
  78. package/dist/tools/operate-execution.js +6 -4
  79. package/dist/tools/operate.d.ts +7 -2
  80. package/dist/tools/operate.d.ts.map +1 -1
  81. package/dist/tools/operate.js +10 -6
  82. package/dist/tools/organizational-data.d.ts +3 -2
  83. package/dist/tools/organizational-data.d.ts.map +1 -1
  84. package/dist/tools/organizational-data.js +15 -13
  85. package/dist/tools/query.d.ts +5 -1
  86. package/dist/tools/query.d.ts.map +1 -1
  87. package/dist/tools/query.js +26 -18
  88. package/dist/tools/recommend.d.ts +3 -1
  89. package/dist/tools/recommend.d.ts.map +1 -1
  90. package/dist/tools/recommend.js +7 -7
  91. package/dist/tools/remediate.d.ts +5 -2
  92. package/dist/tools/remediate.d.ts.map +1 -1
  93. package/dist/tools/remediate.js +69 -20
  94. package/dist/tools/version.d.ts +20 -5
  95. package/dist/tools/version.d.ts.map +1 -1
  96. package/dist/tools/version.js +169 -161
  97. package/package.json +1 -1
  98. package/prompts/helm-generation.md +9 -0
  99. package/dist/core/cluster-utils.d.ts +0 -12
  100. package/dist/core/cluster-utils.d.ts.map +0 -1
  101. package/dist/core/cluster-utils.js +0 -27
  102. package/dist/core/helm-utils.d.ts +0 -66
  103. package/dist/core/helm-utils.d.ts.map +0 -1
  104. package/dist/core/helm-utils.js +0 -196
  105. package/dist/core/kubectl-tools.d.ts +0 -71
  106. package/dist/core/kubectl-tools.d.ts.map +0 -1
  107. package/dist/core/kubectl-tools.js +0 -546
  108. package/dist/core/kubernetes-utils.d.ts +0 -38
  109. package/dist/core/kubernetes-utils.d.ts.map +0 -1
  110. package/dist/core/kubernetes-utils.js +0 -288
  111. package/dist/core/tracing/k8s-tracing.d.ts +0 -57
  112. package/dist/core/tracing/k8s-tracing.d.ts.map +0 -1
  113. package/dist/core/tracing/k8s-tracing.js +0 -155
  114. package/scripts/toolhive.nu +0 -21
@@ -1,546 +0,0 @@
1
- "use strict";
2
- /**
3
- * Kubectl Tools for AI-Powered Investigation
4
- *
5
- * Shared tool definitions and executor for kubectl operations.
6
- * Used by remediation, diagnostics, and other investigation workflows.
7
- *
8
- * PRD #143: Tool-Based Remediation with Observability Data Sources
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.KUBECTL_INVESTIGATION_TOOLS = exports.KUBECTL_GET_RESOURCE_JSON_TOOL = exports.KUBECTL_GET_CRD_SCHEMA_TOOL = exports.KUBECTL_DELETE_DRYRUN_TOOL = exports.KUBECTL_APPLY_DRYRUN_TOOL = exports.KUBECTL_PATCH_DRYRUN_TOOL = exports.KUBECTL_EVENTS_TOOL = exports.KUBECTL_LOGS_TOOL = exports.KUBECTL_DESCRIBE_TOOL = exports.KUBECTL_GET_TOOL = exports.KUBECTL_API_RESOURCES_TOOL = void 0;
12
- exports.executeKubectlTools = executeKubectlTools;
13
- const kubernetes_utils_1 = require("./kubernetes-utils");
14
- const validation_1 = require("./constants/validation");
15
- /**
16
- * Tool: kubectl_api_resources
17
- * Get list of all available Kubernetes API resources in the cluster
18
- */
19
- exports.KUBECTL_API_RESOURCES_TOOL = {
20
- name: 'kubectl_api_resources',
21
- description: 'Get list of all available Kubernetes API resources in the cluster (resource types, API groups, namespaced vs cluster-scoped). Use this to discover what resources are available before querying specific resources. Essential for understanding what can be investigated in this cluster.',
22
- inputSchema: {
23
- type: 'object',
24
- properties: {},
25
- required: []
26
- }
27
- };
28
- /**
29
- * Tool: kubectl_get
30
- * Get Kubernetes resources with their current state
31
- */
32
- exports.KUBECTL_GET_TOOL = {
33
- name: 'kubectl_get',
34
- description: 'Get Kubernetes resources and their current state in TABLE FORMAT (most efficient). Returns compact table with NAME, STATUS, READY, AGE columns. Use this to list resources and check basic status. For detailed information, use kubectl_describe instead. IMPORTANT: Always returns table format - output format flags like -o=yaml or -o=json are automatically stripped.',
35
- inputSchema: {
36
- type: 'object',
37
- properties: {
38
- resource: {
39
- type: 'string',
40
- description: 'Resource type to get (e.g., "pods", "deployments", "services", "pod/my-pod", "clusters.postgresql.cnpg.io"). Can be plural (pods) or singular with name (pod/name). Can include API group for custom resources.'
41
- },
42
- namespace: {
43
- type: 'string',
44
- description: 'Kubernetes namespace to query. Omit for cluster-scoped resources or to query all namespaces.'
45
- },
46
- args: {
47
- type: 'array',
48
- items: { type: 'string' },
49
- description: 'Filtering arguments only (e.g., ["--selector=app=myapp"], ["--field-selector=status.phase=Running"], ["--all-namespaces"], ["--show-labels"]). Output format flags (-o=yaml, -o=json, etc.) are NOT allowed and will be automatically stripped.'
50
- }
51
- },
52
- required: ['resource']
53
- }
54
- };
55
- /**
56
- * Tool: kubectl_describe
57
- * Get detailed information about Kubernetes resources
58
- */
59
- exports.KUBECTL_DESCRIBE_TOOL = {
60
- name: 'kubectl_describe',
61
- description: 'Get detailed information about specific Kubernetes resources including configuration, status, events, and relationships. Use this when you need comprehensive details about a specific resource, especially to understand configuration issues or see recent events related to that resource.',
62
- inputSchema: {
63
- type: 'object',
64
- properties: {
65
- resource: {
66
- type: 'string',
67
- description: 'Resource to describe (e.g., "pod/my-pod", "deployment/my-app", "cluster/postgres-db"). Should include the resource name.'
68
- },
69
- namespace: {
70
- type: 'string',
71
- description: 'Kubernetes namespace. Required for namespaced resources.'
72
- }
73
- },
74
- required: ['resource']
75
- }
76
- };
77
- /**
78
- * Tool: kubectl_logs
79
- * Get container logs from pods
80
- */
81
- exports.KUBECTL_LOGS_TOOL = {
82
- name: 'kubectl_logs',
83
- description: 'Get container logs from pods. Essential for debugging application crashes, errors, and understanding runtime behavior. Use --previous flag to get logs from crashed/restarted containers.',
84
- inputSchema: {
85
- type: 'object',
86
- properties: {
87
- resource: {
88
- type: 'string',
89
- description: 'Pod name to get logs from (e.g., "my-pod" or "pod/my-pod").'
90
- },
91
- namespace: {
92
- type: 'string',
93
- description: 'Kubernetes namespace where the pod is running.'
94
- },
95
- args: {
96
- type: 'array',
97
- items: { type: 'string' },
98
- description: 'Additional log arguments (e.g., ["--previous"] for crashed container logs, ["--tail=50"] to limit output, ["--since=5m"] for recent logs, ["-c", "container-name"] for specific container).'
99
- }
100
- },
101
- required: ['resource', 'namespace']
102
- }
103
- };
104
- /**
105
- * Tool: kubectl_events
106
- * Get Kubernetes events for troubleshooting
107
- */
108
- exports.KUBECTL_EVENTS_TOOL = {
109
- name: 'kubectl_events',
110
- description: 'Get Kubernetes events which record important state changes, errors, warnings, and informational messages from the cluster. Essential for understanding scheduling issues, resource problems, configuration errors, and system-level events affecting resources.',
111
- inputSchema: {
112
- type: 'object',
113
- properties: {
114
- namespace: {
115
- type: 'string',
116
- description: 'Kubernetes namespace to get events from. Omit for cluster-wide events.'
117
- },
118
- args: {
119
- type: 'array',
120
- items: { type: 'string' },
121
- description: 'Additional event arguments (e.g., ["--sort-by=.lastTimestamp"] to sort by time, ["--field-selector=involvedObject.name=my-pod"] to filter by resource, ["--since=10m"] for recent events).'
122
- }
123
- },
124
- required: []
125
- }
126
- };
127
- /**
128
- * Tool: kubectl_patch_dryrun
129
- * Validate patch commands with dry-run before execution
130
- */
131
- exports.KUBECTL_PATCH_DRYRUN_TOOL = {
132
- name: 'kubectl_patch_dryrun',
133
- description: 'Validate that a kubectl patch command will be accepted by the cluster without actually applying it. Use this to test your proposed remediation patches before completing investigation. Essential for confirming command syntax and cluster acceptance.',
134
- inputSchema: {
135
- type: 'object',
136
- properties: {
137
- resource: {
138
- type: 'string',
139
- description: 'Resource to patch (e.g., "deployment/my-app", "cluster/postgres-db"). Must include resource type and name.'
140
- },
141
- namespace: {
142
- type: 'string',
143
- description: 'Kubernetes namespace. Required for namespaced resources.'
144
- },
145
- patch: {
146
- type: 'string',
147
- description: 'The patch content in JSON format (e.g., \'{"spec":{"replicas":3}}\')'
148
- },
149
- patchType: {
150
- type: 'string',
151
- description: 'Type of patch: "strategic" (default), "merge", or "json". Use "json" for JSON Patch operations.'
152
- }
153
- },
154
- required: ['resource', 'patch']
155
- }
156
- };
157
- /**
158
- * Tool: kubectl_apply_dryrun
159
- * Validate apply commands with dry-run before execution
160
- */
161
- exports.KUBECTL_APPLY_DRYRUN_TOOL = {
162
- name: 'kubectl_apply_dryrun',
163
- description: 'Validate that a kubectl apply command will be accepted by the cluster without actually applying it. Use this to test applying YAML manifests or configuration changes before completing investigation.',
164
- inputSchema: {
165
- type: 'object',
166
- properties: {
167
- manifest: {
168
- type: 'string',
169
- description: 'The YAML manifest content to apply'
170
- },
171
- namespace: {
172
- type: 'string',
173
- description: 'Kubernetes namespace for the resource. Omit for cluster-scoped resources or if namespace is specified in manifest.'
174
- }
175
- },
176
- required: ['manifest']
177
- }
178
- };
179
- /**
180
- * Tool: kubectl_delete_dryrun
181
- * Validate delete commands with dry-run before execution
182
- */
183
- exports.KUBECTL_DELETE_DRYRUN_TOOL = {
184
- name: 'kubectl_delete_dryrun',
185
- description: 'Validate that a kubectl delete command will be accepted by the cluster without actually deleting resources. Use this to test resource deletion before completing investigation.',
186
- inputSchema: {
187
- type: 'object',
188
- properties: {
189
- resource: {
190
- type: 'string',
191
- description: 'Resource to delete (e.g., "pod/my-pod", "deployment/my-app", "configmap/my-config")'
192
- },
193
- namespace: {
194
- type: 'string',
195
- description: 'Kubernetes namespace. Required for namespaced resources.'
196
- }
197
- },
198
- required: ['resource']
199
- }
200
- };
201
- /**
202
- * Tool: kubectl_get_crd_schema
203
- * Get the OpenAPI v3 schema for a Custom Resource Definition
204
- */
205
- exports.KUBECTL_GET_CRD_SCHEMA_TOOL = {
206
- name: 'kubectl_get_crd_schema',
207
- description: 'Get the OpenAPI v3 schema for a Custom Resource Definition (CRD). Use this to understand the structure, required fields, validation rules, and available properties when crafting patches or configurations for custom resources like CNPG clusters, Crossplane resources, ArgoCD applications, etc.',
208
- inputSchema: {
209
- type: 'object',
210
- properties: {
211
- crdName: {
212
- type: 'string',
213
- description: 'Full CRD name including API group (e.g., "clusters.postgresql.cnpg.io", "compositions.apiextensions.crossplane.io", "applications.argoproj.io"). Use kubectl_api_resources to discover available CRDs.'
214
- }
215
- },
216
- required: ['crdName']
217
- }
218
- };
219
- /**
220
- * Tool: kubectl_get_resource_json
221
- * Get a single Kubernetes resource as structured JSON
222
- */
223
- exports.KUBECTL_GET_RESOURCE_JSON_TOOL = {
224
- name: 'kubectl_get_resource_json',
225
- description: 'Get a single Kubernetes resource as structured JSON with full metadata, spec, and status. Use this when you need programmatic access to resource configuration and state, such as analyzing ownerReferences, checking exact spec values, or examining detailed status conditions. Returns the complete resource object.',
226
- inputSchema: {
227
- type: 'object',
228
- properties: {
229
- resource: {
230
- type: 'string',
231
- description: 'Resource to get in kind/name format (e.g., "deployment/my-app", "pod/my-pod", "cluster.postgresql.cnpg.io/my-db"). Must include the resource name.'
232
- },
233
- namespace: {
234
- type: 'string',
235
- description: 'Kubernetes namespace. Required for namespaced resources, omit for cluster-scoped resources.'
236
- },
237
- field: {
238
- type: 'string',
239
- description: 'Optional: Return only a specific top-level field (e.g., "spec", "status", "metadata"). Omit to return the complete resource.'
240
- }
241
- },
242
- required: ['resource']
243
- }
244
- };
245
- /**
246
- * Tool executor for kubectl-based tools
247
- * Handles execution and error handling for all kubectl tool calls
248
- */
249
- async function executeKubectlTools(toolName, input) {
250
- try {
251
- switch (toolName) {
252
- case 'kubectl_api_resources': {
253
- const output = await (0, kubernetes_utils_1.executeKubectl)(['api-resources']);
254
- return {
255
- success: true,
256
- data: output,
257
- message: 'Successfully retrieved cluster API resources'
258
- };
259
- }
260
- case 'kubectl_get': {
261
- const { resource, namespace, args = [] } = input;
262
- if (!resource) {
263
- return {
264
- success: false,
265
- error: validation_1.VALIDATION_MESSAGES.MISSING_PARAMETER('resource'),
266
- message: 'kubectl_get requires a resource parameter'
267
- };
268
- }
269
- // Build kubectl command
270
- const cmdArgs = ['get', resource];
271
- // Add namespace if provided
272
- if (namespace) {
273
- cmdArgs.push('-n', namespace);
274
- }
275
- // Strip output format args - we always return table format for efficiency
276
- // Allow filtering args like --selector, --field-selector, --all-namespaces, --show-labels
277
- if (args && Array.isArray(args)) {
278
- const filteredArgs = args.filter(arg => {
279
- const argLower = arg.toLowerCase();
280
- // Block any output format flags
281
- return !argLower.startsWith('-o=') &&
282
- !argLower.startsWith('-o') &&
283
- !argLower.startsWith('--output') &&
284
- !argLower.includes('=json') &&
285
- !argLower.includes('=yaml');
286
- });
287
- cmdArgs.push(...filteredArgs);
288
- }
289
- const output = await (0, kubernetes_utils_1.executeKubectl)(cmdArgs);
290
- return {
291
- success: true,
292
- data: output,
293
- message: `Successfully retrieved ${resource}${namespace ? ` in namespace ${namespace}` : ''}`
294
- };
295
- }
296
- case 'kubectl_describe': {
297
- const { resource, namespace } = input;
298
- if (!resource) {
299
- return {
300
- success: false,
301
- error: validation_1.VALIDATION_MESSAGES.MISSING_PARAMETER('resource'),
302
- message: 'kubectl_describe requires a resource parameter'
303
- };
304
- }
305
- // Build kubectl command
306
- const cmdArgs = ['describe', resource];
307
- // Add namespace if provided
308
- if (namespace) {
309
- cmdArgs.push('-n', namespace);
310
- }
311
- const output = await (0, kubernetes_utils_1.executeKubectl)(cmdArgs);
312
- return {
313
- success: true,
314
- data: output,
315
- message: `Successfully described ${resource}${namespace ? ` in namespace ${namespace}` : ''}`
316
- };
317
- }
318
- case 'kubectl_logs': {
319
- const { resource, namespace, args = [] } = input;
320
- if (!resource) {
321
- return {
322
- success: false,
323
- error: validation_1.VALIDATION_MESSAGES.MISSING_PARAMETER('resource'),
324
- message: 'kubectl_logs requires a resource parameter'
325
- };
326
- }
327
- if (!namespace) {
328
- return {
329
- success: false,
330
- error: validation_1.VALIDATION_MESSAGES.MISSING_PARAMETER('namespace'),
331
- message: 'kubectl_logs requires a namespace parameter'
332
- };
333
- }
334
- // Build kubectl command
335
- const cmdArgs = ['logs', resource, '-n', namespace];
336
- // Add additional arguments
337
- if (args && Array.isArray(args)) {
338
- cmdArgs.push(...args);
339
- }
340
- const output = await (0, kubernetes_utils_1.executeKubectl)(cmdArgs);
341
- return {
342
- success: true,
343
- data: output,
344
- message: `Successfully retrieved logs for ${resource} in namespace ${namespace}`
345
- };
346
- }
347
- case 'kubectl_events': {
348
- const { namespace, args = [] } = input;
349
- // Build kubectl command
350
- const cmdArgs = ['get', 'events'];
351
- // Add namespace if provided
352
- if (namespace) {
353
- cmdArgs.push('-n', namespace);
354
- }
355
- // Add additional arguments
356
- if (args && Array.isArray(args)) {
357
- cmdArgs.push(...args);
358
- }
359
- const output = await (0, kubernetes_utils_1.executeKubectl)(cmdArgs);
360
- return {
361
- success: true,
362
- data: output,
363
- message: `Successfully retrieved events${namespace ? ` in namespace ${namespace}` : ' (cluster-wide)'}`
364
- };
365
- }
366
- case 'kubectl_patch_dryrun': {
367
- const { resource, namespace, patch, patchType = 'strategic' } = input;
368
- if (!resource) {
369
- return {
370
- success: false,
371
- error: validation_1.VALIDATION_MESSAGES.MISSING_PARAMETER('resource'),
372
- message: 'kubectl_patch_dryrun requires a resource parameter'
373
- };
374
- }
375
- if (!patch) {
376
- return {
377
- success: false,
378
- error: validation_1.VALIDATION_MESSAGES.MISSING_PARAMETER('patch'),
379
- message: 'kubectl_patch_dryrun requires a patch parameter'
380
- };
381
- }
382
- // Build kubectl command
383
- const cmdArgs = ['patch', resource, '--dry-run=server'];
384
- // Add namespace if provided
385
- if (namespace) {
386
- cmdArgs.push('-n', namespace);
387
- }
388
- // Add patch type
389
- if (patchType === 'json') {
390
- cmdArgs.push('--type=json');
391
- }
392
- else if (patchType === 'merge') {
393
- cmdArgs.push('--type=merge');
394
- }
395
- // strategic is default, no flag needed
396
- // Add patch content
397
- cmdArgs.push('-p', patch);
398
- const output = await (0, kubernetes_utils_1.executeKubectl)(cmdArgs);
399
- return {
400
- success: true,
401
- data: output,
402
- message: `Dry-run validation successful for patch on ${resource}${namespace ? ` in namespace ${namespace}` : ''}`
403
- };
404
- }
405
- case 'kubectl_apply_dryrun': {
406
- const { manifest, namespace } = input;
407
- if (!manifest) {
408
- return {
409
- success: false,
410
- error: validation_1.VALIDATION_MESSAGES.MISSING_PARAMETER('manifest'),
411
- message: 'kubectl_apply_dryrun requires a manifest parameter'
412
- };
413
- }
414
- // Build kubectl command
415
- const cmdArgs = ['apply', '--dry-run=server', '-f', '-'];
416
- // Add namespace if provided
417
- if (namespace) {
418
- cmdArgs.push('-n', namespace);
419
- }
420
- // Execute with manifest as stdin
421
- const output = await (0, kubernetes_utils_1.executeKubectl)(cmdArgs, { stdin: manifest });
422
- return {
423
- success: true,
424
- data: output,
425
- message: `Dry-run validation successful for apply${namespace ? ` in namespace ${namespace}` : ''}`
426
- };
427
- }
428
- case 'kubectl_delete_dryrun': {
429
- const { resource, namespace } = input;
430
- if (!resource) {
431
- return {
432
- success: false,
433
- error: validation_1.VALIDATION_MESSAGES.MISSING_PARAMETER('resource'),
434
- message: 'kubectl_delete_dryrun requires a resource parameter'
435
- };
436
- }
437
- // Build kubectl command
438
- const cmdArgs = ['delete', resource, '--dry-run=server'];
439
- // Add namespace if provided
440
- if (namespace) {
441
- cmdArgs.push('-n', namespace);
442
- }
443
- const output = await (0, kubernetes_utils_1.executeKubectl)(cmdArgs);
444
- return {
445
- success: true,
446
- data: output,
447
- message: `Dry-run validation successful for delete on ${resource}${namespace ? ` in namespace ${namespace}` : ''}`
448
- };
449
- }
450
- case 'kubectl_get_crd_schema': {
451
- const { crdName } = input;
452
- if (!crdName) {
453
- return {
454
- success: false,
455
- error: validation_1.VALIDATION_MESSAGES.MISSING_PARAMETER('crdName'),
456
- message: 'kubectl_get_crd_schema requires a crdName parameter (e.g., "clusters.postgresql.cnpg.io")'
457
- };
458
- }
459
- // Get CRD definition in JSON format - AI can parse what it needs
460
- const cmdArgs = ['get', 'crd', crdName, '-o', 'json'];
461
- const output = await (0, kubernetes_utils_1.executeKubectl)(cmdArgs);
462
- return {
463
- success: true,
464
- data: output,
465
- message: `Successfully retrieved CRD schema for ${crdName}`
466
- };
467
- }
468
- case 'kubectl_get_resource_json': {
469
- const { resource, namespace, field } = input;
470
- if (!resource) {
471
- return {
472
- success: false,
473
- error: validation_1.VALIDATION_MESSAGES.MISSING_PARAMETER('resource'),
474
- message: 'kubectl_get_resource_json requires a resource parameter (e.g., "deployment/my-app")'
475
- };
476
- }
477
- // Build kubectl command to get resource as JSON
478
- const cmdArgs = ['get', resource, '-o', 'json'];
479
- // Add namespace if provided
480
- if (namespace) {
481
- cmdArgs.push('-n', namespace);
482
- }
483
- const output = await (0, kubernetes_utils_1.executeKubectl)(cmdArgs);
484
- let parsed;
485
- try {
486
- parsed = JSON.parse(output);
487
- }
488
- catch (parseError) {
489
- return {
490
- success: false,
491
- error: `Failed to parse kubectl output as JSON: ${parseError instanceof Error ? parseError.message : String(parseError)}`,
492
- message: `Raw output: ${output.slice(0, 500)}${output.length > 500 ? '...' : ''}`
493
- };
494
- }
495
- // Return specific field or full resource
496
- let data = parsed;
497
- if (field) {
498
- if (!(field in parsed)) {
499
- return {
500
- success: false,
501
- error: `Field '${field}' not found in resource`,
502
- message: `Available top-level fields: ${Object.keys(parsed).join(', ')}`
503
- };
504
- }
505
- data = parsed[field];
506
- }
507
- return {
508
- success: true,
509
- data: JSON.stringify(data, null, 2),
510
- message: `Successfully retrieved ${field ? field + ' for ' : ''}${resource}${namespace ? ` in namespace ${namespace}` : ''}`
511
- };
512
- }
513
- default:
514
- return {
515
- success: false,
516
- error: `Unknown kubectl tool: ${toolName}`,
517
- message: `Tool '${toolName}' is not implemented`
518
- };
519
- }
520
- }
521
- catch (error) {
522
- const errorMessage = error instanceof Error ? error.message : String(error);
523
- return {
524
- success: false,
525
- error: errorMessage,
526
- message: `Failed to execute ${toolName}: ${errorMessage}`
527
- };
528
- }
529
- }
530
- /**
531
- * All kubectl investigation tools (read-only operations + dry-run validation)
532
- * Used during investigation phase for gathering cluster state information and validating solutions
533
- * Convenient array for passing to toolLoop()
534
- */
535
- exports.KUBECTL_INVESTIGATION_TOOLS = [
536
- exports.KUBECTL_API_RESOURCES_TOOL,
537
- exports.KUBECTL_GET_TOOL,
538
- exports.KUBECTL_DESCRIBE_TOOL,
539
- exports.KUBECTL_LOGS_TOOL,
540
- exports.KUBECTL_EVENTS_TOOL,
541
- exports.KUBECTL_PATCH_DRYRUN_TOOL,
542
- exports.KUBECTL_APPLY_DRYRUN_TOOL,
543
- exports.KUBECTL_DELETE_DRYRUN_TOOL,
544
- exports.KUBECTL_GET_CRD_SCHEMA_TOOL,
545
- exports.KUBECTL_GET_RESOURCE_JSON_TOOL
546
- ];
@@ -1,38 +0,0 @@
1
- /**
2
- * Shared Kubernetes Utilities
3
- *
4
- * Common functions for interacting with Kubernetes clusters
5
- */
6
- export interface KubectlConfig {
7
- context?: string;
8
- namespace?: string;
9
- kubeconfig?: string;
10
- timeout?: number;
11
- stdin?: string;
12
- }
13
- /**
14
- * Execute kubectl command with proper configuration
15
- * Automatically traced with OpenTelemetry
16
- * Uses semaphore to limit concurrent executions and prevent K8s API rate limiting
17
- */
18
- export declare function executeKubectl(args: string[], config?: KubectlConfig): Promise<string>;
19
- export declare function buildKubectlCommand(args: string[], config?: KubectlConfig): string;
20
- export declare class ErrorClassifier {
21
- static classifyError(error: Error): {
22
- type: string;
23
- enhancedMessage: string;
24
- };
25
- private static isNetworkError;
26
- private static isAuthenticationError;
27
- private static isAuthorizationError;
28
- private static isAPIAvailabilityError;
29
- private static isKubeconfigError;
30
- private static isVersionCompatibilityError;
31
- private static enhanceNetworkError;
32
- private static enhanceAuthenticationError;
33
- private static enhanceAuthorizationError;
34
- private static enhanceAPIAvailabilityError;
35
- private static enhanceKubeconfigError;
36
- private static enhanceVersionCompatibilityError;
37
- }
38
- //# sourceMappingURL=kubernetes-utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"kubernetes-utils.d.ts","sourceRoot":"","sources":["../../src/core/kubernetes-utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAiDH,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,MAAM,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAkE5F;AAsBD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,MAAM,CAAC,EAAE,aAAa,GAAG,MAAM,CAmBlF;AAGD,qBAAa,eAAe;IAC1B,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE;IA0D7E,OAAO,CAAC,MAAM,CAAC,cAAc;IAa7B,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAYpC,OAAO,CAAC,MAAM,CAAC,oBAAoB;IAInC,OAAO,CAAC,MAAM,CAAC,sBAAsB;IAIrC,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAMhC,OAAO,CAAC,MAAM,CAAC,2BAA2B;IAI1C,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAYlC,OAAO,CAAC,MAAM,CAAC,0BAA0B;IAgBzC,OAAO,CAAC,MAAM,CAAC,yBAAyB;IAYxC,OAAO,CAAC,MAAM,CAAC,2BAA2B;IAQ1C,OAAO,CAAC,MAAM,CAAC,sBAAsB;IAYrC,OAAO,CAAC,MAAM,CAAC,gCAAgC;CAGhD"}