@kwirthmagnify/kwirth-common-ai 0.5.18 → 0.5.20
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 +29 -0
- package/dist/back.js +108 -0
- 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;
|
|
@@ -76,6 +83,28 @@ export declare const tools: {
|
|
|
76
83
|
namespace: string;
|
|
77
84
|
name: string;
|
|
78
85
|
}, any>;
|
|
86
|
+
readonly list_services: import("ai").Tool<{
|
|
87
|
+
namespace?: string | undefined;
|
|
88
|
+
}, {
|
|
89
|
+
services: any;
|
|
90
|
+
error?: undefined;
|
|
91
|
+
} | {
|
|
92
|
+
error: any;
|
|
93
|
+
services?: undefined;
|
|
94
|
+
}>;
|
|
95
|
+
readonly list_ingresses: import("ai").Tool<{
|
|
96
|
+
namespace?: string | undefined;
|
|
97
|
+
}, {
|
|
98
|
+
ingresses: any;
|
|
99
|
+
error?: undefined;
|
|
100
|
+
} | {
|
|
101
|
+
error: any;
|
|
102
|
+
ingresses?: undefined;
|
|
103
|
+
}>;
|
|
104
|
+
readonly get_ingress_yaml: import("ai").Tool<{
|
|
105
|
+
namespace: string;
|
|
106
|
+
name: string;
|
|
107
|
+
}, any>;
|
|
79
108
|
readonly get_cluster_usage: import("ai").Tool<Record<string, never>, {
|
|
80
109
|
error: string;
|
|
81
110
|
vcpus?: undefined;
|
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({}),
|
|
@@ -290,6 +314,86 @@ exports.tools = {
|
|
|
290
314
|
}
|
|
291
315
|
}
|
|
292
316
|
}),
|
|
317
|
+
list_services: (0, ai_1.tool)({
|
|
318
|
+
description: 'Lists all Services in the cluster with full details (type, clusterIP, ports, selector). Optionally filter by namespace.',
|
|
319
|
+
inputSchema: zod_1.z.object({ namespace: zod_1.z.string().optional().describe('Namespace to filter results (omit for all namespaces)') }),
|
|
320
|
+
execute: async ({ namespace }) => {
|
|
321
|
+
var _a;
|
|
322
|
+
ctx().trace('list_services', { namespace: namespace !== null && namespace !== void 0 ? namespace : '*' });
|
|
323
|
+
try {
|
|
324
|
+
const c = ctx().clusterInfo;
|
|
325
|
+
const resp = namespace
|
|
326
|
+
? await c.coreApi.listNamespacedService({ namespace })
|
|
327
|
+
: await c.coreApi.listServiceForAllNamespaces();
|
|
328
|
+
return {
|
|
329
|
+
services: resp.items.map((x) => {
|
|
330
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
331
|
+
return ({
|
|
332
|
+
name: (_a = x.metadata) === null || _a === void 0 ? void 0 : _a.name,
|
|
333
|
+
namespace: (_b = x.metadata) === null || _b === void 0 ? void 0 : _b.namespace,
|
|
334
|
+
type: (_c = x.spec) === null || _c === void 0 ? void 0 : _c.type,
|
|
335
|
+
clusterIP: (_d = x.spec) === null || _d === void 0 ? void 0 : _d.clusterIP,
|
|
336
|
+
externalIPs: (_f = (_e = x.spec) === null || _e === void 0 ? void 0 : _e.externalIPs) !== null && _f !== void 0 ? _f : [],
|
|
337
|
+
ports: (_j = (_h = (_g = x.spec) === null || _g === void 0 ? void 0 : _g.ports) === null || _h === void 0 ? void 0 : _h.map((p) => ({ name: p.name, port: p.port, targetPort: p.targetPort, protocol: p.protocol }))) !== null && _j !== void 0 ? _j : [],
|
|
338
|
+
selector: (_l = (_k = x.spec) === null || _k === void 0 ? void 0 : _k.selector) !== null && _l !== void 0 ? _l : {}
|
|
339
|
+
});
|
|
340
|
+
})
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
catch (err) {
|
|
344
|
+
return { error: (_a = err.message) !== null && _a !== void 0 ? _a : String(err) };
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}),
|
|
348
|
+
list_ingresses: (0, ai_1.tool)({
|
|
349
|
+
description: 'Lists all Ingresses in the cluster (hosts, paths, TLS, backend services). Optionally filter by namespace.',
|
|
350
|
+
inputSchema: zod_1.z.object({ namespace: zod_1.z.string().optional().describe('Namespace to filter results (omit for all namespaces)') }),
|
|
351
|
+
execute: async ({ namespace }) => {
|
|
352
|
+
var _a;
|
|
353
|
+
ctx().trace('list_ingresses', { namespace: namespace !== null && namespace !== void 0 ? namespace : '*' });
|
|
354
|
+
try {
|
|
355
|
+
const c = ctx().clusterInfo;
|
|
356
|
+
const resp = namespace
|
|
357
|
+
? await c.networkApi.listNamespacedIngress({ namespace })
|
|
358
|
+
: await c.networkApi.listIngressForAllNamespaces();
|
|
359
|
+
return {
|
|
360
|
+
ingresses: resp.items.map((x) => {
|
|
361
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
362
|
+
return ({
|
|
363
|
+
name: (_a = x.metadata) === null || _a === void 0 ? void 0 : _a.name,
|
|
364
|
+
namespace: (_b = x.metadata) === null || _b === void 0 ? void 0 : _b.namespace,
|
|
365
|
+
ingressClass: (_c = x.spec) === null || _c === void 0 ? void 0 : _c.ingressClassName,
|
|
366
|
+
hosts: (_f = (_e = (_d = x.spec) === null || _d === void 0 ? void 0 : _d.rules) === null || _e === void 0 ? void 0 : _e.map((r) => r.host)) !== null && _f !== void 0 ? _f : [],
|
|
367
|
+
paths: (_j = (_h = (_g = x.spec) === null || _g === void 0 ? void 0 : _g.rules) === null || _h === void 0 ? void 0 : _h.flatMap((r) => { var _a, _b, _c; return (_c = (_b = (_a = r.http) === null || _a === void 0 ? void 0 : _a.paths) === null || _b === void 0 ? void 0 : _b.map((p) => { var _a, _b, _c, _d, _e; return ({ host: r.host, path: p.path, pathType: p.pathType, service: (_b = (_a = p.backend) === null || _a === void 0 ? void 0 : _a.service) === null || _b === void 0 ? void 0 : _b.name, port: (_e = (_d = (_c = p.backend) === null || _c === void 0 ? void 0 : _c.service) === null || _d === void 0 ? void 0 : _d.port) === null || _e === void 0 ? void 0 : _e.number }); })) !== null && _c !== void 0 ? _c : []; })) !== null && _j !== void 0 ? _j : [],
|
|
368
|
+
tls: (_m = (_l = (_k = x.spec) === null || _k === void 0 ? void 0 : _k.tls) === null || _l === void 0 ? void 0 : _l.map((t) => ({ secretName: t.secretName, hosts: t.hosts }))) !== null && _m !== void 0 ? _m : [],
|
|
369
|
+
loadBalancer: (_q = (_p = (_o = x.status) === null || _o === void 0 ? void 0 : _o.loadBalancer) === null || _p === void 0 ? void 0 : _p.ingress) !== null && _q !== void 0 ? _q : []
|
|
370
|
+
});
|
|
371
|
+
})
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
catch (err) {
|
|
375
|
+
return { error: (_a = err.message) !== null && _a !== void 0 ? _a : String(err) };
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}),
|
|
379
|
+
get_ingress_yaml: (0, ai_1.tool)({
|
|
380
|
+
description: 'Returns the full Kubernetes Ingress manifest (equivalent to kubectl get ingress -o yaml) for a given namespace and ingress name.',
|
|
381
|
+
inputSchema: zod_1.z.object({
|
|
382
|
+
namespace: zod_1.z.string().describe('Namespace where the ingress lives'),
|
|
383
|
+
name: zod_1.z.string().describe('Name of the ingress')
|
|
384
|
+
}),
|
|
385
|
+
execute: async ({ namespace, name }) => {
|
|
386
|
+
var _a;
|
|
387
|
+
ctx().trace('get_ingress_yaml', { namespace, name });
|
|
388
|
+
try {
|
|
389
|
+
const ing = await ctx().clusterInfo.networkApi.readNamespacedIngress({ name, namespace });
|
|
390
|
+
return ing;
|
|
391
|
+
}
|
|
392
|
+
catch (err) {
|
|
393
|
+
return { error: (_a = err.message) !== null && _a !== void 0 ? _a : String(err) };
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}),
|
|
293
397
|
// ── CURRENT USAGE ────────────────────────────────────────────────────────
|
|
294
398
|
get_cluster_usage: (0, ai_1.tool)({
|
|
295
399
|
description: 'Returns current overall cluster resource usage: CPU%, memory%, network Mbps, total vCPUs and total memory GB.',
|
|
@@ -582,11 +686,15 @@ exports.tools = {
|
|
|
582
686
|
}),
|
|
583
687
|
};
|
|
584
688
|
exports.toolInfoList = [
|
|
689
|
+
{ name: 'list_namespaces', description: 'Lists all namespaces in the cluster with their status and labels.' },
|
|
585
690
|
{ name: 'get_node_data', description: 'Returns configuration info about all Kubernetes nodes (name, IP). Configuration only — not workload or usage data.' },
|
|
586
691
|
{ 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.' },
|
|
587
692
|
{ name: 'get_workload_data', description: 'Returns all workloads in the cluster: deployments, statefulsets, daemonsets, pods and services. Optionally filter by namespace.' },
|
|
588
693
|
{ name: 'get_space_data', description: 'Returns all resources in a specific Kubernetes namespace: pods (with restart count), deployments, services, configmap names.' },
|
|
589
694
|
{ name: 'get_service_yaml', description: 'Returns the full Kubernetes Service manifest (equivalent to kubectl get service -o yaml) for a given namespace and service name.' },
|
|
695
|
+
{ name: 'list_services', description: 'Lists all Services in the cluster with full details (type, clusterIP, ports, selector). Optionally filter by namespace.' },
|
|
696
|
+
{ name: 'list_ingresses', description: 'Lists all Ingresses in the cluster (hosts, paths, TLS, backend services). Optionally filter by namespace.' },
|
|
697
|
+
{ name: 'get_ingress_yaml', description: 'Returns the full Kubernetes Ingress manifest (equivalent to kubectl get ingress -o yaml) for a given namespace and ingress name.' },
|
|
590
698
|
{ name: 'get_cluster_usage', description: 'Returns current overall cluster resource usage: CPU%, memory%, network Mbps, total vCPUs and total memory GB.' },
|
|
591
699
|
{ name: 'get_node_usage', description: 'Returns current CPU and memory usage for one node or all nodes from the latest metrics reading.' },
|
|
592
700
|
{ name: 'get_deployment_usage', description: 'Returns current aggregated CPU and memory usage for all pods belonging to a specific deployment.' },
|