@kwirthmagnify/kwirth-common-ai 0.5.40 → 0.5.41

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.
Files changed (2) hide show
  1. package/dist/back.js +49 -39
  2. package/package.json +1 -1
package/dist/back.js CHANGED
@@ -82,7 +82,7 @@ exports.buildModel = buildModel;
82
82
  // un schema Zod (patrón Output.object). Reutilizable por toda la plataforma (Iter la usa para extraer un mapa
83
83
  // de un diagrama). No lanza: los errores vuelven en `error`.
84
84
  const generateVision = async (opts) => {
85
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
85
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _l, _m, _o, _p, _q, _r;
86
86
  try {
87
87
  const imagePart = opts.mediaType
88
88
  ? { type: 'image', image: opts.image, mediaType: opts.mediaType }
@@ -90,24 +90,34 @@ const generateVision = async (opts) => {
90
90
  console.log('[generateVision] request', {
91
91
  modelId: (_d = (_b = (_a = opts.model) === null || _a === void 0 ? void 0 : _a.modelId) !== null && _b !== void 0 ? _b : (_c = opts.model) === null || _c === void 0 ? void 0 : _c.model) !== null && _d !== void 0 ? _d : '(unknown)',
92
92
  provider: (_j = (_f = (_e = opts.model) === null || _e === void 0 ? void 0 : _e.provider) !== null && _f !== void 0 ? _f : (_h = (_g = opts.model) === null || _g === void 0 ? void 0 : _g.config) === null || _h === void 0 ? void 0 : _h.provider) !== null && _j !== void 0 ? _j : '(unknown)',
93
- mediaType: opts.mediaType, imageBytes: ((_k = opts.image) !== null && _k !== void 0 ? _k : '').length,
94
- systemLen: ((_l = opts.system) !== null && _l !== void 0 ? _l : '').length, providerOptions: opts.providerOptions,
93
+ mediaType: opts.mediaType, imageBytes: ((_l = opts.image) !== null && _l !== void 0 ? _l : '').length,
94
+ systemLen: ((_m = opts.system) !== null && _m !== void 0 ? _m : '').length, providerOptions: opts.providerOptions,
95
95
  });
96
- const { output, text, usage } = await (0, ai_1.generateText)(Object.assign({ model: opts.model, temperature: (_m = opts.temperature) !== null && _m !== void 0 ? _m : 0, system: opts.system, messages: [{
96
+ const { output, text, usage } = await (0, ai_1.generateText)(Object.assign({ model: opts.model, temperature: (_o = opts.temperature) !== null && _o !== void 0 ? _o : 0, system: opts.system, messages: [{
97
97
  role: 'user',
98
98
  content: [{ type: 'text', text: opts.prompt }, imagePart],
99
99
  }], output: ai_1.Output.object({ schema: opts.schema }) }, (opts.providerOptions ? { providerOptions: opts.providerOptions } : {})));
100
100
  console.log('[generateVision] ok', { hasOutput: output != null, textLen: (text !== null && text !== void 0 ? text : '').length, usage });
101
- return { object: (_o = output) !== null && _o !== void 0 ? _o : null, text: text !== null && text !== void 0 ? text : '', usage };
101
+ return { object: (_p = output) !== null && _p !== void 0 ? _p : null, text: text !== null && text !== void 0 ? text : '', usage };
102
102
  }
103
103
  catch (err) {
104
104
  const e = err;
105
105
  const body = typeof (e === null || e === void 0 ? void 0 : e.responseBody) === 'string' ? e.responseBody : ((e === null || e === void 0 ? void 0 : e.responseBody) ? JSON.stringify(e.responseBody) : undefined);
106
- // TRAZA COMPLETA del fallo de la llamada al LLM (URL, status, cuerpo de respuesta, causa).
106
+ // Serializa el body ENVIADO truncando cadenas largas (el base64 de la imagen) para ver la ESTRUCTURA
107
+ // de content[] (qué campos lleva cada parte) sin volcar megas.
108
+ const trunc = (o) => {
109
+ try {
110
+ return JSON.stringify(o, (_k, v) => (typeof v === 'string' && v.length > 120 ? `${v.slice(0, 60)}…[${v.length} chars]` : v)).slice(0, 4000);
111
+ }
112
+ catch (_a) {
113
+ return String(o);
114
+ }
115
+ };
116
+ // TRAZA COMPLETA del fallo de la llamada al LLM (URL, status, cuerpo de respuesta, causa, request).
107
117
  console.error('[generateVision] FAILED', {
108
118
  name: e === null || e === void 0 ? void 0 : e.name, message: e === null || e === void 0 ? void 0 : e.message, statusCode: e === null || e === void 0 ? void 0 : e.statusCode, url: e === null || e === void 0 ? void 0 : e.url,
109
- responseBody: body, cause: (_q = (_p = e === null || e === void 0 ? void 0 : e.cause) === null || _p === void 0 ? void 0 : _p.message) !== null && _q !== void 0 ? _q : e === null || e === void 0 ? void 0 : e.cause,
110
- requestBody: typeof (e === null || e === void 0 ? void 0 : e.requestBodyValues) === 'object' ? '[requestBodyValues present]' : undefined,
119
+ responseBody: body, cause: (_r = (_q = e === null || e === void 0 ? void 0 : e.cause) === null || _q === void 0 ? void 0 : _q.message) !== null && _r !== void 0 ? _r : e === null || e === void 0 ? void 0 : e.cause,
120
+ requestBody: trunc(e === null || e === void 0 ? void 0 : e.requestBodyValues),
111
121
  });
112
122
  const parts = [e === null || e === void 0 ? void 0 : e.statusCode, e === null || e === void 0 ? void 0 : e.message, e === null || e === void 0 ? void 0 : e.url, body].filter(Boolean).map((x) => String(x));
113
123
  return { object: null, text: '', error: parts.join(' | ') || String(err) };
@@ -115,7 +125,7 @@ const generateVision = async (opts) => {
115
125
  };
116
126
  exports.generateVision = generateVision;
117
127
  const loadModels = async (providers, log) => {
118
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
128
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _l, _m;
119
129
  (_a = log.logInfo) === null || _a === void 0 ? void 0 : _a.call(log, 'Loading AI models...');
120
130
  for (const provider of providers) {
121
131
  try {
@@ -226,10 +236,10 @@ const loadModels = async (providers, log) => {
226
236
  default:
227
237
  (_j = log.logWarning) === null || _j === void 0 ? void 0 : _j.call(log, `Provider '${provider.name}' has unknown type '${type}', will not be available.`);
228
238
  }
229
- (_k = log.logInfo) === null || _k === void 0 ? void 0 : _k.call(log, `Provider '${provider.name}' loaded ${provider.models.length} models`);
239
+ (_l = log.logInfo) === null || _l === void 0 ? void 0 : _l.call(log, `Provider '${provider.name}' loaded ${provider.models.length} models`);
230
240
  }
231
241
  catch (err) {
232
- (_l = log.logError) === null || _l === void 0 ? void 0 : _l.call(log, `Error loading models from provider '${provider.name}': ${err}`);
242
+ (_m = log.logError) === null || _m === void 0 ? void 0 : _m.call(log, `Error loading models from provider '${provider.name}': ${err}`);
233
243
  }
234
244
  }
235
245
  };
@@ -360,7 +370,7 @@ const lastModifiedOf = (meta) => {
360
370
  };
361
371
  // The ConfigMap/Secret references a pod template consumes: envFrom, env.valueFrom, and volumes.
362
372
  const configRefsOfPodSpec = (spec) => {
363
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
373
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _l, _m, _o, _p;
364
374
  const refs = [];
365
375
  const add = (kind, name, via) => { if (name)
366
376
  refs.push({ kind, name, via }); };
@@ -371,12 +381,12 @@ const configRefsOfPodSpec = (spec) => {
371
381
  }
372
382
  for (const e of (_f = ct.env) !== null && _f !== void 0 ? _f : []) {
373
383
  add('ConfigMap', (_h = (_g = e.valueFrom) === null || _g === void 0 ? void 0 : _g.configMapKeyRef) === null || _h === void 0 ? void 0 : _h.name, `env ${e.name}`);
374
- add('Secret', (_k = (_j = e.valueFrom) === null || _j === void 0 ? void 0 : _j.secretKeyRef) === null || _k === void 0 ? void 0 : _k.name, `env ${e.name}`);
384
+ add('Secret', (_l = (_j = e.valueFrom) === null || _j === void 0 ? void 0 : _j.secretKeyRef) === null || _l === void 0 ? void 0 : _l.name, `env ${e.name}`);
375
385
  }
376
386
  }
377
- for (const v of (_l = spec === null || spec === void 0 ? void 0 : spec.volumes) !== null && _l !== void 0 ? _l : []) {
378
- add('ConfigMap', (_m = v.configMap) === null || _m === void 0 ? void 0 : _m.name, `volume ${v.name}`);
379
- add('Secret', (_o = v.secret) === null || _o === void 0 ? void 0 : _o.secretName, `volume ${v.name}`);
387
+ for (const v of (_m = spec === null || spec === void 0 ? void 0 : spec.volumes) !== null && _m !== void 0 ? _m : []) {
388
+ add('ConfigMap', (_o = v.configMap) === null || _o === void 0 ? void 0 : _o.name, `volume ${v.name}`);
389
+ add('Secret', (_p = v.secret) === null || _p === void 0 ? void 0 : _p.secretName, `volume ${v.name}`);
380
390
  }
381
391
  return refs;
382
392
  };
@@ -419,7 +429,7 @@ exports.tools = {
419
429
  ctx().trace('get_cluster_data', {});
420
430
  try {
421
431
  const resp = await ctx().clusterInfo.coreApi.listNode();
422
- return { name: ctx().clusterInfo.name, flavour: ctx().clusterInfo.flavour, vcpus: ctx().clusterInfo.vcpus, memoryGB: Math.round(ctx().clusterInfo.memory / 1024 / 1024 / 1024 * 100) / 100, nodeCount: resp.items.length, nodes: resp.items.map((n) => { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k; return ({ name: (_a = n.metadata) === null || _a === void 0 ? void 0 : _a.name, cpu: (_c = (_b = n.status) === null || _b === void 0 ? void 0 : _b.capacity) === null || _c === void 0 ? void 0 : _c['cpu'], memoryKi: (_e = (_d = n.status) === null || _d === void 0 ? void 0 : _d.capacity) === null || _e === void 0 ? void 0 : _e['memory'], ready: ((_h = (_g = (_f = n.status) === null || _f === void 0 ? void 0 : _f.conditions) === null || _g === void 0 ? void 0 : _g.find((c) => c.type === 'Ready')) === null || _h === void 0 ? void 0 : _h.status) === 'True', unschedulable: (_k = (_j = n.spec) === null || _j === void 0 ? void 0 : _j.unschedulable) !== null && _k !== void 0 ? _k : false }); }) };
432
+ return { name: ctx().clusterInfo.name, flavour: ctx().clusterInfo.flavour, vcpus: ctx().clusterInfo.vcpus, memoryGB: Math.round(ctx().clusterInfo.memory / 1024 / 1024 / 1024 * 100) / 100, nodeCount: resp.items.length, nodes: resp.items.map((n) => { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _l; return ({ name: (_a = n.metadata) === null || _a === void 0 ? void 0 : _a.name, cpu: (_c = (_b = n.status) === null || _b === void 0 ? void 0 : _b.capacity) === null || _c === void 0 ? void 0 : _c['cpu'], memoryKi: (_e = (_d = n.status) === null || _d === void 0 ? void 0 : _d.capacity) === null || _e === void 0 ? void 0 : _e['memory'], ready: ((_h = (_g = (_f = n.status) === null || _f === void 0 ? void 0 : _f.conditions) === null || _g === void 0 ? void 0 : _g.find((c) => c.type === 'Ready')) === null || _h === void 0 ? void 0 : _h.status) === 'True', unschedulable: (_l = (_j = n.spec) === null || _j === void 0 ? void 0 : _j.unschedulable) !== null && _l !== void 0 ? _l : false }); }) };
423
433
  }
424
434
  catch (err) {
425
435
  return { error: (_a = err.message) !== null && _a !== void 0 ? _a : String(err) };
@@ -509,7 +519,7 @@ exports.tools = {
509
519
  : await c.coreApi.listServiceForAllNamespaces();
510
520
  return {
511
521
  services: resp.items.map((x) => {
512
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
522
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _l, _m;
513
523
  return ({
514
524
  name: (_a = x.metadata) === null || _a === void 0 ? void 0 : _a.name,
515
525
  namespace: (_b = x.metadata) === null || _b === void 0 ? void 0 : _b.namespace,
@@ -517,7 +527,7 @@ exports.tools = {
517
527
  clusterIP: (_d = x.spec) === null || _d === void 0 ? void 0 : _d.clusterIP,
518
528
  externalIPs: (_f = (_e = x.spec) === null || _e === void 0 ? void 0 : _e.externalIPs) !== null && _f !== void 0 ? _f : [],
519
529
  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 : [],
520
- selector: (_l = (_k = x.spec) === null || _k === void 0 ? void 0 : _k.selector) !== null && _l !== void 0 ? _l : {}
530
+ selector: (_m = (_l = x.spec) === null || _l === void 0 ? void 0 : _l.selector) !== null && _m !== void 0 ? _m : {}
521
531
  });
522
532
  })
523
533
  };
@@ -541,15 +551,15 @@ exports.tools = {
541
551
  : await c.networkApi.listIngressForAllNamespaces();
542
552
  return {
543
553
  ingresses: resp.items.map((x) => {
544
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
554
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _l, _m, _o, _p, _q, _r;
545
555
  return ({
546
556
  name: (_a = x.metadata) === null || _a === void 0 ? void 0 : _a.name,
547
557
  namespace: (_b = x.metadata) === null || _b === void 0 ? void 0 : _b.namespace,
548
558
  ingressClass: (_c = x.spec) === null || _c === void 0 ? void 0 : _c.ingressClassName,
549
559
  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 : [],
550
560
  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 : [],
551
- 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 : [],
552
- 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 : []
561
+ tls: (_o = (_m = (_l = x.spec) === null || _l === void 0 ? void 0 : _l.tls) === null || _m === void 0 ? void 0 : _m.map((t) => ({ secretName: t.secretName, hosts: t.hosts }))) !== null && _o !== void 0 ? _o : [],
562
+ loadBalancer: (_r = (_q = (_p = x.status) === null || _p === void 0 ? void 0 : _p.loadBalancer) === null || _q === void 0 ? void 0 : _q.ingress) !== null && _r !== void 0 ? _r : []
553
563
  });
554
564
  })
555
565
  };
@@ -598,14 +608,14 @@ exports.tools = {
598
608
  return { error: 'No metrics available yet' };
599
609
  const latest = ctx().clusterMetrics[ctx().clusterMetrics.length - 1];
600
610
  const nodes = nodeName ? latest.nodes.filter((n) => n.name === nodeName) : latest.nodes;
601
- return nodes.map((n) => { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q; return ({ name: n.name, cpuMillicores: Math.round(((_c = (_b = (_a = n.summary) === null || _a === void 0 ? void 0 : _a.cpu) === null || _b === void 0 ? void 0 : _b.usageNanoCores) !== null && _c !== void 0 ? _c : 0) / 1000000), memoryMB: Math.round(((_f = (_e = (_d = n.summary) === null || _d === void 0 ? void 0 : _d.memory) === null || _e === void 0 ? void 0 : _e.workingSetBytes) !== null && _f !== void 0 ? _f : 0) / 1024 / 1024), networkRxMB: Math.round(((_j = (_h = (_g = n.summary) === null || _g === void 0 ? void 0 : _g.network) === null || _h === void 0 ? void 0 : _h.rxBytes) !== null && _j !== void 0 ? _j : 0) / 1024 / 1024), networkTxMB: Math.round(((_m = (_l = (_k = n.summary) === null || _k === void 0 ? void 0 : _k.network) === null || _l === void 0 ? void 0 : _l.txBytes) !== null && _m !== void 0 ? _m : 0) / 1024 / 1024), podCount: (_q = (_p = (_o = n.summary) === null || _o === void 0 ? void 0 : _o.pods) === null || _p === void 0 ? void 0 : _p.length) !== null && _q !== void 0 ? _q : 0, timestamp: n.timestamp }); });
611
+ return nodes.map((n) => { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _l, _m, _o, _p, _q, _r; return ({ name: n.name, cpuMillicores: Math.round(((_c = (_b = (_a = n.summary) === null || _a === void 0 ? void 0 : _a.cpu) === null || _b === void 0 ? void 0 : _b.usageNanoCores) !== null && _c !== void 0 ? _c : 0) / 1000000), memoryMB: Math.round(((_f = (_e = (_d = n.summary) === null || _d === void 0 ? void 0 : _d.memory) === null || _e === void 0 ? void 0 : _e.workingSetBytes) !== null && _f !== void 0 ? _f : 0) / 1024 / 1024), networkRxMB: Math.round(((_j = (_h = (_g = n.summary) === null || _g === void 0 ? void 0 : _g.network) === null || _h === void 0 ? void 0 : _h.rxBytes) !== null && _j !== void 0 ? _j : 0) / 1024 / 1024), networkTxMB: Math.round(((_o = (_m = (_l = n.summary) === null || _l === void 0 ? void 0 : _l.network) === null || _m === void 0 ? void 0 : _m.txBytes) !== null && _o !== void 0 ? _o : 0) / 1024 / 1024), podCount: (_r = (_q = (_p = n.summary) === null || _p === void 0 ? void 0 : _p.pods) === null || _q === void 0 ? void 0 : _q.length) !== null && _r !== void 0 ? _r : 0, timestamp: n.timestamp }); });
602
612
  }
603
613
  }),
604
614
  get_deployment_usage: (0, ai_1.tool)({
605
615
  description: 'Returns current aggregated CPU and memory usage for all pods belonging to a specific deployment.',
606
616
  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') }),
607
617
  execute: async ({ namespace, name }) => {
608
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
618
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _l, _m, _o, _p;
609
619
  ctx().trace('get_deployment_usage', { namespace, name });
610
620
  try {
611
621
  if (ctx().clusterMetrics.length === 0)
@@ -621,13 +631,13 @@ exports.tools = {
621
631
  for (const pod of ((_e = (_d = node.summary) === null || _d === void 0 ? void 0 : _d.pods) !== null && _e !== void 0 ? _e : []))
622
632
  if (((_f = pod.podRef) === null || _f === void 0 ? void 0 : _f.namespace) === namespace && podNames.has((_g = pod.podRef) === null || _g === void 0 ? void 0 : _g.name)) {
623
633
  totalCpu += (_j = (_h = pod.cpu) === null || _h === void 0 ? void 0 : _h.usageNanoCores) !== null && _j !== void 0 ? _j : 0;
624
- totalMem += (_l = (_k = pod.memory) === null || _k === void 0 ? void 0 : _k.workingSetBytes) !== null && _l !== void 0 ? _l : 0;
634
+ totalMem += (_m = (_l = pod.memory) === null || _l === void 0 ? void 0 : _l.workingSetBytes) !== null && _m !== void 0 ? _m : 0;
625
635
  podCount++;
626
636
  }
627
- return { deployment: name, namespace, podCount, cpuMillicores: Math.round(totalCpu / 1000000), memoryMB: Math.round(totalMem / 1024 / 1024), timestamp: (_m = latest.nodes[0]) === null || _m === void 0 ? void 0 : _m.timestamp };
637
+ return { deployment: name, namespace, podCount, cpuMillicores: Math.round(totalCpu / 1000000), memoryMB: Math.round(totalMem / 1024 / 1024), timestamp: (_o = latest.nodes[0]) === null || _o === void 0 ? void 0 : _o.timestamp };
628
638
  }
629
639
  catch (err) {
630
- return { error: (_o = err.message) !== null && _o !== void 0 ? _o : String(err) };
640
+ return { error: (_p = err.message) !== null && _p !== void 0 ? _p : String(err) };
631
641
  }
632
642
  }
633
643
  }),
@@ -973,7 +983,7 @@ exports.tools = {
973
983
  name: zod_1.z.string().describe('Name of the pod')
974
984
  }),
975
985
  execute: async ({ namespace, name }) => {
976
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
986
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _l, _m, _o, _p, _q, _r;
977
987
  ctx().trace('describe_pod', { namespace, name });
978
988
  try {
979
989
  const c = ctx().clusterInfo;
@@ -1000,7 +1010,7 @@ exports.tools = {
1000
1010
  const rsOwner = ((_f = (_e = rs.metadata) === null || _e === void 0 ? void 0 : _e.ownerReferences) !== null && _f !== void 0 ? _f : [])[0];
1001
1011
  controlledBy = rsOwner ? { kind: rsOwner.kind, name: rsOwner.name } : { kind: 'ReplicaSet', name: podOwner.name };
1002
1012
  }
1003
- catch (_r) {
1013
+ catch (_s) {
1004
1014
  controlledBy = { kind: 'ReplicaSet', name: podOwner.name };
1005
1015
  }
1006
1016
  }
@@ -1011,19 +1021,19 @@ exports.tools = {
1011
1021
  // the repo + commit the image was built from, so the bot can read the actual source (get_source_file).
1012
1022
  const ann = (_h = (_g = pod.metadata) === null || _g === void 0 ? void 0 : _g.annotations) !== null && _h !== void 0 ? _h : {};
1013
1023
  const sourceRepo = (_j = ann['org.opencontainers.image.source']) !== null && _j !== void 0 ? _j : ann['kwirth.io/source-repo'];
1014
- const source = sourceRepo ? { repo: sourceRepo, revision: (_k = ann['org.opencontainers.image.revision']) !== null && _k !== void 0 ? _k : ann['kwirth.io/source-ref'] } : undefined;
1024
+ const source = sourceRepo ? { repo: sourceRepo, revision: (_l = ann['org.opencontainers.image.revision']) !== null && _l !== void 0 ? _l : ann['kwirth.io/source-ref'] } : undefined;
1015
1025
  return {
1016
1026
  name, namespace, phase: status.phase, node: spec.nodeName, startTime: status.startTime, reason: status.reason, message: status.message,
1017
1027
  controlledBy, // e.g. { kind: 'Deployment', name: 'montag-agent' } → feed to get_rollout_history
1018
1028
  source, // { repo, revision } from image annotations → feed to get_source_file
1019
- conditions: ((_l = status.conditions) !== null && _l !== void 0 ? _l : []).map((c) => ({ type: c.type, status: c.status, reason: c.reason })),
1020
- containers: ((_m = status.containerStatuses) !== null && _m !== void 0 ? _m : []).map(containerStatus),
1021
- initContainers: ((_o = status.initContainerStatuses) !== null && _o !== void 0 ? _o : []).map(containerStatus),
1022
- spec: { containers: ((_p = spec.containers) !== null && _p !== void 0 ? _p : []).map(specContainer), restartPolicy: spec.restartPolicy }
1029
+ conditions: ((_m = status.conditions) !== null && _m !== void 0 ? _m : []).map((c) => ({ type: c.type, status: c.status, reason: c.reason })),
1030
+ containers: ((_o = status.containerStatuses) !== null && _o !== void 0 ? _o : []).map(containerStatus),
1031
+ initContainers: ((_p = status.initContainerStatuses) !== null && _p !== void 0 ? _p : []).map(containerStatus),
1032
+ spec: { containers: ((_q = spec.containers) !== null && _q !== void 0 ? _q : []).map(specContainer), restartPolicy: spec.restartPolicy }
1023
1033
  };
1024
1034
  }
1025
1035
  catch (err) {
1026
- return { error: (_q = err.message) !== null && _q !== void 0 ? _q : String(err) };
1036
+ return { error: (_r = err.message) !== null && _r !== void 0 ? _r : String(err) };
1027
1037
  }
1028
1038
  }
1029
1039
  }),
@@ -1084,15 +1094,15 @@ exports.tools = {
1084
1094
  };
1085
1095
  const container = (ct) => { var _a; return ({ name: ct.name, image: ct.image, command: ct.command, args: ct.args, resources: ct.resources, env: ((_a = ct.env) !== null && _a !== void 0 ? _a : []).map((e) => ({ name: e.name, value: e.value, from: envSource(e) })) }); };
1086
1096
  const revisions = owned.map((rs) => {
1087
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
1097
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _l, _m, _o, _p;
1088
1098
  const tmpl = (_c = (_b = (_a = rs.spec) === null || _a === void 0 ? void 0 : _a.template) === null || _b === void 0 ? void 0 : _b.spec) !== null && _c !== void 0 ? _c : {};
1089
1099
  return {
1090
1100
  revision: Number((_f = (_e = (_d = rs.metadata) === null || _d === void 0 ? void 0 : _d.annotations) === null || _e === void 0 ? void 0 : _e['deployment.kubernetes.io/revision']) !== null && _f !== void 0 ? _f : 0),
1091
1101
  replicaSet: (_g = rs.metadata) === null || _g === void 0 ? void 0 : _g.name,
1092
1102
  createdAt: (_h = rs.metadata) === null || _h === void 0 ? void 0 : _h.creationTimestamp,
1093
- replicas: (_k = (_j = rs.spec) === null || _j === void 0 ? void 0 : _j.replicas) !== null && _k !== void 0 ? _k : 0,
1094
- readyReplicas: (_m = (_l = rs.status) === null || _l === void 0 ? void 0 : _l.readyReplicas) !== null && _m !== void 0 ? _m : 0,
1095
- containers: ((_o = tmpl.containers) !== null && _o !== void 0 ? _o : []).map(container),
1103
+ replicas: (_l = (_j = rs.spec) === null || _j === void 0 ? void 0 : _j.replicas) !== null && _l !== void 0 ? _l : 0,
1104
+ readyReplicas: (_o = (_m = rs.status) === null || _m === void 0 ? void 0 : _m.readyReplicas) !== null && _o !== void 0 ? _o : 0,
1105
+ containers: ((_p = tmpl.containers) !== null && _p !== void 0 ? _p : []).map(container),
1096
1106
  serviceAccount: tmpl.serviceAccountName,
1097
1107
  securityContext: tmpl.securityContext
1098
1108
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kwirthmagnify/kwirth-common-ai",
3
- "version": "0.5.40",
3
+ "version": "0.5.41",
4
4
  "description": "Shared AI/LLM types and utilities for Kwirth AI plugins",
5
5
  "scripts": {
6
6
  "build": "del .\\dist\\* /s /q 2>nul & tsc",