@adcp/sdk 13.0.2 → 13.0.3
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/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 +86 -23
- package/dist/lib/testing/storyboard/validations.js.map +1 -1
- package/dist/lib/testing/storyboard/validations.mjs +86 -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 +1 -1
|
@@ -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,57 @@ 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) {
|
|
251
|
+
if (!strict) {
|
|
252
|
+
return noResponseSchemaResult(validation, taskName, schema_id, schema_url);
|
|
253
|
+
}
|
|
254
|
+
if (strict.valid) {
|
|
255
|
+
const base = {
|
|
256
|
+
check: "response_schema",
|
|
257
|
+
passed: true,
|
|
258
|
+
description: validation.description,
|
|
259
|
+
schema_id,
|
|
260
|
+
schema_url,
|
|
261
|
+
strict
|
|
262
|
+
};
|
|
263
|
+
const warning = buildStrictWarning(strict);
|
|
264
|
+
return warning ? { ...base, warning } : base;
|
|
265
|
+
}
|
|
266
|
+
const issues2 = strict.issues ?? [];
|
|
267
|
+
const firstIssue2 = issues2[0];
|
|
268
|
+
return {
|
|
269
|
+
check: "response_schema",
|
|
270
|
+
passed: false,
|
|
271
|
+
description: validation.description,
|
|
272
|
+
error: issues2.length > 0 ? issues2.slice(0, 5).map((issue) => `${issue.instance_path || "/"}: ${issue.message}`).join("; ") : `External JSON Schema rejected the ${taskName} response`,
|
|
273
|
+
json_pointer: firstIssue2?.instance_path || null,
|
|
274
|
+
expected: schema_id ?? `response schema for ${taskName}`,
|
|
275
|
+
actual: issues2,
|
|
276
|
+
schema_id,
|
|
277
|
+
schema_url,
|
|
278
|
+
strict
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
if (!schema) {
|
|
282
|
+
return noResponseSchemaResult(validation, taskName, schema_id, schema_url, strict);
|
|
283
|
+
}
|
|
284
|
+
if (!parseResult) return noResponseSchemaResult(validation, taskName, schema_id, schema_url, strict);
|
|
262
285
|
if (parseResult.success) {
|
|
263
286
|
const base = {
|
|
264
287
|
check: "response_schema",
|
|
@@ -267,6 +290,19 @@ function validateResponseSchema(validation, ctx, taskResult) {
|
|
|
267
290
|
schema_id,
|
|
268
291
|
schema_url
|
|
269
292
|
};
|
|
293
|
+
if (strict && !strict.valid && ctx.strictResponseSchemaValidation === true) {
|
|
294
|
+
const issues2 = strict.issues ?? [];
|
|
295
|
+
const firstIssue2 = issues2[0];
|
|
296
|
+
return {
|
|
297
|
+
...base,
|
|
298
|
+
passed: false,
|
|
299
|
+
error: issues2.length > 0 ? issues2.slice(0, 5).map((issue) => `${issue.instance_path || "/"}: ${issue.message}`).join("; ") : `Strict JSON Schema rejected the ${taskName} response`,
|
|
300
|
+
json_pointer: firstIssue2?.instance_path || null,
|
|
301
|
+
expected: schema_id ?? `response schema for ${taskName}`,
|
|
302
|
+
actual: issues2,
|
|
303
|
+
strict
|
|
304
|
+
};
|
|
305
|
+
}
|
|
270
306
|
const warning = strict ? buildStrictWarning(strict) : void 0;
|
|
271
307
|
if (!strict && !warning) return base;
|
|
272
308
|
if (!strict) return { ...base, warning };
|
|
@@ -289,9 +325,34 @@ function validateResponseSchema(validation, ctx, taskResult) {
|
|
|
289
325
|
};
|
|
290
326
|
return strict ? { ...failed, strict } : failed;
|
|
291
327
|
}
|
|
328
|
+
function isExternalResponseSchemaAuthoritative(ctx) {
|
|
329
|
+
const validationVersion = responseSchemaValidationVersion(ctx.adcpVersion, ctx.responseAdcpVersion);
|
|
330
|
+
return validationVersion !== void 0 && isExternalSchemaRootActive(validationVersion);
|
|
331
|
+
}
|
|
332
|
+
function responseSchemaValidationVersion(adcpVersion, responseAdcpVersion) {
|
|
333
|
+
if (adcpVersion && isExternalSchemaRootActive(adcpVersion)) return adcpVersion;
|
|
334
|
+
return responseAdcpVersion && hasSchemaBundle(responseAdcpVersion) ? responseAdcpVersion : adcpVersion;
|
|
335
|
+
}
|
|
336
|
+
function noResponseSchemaResult(validation, taskName, schema_id, schema_url, strict) {
|
|
337
|
+
const result = {
|
|
338
|
+
check: "response_schema",
|
|
339
|
+
passed: false,
|
|
340
|
+
description: validation.description,
|
|
341
|
+
error: `No schema registered for task "${taskName}"`,
|
|
342
|
+
json_pointer: null,
|
|
343
|
+
expected: schema_id ?? `response schema for ${taskName}`,
|
|
344
|
+
// The runner failed before observing the agent — distinguish that from
|
|
345
|
+
// "agent returned null" so implementors don't chase a phantom agent bug.
|
|
346
|
+
actual: { reason: "no_schema_registered", task: taskName },
|
|
347
|
+
schema_id,
|
|
348
|
+
schema_url
|
|
349
|
+
};
|
|
350
|
+
return strict ? { ...result, strict } : result;
|
|
351
|
+
}
|
|
292
352
|
function computeStrictVerdict(taskName, payload, adcpVersion, responseAdcpVersion) {
|
|
293
|
-
const
|
|
294
|
-
|
|
353
|
+
const externalVersionSelected = adcpVersion !== void 0 && isExternalSchemaRootActive(adcpVersion);
|
|
354
|
+
const validationVersion = responseSchemaValidationVersion(adcpVersion, responseAdcpVersion);
|
|
355
|
+
if (!externalVersionSelected && responseAdcpVersion && isPre31AdcpVersion(responseAdcpVersion) && !hasSchemaBundle(responseAdcpVersion)) {
|
|
295
356
|
return void 0;
|
|
296
357
|
}
|
|
297
358
|
const payloadForValidation = prepareResponseForSchemaValidation(taskName, payload, responseAdcpVersion);
|
|
@@ -2538,6 +2599,7 @@ export {
|
|
|
2538
2599
|
RUNNER_CAPABILITY_VERSION,
|
|
2539
2600
|
decorateValidationResult,
|
|
2540
2601
|
detectShapeDriftHint,
|
|
2602
|
+
isExternalResponseSchemaAuthoritative,
|
|
2541
2603
|
resolvePath2 as resolvePath,
|
|
2542
2604
|
runValidations,
|
|
2543
2605
|
validationFailsStep
|