agents-library 1.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.
- package/dist/base-agent.d.ts +172 -0
- package/dist/base-agent.d.ts.map +1 -0
- package/dist/base-agent.js +255 -0
- package/dist/base-agent.js.map +1 -0
- package/dist/base-bot.d.ts +282 -0
- package/dist/base-bot.d.ts.map +1 -0
- package/dist/base-bot.js +375 -0
- package/dist/base-bot.js.map +1 -0
- package/dist/common/result.d.ts +51 -0
- package/dist/common/result.d.ts.map +1 -0
- package/dist/common/result.js +45 -0
- package/dist/common/result.js.map +1 -0
- package/dist/common/types.d.ts +57 -0
- package/dist/common/types.d.ts.map +1 -0
- package/dist/common/types.js +42 -0
- package/dist/common/types.js.map +1 -0
- package/dist/index.d.ts +94 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +108 -0
- package/dist/index.js.map +1 -0
- package/dist/kadi-event-publisher.d.ts +163 -0
- package/dist/kadi-event-publisher.d.ts.map +1 -0
- package/dist/kadi-event-publisher.js +286 -0
- package/dist/kadi-event-publisher.js.map +1 -0
- package/dist/memory/arcadedb-adapter.d.ts +159 -0
- package/dist/memory/arcadedb-adapter.d.ts.map +1 -0
- package/dist/memory/arcadedb-adapter.js +314 -0
- package/dist/memory/arcadedb-adapter.js.map +1 -0
- package/dist/memory/file-storage-adapter.d.ts +122 -0
- package/dist/memory/file-storage-adapter.d.ts.map +1 -0
- package/dist/memory/file-storage-adapter.js +352 -0
- package/dist/memory/file-storage-adapter.js.map +1 -0
- package/dist/memory/memory-service.d.ts +208 -0
- package/dist/memory/memory-service.d.ts.map +1 -0
- package/dist/memory/memory-service.js +410 -0
- package/dist/memory/memory-service.js.map +1 -0
- package/dist/memory/types.d.ts +126 -0
- package/dist/memory/types.d.ts.map +1 -0
- package/dist/memory/types.js +41 -0
- package/dist/memory/types.js.map +1 -0
- package/dist/producer-tool-utils.d.ts +474 -0
- package/dist/producer-tool-utils.d.ts.map +1 -0
- package/dist/producer-tool-utils.js +664 -0
- package/dist/producer-tool-utils.js.map +1 -0
- package/dist/providers/anthropic-provider.d.ts +160 -0
- package/dist/providers/anthropic-provider.d.ts.map +1 -0
- package/dist/providers/anthropic-provider.js +527 -0
- package/dist/providers/anthropic-provider.js.map +1 -0
- package/dist/providers/model-manager-provider.d.ts +91 -0
- package/dist/providers/model-manager-provider.d.ts.map +1 -0
- package/dist/providers/model-manager-provider.js +355 -0
- package/dist/providers/model-manager-provider.js.map +1 -0
- package/dist/providers/provider-manager.d.ts +111 -0
- package/dist/providers/provider-manager.d.ts.map +1 -0
- package/dist/providers/provider-manager.js +337 -0
- package/dist/providers/provider-manager.js.map +1 -0
- package/dist/providers/types.d.ts +145 -0
- package/dist/providers/types.d.ts.map +1 -0
- package/dist/providers/types.js +23 -0
- package/dist/providers/types.js.map +1 -0
- package/dist/shadow-agent-factory.d.ts +623 -0
- package/dist/shadow-agent-factory.d.ts.map +1 -0
- package/dist/shadow-agent-factory.js +1117 -0
- package/dist/shadow-agent-factory.js.map +1 -0
- package/dist/types/agent-config.d.ts +307 -0
- package/dist/types/agent-config.d.ts.map +1 -0
- package/dist/types/agent-config.js +15 -0
- package/dist/types/agent-config.js.map +1 -0
- package/dist/types/event-schemas.d.ts +358 -0
- package/dist/types/event-schemas.d.ts.map +1 -0
- package/dist/types/event-schemas.js +188 -0
- package/dist/types/event-schemas.js.map +1 -0
- package/dist/types/tool-schemas.d.ts +498 -0
- package/dist/types/tool-schemas.d.ts.map +1 -0
- package/dist/types/tool-schemas.js +457 -0
- package/dist/types/tool-schemas.js.map +1 -0
- package/dist/utils/logger.d.ts +135 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +205 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/timer.d.ts +186 -0
- package/dist/utils/timer.d.ts.map +1 -0
- package/dist/utils/timer.js +211 -0
- package/dist/utils/timer.js.map +1 -0
- package/dist/worker-agent-factory.d.ts +688 -0
- package/dist/worker-agent-factory.d.ts.map +1 -0
- package/dist/worker-agent-factory.js +1517 -0
- package/dist/worker-agent-factory.js.map +1 -0
- package/package.json +38 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BaseAgent - Shared Foundation for All KĀDI Agents
|
|
3
|
+
* ==================================================
|
|
4
|
+
*
|
|
5
|
+
* Provides the common infrastructure that all agents need:
|
|
6
|
+
* - KadiClient setup and broker connection (non-blocking connect())
|
|
7
|
+
* - Optional ProviderManager for LLM operations
|
|
8
|
+
* - Optional MemoryService for context persistence
|
|
9
|
+
* - Graceful shutdown handling (SIGINT/SIGTERM)
|
|
10
|
+
* - Agent metadata (agentId, agentRole)
|
|
11
|
+
*
|
|
12
|
+
* Design: Composition, not inheritance. Each agent repo instantiates BaseAgent
|
|
13
|
+
* and implements its own behavior. BaseAgent is a concrete class, not abstract.
|
|
14
|
+
*
|
|
15
|
+
* Usage:
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const agent = new BaseAgent({
|
|
18
|
+
* agentId: 'agent-artist',
|
|
19
|
+
* agentRole: 'artist',
|
|
20
|
+
* brokerUrl: 'ws://localhost:8080',
|
|
21
|
+
* networks: ['global'],
|
|
22
|
+
* });
|
|
23
|
+
* await agent.connect();
|
|
24
|
+
* // ... agent-specific logic using agent.client, agent.providerManager, etc.
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @module base-agent
|
|
28
|
+
*/
|
|
29
|
+
import { KadiClient } from '@kadi.build/core';
|
|
30
|
+
import { ProviderManager } from './providers/provider-manager.js';
|
|
31
|
+
import { MemoryService } from './memory/memory-service.js';
|
|
32
|
+
/**
|
|
33
|
+
* Provider configuration for BaseAgent.
|
|
34
|
+
* Controls which LLM providers are available and how they fail over.
|
|
35
|
+
*/
|
|
36
|
+
export interface BaseAgentProviderConfig {
|
|
37
|
+
/** Anthropic API key (required if using Anthropic provider) */
|
|
38
|
+
anthropicApiKey?: string;
|
|
39
|
+
/** Model Manager Gateway base URL (optional, enables model-manager provider) */
|
|
40
|
+
modelManagerBaseUrl?: string;
|
|
41
|
+
/** Model Manager Gateway API key (required if modelManagerBaseUrl is set) */
|
|
42
|
+
modelManagerApiKey?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Primary provider name.
|
|
45
|
+
* @default 'anthropic' if only anthropicApiKey is set
|
|
46
|
+
* @default 'model-manager' if modelManagerBaseUrl is set
|
|
47
|
+
*/
|
|
48
|
+
primaryProvider?: string;
|
|
49
|
+
/** Fallback provider name (optional, enables automatic failover) */
|
|
50
|
+
fallbackProvider?: string;
|
|
51
|
+
/** Number of retry attempts for failed LLM calls @default 3 */
|
|
52
|
+
retryAttempts?: number;
|
|
53
|
+
/** Delay between retries in milliseconds @default 1000 */
|
|
54
|
+
retryDelayMs?: number;
|
|
55
|
+
/** Health check interval in milliseconds @default 60000 */
|
|
56
|
+
healthCheckIntervalMs?: number;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Memory configuration for BaseAgent.
|
|
60
|
+
* Controls where conversation context and knowledge are stored.
|
|
61
|
+
*/
|
|
62
|
+
export interface BaseAgentMemoryConfig {
|
|
63
|
+
/** Path to file-based memory storage directory */
|
|
64
|
+
dataPath: string;
|
|
65
|
+
/** ArcadeDB URL for long-term memory (optional) */
|
|
66
|
+
arcadedbUrl?: string;
|
|
67
|
+
/** ArcadeDB root password @default 'root' */
|
|
68
|
+
arcadedbPassword?: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Configuration for BaseAgent.
|
|
72
|
+
* Only agentId, agentRole, brokerUrl, and networks are required.
|
|
73
|
+
* Provider and memory are optional — agents without them still work.
|
|
74
|
+
*/
|
|
75
|
+
export interface BaseAgentConfig {
|
|
76
|
+
/** Unique agent identifier (e.g., 'agent-producer', 'agent-artist') */
|
|
77
|
+
agentId: string;
|
|
78
|
+
/** Agent role (e.g., 'producer', 'artist', 'designer', 'programmer') */
|
|
79
|
+
agentRole: string;
|
|
80
|
+
/** Agent version string @default '1.0.0' */
|
|
81
|
+
version?: string;
|
|
82
|
+
/** KĀDI broker WebSocket URL (used as the 'default' broker) */
|
|
83
|
+
brokerUrl: string;
|
|
84
|
+
/** KĀDI networks this agent belongs to (for the default broker) */
|
|
85
|
+
networks: string[];
|
|
86
|
+
/**
|
|
87
|
+
* Additional named brokers to connect to simultaneously.
|
|
88
|
+
* Each key is a broker name, value is { url, networks }.
|
|
89
|
+
* The primary broker (brokerUrl + networks) is always named 'default'.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* additionalBrokers: {
|
|
94
|
+
* remote: { url: 'ws://remote:8080/kadi', networks: ['global'] },
|
|
95
|
+
* }
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
additionalBrokers?: Record<string, {
|
|
99
|
+
url: string;
|
|
100
|
+
networks: string[];
|
|
101
|
+
}>;
|
|
102
|
+
/** Optional LLM provider configuration */
|
|
103
|
+
provider?: BaseAgentProviderConfig;
|
|
104
|
+
/** Optional memory service configuration */
|
|
105
|
+
memory?: BaseAgentMemoryConfig;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Shared foundation for all KĀDI agents.
|
|
109
|
+
*
|
|
110
|
+
* Provides KadiClient, optional ProviderManager, optional MemoryService,
|
|
111
|
+
* and graceful shutdown. Each agent repo uses BaseAgent via composition
|
|
112
|
+
* and adds its own behavior.
|
|
113
|
+
*/
|
|
114
|
+
export declare class BaseAgent {
|
|
115
|
+
/** KĀDI protocol client for broker communication */
|
|
116
|
+
readonly client: KadiClient;
|
|
117
|
+
/** LLM provider manager (undefined if no provider config) */
|
|
118
|
+
readonly providerManager?: ProviderManager;
|
|
119
|
+
/** Memory service for context persistence (undefined if no memory config) */
|
|
120
|
+
readonly memoryService?: MemoryService;
|
|
121
|
+
/** Agent configuration */
|
|
122
|
+
readonly config: BaseAgentConfig;
|
|
123
|
+
/** Whether shutdown handlers have been registered */
|
|
124
|
+
private shutdownHandlersRegistered;
|
|
125
|
+
/** Whether the agent is currently connected */
|
|
126
|
+
private connected;
|
|
127
|
+
/** Timer key for this agent's lifetime tracking */
|
|
128
|
+
private readonly timerKey;
|
|
129
|
+
constructor(config: BaseAgentConfig);
|
|
130
|
+
/**
|
|
131
|
+
* Connect to KĀDI broker and initialize async services.
|
|
132
|
+
*
|
|
133
|
+
* Uses client.connect() (non-blocking) — NOT client.serve() which blocks forever.
|
|
134
|
+
* After connection, initializes MemoryService if configured.
|
|
135
|
+
*/
|
|
136
|
+
connect(): Promise<void>;
|
|
137
|
+
/**
|
|
138
|
+
* Register SIGINT/SIGTERM handlers for graceful shutdown.
|
|
139
|
+
*
|
|
140
|
+
* Call this once after setting up agent-specific resources.
|
|
141
|
+
* The shutdown sequence: agent-specific cleanup → disconnect → exit.
|
|
142
|
+
*
|
|
143
|
+
* @param onBeforeShutdown - Optional async callback for agent-specific cleanup
|
|
144
|
+
* (e.g., stopping bots, unsubscribing events) before broker disconnect.
|
|
145
|
+
*/
|
|
146
|
+
registerShutdownHandlers(onBeforeShutdown?: () => Promise<void>): void;
|
|
147
|
+
/**
|
|
148
|
+
* Shut down the agent: dispose services and disconnect from broker.
|
|
149
|
+
*
|
|
150
|
+
* Can be called directly for programmatic shutdown, or automatically
|
|
151
|
+
* via registered signal handlers.
|
|
152
|
+
*/
|
|
153
|
+
shutdown(): Promise<void>;
|
|
154
|
+
/**
|
|
155
|
+
* Check if the agent is currently connected to the broker.
|
|
156
|
+
*/
|
|
157
|
+
isConnected(): boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Get agent metadata for inclusion in event payloads.
|
|
160
|
+
* Used by the generic event naming system (task 3.11).
|
|
161
|
+
*/
|
|
162
|
+
getMetadata(): {
|
|
163
|
+
agentId: string;
|
|
164
|
+
agentRole: string;
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Create ProviderManager from provider configuration.
|
|
168
|
+
* Instantiates the appropriate LLM providers based on available credentials.
|
|
169
|
+
*/
|
|
170
|
+
private createProviderManager;
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=base-agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-agent.d.ts","sourceRoot":"","sources":["../src/base-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAGlE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAS3D;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC,+DAA+D;IAC/D,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,gFAAgF;IAChF,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B,6EAA6E;IAC7E,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,oEAAoE;IACpE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,+DAA+D;IAC/D,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,0DAA0D;IAC1D,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,2DAA2D;IAC3D,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,kDAAkD;IAClD,QAAQ,EAAE,MAAM,CAAC;IAEjB,mDAAmD;IACnD,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,6CAA6C;IAC7C,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,uEAAuE;IACvE,OAAO,EAAE,MAAM,CAAC;IAEhB,wEAAwE;IACxE,SAAS,EAAE,MAAM,CAAC;IAElB,4CAA4C;IAC5C,OAAO,CAAC,EAAE,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;IACH,OAAO,CAAC,qBAAqB;CAuC9B"}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BaseAgent - Shared Foundation for All KĀDI Agents
|
|
3
|
+
* ==================================================
|
|
4
|
+
*
|
|
5
|
+
* Provides the common infrastructure that all agents need:
|
|
6
|
+
* - KadiClient setup and broker connection (non-blocking connect())
|
|
7
|
+
* - Optional ProviderManager for LLM operations
|
|
8
|
+
* - Optional MemoryService for context persistence
|
|
9
|
+
* - Graceful shutdown handling (SIGINT/SIGTERM)
|
|
10
|
+
* - Agent metadata (agentId, agentRole)
|
|
11
|
+
*
|
|
12
|
+
* Design: Composition, not inheritance. Each agent repo instantiates BaseAgent
|
|
13
|
+
* and implements its own behavior. BaseAgent is a concrete class, not abstract.
|
|
14
|
+
*
|
|
15
|
+
* Usage:
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const agent = new BaseAgent({
|
|
18
|
+
* agentId: 'agent-artist',
|
|
19
|
+
* agentRole: 'artist',
|
|
20
|
+
* brokerUrl: 'ws://localhost:8080',
|
|
21
|
+
* networks: ['global'],
|
|
22
|
+
* });
|
|
23
|
+
* await agent.connect();
|
|
24
|
+
* // ... agent-specific logic using agent.client, agent.providerManager, etc.
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @module base-agent
|
|
28
|
+
*/
|
|
29
|
+
import { KadiClient } from '@kadi.build/core';
|
|
30
|
+
import { ProviderManager } from './providers/provider-manager.js';
|
|
31
|
+
import { AnthropicProvider } from './providers/anthropic-provider.js';
|
|
32
|
+
import { ModelManagerProvider } from './providers/model-manager-provider.js';
|
|
33
|
+
import { MemoryService } from './memory/memory-service.js';
|
|
34
|
+
import { logger, MODULE_AGENT } from './utils/logger.js';
|
|
35
|
+
import { timer } from './utils/timer.js';
|
|
36
|
+
// ============================================================================
|
|
37
|
+
// BaseAgent Class
|
|
38
|
+
// ============================================================================
|
|
39
|
+
/**
|
|
40
|
+
* Shared foundation for all KĀDI agents.
|
|
41
|
+
*
|
|
42
|
+
* Provides KadiClient, optional ProviderManager, optional MemoryService,
|
|
43
|
+
* and graceful shutdown. Each agent repo uses BaseAgent via composition
|
|
44
|
+
* and adds its own behavior.
|
|
45
|
+
*/
|
|
46
|
+
export class BaseAgent {
|
|
47
|
+
/** KĀDI protocol client for broker communication */
|
|
48
|
+
client;
|
|
49
|
+
/** LLM provider manager (undefined if no provider config) */
|
|
50
|
+
providerManager;
|
|
51
|
+
/** Memory service for context persistence (undefined if no memory config) */
|
|
52
|
+
memoryService;
|
|
53
|
+
/** Agent configuration */
|
|
54
|
+
config;
|
|
55
|
+
/** Whether shutdown handlers have been registered */
|
|
56
|
+
shutdownHandlersRegistered = false;
|
|
57
|
+
/** Whether the agent is currently connected */
|
|
58
|
+
connected = false;
|
|
59
|
+
/** Timer key for this agent's lifetime tracking */
|
|
60
|
+
timerKey;
|
|
61
|
+
constructor(config) {
|
|
62
|
+
this.config = config;
|
|
63
|
+
this.timerKey = `base-agent-${config.agentId}`;
|
|
64
|
+
timer.start(this.timerKey);
|
|
65
|
+
logger.info(MODULE_AGENT, `Initializing BaseAgent: ${config.agentId} (role: ${config.agentRole})`, timer.elapsed(this.timerKey));
|
|
66
|
+
// Build brokers map: 'default' + any additional brokers
|
|
67
|
+
const brokers = {
|
|
68
|
+
default: { url: config.brokerUrl, networks: config.networks },
|
|
69
|
+
};
|
|
70
|
+
if (config.additionalBrokers) {
|
|
71
|
+
for (const [name, entry] of Object.entries(config.additionalBrokers)) {
|
|
72
|
+
brokers[name] = { url: entry.url, networks: entry.networks };
|
|
73
|
+
logger.info(MODULE_AGENT, ` Broker '${name}': ${entry.url} [${entry.networks.join(', ')}]`, timer.elapsed(this.timerKey));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// Create KadiClient
|
|
77
|
+
this.client = new KadiClient({
|
|
78
|
+
name: config.agentId,
|
|
79
|
+
version: config.version || '1.0.0',
|
|
80
|
+
brokers,
|
|
81
|
+
defaultBroker: 'default',
|
|
82
|
+
});
|
|
83
|
+
// Create ProviderManager if configured
|
|
84
|
+
if (config.provider) {
|
|
85
|
+
this.providerManager = this.createProviderManager(config.provider);
|
|
86
|
+
logger.info(MODULE_AGENT, ' ✅ ProviderManager created', timer.elapsed(this.timerKey));
|
|
87
|
+
}
|
|
88
|
+
// Create MemoryService if configured (requires async initialize() later)
|
|
89
|
+
if (config.memory) {
|
|
90
|
+
this.memoryService = new MemoryService(config.memory.dataPath, config.memory.arcadedbUrl, config.memory.arcadedbPassword, this.providerManager);
|
|
91
|
+
logger.info(MODULE_AGENT, ' ✅ MemoryService created (pending initialization)', timer.elapsed(this.timerKey));
|
|
92
|
+
}
|
|
93
|
+
logger.info(MODULE_AGENT, ` BaseAgent initialized for ${config.agentId}`, timer.elapsed(this.timerKey));
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Connect to KĀDI broker and initialize async services.
|
|
97
|
+
*
|
|
98
|
+
* Uses client.connect() (non-blocking) — NOT client.serve() which blocks forever.
|
|
99
|
+
* After connection, initializes MemoryService if configured.
|
|
100
|
+
*/
|
|
101
|
+
async connect() {
|
|
102
|
+
const brokerCount = 1 + Object.keys(this.config.additionalBrokers || {}).length;
|
|
103
|
+
logger.info(MODULE_AGENT, `Connecting ${this.config.agentId} to ${brokerCount} broker(s)...`, timer.elapsed(this.timerKey));
|
|
104
|
+
logger.info(MODULE_AGENT, ` Broker 'default': ${this.config.brokerUrl} [${this.config.networks.join(', ')}]`, timer.elapsed(this.timerKey));
|
|
105
|
+
try {
|
|
106
|
+
await this.client.connect();
|
|
107
|
+
this.connected = true;
|
|
108
|
+
logger.info(MODULE_AGENT, ` ✅ Connected to ${brokerCount} broker(s)`, timer.elapsed(this.timerKey));
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
logger.error(MODULE_AGENT, `Failed to connect to broker: ${error.message || String(error)}`, timer.elapsed(this.timerKey), error);
|
|
112
|
+
throw error;
|
|
113
|
+
}
|
|
114
|
+
// Initialize MemoryService after connection (async operation)
|
|
115
|
+
if (this.memoryService) {
|
|
116
|
+
try {
|
|
117
|
+
await this.memoryService.initialize();
|
|
118
|
+
logger.info(MODULE_AGENT, ' ✅ MemoryService initialized', timer.elapsed(this.timerKey));
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
// Memory initialization failure is non-fatal — agent can still operate
|
|
122
|
+
logger.error(MODULE_AGENT, `MemoryService initialization failed (non-fatal): ${error.message || String(error)}`, timer.elapsed(this.timerKey), error);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Register SIGINT/SIGTERM handlers for graceful shutdown.
|
|
128
|
+
*
|
|
129
|
+
* Call this once after setting up agent-specific resources.
|
|
130
|
+
* The shutdown sequence: agent-specific cleanup → disconnect → exit.
|
|
131
|
+
*
|
|
132
|
+
* @param onBeforeShutdown - Optional async callback for agent-specific cleanup
|
|
133
|
+
* (e.g., stopping bots, unsubscribing events) before broker disconnect.
|
|
134
|
+
*/
|
|
135
|
+
registerShutdownHandlers(onBeforeShutdown) {
|
|
136
|
+
if (this.shutdownHandlersRegistered) {
|
|
137
|
+
logger.info(MODULE_AGENT, 'Shutdown handlers already registered, skipping', timer.elapsed(this.timerKey));
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const shutdownHandler = async (signal) => {
|
|
141
|
+
logger.info(MODULE_AGENT, `${signal} received, shutting down ${this.config.agentId}...`, timer.elapsed(this.timerKey));
|
|
142
|
+
try {
|
|
143
|
+
// Step 1: Agent-specific cleanup
|
|
144
|
+
if (onBeforeShutdown) {
|
|
145
|
+
await onBeforeShutdown();
|
|
146
|
+
}
|
|
147
|
+
// Step 2: Shutdown base services
|
|
148
|
+
await this.shutdown();
|
|
149
|
+
logger.info(MODULE_AGENT, 'Graceful shutdown complete', timer.elapsed(this.timerKey));
|
|
150
|
+
process.exit(0);
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
logger.error(MODULE_AGENT, `Error during shutdown: ${error.message || String(error)}`, timer.elapsed(this.timerKey), error);
|
|
154
|
+
process.exit(1);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
process.on('SIGTERM', () => shutdownHandler('SIGTERM'));
|
|
158
|
+
process.on('SIGINT', () => shutdownHandler('SIGINT'));
|
|
159
|
+
this.shutdownHandlersRegistered = true;
|
|
160
|
+
logger.info(MODULE_AGENT, 'Shutdown handlers registered (SIGTERM, SIGINT)', timer.elapsed(this.timerKey));
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Shut down the agent: dispose services and disconnect from broker.
|
|
164
|
+
*
|
|
165
|
+
* Can be called directly for programmatic shutdown, or automatically
|
|
166
|
+
* via registered signal handlers.
|
|
167
|
+
*/
|
|
168
|
+
async shutdown() {
|
|
169
|
+
logger.info(MODULE_AGENT, `Shutting down ${this.config.agentId}...`, timer.elapsed(this.timerKey));
|
|
170
|
+
// Dispose ProviderManager (stops health checks)
|
|
171
|
+
if (this.providerManager) {
|
|
172
|
+
try {
|
|
173
|
+
this.providerManager.dispose();
|
|
174
|
+
logger.info(MODULE_AGENT, ' ProviderManager disposed', timer.elapsed(this.timerKey));
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
logger.error(MODULE_AGENT, `Error disposing ProviderManager: ${error.message}`, timer.elapsed(this.timerKey));
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
// Dispose MemoryService
|
|
181
|
+
if (this.memoryService) {
|
|
182
|
+
try {
|
|
183
|
+
this.memoryService.dispose();
|
|
184
|
+
logger.info(MODULE_AGENT, ' MemoryService disposed', timer.elapsed(this.timerKey));
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
logger.error(MODULE_AGENT, `Error disposing MemoryService: ${error.message}`, timer.elapsed(this.timerKey));
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
// Disconnect from broker (clears subscriptions, unloads abilities)
|
|
191
|
+
if (this.connected) {
|
|
192
|
+
try {
|
|
193
|
+
await this.client.disconnect();
|
|
194
|
+
this.connected = false;
|
|
195
|
+
logger.info(MODULE_AGENT, ' Disconnected from broker', timer.elapsed(this.timerKey));
|
|
196
|
+
}
|
|
197
|
+
catch (error) {
|
|
198
|
+
logger.error(MODULE_AGENT, `Error disconnecting from broker: ${error.message}`, timer.elapsed(this.timerKey));
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Check if the agent is currently connected to the broker.
|
|
204
|
+
*/
|
|
205
|
+
isConnected() {
|
|
206
|
+
return this.connected;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Get agent metadata for inclusion in event payloads.
|
|
210
|
+
* Used by the generic event naming system (task 3.11).
|
|
211
|
+
*/
|
|
212
|
+
getMetadata() {
|
|
213
|
+
return {
|
|
214
|
+
agentId: this.config.agentId,
|
|
215
|
+
agentRole: this.config.agentRole,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
// ============================================================================
|
|
219
|
+
// Private Helpers
|
|
220
|
+
// ============================================================================
|
|
221
|
+
/**
|
|
222
|
+
* Create ProviderManager from provider configuration.
|
|
223
|
+
* Instantiates the appropriate LLM providers based on available credentials.
|
|
224
|
+
*/
|
|
225
|
+
createProviderManager(providerConfig) {
|
|
226
|
+
const providers = [];
|
|
227
|
+
// Add Anthropic provider if API key is available
|
|
228
|
+
if (providerConfig.anthropicApiKey) {
|
|
229
|
+
providers.push(new AnthropicProvider(providerConfig.anthropicApiKey));
|
|
230
|
+
}
|
|
231
|
+
// Add Model Manager provider if configured
|
|
232
|
+
if (providerConfig.modelManagerBaseUrl && providerConfig.modelManagerApiKey) {
|
|
233
|
+
providers.push(new ModelManagerProvider(providerConfig.modelManagerBaseUrl, providerConfig.modelManagerApiKey));
|
|
234
|
+
}
|
|
235
|
+
if (providers.length === 0) {
|
|
236
|
+
throw new Error('BaseAgent provider config requires at least one provider (set anthropicApiKey or modelManagerBaseUrl + modelManagerApiKey)');
|
|
237
|
+
}
|
|
238
|
+
// Determine primary/fallback providers
|
|
239
|
+
const hasBothProviders = providers.length > 1;
|
|
240
|
+
const primaryProvider = providerConfig.primaryProvider
|
|
241
|
+
|| (providerConfig.modelManagerBaseUrl ? 'model-manager' : 'anthropic');
|
|
242
|
+
const fallbackProvider = providerConfig.fallbackProvider
|
|
243
|
+
|| (hasBothProviders ? (primaryProvider === 'model-manager' ? 'anthropic' : 'model-manager') : undefined);
|
|
244
|
+
const config = {
|
|
245
|
+
primaryProvider,
|
|
246
|
+
fallbackProvider,
|
|
247
|
+
retryAttempts: providerConfig.retryAttempts ?? 3,
|
|
248
|
+
retryDelayMs: providerConfig.retryDelayMs ?? 1000,
|
|
249
|
+
healthCheckIntervalMs: providerConfig.healthCheckIntervalMs ?? 60000,
|
|
250
|
+
};
|
|
251
|
+
logger.info(MODULE_AGENT, ` Creating ProviderManager: primary=${primaryProvider}, fallback=${fallbackProvider || 'none'}, providers=${providers.length}`, timer.elapsed(this.timerKey));
|
|
252
|
+
return new ProviderManager(providers, config);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
//# sourceMappingURL=base-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-agent.js","sourceRoot":"","sources":["../src/base-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,mBAAmB,C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