@lex-inc/thoughtful 0.0.1 → 0.0.2
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/index.js +41 -29
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -2836,40 +2836,52 @@ class ThoughtfulClient {
|
|
|
2836
2836
|
if (!skipAuth && this.config.accessToken) {
|
|
2837
2837
|
headers["Authorization"] = `Bearer ${this.config.accessToken}`;
|
|
2838
2838
|
}
|
|
2839
|
-
const
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2839
|
+
const controller = new AbortController;
|
|
2840
|
+
const timeoutId = setTimeout(() => controller.abort(), 120000);
|
|
2841
|
+
try {
|
|
2842
|
+
const res = await fetch(`${this.config.apiUrl}${path2}`, {
|
|
2843
|
+
...fetchOptions,
|
|
2844
|
+
headers,
|
|
2845
|
+
signal: controller.signal
|
|
2846
|
+
});
|
|
2847
|
+
clearTimeout(timeoutId);
|
|
2848
|
+
if (!res.ok) {
|
|
2849
|
+
if (res.status === 401 && !skipAuth) {
|
|
2850
|
+
const refreshed = await this.refreshTokens();
|
|
2851
|
+
if (refreshed) {
|
|
2852
|
+
headers["Authorization"] = `Bearer ${this.config.accessToken}`;
|
|
2853
|
+
const retryRes = await fetch(`${this.config.apiUrl}${path2}`, {
|
|
2854
|
+
...fetchOptions,
|
|
2855
|
+
headers
|
|
2856
|
+
});
|
|
2857
|
+
if (retryRes.ok) {
|
|
2858
|
+
return retryRes.json();
|
|
2859
|
+
}
|
|
2854
2860
|
}
|
|
2861
|
+
clearAuth();
|
|
2862
|
+
throw new Error("Session expired. Please run 'thoughtful login' again.");
|
|
2863
|
+
}
|
|
2864
|
+
let body;
|
|
2865
|
+
const text2 = await res.text();
|
|
2866
|
+
try {
|
|
2867
|
+
body = JSON.parse(text2);
|
|
2868
|
+
} catch {
|
|
2869
|
+
body = text2;
|
|
2855
2870
|
}
|
|
2856
|
-
|
|
2857
|
-
throw new Error("Session expired. Please run 'thoughtful login' again.");
|
|
2871
|
+
throw new ApiError(res.status, res.statusText, body);
|
|
2858
2872
|
}
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
body = JSON.parse(text2);
|
|
2863
|
-
} catch {
|
|
2864
|
-
body = text2;
|
|
2873
|
+
const text = await res.text();
|
|
2874
|
+
if (!text) {
|
|
2875
|
+
return {};
|
|
2865
2876
|
}
|
|
2866
|
-
|
|
2867
|
-
}
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2877
|
+
return JSON.parse(text);
|
|
2878
|
+
} catch (error) {
|
|
2879
|
+
clearTimeout(timeoutId);
|
|
2880
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
2881
|
+
throw new Error("Request timed out after 2 minutes. The AI response may be taking longer than expected.");
|
|
2882
|
+
}
|
|
2883
|
+
throw error;
|
|
2871
2884
|
}
|
|
2872
|
-
return JSON.parse(text);
|
|
2873
2885
|
}
|
|
2874
2886
|
async sendVerificationCode(email) {
|
|
2875
2887
|
return this.request("/api/auth/mobile/send-code", {
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lex-inc/thoughtful",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "CLI tool for interacting with your Thoughtful workspace",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
-
"thoughtful": "
|
|
7
|
+
"thoughtful": "dist/index.js"
|
|
8
8
|
},
|
|
9
9
|
"main": "./dist/index.js",
|
|
10
10
|
"files": [
|
|
@@ -46,6 +46,6 @@
|
|
|
46
46
|
"license": "MIT",
|
|
47
47
|
"repository": {
|
|
48
48
|
"type": "git",
|
|
49
|
-
"url": "https://github.com/
|
|
49
|
+
"url": "git+https://github.com/lex-inc/tokatsu.git"
|
|
50
50
|
}
|
|
51
51
|
}
|