@adcp/sdk 13.0.2 → 13.0.4
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 +37 -2
- package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
- package/dist/lib/server/decisioning/capabilities.d.mts +5 -5
- package/dist/lib/server/decisioning/capabilities.d.ts +5 -5
- package/dist/lib/server/decisioning/capabilities.js.map +1 -1
- package/dist/lib/server/decisioning/capabilities.mjs.map +1 -1
- package/dist/lib/testing/client.d.ts.map +1 -1
- package/dist/lib/testing/client.js +6 -2
- package/dist/lib/testing/client.js.map +1 -1
- package/dist/lib/testing/client.mjs +6 -2
- package/dist/lib/testing/client.mjs.map +1 -1
- package/dist/lib/testing/compliance/comply.d.ts.map +1 -1
- package/dist/lib/testing/compliance/comply.js +27 -18
- package/dist/lib/testing/compliance/comply.js.map +1 -1
- package/dist/lib/testing/compliance/comply.mjs +25 -17
- package/dist/lib/testing/compliance/comply.mjs.map +1 -1
- package/dist/lib/testing/storyboard/runner.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/runner.js +18 -4
- package/dist/lib/testing/storyboard/runner.js.map +1 -1
- package/dist/lib/testing/storyboard/runner.mjs +18 -4
- package/dist/lib/testing/storyboard/runner.mjs.map +1 -1
- package/dist/lib/testing/storyboard/types.d.mts +83 -29
- package/dist/lib/testing/storyboard/types.d.ts +83 -29
- package/dist/lib/testing/storyboard/types.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/types.js.map +1 -1
- package/dist/lib/testing/storyboard/types.mjs.map +1 -1
- package/dist/lib/testing/storyboard/validations.d.mts +3 -1
- package/dist/lib/testing/storyboard/validations.d.ts +3 -1
- package/dist/lib/testing/storyboard/validations.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/validations.js +83 -23
- package/dist/lib/testing/storyboard/validations.js.map +1 -1
- package/dist/lib/testing/storyboard/validations.mjs +83 -24
- package/dist/lib/testing/storyboard/validations.mjs.map +1 -1
- package/dist/lib/testing/types.d.mts +11 -0
- package/dist/lib/testing/types.d.ts +11 -0
- package/dist/lib/testing/types.d.ts.map +1 -1
- package/dist/lib/testing/types.js.map +1 -1
- package/dist/lib/validation/schema-loader.d.ts.map +1 -1
- package/dist/lib/validation/schema-loader.js +9 -0
- package/dist/lib/validation/schema-loader.js.map +1 -1
- package/dist/lib/validation/schema-loader.mjs +8 -0
- package/dist/lib/validation/schema-loader.mjs.map +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.js.map +1 -1
- package/dist/lib/version.mjs +3 -3
- package/dist/lib/version.mjs.map +1 -1
- package/package.json +3 -3
|
@@ -2,7 +2,7 @@ import { prepareResponseForSchemaValidation, TOOL_RESPONSE_SCHEMAS } from "../..
|
|
|
2
2
|
import { injectLegacyEnvelopeStatus } from "../../utils/envelope-status-compat.mjs";
|
|
3
3
|
import { TRANSPORT_SUFFIX_REGEX } from "../../utils/a2a-discovery.mjs";
|
|
4
4
|
import { validateResponse } from "../../validation/schema-validator.mjs";
|
|
5
|
-
import { hasSchemaBundle } from "../../validation/schema-loader.mjs";
|
|
5
|
+
import { hasSchemaBundle, isExternalSchemaRootActive } from "../../validation/schema-loader.mjs";
|
|
6
6
|
import { ADCP_VERSION, LIBRARY_VERSION } from "../../version.mjs";
|
|
7
7
|
import { isPre31AdcpVersion } from "../../utils/adcp-version-config.mjs";
|
|
8
8
|
import { gte as semverGte, valid as validSemver } from "semver";
|
|
@@ -175,10 +175,10 @@ function resolveTarget(ctx) {
|
|
|
175
175
|
return { success: false, data: void 0 };
|
|
176
176
|
}
|
|
177
177
|
const SCHEMA_URL_BASE = "https://adcontextprotocol.org";
|
|
178
|
-
function resolveSchemaIdentity(schemaRef) {
|
|
178
|
+
function resolveSchemaIdentity(schemaRef, adcpVersion = ADCP_VERSION) {
|
|
179
179
|
if (!schemaRef) return { schema_id: null, schema_url: null };
|
|
180
180
|
const trimmed = schemaRef.replace(/^\/+/, "");
|
|
181
|
-
const schemaId = `/schemas/${
|
|
181
|
+
const schemaId = `/schemas/${adcpVersion}/${trimmed}`;
|
|
182
182
|
const schemaUrl = `${SCHEMA_URL_BASE}${schemaId}`;
|
|
183
183
|
return { schema_id: schemaId, schema_url: schemaUrl };
|
|
184
184
|
}
|
|
@@ -231,34 +231,54 @@ function mapZodIssueToSchemaKeyword(issue) {
|
|
|
231
231
|
}
|
|
232
232
|
function validateResponseSchema(validation, ctx, taskResult) {
|
|
233
233
|
const taskName = ctx.taskName;
|
|
234
|
-
const
|
|
235
|
-
const
|
|
236
|
-
if (!schema) {
|
|
237
|
-
return {
|
|
238
|
-
check: "response_schema",
|
|
239
|
-
passed: false,
|
|
240
|
-
description: validation.description,
|
|
241
|
-
error: `No schema registered for task "${taskName}"`,
|
|
242
|
-
json_pointer: null,
|
|
243
|
-
expected: schema_id ?? `response schema for ${taskName}`,
|
|
244
|
-
// The runner failed before observing the agent — distinguish that from
|
|
245
|
-
// "agent returned null" so implementors don't chase a phantom agent bug.
|
|
246
|
-
actual: { reason: "no_schema_registered", task: taskName },
|
|
247
|
-
schema_id,
|
|
248
|
-
schema_url
|
|
249
|
-
};
|
|
250
|
-
}
|
|
234
|
+
const schemaIdentityVersion = ctx.adcpVersion ?? ctx.responseAdcpVersion ?? ADCP_VERSION;
|
|
235
|
+
const { schema_id, schema_url } = resolveSchemaIdentity(ctx.responseSchemaRef, schemaIdentityVersion);
|
|
251
236
|
const rawData = taskResult.data ?? {};
|
|
252
237
|
const dataWithoutMessage = Array.isArray(rawData) ? rawData : (() => {
|
|
253
238
|
const { _message, ...rest } = rawData;
|
|
254
239
|
return rest;
|
|
255
240
|
})();
|
|
241
|
+
const schema = TOOL_RESPONSE_SCHEMAS[taskName];
|
|
256
242
|
const dataForValidation = Array.isArray(dataWithoutMessage) ? dataWithoutMessage : injectLegacyEnvelopeStatus(dataWithoutMessage, { toolName: taskName });
|
|
257
243
|
const responseAdcpVersion = ctx.responseAdcpVersion ?? ctx.adcpVersion;
|
|
258
|
-
const parseResult = schema
|
|
244
|
+
const parseResult = schema?.safeParse(
|
|
259
245
|
prepareResponseForSchemaValidation(taskName, dataForValidation, responseAdcpVersion)
|
|
260
246
|
);
|
|
261
|
-
const
|
|
247
|
+
const computedStrict = computeStrictVerdict(taskName, dataWithoutMessage, ctx.adcpVersion, ctx.responseAdcpVersion);
|
|
248
|
+
const strict = computedStrict ? { ...computedStrict, lenient_valid: parseResult?.success ?? null } : void 0;
|
|
249
|
+
const externalSchemaIsAuthoritative = isExternalResponseSchemaAuthoritative(ctx);
|
|
250
|
+
if (externalSchemaIsAuthoritative && strict) {
|
|
251
|
+
if (strict.valid) {
|
|
252
|
+
const base = {
|
|
253
|
+
check: "response_schema",
|
|
254
|
+
passed: true,
|
|
255
|
+
description: validation.description,
|
|
256
|
+
schema_id,
|
|
257
|
+
schema_url,
|
|
258
|
+
strict
|
|
259
|
+
};
|
|
260
|
+
const warning = buildStrictWarning(strict);
|
|
261
|
+
return warning ? { ...base, warning } : base;
|
|
262
|
+
}
|
|
263
|
+
const issues2 = strict.issues ?? [];
|
|
264
|
+
const firstIssue2 = issues2[0];
|
|
265
|
+
return {
|
|
266
|
+
check: "response_schema",
|
|
267
|
+
passed: false,
|
|
268
|
+
description: validation.description,
|
|
269
|
+
error: issues2.length > 0 ? issues2.slice(0, 5).map((issue) => `${issue.instance_path || "/"}: ${issue.message}`).join("; ") : `External JSON Schema rejected the ${taskName} response`,
|
|
270
|
+
json_pointer: firstIssue2?.instance_path || null,
|
|
271
|
+
expected: schema_id ?? `response schema for ${taskName}`,
|
|
272
|
+
actual: issues2,
|
|
273
|
+
schema_id,
|
|
274
|
+
schema_url,
|
|
275
|
+
strict
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
if (!schema) {
|
|
279
|
+
return noResponseSchemaResult(validation, taskName, schema_id, schema_url, strict);
|
|
280
|
+
}
|
|
281
|
+
if (!parseResult) return noResponseSchemaResult(validation, taskName, schema_id, schema_url, strict);
|
|
262
282
|
if (parseResult.success) {
|
|
263
283
|
const base = {
|
|
264
284
|
check: "response_schema",
|
|
@@ -267,6 +287,19 @@ function validateResponseSchema(validation, ctx, taskResult) {
|
|
|
267
287
|
schema_id,
|
|
268
288
|
schema_url
|
|
269
289
|
};
|
|
290
|
+
if (strict && !strict.valid && ctx.strictResponseSchemaValidation === true) {
|
|
291
|
+
const issues2 = strict.issues ?? [];
|
|
292
|
+
const firstIssue2 = issues2[0];
|
|
293
|
+
return {
|
|
294
|
+
...base,
|
|
295
|
+
passed: false,
|
|
296
|
+
error: issues2.length > 0 ? issues2.slice(0, 5).map((issue) => `${issue.instance_path || "/"}: ${issue.message}`).join("; ") : `Strict JSON Schema rejected the ${taskName} response`,
|
|
297
|
+
json_pointer: firstIssue2?.instance_path || null,
|
|
298
|
+
expected: schema_id ?? `response schema for ${taskName}`,
|
|
299
|
+
actual: issues2,
|
|
300
|
+
strict
|
|
301
|
+
};
|
|
302
|
+
}
|
|
270
303
|
const warning = strict ? buildStrictWarning(strict) : void 0;
|
|
271
304
|
if (!strict && !warning) return base;
|
|
272
305
|
if (!strict) return { ...base, warning };
|
|
@@ -289,9 +322,34 @@ function validateResponseSchema(validation, ctx, taskResult) {
|
|
|
289
322
|
};
|
|
290
323
|
return strict ? { ...failed, strict } : failed;
|
|
291
324
|
}
|
|
325
|
+
function isExternalResponseSchemaAuthoritative(ctx) {
|
|
326
|
+
const validationVersion = responseSchemaValidationVersion(ctx.adcpVersion, ctx.responseAdcpVersion);
|
|
327
|
+
return validationVersion !== void 0 && isExternalSchemaRootActive(validationVersion);
|
|
328
|
+
}
|
|
329
|
+
function responseSchemaValidationVersion(adcpVersion, responseAdcpVersion) {
|
|
330
|
+
if (adcpVersion && isExternalSchemaRootActive(adcpVersion)) return adcpVersion;
|
|
331
|
+
return responseAdcpVersion && hasSchemaBundle(responseAdcpVersion) ? responseAdcpVersion : adcpVersion;
|
|
332
|
+
}
|
|
333
|
+
function noResponseSchemaResult(validation, taskName, schema_id, schema_url, strict) {
|
|
334
|
+
const result = {
|
|
335
|
+
check: "response_schema",
|
|
336
|
+
passed: false,
|
|
337
|
+
description: validation.description,
|
|
338
|
+
error: `No schema registered for task "${taskName}"`,
|
|
339
|
+
json_pointer: null,
|
|
340
|
+
expected: schema_id ?? `response schema for ${taskName}`,
|
|
341
|
+
// The runner failed before observing the agent — distinguish that from
|
|
342
|
+
// "agent returned null" so implementors don't chase a phantom agent bug.
|
|
343
|
+
actual: { reason: "no_schema_registered", task: taskName },
|
|
344
|
+
schema_id,
|
|
345
|
+
schema_url
|
|
346
|
+
};
|
|
347
|
+
return strict ? { ...result, strict } : result;
|
|
348
|
+
}
|
|
292
349
|
function computeStrictVerdict(taskName, payload, adcpVersion, responseAdcpVersion) {
|
|
293
|
-
const
|
|
294
|
-
|
|
350
|
+
const externalVersionSelected = adcpVersion !== void 0 && isExternalSchemaRootActive(adcpVersion);
|
|
351
|
+
const validationVersion = responseSchemaValidationVersion(adcpVersion, responseAdcpVersion);
|
|
352
|
+
if (!externalVersionSelected && responseAdcpVersion && isPre31AdcpVersion(responseAdcpVersion) && !hasSchemaBundle(responseAdcpVersion)) {
|
|
295
353
|
return void 0;
|
|
296
354
|
}
|
|
297
355
|
const payloadForValidation = prepareResponseForSchemaValidation(taskName, payload, responseAdcpVersion);
|
|
@@ -2538,6 +2596,7 @@ export {
|
|
|
2538
2596
|
RUNNER_CAPABILITY_VERSION,
|
|
2539
2597
|
decorateValidationResult,
|
|
2540
2598
|
detectShapeDriftHint,
|
|
2599
|
+
isExternalResponseSchemaAuthoritative,
|
|
2541
2600
|
resolvePath2 as resolvePath,
|
|
2542
2601
|
runValidations,
|
|
2543
2602
|
validationFailsStep
|