@kwirthmagnify/kwirth-common-ai 0.5.57 → 0.5.59
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 +89 -46
- package/dist/back.js +11 -5
- package/package.json +1 -1
package/dist/back.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ interface ILogChannel {
|
|
|
5
5
|
logWarning?: (msg: string) => void;
|
|
6
6
|
logError?: (msg: string) => void;
|
|
7
7
|
}
|
|
8
|
-
import { LanguageModel, ToolSet } from 'ai';
|
|
8
|
+
import { LanguageModel, Tool, ToolSet } from 'ai';
|
|
9
9
|
import { z } from 'zod';
|
|
10
10
|
export declare const buildModel: (llm: ILlm, providers: ILlmProvider[]) => LanguageModel | null;
|
|
11
11
|
export interface IVisionResult<T> {
|
|
@@ -74,10 +74,53 @@ export interface IK8sCapability {
|
|
|
74
74
|
appsApi: AppsV1Api;
|
|
75
75
|
networkApi: NetworkingV1Api;
|
|
76
76
|
}
|
|
77
|
+
export interface IMetricsPodSample {
|
|
78
|
+
podRef?: {
|
|
79
|
+
name?: string;
|
|
80
|
+
namespace?: string;
|
|
81
|
+
};
|
|
82
|
+
cpu?: {
|
|
83
|
+
usageNanoCores?: number;
|
|
84
|
+
};
|
|
85
|
+
memory?: {
|
|
86
|
+
workingSetBytes?: number;
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
export interface IMetricsNodeSample {
|
|
90
|
+
name?: string;
|
|
91
|
+
timestamp?: number;
|
|
92
|
+
summary?: {
|
|
93
|
+
cpu?: {
|
|
94
|
+
usageNanoCores?: number;
|
|
95
|
+
};
|
|
96
|
+
memory?: {
|
|
97
|
+
workingSetBytes?: number;
|
|
98
|
+
};
|
|
99
|
+
network?: {
|
|
100
|
+
rxBytes?: number;
|
|
101
|
+
txBytes?: number;
|
|
102
|
+
};
|
|
103
|
+
pods?: IMetricsPodSample[];
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
export interface IMetricsSample {
|
|
107
|
+
/** Segundos entre lecturas. Sin esto, una serie de numeros no dice a que ritmo pasa el tiempo. */
|
|
108
|
+
metricsInterval?: number;
|
|
109
|
+
cluster: {
|
|
110
|
+
vcpus: number;
|
|
111
|
+
memory: number;
|
|
112
|
+
/** Porcentajes, 0-100. */
|
|
113
|
+
cpuUsage: number;
|
|
114
|
+
memoryUsage: number;
|
|
115
|
+
txmbps: number;
|
|
116
|
+
rxmbps: number;
|
|
117
|
+
};
|
|
118
|
+
nodes: IMetricsNodeSample[];
|
|
119
|
+
}
|
|
77
120
|
/** Metricas del cluster (`ECapability.METRICS`). */
|
|
78
121
|
export interface IMetricsCapability {
|
|
79
|
-
/** Muestras
|
|
80
|
-
samples:
|
|
122
|
+
/** Muestras que el core mantiene en memoria. La mas reciente, al final. */
|
|
123
|
+
samples: IMetricsSample[];
|
|
81
124
|
}
|
|
82
125
|
/**
|
|
83
126
|
* Un elemento del buffer de eventos del core: el tipo de cambio y el objeto tal y como vino de la API.
|
|
@@ -232,15 +275,15 @@ export interface IAgentToolHooks {
|
|
|
232
275
|
*/
|
|
233
276
|
export declare const buildAgentTools: (config: IToolsetConfig, context: IToolContext, hooks?: IAgentToolHooks) => ToolSet;
|
|
234
277
|
export declare const tools: {
|
|
235
|
-
readonly list_namespaces:
|
|
278
|
+
readonly list_namespaces: Tool<Record<string, never>, {
|
|
236
279
|
namespaces: any;
|
|
237
280
|
error?: undefined;
|
|
238
281
|
} | {
|
|
239
282
|
error: any;
|
|
240
283
|
namespaces?: undefined;
|
|
241
284
|
}>;
|
|
242
|
-
readonly get_node_data:
|
|
243
|
-
readonly get_cluster_data:
|
|
285
|
+
readonly get_node_data: Tool<Record<string, never>, any>;
|
|
286
|
+
readonly get_cluster_data: Tool<Record<string, never>, {
|
|
244
287
|
name: any;
|
|
245
288
|
flavour: any;
|
|
246
289
|
vcpus: any;
|
|
@@ -257,7 +300,7 @@ export declare const tools: {
|
|
|
257
300
|
nodeCount?: undefined;
|
|
258
301
|
nodes?: undefined;
|
|
259
302
|
}>;
|
|
260
|
-
readonly get_workload_data:
|
|
303
|
+
readonly get_workload_data: Tool<{
|
|
261
304
|
namespace?: string | undefined;
|
|
262
305
|
}, {
|
|
263
306
|
deployments: any;
|
|
@@ -274,7 +317,7 @@ export declare const tools: {
|
|
|
274
317
|
pods?: undefined;
|
|
275
318
|
services?: undefined;
|
|
276
319
|
}>;
|
|
277
|
-
readonly get_space_data:
|
|
320
|
+
readonly get_space_data: Tool<{
|
|
278
321
|
namespace: string;
|
|
279
322
|
}, {
|
|
280
323
|
namespace: string;
|
|
@@ -299,10 +342,10 @@ export declare const tools: {
|
|
|
299
342
|
services?: undefined;
|
|
300
343
|
configMaps?: undefined;
|
|
301
344
|
}>;
|
|
302
|
-
readonly get_namespace_yaml:
|
|
345
|
+
readonly get_namespace_yaml: Tool<{
|
|
303
346
|
name: string;
|
|
304
347
|
}, any>;
|
|
305
|
-
readonly describe_service:
|
|
348
|
+
readonly describe_service: Tool<{
|
|
306
349
|
namespace: string;
|
|
307
350
|
name: string;
|
|
308
351
|
}, {
|
|
@@ -332,7 +375,7 @@ export declare const tools: {
|
|
|
332
375
|
endpoints?: undefined;
|
|
333
376
|
endpointCount?: undefined;
|
|
334
377
|
}>;
|
|
335
|
-
readonly describe_ingress:
|
|
378
|
+
readonly describe_ingress: Tool<{
|
|
336
379
|
namespace: string;
|
|
337
380
|
name: string;
|
|
338
381
|
}, {
|
|
@@ -354,7 +397,7 @@ export declare const tools: {
|
|
|
354
397
|
tls?: undefined;
|
|
355
398
|
loadBalancer?: undefined;
|
|
356
399
|
}>;
|
|
357
|
-
readonly describe_controller:
|
|
400
|
+
readonly describe_controller: Tool<{
|
|
358
401
|
namespace: string;
|
|
359
402
|
kind: "Deployment" | "StatefulSet" | "DaemonSet" | "ReplicaSet";
|
|
360
403
|
name: string;
|
|
@@ -395,11 +438,11 @@ export declare const tools: {
|
|
|
395
438
|
selector?: undefined;
|
|
396
439
|
template?: undefined;
|
|
397
440
|
}>;
|
|
398
|
-
readonly get_service_yaml:
|
|
441
|
+
readonly get_service_yaml: Tool<{
|
|
399
442
|
namespace: string;
|
|
400
443
|
name: string;
|
|
401
444
|
}, any>;
|
|
402
|
-
readonly list_services:
|
|
445
|
+
readonly list_services: Tool<{
|
|
403
446
|
namespace?: string | undefined;
|
|
404
447
|
}, {
|
|
405
448
|
services: any;
|
|
@@ -408,7 +451,7 @@ export declare const tools: {
|
|
|
408
451
|
error: any;
|
|
409
452
|
services?: undefined;
|
|
410
453
|
}>;
|
|
411
|
-
readonly list_ingresses:
|
|
454
|
+
readonly list_ingresses: Tool<{
|
|
412
455
|
namespace?: string | undefined;
|
|
413
456
|
}, {
|
|
414
457
|
ingresses: any;
|
|
@@ -417,11 +460,11 @@ export declare const tools: {
|
|
|
417
460
|
error: any;
|
|
418
461
|
ingresses?: undefined;
|
|
419
462
|
}>;
|
|
420
|
-
readonly get_ingress_yaml:
|
|
463
|
+
readonly get_ingress_yaml: Tool<{
|
|
421
464
|
namespace: string;
|
|
422
465
|
name: string;
|
|
423
466
|
}, any>;
|
|
424
|
-
readonly get_cluster_usage:
|
|
467
|
+
readonly get_cluster_usage: Tool<Record<string, never>, {
|
|
425
468
|
error: string;
|
|
426
469
|
vcpus?: undefined;
|
|
427
470
|
memoryGB?: undefined;
|
|
@@ -440,10 +483,10 @@ export declare const tools: {
|
|
|
440
483
|
metricsIntervalSeconds: any;
|
|
441
484
|
error?: undefined;
|
|
442
485
|
}>;
|
|
443
|
-
readonly get_node_usage:
|
|
486
|
+
readonly get_node_usage: Tool<{
|
|
444
487
|
nodeName?: string | undefined;
|
|
445
488
|
}, any>;
|
|
446
|
-
readonly get_deployment_usage:
|
|
489
|
+
readonly get_deployment_usage: Tool<{
|
|
447
490
|
namespace: string;
|
|
448
491
|
name: string;
|
|
449
492
|
}, {
|
|
@@ -463,7 +506,7 @@ export declare const tools: {
|
|
|
463
506
|
memoryMB?: undefined;
|
|
464
507
|
timestamp?: undefined;
|
|
465
508
|
}>;
|
|
466
|
-
readonly get_prev_cluster_usage:
|
|
509
|
+
readonly get_prev_cluster_usage: Tool<{
|
|
467
510
|
count?: number | undefined;
|
|
468
511
|
}, {
|
|
469
512
|
vcpus: any;
|
|
@@ -475,7 +518,7 @@ export declare const tools: {
|
|
|
475
518
|
}[] | {
|
|
476
519
|
error: string;
|
|
477
520
|
}>;
|
|
478
|
-
readonly get_prev_node_usage:
|
|
521
|
+
readonly get_prev_node_usage: Tool<{
|
|
479
522
|
nodeName?: string | undefined;
|
|
480
523
|
count?: number | undefined;
|
|
481
524
|
}, {
|
|
@@ -483,7 +526,7 @@ export declare const tools: {
|
|
|
483
526
|
}[] | {
|
|
484
527
|
error: string;
|
|
485
528
|
}>;
|
|
486
|
-
readonly get_prev_deployment_usage:
|
|
529
|
+
readonly get_prev_deployment_usage: Tool<{
|
|
487
530
|
namespace: string;
|
|
488
531
|
name: string;
|
|
489
532
|
count?: number | undefined;
|
|
@@ -497,7 +540,7 @@ export declare const tools: {
|
|
|
497
540
|
}[] | {
|
|
498
541
|
error: any;
|
|
499
542
|
}>;
|
|
500
|
-
readonly get_prev_space_data:
|
|
543
|
+
readonly get_prev_space_data: Tool<{
|
|
501
544
|
namespace: string;
|
|
502
545
|
count?: number | undefined;
|
|
503
546
|
}, {
|
|
@@ -509,7 +552,7 @@ export declare const tools: {
|
|
|
509
552
|
}[] | {
|
|
510
553
|
error: string;
|
|
511
554
|
}>;
|
|
512
|
-
readonly add_node:
|
|
555
|
+
readonly add_node: Tool<{
|
|
513
556
|
nodeName?: string | undefined;
|
|
514
557
|
nodePoolName?: string | undefined;
|
|
515
558
|
}, {
|
|
@@ -531,7 +574,7 @@ export declare const tools: {
|
|
|
531
574
|
stderr?: undefined;
|
|
532
575
|
error?: undefined;
|
|
533
576
|
}>;
|
|
534
|
-
readonly remove_node:
|
|
577
|
+
readonly remove_node: Tool<{
|
|
535
578
|
nodeName: string;
|
|
536
579
|
nodePoolName?: string | undefined;
|
|
537
580
|
}, {
|
|
@@ -553,7 +596,7 @@ export declare const tools: {
|
|
|
553
596
|
stderr?: undefined;
|
|
554
597
|
error?: undefined;
|
|
555
598
|
}>;
|
|
556
|
-
readonly stop_node:
|
|
599
|
+
readonly stop_node: Tool<{
|
|
557
600
|
nodeName: string;
|
|
558
601
|
}, {
|
|
559
602
|
success: boolean;
|
|
@@ -574,7 +617,7 @@ export declare const tools: {
|
|
|
574
617
|
stderr: string;
|
|
575
618
|
error?: undefined;
|
|
576
619
|
}>;
|
|
577
|
-
readonly start_node:
|
|
620
|
+
readonly start_node: Tool<{
|
|
578
621
|
nodeName: string;
|
|
579
622
|
}, {
|
|
580
623
|
success: boolean;
|
|
@@ -595,7 +638,7 @@ export declare const tools: {
|
|
|
595
638
|
stderr?: undefined;
|
|
596
639
|
error?: undefined;
|
|
597
640
|
}>;
|
|
598
|
-
readonly add_replica:
|
|
641
|
+
readonly add_replica: Tool<{
|
|
599
642
|
namespace: string;
|
|
600
643
|
name: string;
|
|
601
644
|
}, {
|
|
@@ -607,7 +650,7 @@ export declare const tools: {
|
|
|
607
650
|
error: any;
|
|
608
651
|
message?: undefined;
|
|
609
652
|
}>;
|
|
610
|
-
readonly remove_replica:
|
|
653
|
+
readonly remove_replica: Tool<{
|
|
611
654
|
namespace: string;
|
|
612
655
|
name: string;
|
|
613
656
|
}, {
|
|
@@ -619,7 +662,7 @@ export declare const tools: {
|
|
|
619
662
|
error: any;
|
|
620
663
|
message?: undefined;
|
|
621
664
|
}>;
|
|
622
|
-
readonly restart_deployment:
|
|
665
|
+
readonly restart_deployment: Tool<{
|
|
623
666
|
namespace: string;
|
|
624
667
|
name: string;
|
|
625
668
|
}, {
|
|
@@ -631,7 +674,7 @@ export declare const tools: {
|
|
|
631
674
|
error: any;
|
|
632
675
|
message?: undefined;
|
|
633
676
|
}>;
|
|
634
|
-
readonly delete_pod:
|
|
677
|
+
readonly delete_pod: Tool<{
|
|
635
678
|
namespace: string;
|
|
636
679
|
name: string;
|
|
637
680
|
}, {
|
|
@@ -643,17 +686,17 @@ export declare const tools: {
|
|
|
643
686
|
error: any;
|
|
644
687
|
message?: undefined;
|
|
645
688
|
}>;
|
|
646
|
-
readonly times_two:
|
|
689
|
+
readonly times_two: Tool<{
|
|
647
690
|
data: number;
|
|
648
691
|
}, number>;
|
|
649
|
-
readonly father_of:
|
|
692
|
+
readonly father_of: Tool<{
|
|
650
693
|
data: string;
|
|
651
694
|
}, string>;
|
|
652
|
-
readonly get_certificate_info:
|
|
695
|
+
readonly get_certificate_info: Tool<{
|
|
653
696
|
hostname: string;
|
|
654
697
|
port?: number | undefined;
|
|
655
698
|
}, unknown>;
|
|
656
|
-
readonly get_cluster_events:
|
|
699
|
+
readonly get_cluster_events: Tool<{
|
|
657
700
|
warningsOnly?: boolean | undefined;
|
|
658
701
|
namespace?: string | undefined;
|
|
659
702
|
limit?: number | undefined;
|
|
@@ -661,14 +704,14 @@ export declare const tools: {
|
|
|
661
704
|
count: number;
|
|
662
705
|
events: Record<string, unknown>[];
|
|
663
706
|
}>;
|
|
664
|
-
readonly get_object_events:
|
|
707
|
+
readonly get_object_events: Tool<{
|
|
665
708
|
namespace: string;
|
|
666
709
|
name: string;
|
|
667
710
|
}, {
|
|
668
711
|
count: number;
|
|
669
712
|
events: Record<string, unknown>[];
|
|
670
713
|
}>;
|
|
671
|
-
readonly get_pod_logs:
|
|
714
|
+
readonly get_pod_logs: Tool<{
|
|
672
715
|
namespace: string;
|
|
673
716
|
name: string;
|
|
674
717
|
container?: string | undefined;
|
|
@@ -691,7 +734,7 @@ export declare const tools: {
|
|
|
691
734
|
truncated?: undefined;
|
|
692
735
|
logs?: undefined;
|
|
693
736
|
}>;
|
|
694
|
-
readonly describe_pod:
|
|
737
|
+
readonly describe_pod: Tool<{
|
|
695
738
|
namespace: string;
|
|
696
739
|
name: string;
|
|
697
740
|
}, {
|
|
@@ -731,20 +774,20 @@ export declare const tools: {
|
|
|
731
774
|
initContainers?: undefined;
|
|
732
775
|
spec?: undefined;
|
|
733
776
|
}>;
|
|
734
|
-
readonly get_pod_yaml:
|
|
777
|
+
readonly get_pod_yaml: Tool<{
|
|
735
778
|
namespace: string;
|
|
736
779
|
name: string;
|
|
737
780
|
}, any>;
|
|
738
|
-
readonly get_deployment_yaml:
|
|
781
|
+
readonly get_deployment_yaml: Tool<{
|
|
739
782
|
namespace: string;
|
|
740
783
|
name: string;
|
|
741
784
|
}, any>;
|
|
742
|
-
readonly get_controller_yaml:
|
|
785
|
+
readonly get_controller_yaml: Tool<{
|
|
743
786
|
namespace: string;
|
|
744
787
|
kind: "Deployment" | "StatefulSet" | "DaemonSet" | "ReplicaSet";
|
|
745
788
|
name: string;
|
|
746
789
|
}, any>;
|
|
747
|
-
readonly get_rollout_history:
|
|
790
|
+
readonly get_rollout_history: Tool<{
|
|
748
791
|
namespace: string;
|
|
749
792
|
name: string;
|
|
750
793
|
}, {
|
|
@@ -760,7 +803,7 @@ export declare const tools: {
|
|
|
760
803
|
revisionCount?: undefined;
|
|
761
804
|
revisions?: undefined;
|
|
762
805
|
}>;
|
|
763
|
-
readonly get_configmap:
|
|
806
|
+
readonly get_configmap: Tool<{
|
|
764
807
|
namespace: string;
|
|
765
808
|
name: string;
|
|
766
809
|
}, {
|
|
@@ -780,7 +823,7 @@ export declare const tools: {
|
|
|
780
823
|
data?: undefined;
|
|
781
824
|
binaryDataKeys?: undefined;
|
|
782
825
|
}>;
|
|
783
|
-
readonly get_secret:
|
|
826
|
+
readonly get_secret: Tool<{
|
|
784
827
|
namespace: string;
|
|
785
828
|
name: string;
|
|
786
829
|
}, {
|
|
@@ -800,7 +843,7 @@ export declare const tools: {
|
|
|
800
843
|
lastModified?: undefined;
|
|
801
844
|
keys?: undefined;
|
|
802
845
|
}>;
|
|
803
|
-
readonly get_workload_config_refs:
|
|
846
|
+
readonly get_workload_config_refs: Tool<{
|
|
804
847
|
namespace: string;
|
|
805
848
|
name: string;
|
|
806
849
|
}, {
|
|
@@ -825,7 +868,7 @@ export declare const tools: {
|
|
|
825
868
|
namespace?: undefined;
|
|
826
869
|
refs?: undefined;
|
|
827
870
|
}>;
|
|
828
|
-
readonly get_source_file:
|
|
871
|
+
readonly get_source_file: Tool<{
|
|
829
872
|
repo: string;
|
|
830
873
|
ref: string;
|
|
831
874
|
path: string;
|
package/dist/back.js
CHANGED
|
@@ -469,7 +469,7 @@ const buildToolHost = (requires, context) => {
|
|
|
469
469
|
};
|
|
470
470
|
}
|
|
471
471
|
if (requires.includes(index_1.ECapability.METRICS))
|
|
472
|
-
host.metrics = { samples: (_a = context.clusterMetrics) !== null && _a !== void 0 ? _a : [] };
|
|
472
|
+
host.metrics = { samples: ((_a = context.clusterMetrics) !== null && _a !== void 0 ? _a : []) };
|
|
473
473
|
if (requires.includes(index_1.ECapability.EVENTS))
|
|
474
474
|
host.events = { recent: ((_b = context.clusterEvents) !== null && _b !== void 0 ? _b : []) };
|
|
475
475
|
if (requires.includes(index_1.ECapability.REPOS))
|
|
@@ -543,9 +543,15 @@ const buildAgentTools = (config, context, hooks = {}) => {
|
|
|
543
543
|
const { effective } = (0, exports.resolveTools)(config);
|
|
544
544
|
const entries = effective.map(e => {
|
|
545
545
|
const invocationOf = (args) => ({ ref: e.ref, toolsetId: e.toolsetId, toolName: e.name, args });
|
|
546
|
-
//
|
|
547
|
-
//
|
|
548
|
-
|
|
546
|
+
// ⚠️ Un objeto PLANO, no `dynamicTool`. Parece equivalente y no lo es:
|
|
547
|
+
// tool(t) => t (solo ayuda de tipos, no toca nada)
|
|
548
|
+
// dynamicTool(t) => { ...t, type: 'dynamic' } (marca la tool en RUNTIME)
|
|
549
|
+
// Una tool marcada como dinamica la trata el SDK por otro camino, y con `Output.object` la
|
|
550
|
+
// ejecucion acaba en AI_NoOutputGeneratedError: la tool corre, devuelve, y la respuesta
|
|
551
|
+
// estructurada no se genera. Se uso `dynamicTool` para esquivar una friccion de tipos —el helper
|
|
552
|
+
// `tool()` infiere `never` con un ZodTypeAny generico— y el precio fue cambiar el comportamiento.
|
|
553
|
+
// El casteo es la forma honesta: lo que el SDK necesita es exactamente este objeto.
|
|
554
|
+
return [e.name, {
|
|
549
555
|
description: e.tool.description,
|
|
550
556
|
inputSchema: e.tool.inputSchema,
|
|
551
557
|
execute: async (rawArgs) => {
|
|
@@ -576,7 +582,7 @@ const buildAgentTools = (config, context, hooks = {}) => {
|
|
|
576
582
|
return { error: message };
|
|
577
583
|
}
|
|
578
584
|
}
|
|
579
|
-
}
|
|
585
|
+
}];
|
|
580
586
|
});
|
|
581
587
|
return Object.fromEntries(entries);
|
|
582
588
|
};
|