@forgeintel/sdk 0.5.0-beta.12 → 0.5.0-beta.13
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 +6 -3
- package/dist/express.js +12 -2
- package/dist/fetch.js +3 -2
- package/dist/hono.js +0 -2
- package/dist/openapi.js +6 -1
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -104,7 +104,10 @@ export function checkOptions(input) {
|
|
|
104
104
|
}
|
|
105
105
|
return { errors, warnings, options };
|
|
106
106
|
}
|
|
107
|
-
/**
|
|
107
|
+
/**
|
|
108
|
+
* Used when invalid options turned Forge off: nothing is recorded or added, but agent context is still removed from
|
|
109
|
+
* requests, so agents that learned about it (an earlier deploy, a cached listing) can't trip strict validators.
|
|
110
|
+
*/
|
|
108
111
|
function disabledCore(errors, warnings) {
|
|
109
112
|
const passThrough = {
|
|
110
113
|
feedbackId: undefined,
|
|
@@ -113,8 +116,8 @@ function disabledCore(errors, warnings) {
|
|
|
113
116
|
json: (_status, body) => body,
|
|
114
117
|
text: (_status, _type, body) => body,
|
|
115
118
|
headers: () => ({}),
|
|
116
|
-
requestBody: (body) => body,
|
|
117
|
-
requestUrl: (url) => url,
|
|
119
|
+
requestBody: (body) => takeFromBody(body).body,
|
|
120
|
+
requestUrl: (url) => takeFromUrl(url).url,
|
|
118
121
|
finish: () => { },
|
|
119
122
|
};
|
|
120
123
|
return {
|
package/dist/express.js
CHANGED
|
@@ -202,8 +202,18 @@ export function createForge(options) {
|
|
|
202
202
|
diagnostics: core.diagnostics,
|
|
203
203
|
shutdown: core.shutdown,
|
|
204
204
|
middleware() {
|
|
205
|
-
if (!core.enabled)
|
|
206
|
-
|
|
205
|
+
if (!core.enabled) {
|
|
206
|
+
// Disabled by invalid options: only remove agent context, so strict validators never see it.
|
|
207
|
+
return (req, _res, next) => {
|
|
208
|
+
try {
|
|
209
|
+
takeAgentContext(req, core.call({ method: req.method, path: req.path, header: () => undefined }));
|
|
210
|
+
}
|
|
211
|
+
catch {
|
|
212
|
+
// never break the business request
|
|
213
|
+
}
|
|
214
|
+
next();
|
|
215
|
+
};
|
|
216
|
+
}
|
|
207
217
|
return (req, res, next) => {
|
|
208
218
|
core
|
|
209
219
|
.route({
|
package/dist/fetch.js
CHANGED
|
@@ -113,8 +113,6 @@ export function createForge(options) {
|
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
async function handle(request, next) {
|
|
116
|
-
if (!core.enabled)
|
|
117
|
-
return next(request);
|
|
118
116
|
// Before the handler: our own routes, the spec, and agent context. Required-context errors stop paid attempts.
|
|
119
117
|
let call;
|
|
120
118
|
let forwarded = request;
|
|
@@ -168,6 +166,9 @@ export function createForge(options) {
|
|
|
168
166
|
}
|
|
169
167
|
return next(request);
|
|
170
168
|
}
|
|
169
|
+
// Disabled by invalid options: agent context is removed (above), nothing else.
|
|
170
|
+
if (!core.enabled)
|
|
171
|
+
return next(forwarded);
|
|
171
172
|
const response = await next(forwarded);
|
|
172
173
|
// After the handler: decorate the 402 or the paid response. Any failure before the body is read: the original
|
|
173
174
|
// response goes out. Once read, the body is always sent from what was read (decorated or not).
|
package/dist/hono.js
CHANGED
|
@@ -10,8 +10,6 @@ export function createForge(options) {
|
|
|
10
10
|
shutdown: forge.shutdown,
|
|
11
11
|
validate: forge.validate,
|
|
12
12
|
middleware() {
|
|
13
|
-
if (!forge.enabled)
|
|
14
|
-
return async (_c, next) => next();
|
|
15
13
|
return async (c, next) => {
|
|
16
14
|
let ranNext = false;
|
|
17
15
|
const response = await forge.handle(c.req.raw, async (request) => {
|
package/dist/openapi.js
CHANGED
|
@@ -61,6 +61,8 @@ function feedbackProperties(rateUrl, hintField = false) {
|
|
|
61
61
|
}
|
|
62
62
|
/** Returns an extended copy of an object schema, or a reason it can't be extended safely. */
|
|
63
63
|
function extendSchema(doc, schema, props) {
|
|
64
|
+
if (schema === true)
|
|
65
|
+
schema = {}; // `true` accepts any value, like {}
|
|
64
66
|
if (!isObj(schema))
|
|
65
67
|
return { reason: "no_schema" };
|
|
66
68
|
let target = schema;
|
|
@@ -83,7 +85,10 @@ function extendSchema(doc, schema, props) {
|
|
|
83
85
|
if (COMPOSITION.some((k) => k in copy))
|
|
84
86
|
return { reason: "composition" };
|
|
85
87
|
const types = Array.isArray(copy.type) ? copy.type : [copy.type];
|
|
86
|
-
|
|
88
|
+
// {} (annotations only) accepts any value, e.g. FastAPI's default response schema. `properties` only constrains
|
|
89
|
+
// objects, so documenting the field there narrows nothing.
|
|
90
|
+
const anyValue = Object.keys(copy).every((k) => ANNOTATIONS.has(k));
|
|
91
|
+
const objectish = anyValue || types.includes("object") || (copy.type === undefined && (isObj(copy.properties) || Array.isArray(copy.allOf)));
|
|
87
92
|
if (!objectish)
|
|
88
93
|
return { reason: "not_object" };
|
|
89
94
|
if ("propertyNames" in copy || "maxProperties" in copy)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forgeintel/sdk",
|
|
3
|
-
"version": "0.5.0-beta.
|
|
3
|
+
"version": "0.5.0-beta.13",
|
|
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",
|