@adcp/client 2.4.1 → 2.5.1
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/README.md +66 -11
- package/bin/adcp-config.js +233 -0
- package/bin/adcp.js +321 -45
- package/dist/lib/core/ADCPClient.d.ts +33 -3
- package/dist/lib/core/ADCPClient.d.ts.map +1 -1
- package/dist/lib/core/ADCPClient.js +93 -16
- package/dist/lib/core/ADCPClient.js.map +1 -1
- package/dist/lib/core/ADCPMultiAgentClient.d.ts +8 -0
- package/dist/lib/core/ADCPMultiAgentClient.d.ts.map +1 -1
- package/dist/lib/core/ADCPMultiAgentClient.js +14 -0
- package/dist/lib/core/ADCPMultiAgentClient.js.map +1 -1
- package/dist/lib/core/AgentClient.d.ts +18 -2
- package/dist/lib/core/AgentClient.d.ts.map +1 -1
- package/dist/lib/core/AgentClient.js +10 -3
- package/dist/lib/core/AgentClient.js.map +1 -1
- package/dist/lib/core/ResponseValidator.d.ts +13 -9
- package/dist/lib/core/ResponseValidator.d.ts.map +1 -1
- package/dist/lib/core/ResponseValidator.js +93 -33
- package/dist/lib/core/ResponseValidator.js.map +1 -1
- package/dist/lib/core/TaskExecutor.d.ts +12 -0
- package/dist/lib/core/TaskExecutor.d.ts.map +1 -1
- package/dist/lib/core/TaskExecutor.js +88 -6
- package/dist/lib/core/TaskExecutor.js.map +1 -1
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +4 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/protocols/mcp.d.ts.map +1 -1
- package/dist/lib/protocols/mcp.js +9 -0
- package/dist/lib/protocols/mcp.js.map +1 -1
- package/dist/lib/types/adcp.d.ts +2 -6
- package/dist/lib/types/adcp.d.ts.map +1 -1
- package/dist/lib/types/schemas.generated.d.ts +0 -2
- package/dist/lib/types/schemas.generated.d.ts.map +1 -1
- package/dist/lib/types/schemas.generated.js +1 -2
- package/dist/lib/types/schemas.generated.js.map +1 -1
- package/dist/lib/types/tools.generated.d.ts +0 -8
- package/dist/lib/types/tools.generated.d.ts.map +1 -1
- package/dist/lib/types/tools.generated.js.map +1 -1
- package/dist/lib/utils/index.d.ts +1 -0
- package/dist/lib/utils/index.d.ts.map +1 -1
- package/dist/lib/utils/index.js +9 -4
- package/dist/lib/utils/index.js.map +1 -1
- package/dist/lib/utils/logger.d.ts +55 -0
- package/dist/lib/utils/logger.d.ts.map +1 -0
- package/dist/lib/utils/logger.js +100 -0
- package/dist/lib/utils/logger.js.map +1 -0
- package/dist/lib/utils/protocol-detection.d.ts +26 -0
- package/dist/lib/utils/protocol-detection.d.ts.map +1 -0
- package/dist/lib/utils/protocol-detection.js +84 -0
- package/dist/lib/utils/protocol-detection.js.map +1 -0
- package/dist/lib/version.d.ts +3 -3
- package/dist/lib/version.js +3 -3
- package/package.json +1 -1
package/bin/adcp.js
CHANGED
|
@@ -14,9 +14,59 @@
|
|
|
14
14
|
* adcp mcp https://agent.example.com/mcp create_media_buy @payload.json --auth $AGENT_TOKEN
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
const { ADCPClient } = require('../dist/lib/index.js');
|
|
17
|
+
const { ADCPClient, detectProtocol } = require('../dist/lib/index.js');
|
|
18
18
|
const { readFileSync } = require('fs');
|
|
19
19
|
const { AsyncWebhookHandler } = require('./adcp-async-handler.js');
|
|
20
|
+
const {
|
|
21
|
+
getAgent,
|
|
22
|
+
listAgents,
|
|
23
|
+
isAlias,
|
|
24
|
+
interactiveSetup,
|
|
25
|
+
removeAgent,
|
|
26
|
+
getConfigPath
|
|
27
|
+
} = require('./adcp-config.js');
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Extract human-readable protocol message from conversation
|
|
31
|
+
*/
|
|
32
|
+
function extractProtocolMessage(conversation, protocol) {
|
|
33
|
+
if (!conversation || conversation.length === 0) return null;
|
|
34
|
+
|
|
35
|
+
// Find the last agent response (don't mutate original array)
|
|
36
|
+
const agentResponse = [...conversation].reverse().find(msg => msg.role === 'agent');
|
|
37
|
+
if (!agentResponse || !agentResponse.content) return null;
|
|
38
|
+
|
|
39
|
+
if (protocol === 'mcp') {
|
|
40
|
+
// MCP: The content[].text contains the tool response (JSON stringified)
|
|
41
|
+
// This IS the protocol message in MCP
|
|
42
|
+
if (agentResponse.content.content && Array.isArray(agentResponse.content.content)) {
|
|
43
|
+
const textContent = agentResponse.content.content.find(c => c.type === 'text');
|
|
44
|
+
return textContent?.text || null;
|
|
45
|
+
}
|
|
46
|
+
if (agentResponse.content.text) {
|
|
47
|
+
return agentResponse.content.text;
|
|
48
|
+
}
|
|
49
|
+
} else if (protocol === 'a2a') {
|
|
50
|
+
// A2A: Extract human-readable message from task result
|
|
51
|
+
// The message is nested in result.artifacts[0].parts[0].data.message
|
|
52
|
+
const result = agentResponse.content.result;
|
|
53
|
+
if (result && result.artifacts && result.artifacts.length > 0) {
|
|
54
|
+
const artifact = result.artifacts[0];
|
|
55
|
+
if (artifact.parts && artifact.parts.length > 0) {
|
|
56
|
+
const data = artifact.parts[0].data;
|
|
57
|
+
if (data && data.message) {
|
|
58
|
+
return data.message;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// Fallback: check top-level status message
|
|
63
|
+
if (result && result.status && result.status.message) {
|
|
64
|
+
return result.status.message;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
20
70
|
|
|
21
71
|
/**
|
|
22
72
|
* Display agent info - just calls library method
|
|
@@ -59,53 +109,78 @@ function printUsage() {
|
|
|
59
109
|
AdCP CLI Tool - Direct Agent Communication
|
|
60
110
|
|
|
61
111
|
USAGE:
|
|
62
|
-
adcp <
|
|
112
|
+
adcp <agent-alias|url> [tool-name] [payload] [options]
|
|
63
113
|
|
|
64
114
|
ARGUMENTS:
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
- Can be stdin: -
|
|
115
|
+
agent-alias|url Saved agent alias (e.g., 'test') or full URL to agent endpoint
|
|
116
|
+
tool-name Name of the tool to call (optional - omit to list available tools)
|
|
117
|
+
payload JSON payload for the tool (default: {})
|
|
118
|
+
- Can be inline JSON: '{"brief":"text"}'
|
|
119
|
+
- Can be file path: @payload.json
|
|
120
|
+
- Can be stdin: -
|
|
72
121
|
|
|
73
122
|
OPTIONS:
|
|
74
|
-
--
|
|
75
|
-
--
|
|
76
|
-
--
|
|
77
|
-
--
|
|
78
|
-
--
|
|
79
|
-
--
|
|
80
|
-
--
|
|
123
|
+
--protocol PROTO Force protocol: 'mcp' or 'a2a' (default: auto-detect)
|
|
124
|
+
--auth TOKEN Authentication token for the agent
|
|
125
|
+
--wait Wait for async/webhook responses (requires ngrok or --local)
|
|
126
|
+
--local Use local webhook without ngrok (for local agents only)
|
|
127
|
+
--timeout MS Webhook timeout in milliseconds (default: 300000 = 5min)
|
|
128
|
+
--help, -h Show this help message
|
|
129
|
+
--json Output raw JSON response (default: pretty print)
|
|
130
|
+
--debug Show debug information
|
|
131
|
+
|
|
132
|
+
AGENT MANAGEMENT:
|
|
133
|
+
--save-auth <alias> [url] [protocol] [--auth token | --no-auth]
|
|
134
|
+
Save agent configuration with an alias name
|
|
135
|
+
Requires --auth or --no-auth for non-interactive mode
|
|
136
|
+
--list-agents List all saved agents
|
|
137
|
+
--remove-agent <alias> Remove saved agent configuration
|
|
138
|
+
--show-config Show config file location
|
|
81
139
|
|
|
82
140
|
EXAMPLES:
|
|
83
|
-
#
|
|
84
|
-
adcp
|
|
85
|
-
adcp a2a https://creative.adcontextprotocol.org
|
|
141
|
+
# Non-interactive: save with auth token
|
|
142
|
+
adcp --save-auth myagent https://test-agent.adcontextprotocol.org --auth your_token
|
|
86
143
|
|
|
87
|
-
#
|
|
88
|
-
adcp
|
|
144
|
+
# Non-interactive: save without auth
|
|
145
|
+
adcp --save-auth myagent https://test-agent.adcontextprotocol.org --no-auth
|
|
89
146
|
|
|
90
|
-
#
|
|
91
|
-
adcp
|
|
147
|
+
# Interactive setup (prompts for URL, protocol, and auth)
|
|
148
|
+
adcp --save-auth myagent
|
|
92
149
|
|
|
93
|
-
#
|
|
94
|
-
adcp
|
|
150
|
+
# Use saved agent alias (auto-detect protocol)
|
|
151
|
+
adcp myagent
|
|
152
|
+
adcp myagent get_products '{"brief":"travel"}'
|
|
153
|
+
|
|
154
|
+
# List saved agents
|
|
155
|
+
adcp --list-agents
|
|
156
|
+
|
|
157
|
+
# Auto-detect protocol with URL
|
|
158
|
+
adcp https://test-agent.adcontextprotocol.org get_products '{"brief":"coffee"}'
|
|
159
|
+
|
|
160
|
+
# Force specific protocol
|
|
161
|
+
adcp https://agent.example.com get_products '{"brief":"coffee"}' --protocol mcp
|
|
162
|
+
adcp myagent list_authorized_properties --protocol a2a
|
|
95
163
|
|
|
96
|
-
#
|
|
97
|
-
adcp
|
|
164
|
+
# Override saved auth token
|
|
165
|
+
adcp myagent get_products '{"brief":"..."}' --auth different-token
|
|
98
166
|
|
|
99
|
-
#
|
|
100
|
-
adcp
|
|
167
|
+
# Wait for async response (requires ngrok)
|
|
168
|
+
adcp myagent create_media_buy @payload.json --wait
|
|
169
|
+
|
|
170
|
+
# From file or stdin
|
|
171
|
+
adcp myagent create_media_buy @payload.json
|
|
172
|
+
echo '{"brief":"travel"}' | adcp myagent get_products -
|
|
101
173
|
|
|
102
|
-
#
|
|
103
|
-
|
|
174
|
+
# JSON output for scripting
|
|
175
|
+
adcp myagent get_products '{"brief":"travel"}' --json | jq '.products[0]'
|
|
104
176
|
|
|
105
177
|
ENVIRONMENT VARIABLES:
|
|
106
178
|
ADCP_AUTH_TOKEN Default authentication token (overridden by --auth)
|
|
107
179
|
ADCP_DEBUG Enable debug mode (set to 'true')
|
|
108
180
|
|
|
181
|
+
CONFIG FILE:
|
|
182
|
+
Agents are saved to ~/.adcp/config.json
|
|
183
|
+
|
|
109
184
|
EXIT CODES:
|
|
110
185
|
0 Success
|
|
111
186
|
1 General error
|
|
@@ -123,8 +198,108 @@ async function main() {
|
|
|
123
198
|
process.exit(0);
|
|
124
199
|
}
|
|
125
200
|
|
|
201
|
+
// Handle agent management commands
|
|
202
|
+
if (args[0] === '--save-auth') {
|
|
203
|
+
// Parse flags first
|
|
204
|
+
const authFlagIndex = args.indexOf('--auth');
|
|
205
|
+
const noAuthFlag = args.includes('--no-auth');
|
|
206
|
+
const providedAuthToken = authFlagIndex !== -1 ? args[authFlagIndex + 1] : null;
|
|
207
|
+
|
|
208
|
+
// Filter out flags to get positional args
|
|
209
|
+
const saveAuthPositional = args.slice(1).filter(arg =>
|
|
210
|
+
arg !== '--auth' &&
|
|
211
|
+
arg !== '--no-auth' &&
|
|
212
|
+
arg !== providedAuthToken
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
let alias = saveAuthPositional[0];
|
|
216
|
+
let url = saveAuthPositional[1] || null;
|
|
217
|
+
const protocol = saveAuthPositional[2] || null;
|
|
218
|
+
|
|
219
|
+
if (!alias) {
|
|
220
|
+
console.error('ERROR: --save-auth requires an alias\n');
|
|
221
|
+
console.error('Usage: adcp --save-auth <alias> [url] [protocol] [--auth token | --no-auth]\n');
|
|
222
|
+
console.error('Example: adcp --save-auth myagent https://agent.example.com --auth your_token\n');
|
|
223
|
+
process.exit(2);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Check if first arg looks like a URL (common mistake)
|
|
227
|
+
if (alias.startsWith('http://') || alias.startsWith('https://')) {
|
|
228
|
+
console.error('\n⚠️ It looks like you provided a URL without an alias.\n');
|
|
229
|
+
console.error('The --save-auth command requires an alias name first:\n');
|
|
230
|
+
console.error(` adcp --save-auth <alias> <url>\n`);
|
|
231
|
+
console.error('Example:\n');
|
|
232
|
+
console.error(` adcp --save-auth myagent ${alias}\n`);
|
|
233
|
+
process.exit(2);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Validate flags
|
|
237
|
+
if (providedAuthToken && noAuthFlag) {
|
|
238
|
+
console.error('ERROR: Cannot use both --auth and --no-auth\n');
|
|
239
|
+
process.exit(2);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// Determine mode:
|
|
243
|
+
// - If URL provided AND (--auth or --no-auth): fully non-interactive
|
|
244
|
+
// - Otherwise: interactive (prompts for missing values)
|
|
245
|
+
const hasAuthDecision = providedAuthToken !== null || noAuthFlag;
|
|
246
|
+
const nonInteractive = url && hasAuthDecision;
|
|
247
|
+
|
|
248
|
+
await interactiveSetup(alias, url, protocol, providedAuthToken, nonInteractive, noAuthFlag);
|
|
249
|
+
process.exit(0);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (args[0] === '--list-agents') {
|
|
253
|
+
const agents = listAgents();
|
|
254
|
+
const aliases = Object.keys(agents);
|
|
255
|
+
|
|
256
|
+
if (aliases.length === 0) {
|
|
257
|
+
console.log('\nNo saved agents found.');
|
|
258
|
+
console.log('Use: adcp --save-auth <alias> <url>\n');
|
|
259
|
+
process.exit(0);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
console.log('\n📋 Saved Agents:\n');
|
|
263
|
+
aliases.forEach(alias => {
|
|
264
|
+
const agent = agents[alias];
|
|
265
|
+
console.log(` ${alias}`);
|
|
266
|
+
console.log(` URL: ${agent.url}`);
|
|
267
|
+
if (agent.protocol) {
|
|
268
|
+
console.log(` Protocol: ${agent.protocol}`);
|
|
269
|
+
}
|
|
270
|
+
if (agent.auth_token) {
|
|
271
|
+
console.log(` Auth: configured`);
|
|
272
|
+
}
|
|
273
|
+
console.log('');
|
|
274
|
+
});
|
|
275
|
+
console.log(`Config: ${getConfigPath()}\n`);
|
|
276
|
+
process.exit(0);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
if (args[0] === '--remove-agent') {
|
|
280
|
+
const alias = args[1];
|
|
281
|
+
|
|
282
|
+
if (!alias) {
|
|
283
|
+
console.error('ERROR: --remove-agent requires an alias\n');
|
|
284
|
+
process.exit(2);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
if (removeAgent(alias)) {
|
|
288
|
+
console.log(`\n✅ Removed agent '${alias}'\n`);
|
|
289
|
+
} else {
|
|
290
|
+
console.error(`\nERROR: Agent '${alias}' not found\n`);
|
|
291
|
+
process.exit(2);
|
|
292
|
+
}
|
|
293
|
+
process.exit(0);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
if (args[0] === '--show-config') {
|
|
297
|
+
console.log(`\nConfig file: ${getConfigPath()}\n`);
|
|
298
|
+
process.exit(0);
|
|
299
|
+
}
|
|
300
|
+
|
|
126
301
|
// Parse arguments
|
|
127
|
-
if (args.length <
|
|
302
|
+
if (args.length < 1) {
|
|
128
303
|
console.error('ERROR: Missing required arguments\n');
|
|
129
304
|
printUsage();
|
|
130
305
|
process.exit(2);
|
|
@@ -133,6 +308,8 @@ async function main() {
|
|
|
133
308
|
// Parse options first
|
|
134
309
|
const authIndex = args.indexOf('--auth');
|
|
135
310
|
const authToken = authIndex !== -1 ? args[authIndex + 1] : process.env.ADCP_AUTH_TOKEN;
|
|
311
|
+
const protocolIndex = args.indexOf('--protocol');
|
|
312
|
+
const protocolFlag = protocolIndex !== -1 ? args[protocolIndex + 1] : null;
|
|
136
313
|
const jsonOutput = args.includes('--json');
|
|
137
314
|
const debug = args.includes('--debug') || process.env.ADCP_DEBUG === 'true';
|
|
138
315
|
const waitForAsync = args.includes('--wait');
|
|
@@ -140,21 +317,66 @@ async function main() {
|
|
|
140
317
|
const timeoutIndex = args.indexOf('--timeout');
|
|
141
318
|
const timeout = timeoutIndex !== -1 ? parseInt(args[timeoutIndex + 1]) : 300000;
|
|
142
319
|
|
|
320
|
+
// Validate protocol flag if provided
|
|
321
|
+
if (protocolFlag && protocolFlag !== 'mcp' && protocolFlag !== 'a2a') {
|
|
322
|
+
console.error(`ERROR: Invalid protocol '${protocolFlag}'. Must be 'mcp' or 'a2a'\n`);
|
|
323
|
+
printUsage();
|
|
324
|
+
process.exit(2);
|
|
325
|
+
}
|
|
326
|
+
|
|
143
327
|
// Filter out flag arguments to find positional arguments
|
|
144
328
|
const positionalArgs = args.filter(arg =>
|
|
145
329
|
!arg.startsWith('--') &&
|
|
146
330
|
arg !== authToken && // Don't include the auth token value
|
|
331
|
+
arg !== protocolFlag && // Don't include the protocol value
|
|
147
332
|
arg !== (timeoutIndex !== -1 ? args[timeoutIndex + 1] : null) // Don't include timeout value
|
|
148
333
|
);
|
|
149
334
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
let
|
|
335
|
+
// Determine if first arg is alias or URL
|
|
336
|
+
let protocol = protocolFlag; // Start with flag if provided
|
|
337
|
+
let agentUrl;
|
|
338
|
+
let toolName;
|
|
339
|
+
let payloadArg;
|
|
340
|
+
let savedAgent = null;
|
|
341
|
+
|
|
342
|
+
const firstArg = positionalArgs[0];
|
|
343
|
+
|
|
344
|
+
// Check if first arg is a saved alias
|
|
345
|
+
if (isAlias(firstArg)) {
|
|
346
|
+
// Alias mode - load saved agent config
|
|
347
|
+
savedAgent = getAgent(firstArg);
|
|
348
|
+
agentUrl = savedAgent.url;
|
|
349
|
+
|
|
350
|
+
// Protocol priority: --protocol flag > saved config > auto-detect
|
|
351
|
+
if (!protocol) {
|
|
352
|
+
protocol = savedAgent.protocol || null;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
toolName = positionalArgs[1];
|
|
356
|
+
payloadArg = positionalArgs[2] || '{}';
|
|
154
357
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
358
|
+
// Use saved auth token if not overridden
|
|
359
|
+
if (!authToken && savedAgent.auth_token) {
|
|
360
|
+
authToken = savedAgent.auth_token;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
if (debug) {
|
|
364
|
+
console.error(`DEBUG: Using saved agent '${firstArg}'`);
|
|
365
|
+
console.error(` URL: ${agentUrl}`);
|
|
366
|
+
if (protocol) {
|
|
367
|
+
console.error(` Protocol: ${protocol}`);
|
|
368
|
+
}
|
|
369
|
+
console.error('');
|
|
370
|
+
}
|
|
371
|
+
} else if (firstArg && (firstArg.startsWith('http://') || firstArg.startsWith('https://'))) {
|
|
372
|
+
// URL mode
|
|
373
|
+
agentUrl = firstArg;
|
|
374
|
+
toolName = positionalArgs[1];
|
|
375
|
+
payloadArg = positionalArgs[2] || '{}';
|
|
376
|
+
// protocol already set from flag, or null for auto-detect
|
|
377
|
+
} else {
|
|
378
|
+
console.error(`ERROR: First argument must be an alias or URL\n`);
|
|
379
|
+
console.error(`Available aliases: ${Object.keys(listAgents()).join(', ') || 'none'}\n`);
|
|
158
380
|
printUsage();
|
|
159
381
|
process.exit(2);
|
|
160
382
|
}
|
|
@@ -180,11 +402,29 @@ async function main() {
|
|
|
180
402
|
process.exit(2);
|
|
181
403
|
}
|
|
182
404
|
|
|
405
|
+
// Auto-detect protocol if not specified
|
|
406
|
+
if (!protocol) {
|
|
407
|
+
if (debug || !jsonOutput) {
|
|
408
|
+
console.error('🔍 Auto-detecting protocol...');
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
try {
|
|
412
|
+
protocol = await detectProtocol(agentUrl);
|
|
413
|
+
if (debug || !jsonOutput) {
|
|
414
|
+
console.error(`✓ Detected protocol: ${protocol.toUpperCase()}\n`);
|
|
415
|
+
}
|
|
416
|
+
} catch (error) {
|
|
417
|
+
console.error(`ERROR: Failed to detect protocol: ${error.message}\n`);
|
|
418
|
+
console.error('Please specify protocol explicitly: adcp mcp <url> or adcp a2a <url>\n');
|
|
419
|
+
process.exit(2);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
183
423
|
if (debug) {
|
|
184
424
|
console.error('DEBUG: Configuration');
|
|
185
425
|
console.error(` Protocol: ${protocol}`);
|
|
186
426
|
console.error(` Agent URL: ${agentUrl}`);
|
|
187
|
-
console.error(` Tool: ${toolName}`);
|
|
427
|
+
console.error(` Tool: ${toolName || '(list tools)'}`);
|
|
188
428
|
console.error(` Auth: ${authToken ? 'provided' : 'none'}`);
|
|
189
429
|
console.error(` Payload: ${JSON.stringify(payload, null, 2)}`);
|
|
190
430
|
console.error('');
|
|
@@ -317,16 +557,42 @@ async function main() {
|
|
|
317
557
|
// Handle result
|
|
318
558
|
if (result.success) {
|
|
319
559
|
if (jsonOutput) {
|
|
320
|
-
// Raw JSON output
|
|
321
|
-
console.log(JSON.stringify(
|
|
560
|
+
// Raw JSON output - include protocol metadata
|
|
561
|
+
console.log(JSON.stringify({
|
|
562
|
+
data: result.data,
|
|
563
|
+
metadata: {
|
|
564
|
+
taskId: result.metadata.taskId,
|
|
565
|
+
protocol: result.metadata.agent.protocol,
|
|
566
|
+
responseTimeMs: result.metadata.responseTimeMs,
|
|
567
|
+
...(result.conversation && result.conversation.length > 0 && {
|
|
568
|
+
protocolMessage: extractProtocolMessage(result.conversation, result.metadata.agent.protocol),
|
|
569
|
+
contextId: result.metadata.taskId // Using taskId as context identifier
|
|
570
|
+
})
|
|
571
|
+
}
|
|
572
|
+
}, null, 2));
|
|
322
573
|
} else {
|
|
323
574
|
// Pretty output
|
|
324
575
|
console.log('\n✅ SUCCESS\n');
|
|
576
|
+
|
|
577
|
+
// Show protocol message if available
|
|
578
|
+
if (result.conversation && result.conversation.length > 0) {
|
|
579
|
+
const message = extractProtocolMessage(result.conversation, result.metadata.agent.protocol);
|
|
580
|
+
if (message) {
|
|
581
|
+
console.log('Protocol Message:');
|
|
582
|
+
console.log(message);
|
|
583
|
+
console.log('');
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
|
|
325
587
|
console.log('Response:');
|
|
326
588
|
console.log(JSON.stringify(result.data, null, 2));
|
|
327
589
|
console.log('');
|
|
590
|
+
console.log(`Protocol: ${result.metadata.agent.protocol.toUpperCase()}`);
|
|
328
591
|
console.log(`Response Time: ${result.metadata.responseTimeMs}ms`);
|
|
329
592
|
console.log(`Task ID: ${result.metadata.taskId}`);
|
|
593
|
+
if (result.conversation && result.conversation.length > 0) {
|
|
594
|
+
console.log(`Context ID: ${result.metadata.taskId}`);
|
|
595
|
+
}
|
|
330
596
|
}
|
|
331
597
|
process.exit(0);
|
|
332
598
|
} else {
|
|
@@ -335,9 +601,19 @@ async function main() {
|
|
|
335
601
|
if (result.metadata?.clarificationRounds) {
|
|
336
602
|
console.error(`Clarifications: ${result.metadata.clarificationRounds}`);
|
|
337
603
|
}
|
|
338
|
-
if (debug
|
|
339
|
-
|
|
340
|
-
|
|
604
|
+
if (debug) {
|
|
605
|
+
if (result.metadata) {
|
|
606
|
+
console.error('\nMetadata:');
|
|
607
|
+
console.error(JSON.stringify(result.metadata, null, 2));
|
|
608
|
+
}
|
|
609
|
+
if (result.debug_logs && result.debug_logs.length > 0) {
|
|
610
|
+
console.error('\nDebug Logs:');
|
|
611
|
+
console.error(JSON.stringify(result.debug_logs, null, 2));
|
|
612
|
+
}
|
|
613
|
+
if (result.conversation && result.conversation.length > 0) {
|
|
614
|
+
console.error('\nConversation:');
|
|
615
|
+
console.error(JSON.stringify(result.conversation, null, 2));
|
|
616
|
+
}
|
|
341
617
|
}
|
|
342
618
|
process.exit(3);
|
|
343
619
|
}
|
|
@@ -32,6 +32,26 @@ export interface ADCPClientConfig extends ConversationConfig {
|
|
|
32
32
|
* Custom: "https://myapp.com/api/v1/adcp/{agent_id}?operation={operation_id}"
|
|
33
33
|
*/
|
|
34
34
|
webhookUrlTemplate?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Runtime schema validation options
|
|
37
|
+
*/
|
|
38
|
+
validation?: {
|
|
39
|
+
/**
|
|
40
|
+
* Fail tasks when response schema validation fails (default: true)
|
|
41
|
+
*
|
|
42
|
+
* When true: Invalid responses cause task to fail with error
|
|
43
|
+
* When false: Schema violations are logged but task continues
|
|
44
|
+
*
|
|
45
|
+
* @default true
|
|
46
|
+
*/
|
|
47
|
+
strictSchemaValidation?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Log all schema validation violations to debug logs (default: true)
|
|
50
|
+
*
|
|
51
|
+
* @default true
|
|
52
|
+
*/
|
|
53
|
+
logSchemaViolations?: boolean;
|
|
54
|
+
};
|
|
35
55
|
}
|
|
36
56
|
/**
|
|
37
57
|
* Main ADCP Client providing strongly-typed conversation-aware interface
|
|
@@ -63,10 +83,12 @@ export declare class ADCPClient {
|
|
|
63
83
|
*/
|
|
64
84
|
private ensureEndpointDiscovered;
|
|
65
85
|
/**
|
|
66
|
-
* Discover MCP endpoint by testing the provided path, then trying
|
|
86
|
+
* Discover MCP endpoint by testing the provided path, then trying variants
|
|
67
87
|
*
|
|
68
|
-
* Strategy:
|
|
69
|
-
*
|
|
88
|
+
* Strategy:
|
|
89
|
+
* 1. Test the exact URL provided (preserving trailing slashes)
|
|
90
|
+
* 2. If that fails, try with/without trailing slash
|
|
91
|
+
* 3. If still fails and doesn't end with /mcp, try adding /mcp
|
|
70
92
|
*
|
|
71
93
|
* Note: This is async and called lazily on first agent interaction
|
|
72
94
|
*/
|
|
@@ -491,6 +513,14 @@ export declare class ADCPClient {
|
|
|
491
513
|
* ```
|
|
492
514
|
*/
|
|
493
515
|
static discoverCreativeFormats(creativeAgentUrl: string, protocol?: 'mcp' | 'a2a'): Promise<Format[]>;
|
|
516
|
+
/**
|
|
517
|
+
* Validate request parameters against AdCP schema
|
|
518
|
+
*/
|
|
519
|
+
private validateRequest;
|
|
520
|
+
/**
|
|
521
|
+
* Get request schema for a given task type
|
|
522
|
+
*/
|
|
523
|
+
private getRequestSchema;
|
|
494
524
|
}
|
|
495
525
|
/**
|
|
496
526
|
* Factory function to create an ADCP client
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ADCPClient.d.ts","sourceRoot":"","sources":["../../../src/lib/core/ADCPClient.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ADCPClient.d.ts","sourceRoot":"","sources":["../../../src/lib/core/ADCPClient.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,KA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