@adcp/client 3.7.1 → 3.8.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/bin/adcp.js +42 -3
- package/dist/lib/adapters/content-standards-adapter.d.ts +106 -0
- package/dist/lib/adapters/content-standards-adapter.d.ts.map +1 -0
- package/dist/lib/adapters/content-standards-adapter.js +199 -0
- package/dist/lib/adapters/content-standards-adapter.js.map +1 -0
- package/dist/lib/adapters/index.d.ts +18 -0
- package/dist/lib/adapters/index.d.ts.map +1 -0
- package/dist/lib/adapters/index.js +41 -0
- package/dist/lib/adapters/index.js.map +1 -0
- package/dist/lib/adapters/property-list-adapter.d.ts +123 -0
- package/dist/lib/adapters/property-list-adapter.d.ts.map +1 -0
- package/dist/lib/adapters/property-list-adapter.js +212 -0
- package/dist/lib/adapters/property-list-adapter.js.map +1 -0
- package/dist/lib/adapters/proposal-manager.d.ts +142 -0
- package/dist/lib/adapters/proposal-manager.d.ts.map +1 -0
- package/dist/lib/adapters/proposal-manager.js +184 -0
- package/dist/lib/adapters/proposal-manager.js.map +1 -0
- package/dist/lib/adapters/si-session-manager.d.ts +161 -0
- package/dist/lib/adapters/si-session-manager.d.ts.map +1 -0
- package/dist/lib/adapters/si-session-manager.js +320 -0
- package/dist/lib/adapters/si-session-manager.js.map +1 -0
- package/dist/lib/agents/index.generated.d.ts +109 -33
- package/dist/lib/agents/index.generated.d.ts.map +1 -1
- package/dist/lib/agents/index.generated.js +162 -36
- package/dist/lib/agents/index.generated.js.map +1 -1
- package/dist/lib/core/ADCPMultiAgentClient.d.ts +5 -7
- package/dist/lib/core/ADCPMultiAgentClient.d.ts.map +1 -1
- package/dist/lib/core/ADCPMultiAgentClient.js +47 -35
- package/dist/lib/core/ADCPMultiAgentClient.js.map +1 -1
- package/dist/lib/core/AgentClient.d.ts +13 -6
- package/dist/lib/core/AgentClient.d.ts.map +1 -1
- package/dist/lib/core/AgentClient.js +23 -13
- package/dist/lib/core/AgentClient.js.map +1 -1
- package/dist/lib/core/AsyncHandler.d.ts +1 -2
- package/dist/lib/core/AsyncHandler.d.ts.map +1 -1
- package/dist/lib/core/AsyncHandler.js +0 -3
- package/dist/lib/core/AsyncHandler.js.map +1 -1
- package/dist/lib/core/ResponseValidator.d.ts.map +1 -1
- package/dist/lib/core/ResponseValidator.js +0 -1
- package/dist/lib/core/ResponseValidator.js.map +1 -1
- package/dist/lib/core/SingleAgentClient.d.ts +102 -10
- package/dist/lib/core/SingleAgentClient.d.ts.map +1 -1
- package/dist/lib/core/SingleAgentClient.js +244 -17
- package/dist/lib/core/SingleAgentClient.js.map +1 -1
- package/dist/lib/discovery/property-crawler.d.ts +13 -2
- package/dist/lib/discovery/property-crawler.d.ts.map +1 -1
- package/dist/lib/discovery/property-crawler.js +48 -13
- package/dist/lib/discovery/property-crawler.js.map +1 -1
- package/dist/lib/discovery/types.d.ts +7 -1
- package/dist/lib/discovery/types.d.ts.map +1 -1
- package/dist/lib/index.d.ts +13 -4
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +79 -5
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/types/core.generated.d.ts +502 -238
- package/dist/lib/types/core.generated.d.ts.map +1 -1
- package/dist/lib/types/core.generated.js +2 -2
- package/dist/lib/types/core.generated.js.map +1 -1
- package/dist/lib/types/schemas.generated.d.ts +7237 -2284
- package/dist/lib/types/schemas.generated.d.ts.map +1 -1
- package/dist/lib/types/schemas.generated.js +1368 -461
- package/dist/lib/types/schemas.generated.js.map +1 -1
- package/dist/lib/types/tools.generated.d.ts +3128 -507
- package/dist/lib/types/tools.generated.d.ts.map +1 -1
- package/dist/lib/types/tools.generated.js +1 -1
- package/dist/lib/types/tools.generated.js.map +1 -1
- package/dist/lib/utils/capabilities.d.ts +98 -0
- package/dist/lib/utils/capabilities.d.ts.map +1 -0
- package/dist/lib/utils/capabilities.js +155 -0
- package/dist/lib/utils/capabilities.js.map +1 -0
- package/dist/lib/utils/creative-adapter.d.ts +87 -0
- package/dist/lib/utils/creative-adapter.d.ts.map +1 -0
- package/dist/lib/utils/creative-adapter.js +125 -0
- package/dist/lib/utils/creative-adapter.js.map +1 -0
- package/dist/lib/utils/format-assets.d.ts +4 -16
- package/dist/lib/utils/format-assets.d.ts.map +1 -1
- package/dist/lib/utils/format-assets.js +16 -14
- package/dist/lib/utils/format-assets.js.map +1 -1
- package/dist/lib/utils/format-renders.d.ts +82 -0
- package/dist/lib/utils/format-renders.d.ts.map +1 -0
- package/dist/lib/utils/format-renders.js +137 -0
- package/dist/lib/utils/format-renders.js.map +1 -0
- package/dist/lib/utils/index.d.ts +2 -1
- package/dist/lib/utils/index.d.ts.map +1 -1
- package/dist/lib/utils/index.js +13 -3
- package/dist/lib/utils/index.js.map +1 -1
- package/dist/lib/utils/preview-normalizer.d.ts +109 -0
- package/dist/lib/utils/preview-normalizer.d.ts.map +1 -0
- package/dist/lib/utils/preview-normalizer.js +122 -0
- package/dist/lib/utils/preview-normalizer.js.map +1 -0
- package/dist/lib/utils/pricing-adapter.d.ts +121 -0
- package/dist/lib/utils/pricing-adapter.d.ts.map +1 -0
- package/dist/lib/utils/pricing-adapter.js +213 -0
- package/dist/lib/utils/pricing-adapter.js.map +1 -0
- package/dist/lib/utils/response-unwrapper.d.ts +2 -2
- package/dist/lib/utils/response-unwrapper.d.ts.map +1 -1
- package/dist/lib/utils/response-unwrapper.js +2 -2
- package/dist/lib/utils/response-unwrapper.js.map +1 -1
- package/dist/lib/version.d.ts +15 -7
- package/dist/lib/version.d.ts.map +1 -1
- package/dist/lib/version.js +20 -11
- package/dist/lib/version.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,9 +1,32 @@
|
|
|
1
1
|
import type { AgentConfig } from '../types';
|
|
2
|
-
import type { GetProductsRequest, GetProductsResponse, ListCreativeFormatsRequest, ListCreativeFormatsResponse, CreateMediaBuyRequest, UpdateMediaBuyRequest, UpdateMediaBuyResponse, SyncCreativesRequest, SyncCreativesResponse, ListCreativesRequest, ListCreativesResponse, GetMediaBuyDeliveryRequest, GetMediaBuyDeliveryResponse,
|
|
2
|
+
import type { GetProductsRequest, GetProductsResponse, ListCreativeFormatsRequest, ListCreativeFormatsResponse, CreateMediaBuyRequest, UpdateMediaBuyRequest, UpdateMediaBuyResponse, SyncCreativesRequest, SyncCreativesResponse, ListCreativesRequest, ListCreativesResponse, GetMediaBuyDeliveryRequest, GetMediaBuyDeliveryResponse, ProvidePerformanceFeedbackRequest, ProvidePerformanceFeedbackResponse, GetSignalsRequest, GetSignalsResponse, ActivateSignalRequest, ActivateSignalResponse, PreviewCreativeRequest, PreviewCreativeResponse, Format, GetAdCPCapabilitiesRequest, GetAdCPCapabilitiesResponse } from '../types/tools.generated';
|
|
3
3
|
import type { MCPWebhookPayload, CreateMediaBuyResponse } from '../types/core.generated';
|
|
4
4
|
import type { Task as A2ATask, TaskStatusUpdateEvent } from '@a2a-js/sdk';
|
|
5
5
|
import type { InputHandler, TaskOptions, TaskResult, ConversationConfig, TaskInfo } from './ConversationTypes';
|
|
6
6
|
import type { Activity, AsyncHandlerConfig } from './AsyncHandler';
|
|
7
|
+
import type { AdcpCapabilities } from '../utils/capabilities';
|
|
8
|
+
/**
|
|
9
|
+
* Error class for v3 feature compatibility issues
|
|
10
|
+
*
|
|
11
|
+
* Note: The library no longer throws this error for get_products calls with
|
|
12
|
+
* unsupported v3 features. Instead, it returns an empty result (semantically
|
|
13
|
+
* "no products match this filter"). This error class is exported for use in
|
|
14
|
+
* custom validation logic or other scenarios.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* // Custom validation before making requests
|
|
19
|
+
* const capabilities = await client.getCapabilities();
|
|
20
|
+
* if (params.property_list && !capabilities.features.propertyListFiltering) {
|
|
21
|
+
* throw new UnsupportedFeatureError('property_list', capabilities.version);
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare class UnsupportedFeatureError extends Error {
|
|
26
|
+
readonly feature: string;
|
|
27
|
+
readonly serverVersion: 'v2' | 'v3';
|
|
28
|
+
constructor(feature: string, serverVersion: 'v2' | 'v3', message?: string);
|
|
29
|
+
}
|
|
7
30
|
/**
|
|
8
31
|
* Configuration for SingleAgentClient (and multi-agent client)
|
|
9
32
|
*/
|
|
@@ -83,6 +106,7 @@ export declare class SingleAgentClient {
|
|
|
83
106
|
private normalizedAgent;
|
|
84
107
|
private discoveredEndpoint?;
|
|
85
108
|
private canonicalBaseUrl?;
|
|
109
|
+
private cachedCapabilities?;
|
|
86
110
|
constructor(agent: AgentConfig, config?: SingleAgentClientConfig);
|
|
87
111
|
/**
|
|
88
112
|
* Ensure MCP endpoint is discovered (lazy initialization)
|
|
@@ -251,8 +275,32 @@ export declare class SingleAgentClient {
|
|
|
251
275
|
verifyWebhookSignature(payload: any, signature: string, timestamp: string | number): boolean;
|
|
252
276
|
/**
|
|
253
277
|
* Execute task and call appropriate handler on completion
|
|
278
|
+
*
|
|
279
|
+
* Automatically adapts requests for v2 servers and normalizes responses.
|
|
254
280
|
*/
|
|
255
281
|
private executeAndHandle;
|
|
282
|
+
/**
|
|
283
|
+
* Adapt request parameters for the detected server version
|
|
284
|
+
*
|
|
285
|
+
* Converts v3-style requests to v2 format when talking to v2 servers.
|
|
286
|
+
*/
|
|
287
|
+
private adaptRequestForServerVersion;
|
|
288
|
+
/**
|
|
289
|
+
* Normalize response to v3 format
|
|
290
|
+
*
|
|
291
|
+
* Converts v2 responses to v3 structure for consistent API surface.
|
|
292
|
+
*/
|
|
293
|
+
private normalizeResponseToV3;
|
|
294
|
+
/**
|
|
295
|
+
* Check if request uses v3 features that the server doesn't support
|
|
296
|
+
*
|
|
297
|
+
* Returns an early empty result if the request requires v3 features
|
|
298
|
+
* that the server doesn't support. This treats "products matching unsupported
|
|
299
|
+
* capability" as an empty result set rather than an error.
|
|
300
|
+
*
|
|
301
|
+
* @returns TaskResult with empty data if v3 features are unsupported, null to proceed normally
|
|
302
|
+
*/
|
|
303
|
+
private getEarlyResultForUnsupportedFeatures;
|
|
256
304
|
/**
|
|
257
305
|
* Discover available advertising products
|
|
258
306
|
*
|
|
@@ -331,14 +379,6 @@ export declare class SingleAgentClient {
|
|
|
331
379
|
* @param options - Task execution options
|
|
332
380
|
*/
|
|
333
381
|
getMediaBuyDelivery(params: GetMediaBuyDeliveryRequest, inputHandler?: InputHandler, options?: TaskOptions): Promise<TaskResult<GetMediaBuyDeliveryResponse>>;
|
|
334
|
-
/**
|
|
335
|
-
* List authorized properties
|
|
336
|
-
*
|
|
337
|
-
* @param params - Property listing parameters
|
|
338
|
-
* @param inputHandler - Handler for clarification requests
|
|
339
|
-
* @param options - Task execution options
|
|
340
|
-
*/
|
|
341
|
-
listAuthorizedProperties(params: ListAuthorizedPropertiesRequest, inputHandler?: InputHandler, options?: TaskOptions): Promise<TaskResult<ListAuthorizedPropertiesResponse>>;
|
|
342
382
|
/**
|
|
343
383
|
* Provide performance feedback
|
|
344
384
|
*
|
|
@@ -363,6 +403,14 @@ export declare class SingleAgentClient {
|
|
|
363
403
|
* @param options - Task execution options
|
|
364
404
|
*/
|
|
365
405
|
activateSignal(params: ActivateSignalRequest, inputHandler?: InputHandler, options?: TaskOptions): Promise<TaskResult<ActivateSignalResponse>>;
|
|
406
|
+
/**
|
|
407
|
+
* Get AdCP capabilities
|
|
408
|
+
*
|
|
409
|
+
* @param params - Capabilities request parameters
|
|
410
|
+
* @param inputHandler - Handler for clarification requests
|
|
411
|
+
* @param options - Task execution options
|
|
412
|
+
*/
|
|
413
|
+
getAdcpCapabilities(params: GetAdCPCapabilitiesRequest, inputHandler?: InputHandler, options?: TaskOptions): Promise<TaskResult<GetAdCPCapabilitiesResponse>>;
|
|
366
414
|
/**
|
|
367
415
|
* Execute any task by name with type safety
|
|
368
416
|
*
|
|
@@ -618,6 +666,37 @@ export declare class SingleAgentClient {
|
|
|
618
666
|
parameters?: string[];
|
|
619
667
|
}>;
|
|
620
668
|
}>;
|
|
669
|
+
/**
|
|
670
|
+
* Get agent capabilities, including AdCP version support
|
|
671
|
+
*
|
|
672
|
+
* For v3 servers, calls get_adcp_capabilities tool.
|
|
673
|
+
* For v2 servers, builds synthetic capabilities from available tools.
|
|
674
|
+
*
|
|
675
|
+
* @returns Promise resolving to normalized capabilities object
|
|
676
|
+
*
|
|
677
|
+
* @example
|
|
678
|
+
* ```typescript
|
|
679
|
+
* const capabilities = await client.getCapabilities();
|
|
680
|
+
*
|
|
681
|
+
* console.log(`Server version: ${capabilities.version}`);
|
|
682
|
+
* console.log(`Protocols: ${capabilities.protocols.join(', ')}`);
|
|
683
|
+
*
|
|
684
|
+
* if (capabilities.features.propertyListFiltering) {
|
|
685
|
+
* // Use v3 property list features
|
|
686
|
+
* }
|
|
687
|
+
* ```
|
|
688
|
+
*/
|
|
689
|
+
getCapabilities(): Promise<AdcpCapabilities>;
|
|
690
|
+
/**
|
|
691
|
+
* Detect server AdCP version
|
|
692
|
+
*
|
|
693
|
+
* @returns 'v2' or 'v3' based on server capabilities
|
|
694
|
+
*/
|
|
695
|
+
detectServerVersion(): Promise<'v2' | 'v3'>;
|
|
696
|
+
/**
|
|
697
|
+
* Check if server supports a specific AdCP major version
|
|
698
|
+
*/
|
|
699
|
+
supportsVersion(version: 2 | 3): Promise<boolean>;
|
|
621
700
|
/**
|
|
622
701
|
* Query a creative agent to discover available creative formats
|
|
623
702
|
*
|
|
@@ -656,7 +735,20 @@ export declare class SingleAgentClient {
|
|
|
656
735
|
*/
|
|
657
736
|
private validateRequest;
|
|
658
737
|
/**
|
|
659
|
-
* Get request schema for a given task type
|
|
738
|
+
* Get request schema for a given task type.
|
|
739
|
+
*
|
|
740
|
+
* Note: Schema validation is not available for all task types. The following
|
|
741
|
+
* tasks use complex discriminated unions that cannot be represented in Zod
|
|
742
|
+
* without significant runtime overhead:
|
|
743
|
+
*
|
|
744
|
+
* - `get_products`: Uses conditional fields based on brief vs proposal_id
|
|
745
|
+
* - `update_media_buy`: Uses conditional package update operations
|
|
746
|
+
*
|
|
747
|
+
* For these tasks, TypeScript compile-time checking is still enforced via
|
|
748
|
+
* the generated types, but runtime validation falls back to basic type checks.
|
|
749
|
+
* Invalid requests will still be rejected by the server with descriptive errors.
|
|
750
|
+
*
|
|
751
|
+
* @internal
|
|
660
752
|
*/
|
|
661
753
|
private getRequestSchema;
|
|
662
754
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SingleAgentClient.d.ts","sourceRoot":"","sources":["../../../src/lib/core/SingleAgentClient.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,0BAA0B,EAC1B,2BAA2B,EAC3B,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,0BAA0B,EAC1B,2BAA2B,EAC3B
|
|
1
|
+
{"version":3,"file":"SingleAgentClient.d.ts","sourceRoot":"","sources":["../../../src/lib/core/SingleAgentClient.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,0BAA0B,EAC1B,2BAA2B,EAC3B,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,0BAA0B,EAC1B,2BAA2B,EAC3B,iCAAiC,EACjC,kCAAkC,EAClC,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,uBAAuB,EACvB,MAAM,EACN,0BAA0B,EAC1B,2BAA2B,EAC5B,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EACV,iBAAiB,EAGjB,sBAAsB,EACvB,MAAM,yBAAyB,CAAC;A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CAAC;IAoClD;;;;OAIG;IACG,mBAAmB,IAAI,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IAKjD;;OAEG;IACG,eAAe,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAOvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;WACU,uBAAuB,CAAC,gBAAgB,EAAE,MAAM,EAAE,QAAQ,GAAE,KAAK,GAAG,KAAa,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAoBlH;;OAEG;IACH,OAAO,CAAC,eAAe;IAyBvB;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,gBAAgB;CAezB;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,uBAAuB,GAAG,iBAAiB,CAE/G"}
|
|
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
};
|
|
35
35
|
})();
|
|
36
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
-
exports.SingleAgentClient = void 0;
|
|
37
|
+
exports.SingleAgentClient = exports.UnsupportedFeatureError = void 0;
|
|
38
38
|
exports.createSingleAgentClient = createSingleAgentClient;
|
|
39
39
|
const zod_1 = require("zod");
|
|
40
40
|
const schemas = __importStar(require("../types/schemas.generated"));
|
|
@@ -42,6 +42,39 @@ const TaskExecutor_1 = require("./TaskExecutor");
|
|
|
42
42
|
const AsyncHandler_1 = require("./AsyncHandler");
|
|
43
43
|
const response_unwrapper_1 = require("../utils/response-unwrapper");
|
|
44
44
|
const crypto = __importStar(require("crypto"));
|
|
45
|
+
const capabilities_1 = require("../utils/capabilities");
|
|
46
|
+
const creative_adapter_1 = require("../utils/creative-adapter");
|
|
47
|
+
const format_renders_1 = require("../utils/format-renders");
|
|
48
|
+
const preview_normalizer_1 = require("../utils/preview-normalizer");
|
|
49
|
+
const pricing_adapter_1 = require("../utils/pricing-adapter");
|
|
50
|
+
/**
|
|
51
|
+
* Error class for v3 feature compatibility issues
|
|
52
|
+
*
|
|
53
|
+
* Note: The library no longer throws this error for get_products calls with
|
|
54
|
+
* unsupported v3 features. Instead, it returns an empty result (semantically
|
|
55
|
+
* "no products match this filter"). This error class is exported for use in
|
|
56
|
+
* custom validation logic or other scenarios.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* // Custom validation before making requests
|
|
61
|
+
* const capabilities = await client.getCapabilities();
|
|
62
|
+
* if (params.property_list && !capabilities.features.propertyListFiltering) {
|
|
63
|
+
* throw new UnsupportedFeatureError('property_list', capabilities.version);
|
|
64
|
+
* }
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
class UnsupportedFeatureError extends Error {
|
|
68
|
+
feature;
|
|
69
|
+
serverVersion;
|
|
70
|
+
constructor(feature, serverVersion, message) {
|
|
71
|
+
super(message || `Feature '${feature}' requires AdCP v3 but server is ${serverVersion}`);
|
|
72
|
+
this.feature = feature;
|
|
73
|
+
this.serverVersion = serverVersion;
|
|
74
|
+
this.name = 'UnsupportedFeatureError';
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.UnsupportedFeatureError = UnsupportedFeatureError;
|
|
45
78
|
/**
|
|
46
79
|
* Internal single-agent client implementation
|
|
47
80
|
*
|
|
@@ -64,6 +97,7 @@ class SingleAgentClient {
|
|
|
64
97
|
normalizedAgent;
|
|
65
98
|
discoveredEndpoint; // Cache discovered MCP endpoint
|
|
66
99
|
canonicalBaseUrl; // Cache canonical base URL (from agent card or stripped /mcp)
|
|
100
|
+
cachedCapabilities; // Cache detected server capabilities
|
|
67
101
|
constructor(agent, config = {}) {
|
|
68
102
|
this.agent = agent;
|
|
69
103
|
this.config = config;
|
|
@@ -594,12 +628,25 @@ class SingleAgentClient {
|
|
|
594
628
|
}
|
|
595
629
|
/**
|
|
596
630
|
* Execute task and call appropriate handler on completion
|
|
631
|
+
*
|
|
632
|
+
* Automatically adapts requests for v2 servers and normalizes responses.
|
|
597
633
|
*/
|
|
598
634
|
async executeAndHandle(taskType, handlerName, params, inputHandler, options) {
|
|
599
635
|
// Validate request params against schema
|
|
600
636
|
this.validateRequest(taskType, params);
|
|
637
|
+
// Check for v3 features used against v2 servers - return empty result if unsupported
|
|
638
|
+
const earlyResult = await this.getEarlyResultForUnsupportedFeatures(taskType, params);
|
|
639
|
+
if (earlyResult) {
|
|
640
|
+
return earlyResult;
|
|
641
|
+
}
|
|
601
642
|
const agent = await this.ensureEndpointDiscovered();
|
|
602
|
-
|
|
643
|
+
// Adapt request for v2 servers if needed
|
|
644
|
+
const adaptedParams = await this.adaptRequestForServerVersion(taskType, params);
|
|
645
|
+
const result = await this.executor.executeTask(agent, taskType, adaptedParams, inputHandler, options);
|
|
646
|
+
// Normalize response to v3 format
|
|
647
|
+
if (result.success && result.data) {
|
|
648
|
+
result.data = this.normalizeResponseToV3(taskType, result.data);
|
|
649
|
+
}
|
|
603
650
|
// Call handler if task completed successfully and handler is configured
|
|
604
651
|
if (result.status === 'completed' && result.success && this.asyncHandler) {
|
|
605
652
|
const handler = this.config.handlers?.[handlerName];
|
|
@@ -617,6 +664,106 @@ class SingleAgentClient {
|
|
|
617
664
|
}
|
|
618
665
|
return result;
|
|
619
666
|
}
|
|
667
|
+
/**
|
|
668
|
+
* Adapt request parameters for the detected server version
|
|
669
|
+
*
|
|
670
|
+
* Converts v3-style requests to v2 format when talking to v2 servers.
|
|
671
|
+
*/
|
|
672
|
+
async adaptRequestForServerVersion(taskType, params) {
|
|
673
|
+
// Get server version (cached after first call)
|
|
674
|
+
const version = await this.detectServerVersion();
|
|
675
|
+
// If server is v3, no adaptation needed
|
|
676
|
+
if (version === 'v3') {
|
|
677
|
+
return params;
|
|
678
|
+
}
|
|
679
|
+
// Adapt v3 requests for v2 servers
|
|
680
|
+
switch (taskType) {
|
|
681
|
+
case 'create_media_buy':
|
|
682
|
+
return (0, creative_adapter_1.adaptCreateMediaBuyRequestForV2)(params);
|
|
683
|
+
case 'update_media_buy':
|
|
684
|
+
return (0, creative_adapter_1.adaptUpdateMediaBuyRequestForV2)(params);
|
|
685
|
+
default:
|
|
686
|
+
return params;
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* Normalize response to v3 format
|
|
691
|
+
*
|
|
692
|
+
* Converts v2 responses to v3 structure for consistent API surface.
|
|
693
|
+
*/
|
|
694
|
+
normalizeResponseToV3(taskType, data) {
|
|
695
|
+
switch (taskType) {
|
|
696
|
+
case 'get_products':
|
|
697
|
+
return (0, pricing_adapter_1.normalizeGetProductsResponse)(data);
|
|
698
|
+
case 'list_creative_formats':
|
|
699
|
+
return (0, format_renders_1.normalizeFormatsResponse)(data);
|
|
700
|
+
case 'preview_creative':
|
|
701
|
+
return (0, preview_normalizer_1.normalizePreviewCreativeResponse)(data);
|
|
702
|
+
case 'create_media_buy':
|
|
703
|
+
case 'update_media_buy':
|
|
704
|
+
return (0, creative_adapter_1.normalizeMediaBuyResponse)(data);
|
|
705
|
+
default:
|
|
706
|
+
return data;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
/**
|
|
710
|
+
* Check if request uses v3 features that the server doesn't support
|
|
711
|
+
*
|
|
712
|
+
* Returns an early empty result if the request requires v3 features
|
|
713
|
+
* that the server doesn't support. This treats "products matching unsupported
|
|
714
|
+
* capability" as an empty result set rather than an error.
|
|
715
|
+
*
|
|
716
|
+
* @returns TaskResult with empty data if v3 features are unsupported, null to proceed normally
|
|
717
|
+
*/
|
|
718
|
+
async getEarlyResultForUnsupportedFeatures(taskType, params) {
|
|
719
|
+
// Only check for tasks that have v3-specific features
|
|
720
|
+
if (taskType !== 'get_products') {
|
|
721
|
+
return null;
|
|
722
|
+
}
|
|
723
|
+
// Get capabilities to check what the server supports
|
|
724
|
+
const capabilities = await this.getCapabilities();
|
|
725
|
+
// If server is v3, all features are supported - proceed normally
|
|
726
|
+
if (capabilities.version === 'v3') {
|
|
727
|
+
return null;
|
|
728
|
+
}
|
|
729
|
+
// Check for v3-only features that would make this query return empty results
|
|
730
|
+
const usesUnsupportedFeature =
|
|
731
|
+
// property_list requires propertyListFiltering
|
|
732
|
+
(params.property_list && !capabilities.features.propertyListFiltering) ||
|
|
733
|
+
// required_features: content_standards requires contentStandards
|
|
734
|
+
(params.filters?.required_features?.includes('content_standards') && !capabilities.features.contentStandards) ||
|
|
735
|
+
// required_features: property_list_filtering requires propertyListFiltering
|
|
736
|
+
(params.filters?.required_features?.includes('property_list_filtering') &&
|
|
737
|
+
!capabilities.features.propertyListFiltering);
|
|
738
|
+
if (!usesUnsupportedFeature) {
|
|
739
|
+
return null; // Proceed normally
|
|
740
|
+
}
|
|
741
|
+
// Log warning about v2 downgrade
|
|
742
|
+
console.warn(`[AdCP] v3-only features not supported by server "${this.agent.id}" (${capabilities.version}). Returning empty results.`);
|
|
743
|
+
// Return empty result - semantically "no products match this filter"
|
|
744
|
+
const emptyResponse = {
|
|
745
|
+
products: [],
|
|
746
|
+
property_list_applied: false,
|
|
747
|
+
};
|
|
748
|
+
return {
|
|
749
|
+
success: true,
|
|
750
|
+
status: 'completed',
|
|
751
|
+
data: emptyResponse,
|
|
752
|
+
metadata: {
|
|
753
|
+
taskId: `early_${Date.now()}`,
|
|
754
|
+
taskName: taskType,
|
|
755
|
+
agent: {
|
|
756
|
+
id: this.agent.id,
|
|
757
|
+
name: this.agent.name,
|
|
758
|
+
protocol: this.normalizedAgent.protocol,
|
|
759
|
+
},
|
|
760
|
+
responseTimeMs: 0,
|
|
761
|
+
timestamp: new Date().toISOString(),
|
|
762
|
+
clarificationRounds: 0,
|
|
763
|
+
status: 'completed',
|
|
764
|
+
},
|
|
765
|
+
};
|
|
766
|
+
}
|
|
620
767
|
// ====== MEDIA BUY TASKS ======
|
|
621
768
|
/**
|
|
622
769
|
* Discover available advertising products
|
|
@@ -743,16 +890,6 @@ class SingleAgentClient {
|
|
|
743
890
|
async getMediaBuyDelivery(params, inputHandler, options) {
|
|
744
891
|
return this.executeAndHandle('get_media_buy_delivery', 'onGetMediaBuyDeliveryStatusChange', params, inputHandler, options);
|
|
745
892
|
}
|
|
746
|
-
/**
|
|
747
|
-
* List authorized properties
|
|
748
|
-
*
|
|
749
|
-
* @param params - Property listing parameters
|
|
750
|
-
* @param inputHandler - Handler for clarification requests
|
|
751
|
-
* @param options - Task execution options
|
|
752
|
-
*/
|
|
753
|
-
async listAuthorizedProperties(params, inputHandler, options) {
|
|
754
|
-
return this.executeAndHandle('list_authorized_properties', 'onListAuthorizedPropertiesStatusChange', params, inputHandler, options);
|
|
755
|
-
}
|
|
756
893
|
/**
|
|
757
894
|
* Provide performance feedback
|
|
758
895
|
*
|
|
@@ -784,6 +921,18 @@ class SingleAgentClient {
|
|
|
784
921
|
async activateSignal(params, inputHandler, options) {
|
|
785
922
|
return this.executeAndHandle('activate_signal', 'onActivateSignalStatusChange', params, inputHandler, options);
|
|
786
923
|
}
|
|
924
|
+
// ====== PROTOCOL TASKS ======
|
|
925
|
+
/**
|
|
926
|
+
* Get AdCP capabilities
|
|
927
|
+
*
|
|
928
|
+
* @param params - Capabilities request parameters
|
|
929
|
+
* @param inputHandler - Handler for clarification requests
|
|
930
|
+
* @param options - Task execution options
|
|
931
|
+
*/
|
|
932
|
+
async getAdcpCapabilities(params, inputHandler, options) {
|
|
933
|
+
const agent = await this.ensureEndpointDiscovered();
|
|
934
|
+
return this.executor.executeTask(agent, 'get_adcp_capabilities', params, inputHandler, options);
|
|
935
|
+
}
|
|
787
936
|
// ====== GENERIC TASK EXECUTION ======
|
|
788
937
|
/**
|
|
789
938
|
* Execute any task by name with type safety
|
|
@@ -1224,6 +1373,73 @@ class SingleAgentClient {
|
|
|
1224
1373
|
}
|
|
1225
1374
|
throw new Error(`Unsupported protocol: ${this.normalizedAgent.protocol}`);
|
|
1226
1375
|
}
|
|
1376
|
+
/**
|
|
1377
|
+
* Get agent capabilities, including AdCP version support
|
|
1378
|
+
*
|
|
1379
|
+
* For v3 servers, calls get_adcp_capabilities tool.
|
|
1380
|
+
* For v2 servers, builds synthetic capabilities from available tools.
|
|
1381
|
+
*
|
|
1382
|
+
* @returns Promise resolving to normalized capabilities object
|
|
1383
|
+
*
|
|
1384
|
+
* @example
|
|
1385
|
+
* ```typescript
|
|
1386
|
+
* const capabilities = await client.getCapabilities();
|
|
1387
|
+
*
|
|
1388
|
+
* console.log(`Server version: ${capabilities.version}`);
|
|
1389
|
+
* console.log(`Protocols: ${capabilities.protocols.join(', ')}`);
|
|
1390
|
+
*
|
|
1391
|
+
* if (capabilities.features.propertyListFiltering) {
|
|
1392
|
+
* // Use v3 property list features
|
|
1393
|
+
* }
|
|
1394
|
+
* ```
|
|
1395
|
+
*/
|
|
1396
|
+
async getCapabilities() {
|
|
1397
|
+
// Return cached if available
|
|
1398
|
+
if (this.cachedCapabilities) {
|
|
1399
|
+
return this.cachedCapabilities;
|
|
1400
|
+
}
|
|
1401
|
+
// First get tool list to support both detection methods
|
|
1402
|
+
const agentInfo = await this.getAgentInfo();
|
|
1403
|
+
const tools = agentInfo.tools.map(t => ({
|
|
1404
|
+
name: t.name,
|
|
1405
|
+
description: t.description,
|
|
1406
|
+
}));
|
|
1407
|
+
// Check if agent supports get_adcp_capabilities (v3)
|
|
1408
|
+
const hasCapabilitiesTool = tools.some(t => t.name === 'get_adcp_capabilities');
|
|
1409
|
+
if (hasCapabilitiesTool) {
|
|
1410
|
+
try {
|
|
1411
|
+
// Call get_adcp_capabilities tool
|
|
1412
|
+
const agent = await this.ensureEndpointDiscovered();
|
|
1413
|
+
const result = await this.executor.executeTask(agent, 'get_adcp_capabilities', {}, undefined);
|
|
1414
|
+
if (result.success && result.data) {
|
|
1415
|
+
this.cachedCapabilities = (0, capabilities_1.parseCapabilitiesResponse)(result.data);
|
|
1416
|
+
return this.cachedCapabilities;
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
catch {
|
|
1420
|
+
// Fall through to synthetic capabilities
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
// Build synthetic capabilities from tool list (v2)
|
|
1424
|
+
this.cachedCapabilities = (0, capabilities_1.buildSyntheticCapabilities)(tools);
|
|
1425
|
+
return this.cachedCapabilities;
|
|
1426
|
+
}
|
|
1427
|
+
/**
|
|
1428
|
+
* Detect server AdCP version
|
|
1429
|
+
*
|
|
1430
|
+
* @returns 'v2' or 'v3' based on server capabilities
|
|
1431
|
+
*/
|
|
1432
|
+
async detectServerVersion() {
|
|
1433
|
+
const capabilities = await this.getCapabilities();
|
|
1434
|
+
return capabilities.version;
|
|
1435
|
+
}
|
|
1436
|
+
/**
|
|
1437
|
+
* Check if server supports a specific AdCP major version
|
|
1438
|
+
*/
|
|
1439
|
+
async supportsVersion(version) {
|
|
1440
|
+
const capabilities = await this.getCapabilities();
|
|
1441
|
+
return capabilities.majorVersions.includes(version);
|
|
1442
|
+
}
|
|
1227
1443
|
// ====== STATIC HELPER METHODS ======
|
|
1228
1444
|
/**
|
|
1229
1445
|
* Query a creative agent to discover available creative formats
|
|
@@ -1299,19 +1515,30 @@ class SingleAgentClient {
|
|
|
1299
1515
|
}
|
|
1300
1516
|
}
|
|
1301
1517
|
/**
|
|
1302
|
-
* Get request schema for a given task type
|
|
1518
|
+
* Get request schema for a given task type.
|
|
1519
|
+
*
|
|
1520
|
+
* Note: Schema validation is not available for all task types. The following
|
|
1521
|
+
* tasks use complex discriminated unions that cannot be represented in Zod
|
|
1522
|
+
* without significant runtime overhead:
|
|
1523
|
+
*
|
|
1524
|
+
* - `get_products`: Uses conditional fields based on brief vs proposal_id
|
|
1525
|
+
* - `update_media_buy`: Uses conditional package update operations
|
|
1526
|
+
*
|
|
1527
|
+
* For these tasks, TypeScript compile-time checking is still enforced via
|
|
1528
|
+
* the generated types, but runtime validation falls back to basic type checks.
|
|
1529
|
+
* Invalid requests will still be rejected by the server with descriptive errors.
|
|
1530
|
+
*
|
|
1531
|
+
* @internal
|
|
1303
1532
|
*/
|
|
1304
1533
|
getRequestSchema(taskType) {
|
|
1305
|
-
// Only include schemas that exist in generated schemas
|
|
1306
1534
|
const schemaMap = {
|
|
1307
|
-
get_products:
|
|
1535
|
+
// get_products: excluded - complex discriminated unions (brief vs proposal_id)
|
|
1308
1536
|
list_creative_formats: schemas.ListCreativeFormatsRequestSchema,
|
|
1309
1537
|
create_media_buy: schemas.CreateMediaBuyRequestSchema,
|
|
1310
|
-
update_media_buy:
|
|
1538
|
+
// update_media_buy: excluded - complex discriminated unions (package operations)
|
|
1311
1539
|
sync_creatives: schemas.SyncCreativesRequestSchema,
|
|
1312
1540
|
list_creatives: schemas.ListCreativesRequestSchema,
|
|
1313
1541
|
get_media_buy_delivery: schemas.GetMediaBuyDeliveryRequestSchema,
|
|
1314
|
-
list_authorized_properties: schemas.ListAuthorizedPropertiesRequestSchema,
|
|
1315
1542
|
get_signals: schemas.GetSignalsRequestSchema,
|
|
1316
1543
|
activate_signal: schemas.ActivateSignalRequestSchema,
|
|
1317
1544
|
};
|