@cogitator-ai/core 0.9.0 → 0.11.0
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/agent.d.ts +52 -2
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +52 -2
- package/dist/agent.js.map +1 -1
- package/dist/cogitator/index.d.ts +6 -0
- package/dist/cogitator/index.d.ts.map +1 -0
- package/dist/cogitator/index.js +6 -0
- package/dist/cogitator/index.js.map +1 -0
- package/dist/cogitator/initializers.d.ts +54 -0
- package/dist/cogitator/initializers.d.ts.map +1 -0
- package/dist/cogitator/initializers.js +126 -0
- package/dist/cogitator/initializers.js.map +1 -0
- package/dist/cogitator/message-builder.d.ts +10 -0
- package/dist/cogitator/message-builder.d.ts.map +1 -0
- package/dist/cogitator/message-builder.js +72 -0
- package/dist/cogitator/message-builder.js.map +1 -0
- package/dist/cogitator/span-factory.d.ts +4 -0
- package/dist/cogitator/span-factory.d.ts.map +1 -0
- package/dist/cogitator/span-factory.js +27 -0
- package/dist/cogitator/span-factory.js.map +1 -0
- package/dist/cogitator/streaming.d.ts +16 -0
- package/dist/cogitator/streaming.d.ts.map +1 -0
- package/dist/cogitator/streaming.js +52 -0
- package/dist/cogitator/streaming.js.map +1 -0
- package/dist/cogitator/tool-executor.d.ts +7 -0
- package/dist/cogitator/tool-executor.d.ts.map +1 -0
- package/dist/cogitator/tool-executor.js +146 -0
- package/dist/cogitator/tool-executor.js.map +1 -0
- package/dist/cogitator.d.ts +142 -82
- package/dist/cogitator.d.ts.map +1 -1
- package/dist/cogitator.js +205 -513
- package/dist/cogitator.js.map +1 -1
- package/dist/llm/anthropic.d.ts +1 -0
- package/dist/llm/anthropic.d.ts.map +1 -1
- package/dist/llm/anthropic.js +83 -22
- package/dist/llm/anthropic.js.map +1 -1
- package/dist/llm/azure.d.ts +1 -0
- package/dist/llm/azure.d.ts.map +1 -1
- package/dist/llm/azure.js +109 -46
- package/dist/llm/azure.js.map +1 -1
- package/dist/llm/bedrock.d.ts +1 -0
- package/dist/llm/bedrock.d.ts.map +1 -1
- package/dist/llm/bedrock.js +47 -4
- package/dist/llm/bedrock.js.map +1 -1
- package/dist/llm/debug.d.ts +35 -0
- package/dist/llm/debug.d.ts.map +1 -0
- package/dist/llm/debug.js +175 -0
- package/dist/llm/debug.js.map +1 -0
- package/dist/llm/errors.d.ts +28 -0
- package/dist/llm/errors.d.ts.map +1 -0
- package/dist/llm/errors.js +126 -0
- package/dist/llm/errors.js.map +1 -0
- package/dist/llm/google.d.ts.map +1 -1
- package/dist/llm/google.js +43 -22
- package/dist/llm/google.js.map +1 -1
- package/dist/llm/index.d.ts +3 -0
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/index.js +3 -0
- package/dist/llm/index.js.map +1 -1
- package/dist/llm/ollama.d.ts.map +1 -1
- package/dist/llm/ollama.js +64 -39
- package/dist/llm/ollama.js.map +1 -1
- package/dist/llm/openai.d.ts +1 -0
- package/dist/llm/openai.d.ts.map +1 -1
- package/dist/llm/openai.js +108 -45
- package/dist/llm/openai.js.map +1 -1
- package/dist/llm/plugin.d.ts +53 -0
- package/dist/llm/plugin.d.ts.map +1 -0
- package/dist/llm/plugin.js +71 -0
- package/dist/llm/plugin.js.map +1 -0
- package/dist/registry.d.ts +64 -2
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +64 -2
- package/dist/registry.js.map +1 -1
- package/dist/tool.d.ts +48 -5
- package/dist/tool.d.ts.map +1 -1
- package/dist/tool.js +48 -5
- package/dist/tool.js.map +1 -1
- package/package.json +5 -5
package/dist/llm/openai.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai.js","sourceRoot":"","sources":["../../src/llm/openai.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,MAAM,MAAM,QAAQ,CAAC;AAY5B,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"openai.js","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
+
*
|
|
4
|
+
* Allows registration and discovery of custom LLM backends.
|
|
5
|
+
*/
|
|
6
|
+
import type { LLMBackend } from '@cogitator-ai/types';
|
|
7
|
+
export interface LLMBackendFactory<TConfig = unknown> {
|
|
8
|
+
(config: TConfig): LLMBackend;
|
|
9
|
+
}
|
|
10
|
+
export interface LLMPluginMetadata {
|
|
11
|
+
name: string;
|
|
12
|
+
version?: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
author?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface LLMPlugin<TConfig = unknown> {
|
|
17
|
+
metadata: LLMPluginMetadata;
|
|
18
|
+
provider: string;
|
|
19
|
+
factory: LLMBackendFactory<TConfig>;
|
|
20
|
+
validateConfig?: (config: unknown) => config is TConfig;
|
|
21
|
+
}
|
|
22
|
+
type RegisteredPlugin = {
|
|
23
|
+
metadata: LLMPluginMetadata;
|
|
24
|
+
factory: LLMBackendFactory;
|
|
25
|
+
validateConfig?: (config: unknown) => boolean;
|
|
26
|
+
};
|
|
27
|
+
declare class LLMPluginRegistry {
|
|
28
|
+
private plugins;
|
|
29
|
+
register<TConfig>(plugin: LLMPlugin<TConfig>): void;
|
|
30
|
+
unregister(provider: string): boolean;
|
|
31
|
+
has(provider: string): boolean;
|
|
32
|
+
get(provider: string): RegisteredPlugin | undefined;
|
|
33
|
+
create(provider: string, config: unknown): LLMBackend;
|
|
34
|
+
list(): Array<{
|
|
35
|
+
provider: string;
|
|
36
|
+
metadata: LLMPluginMetadata;
|
|
37
|
+
}>;
|
|
38
|
+
clear(): void;
|
|
39
|
+
}
|
|
40
|
+
export declare const llmPluginRegistry: LLMPluginRegistry;
|
|
41
|
+
export declare function registerLLMBackend<TConfig>(plugin: LLMPlugin<TConfig>): void;
|
|
42
|
+
export declare function unregisterLLMBackend(provider: string): boolean;
|
|
43
|
+
export declare function createLLMBackendFromPlugin(provider: string, config: unknown): LLMBackend;
|
|
44
|
+
export declare function listLLMPlugins(): Array<{
|
|
45
|
+
provider: string;
|
|
46
|
+
metadata: LLMPluginMetadata;
|
|
47
|
+
}>;
|
|
48
|
+
export declare function hasLLMPlugin(provider: string): boolean;
|
|
49
|
+
export declare function defineBackend<TConfig>(options: Omit<LLMPlugin<TConfig>, 'factory'> & {
|
|
50
|
+
create: LLMBackendFactory<TConfig>;
|
|
51
|
+
}): LLMPlugin<TConfig>;
|
|
52
|
+
export {};
|
|
53
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/llm/plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,MAAM,WAAW,iBAAiB,CAAC,OAAO,GAAG,OAAO;IAClD,CAAC,MAAM,EAAE,OAAO,GAAG,UAAU,CAAC;CAC/B;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,SAAS,CAAC,OAAO,GAAG,OAAO;IAC1C,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACpC,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,MAAM,IAAI,OAAO,CAAC;CACzD;AAED,KAAK,gBAAgB,GAAG;IACtB,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,OAAO,EAAE,iBAAiB,CAAC;IAC3B,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC;CAC/C,CAAC;AAEF,cAAM,iBAAiB;IACrB,OAAO,CAAC,OAAO,CAAuC;IAEtD,QAAQ,CAAC,OAAO,E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.
|
|
5
|
+
*/
|
|
6
|
+
class LLMPluginRegistry {
|
|
7
|
+
plugins = new Map();
|
|
8
|
+
register(plugin) {
|
|
9
|
+
if (this.plugins.has(plugin.provider)) {
|
|
10
|
+
throw new Error(`Plugin for provider '${plugin.provider}' is already registered`);
|
|
11
|
+
}
|
|
12
|
+
this.plugins.set(plugin.provider, {
|
|
13
|
+
metadata: plugin.metadata,
|
|
14
|
+
factory: plugin.factory,
|
|
15
|
+
validateConfig: plugin.validateConfig,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
unregister(provider) {
|
|
19
|
+
return this.plugins.delete(provider);
|
|
20
|
+
}
|
|
21
|
+
has(provider) {
|
|
22
|
+
return this.plugins.has(provider);
|
|
23
|
+
}
|
|
24
|
+
get(provider) {
|
|
25
|
+
return this.plugins.get(provider);
|
|
26
|
+
}
|
|
27
|
+
create(provider, config) {
|
|
28
|
+
const plugin = this.plugins.get(provider);
|
|
29
|
+
if (!plugin) {
|
|
30
|
+
throw new Error(`No plugin registered for provider '${provider}'`);
|
|
31
|
+
}
|
|
32
|
+
if (plugin.validateConfig && !plugin.validateConfig(config)) {
|
|
33
|
+
throw new Error(`Invalid configuration for provider '${provider}'`);
|
|
34
|
+
}
|
|
35
|
+
return plugin.factory(config);
|
|
36
|
+
}
|
|
37
|
+
list() {
|
|
38
|
+
return Array.from(this.plugins.entries()).map(([provider, plugin]) => ({
|
|
39
|
+
provider,
|
|
40
|
+
metadata: plugin.metadata,
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
clear() {
|
|
44
|
+
this.plugins.clear();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export const llmPluginRegistry = new LLMPluginRegistry();
|
|
48
|
+
export function registerLLMBackend(plugin) {
|
|
49
|
+
llmPluginRegistry.register(plugin);
|
|
50
|
+
}
|
|
51
|
+
export function unregisterLLMBackend(provider) {
|
|
52
|
+
return llmPluginRegistry.unregister(provider);
|
|
53
|
+
}
|
|
54
|
+
export function createLLMBackendFromPlugin(provider, config) {
|
|
55
|
+
return llmPluginRegistry.create(provider, config);
|
|
56
|
+
}
|
|
57
|
+
export function listLLMPlugins() {
|
|
58
|
+
return llmPluginRegistry.list();
|
|
59
|
+
}
|
|
60
|
+
export function hasLLMPlugin(provider) {
|
|
61
|
+
return llmPluginRegistry.has(provider);
|
|
62
|
+
}
|
|
63
|
+
export function defineBackend(options) {
|
|
64
|
+
return {
|
|
65
|
+
metadata: options.metadata,
|
|
66
|
+
provider: options.provider,
|
|
67
|
+
factory: options.create,
|
|
68
|
+
validateConfig: options.validateConfig,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/llm/plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA4BH,MAAM,iBAAiB;IACb,OAAO,GAAG,IAAI,GAAG,EAA4B,CAAC;IAEtD,QAAQ,CAAU,MAA0B;QAC1C,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YACtC,MAAM,IAAI,KAAK,CAAC,wBAAwB,MAAM,CAAC,QAAQ,yBAAyB,CAAC,CAAC;QACpF,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE;YAChC,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,OAAO,EAAE,MAAM,CAAC,OAA4B;YAC5C,cAAc,EAAE,MAAM,CAAC,cAA4D;SACpF,CAAC,CAAC;IACL,CAAC;IAED,UAAU,CAAC,QAAgB;QACzB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC;IAED,GAAG,CAAC,QAAgB;QAClB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACpC,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OAAO,iBAAiB,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,OAAO,iBAAiB,CAAC,IAAI,EAAE,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,QAAgB;IAC3C,OAAO,iBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,OAEC;IAED,OAAO;QACL,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,OAAO,EAAE,OAAO,CAAC,MAAM;QACvB,cAAc,EAAE,OAAO,CAAC,cAAc;KACvC,CAAC;AACJ,CAAC"}
|
package/dist/registry.d.ts
CHANGED
|
@@ -1,16 +1,78 @@
|
|
|
1
|
+
import type { Tool, ToolSchema } from '@cogitator-ai/types';
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
+
* Registry for managing and organizing tools available to agents.
|
|
4
|
+
*
|
|
5
|
+
* ToolRegistry provides a centralized store for tools with
|
|
6
|
+
* lookup, registration, and schema generation capabilities.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { ToolRegistry, tool } from '@cogitator-ai/core';
|
|
11
|
+
* import { z } from 'zod';
|
|
12
|
+
*
|
|
13
|
+
* const registry = new ToolRegistry();
|
|
14
|
+
*
|
|
15
|
+
* registry.register(tool({
|
|
16
|
+
* name: 'calculator',
|
|
17
|
+
* description: 'Perform math operations',
|
|
18
|
+
* parameters: z.object({ expression: z.string() }),
|
|
19
|
+
* execute: async ({ expression }) => eval(expression),
|
|
20
|
+
* }));
|
|
21
|
+
*
|
|
22
|
+
* const schemas = registry.getSchemas(); // For LLM function calling
|
|
23
|
+
* const calc = registry.get('calculator'); // Get tool by name
|
|
24
|
+
* ```
|
|
3
25
|
*/
|
|
4
|
-
import type { Tool, ToolSchema } from '@cogitator-ai/types';
|
|
5
26
|
export declare class ToolRegistry {
|
|
6
27
|
private tools;
|
|
28
|
+
/**
|
|
29
|
+
* Register a single tool in the registry.
|
|
30
|
+
* If a tool with the same name exists, it will be replaced.
|
|
31
|
+
*
|
|
32
|
+
* @param tool - Tool to register
|
|
33
|
+
*/
|
|
7
34
|
register(tool: Tool): void;
|
|
35
|
+
/**
|
|
36
|
+
* Register multiple tools at once.
|
|
37
|
+
*
|
|
38
|
+
* @param tools - Array of tools to register
|
|
39
|
+
*/
|
|
8
40
|
registerMany(tools: Tool[]): void;
|
|
41
|
+
/**
|
|
42
|
+
* Get a tool by its name.
|
|
43
|
+
*
|
|
44
|
+
* @param name - Name of the tool to retrieve
|
|
45
|
+
* @returns The tool if found, undefined otherwise
|
|
46
|
+
*/
|
|
9
47
|
get(name: string): Tool | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Check if a tool with the given name exists in the registry.
|
|
50
|
+
*
|
|
51
|
+
* @param name - Name of the tool to check
|
|
52
|
+
* @returns true if the tool exists
|
|
53
|
+
*/
|
|
10
54
|
has(name: string): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Get all registered tools.
|
|
57
|
+
*
|
|
58
|
+
* @returns Array of all tools in the registry
|
|
59
|
+
*/
|
|
11
60
|
getAll(): Tool[];
|
|
61
|
+
/**
|
|
62
|
+
* Get JSON schemas for all tools (for LLM function calling).
|
|
63
|
+
*
|
|
64
|
+
* @returns Array of tool schemas in OpenAPI format
|
|
65
|
+
*/
|
|
12
66
|
getSchemas(): ToolSchema[];
|
|
67
|
+
/**
|
|
68
|
+
* Get names of all registered tools.
|
|
69
|
+
*
|
|
70
|
+
* @returns Array of tool names
|
|
71
|
+
*/
|
|
13
72
|
getNames(): string[];
|
|
73
|
+
/**
|
|
74
|
+
* Remove all tools from the registry.
|
|
75
|
+
*/
|
|
14
76
|
clear(): void;
|
|
15
77
|
}
|
|
16
78
|
//# sourceMappingURL=registry.d.ts.map
|
package/dist/registry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAG5D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAA2B;IAExC;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAI1B;;;;OAIG;IACH,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI;IAMjC;;;;;OAKG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;IAInC;;;;;OAKG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B;;;;OAIG;IACH,MAAM,IAAI,IAAI,EAAE;IAIhB;;;;OAIG;IACH,UAAU,IAAI,UAAU,EAAE;IAI1B;;;;OAIG;IACH,QAAQ,IAAI,MAAM,EAAE;IAIpB;;OAEG;IACH,KAAK,IAAI,IAAI;CAGd"}
|
package/dist/registry.js
CHANGED
|
@@ -1,32 +1,94 @@
|
|
|
1
|
+
import { toolToSchema } from './tool';
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
+
* Registry for managing and organizing tools available to agents.
|
|
4
|
+
*
|
|
5
|
+
* ToolRegistry provides a centralized store for tools with
|
|
6
|
+
* lookup, registration, and schema generation capabilities.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { ToolRegistry, tool } from '@cogitator-ai/core';
|
|
11
|
+
* import { z } from 'zod';
|
|
12
|
+
*
|
|
13
|
+
* const registry = new ToolRegistry();
|
|
14
|
+
*
|
|
15
|
+
* registry.register(tool({
|
|
16
|
+
* name: 'calculator',
|
|
17
|
+
* description: 'Perform math operations',
|
|
18
|
+
* parameters: z.object({ expression: z.string() }),
|
|
19
|
+
* execute: async ({ expression }) => eval(expression),
|
|
20
|
+
* }));
|
|
21
|
+
*
|
|
22
|
+
* const schemas = registry.getSchemas(); // For LLM function calling
|
|
23
|
+
* const calc = registry.get('calculator'); // Get tool by name
|
|
24
|
+
* ```
|
|
3
25
|
*/
|
|
4
|
-
import { toolToSchema } from './tool';
|
|
5
26
|
export class ToolRegistry {
|
|
6
27
|
tools = new Map();
|
|
28
|
+
/**
|
|
29
|
+
* Register a single tool in the registry.
|
|
30
|
+
* If a tool with the same name exists, it will be replaced.
|
|
31
|
+
*
|
|
32
|
+
* @param tool - Tool to register
|
|
33
|
+
*/
|
|
7
34
|
register(tool) {
|
|
8
35
|
this.tools.set(tool.name, tool);
|
|
9
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Register multiple tools at once.
|
|
39
|
+
*
|
|
40
|
+
* @param tools - Array of tools to register
|
|
41
|
+
*/
|
|
10
42
|
registerMany(tools) {
|
|
11
43
|
for (const tool of tools) {
|
|
12
44
|
this.register(tool);
|
|
13
45
|
}
|
|
14
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Get a tool by its name.
|
|
49
|
+
*
|
|
50
|
+
* @param name - Name of the tool to retrieve
|
|
51
|
+
* @returns The tool if found, undefined otherwise
|
|
52
|
+
*/
|
|
15
53
|
get(name) {
|
|
16
54
|
return this.tools.get(name);
|
|
17
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Check if a tool with the given name exists in the registry.
|
|
58
|
+
*
|
|
59
|
+
* @param name - Name of the tool to check
|
|
60
|
+
* @returns true if the tool exists
|
|
61
|
+
*/
|
|
18
62
|
has(name) {
|
|
19
63
|
return this.tools.has(name);
|
|
20
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Get all registered tools.
|
|
67
|
+
*
|
|
68
|
+
* @returns Array of all tools in the registry
|
|
69
|
+
*/
|
|
21
70
|
getAll() {
|
|
22
71
|
return Array.from(this.tools.values());
|
|
23
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Get JSON schemas for all tools (for LLM function calling).
|
|
75
|
+
*
|
|
76
|
+
* @returns Array of tool schemas in OpenAPI format
|
|
77
|
+
*/
|
|
24
78
|
getSchemas() {
|
|
25
79
|
return this.getAll().map(toolToSchema);
|
|
26
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Get names of all registered tools.
|
|
83
|
+
*
|
|
84
|
+
* @returns Array of tool names
|
|
85
|
+
*/
|
|
27
86
|
getNames() {
|
|
28
87
|
return Array.from(this.tools.keys());
|
|
29
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Remove all tools from the registry.
|
|
91
|
+
*/
|
|
30
92
|
clear() {
|
|
31
93
|
this.tools.clear();
|
|
32
94
|
}
|
package/dist/registry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,OAAO,YAAY;IACf,KAAK,GAAG,IAAI,GAAG,EAAgB,CAAC;IAExC;;;;;OAKG;IACH,QAAQ,CAAC,IAAU;QACjB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;IAED;;;;OAIG;IACH,YAAY,CAAC,KAAa;QACxB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAED;;;;OAIG;IACH,MAAM;QACJ,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IACzC,CAAC;IAED;;;;OAIG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACzC,CAAC;IAED;;;;OAIG;IACH,QAAQ;QACN,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;IACvC,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;CACF"}
|
package/dist/tool.d.ts
CHANGED
|
@@ -1,13 +1,56 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tool factory and implementation
|
|
3
|
-
*/
|
|
4
1
|
import type { Tool, ToolConfig, ToolSchema } from '@cogitator-ai/types';
|
|
5
2
|
/**
|
|
6
|
-
* Create a type-safe tool
|
|
3
|
+
* Create a type-safe tool for agent use.
|
|
4
|
+
*
|
|
5
|
+
* Tools enable agents to interact with external systems, APIs, databases,
|
|
6
|
+
* or perform computations. Parameters are validated using Zod schemas.
|
|
7
|
+
*
|
|
8
|
+
* @typeParam TParams - Type of parameters the tool accepts
|
|
9
|
+
* @typeParam TResult - Type of result the tool returns
|
|
10
|
+
* @param config - Tool configuration
|
|
11
|
+
* @returns A Tool instance ready for agent use
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { tool } from '@cogitator-ai/core';
|
|
16
|
+
* import { z } from 'zod';
|
|
17
|
+
*
|
|
18
|
+
* const weatherTool = tool({
|
|
19
|
+
* name: 'get_weather',
|
|
20
|
+
* description: 'Get current weather for a city',
|
|
21
|
+
* parameters: z.object({
|
|
22
|
+
* city: z.string().describe('City name'),
|
|
23
|
+
* units: z.enum(['celsius', 'fahrenheit']).default('celsius'),
|
|
24
|
+
* }),
|
|
25
|
+
* execute: async ({ city, units }) => {
|
|
26
|
+
* const response = await fetch(`https://api.weather.com/${city}`);
|
|
27
|
+
* return response.json();
|
|
28
|
+
* },
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @example Sandboxed tool execution
|
|
33
|
+
* ```ts
|
|
34
|
+
* const shellTool = tool({
|
|
35
|
+
* name: 'run_command',
|
|
36
|
+
* description: 'Execute a shell command safely',
|
|
37
|
+
* parameters: z.object({ command: z.string() }),
|
|
38
|
+
* execute: async ({ command }) => ({ command }),
|
|
39
|
+
* sandbox: { type: 'docker', image: 'alpine:latest' },
|
|
40
|
+
* });
|
|
41
|
+
* ```
|
|
7
42
|
*/
|
|
8
43
|
export declare function tool<TParams, TResult>(config: ToolConfig<TParams, TResult>): Tool<TParams, TResult>;
|
|
9
44
|
/**
|
|
10
|
-
* Convert a tool to JSON Schema format for LLM
|
|
45
|
+
* Convert a tool to JSON Schema format for LLM function calling.
|
|
46
|
+
*
|
|
47
|
+
* Transforms Zod schema to OpenAPI 3.0 compatible JSON Schema
|
|
48
|
+
* that can be sent to LLM providers for function calling.
|
|
49
|
+
*
|
|
50
|
+
* @typeParam TParams - Type of tool parameters
|
|
51
|
+
* @typeParam TResult - Type of tool result
|
|
52
|
+
* @param t - Tool to convert
|
|
53
|
+
* @returns JSON Schema representation of the tool
|
|
11
54
|
*/
|
|
12
55
|
export declare function toolToSchema<TParams, TResult>(t: Tool<TParams, TResult>): ToolSchema;
|
|
13
56
|
//# sourceMappingURL=tool.d.ts.map
|
package/dist/tool.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../src/tool.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../src/tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAIxE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,OAAO,EACnC,MAAM,EAAE,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,GACnC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAgBxB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,UAAU,CAmBpF"}
|
package/dist/tool.js
CHANGED
|
@@ -1,9 +1,44 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tool factory and implementation
|
|
3
|
-
*/
|
|
4
1
|
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
5
2
|
/**
|
|
6
|
-
* Create a type-safe tool
|
|
3
|
+
* Create a type-safe tool for agent use.
|
|
4
|
+
*
|
|
5
|
+
* Tools enable agents to interact with external systems, APIs, databases,
|
|
6
|
+
* or perform computations. Parameters are validated using Zod schemas.
|
|
7
|
+
*
|
|
8
|
+
* @typeParam TParams - Type of parameters the tool accepts
|
|
9
|
+
* @typeParam TResult - Type of result the tool returns
|
|
10
|
+
* @param config - Tool configuration
|
|
11
|
+
* @returns A Tool instance ready for agent use
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { tool } from '@cogitator-ai/core';
|
|
16
|
+
* import { z } from 'zod';
|
|
17
|
+
*
|
|
18
|
+
* const weatherTool = tool({
|
|
19
|
+
* name: 'get_weather',
|
|
20
|
+
* description: 'Get current weather for a city',
|
|
21
|
+
* parameters: z.object({
|
|
22
|
+
* city: z.string().describe('City name'),
|
|
23
|
+
* units: z.enum(['celsius', 'fahrenheit']).default('celsius'),
|
|
24
|
+
* }),
|
|
25
|
+
* execute: async ({ city, units }) => {
|
|
26
|
+
* const response = await fetch(`https://api.weather.com/${city}`);
|
|
27
|
+
* return response.json();
|
|
28
|
+
* },
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @example Sandboxed tool execution
|
|
33
|
+
* ```ts
|
|
34
|
+
* const shellTool = tool({
|
|
35
|
+
* name: 'run_command',
|
|
36
|
+
* description: 'Execute a shell command safely',
|
|
37
|
+
* parameters: z.object({ command: z.string() }),
|
|
38
|
+
* execute: async ({ command }) => ({ command }),
|
|
39
|
+
* sandbox: { type: 'docker', image: 'alpine:latest' },
|
|
40
|
+
* });
|
|
41
|
+
* ```
|
|
7
42
|
*/
|
|
8
43
|
export function tool(config) {
|
|
9
44
|
return {
|
|
@@ -23,7 +58,15 @@ export function tool(config) {
|
|
|
23
58
|
};
|
|
24
59
|
}
|
|
25
60
|
/**
|
|
26
|
-
* Convert a tool to JSON Schema format for LLM
|
|
61
|
+
* Convert a tool to JSON Schema format for LLM function calling.
|
|
62
|
+
*
|
|
63
|
+
* Transforms Zod schema to OpenAPI 3.0 compatible JSON Schema
|
|
64
|
+
* that can be sent to LLM providers for function calling.
|
|
65
|
+
*
|
|
66
|
+
* @typeParam TParams - Type of tool parameters
|
|
67
|
+
* @typeParam TResult - Type of tool result
|
|
68
|
+
* @param t - Tool to convert
|
|
69
|
+
* @returns JSON Schema representation of the tool
|
|
27
70
|
*/
|
|
28
71
|
export function toolToSchema(t) {
|
|
29
72
|
const jsonSchema = zodToJsonSchema(t.parameters, {
|
package/dist/tool.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool.js","sourceRoot":"","sources":["../src/tool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3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+1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cogitator-ai/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Core runtime for Cogitator AI agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"openai": "^4.24.0",
|
|
23
23
|
"zod": "^3.22.4",
|
|
24
24
|
"zod-to-json-schema": "^3.22.4",
|
|
25
|
-
"@cogitator-ai/
|
|
26
|
-
"@cogitator-ai/
|
|
27
|
-
"@cogitator-ai/types": "0.
|
|
25
|
+
"@cogitator-ai/memory": "0.5.1",
|
|
26
|
+
"@cogitator-ai/models": "8.0.0",
|
|
27
|
+
"@cogitator-ai/types": "0.10.0"
|
|
28
28
|
},
|
|
29
29
|
"optionalDependencies": {
|
|
30
30
|
"pg": "^8.11.3"
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@aws-sdk/client-bedrock-runtime": "^3.0.0",
|
|
39
39
|
"pg": "^8.0.0",
|
|
40
|
-
"@cogitator-ai/sandbox": "0.2.
|
|
40
|
+
"@cogitator-ai/sandbox": "0.2.8"
|
|
41
41
|
},
|
|
42
42
|
"peerDependenciesMeta": {
|
|
43
43
|
"@aws-sdk/client-bedrock-runtime": {
|