@forgeintel/sdk 0.5.0-alpha.feedback030.b13 → 0.5.0-alpha.feedback030top.b13
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/core.js +3 -2
- package/dist/openapi.js +5 -4
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -501,14 +501,15 @@ function enabledCore(options, configWarnings) {
|
|
|
501
501
|
Object.getPrototypeOf(body) === Object.prototype &&
|
|
502
502
|
!(FEEDBACK_FIELD in body) &&
|
|
503
503
|
(allowInjection?.(request.method, request.path, status) ?? true)) {
|
|
504
|
-
// One namespaced object, so the merchant's own fields stay recognizably theirs.
|
|
504
|
+
// One namespaced object, so the merchant's own fields stay recognizably theirs. It goes first:
|
|
505
|
+
// agents read the top of a response, and long results would otherwise push it out of view.
|
|
505
506
|
return {
|
|
506
|
-
...body,
|
|
507
507
|
[FEEDBACK_FIELD]: {
|
|
508
508
|
feedback_id: feedbackId,
|
|
509
509
|
feedback_url: feedbackUrl,
|
|
510
510
|
...(rateHint ? { rate_this_call: rateHint.replaceAll("{feedback_url}", feedbackUrl).replaceAll("{summary_url}", callLinks.summary) } : {}),
|
|
511
511
|
},
|
|
512
|
+
...body,
|
|
512
513
|
};
|
|
513
514
|
}
|
|
514
515
|
}
|
package/dist/openapi.js
CHANGED
|
@@ -60,7 +60,7 @@ function feedbackProperties(rateUrl, hintField = false) {
|
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
62
|
/** Returns an extended copy of an object schema, or a reason it can't be extended safely. */
|
|
63
|
-
function extendSchema(doc, schema, props) {
|
|
63
|
+
function extendSchema(doc, schema, props, first = false) {
|
|
64
64
|
if (schema === true)
|
|
65
65
|
schema = {}; // `true` accepts any value, like {}
|
|
66
66
|
if (!isObj(schema))
|
|
@@ -109,7 +109,8 @@ function extendSchema(doc, schema, props) {
|
|
|
109
109
|
return { reason: "field_collision" };
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
|
|
112
|
+
const own = isObj(copy.properties) ? copy.properties : {};
|
|
113
|
+
copy.properties = first ? { ...clone(props), ...own } : { ...own, ...clone(props) };
|
|
113
114
|
return { schema: copy };
|
|
114
115
|
}
|
|
115
116
|
const BODYLESS = new Set(["get", "head", "delete", "options", "trace"]);
|
|
@@ -349,7 +350,7 @@ export function enrichOpenApi(input, options) {
|
|
|
349
350
|
opReport.responses[code] = "undocumented";
|
|
350
351
|
continue;
|
|
351
352
|
}
|
|
352
|
-
const results = schemas.map((s) => extendSchema(doc, s.get(), props));
|
|
353
|
+
const results = schemas.map((s) => extendSchema(doc, s.get(), props, true)); // first, as in the body
|
|
353
354
|
const failure = results.find((r) => "reason" in r);
|
|
354
355
|
if (failure) {
|
|
355
356
|
opReport.responses[code] = "incompatible";
|
|
@@ -365,7 +366,7 @@ export function enrichOpenApi(input, options) {
|
|
|
365
366
|
// agentcash-style payment metadata carries its own output schema.
|
|
366
367
|
const info = op["x-payment-info"];
|
|
367
368
|
if (isObj(info) && isObj(info.outputSchema)) {
|
|
368
|
-
const r = extendSchema(doc, info.outputSchema, props);
|
|
369
|
+
const r = extendSchema(doc, info.outputSchema, props, true);
|
|
369
370
|
if ("schema" in r)
|
|
370
371
|
info.outputSchema = r.schema;
|
|
371
372
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forgeintel/sdk",
|
|
3
|
-
"version": "0.5.0-alpha.
|
|
3
|
+
"version": "0.5.0-alpha.feedback030top.b13",
|
|
4
4
|
"description": "The Forge SDK for x402 paid APIs: agent feedback, agent context, OpenAPI and challenge enrichment, and passive call signals. Express, Hono, Next.js and fetch handlers. No Forge network request on the merchant response path.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|