@kwirthmagnify/kwirth-common-ai 0.5.29 → 0.5.30
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 +24 -0
- package/dist/back.js +39 -0
- package/package.json +1 -1
package/dist/back.d.ts
CHANGED
|
@@ -316,6 +316,30 @@ export declare const tools: {
|
|
|
316
316
|
error: any;
|
|
317
317
|
message?: undefined;
|
|
318
318
|
}>;
|
|
319
|
+
readonly restart_deployment: import("ai").Tool<{
|
|
320
|
+
namespace: string;
|
|
321
|
+
name: string;
|
|
322
|
+
}, {
|
|
323
|
+
success: boolean;
|
|
324
|
+
message: string;
|
|
325
|
+
error?: undefined;
|
|
326
|
+
} | {
|
|
327
|
+
success: boolean;
|
|
328
|
+
error: any;
|
|
329
|
+
message?: undefined;
|
|
330
|
+
}>;
|
|
331
|
+
readonly delete_pod: import("ai").Tool<{
|
|
332
|
+
namespace: string;
|
|
333
|
+
name: string;
|
|
334
|
+
}, {
|
|
335
|
+
success: boolean;
|
|
336
|
+
message: string;
|
|
337
|
+
error?: undefined;
|
|
338
|
+
} | {
|
|
339
|
+
success: boolean;
|
|
340
|
+
error: any;
|
|
341
|
+
message?: undefined;
|
|
342
|
+
}>;
|
|
319
343
|
readonly times_two: import("ai").Tool<{
|
|
320
344
|
data: number;
|
|
321
345
|
}, number>;
|
package/dist/back.js
CHANGED
|
@@ -738,6 +738,43 @@ exports.tools = {
|
|
|
738
738
|
}
|
|
739
739
|
}
|
|
740
740
|
}),
|
|
741
|
+
restart_deployment: (0, ai_1.tool)({
|
|
742
|
+
description: 'Rollout-restarts a deployment (equivalent to `kubectl rollout restart`): recreates its pods gracefully, respecting the rolling-update strategy, by stamping the kubectl.kubernetes.io/restartedAt annotation on the pod template. Restarts a workload WITHOUT changing its spec — recover stuck/crashing pods or pick up a changed ConfigMap/Secret. Preferred over delete_pod for a whole workload.',
|
|
743
|
+
inputSchema: zod_1.z.object({ namespace: zod_1.z.string().describe('Namespace of the deployment'), name: zod_1.z.string().describe('Name of the deployment') }),
|
|
744
|
+
execute: async ({ namespace, name }) => {
|
|
745
|
+
var _a, _b, _c, _d, _e;
|
|
746
|
+
ctx().trace('restart_deployment', { namespace, name });
|
|
747
|
+
try {
|
|
748
|
+
const c = ctx().clusterInfo;
|
|
749
|
+
const d = await c.appsApi.readNamespacedDeployment({ name, namespace });
|
|
750
|
+
const restartedAt = new Date().toISOString();
|
|
751
|
+
// Merge (not replace) the existing template annotations, then `add` the whole map: `add` on an
|
|
752
|
+
// existing path replaces it and on a missing path creates it, so it is safe whether or not the
|
|
753
|
+
// pod template already had annotations.
|
|
754
|
+
const annotations = Object.assign(Object.assign({}, ((_d = (_c = (_b = (_a = d.spec) === null || _a === void 0 ? void 0 : _a.template) === null || _b === void 0 ? void 0 : _b.metadata) === null || _c === void 0 ? void 0 : _c.annotations) !== null && _d !== void 0 ? _d : {})), { 'kubectl.kubernetes.io/restartedAt': restartedAt });
|
|
755
|
+
await c.appsApi.patchNamespacedDeployment({ name, namespace, body: [{ op: 'add', path: '/spec/template/metadata/annotations', value: annotations }] });
|
|
756
|
+
return { success: true, message: `Deployment ${namespace}/${name} rollout-restarted at ${restartedAt}` };
|
|
757
|
+
}
|
|
758
|
+
catch (err) {
|
|
759
|
+
return { success: false, error: (_e = err.message) !== null && _e !== void 0 ? _e : String(err) };
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
}),
|
|
763
|
+
delete_pod: (0, ai_1.tool)({
|
|
764
|
+
description: 'Deletes a single pod (equivalent to `kubectl delete pod`). Its controller (Deployment/StatefulSet/DaemonSet) recreates it — a surgical way to restart ONE stuck or misbehaving pod. Does not respect a rolling update; for a whole workload prefer restart_deployment.',
|
|
765
|
+
inputSchema: zod_1.z.object({ namespace: zod_1.z.string().describe('Namespace of the pod'), name: zod_1.z.string().describe('Name of the pod') }),
|
|
766
|
+
execute: async ({ namespace, name }) => {
|
|
767
|
+
var _a;
|
|
768
|
+
ctx().trace('delete_pod', { namespace, name });
|
|
769
|
+
try {
|
|
770
|
+
await ctx().clusterInfo.coreApi.deleteNamespacedPod({ name, namespace });
|
|
771
|
+
return { success: true, message: `Pod ${namespace}/${name} deleted; its controller will recreate it` };
|
|
772
|
+
}
|
|
773
|
+
catch (err) {
|
|
774
|
+
return { success: false, error: (_a = err.message) !== null && _a !== void 0 ? _a : String(err) };
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
}),
|
|
741
778
|
// ── MISC ─────────────────────────────────────────────────────────────────
|
|
742
779
|
times_two: (0, ai_1.tool)({
|
|
743
780
|
description: 'Multiplies a number by two.',
|
|
@@ -1101,6 +1138,8 @@ exports.toolInfoList = [
|
|
|
1101
1138
|
{ name: 'start_node', effect: EToolEffect.WRITE, description: 'Starts a previously stopped cluster node and uncordons it. For k3d uses `k3d node start`.' },
|
|
1102
1139
|
{ name: 'add_replica', effect: EToolEffect.WRITE, description: 'Scales up a deployment by adding one replica.' },
|
|
1103
1140
|
{ name: 'remove_replica', effect: EToolEffect.WRITE, description: 'Scales down a deployment by removing one replica. Minimum of 1 replica is enforced.' },
|
|
1141
|
+
{ name: 'restart_deployment', effect: EToolEffect.WRITE, description: 'Rollout-restarts a deployment (recreates its pods gracefully via the restartedAt annotation, respecting the rolling update) — restart a workload without changing its spec.' },
|
|
1142
|
+
{ name: 'delete_pod', effect: EToolEffect.WRITE, description: 'Deletes a single pod; its controller recreates it. Surgical restart of one stuck pod (no rolling update — prefer restart_deployment for a whole workload).' },
|
|
1104
1143
|
{ name: 'times_two', effect: EToolEffect.READ, description: 'Multiplies a number by two.' },
|
|
1105
1144
|
{ name: 'father_of', effect: EToolEffect.READ, description: 'Returns the name of the father of a person.' },
|
|
1106
1145
|
{ 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.' },
|