@lidianai/cli 0.1.5 → 0.1.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/lib/http.ts +8 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lidianai/cli",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "publishConfig": {
package/src/lib/http.ts CHANGED
@@ -60,6 +60,10 @@ const authHeaders = (apiKey?: string): HeadersInit => {
60
60
  };
61
61
 
62
62
  const handleResponse = async <T>(response: Response): Promise<T> => {
63
+ const hasPaymentHeader =
64
+ response.headers.get("x402") !== null ||
65
+ response.headers.get("payment-required") !== null;
66
+
63
67
  const json = (await response
64
68
  .json()
65
69
  .catch(() => null)) as ApiResponse<T> | null;
@@ -87,6 +91,10 @@ const handleResponse = async <T>(response: Response): Promise<T> => {
87
91
  throw new CliError(`Request failed with status ${response.status}`, 1);
88
92
  }
89
93
 
94
+ if (hasPaymentHeader) {
95
+ return null as T;
96
+ }
97
+
90
98
  if (!json || !("success" in json) || json.success !== true) {
91
99
  throw new CliError("Unexpected API response format", 1);
92
100
  }