@marco-kueks/agent-factory-core 0.1.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.
@@ -0,0 +1,3 @@
1
+ import type { AgentConfig } from './types';
2
+ export declare function defineAgent(config: AgentConfig): AgentConfig;
3
+ //# sourceMappingURL=defineAgent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defineAgent.d.ts","sourceRoot":"","sources":["../src/defineAgent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CAoB5D"}
@@ -0,0 +1,3 @@
1
+ import type { FrameworkConfig } from './types';
2
+ export declare function defineConfig(config?: Partial<FrameworkConfig>): FrameworkConfig;
3
+ //# sourceMappingURL=defineConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defineConfig.d.ts","sourceRoot":"","sources":["../src/defineConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAkB9C,wBAAgB,YAAY,CAAC,MAAM,GAAE,OAAO,CAAC,eAAe,CAAM,GAAG,eAAe,CAcnF"}
@@ -0,0 +1,3 @@
1
+ import type { ContextFunction } from './types';
2
+ export declare function defineContext(fn: ContextFunction): ContextFunction;
3
+ //# sourceMappingURL=defineContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defineContext.d.ts","sourceRoot":"","sources":["../src/defineContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAiC,MAAM,SAAS,CAAA;AAE7E,wBAAgB,aAAa,CAAC,EAAE,EAAE,eAAe,GAAG,eAAe,CAUlE"}
@@ -0,0 +1,10 @@
1
+ import type { ToolReference, ToolParameters, ToolHandler } from './types';
2
+ interface ToolDefinition {
3
+ name: string;
4
+ description: string;
5
+ parameters: ToolParameters;
6
+ handler: ToolHandler;
7
+ }
8
+ export declare function defineTools(tools: ToolDefinition[]): ToolReference[];
9
+ export {};
10
+ //# sourceMappingURL=defineTools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defineTools.d.ts","sourceRoot":"","sources":["../src/defineTools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAe,MAAM,SAAS,CAAA;AAEtF,UAAU,cAAc;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,cAAc,CAAA;IAC1B,OAAO,EAAE,WAAW,CAAA;CACrB;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,aAAa,EAAE,CAEpE"}
@@ -0,0 +1,6 @@
1
+ export { defineAgent } from './defineAgent';
2
+ export { defineContext } from './defineContext';
3
+ export { defineTools } from './defineTools';
4
+ export { defineConfig } from './defineConfig';
5
+ export type { AgentConfig, ModelConfig, ToolReference, ToolParameters, ParameterDefinition, ToolHandler, ToolContext, StateAccessor, WorkflowReference, StateConfig, ContextFunction, ContextRequest, ContextResult, FrameworkConfig, CorsConfig, LoggingConfig, AuthConfig, Message, Conversation, TestCase, TestMessage, TestToolCall, TestAssertion, DeployConfig, ScalingConfig, } from './types';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C,YAAY,EACV,WAAW,EACX,WAAW,EACX,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,WAAW,EACX,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,eAAe,EACf,cAAc,EACd,aAAa,EACb,eAAe,EACf,UAAU,EACV,aAAa,EACb,UAAU,EACV,OAAO,EACP,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,aAAa,GACd,MAAM,SAAS,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,98 @@
1
+ // src/defineAgent.ts
2
+ function defineAgent(config) {
3
+ if (!config.name) {
4
+ throw new Error("Agent name is required");
5
+ }
6
+ if (!config.version) {
7
+ throw new Error("Agent version is required");
8
+ }
9
+ if (!config.systemPrompt) {
10
+ throw new Error("System prompt is required");
11
+ }
12
+ return {
13
+ model: {
14
+ provider: "anthropic",
15
+ name: "claude-sonnet-4-20250514",
16
+ temperature: 0.7,
17
+ maxTokens: 4096
18
+ },
19
+ ...config
20
+ };
21
+ }
22
+ // src/defineContext.ts
23
+ function defineContext(fn) {
24
+ return async (request) => {
25
+ try {
26
+ const result = await fn(request);
27
+ return result ?? {};
28
+ } catch (error) {
29
+ console.error("Context function error:", error);
30
+ return {};
31
+ }
32
+ };
33
+ }
34
+ // src/defineTools.ts
35
+ function defineTools(tools) {
36
+ return tools.map(validateTool);
37
+ }
38
+ function validateTool(tool) {
39
+ if (!tool.name) {
40
+ throw new Error("Tool name is required");
41
+ }
42
+ if (!tool.description) {
43
+ throw new Error(`Tool "${tool.name}" requires a description`);
44
+ }
45
+ if (!tool.parameters) {
46
+ throw new Error(`Tool "${tool.name}" requires parameters definition`);
47
+ }
48
+ if (typeof tool.handler !== "function") {
49
+ throw new Error(`Tool "${tool.name}" requires a handler function`);
50
+ }
51
+ return {
52
+ name: tool.name,
53
+ description: tool.description,
54
+ parameters: tool.parameters,
55
+ handler: wrapHandler(tool.name, tool.handler)
56
+ };
57
+ }
58
+ function wrapHandler(name, handler) {
59
+ return async (params, context) => {
60
+ try {
61
+ return await handler(params, context);
62
+ } catch (error) {
63
+ console.error(`Tool "${name}" execution error:`, error);
64
+ throw error;
65
+ }
66
+ };
67
+ }
68
+ // src/defineConfig.ts
69
+ var defaultConfig = {
70
+ port: 3000,
71
+ host: "localhost",
72
+ cors: {
73
+ origins: ["http://localhost:3000"],
74
+ credentials: true
75
+ },
76
+ logging: {
77
+ level: "info",
78
+ format: "pretty"
79
+ },
80
+ auth: {
81
+ type: "none"
82
+ }
83
+ };
84
+ function defineConfig(config = {}) {
85
+ return {
86
+ ...defaultConfig,
87
+ ...config,
88
+ cors: config.cors ? { ...defaultConfig.cors, ...config.cors } : defaultConfig.cors,
89
+ logging: config.logging ? { ...defaultConfig.logging, ...config.logging } : defaultConfig.logging,
90
+ auth: config.auth ? { ...defaultConfig.auth, ...config.auth } : defaultConfig.auth
91
+ };
92
+ }
93
+ export {
94
+ defineTools,
95
+ defineContext,
96
+ defineConfig,
97
+ defineAgent
98
+ };
@@ -0,0 +1,129 @@
1
+ export interface AgentConfig {
2
+ name: string;
3
+ version: string;
4
+ description?: string;
5
+ model?: ModelConfig;
6
+ systemPrompt: string | (() => string | Promise<string>);
7
+ tools?: ToolReference[];
8
+ workflows?: WorkflowReference[];
9
+ state?: StateConfig;
10
+ context?: ContextFunction;
11
+ }
12
+ export interface ModelConfig {
13
+ provider: 'anthropic' | 'openai' | 'google' | 'custom';
14
+ name: string;
15
+ temperature?: number;
16
+ maxTokens?: number;
17
+ }
18
+ export interface ToolReference {
19
+ name: string;
20
+ description: string;
21
+ parameters: ToolParameters;
22
+ handler: ToolHandler;
23
+ }
24
+ export interface ToolParameters {
25
+ type: 'object';
26
+ properties: Record<string, ParameterDefinition>;
27
+ required?: string[];
28
+ }
29
+ export interface ParameterDefinition {
30
+ type: 'string' | 'number' | 'boolean' | 'array' | 'object';
31
+ description: string;
32
+ enum?: string[];
33
+ items?: ParameterDefinition;
34
+ properties?: Record<string, ParameterDefinition>;
35
+ }
36
+ export type ToolHandler = (params: Record<string, unknown>, context: ToolContext) => Promise<unknown>;
37
+ export interface ToolContext {
38
+ conversationId: string;
39
+ userId?: string;
40
+ state: StateAccessor;
41
+ }
42
+ export interface StateAccessor {
43
+ get<T>(key: string): Promise<T | undefined>;
44
+ set<T>(key: string, value: T): Promise<void>;
45
+ delete(key: string): Promise<void>;
46
+ }
47
+ export interface WorkflowReference {
48
+ name: string;
49
+ path: string;
50
+ }
51
+ export interface StateConfig {
52
+ storage: 'memory' | 'redis' | 'postgres' | 'custom';
53
+ ttl?: number;
54
+ prefix?: string;
55
+ }
56
+ export type ContextFunction = (request: ContextRequest) => Promise<ContextResult>;
57
+ export interface ContextRequest {
58
+ conversationId: string;
59
+ userId?: string;
60
+ channel: string;
61
+ message: string;
62
+ state: StateAccessor;
63
+ }
64
+ export interface ContextResult {
65
+ additionalContext?: string;
66
+ variables?: Record<string, unknown>;
67
+ }
68
+ export interface FrameworkConfig {
69
+ port?: number;
70
+ host?: string;
71
+ cors?: CorsConfig;
72
+ logging?: LoggingConfig;
73
+ auth?: AuthConfig;
74
+ }
75
+ export interface CorsConfig {
76
+ origins: string[];
77
+ credentials?: boolean;
78
+ }
79
+ export interface LoggingConfig {
80
+ level: 'debug' | 'info' | 'warn' | 'error';
81
+ format?: 'json' | 'pretty';
82
+ }
83
+ export interface AuthConfig {
84
+ type: 'none' | 'api-key' | 'jwt' | 'custom';
85
+ validate?: (token: string) => Promise<boolean>;
86
+ }
87
+ export interface Message {
88
+ role: 'user' | 'assistant' | 'system';
89
+ content: string;
90
+ timestamp: Date;
91
+ metadata?: Record<string, unknown>;
92
+ }
93
+ export interface Conversation {
94
+ id: string;
95
+ messages: Message[];
96
+ state: Record<string, unknown>;
97
+ createdAt: Date;
98
+ updatedAt: Date;
99
+ }
100
+ export interface TestCase {
101
+ name: string;
102
+ description?: string;
103
+ conversation: TestMessage[];
104
+ assertions: TestAssertion[];
105
+ }
106
+ export interface TestMessage {
107
+ role: 'user' | 'assistant';
108
+ content: string;
109
+ toolCalls?: TestToolCall[];
110
+ }
111
+ export interface TestToolCall {
112
+ name: string;
113
+ parameters?: Record<string, unknown>;
114
+ }
115
+ export interface TestAssertion {
116
+ type: 'contains' | 'matches' | 'toolCalled' | 'stateEquals';
117
+ value: string | Record<string, unknown>;
118
+ }
119
+ export interface DeployConfig {
120
+ environment: 'staging' | 'production';
121
+ region?: string;
122
+ scaling?: ScalingConfig;
123
+ }
124
+ export interface ScalingConfig {
125
+ minInstances: number;
126
+ maxInstances: number;
127
+ targetConcurrency?: number;
128
+ }
129
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,WAAW,CAAA;IACnB,YAAY,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;IACvD,KAAK,CAAC,EAAE,aAAa,EAAE,CAAA;IACvB,SAAS,CAAC,EAAE,iBAAiB,EAAE,CAAA;IAC/B,KAAK,CAAC,EAAE,WAAW,CAAA;IACnB,OAAO,CAAC,EAAE,eAAe,CAAA;CAC1B;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,WAAW,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAA;IACtD,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,cAAc,CAAA;IAC1B,OAAO,EAAE,WAAW,CAAA;CACrB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,QAAQ,CA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.0",
4
+ "description": "Core library for building AI agents with Agent Factory",
5
+ "keywords": ["ai", "agents", "llm", "anthropic", "openai", "framework"],
6
+ "author": "marco-kueks",
7
+ "license": "MIT",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/MarcoNaik/agent-factory.git",
11
+ "directory": "packages/core"
12
+ },
13
+ "homepage": "https://github.com/MarcoNaik/agent-factory#readme",
14
+ "bugs": {
15
+ "url": "https://github.com/MarcoNaik/agent-factory/issues"
16
+ },
17
+ "type": "module",
18
+ "main": "./dist/index.js",
19
+ "types": "./dist/index.d.ts",
20
+ "exports": {
21
+ ".": {
22
+ "import": "./dist/index.js",
23
+ "types": "./dist/index.d.ts"
24
+ }
25
+ },
26
+ "files": ["dist"],
27
+ "scripts": {
28
+ "build": "bun build ./src/index.ts --outdir ./dist --target node && tsc --emitDeclarationOnly",
29
+ "dev": "tsc --watch",
30
+ "test": "bun test"
31
+ },
32
+ "devDependencies": {
33
+ "bun-types": "^1.0.0",
34
+ "typescript": "^5.3.0"
35
+ }
36
+ }