async () => {
const clusterId = "cls_abc123"; // resolved by the agent from conversation
const namespace = "production"; // resolved by the agent from conversation
const kube = (path) => cnap.request({
method: "GET",
path: `/v1/clusters/${clusterId}/kube/${path}`,
}).then(r => r.body);
const pods = await kube(`api/v1/namespaces/${namespace}/pods`);
return pods.items.map(p => ({
name: p.metadata.name,
phase: p.status.phase,
restarts: p.status.containerStatuses?.reduce((s, c) => s + c.restartCount, 0) || 0,
ready: p.status.containerStatuses?.every(c => c.ready) || false,
containers: p.status.containerStatuses?.map(c => ({
name: c.name,
ready: c.ready,
restarts: c.restartCount,
state: Object.keys(c.state || {})[0],
reason: c.state?.waiting?.reason || c.state?.terminated?.reason || null,
})),
}));
}