@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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Ad Context Protocol
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# @adcp/client
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/js/@adcp%2Fclient)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://www.typescriptlang.org/)
|
|
6
|
+
[](https://your-org.github.io/adcp-client/)
|
|
7
|
+
|
|
8
|
+
Official TypeScript/JavaScript client for the **Ad Context Protocol (AdCP)**. Seamlessly communicate with advertising agents using MCP and A2A protocols.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @adcp/client
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Quick Start
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
import { ADCPClient } from '@adcp/client';
|
|
20
|
+
|
|
21
|
+
// Simple setup with direct URL
|
|
22
|
+
const client = ADCPClient.simple('https://agent.example.com/mcp/', {
|
|
23
|
+
authToken: 'your-auth-token'
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// Execute a task
|
|
27
|
+
const result = await client.executeTask('get_products', {
|
|
28
|
+
brief: 'Looking for premium coffee advertising',
|
|
29
|
+
promoted_offering: 'Artisan coffee blends'
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
if (result.success) {
|
|
33
|
+
console.log('Products:', result.data.products);
|
|
34
|
+
} else {
|
|
35
|
+
console.error('Error:', result.error);
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Key Features
|
|
40
|
+
|
|
41
|
+
- **🔗 Unified Interface** - Single API for MCP and A2A protocols
|
|
42
|
+
- **⚡ Async Support** - Handle long-running tasks with webhooks and deferrals
|
|
43
|
+
- **🔐 Built-in Auth** - Bearer tokens and API key support
|
|
44
|
+
- **🛡️ Type Safe** - Full TypeScript with comprehensive types
|
|
45
|
+
- **📊 Production Ready** - Circuit breakers, retries, and validation
|
|
46
|
+
|
|
47
|
+
## Async Execution Model
|
|
48
|
+
|
|
49
|
+
Handle complex async patterns with ease:
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
// Configure input handler for interactive tasks
|
|
53
|
+
const client = ADCPClient.simple('https://agent.example.com', {
|
|
54
|
+
authToken: 'token',
|
|
55
|
+
inputHandler: async (request) => {
|
|
56
|
+
// Handle 'input-required' status
|
|
57
|
+
if (request.type === 'user_approval') {
|
|
58
|
+
const approved = await getUserApproval(request.data);
|
|
59
|
+
return { approved };
|
|
60
|
+
}
|
|
61
|
+
// Defer for human review
|
|
62
|
+
return { defer: true };
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// Long-running server task (returns immediately)
|
|
67
|
+
const result = await client.executeTask('analyze_campaign', {
|
|
68
|
+
campaign_id: '12345'
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
if (result.status === 'submitted') {
|
|
72
|
+
// Task running on server, will notify via webhook
|
|
73
|
+
console.log('Task ID:', result.submitted.taskId);
|
|
74
|
+
console.log('Webhook:', result.submitted.webhookUrl);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Client-deferred task (needs human input)
|
|
78
|
+
if (result.status === 'deferred') {
|
|
79
|
+
// Save continuation for later
|
|
80
|
+
const continuation = result.deferred;
|
|
81
|
+
|
|
82
|
+
// ... later, after human provides input ...
|
|
83
|
+
const finalResult = await client.resumeDeferredTask(
|
|
84
|
+
continuation,
|
|
85
|
+
{ approved: true, budget: 50000 }
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Multi-Agent Support
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
import { ADCPMultiAgentClient } from '@adcp/client';
|
|
94
|
+
|
|
95
|
+
const client = new ADCPMultiAgentClient([
|
|
96
|
+
{
|
|
97
|
+
id: 'agent1',
|
|
98
|
+
name: 'MCP Agent',
|
|
99
|
+
agent_uri: 'https://agent1.example.com/mcp/',
|
|
100
|
+
protocol: 'mcp',
|
|
101
|
+
requiresAuth: true,
|
|
102
|
+
auth_token_env: 'AGENT1_TOKEN'
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
id: 'agent2',
|
|
106
|
+
name: 'A2A Agent',
|
|
107
|
+
agent_uri: 'https://agent2.example.com',
|
|
108
|
+
protocol: 'a2a'
|
|
109
|
+
}
|
|
110
|
+
]);
|
|
111
|
+
|
|
112
|
+
// Execute on specific agent
|
|
113
|
+
const result = await client.executeTask('agent1', 'get_products', params);
|
|
114
|
+
|
|
115
|
+
// Execute on all agents in parallel
|
|
116
|
+
const results = await client.executeTaskOnAll('get_products', params);
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Documentation
|
|
120
|
+
|
|
121
|
+
- 📚 **[Full Documentation](https://your-org.github.io/adcp-client/)** - Complete guides and API reference
|
|
122
|
+
- 🚀 **[Getting Started Guide](https://your-org.github.io/adcp-client/getting-started)** - Step-by-step tutorial
|
|
123
|
+
- 🔄 **[Async Patterns](https://your-org.github.io/adcp-client/async-patterns)** - Handle complex async flows
|
|
124
|
+
- 📖 **[API Reference](https://your-org.github.io/adcp-client/api)** - Generated from TypeDoc
|
|
125
|
+
- 💡 **[Examples](./examples/)** - Real-world usage examples
|
|
126
|
+
|
|
127
|
+
## Examples
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
# Clone for full examples
|
|
131
|
+
git clone https://github.com/your-org/adcp-client
|
|
132
|
+
cd adcp-client/examples
|
|
133
|
+
|
|
134
|
+
# Run examples
|
|
135
|
+
npx tsx basic-usage.ts
|
|
136
|
+
npx tsx async-patterns.ts
|
|
137
|
+
npx tsx multi-agent.ts
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Testing UI
|
|
141
|
+
|
|
142
|
+
The package includes an interactive testing framework:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
# Install and run locally
|
|
146
|
+
git clone https://github.com/your-org/adcp-client
|
|
147
|
+
cd adcp-client
|
|
148
|
+
npm install
|
|
149
|
+
npm run dev
|
|
150
|
+
|
|
151
|
+
# Open http://localhost:8080
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Contributing
|
|
155
|
+
|
|
156
|
+
We welcome contributions! See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines.
|
|
157
|
+
|
|
158
|
+
## License
|
|
159
|
+
|
|
160
|
+
MIT - see [LICENSE](./LICENSE) for details.
|
|
161
|
+
|
|
162
|
+
## Links
|
|
163
|
+
|
|
164
|
+
- [AdCP Specification](https://adcontextprotocol.org)
|
|
165
|
+
- [Issue Tracker](https://github.com/your-org/adcp-client/issues)
|
|
166
|
+
- [npm Package](https://www.npmjs.com/package/@adcp/client)
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import type { AgentConfig } from '../types';
|
|
2
|
+
import type { GetProductsRequest, GetProductsResponse, ListCreativeFormatsRequest, ListCreativeFormatsResponse, CreateMediaBuyRequest, CreateMediaBuyResponse, SyncCreativesRequest, SyncCreativesResponse, ListCreativesRequest, ListCreativesResponse, UpdateMediaBuyRequest, UpdateMediaBuyResponse, GetMediaBuyDeliveryRequest, GetMediaBuyDeliveryResponse, ListAuthorizedPropertiesRequest, ListAuthorizedPropertiesResponse, ProvidePerformanceFeedbackRequest, ProvidePerformanceFeedbackResponse, GetSignalsRequest, GetSignalsResponse, ActivateSignalRequest, ActivateSignalResponse } from '../types/tools.generated';
|
|
3
|
+
interface ToolResponse<T> {
|
|
4
|
+
success: true;
|
|
5
|
+
data: T;
|
|
6
|
+
agent: {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
protocol: 'mcp' | 'a2a';
|
|
10
|
+
};
|
|
11
|
+
responseTimeMs: number;
|
|
12
|
+
timestamp: string;
|
|
13
|
+
debugLogs?: any[];
|
|
14
|
+
}
|
|
15
|
+
interface ToolError {
|
|
16
|
+
success: false;
|
|
17
|
+
error: string;
|
|
18
|
+
agent: {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
protocol: 'mcp' | 'a2a';
|
|
22
|
+
};
|
|
23
|
+
responseTimeMs: number;
|
|
24
|
+
timestamp: string;
|
|
25
|
+
debugLogs?: any[];
|
|
26
|
+
}
|
|
27
|
+
type ToolResult<T> = ToolResponse<T> | ToolError;
|
|
28
|
+
/**
|
|
29
|
+
* Single agent operations with full type safety
|
|
30
|
+
*/
|
|
31
|
+
export declare class Agent {
|
|
32
|
+
private config;
|
|
33
|
+
private client;
|
|
34
|
+
constructor(config: AgentConfig, client: any);
|
|
35
|
+
private callTool;
|
|
36
|
+
/**
|
|
37
|
+
* Official AdCP get_products tool schema
|
|
38
|
+
* Official AdCP get_products tool schema
|
|
39
|
+
*/
|
|
40
|
+
getProducts(params: GetProductsRequest): Promise<ToolResult<GetProductsResponse>>;
|
|
41
|
+
/**
|
|
42
|
+
* Official AdCP list_creative_formats tool schema
|
|
43
|
+
* Official AdCP list_creative_formats tool schema
|
|
44
|
+
*/
|
|
45
|
+
listCreativeFormats(params: ListCreativeFormatsRequest): Promise<ToolResult<ListCreativeFormatsResponse>>;
|
|
46
|
+
/**
|
|
47
|
+
* Official AdCP create_media_buy tool schema
|
|
48
|
+
* Official AdCP create_media_buy tool schema
|
|
49
|
+
*/
|
|
50
|
+
createMediaBuy(params: CreateMediaBuyRequest): Promise<ToolResult<CreateMediaBuyResponse>>;
|
|
51
|
+
/**
|
|
52
|
+
* Official AdCP sync_creatives tool schema
|
|
53
|
+
* Official AdCP sync_creatives tool schema
|
|
54
|
+
*/
|
|
55
|
+
syncCreatives(params: SyncCreativesRequest): Promise<ToolResult<SyncCreativesResponse>>;
|
|
56
|
+
/**
|
|
57
|
+
* Official AdCP list_creatives tool schema
|
|
58
|
+
* Official AdCP list_creatives tool schema
|
|
59
|
+
*/
|
|
60
|
+
listCreatives(params: ListCreativesRequest): Promise<ToolResult<ListCreativesResponse>>;
|
|
61
|
+
/**
|
|
62
|
+
* Official AdCP update_media_buy tool schema
|
|
63
|
+
* Official AdCP update_media_buy tool schema
|
|
64
|
+
*/
|
|
65
|
+
updateMediaBuy(params: UpdateMediaBuyRequest): Promise<ToolResult<UpdateMediaBuyResponse>>;
|
|
66
|
+
/**
|
|
67
|
+
* Official AdCP get_media_buy_delivery tool schema
|
|
68
|
+
* Official AdCP get_media_buy_delivery tool schema
|
|
69
|
+
*/
|
|
70
|
+
getMediaBuyDelivery(params: GetMediaBuyDeliveryRequest): Promise<ToolResult<GetMediaBuyDeliveryResponse>>;
|
|
71
|
+
/**
|
|
72
|
+
* Official AdCP list_authorized_properties tool schema
|
|
73
|
+
* Official AdCP list_authorized_properties tool schema
|
|
74
|
+
*/
|
|
75
|
+
listAuthorizedProperties(params: ListAuthorizedPropertiesRequest): Promise<ToolResult<ListAuthorizedPropertiesResponse>>;
|
|
76
|
+
/**
|
|
77
|
+
* Official AdCP provide_performance_feedback tool schema
|
|
78
|
+
* Official AdCP provide_performance_feedback tool schema
|
|
79
|
+
*/
|
|
80
|
+
providePerformanceFeedback(params: ProvidePerformanceFeedbackRequest): Promise<ToolResult<ProvidePerformanceFeedbackResponse>>;
|
|
81
|
+
/**
|
|
82
|
+
* Official AdCP get_signals tool schema
|
|
83
|
+
* Official AdCP get_signals tool schema
|
|
84
|
+
*/
|
|
85
|
+
getSignals(params: GetSignalsRequest): Promise<ToolResult<GetSignalsResponse>>;
|
|
86
|
+
/**
|
|
87
|
+
* Official AdCP activate_signal tool schema
|
|
88
|
+
* Official AdCP activate_signal tool schema
|
|
89
|
+
*/
|
|
90
|
+
activateSignal(params: ActivateSignalRequest): Promise<ToolResult<ActivateSignalResponse>>;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Multi-agent operations with full type safety
|
|
94
|
+
*/
|
|
95
|
+
export declare class AgentCollection {
|
|
96
|
+
private configs;
|
|
97
|
+
private client;
|
|
98
|
+
constructor(configs: AgentConfig[], client: any);
|
|
99
|
+
private callToolOnAll;
|
|
100
|
+
/**
|
|
101
|
+
* Official AdCP get_products tool schema (across multiple agents)
|
|
102
|
+
* Official AdCP get_products tool schema
|
|
103
|
+
*/
|
|
104
|
+
getProducts(params: GetProductsRequest): Promise<ToolResult<GetProductsResponse>[]>;
|
|
105
|
+
/**
|
|
106
|
+
* Official AdCP list_creative_formats tool schema (across multiple agents)
|
|
107
|
+
* Official AdCP list_creative_formats tool schema
|
|
108
|
+
*/
|
|
109
|
+
listCreativeFormats(params: ListCreativeFormatsRequest): Promise<ToolResult<ListCreativeFormatsResponse>[]>;
|
|
110
|
+
/**
|
|
111
|
+
* Official AdCP sync_creatives tool schema (across multiple agents)
|
|
112
|
+
* Official AdCP sync_creatives tool schema
|
|
113
|
+
*/
|
|
114
|
+
syncCreatives(params: SyncCreativesRequest): Promise<ToolResult<SyncCreativesResponse>[]>;
|
|
115
|
+
/**
|
|
116
|
+
* Official AdCP list_creatives tool schema (across multiple agents)
|
|
117
|
+
* Official AdCP list_creatives tool schema
|
|
118
|
+
*/
|
|
119
|
+
listCreatives(params: ListCreativesRequest): Promise<ToolResult<ListCreativesResponse>[]>;
|
|
120
|
+
/**
|
|
121
|
+
* Official AdCP get_media_buy_delivery tool schema (across multiple agents)
|
|
122
|
+
* Official AdCP get_media_buy_delivery tool schema
|
|
123
|
+
*/
|
|
124
|
+
getMediaBuyDelivery(params: GetMediaBuyDeliveryRequest): Promise<ToolResult<GetMediaBuyDeliveryResponse>[]>;
|
|
125
|
+
/**
|
|
126
|
+
* Official AdCP list_authorized_properties tool schema (across multiple agents)
|
|
127
|
+
* Official AdCP list_authorized_properties tool schema
|
|
128
|
+
*/
|
|
129
|
+
listAuthorizedProperties(params: ListAuthorizedPropertiesRequest): Promise<ToolResult<ListAuthorizedPropertiesResponse>[]>;
|
|
130
|
+
/**
|
|
131
|
+
* Official AdCP provide_performance_feedback tool schema (across multiple agents)
|
|
132
|
+
* Official AdCP provide_performance_feedback tool schema
|
|
133
|
+
*/
|
|
134
|
+
providePerformanceFeedback(params: ProvidePerformanceFeedbackRequest): Promise<ToolResult<ProvidePerformanceFeedbackResponse>[]>;
|
|
135
|
+
/**
|
|
136
|
+
* Official AdCP get_signals tool schema (across multiple agents)
|
|
137
|
+
* Official AdCP get_signals tool schema
|
|
138
|
+
*/
|
|
139
|
+
getSignals(params: GetSignalsRequest): Promise<ToolResult<GetSignalsResponse>[]>;
|
|
140
|
+
/**
|
|
141
|
+
* Official AdCP activate_signal tool schema (across multiple agents)
|
|
142
|
+
* Official AdCP activate_signal tool schema
|
|
143
|
+
*/
|
|
144
|
+
activateSignal(params: ActivateSignalRequest): Promise<ToolResult<ActivateSignalResponse>[]>;
|
|
145
|
+
}
|
|
146
|
+
export {};
|
|
147
|
+
//# sourceMappingURL=index.generated.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.generated.d.ts","sourceRoot":"","sources":["../../../src/lib/agents/index.generated.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAI5C,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,0BAA0B,EAC1B,2BAA2B,EAC3B,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,0BAA0B,EAC1B,2BAA2B,EAC3B,+BAA+B,EAC/B,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,CAAC,2BAA2B,CAAC,EAAE,CAAC;IAIjH;;;OAGG;IACG,aAAa,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,UAAU,CAAC,qBAAqB,CAAC,EAAE,CAAC;IAI/F;;;OAGG;IACG,aAAa,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,UAAU,CAAC,qBAAqB,CAAC,EAAE,CAAC;IAI/F;;;OAGG;IACG,mBAAmB,CAAC,MAAM,EAAE,0BAA0B,GAAG,OAAO,CAAC,UAAU,CAAC,2BAA2B,CAAC,EAAE,CAAC;IAIjH;;;OAGG;IACG,wBAAwB,CAAC,MAAM,EAAE,+BAA+B,GAAG,OAAO,CAAC,UAAU,CAAC,gCAAgC,CAAC,EAAE,CAAC;IAIhI;;;OAGG;IACG,0BAA0B,CAAC,MAAM,EAAE,iCAAiC,GAAG,OAAO,CAAC,UAAU,CAAC,kCAAkC,CAAC,EAAE,CAAC;IAItI;;;OAGG;IACG,UAAU,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,kBAAkB,CAAC,EAAE,CAAC;IAItF;;;OAGG;IACG,cAAc,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,UAAU,CAAC,sBAAsB,CAAC,EAAE,CAAC;CAInG"}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Generated Agent Classes
|
|
3
|
+
// Auto-generated from AdCP tool definitions
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.AgentCollection = exports.Agent = void 0;
|
|
6
|
+
const protocols_1 = require("../protocols");
|
|
7
|
+
const validation_1 = require("../validation");
|
|
8
|
+
const utils_1 = require("../utils");
|
|
9
|
+
/**
|
|
10
|
+
* Single agent operations with full type safety
|
|
11
|
+
*/
|
|
12
|
+
class Agent {
|
|
13
|
+
config;
|
|
14
|
+
client;
|
|
15
|
+
constructor(config, client // Will be AdCPClient
|
|
16
|
+
) {
|
|
17
|
+
this.config = config;
|
|
18
|
+
this.client = client;
|
|
19
|
+
}
|
|
20
|
+
async callTool(toolName, params) {
|
|
21
|
+
const startTime = Date.now();
|
|
22
|
+
const debugLogs = [];
|
|
23
|
+
try {
|
|
24
|
+
(0, validation_1.validateAgentUrl)(this.config.agent_uri);
|
|
25
|
+
const circuitBreaker = (0, utils_1.getCircuitBreaker)(this.config.id);
|
|
26
|
+
const result = await circuitBreaker.call(async () => {
|
|
27
|
+
return await protocols_1.ProtocolClient.callTool(this.config, toolName, params, debugLogs);
|
|
28
|
+
});
|
|
29
|
+
return {
|
|
30
|
+
success: true,
|
|
31
|
+
data: result,
|
|
32
|
+
agent: {
|
|
33
|
+
id: this.config.id,
|
|
34
|
+
name: this.config.name,
|
|
35
|
+
protocol: this.config.protocol
|
|
36
|
+
},
|
|
37
|
+
responseTimeMs: Date.now() - startTime,
|
|
38
|
+
timestamp: new Date().toISOString(),
|
|
39
|
+
debugLogs
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
44
|
+
return {
|
|
45
|
+
success: false,
|
|
46
|
+
error: errorMessage,
|
|
47
|
+
agent: {
|
|
48
|
+
id: this.config.id,
|
|
49
|
+
name: this.config.name,
|
|
50
|
+
protocol: this.config.protocol
|
|
51
|
+
},
|
|
52
|
+
responseTimeMs: Date.now() - startTime,
|
|
53
|
+
timestamp: new Date().toISOString(),
|
|
54
|
+
debugLogs
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Official AdCP get_products tool schema
|
|
60
|
+
* Official AdCP get_products tool schema
|
|
61
|
+
*/
|
|
62
|
+
async getProducts(params) {
|
|
63
|
+
return this.callTool('get_products', params);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Official AdCP list_creative_formats tool schema
|
|
67
|
+
* Official AdCP list_creative_formats tool schema
|
|
68
|
+
*/
|
|
69
|
+
async listCreativeFormats(params) {
|
|
70
|
+
return this.callTool('list_creative_formats', params);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Official AdCP create_media_buy tool schema
|
|
74
|
+
* Official AdCP create_media_buy tool schema
|
|
75
|
+
*/
|
|
76
|
+
async createMediaBuy(params) {
|
|
77
|
+
return this.callTool('create_media_buy', params);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Official AdCP sync_creatives tool schema
|
|
81
|
+
* Official AdCP sync_creatives tool schema
|
|
82
|
+
*/
|
|
83
|
+
async syncCreatives(params) {
|
|
84
|
+
return this.callTool('sync_creatives', params);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Official AdCP list_creatives tool schema
|
|
88
|
+
* Official AdCP list_creatives tool schema
|
|
89
|
+
*/
|
|
90
|
+
async listCreatives(params) {
|
|
91
|
+
return this.callTool('list_creatives', params);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Official AdCP update_media_buy tool schema
|
|
95
|
+
* Official AdCP update_media_buy tool schema
|
|
96
|
+
*/
|
|
97
|
+
async updateMediaBuy(params) {
|
|
98
|
+
return this.callTool('update_media_buy', params);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Official AdCP get_media_buy_delivery tool schema
|
|
102
|
+
* Official AdCP get_media_buy_delivery tool schema
|
|
103
|
+
*/
|
|
104
|
+
async getMediaBuyDelivery(params) {
|
|
105
|
+
return this.callTool('get_media_buy_delivery', params);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Official AdCP list_authorized_properties tool schema
|
|
109
|
+
* Official AdCP list_authorized_properties tool schema
|
|
110
|
+
*/
|
|
111
|
+
async listAuthorizedProperties(params) {
|
|
112
|
+
return this.callTool('list_authorized_properties', params);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Official AdCP provide_performance_feedback tool schema
|
|
116
|
+
* Official AdCP provide_performance_feedback tool schema
|
|
117
|
+
*/
|
|
118
|
+
async providePerformanceFeedback(params) {
|
|
119
|
+
return this.callTool('provide_performance_feedback', params);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Official AdCP get_signals tool schema
|
|
123
|
+
* Official AdCP get_signals tool schema
|
|
124
|
+
*/
|
|
125
|
+
async getSignals(params) {
|
|
126
|
+
return this.callTool('get_signals', params);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Official AdCP activate_signal tool schema
|
|
130
|
+
* Official AdCP activate_signal tool schema
|
|
131
|
+
*/
|
|
132
|
+
async activateSignal(params) {
|
|
133
|
+
return this.callTool('activate_signal', params);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
exports.Agent = Agent;
|
|
137
|
+
/**
|
|
138
|
+
* Multi-agent operations with full type safety
|
|
139
|
+
*/
|
|
140
|
+
class AgentCollection {
|
|
141
|
+
configs;
|
|
142
|
+
client;
|
|
143
|
+
constructor(configs, client // Will be AdCPClient
|
|
144
|
+
) {
|
|
145
|
+
this.configs = configs;
|
|
146
|
+
this.client = client;
|
|
147
|
+
}
|
|
148
|
+
async callToolOnAll(toolName, params) {
|
|
149
|
+
const agents = this.configs.map(config => new Agent(config, this.client));
|
|
150
|
+
const promises = agents.map(agent => agent.callTool(toolName, params));
|
|
151
|
+
return Promise.all(promises);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Official AdCP get_products tool schema (across multiple agents)
|
|
155
|
+
* Official AdCP get_products tool schema
|
|
156
|
+
*/
|
|
157
|
+
async getProducts(params) {
|
|
158
|
+
return this.callToolOnAll('get_products', params);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Official AdCP list_creative_formats tool schema (across multiple agents)
|
|
162
|
+
* Official AdCP list_creative_formats tool schema
|
|
163
|
+
*/
|
|
164
|
+
async listCreativeFormats(params) {
|
|
165
|
+
return this.callToolOnAll('list_creative_formats', params);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Official AdCP sync_creatives tool schema (across multiple agents)
|
|
169
|
+
* Official AdCP sync_creatives tool schema
|
|
170
|
+
*/
|
|
171
|
+
async syncCreatives(params) {
|
|
172
|
+
return this.callToolOnAll('sync_creatives', params);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Official AdCP list_creatives tool schema (across multiple agents)
|
|
176
|
+
* Official AdCP list_creatives tool schema
|
|
177
|
+
*/
|
|
178
|
+
async listCreatives(params) {
|
|
179
|
+
return this.callToolOnAll('list_creatives', params);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Official AdCP get_media_buy_delivery tool schema (across multiple agents)
|
|
183
|
+
* Official AdCP get_media_buy_delivery tool schema
|
|
184
|
+
*/
|
|
185
|
+
async getMediaBuyDelivery(params) {
|
|
186
|
+
return this.callToolOnAll('get_media_buy_delivery', params);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Official AdCP list_authorized_properties tool schema (across multiple agents)
|
|
190
|
+
* Official AdCP list_authorized_properties tool schema
|
|
191
|
+
*/
|
|
192
|
+
async listAuthorizedProperties(params) {
|
|
193
|
+
return this.callToolOnAll('list_authorized_properties', params);
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Official AdCP provide_performance_feedback tool schema (across multiple agents)
|
|
197
|
+
* Official AdCP provide_performance_feedback tool schema
|
|
198
|
+
*/
|
|
199
|
+
async providePerformanceFeedback(params) {
|
|
200
|
+
return this.callToolOnAll('provide_performance_feedback', params);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Official AdCP get_signals tool schema (across multiple agents)
|
|
204
|
+
* Official AdCP get_signals tool schema
|
|
205
|
+
*/
|
|
206
|
+
async getSignals(params) {
|
|
207
|
+
return this.callToolOnAll('get_signals', params);
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Official AdCP activate_signal tool schema (across multiple agents)
|
|
211
|
+
* Official AdCP activate_signal tool schema
|
|
212
|
+
*/
|
|
213
|
+
async activateSignal(params) {
|
|
214
|
+
return this.callToolOnAll('activate_signal', params);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
exports.AgentCollection = AgentCollection;
|
|
218
|
+
//# sourceMappingURL=index.generated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.generated.js","sourceRoot":"","sources":["../../../src/lib/agents/index.generated.ts"],"names":[],"mappings":";AAAA,0BAA0B;AAC1B,4CAA4C;;;AAG5C,4CAA8C;AAC9C,8CAAiD;AACjD,oCAA6C;AAuD7C;;GAEG;AACH,MAAa,KAAK;IAEN;IACA;IAFV,YACU,MAAmB,EACnB,MAAW,CAAC,qBAAqB;;QADjC,WAAM,GAAN,MAAM,CAAa;QACnB,WAAM,GAAN,MAAM,CAAK;IAClB,CAAC;IAEI,KAAK,CAAC,QAAQ,CAAI,QAAgB,EAAE,MAAW;QACrD,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC7B,MAAM,SAAS,GAAU,EAAE,CAAC;QAE5B,IAAI,CAAC;YACH,IAAA,6BAAgB,EAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YAExC,MAAM,cAAc,GAAG,IAAA,yBAAiB,EAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YACzD,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE;gBAClD,OAAO,MAAM,0BAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;YACjF,CAAC,CAAC,CAAC;YAEH,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,IAAI,EAAE,MAAM;gBACZ,KAAK,EAAE;oBACL,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE;oBAClB,IAAI,EAAE,IAAI,CAAC,MAAM,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C,8BAA8B,EAAE,MAAM,CAAC,CAAC;IACxG,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,UAAU,CAAC,MAAyB;QACxC,OAAO,IAAI,CAAC,aAAa,CAAqB,aAAa,EAAE,MAAM,CAAC,CAAC;IACvE,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,cAAc,CAAC,MAA6B;QAChD,OAAO,IAAI,CAAC,aAAa,CAAyB,iBAAiB,EAAE,MAAM,CAAC,CAAC;IAC/E,CAAC;CAEF;AApFD,0CAoFC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { AgentConfig } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Generate UUID for request tracking
|
|
4
|
+
*/
|
|
5
|
+
export declare function generateUUID(): string;
|
|
6
|
+
/**
|
|
7
|
+
* Get authentication token for an agent
|
|
8
|
+
*/
|
|
9
|
+
export declare function getAuthToken(agent: AgentConfig): string | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Create AdCP-compliant headers
|
|
12
|
+
*/
|
|
13
|
+
export declare function createAdCPHeaders(authToken?: string, isMCP?: boolean): Record<string, string>;
|
|
14
|
+
/**
|
|
15
|
+
* Create an authenticated fetch function for A2A client
|
|
16
|
+
*/
|
|
17
|
+
export declare function createAuthenticatedFetch(authToken: string): (url: string | URL | Request, options?: RequestInit) => Promise<Response>;
|
|
18
|
+
/**
|
|
19
|
+
* Create MCP authentication headers
|
|
20
|
+
*/
|
|
21
|
+
export declare function createMCPAuthHeaders(authToken?: string): Record<string, string>;
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C;;GAEG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAMrC;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,CAanE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,KAAK,GAAE,OAAe,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CASpG;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,IAC1C,KAAK,MAAM,GAAG,GAAG,GAAG,OAAO,EAAE,UAAU,WAAW,uBAWjE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAU/E"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateUUID = generateUUID;
|
|
4
|
+
exports.getAuthToken = getAuthToken;
|
|
5
|
+
exports.createAdCPHeaders = createAdCPHeaders;
|
|
6
|
+
exports.createAuthenticatedFetch = createAuthenticatedFetch;
|
|
7
|
+
exports.createMCPAuthHeaders = createMCPAuthHeaders;
|
|
8
|
+
/**
|
|
9
|
+
* Generate UUID for request tracking
|
|
10
|
+
*/
|
|
11
|
+
function generateUUID() {
|
|
12
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
13
|
+
const r = Math.random() * 16 | 0;
|
|
14
|
+
const v = c == 'x' ? r : (r & 0x3 | 0x8);
|
|
15
|
+
return v.toString(16);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Get authentication token for an agent
|
|
20
|
+
*/
|
|
21
|
+
function getAuthToken(agent) {
|
|
22
|
+
if (!agent.requiresAuth || !agent.auth_token_env) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
// If auth_token_env looks like a direct token (not an env var name), use it directly
|
|
26
|
+
// Base64-like tokens are typically 40+ chars and contain mixed case/symbols
|
|
27
|
+
if (agent.auth_token_env.length > 20 && !agent.auth_token_env.match(/^[A-Z_][A-Z0-9_]*$/)) {
|
|
28
|
+
return agent.auth_token_env;
|
|
29
|
+
}
|
|
30
|
+
// Otherwise, look up the environment variable
|
|
31
|
+
return process.env[agent.auth_token_env];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Create AdCP-compliant headers
|
|
35
|
+
*/
|
|
36
|
+
function createAdCPHeaders(authToken, isMCP = false) {
|
|
37
|
+
return {
|
|
38
|
+
'Content-Type': isMCP ? 'application/json' : 'application/vnd.adcp+json',
|
|
39
|
+
'AdCP-Version': '1.0',
|
|
40
|
+
'AdCP-Request-ID': generateUUID(),
|
|
41
|
+
'User-Agent': 'AdCP-Testing-Framework/1.0.0',
|
|
42
|
+
'Accept': isMCP ? 'application/json, text/event-stream' : 'application/vnd.adcp+json, application/json',
|
|
43
|
+
...(authToken && { 'Authorization': `Bearer ${authToken}` })
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Create an authenticated fetch function for A2A client
|
|
48
|
+
*/
|
|
49
|
+
function createAuthenticatedFetch(authToken) {
|
|
50
|
+
return async (url, options) => {
|
|
51
|
+
const headers = createAdCPHeaders(authToken);
|
|
52
|
+
return fetch(url, {
|
|
53
|
+
...options,
|
|
54
|
+
headers: {
|
|
55
|
+
...headers,
|
|
56
|
+
...(options?.headers || {})
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Create MCP authentication headers
|
|
63
|
+
*/
|
|
64
|
+
function createMCPAuthHeaders(authToken) {
|
|
65
|
+
const headers = {
|
|
66
|
+
'Accept': 'application/json, text/event-stream'
|
|
67
|
+
};
|
|
68
|
+
if (authToken) {
|
|
69
|
+
headers['x-adcp-auth'] = authToken;
|
|
70
|
+
}
|
|
71
|
+
return headers;
|
|
72
|
+
}
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