opentool 0.7.4 → 0.7.6

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/cli/index.js CHANGED
@@ -543,6 +543,7 @@ async function verifyX402Payment(attempt, definition, options = {}) {
543
543
  const requirement = toX402Requirement(definition);
544
544
  const headers = buildFacilitatorHeaders(facilitator);
545
545
  try {
546
+ console.log("[x402] Calling facilitator /verify", { url: verifierUrl });
546
547
  const verifyResponse = await fetchImpl(verifierUrl, {
547
548
  method: "POST",
548
549
  headers,
@@ -552,6 +553,7 @@ async function verifyX402Payment(attempt, definition, options = {}) {
552
553
  paymentRequirements: requirement
553
554
  })
554
555
  });
556
+ console.log("[x402] Facilitator /verify response", { status: verifyResponse.status });
555
557
  if (!verifyResponse.ok) {
556
558
  return {
557
559
  success: false,
@@ -578,6 +580,7 @@ async function verifyX402Payment(attempt, definition, options = {}) {
578
580
  ensureTrailingSlash(facilitator.url)
579
581
  ).toString();
580
582
  try {
583
+ console.log("[x402] Calling facilitator /settle", { url: settleUrl });
581
584
  const settleResponse = await fetchImpl(settleUrl, {
582
585
  method: "POST",
583
586
  headers,
@@ -587,16 +590,31 @@ async function verifyX402Payment(attempt, definition, options = {}) {
587
590
  paymentRequirements: requirement
588
591
  })
589
592
  });
590
- if (settleResponse.ok) {
591
- const settlePayload = await settleResponse.json();
592
- if (settlePayload.txHash) {
593
- responseHeaders[HEADER_PAYMENT_RESPONSE] = JSON.stringify({
594
- settled: true,
595
- txHash: settlePayload.txHash
596
- });
597
- }
593
+ console.log("[x402] Facilitator /settle response", { status: settleResponse.status });
594
+ if (!settleResponse.ok) {
595
+ return {
596
+ success: false,
597
+ failure: {
598
+ reason: `Facilitator settlement failed: ${settleResponse.status}`,
599
+ code: "settlement_failed"
600
+ }
601
+ };
602
+ }
603
+ const settlePayload = await settleResponse.json();
604
+ if (settlePayload.txHash) {
605
+ responseHeaders[HEADER_PAYMENT_RESPONSE] = JSON.stringify({
606
+ settled: true,
607
+ txHash: settlePayload.txHash
608
+ });
598
609
  }
599
- } catch {
610
+ } catch (error) {
611
+ return {
612
+ success: false,
613
+ failure: {
614
+ reason: error instanceof Error ? error.message : "Settlement failed",
615
+ code: "settlement_failed"
616
+ }
617
+ };
600
618
  }
601
619
  }
602
620
  const result = {