@forgeintel/sdk 0.5.0-alpha.feedback030top.b13 → 0.5.0-alpha.legacy030.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/ask.js CHANGED
@@ -4,7 +4,7 @@ export const ASK = {
4
4
  soft: {
5
5
  challengeSentence: "After your call, please rate this service for other agents: GET {rate_url}?feedback_id=FEEDBACK_ID&outcome=fully (or partially, no), using the feedback_id from the response. Free, one request.",
6
6
  shortChallengeSentence: "After your call, please rate it for other agents: GET {rate_url}?feedback_id=FEEDBACK_ID&outcome=fully. Free, one request.",
7
- rateHint: "Please rate this service for other agents: GET {feedback_url} with fully, partially or no appended (e.g. {feedback_url}fully). Free, no payment: any HTTP client works, including your x402 one. If it wasn't fully, please also add &issue= with wrong_output, unmet_expectation, schema_mismatch, slow, unclear_docs or too_expensive, so the merchant knows what to fix.",
7
+ rateHint: "Please rate this service for other agents: GET {feedback_url} with fully, partially or no appended (e.g. {feedback_url}fully). Free, one request.",
8
8
  extensionAsk: "After your call, please rate this service for other agents. Free, one request.",
9
9
  extensionExtras: {},
10
10
  },
package/dist/core.js CHANGED
@@ -8,7 +8,7 @@ import { agentContextAsk, contextIssues, parseAgentContext, takeFromBody, takeFr
8
8
  import { EventReporter } from "./reporter.js";
9
9
  import { captureClientHeaders } from "./client-signals.js";
10
10
  import { ISSUES, NOTE_MAX_LENGTH, OUTCOMES, PROTOCOL, parseSubmission } from "./values.js";
11
- import { FEEDBACK_FIELD, challengeOrigin, describeChallenge, describeChallengeBody, describeReceipt, feedbackExtension, paymentOrigin, readPaymentHeader, readReceipt, receiptExtension } from "./x402.js";
11
+ import { challengeOrigin, describeChallenge, describeChallengeBody, describeReceipt, feedbackExtension, paymentOrigin, readPaymentHeader, readReceipt, receiptExtension } from "./x402.js";
12
12
  export const FEEDBACK_HEADERS = { "Cache-Control": "no-store", "X-Robots-Tag": "noindex" };
13
13
  /** Max JSON body for POST {basePath}. */
14
14
  export const BODY_LIMIT = 8 * 1024;
@@ -276,7 +276,7 @@ function enabledCore(options, configWarnings) {
276
276
  protocol: PROTOCOL,
277
277
  cost: "free",
278
278
  ratings_are_public_at: links.summary,
279
- feedback_id: `Returned by paid responses in the ${FEEDBACK_FIELD} body object (feedback_id) and the Forge-Feedback-Id header.`,
279
+ feedback_id: "Returned by paid responses as the feedback_id body field and the Forge-Feedback-Id header.",
280
280
  quick: { method: "GET", url: `${links.rate}?feedback_id=FEEDBACK_ID&outcome=OUTCOME`, optional_param: "issue=ISSUE" },
281
281
  detailed: {
282
282
  method: "POST",
@@ -499,17 +499,16 @@ function enabledCore(options, configWarnings) {
499
499
  body !== null &&
500
500
  typeof body === "object" &&
501
501
  Object.getPrototypeOf(body) === Object.prototype &&
502
- !(FEEDBACK_FIELD in body) &&
502
+ !("feedback_id" in body) &&
503
+ !("feedback_url" in body) &&
504
+ !(rateHint && "rate_this_call" in body) &&
503
505
  (allowInjection?.(request.method, request.path, status) ?? true)) {
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.
506
+ // Legacy 0.3.0 shape: flat fields after the merchant's own.
506
507
  return {
507
- [FEEDBACK_FIELD]: {
508
- feedback_id: feedbackId,
509
- feedback_url: feedbackUrl,
510
- ...(rateHint ? { rate_this_call: rateHint.replaceAll("{feedback_url}", feedbackUrl).replaceAll("{summary_url}", callLinks.summary) } : {}),
511
- },
512
508
  ...body,
509
+ feedback_id: feedbackId,
510
+ feedback_url: feedbackUrl,
511
+ ...(rateHint ? { rate_this_call: rateHint.replaceAll("{feedback_url}", feedbackUrl).replaceAll("{summary_url}", callLinks.summary) } : {}),
513
512
  };
514
513
  }
515
514
  }
package/dist/openapi.js CHANGED
@@ -3,7 +3,6 @@
3
3
  // and on any unexpected input return the original document unchanged.
4
4
  import { CONTEXT_FIELD, agentContextParameters, agentContextSchema } from "./context.js";
5
5
  import { FEEDBACK_ID_PATTERN } from "./id.js";
6
- import { FEEDBACK_FIELD } from "./x402.js";
7
6
  import { ISSUES, NOTE_MAX_LENGTH, OUTCOMES, PROTOCOL } from "./values.js";
8
7
  const METHODS = ["get", "put", "post", "delete", "options", "head", "patch", "trace"];
9
8
  const ANNOTATIONS = new Set(["$ref", "description", "title", "summary", "example", "examples", "deprecated", "readOnly", "writeOnly", "$comment"]);
@@ -38,29 +37,23 @@ function resolveRef(doc, ref) {
38
37
  return undefined;
39
38
  }
40
39
  function feedbackProperties(rateUrl, hintField = false) {
40
+ // Legacy 0.3.0 shape: flat fields, as in the paid body.
41
41
  return {
42
- [FEEDBACK_FIELD]: {
43
- type: "object",
44
- description: "Added by Forge to paid responses: how to rate this call. See x-forge-feedback.",
45
- required: ["feedback_id", "feedback_url"],
46
- properties: {
47
- feedback_id: {
48
- type: "string",
49
- pattern: FEEDBACK_ID_PATTERN.source,
50
- description: "Rating ID for this paid call (also sent as the Forge-Feedback-Id header).",
51
- },
52
- feedback_url: {
53
- type: "string",
54
- format: "uri-reference",
55
- description: `Quick-rating URL with outcome left blank; outcome values: ${Object.keys(OUTCOMES).join(", ")}. Base: ${rateUrl}`,
56
- },
57
- ...(hintField ? { rate_this_call: { type: "string", description: "How to rate this paid call in one free request." } } : {}),
58
- },
42
+ ...(hintField ? { rate_this_call: { type: "string", description: "How to rate this paid call in one free request." } } : {}),
43
+ feedback_id: {
44
+ type: "string",
45
+ pattern: FEEDBACK_ID_PATTERN.source,
46
+ description: "Rating ID for this paid call (also sent as the Forge-Feedback-Id header). See x-forge-feedback.",
47
+ },
48
+ feedback_url: {
49
+ type: "string",
50
+ format: "uri",
51
+ description: `Quick-rating URL with outcome left blank; outcome values: ${Object.keys(OUTCOMES).join(", ")}. Base: ${rateUrl}`,
59
52
  },
60
53
  };
61
54
  }
62
55
  /** Returns an extended copy of an object schema, or a reason it can't be extended safely. */
63
- function extendSchema(doc, schema, props, first = false) {
56
+ function extendSchema(doc, schema, props) {
64
57
  if (schema === true)
65
58
  schema = {}; // `true` accepts any value, like {}
66
59
  if (!isObj(schema))
@@ -109,8 +102,7 @@ function extendSchema(doc, schema, props, first = false) {
109
102
  return { reason: "field_collision" };
110
103
  }
111
104
  }
112
- const own = isObj(copy.properties) ? copy.properties : {};
113
- copy.properties = first ? { ...clone(props), ...own } : { ...own, ...clone(props) };
105
+ copy.properties = { ...(isObj(copy.properties) ? copy.properties : {}), ...clone(props) };
114
106
  return { schema: copy };
115
107
  }
116
108
  const BODYLESS = new Set(["get", "head", "delete", "options", "trace"]);
@@ -350,7 +342,7 @@ export function enrichOpenApi(input, options) {
350
342
  opReport.responses[code] = "undocumented";
351
343
  continue;
352
344
  }
353
- const results = schemas.map((s) => extendSchema(doc, s.get(), props, true)); // first, as in the body
345
+ const results = schemas.map((s) => extendSchema(doc, s.get(), props));
354
346
  const failure = results.find((r) => "reason" in r);
355
347
  if (failure) {
356
348
  opReport.responses[code] = "incompatible";
@@ -366,7 +358,7 @@ export function enrichOpenApi(input, options) {
366
358
  // agentcash-style payment metadata carries its own output schema.
367
359
  const info = op["x-payment-info"];
368
360
  if (isObj(info) && isObj(info.outputSchema)) {
369
- const r = extendSchema(doc, info.outputSchema, props, true);
361
+ const r = extendSchema(doc, info.outputSchema, props);
370
362
  if ("schema" in r)
371
363
  info.outputSchema = r.schema;
372
364
  }
package/dist/x402.js CHANGED
@@ -50,7 +50,7 @@ export function feedbackExtension(rateUrl, tone = "soft") {
50
50
  ...ASK[tone].extensionExtras,
51
51
  rate: `GET ${rateUrl}?feedback_id=FEEDBACK_ID&outcome=fully`,
52
52
  outcome: ["fully", "partially", "no"],
53
- feedback_id: `In the paid response body (${FEEDBACK_FIELD}.feedback_id) and the Forge-Feedback-Id header.`,
53
+ feedback_id: "In the paid response body (feedback_id) and the Forge-Feedback-Id header.",
54
54
  payment: "None. Plain GET, not an x402 endpoint.",
55
55
  },
56
56
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forgeintel/sdk",
3
- "version": "0.5.0-alpha.feedback030top.b13",
3
+ "version": "0.5.0-alpha.legacy030.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",