@kwirthmagnify/kwirth-common-ai 0.5.25 → 0.5.26
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 +64 -0
- package/dist/back.js +98 -0
- package/package.json +1 -1
package/dist/back.d.ts
CHANGED
|
@@ -334,6 +334,70 @@ export declare const tools: {
|
|
|
334
334
|
count: number;
|
|
335
335
|
events: Record<string, unknown>[];
|
|
336
336
|
}>;
|
|
337
|
+
readonly get_pod_logs: import("ai").Tool<{
|
|
338
|
+
namespace: string;
|
|
339
|
+
name: string;
|
|
340
|
+
container?: string | undefined;
|
|
341
|
+
previous?: boolean | undefined;
|
|
342
|
+
tailLines?: number | undefined;
|
|
343
|
+
}, {
|
|
344
|
+
namespace: string;
|
|
345
|
+
name: string;
|
|
346
|
+
container: string | null;
|
|
347
|
+
previous: boolean;
|
|
348
|
+
truncated: boolean;
|
|
349
|
+
logs: string;
|
|
350
|
+
error?: undefined;
|
|
351
|
+
} | {
|
|
352
|
+
error: any;
|
|
353
|
+
namespace?: undefined;
|
|
354
|
+
name?: undefined;
|
|
355
|
+
container?: undefined;
|
|
356
|
+
previous?: undefined;
|
|
357
|
+
truncated?: undefined;
|
|
358
|
+
logs?: undefined;
|
|
359
|
+
}>;
|
|
360
|
+
readonly describe_pod: import("ai").Tool<{
|
|
361
|
+
namespace: string;
|
|
362
|
+
name: string;
|
|
363
|
+
}, {
|
|
364
|
+
name: string;
|
|
365
|
+
namespace: string;
|
|
366
|
+
phase: any;
|
|
367
|
+
node: any;
|
|
368
|
+
startTime: any;
|
|
369
|
+
reason: any;
|
|
370
|
+
message: any;
|
|
371
|
+
conditions: any;
|
|
372
|
+
containers: any;
|
|
373
|
+
initContainers: any;
|
|
374
|
+
spec: {
|
|
375
|
+
containers: any;
|
|
376
|
+
restartPolicy: any;
|
|
377
|
+
};
|
|
378
|
+
error?: undefined;
|
|
379
|
+
} | {
|
|
380
|
+
error: any;
|
|
381
|
+
name?: undefined;
|
|
382
|
+
namespace?: undefined;
|
|
383
|
+
phase?: undefined;
|
|
384
|
+
node?: undefined;
|
|
385
|
+
startTime?: undefined;
|
|
386
|
+
reason?: undefined;
|
|
387
|
+
message?: undefined;
|
|
388
|
+
conditions?: undefined;
|
|
389
|
+
containers?: undefined;
|
|
390
|
+
initContainers?: undefined;
|
|
391
|
+
spec?: undefined;
|
|
392
|
+
}>;
|
|
393
|
+
readonly get_pod_yaml: import("ai").Tool<{
|
|
394
|
+
namespace: string;
|
|
395
|
+
name: string;
|
|
396
|
+
}, any>;
|
|
397
|
+
readonly get_deployment_yaml: import("ai").Tool<{
|
|
398
|
+
namespace: string;
|
|
399
|
+
name: string;
|
|
400
|
+
}, any>;
|
|
337
401
|
};
|
|
338
402
|
export declare const toolInfoList: IToolInfo[];
|
|
339
403
|
export interface IAgentRunResult {
|
package/dist/back.js
CHANGED
|
@@ -755,6 +755,100 @@ exports.tools = {
|
|
|
755
755
|
return { count: evs.length, events: evs.map(summarizeClusterEvent) };
|
|
756
756
|
}
|
|
757
757
|
}),
|
|
758
|
+
// ── POD DIAGNOSIS ────────────────────────────────────────────────────────
|
|
759
|
+
get_pod_logs: (0, ai_1.tool)({
|
|
760
|
+
description: 'Returns recent container logs for a pod (equivalent to kubectl logs). For a crashing pod (CrashLoopBackOff) pass previous:true to read the CRASHED container instance logs — that is where the root cause usually is (the events only say it is restarting, not why).',
|
|
761
|
+
inputSchema: zod_1.z.object({
|
|
762
|
+
namespace: zod_1.z.string().describe('Namespace of the pod'),
|
|
763
|
+
name: zod_1.z.string().describe('Name of the pod'),
|
|
764
|
+
container: zod_1.z.string().optional().describe('Container name (omit to use the pod default / first container)'),
|
|
765
|
+
previous: zod_1.z.boolean().optional().describe('Read the previous (crashed/restarted) container instance logs — key for CrashLoopBackOff'),
|
|
766
|
+
tailLines: zod_1.z.number().optional().describe('How many trailing lines to return (default 200)')
|
|
767
|
+
}),
|
|
768
|
+
execute: async ({ namespace, name, container, previous, tailLines = 200 }) => {
|
|
769
|
+
var _a, _b;
|
|
770
|
+
ctx().trace('get_pod_logs', { namespace, name, container: container !== null && container !== void 0 ? container : '(default)', previous: !!previous, tailLines });
|
|
771
|
+
try {
|
|
772
|
+
const raw = await ctx().clusterInfo.coreApi.readNamespacedPodLog({ name, namespace, container, previous: !!previous, tailLines });
|
|
773
|
+
const text = typeof raw === 'string' ? raw : ((_a = raw === null || raw === void 0 ? void 0 : raw.body) !== null && _a !== void 0 ? _a : JSON.stringify(raw));
|
|
774
|
+
const truncated = text.length > 15000;
|
|
775
|
+
return { namespace, name, container: container !== null && container !== void 0 ? container : null, previous: !!previous, truncated, logs: truncated ? text.slice(-15000) : text };
|
|
776
|
+
}
|
|
777
|
+
catch (err) {
|
|
778
|
+
return { error: (_b = err.message) !== null && _b !== void 0 ? _b : String(err) };
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
}),
|
|
782
|
+
describe_pod: (0, ai_1.tool)({
|
|
783
|
+
description: 'Returns a diagnostic summary of a pod (equivalent to kubectl describe pod): phase, conditions, and per-container status — waiting reason (CrashLoopBackOff/ImagePullBackOff…), last termination reason + exitCode (137=OOMKilled, 1=app error, 143=SIGTERM), restart count, image, resources and probes. Best first step to categorize a pod failure.',
|
|
784
|
+
inputSchema: zod_1.z.object({
|
|
785
|
+
namespace: zod_1.z.string().describe('Namespace of the pod'),
|
|
786
|
+
name: zod_1.z.string().describe('Name of the pod')
|
|
787
|
+
}),
|
|
788
|
+
execute: async ({ namespace, name }) => {
|
|
789
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
790
|
+
ctx().trace('describe_pod', { namespace, name });
|
|
791
|
+
try {
|
|
792
|
+
const pod = await ctx().clusterInfo.coreApi.readNamespacedPod({ name, namespace });
|
|
793
|
+
const spec = (_a = pod.spec) !== null && _a !== void 0 ? _a : {}, status = (_b = pod.status) !== null && _b !== void 0 ? _b : {};
|
|
794
|
+
const containerStatus = (cs) => {
|
|
795
|
+
var _a, _b, _c, _d;
|
|
796
|
+
return ({
|
|
797
|
+
name: cs.name, image: cs.image, ready: cs.ready, restartCount: cs.restartCount,
|
|
798
|
+
state: ((_a = cs.state) === null || _a === void 0 ? void 0 : _a.waiting) ? { waiting: { reason: cs.state.waiting.reason, message: cs.state.waiting.message } }
|
|
799
|
+
: ((_b = cs.state) === null || _b === void 0 ? void 0 : _b.terminated) ? { terminated: { reason: cs.state.terminated.reason, exitCode: cs.state.terminated.exitCode } }
|
|
800
|
+
: ((_c = cs.state) === null || _c === void 0 ? void 0 : _c.running) ? { running: { startedAt: cs.state.running.startedAt } } : cs.state,
|
|
801
|
+
lastTerminated: ((_d = cs.lastState) === null || _d === void 0 ? void 0 : _d.terminated) ? { reason: cs.lastState.terminated.reason, exitCode: cs.lastState.terminated.exitCode, signal: cs.lastState.terminated.signal, finishedAt: cs.lastState.terminated.finishedAt } : undefined
|
|
802
|
+
});
|
|
803
|
+
};
|
|
804
|
+
const specContainer = (c) => ({ name: c.name, image: c.image, resources: c.resources, livenessProbe: !!c.livenessProbe, readinessProbe: !!c.readinessProbe, startupProbe: !!c.startupProbe });
|
|
805
|
+
return {
|
|
806
|
+
name, namespace, phase: status.phase, node: spec.nodeName, startTime: status.startTime, reason: status.reason, message: status.message,
|
|
807
|
+
conditions: ((_c = status.conditions) !== null && _c !== void 0 ? _c : []).map((c) => ({ type: c.type, status: c.status, reason: c.reason })),
|
|
808
|
+
containers: ((_d = status.containerStatuses) !== null && _d !== void 0 ? _d : []).map(containerStatus),
|
|
809
|
+
initContainers: ((_e = status.initContainerStatuses) !== null && _e !== void 0 ? _e : []).map(containerStatus),
|
|
810
|
+
spec: { containers: ((_f = spec.containers) !== null && _f !== void 0 ? _f : []).map(specContainer), restartPolicy: spec.restartPolicy }
|
|
811
|
+
};
|
|
812
|
+
}
|
|
813
|
+
catch (err) {
|
|
814
|
+
return { error: (_g = err.message) !== null && _g !== void 0 ? _g : String(err) };
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
}),
|
|
818
|
+
get_pod_yaml: (0, ai_1.tool)({
|
|
819
|
+
description: 'Returns the full Kubernetes Pod manifest (equivalent to kubectl get pod -o yaml): complete spec (env, volumes, resources, probes) and status. Use for deeper misconfiguration analysis after describe_pod.',
|
|
820
|
+
inputSchema: zod_1.z.object({
|
|
821
|
+
namespace: zod_1.z.string().describe('Namespace of the pod'),
|
|
822
|
+
name: zod_1.z.string().describe('Name of the pod')
|
|
823
|
+
}),
|
|
824
|
+
execute: async ({ namespace, name }) => {
|
|
825
|
+
var _a;
|
|
826
|
+
ctx().trace('get_pod_yaml', { namespace, name });
|
|
827
|
+
try {
|
|
828
|
+
return await ctx().clusterInfo.coreApi.readNamespacedPod({ name, namespace });
|
|
829
|
+
}
|
|
830
|
+
catch (err) {
|
|
831
|
+
return { error: (_a = err.message) !== null && _a !== void 0 ? _a : String(err) };
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
}),
|
|
835
|
+
get_deployment_yaml: (0, ai_1.tool)({
|
|
836
|
+
description: 'Returns the full Kubernetes Deployment manifest (equivalent to kubectl get deployment -o yaml): the pod template (image, env, resources, probes) and strategy. Use to check if a pod problem comes from the owning workload spec.',
|
|
837
|
+
inputSchema: zod_1.z.object({
|
|
838
|
+
namespace: zod_1.z.string().describe('Namespace of the deployment'),
|
|
839
|
+
name: zod_1.z.string().describe('Name of the deployment')
|
|
840
|
+
}),
|
|
841
|
+
execute: async ({ namespace, name }) => {
|
|
842
|
+
var _a;
|
|
843
|
+
ctx().trace('get_deployment_yaml', { namespace, name });
|
|
844
|
+
try {
|
|
845
|
+
return await ctx().clusterInfo.appsApi.readNamespacedDeployment({ name, namespace });
|
|
846
|
+
}
|
|
847
|
+
catch (err) {
|
|
848
|
+
return { error: (_a = err.message) !== null && _a !== void 0 ? _a : String(err) };
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
}),
|
|
758
852
|
};
|
|
759
853
|
exports.toolInfoList = [
|
|
760
854
|
{ name: 'list_namespaces', effect: EToolEffect.READ, description: 'Lists all namespaces in the cluster with their status and labels.' },
|
|
@@ -784,6 +878,10 @@ exports.toolInfoList = [
|
|
|
784
878
|
{ name: 'get_certificate_info', effect: EToolEffect.READ, description: 'Connects to a hostname via HTTPS and returns TLS certificate details: subject, issuer, validity dates, SANs, fingerprint and whether it is currently valid.' },
|
|
785
879
|
{ name: 'get_cluster_events', effect: EToolEffect.READ, description: 'Returns recent buffered Kubernetes events for this cluster (warnings + object lifecycle changes); filter by warnings only or namespace.' },
|
|
786
880
|
{ name: 'get_object_events', effect: EToolEffect.READ, description: 'Returns recent events for a specific Kubernetes object (namespace + name), including related kube Events.' },
|
|
881
|
+
{ name: 'get_pod_logs', effect: EToolEffect.READ, description: 'Returns container logs for a pod (kubectl logs); previous:true reads the crashed instance logs — the root cause of a CrashLoopBackOff.' },
|
|
882
|
+
{ name: 'describe_pod', effect: EToolEffect.READ, description: 'Diagnostic summary of a pod (kubectl describe pod): per-container waiting/terminated reason + exitCode (OOMKilled/CrashLoop…), restart count, probes.' },
|
|
883
|
+
{ name: 'get_pod_yaml', effect: EToolEffect.READ, description: 'Full Pod manifest (kubectl get pod -o yaml): spec (env, volumes, resources, probes) and status.' },
|
|
884
|
+
{ name: 'get_deployment_yaml', effect: EToolEffect.READ, description: 'Full Deployment manifest (kubectl get deployment -o yaml): pod template (image, env, resources, probes) and strategy.' },
|
|
787
885
|
];
|
|
788
886
|
// Resolves the tool names an agent may use: autoTools = full catalog, otherwise its own list
|
|
789
887
|
// (intersected with the catalog); readOnly filters out WRITE-effect tools. Pure (no LLM) → unit-testable.
|