@adcp/client 0.2.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/LICENSE +21 -0
- package/README.md +166 -0
- package/dist/lib/agents/index.generated.d.ts +147 -0
- package/dist/lib/agents/index.generated.d.ts.map +1 -0
- package/dist/lib/agents/index.generated.js +218 -0
- package/dist/lib/agents/index.generated.js.map +1 -0
- package/dist/lib/auth/index.d.ts +22 -0
- package/dist/lib/auth/index.d.ts.map +1 -0
- package/dist/lib/auth/index.js +73 -0
- package/dist/lib/auth/index.js.map +1 -0
- package/dist/lib/core/ADCPClient.d.ts +233 -0
- package/dist/lib/core/ADCPClient.d.ts.map +1 -0
- package/dist/lib/core/ADCPClient.js +287 -0
- package/dist/lib/core/ADCPClient.js.map +1 -0
- package/dist/lib/core/ADCPMultiAgentClient.d.ts +308 -0
- package/dist/lib/core/ADCPMultiAgentClient.d.ts.map +1 -0
- package/dist/lib/core/ADCPMultiAgentClient.js +468 -0
- package/dist/lib/core/ADCPMultiAgentClient.js.map +1 -0
- package/dist/lib/core/AgentClient.d.ts +124 -0
- package/dist/lib/core/AgentClient.d.ts.map +1 -0
- package/dist/lib/core/AgentClient.js +242 -0
- package/dist/lib/core/AgentClient.js.map +1 -0
- package/dist/lib/core/ConfigurationManager.d.ts +79 -0
- package/dist/lib/core/ConfigurationManager.d.ts.map +1 -0
- package/dist/lib/core/ConfigurationManager.js +254 -0
- package/dist/lib/core/ConfigurationManager.js.map +1 -0
- package/dist/lib/core/ConversationTypes.d.ts +242 -0
- package/dist/lib/core/ConversationTypes.d.ts.map +1 -0
- package/dist/lib/core/ConversationTypes.js +5 -0
- package/dist/lib/core/ConversationTypes.js.map +1 -0
- package/dist/lib/core/ProtocolResponseParser.d.ts +45 -0
- package/dist/lib/core/ProtocolResponseParser.d.ts.map +1 -0
- package/dist/lib/core/ProtocolResponseParser.js +82 -0
- package/dist/lib/core/ProtocolResponseParser.js.map +1 -0
- package/dist/lib/core/TaskExecutor.d.ts +108 -0
- package/dist/lib/core/TaskExecutor.d.ts.map +1 -0
- package/dist/lib/core/TaskExecutor.js +422 -0
- package/dist/lib/core/TaskExecutor.js.map +1 -0
- package/dist/lib/errors/index.d.ts +125 -0
- package/dist/lib/errors/index.d.ts.map +1 -0
- package/dist/lib/errors/index.js +211 -0
- package/dist/lib/errors/index.js.map +1 -0
- package/dist/lib/handlers/types.d.ts +119 -0
- package/dist/lib/handlers/types.d.ts.map +1 -0
- package/dist/lib/handlers/types.js +239 -0
- package/dist/lib/handlers/types.js.map +1 -0
- package/dist/lib/index.d.ts +51 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +122 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/protocols/a2a.d.ts +2 -0
- package/dist/lib/protocols/a2a.d.ts.map +1 -0
- package/dist/lib/protocols/a2a.js +70 -0
- package/dist/lib/protocols/a2a.js.map +1 -0
- package/dist/lib/protocols/index.d.ts +22 -0
- package/dist/lib/protocols/index.d.ts.map +1 -0
- package/dist/lib/protocols/index.js +47 -0
- package/dist/lib/protocols/index.js.map +1 -0
- package/dist/lib/protocols/mcp.d.ts +2 -0
- package/dist/lib/protocols/mcp.d.ts.map +1 -0
- package/dist/lib/protocols/mcp.js +127 -0
- package/dist/lib/protocols/mcp.js.map +1 -0
- package/dist/lib/storage/MemoryStorage.d.ts +93 -0
- package/dist/lib/storage/MemoryStorage.d.ts.map +1 -0
- package/dist/lib/storage/MemoryStorage.js +219 -0
- package/dist/lib/storage/MemoryStorage.js.map +1 -0
- package/dist/lib/storage/interfaces.d.ts +195 -0
- package/dist/lib/storage/interfaces.d.ts.map +1 -0
- package/dist/lib/storage/interfaces.js +5 -0
- package/dist/lib/storage/interfaces.js.map +1 -0
- package/dist/lib/types/adcp.d.ts +407 -0
- package/dist/lib/types/adcp.d.ts.map +1 -0
- package/dist/lib/types/adcp.js +5 -0
- package/dist/lib/types/adcp.js.map +1 -0
- package/dist/lib/types/core.generated.d.ts +469 -0
- package/dist/lib/types/core.generated.d.ts.map +1 -0
- package/dist/lib/types/core.generated.js +5 -0
- package/dist/lib/types/core.generated.js.map +1 -0
- package/dist/lib/types/index.d.ts +3 -0
- package/dist/lib/types/index.d.ts.map +1 -0
- package/dist/lib/types/index.js +19 -0
- package/dist/lib/types/index.js.map +1 -0
- package/dist/lib/types/tools.generated.d.ts +1674 -0
- package/dist/lib/types/tools.generated.d.ts.map +1 -0
- package/dist/lib/types/tools.generated.js +8 -0
- package/dist/lib/types/tools.generated.js.map +1 -0
- package/dist/lib/utils/index.d.ts +25 -0
- package/dist/lib/utils/index.d.ts.map +1 -0
- package/dist/lib/utils/index.js +109 -0
- package/dist/lib/utils/index.js.map +1 -0
- package/dist/lib/validation/index.d.ts +29 -0
- package/dist/lib/validation/index.d.ts.map +1 -0
- package/dist/lib/validation/index.js +186 -0
- package/dist/lib/validation/index.js.map +1 -0
- package/dist/lib/version.d.ts +22 -0
- package/dist/lib/version.d.ts.map +1 -0
- package/dist/lib/version.js +32 -0
- package/dist/lib/version.js.map +1 -0
- package/package.json +108 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Per-agent client wrapper with conversation context preservation
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.AgentClient = void 0;
|
|
5
|
+
const ADCPClient_1 = require("./ADCPClient");
|
|
6
|
+
/**
|
|
7
|
+
* Per-agent client that maintains conversation context across calls
|
|
8
|
+
*
|
|
9
|
+
* This wrapper provides a persistent conversation context for a single agent,
|
|
10
|
+
* making it easy to have multi-turn conversations and maintain state.
|
|
11
|
+
*/
|
|
12
|
+
class AgentClient {
|
|
13
|
+
agent;
|
|
14
|
+
config;
|
|
15
|
+
client;
|
|
16
|
+
currentContextId;
|
|
17
|
+
constructor(agent, config = {}) {
|
|
18
|
+
this.agent = agent;
|
|
19
|
+
this.config = config;
|
|
20
|
+
this.client = new ADCPClient_1.ADCPClient(agent, config);
|
|
21
|
+
}
|
|
22
|
+
// ====== MEDIA BUY TASKS ======
|
|
23
|
+
/**
|
|
24
|
+
* Discover available advertising products
|
|
25
|
+
*/
|
|
26
|
+
async getProducts(params, inputHandler, options) {
|
|
27
|
+
const result = await this.client.getProducts(params, inputHandler, { ...options, contextId: this.currentContextId });
|
|
28
|
+
if (result.success) {
|
|
29
|
+
this.currentContextId = result.metadata.taskId;
|
|
30
|
+
}
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* List available creative formats
|
|
35
|
+
*/
|
|
36
|
+
async listCreativeFormats(params, inputHandler, options) {
|
|
37
|
+
const result = await this.client.listCreativeFormats(params, inputHandler, { ...options, contextId: this.currentContextId });
|
|
38
|
+
if (result.success) {
|
|
39
|
+
this.currentContextId = result.metadata.taskId;
|
|
40
|
+
}
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Create a new media buy
|
|
45
|
+
*/
|
|
46
|
+
async createMediaBuy(params, inputHandler, options) {
|
|
47
|
+
const result = await this.client.createMediaBuy(params, inputHandler, { ...options, contextId: this.currentContextId });
|
|
48
|
+
if (result.success) {
|
|
49
|
+
this.currentContextId = result.metadata.taskId;
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Update an existing media buy
|
|
55
|
+
*/
|
|
56
|
+
async updateMediaBuy(params, inputHandler, options) {
|
|
57
|
+
const result = await this.client.updateMediaBuy(params, inputHandler, { ...options, contextId: this.currentContextId });
|
|
58
|
+
if (result.success) {
|
|
59
|
+
this.currentContextId = result.metadata.taskId;
|
|
60
|
+
}
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Sync creative assets
|
|
65
|
+
*/
|
|
66
|
+
async syncCreatives(params, inputHandler, options) {
|
|
67
|
+
const result = await this.client.syncCreatives(params, inputHandler, { ...options, contextId: this.currentContextId });
|
|
68
|
+
if (result.success) {
|
|
69
|
+
this.currentContextId = result.metadata.taskId;
|
|
70
|
+
}
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* List creative assets
|
|
75
|
+
*/
|
|
76
|
+
async listCreatives(params, inputHandler, options) {
|
|
77
|
+
const result = await this.client.listCreatives(params, inputHandler, { ...options, contextId: this.currentContextId });
|
|
78
|
+
if (result.success) {
|
|
79
|
+
this.currentContextId = result.metadata.taskId;
|
|
80
|
+
}
|
|
81
|
+
return result;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Get media buy delivery information
|
|
85
|
+
*/
|
|
86
|
+
async getMediaBuyDelivery(params, inputHandler, options) {
|
|
87
|
+
const result = await this.client.getMediaBuyDelivery(params, inputHandler, { ...options, contextId: this.currentContextId });
|
|
88
|
+
if (result.success) {
|
|
89
|
+
this.currentContextId = result.metadata.taskId;
|
|
90
|
+
}
|
|
91
|
+
return result;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* List authorized properties
|
|
95
|
+
*/
|
|
96
|
+
async listAuthorizedProperties(params, inputHandler, options) {
|
|
97
|
+
const result = await this.client.listAuthorizedProperties(params, inputHandler, { ...options, contextId: this.currentContextId });
|
|
98
|
+
if (result.success) {
|
|
99
|
+
this.currentContextId = result.metadata.taskId;
|
|
100
|
+
}
|
|
101
|
+
return result;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Provide performance feedback
|
|
105
|
+
*/
|
|
106
|
+
async providePerformanceFeedback(params, inputHandler, options) {
|
|
107
|
+
const result = await this.client.providePerformanceFeedback(params, inputHandler, { ...options, contextId: this.currentContextId });
|
|
108
|
+
if (result.success) {
|
|
109
|
+
this.currentContextId = result.metadata.taskId;
|
|
110
|
+
}
|
|
111
|
+
return result;
|
|
112
|
+
}
|
|
113
|
+
// ====== SIGNALS TASKS ======
|
|
114
|
+
/**
|
|
115
|
+
* Get audience signals
|
|
116
|
+
*/
|
|
117
|
+
async getSignals(params, inputHandler, options) {
|
|
118
|
+
const result = await this.client.getSignals(params, inputHandler, { ...options, contextId: this.currentContextId });
|
|
119
|
+
if (result.success) {
|
|
120
|
+
this.currentContextId = result.metadata.taskId;
|
|
121
|
+
}
|
|
122
|
+
return result;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Activate audience signals
|
|
126
|
+
*/
|
|
127
|
+
async activateSignal(params, inputHandler, options) {
|
|
128
|
+
const result = await this.client.activateSignal(params, inputHandler, { ...options, contextId: this.currentContextId });
|
|
129
|
+
if (result.success) {
|
|
130
|
+
this.currentContextId = result.metadata.taskId;
|
|
131
|
+
}
|
|
132
|
+
return result;
|
|
133
|
+
}
|
|
134
|
+
// ====== CONVERSATION MANAGEMENT ======
|
|
135
|
+
/**
|
|
136
|
+
* Continue the conversation with a natural language message
|
|
137
|
+
*
|
|
138
|
+
* @param message - Natural language message to send to the agent
|
|
139
|
+
* @param inputHandler - Handler for any clarification requests
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```typescript
|
|
143
|
+
* const agent = multiClient.agent('my-agent');
|
|
144
|
+
* await agent.getProducts({ brief: 'Tech products' });
|
|
145
|
+
*
|
|
146
|
+
* // Continue the conversation
|
|
147
|
+
* const refined = await agent.continueConversation(
|
|
148
|
+
* 'Focus only on laptops under $1000'
|
|
149
|
+
* );
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
async continueConversation(message, inputHandler, options) {
|
|
153
|
+
if (!this.currentContextId) {
|
|
154
|
+
throw new Error('No active conversation to continue. Start with a task method first.');
|
|
155
|
+
}
|
|
156
|
+
const result = await this.client.continueConversation(message, this.currentContextId, inputHandler);
|
|
157
|
+
if (result.success) {
|
|
158
|
+
this.currentContextId = result.metadata.taskId;
|
|
159
|
+
}
|
|
160
|
+
return result;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Get the full conversation history
|
|
164
|
+
*/
|
|
165
|
+
getHistory() {
|
|
166
|
+
if (!this.currentContextId) {
|
|
167
|
+
return undefined;
|
|
168
|
+
}
|
|
169
|
+
return this.client.getConversationHistory(this.currentContextId);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Clear the conversation context (start fresh)
|
|
173
|
+
*/
|
|
174
|
+
clearContext() {
|
|
175
|
+
if (this.currentContextId) {
|
|
176
|
+
this.client.clearConversationHistory(this.currentContextId);
|
|
177
|
+
this.currentContextId = undefined;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Get the current conversation context ID
|
|
182
|
+
*/
|
|
183
|
+
getContextId() {
|
|
184
|
+
return this.currentContextId;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Set a specific conversation context ID
|
|
188
|
+
*/
|
|
189
|
+
setContextId(contextId) {
|
|
190
|
+
this.currentContextId = contextId;
|
|
191
|
+
}
|
|
192
|
+
// ====== AGENT INFORMATION ======
|
|
193
|
+
/**
|
|
194
|
+
* Get the agent configuration
|
|
195
|
+
*/
|
|
196
|
+
getAgent() {
|
|
197
|
+
return this.client.getAgent();
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Get the agent ID
|
|
201
|
+
*/
|
|
202
|
+
getAgentId() {
|
|
203
|
+
return this.client.getAgentId();
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Get the agent name
|
|
207
|
+
*/
|
|
208
|
+
getAgentName() {
|
|
209
|
+
return this.client.getAgentName();
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Get the agent protocol
|
|
213
|
+
*/
|
|
214
|
+
getProtocol() {
|
|
215
|
+
return this.client.getProtocol();
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Check if there's an active conversation
|
|
219
|
+
*/
|
|
220
|
+
hasActiveConversation() {
|
|
221
|
+
return this.currentContextId !== undefined;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Get active tasks for this agent
|
|
225
|
+
*/
|
|
226
|
+
getActiveTasks() {
|
|
227
|
+
return this.client.getActiveTasks();
|
|
228
|
+
}
|
|
229
|
+
// ====== GENERIC TASK EXECUTION ======
|
|
230
|
+
/**
|
|
231
|
+
* Execute any task by name, maintaining conversation context
|
|
232
|
+
*/
|
|
233
|
+
async executeTask(taskName, params, inputHandler, options) {
|
|
234
|
+
const result = await this.client.executeTask(taskName, params, inputHandler, { ...options, contextId: this.currentContextId });
|
|
235
|
+
if (result.success) {
|
|
236
|
+
this.currentContextId = result.metadata.taskId;
|
|
237
|
+
}
|
|
238
|
+
return result;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
exports.AgentClient = AgentClient;
|
|
242
|
+
//# sourceMappingURL=AgentClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentClient.js","sourceRoot":"","sources":["../../../src/lib/core/AgentClient.ts"],"names":[],"mappings":";AAAA,kEAAkE;;;AAGlE,6CAAiE;AAgCjE;;;;;GAKG;AACH,MAAa,WAAW;IAKZ;IACA;IALF,MAAM,CAAa;IACnB,gBAAgB,CAAU;IAElC,YACU,KAAkB,EAClB,SAA2B,EAAE;QAD7B,UAAK,GAAL,KAAK,CAAa;QAClB,WAAM,GAAN,MAAM,CAAuB;QAErC,IAAI,CAAC,MAAM,GAAG,IAAI,uBAAU,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC9C,CAAC;IAED,gCAAgC;IAEhC;;OAEG;IACH,KAAK,CAAC,WAAW,CACf,MAA0B,EAC1B,YAA2B,EAC3B,OAAqB;QAErB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAC1C,MAAM,EACN,YAAY,EACZ,EAAE,GAAG,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,gBAAgB,EAAE,CACjD,CAAC;QAEF,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,IAAI,CAAC,gBAAgB,GAAG,MAAM,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CAAC;IAChB,CAAC;CACF;AArYD,kCAqYC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { AgentConfig } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration structure for ADCP agents
|
|
4
|
+
*/
|
|
5
|
+
export interface ADCPConfig {
|
|
6
|
+
/** Array of agent configurations */
|
|
7
|
+
agents: AgentConfig[];
|
|
8
|
+
/** Default configuration options */
|
|
9
|
+
defaults?: {
|
|
10
|
+
/** Default protocol for agents */
|
|
11
|
+
protocol?: 'mcp' | 'a2a';
|
|
12
|
+
/** Default timeout for all operations */
|
|
13
|
+
timeout?: number;
|
|
14
|
+
/** Default max clarifications */
|
|
15
|
+
maxClarifications?: number;
|
|
16
|
+
/** Enable debug mode by default */
|
|
17
|
+
debug?: boolean;
|
|
18
|
+
};
|
|
19
|
+
/** Environment-specific overrides */
|
|
20
|
+
environments?: {
|
|
21
|
+
[envName: string]: Partial<ADCPConfig>;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Enhanced configuration manager with multiple loading strategies
|
|
26
|
+
*/
|
|
27
|
+
export declare class ConfigurationManager {
|
|
28
|
+
private static readonly CONFIG_FILES;
|
|
29
|
+
private static readonly ENV_VARS;
|
|
30
|
+
/**
|
|
31
|
+
* Load agent configurations using auto-discovery
|
|
32
|
+
* Tries multiple sources in order:
|
|
33
|
+
* 1. Environment variables
|
|
34
|
+
* 2. Config files in current directory
|
|
35
|
+
* 3. Config files in project root
|
|
36
|
+
*/
|
|
37
|
+
static loadAgents(): AgentConfig[];
|
|
38
|
+
/**
|
|
39
|
+
* Load agents from environment variables
|
|
40
|
+
*/
|
|
41
|
+
static loadAgentsFromEnv(): AgentConfig[];
|
|
42
|
+
/**
|
|
43
|
+
* Load agents from config file
|
|
44
|
+
*/
|
|
45
|
+
static loadAgentsFromConfig(configPath?: string): AgentConfig[];
|
|
46
|
+
/**
|
|
47
|
+
* Extract agents array from various config formats
|
|
48
|
+
*/
|
|
49
|
+
private static extractAgents;
|
|
50
|
+
/**
|
|
51
|
+
* Log configured agents in a user-friendly way
|
|
52
|
+
*/
|
|
53
|
+
private static logAgents;
|
|
54
|
+
/**
|
|
55
|
+
* Validate agent configuration
|
|
56
|
+
*/
|
|
57
|
+
static validateAgentConfig(agent: AgentConfig): void;
|
|
58
|
+
/**
|
|
59
|
+
* Validate multiple agent configurations
|
|
60
|
+
*/
|
|
61
|
+
static validateAgentsConfig(agents: AgentConfig[]): void;
|
|
62
|
+
/**
|
|
63
|
+
* Create a sample configuration file
|
|
64
|
+
*/
|
|
65
|
+
static createSampleConfig(): ADCPConfig;
|
|
66
|
+
/**
|
|
67
|
+
* Get configuration file paths that would be checked
|
|
68
|
+
*/
|
|
69
|
+
static getConfigPaths(): string[];
|
|
70
|
+
/**
|
|
71
|
+
* Get environment variables that would be checked
|
|
72
|
+
*/
|
|
73
|
+
static getEnvVars(): string[];
|
|
74
|
+
/**
|
|
75
|
+
* Generate configuration help text
|
|
76
|
+
*/
|
|
77
|
+
static getConfigurationHelp(): string;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=ConfigurationManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfigurationManager.d.ts","sourceRoot":"","sources":["../../../src/lib/core/ConfigurationManager.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAG5C;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,oCAAoC;IACpC,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,oCAAoC;IACpC,QAAQ,CAAC,EAAE;QACT,kCAAkC;QAClC,QAAQ,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;QACzB,yCAAyC;QACzC,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,iCAAiC;QACjC,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,mCAAmC;QACnC,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB,CAAC;IACF,qCAAqC;IACrC,YAAY,CAAC,EAAE;QACb,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;KACxC,CAAC;CACH;AAED;;GAEG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAKlC;IAEF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAI9B;IAEF;;;;;;OAMG;IACH,MAAM,CAAC,UAAU,IAAI,WAAW,EAAE;IAwBlC;;OAEG;IACH,MAAM,CAAC,iBAAiB,IAAI,WAAW,EAAE;IA2BzC;;OAEG;IACH,MAAM,CAAC,oBAAoB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,WAAW,EAAE;IA+B/D;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,aAAa;IAiB5B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,SAAS;IAWxB;;OAEG;IACH,MAAM,CAAC,mBAAmB,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI;IA8BpD;;OAEG;IACH,MAAM,CAAC,oBAAoB,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI;IAuBxD;;OAEG;IACH,MAAM,CAAC,kBAAkB,IAAI,UAAU;IA4BvC;;OAEG;IACH,MAAM,CAAC,cAAc,IAAI,MAAM,EAAE;IAIjC;;OAEG;IACH,MAAM,CAAC,UAAU,IAAI,MAAM,EAAE;IAI7B;;OAEG;IACH,MAAM,CAAC,oBAAoB,IAAI,MAAM;CAqCtC"}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Enhanced configuration manager for easy ADCP client setup
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ConfigurationManager = void 0;
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const errors_1 = require("../errors");
|
|
8
|
+
/**
|
|
9
|
+
* Enhanced configuration manager with multiple loading strategies
|
|
10
|
+
*/
|
|
11
|
+
class ConfigurationManager {
|
|
12
|
+
static CONFIG_FILES = [
|
|
13
|
+
'adcp.config.json',
|
|
14
|
+
'adcp.json',
|
|
15
|
+
'.adcp.json',
|
|
16
|
+
'agents.json'
|
|
17
|
+
];
|
|
18
|
+
static ENV_VARS = [
|
|
19
|
+
'SALES_AGENTS_CONFIG',
|
|
20
|
+
'ADCP_AGENTS_CONFIG',
|
|
21
|
+
'ADCP_CONFIG'
|
|
22
|
+
];
|
|
23
|
+
/**
|
|
24
|
+
* Load agent configurations using auto-discovery
|
|
25
|
+
* Tries multiple sources in order:
|
|
26
|
+
* 1. Environment variables
|
|
27
|
+
* 2. Config files in current directory
|
|
28
|
+
* 3. Config files in project root
|
|
29
|
+
*/
|
|
30
|
+
static loadAgents() {
|
|
31
|
+
// Try environment variables first
|
|
32
|
+
const envAgents = this.loadAgentsFromEnv();
|
|
33
|
+
if (envAgents.length > 0) {
|
|
34
|
+
return envAgents;
|
|
35
|
+
}
|
|
36
|
+
// Try config files
|
|
37
|
+
const configAgents = this.loadAgentsFromConfig();
|
|
38
|
+
if (configAgents.length > 0) {
|
|
39
|
+
return configAgents;
|
|
40
|
+
}
|
|
41
|
+
// No configuration found
|
|
42
|
+
console.warn('⚠️ No ADCP agent configuration found');
|
|
43
|
+
console.log('💡 To configure agents, you can:');
|
|
44
|
+
console.log(' 1. Set SALES_AGENTS_CONFIG environment variable');
|
|
45
|
+
console.log(' 2. Create an adcp.config.json file');
|
|
46
|
+
console.log(' 3. Pass agents directly to the constructor');
|
|
47
|
+
console.log('\n📖 See documentation for configuration examples');
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Load agents from environment variables
|
|
52
|
+
*/
|
|
53
|
+
static loadAgentsFromEnv() {
|
|
54
|
+
for (const envVar of this.ENV_VARS) {
|
|
55
|
+
const configEnv = process.env[envVar];
|
|
56
|
+
if (configEnv) {
|
|
57
|
+
try {
|
|
58
|
+
const config = JSON.parse(configEnv);
|
|
59
|
+
const agents = this.extractAgents(config);
|
|
60
|
+
if (agents.length > 0) {
|
|
61
|
+
console.log(`📡 Loaded ${agents.length} agents from ${envVar}`);
|
|
62
|
+
this.logAgents(agents);
|
|
63
|
+
return agents;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
68
|
+
console.error(`❌ Failed to parse ${envVar}:`, errorMessage);
|
|
69
|
+
throw new errors_1.ConfigurationError(`Invalid JSON in ${envVar}: ${errorMessage}`, envVar);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return [];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Load agents from config file
|
|
77
|
+
*/
|
|
78
|
+
static loadAgentsFromConfig(configPath) {
|
|
79
|
+
const filesToTry = configPath ? [configPath] : this.CONFIG_FILES;
|
|
80
|
+
for (const file of filesToTry) {
|
|
81
|
+
const fullPath = (0, path_1.resolve)(file);
|
|
82
|
+
if ((0, fs_1.existsSync)(fullPath)) {
|
|
83
|
+
try {
|
|
84
|
+
const content = (0, fs_1.readFileSync)(fullPath, 'utf8');
|
|
85
|
+
const config = JSON.parse(content);
|
|
86
|
+
const agents = this.extractAgents(config);
|
|
87
|
+
if (agents.length > 0) {
|
|
88
|
+
console.log(`📁 Loaded ${agents.length} agents from ${file}`);
|
|
89
|
+
this.logAgents(agents);
|
|
90
|
+
return agents;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
95
|
+
console.error(`❌ Failed to load config from ${file}:`, errorMessage);
|
|
96
|
+
throw new errors_1.ConfigurationError(`Invalid config file ${file}: ${errorMessage}`, 'configFile');
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return [];
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Extract agents array from various config formats
|
|
104
|
+
*/
|
|
105
|
+
static extractAgents(config) {
|
|
106
|
+
// Handle different config formats
|
|
107
|
+
if (Array.isArray(config)) {
|
|
108
|
+
return config; // Direct agent array
|
|
109
|
+
}
|
|
110
|
+
if (config.agents && Array.isArray(config.agents)) {
|
|
111
|
+
return config.agents; // Standard format: { agents: [...] }
|
|
112
|
+
}
|
|
113
|
+
if (config.data?.agents && Array.isArray(config.data.agents)) {
|
|
114
|
+
return config.data.agents; // Nested format: { data: { agents: [...] } }
|
|
115
|
+
}
|
|
116
|
+
return [];
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Log configured agents in a user-friendly way
|
|
120
|
+
*/
|
|
121
|
+
static logAgents(agents) {
|
|
122
|
+
agents.forEach((agent) => {
|
|
123
|
+
const protocolIcon = agent.protocol === 'mcp' ? '🔗' : '⚡';
|
|
124
|
+
const authIcon = agent.requiresAuth ? '🔐' : '🌐';
|
|
125
|
+
console.log(` ${protocolIcon}${authIcon} ${agent.name} (${agent.protocol.toUpperCase()}) at ${agent.agent_uri}`);
|
|
126
|
+
});
|
|
127
|
+
const useRealAgents = process.env.USE_REAL_AGENTS === 'true';
|
|
128
|
+
console.log(`🔧 Real agents mode: ${useRealAgents ? 'ENABLED' : 'DISABLED'}`);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Validate agent configuration
|
|
132
|
+
*/
|
|
133
|
+
static validateAgentConfig(agent) {
|
|
134
|
+
const required = ['id', 'name', 'agent_uri', 'protocol'];
|
|
135
|
+
for (const field of required) {
|
|
136
|
+
if (!agent[field]) {
|
|
137
|
+
throw new errors_1.ConfigurationError(`Agent configuration missing required field: ${field}`, field);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (!['mcp', 'a2a'].includes(agent.protocol)) {
|
|
141
|
+
throw new errors_1.ConfigurationError(`Invalid protocol "${agent.protocol}". Must be "mcp" or "a2a"`, 'protocol');
|
|
142
|
+
}
|
|
143
|
+
// Basic URL validation
|
|
144
|
+
try {
|
|
145
|
+
new URL(agent.agent_uri);
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
throw new errors_1.ConfigurationError(`Invalid agent_uri "${agent.agent_uri}". Must be a valid URL`, 'agent_uri');
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Validate multiple agent configurations
|
|
153
|
+
*/
|
|
154
|
+
static validateAgentsConfig(agents) {
|
|
155
|
+
if (!Array.isArray(agents)) {
|
|
156
|
+
throw new errors_1.ConfigurationError('Agents configuration must be an array');
|
|
157
|
+
}
|
|
158
|
+
if (agents.length === 0) {
|
|
159
|
+
throw new errors_1.ConfigurationError('At least one agent must be configured');
|
|
160
|
+
}
|
|
161
|
+
// Check for duplicate IDs
|
|
162
|
+
const ids = agents.map(a => a.id);
|
|
163
|
+
const duplicates = ids.filter((id, index) => ids.indexOf(id) !== index);
|
|
164
|
+
if (duplicates.length > 0) {
|
|
165
|
+
throw new errors_1.ConfigurationError(`Duplicate agent IDs found: ${duplicates.join(', ')}`, 'duplicateIds');
|
|
166
|
+
}
|
|
167
|
+
// Validate each agent
|
|
168
|
+
agents.forEach(agent => this.validateAgentConfig(agent));
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Create a sample configuration file
|
|
172
|
+
*/
|
|
173
|
+
static createSampleConfig() {
|
|
174
|
+
return {
|
|
175
|
+
agents: [
|
|
176
|
+
{
|
|
177
|
+
id: 'premium-network',
|
|
178
|
+
name: 'Premium Ad Network',
|
|
179
|
+
agent_uri: 'https://premium-ads.example.com/mcp/',
|
|
180
|
+
protocol: 'mcp',
|
|
181
|
+
requiresAuth: true,
|
|
182
|
+
auth_token_env: 'PREMIUM_AGENT_TOKEN'
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
id: 'budget-network',
|
|
186
|
+
name: 'Budget Ad Network',
|
|
187
|
+
agent_uri: 'https://budget-ads.example.com/a2a/',
|
|
188
|
+
protocol: 'a2a',
|
|
189
|
+
requiresAuth: false
|
|
190
|
+
}
|
|
191
|
+
],
|
|
192
|
+
defaults: {
|
|
193
|
+
protocol: 'mcp',
|
|
194
|
+
timeout: 30000,
|
|
195
|
+
maxClarifications: 3,
|
|
196
|
+
debug: false
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Get configuration file paths that would be checked
|
|
202
|
+
*/
|
|
203
|
+
static getConfigPaths() {
|
|
204
|
+
return this.CONFIG_FILES.map(file => (0, path_1.resolve)(file));
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Get environment variables that would be checked
|
|
208
|
+
*/
|
|
209
|
+
static getEnvVars() {
|
|
210
|
+
return this.ENV_VARS;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Generate configuration help text
|
|
214
|
+
*/
|
|
215
|
+
static getConfigurationHelp() {
|
|
216
|
+
return `
|
|
217
|
+
🔧 ADCP Agent Configuration
|
|
218
|
+
|
|
219
|
+
The ADCP client can load agents from multiple sources:
|
|
220
|
+
|
|
221
|
+
1️⃣ Environment Variables:
|
|
222
|
+
Set any of: ${this.ENV_VARS.join(', ')}
|
|
223
|
+
|
|
224
|
+
Example:
|
|
225
|
+
export SALES_AGENTS_CONFIG='{"agents":[{"id":"my-agent","name":"My Agent","agent_uri":"https://agent.example.com","protocol":"mcp"}]}'
|
|
226
|
+
|
|
227
|
+
2️⃣ Configuration Files:
|
|
228
|
+
Create any of: ${this.CONFIG_FILES.join(', ')}
|
|
229
|
+
|
|
230
|
+
Example adcp.config.json:
|
|
231
|
+
{
|
|
232
|
+
"agents": [
|
|
233
|
+
{
|
|
234
|
+
"id": "premium-agent",
|
|
235
|
+
"name": "Premium Ad Network",
|
|
236
|
+
"agent_uri": "https://premium.example.com",
|
|
237
|
+
"protocol": "mcp",
|
|
238
|
+
"requiresAuth": true,
|
|
239
|
+
"auth_token_env": "PREMIUM_TOKEN"
|
|
240
|
+
}
|
|
241
|
+
]
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
3️⃣ Programmatic Configuration:
|
|
245
|
+
const client = new ADCPMultiAgentClient([
|
|
246
|
+
{ id: 'agent', agent_uri: 'https://...', protocol: 'mcp' }
|
|
247
|
+
]);
|
|
248
|
+
|
|
249
|
+
📖 For more examples, see the documentation.
|
|
250
|
+
`;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
exports.ConfigurationManager = ConfigurationManager;
|
|
254
|
+
//# sourceMappingURL=ConfigurationManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfigurationManager.js","sourceRoot":"","sources":["../../../src/lib/core/ConfigurationManager.ts"],"names":[],"mappings":";AAAA,4DAA4D;;;AAE5D,2BAA8C;AAC9C,+BAAqC;AAErC,sCAA+C;AAyB/C;;GAEG;AACH,MAAa,oBAAoB;IACvB,MAAM,CAAU,YAAY,GAAG;QACrC,kBAAkB;QAClB,WAAW;QACX,YAAY;QACZ,aAAa;KACd,CAAC;IAEM,MAAM,CAAU,QAAQ,GAAG;QACjC,qBAAqB;QACrB,oBAAoB;QACpB,aAAa;KACd,CAAC;IAEF;;;;;;OAMG;IACH,MAAM,CAAC,UAAU;QACf,kCAAkC;QAClC,MAAM,SAAS,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAC3C,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzB,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,mBAAmB;QACnB,MAAM,YAAY,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC;QACjD,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC5B,OAAO,YAAY,CAAC;QACtB,CAAC;QAED,yBAAyB;QACzB,OAAO,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;QACtD,OAAO,CAAC,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