@kwirthmagnify/kwirth-common-ai 0.5.19 → 0.5.21
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/dist/back.d.ts +7 -0
- package/dist/back.js +43 -15
- package/package.json +1 -1
package/dist/back.d.ts
CHANGED
|
@@ -20,6 +20,13 @@ export interface IToolInfo {
|
|
|
20
20
|
}
|
|
21
21
|
export declare const runWithToolContext: <T>(context: IToolContext, fn: () => Promise<T>) => Promise<T>;
|
|
22
22
|
export declare const tools: {
|
|
23
|
+
readonly list_namespaces: import("ai").Tool<Record<string, never>, {
|
|
24
|
+
namespaces: any;
|
|
25
|
+
error?: undefined;
|
|
26
|
+
} | {
|
|
27
|
+
error: any;
|
|
28
|
+
namespaces?: undefined;
|
|
29
|
+
}>;
|
|
23
30
|
readonly get_node_data: import("ai").Tool<Record<string, never>, any>;
|
|
24
31
|
readonly get_cluster_data: import("ai").Tool<Record<string, never>, {
|
|
25
32
|
name: any;
|
package/dist/back.js
CHANGED
|
@@ -202,6 +202,30 @@ function mapToJson(data) {
|
|
|
202
202
|
}
|
|
203
203
|
exports.tools = {
|
|
204
204
|
// ── CLUSTER CONFIG ───────────────────────────────────────────────────────
|
|
205
|
+
list_namespaces: (0, ai_1.tool)({
|
|
206
|
+
description: 'Lists all namespaces in the cluster with their status and labels.',
|
|
207
|
+
inputSchema: zod_1.z.object({}),
|
|
208
|
+
execute: async () => {
|
|
209
|
+
var _a;
|
|
210
|
+
ctx().trace('list_namespaces', {});
|
|
211
|
+
try {
|
|
212
|
+
const resp = await ctx().clusterInfo.coreApi.listNamespace();
|
|
213
|
+
return {
|
|
214
|
+
namespaces: resp.items.map((ns) => {
|
|
215
|
+
var _a, _b, _c, _d;
|
|
216
|
+
return ({
|
|
217
|
+
name: (_a = ns.metadata) === null || _a === void 0 ? void 0 : _a.name,
|
|
218
|
+
status: (_b = ns.status) === null || _b === void 0 ? void 0 : _b.phase,
|
|
219
|
+
labels: (_d = (_c = ns.metadata) === null || _c === void 0 ? void 0 : _c.labels) !== null && _d !== void 0 ? _d : {}
|
|
220
|
+
});
|
|
221
|
+
})
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
catch (err) {
|
|
225
|
+
return { error: (_a = err.message) !== null && _a !== void 0 ? _a : String(err) };
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}),
|
|
205
229
|
get_node_data: (0, ai_1.tool)({
|
|
206
230
|
description: 'Returns configuration info about all Kubernetes nodes (name, IP). Configuration only — not workload or usage data.',
|
|
207
231
|
inputSchema: zod_1.z.object({}),
|
|
@@ -224,18 +248,19 @@ exports.tools = {
|
|
|
224
248
|
}),
|
|
225
249
|
get_workload_data: (0, ai_1.tool)({
|
|
226
250
|
description: 'Returns all workloads in the cluster: deployments, statefulsets, daemonsets, pods and services. Optionally filter by namespace.',
|
|
227
|
-
inputSchema: zod_1.z.object({ namespace: zod_1.z.string().optional().describe('Namespace to filter results (omit for all namespaces)') }),
|
|
251
|
+
inputSchema: zod_1.z.object({ namespace: zod_1.z.string().optional().describe('Namespace to filter results (omit or pass "*" for all namespaces)') }),
|
|
228
252
|
execute: async ({ namespace }) => {
|
|
229
253
|
var _a;
|
|
230
|
-
|
|
254
|
+
const ns = namespace && namespace !== '*' ? namespace : undefined;
|
|
255
|
+
ctx().trace('get_workload_data', { namespace: ns !== null && ns !== void 0 ? ns : '*' });
|
|
231
256
|
try {
|
|
232
257
|
const c = ctx().clusterInfo;
|
|
233
258
|
const [d, s, ds, p, svc] = await Promise.all([
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
259
|
+
ns ? c.appsApi.listNamespacedDeployment({ namespace: ns }) : c.appsApi.listDeploymentForAllNamespaces(),
|
|
260
|
+
ns ? c.appsApi.listNamespacedStatefulSet({ namespace: ns }) : c.appsApi.listStatefulSetForAllNamespaces(),
|
|
261
|
+
ns ? c.appsApi.listNamespacedDaemonSet({ namespace: ns }) : c.appsApi.listDaemonSetForAllNamespaces(),
|
|
262
|
+
ns ? c.coreApi.listNamespacedPod({ namespace: ns }) : c.coreApi.listPodForAllNamespaces(),
|
|
263
|
+
ns ? c.coreApi.listNamespacedService({ namespace: ns }) : c.coreApi.listServiceForAllNamespaces()
|
|
239
264
|
]);
|
|
240
265
|
return {
|
|
241
266
|
deployments: d.items.map((x) => { var _a, _b, _c, _d, _e, _f, _g; return ({ name: (_a = x.metadata) === null || _a === void 0 ? void 0 : _a.name, namespace: (_b = x.metadata) === null || _b === void 0 ? void 0 : _b.namespace, replicas: (_c = x.spec) === null || _c === void 0 ? void 0 : _c.replicas, readyReplicas: (_e = (_d = x.status) === null || _d === void 0 ? void 0 : _d.readyReplicas) !== null && _e !== void 0 ? _e : 0, availableReplicas: (_g = (_f = x.status) === null || _f === void 0 ? void 0 : _f.availableReplicas) !== null && _g !== void 0 ? _g : 0 }); }),
|
|
@@ -292,14 +317,15 @@ exports.tools = {
|
|
|
292
317
|
}),
|
|
293
318
|
list_services: (0, ai_1.tool)({
|
|
294
319
|
description: 'Lists all Services in the cluster with full details (type, clusterIP, ports, selector). Optionally filter by namespace.',
|
|
295
|
-
inputSchema: zod_1.z.object({ namespace: zod_1.z.string().optional().describe('Namespace to filter results (omit for all namespaces)') }),
|
|
320
|
+
inputSchema: zod_1.z.object({ namespace: zod_1.z.string().optional().describe('Namespace to filter results (omit or pass "*" for all namespaces)') }),
|
|
296
321
|
execute: async ({ namespace }) => {
|
|
297
322
|
var _a;
|
|
298
|
-
|
|
323
|
+
const ns = namespace && namespace !== '*' ? namespace : undefined;
|
|
324
|
+
ctx().trace('list_services', { namespace: ns !== null && ns !== void 0 ? ns : '*' });
|
|
299
325
|
try {
|
|
300
326
|
const c = ctx().clusterInfo;
|
|
301
|
-
const resp =
|
|
302
|
-
? await c.coreApi.listNamespacedService({ namespace })
|
|
327
|
+
const resp = ns
|
|
328
|
+
? await c.coreApi.listNamespacedService({ namespace: ns })
|
|
303
329
|
: await c.coreApi.listServiceForAllNamespaces();
|
|
304
330
|
return {
|
|
305
331
|
services: resp.items.map((x) => {
|
|
@@ -323,14 +349,15 @@ exports.tools = {
|
|
|
323
349
|
}),
|
|
324
350
|
list_ingresses: (0, ai_1.tool)({
|
|
325
351
|
description: 'Lists all Ingresses in the cluster (hosts, paths, TLS, backend services). Optionally filter by namespace.',
|
|
326
|
-
inputSchema: zod_1.z.object({ namespace: zod_1.z.string().optional().describe('Namespace to filter results (omit for all namespaces)') }),
|
|
352
|
+
inputSchema: zod_1.z.object({ namespace: zod_1.z.string().optional().describe('Namespace to filter results (omit or pass "*" for all namespaces)') }),
|
|
327
353
|
execute: async ({ namespace }) => {
|
|
328
354
|
var _a;
|
|
329
|
-
|
|
355
|
+
const ns = namespace && namespace !== '*' ? namespace : undefined;
|
|
356
|
+
ctx().trace('list_ingresses', { namespace: ns !== null && ns !== void 0 ? ns : '*' });
|
|
330
357
|
try {
|
|
331
358
|
const c = ctx().clusterInfo;
|
|
332
|
-
const resp =
|
|
333
|
-
? await c.networkApi.listNamespacedIngress({ namespace })
|
|
359
|
+
const resp = ns
|
|
360
|
+
? await c.networkApi.listNamespacedIngress({ namespace: ns })
|
|
334
361
|
: await c.networkApi.listIngressForAllNamespaces();
|
|
335
362
|
return {
|
|
336
363
|
ingresses: resp.items.map((x) => {
|
|
@@ -662,6 +689,7 @@ exports.tools = {
|
|
|
662
689
|
}),
|
|
663
690
|
};
|
|
664
691
|
exports.toolInfoList = [
|
|
692
|
+
{ name: 'list_namespaces', description: 'Lists all namespaces in the cluster with their status and labels.' },
|
|
665
693
|
{ name: 'get_node_data', description: 'Returns configuration info about all Kubernetes nodes (name, IP). Configuration only — not workload or usage data.' },
|
|
666
694
|
{ name: 'get_cluster_data', description: 'Returns general cluster info: name, flavour (AKS/EKS/GKE/k3s/k3d), total vCPUs, total memory, node count and readiness status.' },
|
|
667
695
|
{ name: 'get_workload_data', description: 'Returns all workloads in the cluster: deployments, statefulsets, daemonsets, pods and services. Optionally filter by namespace.' },
|