@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.
Files changed (2) hide show
  1. package/dist/index.js +41 -29
  2. 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 res = await fetch(`${this.config.apiUrl}${path2}`, {
2840
- ...fetchOptions,
2841
- headers
2842
- });
2843
- if (!res.ok) {
2844
- if (res.status === 401 && !skipAuth) {
2845
- const refreshed = await this.refreshTokens();
2846
- if (refreshed) {
2847
- headers["Authorization"] = `Bearer ${this.config.accessToken}`;
2848
- const retryRes = await fetch(`${this.config.apiUrl}${path2}`, {
2849
- ...fetchOptions,
2850
- headers
2851
- });
2852
- if (retryRes.ok) {
2853
- return retryRes.json();
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
- clearAuth();
2857
- throw new Error("Session expired. Please run 'thoughtful login' again.");
2871
+ throw new ApiError(res.status, res.statusText, body);
2858
2872
  }
2859
- let body;
2860
- const text2 = await res.text();
2861
- try {
2862
- body = JSON.parse(text2);
2863
- } catch {
2864
- body = text2;
2873
+ const text = await res.text();
2874
+ if (!text) {
2875
+ return {};
2865
2876
  }
2866
- throw new ApiError(res.status, res.statusText, body);
2867
- }
2868
- const text = await res.text();
2869
- if (!text) {
2870
- return {};
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.1",
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": "./dist/index.js"
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/tfl-inc/thoughtful"
49
+ "url": "git+https://github.com/lex-inc/tokatsu.git"
50
50
  }
51
51
  }