@kwirthmagnify/kwirth-common-ai 0.5.56 → 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;
@@ -119,6 +119,24 @@ export interface IAiTool extends IAiToolInfo {
119
119
  export interface IAiToolset extends Omit<IAiToolsetInfo, 'tools'> {
120
120
  tools: IAiTool[];
121
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;
122
140
  export declare const isBuiltInToolsetId: (id: string) => boolean;
123
141
  /**
124
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kwirthmagnify/kwirth-common-ai",
3
- "version": "0.5.56",
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",