@adcp/sdk 15.3.0 → 15.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/advanced.d.mts +2 -2
- package/dist/lib/advanced.d.ts +2 -2
- package/dist/lib/advanced.js +8 -2
- package/dist/lib/advanced.mjs +8 -2
- package/dist/lib/core/AgentClient.d.mts +4 -0
- package/dist/lib/core/AgentClient.d.ts +4 -0
- package/dist/lib/core/AgentClient.js +8 -0
- package/dist/lib/core/AgentClient.mjs +8 -0
- package/dist/lib/core/SingleAgentClient.d.mts +154 -0
- package/dist/lib/core/SingleAgentClient.d.ts +154 -0
- package/dist/lib/core/SingleAgentClient.js +661 -23
- package/dist/lib/core/SingleAgentClient.mjs +666 -23
- package/dist/lib/core/agent-discovery-cache.d.mts +103 -0
- package/dist/lib/core/agent-discovery-cache.d.ts +103 -0
- package/dist/lib/core/agent-discovery-cache.js +121 -0
- package/dist/lib/core/agent-discovery-cache.mjs +92 -0
- package/dist/lib/index.d.mts +5 -3
- package/dist/lib/index.d.ts +5 -3
- package/dist/lib/index.js +7 -0
- package/dist/lib/index.mjs +6 -0
- package/dist/lib/protocols/index.d.mts +2 -2
- package/dist/lib/protocols/index.d.ts +2 -2
- package/dist/lib/protocols/index.js +1 -1
- package/dist/lib/protocols/index.mjs +1 -1
- package/dist/lib/protocols/mcp-call-context.d.mts +109 -0
- package/dist/lib/protocols/mcp-call-context.d.ts +109 -0
- package/dist/lib/protocols/mcp-call-context.js +221 -0
- package/dist/lib/protocols/mcp-call-context.mjs +186 -0
- package/dist/lib/protocols/mcp-modern.d.mts +9 -1
- package/dist/lib/protocols/mcp-modern.d.ts +9 -1
- package/dist/lib/protocols/mcp-modern.js +180 -104
- package/dist/lib/protocols/mcp-modern.mjs +193 -104
- package/dist/lib/protocols/mcp-scope.d.mts +15 -0
- package/dist/lib/protocols/mcp-scope.d.ts +15 -0
- package/dist/lib/protocols/mcp.d.mts +4 -2
- package/dist/lib/protocols/mcp.d.ts +4 -2
- package/dist/lib/protocols/mcp.js +178 -154
- package/dist/lib/protocols/mcp.mjs +189 -153
- package/dist/lib/protocols/transportDiagnostics.d.mts +33 -1
- package/dist/lib/protocols/transportDiagnostics.d.ts +33 -1
- package/dist/lib/protocols/transportDiagnostics.js +128 -12
- package/dist/lib/protocols/transportDiagnostics.mjs +128 -12
- package/dist/lib/reporting/gcs/index.d.mts +2 -0
- package/dist/lib/reporting/gcs/index.d.ts +2 -0
- package/dist/lib/reporting/gcs/index.js +3 -0
- package/dist/lib/reporting/gcs/index.mjs +2 -0
- package/dist/lib/reporting/gcs/row-provider.d.mts +32 -0
- package/dist/lib/reporting/gcs/row-provider.d.ts +32 -0
- package/dist/lib/reporting/gcs/row-provider.js +205 -0
- package/dist/lib/reporting/gcs/row-provider.mjs +188 -0
- package/dist/lib/reporting/ledger/change-feed.d.mts +41 -0
- package/dist/lib/reporting/ledger/change-feed.d.ts +41 -0
- package/dist/lib/reporting/ledger/change-feed.js +101 -0
- package/dist/lib/reporting/ledger/change-feed.mjs +74 -0
- package/dist/lib/reporting/ledger/handler.d.mts +6 -0
- package/dist/lib/reporting/ledger/handler.d.ts +6 -0
- package/dist/lib/reporting/ledger/handler.js +51 -8
- package/dist/lib/reporting/ledger/handler.mjs +50 -8
- package/dist/lib/reporting/ledger/index.d.mts +5 -0
- package/dist/lib/reporting/ledger/index.d.ts +5 -0
- package/dist/lib/reporting/ledger/index.js +11 -1
- package/dist/lib/reporting/ledger/index.mjs +5 -0
- package/dist/lib/reporting/ledger/lifecycle.js +3 -2
- package/dist/lib/reporting/ledger/lifecycle.mjs +3 -2
- package/dist/lib/reporting/ledger/managed-postgres.d.mts +2 -0
- package/dist/lib/reporting/ledger/managed-postgres.d.ts +2 -0
- package/dist/lib/reporting/ledger/managed-postgres.js +26 -6
- package/dist/lib/reporting/ledger/managed-postgres.mjs +26 -6
- package/dist/lib/reporting/ledger/managed.d.mts +9 -0
- package/dist/lib/reporting/ledger/managed.d.ts +9 -0
- package/dist/lib/reporting/ledger/managed.js +18 -0
- package/dist/lib/reporting/ledger/managed.mjs +18 -0
- package/dist/lib/reporting/ledger/postgres.d.mts +179 -1
- package/dist/lib/reporting/ledger/postgres.d.ts +179 -1
- package/dist/lib/reporting/ledger/postgres.js +882 -19
- package/dist/lib/reporting/ledger/postgres.mjs +890 -19
- package/dist/lib/reporting/ledger/producer.js +13 -3
- package/dist/lib/reporting/ledger/producer.mjs +13 -3
- package/dist/lib/reporting/ledger/revision-metadata.d.mts +17 -0
- package/dist/lib/reporting/ledger/revision-metadata.d.ts +17 -0
- package/dist/lib/reporting/ledger/revision-metadata.js +71 -0
- package/dist/lib/reporting/ledger/revision-metadata.mjs +44 -0
- package/dist/lib/reporting/ledger/row-encoding.d.mts +128 -0
- package/dist/lib/reporting/ledger/row-encoding.d.ts +128 -0
- package/dist/lib/reporting/ledger/row-encoding.js +355 -0
- package/dist/lib/reporting/ledger/row-encoding.mjs +315 -0
- package/dist/lib/reporting/ledger/row-storage-errors.d.mts +7 -0
- package/dist/lib/reporting/ledger/row-storage-errors.d.ts +7 -0
- package/dist/lib/reporting/ledger/row-storage-errors.js +41 -0
- package/dist/lib/reporting/ledger/row-storage-errors.mjs +16 -0
- package/dist/lib/reporting/ledger/row-storage-migration.d.mts +41 -0
- package/dist/lib/reporting/ledger/row-storage-migration.d.ts +41 -0
- package/dist/lib/reporting/ledger/row-storage-migration.js +234 -0
- package/dist/lib/reporting/ledger/row-storage-migration.mjs +208 -0
- package/dist/lib/reporting/ledger/row-storage-object.d.mts +112 -0
- package/dist/lib/reporting/ledger/row-storage-object.d.ts +112 -0
- package/dist/lib/reporting/ledger/row-storage-object.js +281 -0
- package/dist/lib/reporting/ledger/row-storage-object.mjs +239 -0
- package/dist/lib/reporting/ledger/row-storage-provider-io.d.mts +51 -0
- package/dist/lib/reporting/ledger/row-storage-provider-io.d.ts +51 -0
- package/dist/lib/reporting/ledger/row-storage-provider-io.js +152 -0
- package/dist/lib/reporting/ledger/row-storage-provider-io.mjs +119 -0
- package/dist/lib/reporting/ledger/row-storage.d.mts +224 -0
- package/dist/lib/reporting/ledger/row-storage.d.ts +224 -0
- package/dist/lib/reporting/ledger/row-storage.js +692 -0
- package/dist/lib/reporting/ledger/row-storage.mjs +680 -0
- package/dist/lib/reporting/ledger/types.d.mts +45 -0
- package/dist/lib/reporting/ledger/types.d.ts +45 -0
- package/dist/lib/reporting/service/index.d.mts +41 -1
- package/dist/lib/reporting/service/index.d.ts +41 -1
- package/dist/lib/reporting/service/index.js +68 -1
- package/dist/lib/reporting/service/index.mjs +70 -1
- package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
- package/dist/lib/signing/agent-resolver/fetch-helpers.js +1 -1
- package/dist/lib/signing/agent-resolver/fetch-helpers.mjs +1 -1
- package/dist/lib/testing/storyboard/validations.d.mts +1 -1
- package/dist/lib/testing/storyboard/validations.d.ts +1 -1
- package/dist/lib/version.d.mts +3 -3
- package/dist/lib/version.d.ts +3 -3
- package/dist/lib/version.js +3 -3
- package/dist/lib/version.mjs +3 -3
- package/docs/README.md +1 -1
- package/docs/TYPE-SUMMARY.md +35 -2
- package/docs/guides/DISCOVERY-CACHE-AND-SESSION-REUSE.md +142 -0
- package/docs/guides/EXISTING-PLATFORM.md +43 -12
- package/docs/guides/REPORTING-LEDGER.md +209 -0
- package/docs/llms.txt +4 -2
- package/docs/migration-14.x-rc-worksheet.md +4 -4
- package/docs/recipes/verifying-inbound-webhooks.md +8 -0
- package/package.json +1 -1
package/dist/lib/advanced.d.mts
CHANGED
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
* - Type-safe tool methods
|
|
38
38
|
* - Error handling and validation
|
|
39
39
|
*/
|
|
40
|
-
export { ProtocolClient, callMCPTool, callMCPToolWithOAuth, connectMCP, callA2ATool, createMCPClient, createA2AClient, } from './protocols/index.mjs';
|
|
41
|
-
export type { MCPCallOptions, MCPConnectionResult } from './protocols/index.mjs';
|
|
40
|
+
export { ProtocolClient, callMCPTool, callMCPToolWithOAuth, connectMCP, callA2ATool, createMCPClient, createA2AClient, closeConnections, closeScopedConnections, withMCPConnectionScope, } from './protocols/index.mjs';
|
|
41
|
+
export type { MCPCallOptions, MCPConnectionResult, TransportActivity, TransportActivityType, TransportResponseOutcome, } from './protocols/index.mjs';
|
package/dist/lib/advanced.d.ts
CHANGED
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
* - Type-safe tool methods
|
|
38
38
|
* - Error handling and validation
|
|
39
39
|
*/
|
|
40
|
-
export { ProtocolClient, callMCPTool, callMCPToolWithOAuth, connectMCP, callA2ATool, createMCPClient, createA2AClient, } from './protocols';
|
|
41
|
-
export type { MCPCallOptions, MCPConnectionResult } from './protocols';
|
|
40
|
+
export { ProtocolClient, callMCPTool, callMCPToolWithOAuth, connectMCP, callA2ATool, createMCPClient, createA2AClient, closeConnections, closeScopedConnections, withMCPConnectionScope, } from './protocols';
|
|
41
|
+
export type { MCPCallOptions, MCPConnectionResult, TransportActivity, TransportActivityType, TransportResponseOutcome, } from './protocols';
|
package/dist/lib/advanced.js
CHANGED
|
@@ -22,9 +22,12 @@ __export(advanced_exports, {
|
|
|
22
22
|
callA2ATool: () => import_protocols.callA2ATool,
|
|
23
23
|
callMCPTool: () => import_protocols.callMCPTool,
|
|
24
24
|
callMCPToolWithOAuth: () => import_protocols.callMCPToolWithOAuth,
|
|
25
|
+
closeConnections: () => import_protocols.closeConnections,
|
|
26
|
+
closeScopedConnections: () => import_protocols.closeScopedConnections,
|
|
25
27
|
connectMCP: () => import_protocols.connectMCP,
|
|
26
28
|
createA2AClient: () => import_protocols.createA2AClient,
|
|
27
|
-
createMCPClient: () => import_protocols.createMCPClient
|
|
29
|
+
createMCPClient: () => import_protocols.createMCPClient,
|
|
30
|
+
withMCPConnectionScope: () => import_protocols.withMCPConnectionScope
|
|
28
31
|
});
|
|
29
32
|
module.exports = __toCommonJS(advanced_exports);
|
|
30
33
|
var import_protocols = require('./protocols/index.js');
|
|
@@ -34,7 +37,10 @@ var import_protocols = require('./protocols/index.js');
|
|
|
34
37
|
callA2ATool,
|
|
35
38
|
callMCPTool,
|
|
36
39
|
callMCPToolWithOAuth,
|
|
40
|
+
closeConnections,
|
|
41
|
+
closeScopedConnections,
|
|
37
42
|
connectMCP,
|
|
38
43
|
createA2AClient,
|
|
39
|
-
createMCPClient
|
|
44
|
+
createMCPClient,
|
|
45
|
+
withMCPConnectionScope
|
|
40
46
|
});
|
package/dist/lib/advanced.mjs
CHANGED
|
@@ -5,14 +5,20 @@ import {
|
|
|
5
5
|
connectMCP,
|
|
6
6
|
callA2ATool,
|
|
7
7
|
createMCPClient,
|
|
8
|
-
createA2AClient
|
|
8
|
+
createA2AClient,
|
|
9
|
+
closeConnections,
|
|
10
|
+
closeScopedConnections,
|
|
11
|
+
withMCPConnectionScope
|
|
9
12
|
} from "./protocols/index.mjs";
|
|
10
13
|
export {
|
|
11
14
|
ProtocolClient,
|
|
12
15
|
callA2ATool,
|
|
13
16
|
callMCPTool,
|
|
14
17
|
callMCPToolWithOAuth,
|
|
18
|
+
closeConnections,
|
|
19
|
+
closeScopedConnections,
|
|
15
20
|
connectMCP,
|
|
16
21
|
createA2AClient,
|
|
17
|
-
createMCPClient
|
|
22
|
+
createMCPClient,
|
|
23
|
+
withMCPConnectionScope
|
|
18
24
|
};
|
|
@@ -543,6 +543,10 @@ export declare class AgentClient {
|
|
|
543
543
|
resolveCreativeFormatWireMode(taskType: 'sync_creatives' | 'create_media_buy' | 'update_media_buy', options?: Pick<TaskOptions, 'signal' | 'transport'>): Promise<CreativeFormatWireMode>;
|
|
544
544
|
/** Scope token for a tenant-bound, application-owned capability preflight. */
|
|
545
545
|
getCapabilityEvidenceScope(): import('./SingleAgentClient.mjs').CapabilityEvidenceScope;
|
|
546
|
+
/** Drop this client's discovery evidence and its shared `discoveryCache` entry. */
|
|
547
|
+
invalidateDiscoveryCache(options?: Pick<TaskOptions, 'transport'>): Promise<void>;
|
|
548
|
+
/** Pre-seed the shared `discoveryCache` so peer clients skip discovery within the TTL. */
|
|
549
|
+
primeDiscoveryCache(seed: import('./SingleAgentClient.mjs').AgentDiscoverySeed): Promise<boolean>;
|
|
546
550
|
/** Install fresh capability evidence without making a redundant probe. */
|
|
547
551
|
primeCapabilities(snapshot: import('./SingleAgentClient.mjs').CapabilityEvidenceSnapshot): boolean;
|
|
548
552
|
/**
|
|
@@ -543,6 +543,10 @@ export declare class AgentClient {
|
|
|
543
543
|
resolveCreativeFormatWireMode(taskType: 'sync_creatives' | 'create_media_buy' | 'update_media_buy', options?: Pick<TaskOptions, 'signal' | 'transport'>): Promise<CreativeFormatWireMode>;
|
|
544
544
|
/** Scope token for a tenant-bound, application-owned capability preflight. */
|
|
545
545
|
getCapabilityEvidenceScope(): import('./SingleAgentClient').CapabilityEvidenceScope;
|
|
546
|
+
/** Drop this client's discovery evidence and its shared `discoveryCache` entry. */
|
|
547
|
+
invalidateDiscoveryCache(options?: Pick<TaskOptions, 'transport'>): Promise<void>;
|
|
548
|
+
/** Pre-seed the shared `discoveryCache` so peer clients skip discovery within the TTL. */
|
|
549
|
+
primeDiscoveryCache(seed: import('./SingleAgentClient').AgentDiscoverySeed): Promise<boolean>;
|
|
546
550
|
/** Install fresh capability evidence without making a redundant probe. */
|
|
547
551
|
primeCapabilities(snapshot: import('./SingleAgentClient').CapabilityEvidenceSnapshot): boolean;
|
|
548
552
|
/**
|
|
@@ -805,6 +805,14 @@ class AgentClient {
|
|
|
805
805
|
getCapabilityEvidenceScope() {
|
|
806
806
|
return this.client.getCapabilityEvidenceScope();
|
|
807
807
|
}
|
|
808
|
+
/** Drop this client's discovery evidence and its shared `discoveryCache` entry. */
|
|
809
|
+
invalidateDiscoveryCache(options) {
|
|
810
|
+
return this.client.invalidateDiscoveryCache(options);
|
|
811
|
+
}
|
|
812
|
+
/** Pre-seed the shared `discoveryCache` so peer clients skip discovery within the TTL. */
|
|
813
|
+
primeDiscoveryCache(seed) {
|
|
814
|
+
return this.client.primeDiscoveryCache(seed);
|
|
815
|
+
}
|
|
808
816
|
/** Install fresh capability evidence without making a redundant probe. */
|
|
809
817
|
primeCapabilities(snapshot) {
|
|
810
818
|
return this.client.primeCapabilities(snapshot);
|
|
@@ -773,6 +773,14 @@ class AgentClient {
|
|
|
773
773
|
getCapabilityEvidenceScope() {
|
|
774
774
|
return this.client.getCapabilityEvidenceScope();
|
|
775
775
|
}
|
|
776
|
+
/** Drop this client's discovery evidence and its shared `discoveryCache` entry. */
|
|
777
|
+
invalidateDiscoveryCache(options) {
|
|
778
|
+
return this.client.invalidateDiscoveryCache(options);
|
|
779
|
+
}
|
|
780
|
+
/** Pre-seed the shared `discoveryCache` so peer clients skip discovery within the TTL. */
|
|
781
|
+
primeDiscoveryCache(seed) {
|
|
782
|
+
return this.client.primeDiscoveryCache(seed);
|
|
783
|
+
}
|
|
776
784
|
/** Install fresh capability evidence without making a redundant probe. */
|
|
777
785
|
primeCapabilities(snapshot) {
|
|
778
786
|
return this.client.primeCapabilities(snapshot);
|
|
@@ -14,6 +14,7 @@ import { type WebhookHeaderValue, type WebhookHeadersLike } from '../webhooks/in
|
|
|
14
14
|
import { type WebhookRegistration, type WebhookRegistrationStore } from './webhook-registration.mjs';
|
|
15
15
|
import { type ReplayStore, type RevocationStore, type JwksResolver, type WebhookSignatureErrorCode, type ResolvedAgentJwksResolverOptions } from '../signing/server.mjs';
|
|
16
16
|
import type { AdcpCapabilities, FeatureName } from '../utils/capabilities.mjs';
|
|
17
|
+
import { type AgentDiscoveryCacheConfig } from './agent-discovery-cache.mjs';
|
|
17
18
|
import { BuyerAccountRegistry, type AccountPolicy, type BuyerAccountStorage } from './buyer-account-registry.mjs';
|
|
18
19
|
import type { ProductCache } from './product-cache.mjs';
|
|
19
20
|
import { type ResolveAccountOptions } from './account-resolution.mjs';
|
|
@@ -208,6 +209,21 @@ export interface SingleAgentClientConfig extends ConversationConfig {
|
|
|
208
209
|
/** Trusted stable caller identity for durable registry partitioning. Default is credential fingerprint. */
|
|
209
210
|
accountRegistryScope?: string;
|
|
210
211
|
productCache?: ProductCache;
|
|
212
|
+
/**
|
|
213
|
+
* Share endpoint discovery, the `tools/list` schema map and
|
|
214
|
+
* `get_adcp_capabilities` across client instances. Opt-in: nothing is shared
|
|
215
|
+
* unless a cache and a caller-owned `authIdentity` are supplied.
|
|
216
|
+
*
|
|
217
|
+
* Entries are keyed by agent URL, `authIdentity`, the pinned AdCP version, the
|
|
218
|
+
* non-correlation request headers (tenant/routing headers included), the
|
|
219
|
+
* signing identity and the transport policy (`allowPrivateIp`,
|
|
220
|
+
* `maxResponseBytes`), and expire after `ttlMs`. Synthetic capabilities
|
|
221
|
+
* (a seller whose capabilities call failed or that has no
|
|
222
|
+
* `get_adcp_capabilities`) are never shared, and calls that use a scoped
|
|
223
|
+
* `trustedFetchFn` bypass the cache entirely.
|
|
224
|
+
* See `docs/guides/DISCOVERY-CACHE-AND-SESSION-REUSE.md`.
|
|
225
|
+
*/
|
|
226
|
+
discoveryCache?: AgentDiscoveryCacheConfig;
|
|
211
227
|
/** Durable storage for restart-safe A2A human continuations. */
|
|
212
228
|
deferredStorage?: DeferredTaskStorage;
|
|
213
229
|
/** Resolve current trusted agent configuration for a persisted continuation. */
|
|
@@ -489,6 +505,21 @@ export interface CapabilityEvidenceSnapshot {
|
|
|
489
505
|
/** `tools/list` input-schema properties keyed by tool name; optional when capabilities already carry discoveredTools. */
|
|
490
506
|
toolSchemas?: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
|
|
491
507
|
}
|
|
508
|
+
/** Capability evidence to pre-seed into a shared `discoveryCache`. */
|
|
509
|
+
export interface AgentDiscoverySeed {
|
|
510
|
+
/** Authoritative capabilities (never synthetic). */
|
|
511
|
+
capabilities: AdcpCapabilities;
|
|
512
|
+
/** `tools/list` input-schema properties keyed by tool name; optional when capabilities carry discoveredTools. */
|
|
513
|
+
toolSchemas?: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
|
|
514
|
+
/**
|
|
515
|
+
* The MCP endpoint serving this agent, to skip endpoint probing. Must be a
|
|
516
|
+
* credential-free URL on the configured agent's origin, without query or fragment.
|
|
517
|
+
*/
|
|
518
|
+
endpoint?: {
|
|
519
|
+
agentUri: string;
|
|
520
|
+
mcpEra?: 'legacy' | 'modern';
|
|
521
|
+
};
|
|
522
|
+
}
|
|
492
523
|
export declare class SingleAgentClient {
|
|
493
524
|
private agent;
|
|
494
525
|
private config;
|
|
@@ -522,6 +553,13 @@ export declare class SingleAgentClient {
|
|
|
522
553
|
private primedCapabilitiesExpiresAt?;
|
|
523
554
|
private capabilityEvidenceScopeKey;
|
|
524
555
|
private capabilityEvidenceAuthMaterial?;
|
|
556
|
+
private capabilitiesFromSharedCache;
|
|
557
|
+
private discoveryEpoch;
|
|
558
|
+
private discoveredEndpointKey?;
|
|
559
|
+
private discoveredEndpointEpoch?;
|
|
560
|
+
private discoveredEndpointExpiresAt?;
|
|
561
|
+
private sharedEvidenceEpoch?;
|
|
562
|
+
private sharedEvidenceKey?;
|
|
525
563
|
private _v2WarningFired;
|
|
526
564
|
private _syntheticV3WarningFired;
|
|
527
565
|
private _syntheticV2WarningFired;
|
|
@@ -1443,6 +1481,17 @@ export declare class SingleAgentClient {
|
|
|
1443
1481
|
* ```
|
|
1444
1482
|
*/
|
|
1445
1483
|
getCapabilities(options?: ReadRequestOptions): Promise<AdcpCapabilities>;
|
|
1484
|
+
/**
|
|
1485
|
+
* Serve capabilities from the shared `discoveryCache`, or discover them live
|
|
1486
|
+
* as the single in-process "leader" for this cache key. Concurrent clients
|
|
1487
|
+
* for the same key wait for the leader under their *own* signal and deadline;
|
|
1488
|
+
* a leader that fails or is cancelled never fails its followers, which then
|
|
1489
|
+
* discover for themselves.
|
|
1490
|
+
*/
|
|
1491
|
+
private discoverCapabilitiesThroughSharedCache;
|
|
1492
|
+
/** Install capabilities from a shared entry; `undefined` when the entry is not usable evidence. */
|
|
1493
|
+
private installSharedCapabilities;
|
|
1494
|
+
private discoverCapabilitiesLive;
|
|
1446
1495
|
/**
|
|
1447
1496
|
* Return the client-bound scope required by {@link primeCapabilities}.
|
|
1448
1497
|
*
|
|
@@ -1463,6 +1512,105 @@ export declare class SingleAgentClient {
|
|
|
1463
1512
|
* within their own request scope.
|
|
1464
1513
|
*/
|
|
1465
1514
|
primeCapabilities(snapshot: CapabilityEvidenceSnapshot): boolean;
|
|
1515
|
+
/** Which kind of credential this client presents (never its value), so an unauthenticated client cannot adopt an authenticated one's evidence. */
|
|
1516
|
+
private discoveryCredentialKind;
|
|
1517
|
+
/** Epoch of this client's evidence for the call's effective shared key; `undefined` without a shared cache. */
|
|
1518
|
+
private discoveryEpochSnapshot;
|
|
1519
|
+
private discoveryEpochIs;
|
|
1520
|
+
/** The latest invalidation that applies to `key`: its own, combined with the cache's floor of forgotten ones. */
|
|
1521
|
+
private sharedInvalidationRecord;
|
|
1522
|
+
private sharedInvalidationEpoch;
|
|
1523
|
+
private bumpSharedInvalidationEpoch;
|
|
1524
|
+
/**
|
|
1525
|
+
* Remember which key the local capability evidence belongs to and, unless it
|
|
1526
|
+
* is application-owned (`primeCapabilities`), the shared invalidation epoch it
|
|
1527
|
+
* was obtained under. Application-owned evidence keeps its caller-declared
|
|
1528
|
+
* freshness and is not discarded by another instance's invalidation.
|
|
1529
|
+
*/
|
|
1530
|
+
private recordSharedEvidence;
|
|
1531
|
+
/** Non-secret fingerprint of the request-signing identity, so keys never mix signing identities. */
|
|
1532
|
+
private discoverySigningFingerprint;
|
|
1533
|
+
/**
|
|
1534
|
+
* Shared-discovery key for the effective transport policy of this call, or
|
|
1535
|
+
* `undefined` when sharing is off or the call uses a scoped `trustedFetchFn`
|
|
1536
|
+
* (whose network boundary is per-call, so its evidence is never shared).
|
|
1537
|
+
*/
|
|
1538
|
+
private sharedDiscoveryKey;
|
|
1539
|
+
/**
|
|
1540
|
+
* Run a shared-cache operation under the caller's signal and a fixed backend
|
|
1541
|
+
* deadline, so an unresponsive store can neither make a call uncancellable nor
|
|
1542
|
+
* stall it beyond {@link SHARED_DISCOVERY_CACHE_TIMEOUT_MS}. Rejects on the
|
|
1543
|
+
* caller's abort or when the backend fails or times out; callers decide which
|
|
1544
|
+
* of those is a miss.
|
|
1545
|
+
*/
|
|
1546
|
+
private boundedCacheOperation;
|
|
1547
|
+
/**
|
|
1548
|
+
* Run one backend mutation (or read-modify-write) for a shared key strictly
|
|
1549
|
+
* after every earlier mutation of that key in this process has actually
|
|
1550
|
+
* settled. The caller's wait is still bounded: an unresponsive backend makes
|
|
1551
|
+
* the caller see a miss, but later mutations stay queued behind the hung
|
|
1552
|
+
* operation, so an old callback can never land after a newer one.
|
|
1553
|
+
*
|
|
1554
|
+
* The queue is bounded. A `droppable` mutation (a write or cleanup) is
|
|
1555
|
+
* abandoned when its caller stopped waiting before it started, and is refused
|
|
1556
|
+
* when the key's queue is full; refusal is a failed write, never a call
|
|
1557
|
+
* failure. A `delete` is never refused for a known key: while one is queued
|
|
1558
|
+
* and not yet started, a newer invalidation joins it. Only for a new key beyond
|
|
1559
|
+
* the key cap is a delete refused — the invalidation tombstone still hides the
|
|
1560
|
+
* entry from this process's readers.
|
|
1561
|
+
*/
|
|
1562
|
+
private serializedCacheMutation;
|
|
1563
|
+
/** Is this stored entry structurally sound and not expired (before any caller-TTL cap)? */
|
|
1564
|
+
private isLiveSharedEntry;
|
|
1565
|
+
/**
|
|
1566
|
+
* Read a fresh, structurally valid shared entry. A backend failure or
|
|
1567
|
+
* timeout is a miss, never a call failure; the caller's own abort propagates.
|
|
1568
|
+
*/
|
|
1569
|
+
private readSharedDiscovery;
|
|
1570
|
+
/**
|
|
1571
|
+
* Merge fresh evidence into the shared entry; the merged entry never outlives
|
|
1572
|
+
* its oldest part. Returns the stored entry, or `undefined` when it was not
|
|
1573
|
+
* stored: automatic writes
|
|
1574
|
+
* ignore a `false` (a failed write only costs a later rediscovery), while
|
|
1575
|
+
* {@link primeDiscoveryCache} reports it.
|
|
1576
|
+
*/
|
|
1577
|
+
private writeSharedDiscovery;
|
|
1578
|
+
/** Is `agentUri` a credential-free URL on the configured agent's origin (all discovery ever tries)? */
|
|
1579
|
+
private isDiscoverableEndpoint;
|
|
1580
|
+
/** Adopt a previously discovered MCP endpoint instead of re-probing the agent. */
|
|
1581
|
+
private adoptSharedEndpoint;
|
|
1582
|
+
/**
|
|
1583
|
+
* Drop discovery evidence for this client: its in-memory capability and
|
|
1584
|
+
* tool-schema caches, the discovered endpoint, and the shared
|
|
1585
|
+
* `discoveryCache` entry (when configured). The next call rediscovers.
|
|
1586
|
+
*
|
|
1587
|
+
* Call this when you learn the seller changed (a deploy, a version bump, a
|
|
1588
|
+
* capability-dependent error you observed). The SDK also invalidates by
|
|
1589
|
+
* itself when a feature check fails against shared evidence, and when a
|
|
1590
|
+
* seller answers with a version or capability error.
|
|
1591
|
+
*/
|
|
1592
|
+
invalidateDiscoveryCache(options?: Pick<TaskOptions, 'transport'>): Promise<void>;
|
|
1593
|
+
/**
|
|
1594
|
+
* Pre-seed the shared `discoveryCache` with capability evidence the caller
|
|
1595
|
+
* already holds (for example from a registry sync), so no client sharing
|
|
1596
|
+
* this identity probes the seller within the TTL. Unlike
|
|
1597
|
+
* {@link primeCapabilities} the seeded evidence outlives this instance.
|
|
1598
|
+
*
|
|
1599
|
+
* Returns `true` only once the backing cache has accepted the entry. Returns
|
|
1600
|
+
* `false` — having seeded nothing — when sharing is not configured, the
|
|
1601
|
+
* client uses a scoped `trustedFetchFn`, or the evidence is synthetic,
|
|
1602
|
+
* malformed or not cloneable. When the cache rejects the write or does not
|
|
1603
|
+
* answer within the backend deadline, the result is also `false`, but the
|
|
1604
|
+
* outcome is indeterminate: a write already handed to the backend may still
|
|
1605
|
+
* land, whereas one still queued behind earlier operations is dropped. Treat
|
|
1606
|
+
* `false` as "not confirmed", and seed again (or invalidate) rather than
|
|
1607
|
+
* assuming the cache is empty. Seed `endpoint` as well
|
|
1608
|
+
* to skip the endpoint probe on the first call; without it that probe still
|
|
1609
|
+
* runs once per cold client.
|
|
1610
|
+
*/
|
|
1611
|
+
primeDiscoveryCache(seed: AgentDiscoverySeed): Promise<boolean>;
|
|
1612
|
+
/** Drop shared evidence when a seller answers with an error that says our cached view of it is stale. */
|
|
1613
|
+
private invalidateDiscoveryOnCapabilityError;
|
|
1466
1614
|
/**
|
|
1467
1615
|
* Emit a one-time warning when the agent reports v2 capabilities.
|
|
1468
1616
|
*
|
|
@@ -1564,6 +1712,12 @@ export declare class SingleAgentClient {
|
|
|
1564
1712
|
* with an actionable error message.
|
|
1565
1713
|
*/
|
|
1566
1714
|
require(...features: FeatureName[]): Promise<void>;
|
|
1715
|
+
/**
|
|
1716
|
+
* Throw {@link FeatureUnsupportedError} when a feature is missing, deciding on
|
|
1717
|
+
* live capabilities when the refusal would rest on shared evidence that may
|
|
1718
|
+
* predate a seller upgrade.
|
|
1719
|
+
*/
|
|
1720
|
+
private assertFeaturesSupported;
|
|
1567
1721
|
/**
|
|
1568
1722
|
* Force-refresh cached capabilities from the server.
|
|
1569
1723
|
* Useful when seller capabilities may have changed.
|
|
@@ -14,6 +14,7 @@ import { type WebhookHeaderValue, type WebhookHeadersLike } from '../webhooks';
|
|
|
14
14
|
import { type WebhookRegistration, type WebhookRegistrationStore } from './webhook-registration';
|
|
15
15
|
import { type ReplayStore, type RevocationStore, type JwksResolver, type WebhookSignatureErrorCode, type ResolvedAgentJwksResolverOptions } from '../signing/server';
|
|
16
16
|
import type { AdcpCapabilities, FeatureName } from '../utils/capabilities';
|
|
17
|
+
import { type AgentDiscoveryCacheConfig } from './agent-discovery-cache';
|
|
17
18
|
import { BuyerAccountRegistry, type AccountPolicy, type BuyerAccountStorage } from './buyer-account-registry';
|
|
18
19
|
import type { ProductCache } from './product-cache';
|
|
19
20
|
import { type ResolveAccountOptions } from './account-resolution';
|
|
@@ -208,6 +209,21 @@ export interface SingleAgentClientConfig extends ConversationConfig {
|
|
|
208
209
|
/** Trusted stable caller identity for durable registry partitioning. Default is credential fingerprint. */
|
|
209
210
|
accountRegistryScope?: string;
|
|
210
211
|
productCache?: ProductCache;
|
|
212
|
+
/**
|
|
213
|
+
* Share endpoint discovery, the `tools/list` schema map and
|
|
214
|
+
* `get_adcp_capabilities` across client instances. Opt-in: nothing is shared
|
|
215
|
+
* unless a cache and a caller-owned `authIdentity` are supplied.
|
|
216
|
+
*
|
|
217
|
+
* Entries are keyed by agent URL, `authIdentity`, the pinned AdCP version, the
|
|
218
|
+
* non-correlation request headers (tenant/routing headers included), the
|
|
219
|
+
* signing identity and the transport policy (`allowPrivateIp`,
|
|
220
|
+
* `maxResponseBytes`), and expire after `ttlMs`. Synthetic capabilities
|
|
221
|
+
* (a seller whose capabilities call failed or that has no
|
|
222
|
+
* `get_adcp_capabilities`) are never shared, and calls that use a scoped
|
|
223
|
+
* `trustedFetchFn` bypass the cache entirely.
|
|
224
|
+
* See `docs/guides/DISCOVERY-CACHE-AND-SESSION-REUSE.md`.
|
|
225
|
+
*/
|
|
226
|
+
discoveryCache?: AgentDiscoveryCacheConfig;
|
|
211
227
|
/** Durable storage for restart-safe A2A human continuations. */
|
|
212
228
|
deferredStorage?: DeferredTaskStorage;
|
|
213
229
|
/** Resolve current trusted agent configuration for a persisted continuation. */
|
|
@@ -489,6 +505,21 @@ export interface CapabilityEvidenceSnapshot {
|
|
|
489
505
|
/** `tools/list` input-schema properties keyed by tool name; optional when capabilities already carry discoveredTools. */
|
|
490
506
|
toolSchemas?: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
|
|
491
507
|
}
|
|
508
|
+
/** Capability evidence to pre-seed into a shared `discoveryCache`. */
|
|
509
|
+
export interface AgentDiscoverySeed {
|
|
510
|
+
/** Authoritative capabilities (never synthetic). */
|
|
511
|
+
capabilities: AdcpCapabilities;
|
|
512
|
+
/** `tools/list` input-schema properties keyed by tool name; optional when capabilities carry discoveredTools. */
|
|
513
|
+
toolSchemas?: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
|
|
514
|
+
/**
|
|
515
|
+
* The MCP endpoint serving this agent, to skip endpoint probing. Must be a
|
|
516
|
+
* credential-free URL on the configured agent's origin, without query or fragment.
|
|
517
|
+
*/
|
|
518
|
+
endpoint?: {
|
|
519
|
+
agentUri: string;
|
|
520
|
+
mcpEra?: 'legacy' | 'modern';
|
|
521
|
+
};
|
|
522
|
+
}
|
|
492
523
|
export declare class SingleAgentClient {
|
|
493
524
|
private agent;
|
|
494
525
|
private config;
|
|
@@ -522,6 +553,13 @@ export declare class SingleAgentClient {
|
|
|
522
553
|
private primedCapabilitiesExpiresAt?;
|
|
523
554
|
private capabilityEvidenceScopeKey;
|
|
524
555
|
private capabilityEvidenceAuthMaterial?;
|
|
556
|
+
private capabilitiesFromSharedCache;
|
|
557
|
+
private discoveryEpoch;
|
|
558
|
+
private discoveredEndpointKey?;
|
|
559
|
+
private discoveredEndpointEpoch?;
|
|
560
|
+
private discoveredEndpointExpiresAt?;
|
|
561
|
+
private sharedEvidenceEpoch?;
|
|
562
|
+
private sharedEvidenceKey?;
|
|
525
563
|
private _v2WarningFired;
|
|
526
564
|
private _syntheticV3WarningFired;
|
|
527
565
|
private _syntheticV2WarningFired;
|
|
@@ -1443,6 +1481,17 @@ export declare class SingleAgentClient {
|
|
|
1443
1481
|
* ```
|
|
1444
1482
|
*/
|
|
1445
1483
|
getCapabilities(options?: ReadRequestOptions): Promise<AdcpCapabilities>;
|
|
1484
|
+
/**
|
|
1485
|
+
* Serve capabilities from the shared `discoveryCache`, or discover them live
|
|
1486
|
+
* as the single in-process "leader" for this cache key. Concurrent clients
|
|
1487
|
+
* for the same key wait for the leader under their *own* signal and deadline;
|
|
1488
|
+
* a leader that fails or is cancelled never fails its followers, which then
|
|
1489
|
+
* discover for themselves.
|
|
1490
|
+
*/
|
|
1491
|
+
private discoverCapabilitiesThroughSharedCache;
|
|
1492
|
+
/** Install capabilities from a shared entry; `undefined` when the entry is not usable evidence. */
|
|
1493
|
+
private installSharedCapabilities;
|
|
1494
|
+
private discoverCapabilitiesLive;
|
|
1446
1495
|
/**
|
|
1447
1496
|
* Return the client-bound scope required by {@link primeCapabilities}.
|
|
1448
1497
|
*
|
|
@@ -1463,6 +1512,105 @@ export declare class SingleAgentClient {
|
|
|
1463
1512
|
* within their own request scope.
|
|
1464
1513
|
*/
|
|
1465
1514
|
primeCapabilities(snapshot: CapabilityEvidenceSnapshot): boolean;
|
|
1515
|
+
/** Which kind of credential this client presents (never its value), so an unauthenticated client cannot adopt an authenticated one's evidence. */
|
|
1516
|
+
private discoveryCredentialKind;
|
|
1517
|
+
/** Epoch of this client's evidence for the call's effective shared key; `undefined` without a shared cache. */
|
|
1518
|
+
private discoveryEpochSnapshot;
|
|
1519
|
+
private discoveryEpochIs;
|
|
1520
|
+
/** The latest invalidation that applies to `key`: its own, combined with the cache's floor of forgotten ones. */
|
|
1521
|
+
private sharedInvalidationRecord;
|
|
1522
|
+
private sharedInvalidationEpoch;
|
|
1523
|
+
private bumpSharedInvalidationEpoch;
|
|
1524
|
+
/**
|
|
1525
|
+
* Remember which key the local capability evidence belongs to and, unless it
|
|
1526
|
+
* is application-owned (`primeCapabilities`), the shared invalidation epoch it
|
|
1527
|
+
* was obtained under. Application-owned evidence keeps its caller-declared
|
|
1528
|
+
* freshness and is not discarded by another instance's invalidation.
|
|
1529
|
+
*/
|
|
1530
|
+
private recordSharedEvidence;
|
|
1531
|
+
/** Non-secret fingerprint of the request-signing identity, so keys never mix signing identities. */
|
|
1532
|
+
private discoverySigningFingerprint;
|
|
1533
|
+
/**
|
|
1534
|
+
* Shared-discovery key for the effective transport policy of this call, or
|
|
1535
|
+
* `undefined` when sharing is off or the call uses a scoped `trustedFetchFn`
|
|
1536
|
+
* (whose network boundary is per-call, so its evidence is never shared).
|
|
1537
|
+
*/
|
|
1538
|
+
private sharedDiscoveryKey;
|
|
1539
|
+
/**
|
|
1540
|
+
* Run a shared-cache operation under the caller's signal and a fixed backend
|
|
1541
|
+
* deadline, so an unresponsive store can neither make a call uncancellable nor
|
|
1542
|
+
* stall it beyond {@link SHARED_DISCOVERY_CACHE_TIMEOUT_MS}. Rejects on the
|
|
1543
|
+
* caller's abort or when the backend fails or times out; callers decide which
|
|
1544
|
+
* of those is a miss.
|
|
1545
|
+
*/
|
|
1546
|
+
private boundedCacheOperation;
|
|
1547
|
+
/**
|
|
1548
|
+
* Run one backend mutation (or read-modify-write) for a shared key strictly
|
|
1549
|
+
* after every earlier mutation of that key in this process has actually
|
|
1550
|
+
* settled. The caller's wait is still bounded: an unresponsive backend makes
|
|
1551
|
+
* the caller see a miss, but later mutations stay queued behind the hung
|
|
1552
|
+
* operation, so an old callback can never land after a newer one.
|
|
1553
|
+
*
|
|
1554
|
+
* The queue is bounded. A `droppable` mutation (a write or cleanup) is
|
|
1555
|
+
* abandoned when its caller stopped waiting before it started, and is refused
|
|
1556
|
+
* when the key's queue is full; refusal is a failed write, never a call
|
|
1557
|
+
* failure. A `delete` is never refused for a known key: while one is queued
|
|
1558
|
+
* and not yet started, a newer invalidation joins it. Only for a new key beyond
|
|
1559
|
+
* the key cap is a delete refused — the invalidation tombstone still hides the
|
|
1560
|
+
* entry from this process's readers.
|
|
1561
|
+
*/
|
|
1562
|
+
private serializedCacheMutation;
|
|
1563
|
+
/** Is this stored entry structurally sound and not expired (before any caller-TTL cap)? */
|
|
1564
|
+
private isLiveSharedEntry;
|
|
1565
|
+
/**
|
|
1566
|
+
* Read a fresh, structurally valid shared entry. A backend failure or
|
|
1567
|
+
* timeout is a miss, never a call failure; the caller's own abort propagates.
|
|
1568
|
+
*/
|
|
1569
|
+
private readSharedDiscovery;
|
|
1570
|
+
/**
|
|
1571
|
+
* Merge fresh evidence into the shared entry; the merged entry never outlives
|
|
1572
|
+
* its oldest part. Returns the stored entry, or `undefined` when it was not
|
|
1573
|
+
* stored: automatic writes
|
|
1574
|
+
* ignore a `false` (a failed write only costs a later rediscovery), while
|
|
1575
|
+
* {@link primeDiscoveryCache} reports it.
|
|
1576
|
+
*/
|
|
1577
|
+
private writeSharedDiscovery;
|
|
1578
|
+
/** Is `agentUri` a credential-free URL on the configured agent's origin (all discovery ever tries)? */
|
|
1579
|
+
private isDiscoverableEndpoint;
|
|
1580
|
+
/** Adopt a previously discovered MCP endpoint instead of re-probing the agent. */
|
|
1581
|
+
private adoptSharedEndpoint;
|
|
1582
|
+
/**
|
|
1583
|
+
* Drop discovery evidence for this client: its in-memory capability and
|
|
1584
|
+
* tool-schema caches, the discovered endpoint, and the shared
|
|
1585
|
+
* `discoveryCache` entry (when configured). The next call rediscovers.
|
|
1586
|
+
*
|
|
1587
|
+
* Call this when you learn the seller changed (a deploy, a version bump, a
|
|
1588
|
+
* capability-dependent error you observed). The SDK also invalidates by
|
|
1589
|
+
* itself when a feature check fails against shared evidence, and when a
|
|
1590
|
+
* seller answers with a version or capability error.
|
|
1591
|
+
*/
|
|
1592
|
+
invalidateDiscoveryCache(options?: Pick<TaskOptions, 'transport'>): Promise<void>;
|
|
1593
|
+
/**
|
|
1594
|
+
* Pre-seed the shared `discoveryCache` with capability evidence the caller
|
|
1595
|
+
* already holds (for example from a registry sync), so no client sharing
|
|
1596
|
+
* this identity probes the seller within the TTL. Unlike
|
|
1597
|
+
* {@link primeCapabilities} the seeded evidence outlives this instance.
|
|
1598
|
+
*
|
|
1599
|
+
* Returns `true` only once the backing cache has accepted the entry. Returns
|
|
1600
|
+
* `false` — having seeded nothing — when sharing is not configured, the
|
|
1601
|
+
* client uses a scoped `trustedFetchFn`, or the evidence is synthetic,
|
|
1602
|
+
* malformed or not cloneable. When the cache rejects the write or does not
|
|
1603
|
+
* answer within the backend deadline, the result is also `false`, but the
|
|
1604
|
+
* outcome is indeterminate: a write already handed to the backend may still
|
|
1605
|
+
* land, whereas one still queued behind earlier operations is dropped. Treat
|
|
1606
|
+
* `false` as "not confirmed", and seed again (or invalidate) rather than
|
|
1607
|
+
* assuming the cache is empty. Seed `endpoint` as well
|
|
1608
|
+
* to skip the endpoint probe on the first call; without it that probe still
|
|
1609
|
+
* runs once per cold client.
|
|
1610
|
+
*/
|
|
1611
|
+
primeDiscoveryCache(seed: AgentDiscoverySeed): Promise<boolean>;
|
|
1612
|
+
/** Drop shared evidence when a seller answers with an error that says our cached view of it is stale. */
|
|
1613
|
+
private invalidateDiscoveryOnCapabilityError;
|
|
1466
1614
|
/**
|
|
1467
1615
|
* Emit a one-time warning when the agent reports v2 capabilities.
|
|
1468
1616
|
*
|
|
@@ -1564,6 +1712,12 @@ export declare class SingleAgentClient {
|
|
|
1564
1712
|
* with an actionable error message.
|
|
1565
1713
|
*/
|
|
1566
1714
|
require(...features: FeatureName[]): Promise<void>;
|
|
1715
|
+
/**
|
|
1716
|
+
* Throw {@link FeatureUnsupportedError} when a feature is missing, deciding on
|
|
1717
|
+
* live capabilities when the refusal would rest on shared evidence that may
|
|
1718
|
+
* predate a seller upgrade.
|
|
1719
|
+
*/
|
|
1720
|
+
private assertFeaturesSupported;
|
|
1567
1721
|
/**
|
|
1568
1722
|
* Force-refresh cached capabilities from the server.
|
|
1569
1723
|
* Useful when seller capabilities may have changed.
|