@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.
Files changed (99) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +166 -0
  3. package/dist/lib/agents/index.generated.d.ts +147 -0
  4. package/dist/lib/agents/index.generated.d.ts.map +1 -0
  5. package/dist/lib/agents/index.generated.js +218 -0
  6. package/dist/lib/agents/index.generated.js.map +1 -0
  7. package/dist/lib/auth/index.d.ts +22 -0
  8. package/dist/lib/auth/index.d.ts.map +1 -0
  9. package/dist/lib/auth/index.js +73 -0
  10. package/dist/lib/auth/index.js.map +1 -0
  11. package/dist/lib/core/ADCPClient.d.ts +233 -0
  12. package/dist/lib/core/ADCPClient.d.ts.map +1 -0
  13. package/dist/lib/core/ADCPClient.js +287 -0
  14. package/dist/lib/core/ADCPClient.js.map +1 -0
  15. package/dist/lib/core/ADCPMultiAgentClient.d.ts +308 -0
  16. package/dist/lib/core/ADCPMultiAgentClient.d.ts.map +1 -0
  17. package/dist/lib/core/ADCPMultiAgentClient.js +468 -0
  18. package/dist/lib/core/ADCPMultiAgentClient.js.map +1 -0
  19. package/dist/lib/core/AgentClient.d.ts +124 -0
  20. package/dist/lib/core/AgentClient.d.ts.map +1 -0
  21. package/dist/lib/core/AgentClient.js +242 -0
  22. package/dist/lib/core/AgentClient.js.map +1 -0
  23. package/dist/lib/core/ConfigurationManager.d.ts +79 -0
  24. package/dist/lib/core/ConfigurationManager.d.ts.map +1 -0
  25. package/dist/lib/core/ConfigurationManager.js +254 -0
  26. package/dist/lib/core/ConfigurationManager.js.map +1 -0
  27. package/dist/lib/core/ConversationTypes.d.ts +242 -0
  28. package/dist/lib/core/ConversationTypes.d.ts.map +1 -0
  29. package/dist/lib/core/ConversationTypes.js +5 -0
  30. package/dist/lib/core/ConversationTypes.js.map +1 -0
  31. package/dist/lib/core/ProtocolResponseParser.d.ts +45 -0
  32. package/dist/lib/core/ProtocolResponseParser.d.ts.map +1 -0
  33. package/dist/lib/core/ProtocolResponseParser.js +82 -0
  34. package/dist/lib/core/ProtocolResponseParser.js.map +1 -0
  35. package/dist/lib/core/TaskExecutor.d.ts +108 -0
  36. package/dist/lib/core/TaskExecutor.d.ts.map +1 -0
  37. package/dist/lib/core/TaskExecutor.js +422 -0
  38. package/dist/lib/core/TaskExecutor.js.map +1 -0
  39. package/dist/lib/errors/index.d.ts +125 -0
  40. package/dist/lib/errors/index.d.ts.map +1 -0
  41. package/dist/lib/errors/index.js +211 -0
  42. package/dist/lib/errors/index.js.map +1 -0
  43. package/dist/lib/handlers/types.d.ts +119 -0
  44. package/dist/lib/handlers/types.d.ts.map +1 -0
  45. package/dist/lib/handlers/types.js +239 -0
  46. package/dist/lib/handlers/types.js.map +1 -0
  47. package/dist/lib/index.d.ts +51 -0
  48. package/dist/lib/index.d.ts.map +1 -0
  49. package/dist/lib/index.js +122 -0
  50. package/dist/lib/index.js.map +1 -0
  51. package/dist/lib/protocols/a2a.d.ts +2 -0
  52. package/dist/lib/protocols/a2a.d.ts.map +1 -0
  53. package/dist/lib/protocols/a2a.js +70 -0
  54. package/dist/lib/protocols/a2a.js.map +1 -0
  55. package/dist/lib/protocols/index.d.ts +22 -0
  56. package/dist/lib/protocols/index.d.ts.map +1 -0
  57. package/dist/lib/protocols/index.js +47 -0
  58. package/dist/lib/protocols/index.js.map +1 -0
  59. package/dist/lib/protocols/mcp.d.ts +2 -0
  60. package/dist/lib/protocols/mcp.d.ts.map +1 -0
  61. package/dist/lib/protocols/mcp.js +127 -0
  62. package/dist/lib/protocols/mcp.js.map +1 -0
  63. package/dist/lib/storage/MemoryStorage.d.ts +93 -0
  64. package/dist/lib/storage/MemoryStorage.d.ts.map +1 -0
  65. package/dist/lib/storage/MemoryStorage.js +219 -0
  66. package/dist/lib/storage/MemoryStorage.js.map +1 -0
  67. package/dist/lib/storage/interfaces.d.ts +195 -0
  68. package/dist/lib/storage/interfaces.d.ts.map +1 -0
  69. package/dist/lib/storage/interfaces.js +5 -0
  70. package/dist/lib/storage/interfaces.js.map +1 -0
  71. package/dist/lib/types/adcp.d.ts +407 -0
  72. package/dist/lib/types/adcp.d.ts.map +1 -0
  73. package/dist/lib/types/adcp.js +5 -0
  74. package/dist/lib/types/adcp.js.map +1 -0
  75. package/dist/lib/types/core.generated.d.ts +469 -0
  76. package/dist/lib/types/core.generated.d.ts.map +1 -0
  77. package/dist/lib/types/core.generated.js +5 -0
  78. package/dist/lib/types/core.generated.js.map +1 -0
  79. package/dist/lib/types/index.d.ts +3 -0
  80. package/dist/lib/types/index.d.ts.map +1 -0
  81. package/dist/lib/types/index.js +19 -0
  82. package/dist/lib/types/index.js.map +1 -0
  83. package/dist/lib/types/tools.generated.d.ts +1674 -0
  84. package/dist/lib/types/tools.generated.d.ts.map +1 -0
  85. package/dist/lib/types/tools.generated.js +8 -0
  86. package/dist/lib/types/tools.generated.js.map +1 -0
  87. package/dist/lib/utils/index.d.ts +25 -0
  88. package/dist/lib/utils/index.d.ts.map +1 -0
  89. package/dist/lib/utils/index.js +109 -0
  90. package/dist/lib/utils/index.js.map +1 -0
  91. package/dist/lib/validation/index.d.ts +29 -0
  92. package/dist/lib/validation/index.d.ts.map +1 -0
  93. package/dist/lib/validation/index.js +186 -0
  94. package/dist/lib/validation/index.js.map +1 -0
  95. package/dist/lib/version.d.ts +22 -0
  96. package/dist/lib/version.d.ts.map +1 -0
  97. package/dist/lib/version.js +32 -0
  98. package/dist/lib/version.js.map +1 -0
  99. package/package.json +108 -0
@@ -0,0 +1,233 @@
1
+ import type { AgentConfig } from '../types';
2
+ import type { GetProductsRequest, GetProductsResponse, ListCreativeFormatsRequest, ListCreativeFormatsResponse, CreateMediaBuyRequest, CreateMediaBuyResponse, UpdateMediaBuyRequest, UpdateMediaBuyResponse, SyncCreativesRequest, SyncCreativesResponse, ListCreativesRequest, ListCreativesResponse, GetMediaBuyDeliveryRequest, GetMediaBuyDeliveryResponse, ListAuthorizedPropertiesRequest, ListAuthorizedPropertiesResponse, ProvidePerformanceFeedbackRequest, ProvidePerformanceFeedbackResponse, GetSignalsRequest, GetSignalsResponse, ActivateSignalRequest, ActivateSignalResponse } from '../types/tools.generated';
3
+ import type { InputHandler, TaskOptions, TaskResult, ConversationConfig } from './ConversationTypes';
4
+ /**
5
+ * Configuration for ADCPClient
6
+ */
7
+ export interface ADCPClientConfig extends ConversationConfig {
8
+ /** Enable debug logging */
9
+ debug?: boolean;
10
+ /** Custom user agent string */
11
+ userAgent?: string;
12
+ /** Additional headers to include in requests */
13
+ headers?: Record<string, string>;
14
+ }
15
+ /**
16
+ * Main ADCP Client providing strongly-typed conversation-aware interface
17
+ *
18
+ * This client handles individual agent interactions with full conversation context.
19
+ * For multi-agent operations, use ADCPMultiAgentClient or compose multiple instances.
20
+ *
21
+ * Key features:
22
+ * - 🔒 Full type safety for all ADCP tasks
23
+ * - 💬 Conversation management with context preservation
24
+ * - 🔄 Input handler pattern for clarifications
25
+ * - ⏱️ Timeout and retry support
26
+ * - 🐛 Debug logging and observability
27
+ * - 🎯 Works with both MCP and A2A protocols
28
+ */
29
+ export declare class ADCPClient {
30
+ private agent;
31
+ private config;
32
+ private executor;
33
+ constructor(agent: AgentConfig, config?: ADCPClientConfig);
34
+ /**
35
+ * Discover available advertising products
36
+ *
37
+ * @param params - Product discovery parameters
38
+ * @param inputHandler - Handler for clarification requests
39
+ * @param options - Task execution options
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * const products = await client.getProducts(
44
+ * {
45
+ * brief: 'Premium coffee brands for millennials',
46
+ * promoted_offering: 'Artisan coffee blends'
47
+ * },
48
+ * (context) => {
49
+ * if (context.inputRequest.field === 'budget') return 50000;
50
+ * return context.deferToHuman();
51
+ * }
52
+ * );
53
+ * ```
54
+ */
55
+ getProducts(params: GetProductsRequest, inputHandler?: InputHandler, options?: TaskOptions): Promise<TaskResult<GetProductsResponse>>;
56
+ /**
57
+ * List available creative formats
58
+ *
59
+ * @param params - Format listing parameters
60
+ * @param inputHandler - Handler for clarification requests
61
+ * @param options - Task execution options
62
+ */
63
+ listCreativeFormats(params: ListCreativeFormatsRequest, inputHandler?: InputHandler, options?: TaskOptions): Promise<TaskResult<ListCreativeFormatsResponse>>;
64
+ /**
65
+ * Create a new media buy
66
+ *
67
+ * @param params - Media buy creation parameters
68
+ * @param inputHandler - Handler for clarification requests
69
+ * @param options - Task execution options
70
+ */
71
+ createMediaBuy(params: CreateMediaBuyRequest, inputHandler?: InputHandler, options?: TaskOptions): Promise<TaskResult<CreateMediaBuyResponse>>;
72
+ /**
73
+ * Update an existing media buy
74
+ *
75
+ * @param params - Media buy update parameters
76
+ * @param inputHandler - Handler for clarification requests
77
+ * @param options - Task execution options
78
+ */
79
+ updateMediaBuy(params: UpdateMediaBuyRequest, inputHandler?: InputHandler, options?: TaskOptions): Promise<TaskResult<UpdateMediaBuyResponse>>;
80
+ /**
81
+ * Sync creative assets
82
+ *
83
+ * @param params - Creative sync parameters
84
+ * @param inputHandler - Handler for clarification requests
85
+ * @param options - Task execution options
86
+ */
87
+ syncCreatives(params: SyncCreativesRequest, inputHandler?: InputHandler, options?: TaskOptions): Promise<TaskResult<SyncCreativesResponse>>;
88
+ /**
89
+ * List creative assets
90
+ *
91
+ * @param params - Creative listing parameters
92
+ * @param inputHandler - Handler for clarification requests
93
+ * @param options - Task execution options
94
+ */
95
+ listCreatives(params: ListCreativesRequest, inputHandler?: InputHandler, options?: TaskOptions): Promise<TaskResult<ListCreativesResponse>>;
96
+ /**
97
+ * Get media buy delivery information
98
+ *
99
+ * @param params - Delivery information parameters
100
+ * @param inputHandler - Handler for clarification requests
101
+ * @param options - Task execution options
102
+ */
103
+ getMediaBuyDelivery(params: GetMediaBuyDeliveryRequest, inputHandler?: InputHandler, options?: TaskOptions): Promise<TaskResult<GetMediaBuyDeliveryResponse>>;
104
+ /**
105
+ * List authorized properties
106
+ *
107
+ * @param params - Property listing parameters
108
+ * @param inputHandler - Handler for clarification requests
109
+ * @param options - Task execution options
110
+ */
111
+ listAuthorizedProperties(params: ListAuthorizedPropertiesRequest, inputHandler?: InputHandler, options?: TaskOptions): Promise<TaskResult<ListAuthorizedPropertiesResponse>>;
112
+ /**
113
+ * Provide performance feedback
114
+ *
115
+ * @param params - Performance feedback parameters
116
+ * @param inputHandler - Handler for clarification requests
117
+ * @param options - Task execution options
118
+ */
119
+ providePerformanceFeedback(params: ProvidePerformanceFeedbackRequest, inputHandler?: InputHandler, options?: TaskOptions): Promise<TaskResult<ProvidePerformanceFeedbackResponse>>;
120
+ /**
121
+ * Get audience signals
122
+ *
123
+ * @param params - Signals request parameters
124
+ * @param inputHandler - Handler for clarification requests
125
+ * @param options - Task execution options
126
+ */
127
+ getSignals(params: GetSignalsRequest, inputHandler?: InputHandler, options?: TaskOptions): Promise<TaskResult<GetSignalsResponse>>;
128
+ /**
129
+ * Activate audience signals
130
+ *
131
+ * @param params - Signal activation parameters
132
+ * @param inputHandler - Handler for clarification requests
133
+ * @param options - Task execution options
134
+ */
135
+ activateSignal(params: ActivateSignalRequest, inputHandler?: InputHandler, options?: TaskOptions): Promise<TaskResult<ActivateSignalResponse>>;
136
+ /**
137
+ * Execute any task by name with type safety
138
+ *
139
+ * @param taskName - Name of the task to execute
140
+ * @param params - Task parameters
141
+ * @param inputHandler - Handler for clarification requests
142
+ * @param options - Task execution options
143
+ *
144
+ * @example
145
+ * ```typescript
146
+ * const result = await client.executeTask(
147
+ * 'get_products',
148
+ * { brief: 'Coffee brands' },
149
+ * handler
150
+ * );
151
+ * ```
152
+ */
153
+ executeTask<T = any>(taskName: string, params: any, inputHandler?: InputHandler, options?: TaskOptions): Promise<TaskResult<T>>;
154
+ /**
155
+ * Resume a deferred task using its token
156
+ *
157
+ * @param token - Deferred task token
158
+ * @param inputHandler - Handler to provide the missing input
159
+ *
160
+ * @example
161
+ * ```typescript
162
+ * try {
163
+ * await client.createMediaBuy(params, handler);
164
+ * } catch (error) {
165
+ * if (error instanceof DeferredTaskError) {
166
+ * // Get human input and resume
167
+ * const result = await client.resumeDeferredTask(
168
+ * error.token,
169
+ * (context) => humanProvidedValue
170
+ * );
171
+ * }
172
+ * }
173
+ * ```
174
+ */
175
+ resumeDeferredTask<T = any>(token: string, inputHandler: InputHandler): Promise<TaskResult<T>>;
176
+ /**
177
+ * Continue an existing conversation with the agent
178
+ *
179
+ * @param message - Message to send to the agent
180
+ * @param contextId - Conversation context ID to continue
181
+ * @param inputHandler - Handler for any clarification requests
182
+ *
183
+ * @example
184
+ * ```typescript
185
+ * const agent = new ADCPClient(config);
186
+ * const initial = await agent.getProducts({ brief: 'Tech products' });
187
+ *
188
+ * // Continue the conversation
189
+ * const refined = await agent.continueConversation(
190
+ * 'Focus only on laptops under $1000',
191
+ * initial.metadata.taskId
192
+ * );
193
+ * ```
194
+ */
195
+ continueConversation<T = any>(message: string, contextId: string, inputHandler?: InputHandler): Promise<TaskResult<T>>;
196
+ /**
197
+ * Get conversation history for a task
198
+ */
199
+ getConversationHistory(taskId: string): import("./ConversationTypes").Message[] | undefined;
200
+ /**
201
+ * Clear conversation history for a task
202
+ */
203
+ clearConversationHistory(taskId: string): void;
204
+ /**
205
+ * Get the agent configuration
206
+ */
207
+ getAgent(): AgentConfig;
208
+ /**
209
+ * Get the agent ID
210
+ */
211
+ getAgentId(): string;
212
+ /**
213
+ * Get the agent name
214
+ */
215
+ getAgentName(): string;
216
+ /**
217
+ * Get the agent protocol
218
+ */
219
+ getProtocol(): 'mcp' | 'a2a';
220
+ /**
221
+ * Get active tasks for this agent
222
+ */
223
+ getActiveTasks(): import("./ConversationTypes").TaskState[];
224
+ }
225
+ /**
226
+ * Factory function to create an ADCP client
227
+ *
228
+ * @param agent - Agent configuration
229
+ * @param config - Client configuration
230
+ * @returns Configured ADCPClient instance
231
+ */
232
+ export declare function createADCPClient(agent: AgentConfig, config?: ADCPClientConfig): ADCPClient;
233
+ //# sourceMappingURL=ADCPClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ADCPClient.d.ts","sourceRoot":"","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;OAEG;IACH,WAAW,IAAI,KAAK,GAAG,KAAK;IAI5B;;OAEG;IACH,cAAc;CAKf;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,WAAW,EAClB,MAAM,CAAC,EAAE,gBAAgB,GACxB,UAAU,CAEZ"}
@@ -0,0 +1,287 @@
1
+ "use strict";
2
+ // Main ADCP Client - Type-safe conversation-aware client for AdCP agents
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ADCPClient = void 0;
5
+ exports.createADCPClient = createADCPClient;
6
+ const TaskExecutor_1 = require("./TaskExecutor");
7
+ /**
8
+ * Main ADCP Client providing strongly-typed conversation-aware interface
9
+ *
10
+ * This client handles individual agent interactions with full conversation context.
11
+ * For multi-agent operations, use ADCPMultiAgentClient or compose multiple instances.
12
+ *
13
+ * Key features:
14
+ * - 🔒 Full type safety for all ADCP tasks
15
+ * - 💬 Conversation management with context preservation
16
+ * - 🔄 Input handler pattern for clarifications
17
+ * - ⏱️ Timeout and retry support
18
+ * - 🐛 Debug logging and observability
19
+ * - 🎯 Works with both MCP and A2A protocols
20
+ */
21
+ class ADCPClient {
22
+ agent;
23
+ config;
24
+ executor;
25
+ constructor(agent, config = {}) {
26
+ this.agent = agent;
27
+ this.config = config;
28
+ this.executor = new TaskExecutor_1.TaskExecutor({
29
+ workingTimeout: config.workingTimeout || 120000, // Max 120s for working status
30
+ defaultMaxClarifications: config.defaultMaxClarifications || 3,
31
+ enableConversationStorage: config.persistConversations !== false
32
+ });
33
+ }
34
+ // ====== MEDIA BUY TASKS ======
35
+ /**
36
+ * Discover available advertising products
37
+ *
38
+ * @param params - Product discovery parameters
39
+ * @param inputHandler - Handler for clarification requests
40
+ * @param options - Task execution options
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * const products = await client.getProducts(
45
+ * {
46
+ * brief: 'Premium coffee brands for millennials',
47
+ * promoted_offering: 'Artisan coffee blends'
48
+ * },
49
+ * (context) => {
50
+ * if (context.inputRequest.field === 'budget') return 50000;
51
+ * return context.deferToHuman();
52
+ * }
53
+ * );
54
+ * ```
55
+ */
56
+ async getProducts(params, inputHandler, options) {
57
+ return this.executor.executeTask(this.agent, 'get_products', params, inputHandler, options);
58
+ }
59
+ /**
60
+ * List available creative formats
61
+ *
62
+ * @param params - Format listing parameters
63
+ * @param inputHandler - Handler for clarification requests
64
+ * @param options - Task execution options
65
+ */
66
+ async listCreativeFormats(params, inputHandler, options) {
67
+ return this.executor.executeTask(this.agent, 'list_creative_formats', params, inputHandler, options);
68
+ }
69
+ /**
70
+ * Create a new media buy
71
+ *
72
+ * @param params - Media buy creation parameters
73
+ * @param inputHandler - Handler for clarification requests
74
+ * @param options - Task execution options
75
+ */
76
+ async createMediaBuy(params, inputHandler, options) {
77
+ return this.executor.executeTask(this.agent, 'create_media_buy', params, inputHandler, options);
78
+ }
79
+ /**
80
+ * Update an existing media buy
81
+ *
82
+ * @param params - Media buy update parameters
83
+ * @param inputHandler - Handler for clarification requests
84
+ * @param options - Task execution options
85
+ */
86
+ async updateMediaBuy(params, inputHandler, options) {
87
+ return this.executor.executeTask(this.agent, 'update_media_buy', params, inputHandler, options);
88
+ }
89
+ /**
90
+ * Sync creative assets
91
+ *
92
+ * @param params - Creative sync parameters
93
+ * @param inputHandler - Handler for clarification requests
94
+ * @param options - Task execution options
95
+ */
96
+ async syncCreatives(params, inputHandler, options) {
97
+ return this.executor.executeTask(this.agent, 'sync_creatives', params, inputHandler, options);
98
+ }
99
+ /**
100
+ * List creative assets
101
+ *
102
+ * @param params - Creative listing parameters
103
+ * @param inputHandler - Handler for clarification requests
104
+ * @param options - Task execution options
105
+ */
106
+ async listCreatives(params, inputHandler, options) {
107
+ return this.executor.executeTask(this.agent, 'list_creatives', params, inputHandler, options);
108
+ }
109
+ /**
110
+ * Get media buy delivery information
111
+ *
112
+ * @param params - Delivery information parameters
113
+ * @param inputHandler - Handler for clarification requests
114
+ * @param options - Task execution options
115
+ */
116
+ async getMediaBuyDelivery(params, inputHandler, options) {
117
+ return this.executor.executeTask(this.agent, 'get_media_buy_delivery', params, inputHandler, options);
118
+ }
119
+ /**
120
+ * List authorized properties
121
+ *
122
+ * @param params - Property listing parameters
123
+ * @param inputHandler - Handler for clarification requests
124
+ * @param options - Task execution options
125
+ */
126
+ async listAuthorizedProperties(params, inputHandler, options) {
127
+ return this.executor.executeTask(this.agent, 'list_authorized_properties', params, inputHandler, options);
128
+ }
129
+ /**
130
+ * Provide performance feedback
131
+ *
132
+ * @param params - Performance feedback parameters
133
+ * @param inputHandler - Handler for clarification requests
134
+ * @param options - Task execution options
135
+ */
136
+ async providePerformanceFeedback(params, inputHandler, options) {
137
+ return this.executor.executeTask(this.agent, 'provide_performance_feedback', params, inputHandler, options);
138
+ }
139
+ // ====== SIGNALS TASKS ======
140
+ /**
141
+ * Get audience signals
142
+ *
143
+ * @param params - Signals request parameters
144
+ * @param inputHandler - Handler for clarification requests
145
+ * @param options - Task execution options
146
+ */
147
+ async getSignals(params, inputHandler, options) {
148
+ return this.executor.executeTask(this.agent, 'get_signals', params, inputHandler, options);
149
+ }
150
+ /**
151
+ * Activate audience signals
152
+ *
153
+ * @param params - Signal activation parameters
154
+ * @param inputHandler - Handler for clarification requests
155
+ * @param options - Task execution options
156
+ */
157
+ async activateSignal(params, inputHandler, options) {
158
+ return this.executor.executeTask(this.agent, 'activate_signal', params, inputHandler, options);
159
+ }
160
+ // ====== GENERIC TASK EXECUTION ======
161
+ /**
162
+ * Execute any task by name with type safety
163
+ *
164
+ * @param taskName - Name of the task to execute
165
+ * @param params - Task parameters
166
+ * @param inputHandler - Handler for clarification requests
167
+ * @param options - Task execution options
168
+ *
169
+ * @example
170
+ * ```typescript
171
+ * const result = await client.executeTask(
172
+ * 'get_products',
173
+ * { brief: 'Coffee brands' },
174
+ * handler
175
+ * );
176
+ * ```
177
+ */
178
+ async executeTask(taskName, params, inputHandler, options) {
179
+ return this.executor.executeTask(this.agent, taskName, params, inputHandler, options);
180
+ }
181
+ // ====== DEFERRED TASK MANAGEMENT ======
182
+ /**
183
+ * Resume a deferred task using its token
184
+ *
185
+ * @param token - Deferred task token
186
+ * @param inputHandler - Handler to provide the missing input
187
+ *
188
+ * @example
189
+ * ```typescript
190
+ * try {
191
+ * await client.createMediaBuy(params, handler);
192
+ * } catch (error) {
193
+ * if (error instanceof DeferredTaskError) {
194
+ * // Get human input and resume
195
+ * const result = await client.resumeDeferredTask(
196
+ * error.token,
197
+ * (context) => humanProvidedValue
198
+ * );
199
+ * }
200
+ * }
201
+ * ```
202
+ */
203
+ async resumeDeferredTask(token, inputHandler) {
204
+ // This is a simplified implementation
205
+ // In a full implementation, you'd need to store deferred task state
206
+ // and restore it here
207
+ throw new Error('Deferred task resumption requires storage configuration');
208
+ }
209
+ // ====== CONVERSATION MANAGEMENT ======
210
+ /**
211
+ * Continue an existing conversation with the agent
212
+ *
213
+ * @param message - Message to send to the agent
214
+ * @param contextId - Conversation context ID to continue
215
+ * @param inputHandler - Handler for any clarification requests
216
+ *
217
+ * @example
218
+ * ```typescript
219
+ * const agent = new ADCPClient(config);
220
+ * const initial = await agent.getProducts({ brief: 'Tech products' });
221
+ *
222
+ * // Continue the conversation
223
+ * const refined = await agent.continueConversation(
224
+ * 'Focus only on laptops under $1000',
225
+ * initial.metadata.taskId
226
+ * );
227
+ * ```
228
+ */
229
+ async continueConversation(message, contextId, inputHandler) {
230
+ return this.executor.executeTask(this.agent, 'continue_conversation', { message }, inputHandler, { contextId });
231
+ }
232
+ /**
233
+ * Get conversation history for a task
234
+ */
235
+ getConversationHistory(taskId) {
236
+ return this.executor.getConversationHistory(taskId);
237
+ }
238
+ /**
239
+ * Clear conversation history for a task
240
+ */
241
+ clearConversationHistory(taskId) {
242
+ this.executor.clearConversationHistory(taskId);
243
+ }
244
+ // ====== AGENT INFORMATION ======
245
+ /**
246
+ * Get the agent configuration
247
+ */
248
+ getAgent() {
249
+ return { ...this.agent };
250
+ }
251
+ /**
252
+ * Get the agent ID
253
+ */
254
+ getAgentId() {
255
+ return this.agent.id;
256
+ }
257
+ /**
258
+ * Get the agent name
259
+ */
260
+ getAgentName() {
261
+ return this.agent.name;
262
+ }
263
+ /**
264
+ * Get the agent protocol
265
+ */
266
+ getProtocol() {
267
+ return this.agent.protocol;
268
+ }
269
+ /**
270
+ * Get active tasks for this agent
271
+ */
272
+ getActiveTasks() {
273
+ return this.executor.getActiveTasks().filter((task) => task.agent.id === this.agent.id);
274
+ }
275
+ }
276
+ exports.ADCPClient = ADCPClient;
277
+ /**
278
+ * Factory function to create an ADCP client
279
+ *
280
+ * @param agent - Agent configuration
281
+ * @param config - Client configuration
282
+ * @returns Configured ADCPClient instance
283
+ */
284
+ function createADCPClient(agent, config) {
285
+ return new ADCPClient(agent, config);
286
+ }
287
+ //# sourceMappingURL=ADCPClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ADCPClient.js","sourceRoot":"","sources":["../../../src/lib/core/ADCPClient.ts"],"names":[],"mappings":";AAAA,yEAAyE;;;AAwezE,4CAKC;AAjdD,iDAAiE;AAoBjE;;;;;;;;;;;;;GAaG;AACH,MAAa,UAAU;IAIX;IACA;IAJF,QAAQ,CAAe;IAE/B,YACU,KAAkB,EAClB,SAA2B,EAAE;QAD7B,UAAK,GAAL,KAAK,CAAa;QAClB,WAAM,GAAN,MAAM,CAAuB;QAErC,IAAI,CAAC,QAAQ,GAAG,IAAI,2BAAY,CAAC;YAC/B,cAAc,EAAE,MAAM,CAAC,cAAc,IAAI,MAAM,EAAE,8BAA8B;YAC/E,wBAAwB,EAAE,MAAM,CAAC,wBAAwB,IAAI,CAAC;YAC9D,yBAAyB,EAAE,MAAM,CAAC,oBAAoB,KAAK,KAAK;SACjE,CAAC,CAAC;IACL,CAAC;IAED,gCAAgC;IAEhC;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,KAAK,CAAC,WAAW,CACf,MAA0B,EAC1B,YAA2B,EAC3B,OAAqB;QAErB,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,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