@kwirthmagnify/kwirth-common-ai 0.5.55 → 0.5.57

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 CHANGED
@@ -1,4 +1,4 @@
1
- import { ILlm, ILlmProvider, IAgent, ECapability, EToolEffect, IAiToolInfo, IAiToolsetInfo, IToolsetConfig } from './index';
1
+ import { ILlm, ILlmProvider, IAgent, ECapability, EToolEffect, EToolSensitivity, IAiToolInfo, IAiToolsetInfo, IToolsetConfig } from './index';
2
2
  import type { AppsV1Api, CoreV1Api, NetworkingV1Api } from '@kubernetes/client-node';
3
3
  interface ILogChannel {
4
4
  logInfo?: (msg: string) => void;
@@ -79,10 +79,20 @@ export interface IMetricsCapability {
79
79
  /** Muestras de metricas que el core mantiene en memoria. */
80
80
  samples: unknown[];
81
81
  }
82
+ /**
83
+ * Un elemento del buffer de eventos del core: el tipo de cambio y el objeto tal y como vino de la API.
84
+ * `obj` se deja generico a proposito —ahi caben Events de kube y objetos de cualquier kind— pero tipado
85
+ * como objeto, no como `any`: quien lo lea tiene que mirar el `kind` antes de creerse nada.
86
+ */
87
+ export interface IClusterEvent {
88
+ /** ADDED | MODIFIED | DELETED para cambios de objeto; los Event de kube tambien viajan aqui. */
89
+ type?: string;
90
+ obj?: Record<string, any>;
91
+ }
82
92
  /** Eventos recientes del cluster (`ECapability.EVENTS`). */
83
93
  export interface IEventsCapability {
84
- /** Buffer de eventos ({type, obj}) que el core va acumulando. */
85
- recent: unknown[];
94
+ /** Buffer que el core va acumulando. El mas reciente, al final. */
95
+ recent: IClusterEvent[];
86
96
  }
87
97
  /** Credenciales de repositorios fuente (`ECapability.REPOS`). */
88
98
  export interface IReposCapability {
@@ -109,6 +119,24 @@ export interface IAiTool extends IAiToolInfo {
109
119
  export interface IAiToolset extends Omit<IAiToolsetInfo, 'tools'> {
110
120
  tools: IAiTool[];
111
121
  }
122
+ /**
123
+ * Declara una tool infiriendo el tipo de sus argumentos DESDE su propio `inputSchema`.
124
+ *
125
+ * Sin esto, `execute` recibe `Record<string, unknown>` y cada tool acaba llena de `String(args.namespace)`
126
+ * y castings sueltos: treinta tools asi son treinta sitios donde equivocarse en silencio, y el compilador
127
+ * no puede ayudar. Con esto, el esquema es la unica fuente de verdad y `args` viene tipado.
128
+ *
129
+ * El registro sigue guardando el tipo suelto (`IAiTool`): quien lo invoca no conoce el esquema, y ahi la
130
+ * comprobacion la hace zod en tiempo de ejecucion, como debe ser.
131
+ */
132
+ export declare const defineTool: <S extends z.ZodTypeAny>(definition: {
133
+ name: string;
134
+ description: string;
135
+ effect: EToolEffect;
136
+ sensitivity: EToolSensitivity;
137
+ inputSchema: S;
138
+ execute: (args: z.infer<S>, host: IToolHost) => Promise<unknown>;
139
+ }) => IAiTool;
112
140
  export declare const isBuiltInToolsetId: (id: string) => boolean;
113
141
  /**
114
142
  * Registra un toolset. `builtIn` solo lo usa el core para los suyos: marca el id como reservado.
package/dist/back.js CHANGED
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.runAgent = exports.selectAgentToolNames = exports.toolInfoList = exports.tools = exports.buildAgentTools = exports.resolveTools = exports.resolveToolRef = exports.invokeToolRef = exports.buildToolHost = exports.listToolsetInfos = exports.listToolsets = exports.getToolset = exports.unregisterToolset = exports.registerToolset = exports.isBuiltInToolsetId = exports.runWithToolContext = exports.EToolEffect = exports.zodFromExample = exports.z = exports.tool = exports.stepCountIs = exports.Output = exports.generateText = exports.loadModels = exports.generateVision = exports.buildModel = void 0;
36
+ exports.runAgent = exports.selectAgentToolNames = exports.toolInfoList = exports.tools = exports.buildAgentTools = exports.resolveTools = exports.resolveToolRef = exports.invokeToolRef = exports.buildToolHost = exports.listToolsetInfos = exports.listToolsets = exports.getToolset = exports.unregisterToolset = exports.registerToolset = exports.isBuiltInToolsetId = exports.defineTool = exports.runWithToolContext = exports.EToolEffect = exports.zodFromExample = exports.z = exports.tool = exports.stepCountIs = exports.Output = exports.generateText = exports.loadModels = exports.generateVision = exports.buildModel = void 0;
37
37
  const index_1 = require("./index");
38
38
  const ai_1 = require("ai");
39
39
  const zod_1 = require("zod");
@@ -388,6 +388,18 @@ const configRefsOfPodSpec = (spec) => {
388
388
  }
389
389
  return refs;
390
390
  };
391
+ /**
392
+ * Declara una tool infiriendo el tipo de sus argumentos DESDE su propio `inputSchema`.
393
+ *
394
+ * Sin esto, `execute` recibe `Record<string, unknown>` y cada tool acaba llena de `String(args.namespace)`
395
+ * y castings sueltos: treinta tools asi son treinta sitios donde equivocarse en silencio, y el compilador
396
+ * no puede ayudar. Con esto, el esquema es la unica fuente de verdad y `args` viene tipado.
397
+ *
398
+ * El registro sigue guardando el tipo suelto (`IAiTool`): quien lo invoca no conoce el esquema, y ahi la
399
+ * comprobacion la hace zod en tiempo de ejecucion, como debe ser.
400
+ */
401
+ const defineTool = (definition) => definition;
402
+ exports.defineTool = defineTool;
391
403
  const toolsetRegistry = new Map();
392
404
  // Los ids de los toolsets built-in del core estan RESERVADOS: un `aitoolset` de un tercero no puede
393
405
  // ocuparlos. Sin esta regla, instalar un toolset ajeno llamado 'k8s-inventory' obligaria a renombrar el
@@ -459,7 +471,7 @@ const buildToolHost = (requires, context) => {
459
471
  if (requires.includes(index_1.ECapability.METRICS))
460
472
  host.metrics = { samples: (_a = context.clusterMetrics) !== null && _a !== void 0 ? _a : [] };
461
473
  if (requires.includes(index_1.ECapability.EVENTS))
462
- host.events = { recent: (_b = context.clusterEvents) !== null && _b !== void 0 ? _b : [] };
474
+ host.events = { recent: ((_b = context.clusterEvents) !== null && _b !== void 0 ? _b : []) };
463
475
  if (requires.includes(index_1.ECapability.REPOS))
464
476
  host.repos = { creds: (_c = context.sourceRepos) !== null && _c !== void 0 ? _c : [] };
465
477
  return host;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kwirthmagnify/kwirth-common-ai",
3
- "version": "0.5.55",
3
+ "version": "0.5.57",
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",