@promptbook/remote-client 0.100.0-1 → 0.100.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/esm/index.es.js +8 -62
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/config.d.ts +0 -10
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +8 -62
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/remote-server/connection-improvements.test.d.ts +0 -1
- package/esm/typings/src/remote-server/utils/connectionProgress.d.ts +0 -72
|
@@ -138,9 +138,6 @@ export declare const SMALL_NUMBER = 0.001;
|
|
|
138
138
|
/**
|
|
139
139
|
* Timeout for the connections in milliseconds
|
|
140
140
|
*
|
|
141
|
-
* Note: Increased from 7 seconds to 30 seconds to accommodate OAuth flows
|
|
142
|
-
* like Facebook login which may require user interaction and redirects
|
|
143
|
-
*
|
|
144
141
|
* @private within the repository - too low-level in comparison with other `MAX_...`
|
|
145
142
|
*/
|
|
146
143
|
export declare const CONNECTION_TIMEOUT_MS: number;
|
|
@@ -150,13 +147,6 @@ export declare const CONNECTION_TIMEOUT_MS: number;
|
|
|
150
147
|
* @private within the repository - too low-level in comparison with other `MAX_...`
|
|
151
148
|
*/
|
|
152
149
|
export declare const CONNECTION_RETRIES_LIMIT = 5;
|
|
153
|
-
/**
|
|
154
|
-
* Timeout specifically for OAuth authentication flows in milliseconds
|
|
155
|
-
* OAuth flows typically require more time due to user interaction and redirects
|
|
156
|
-
*
|
|
157
|
-
* @private within the repository - too low-level in comparison with other `MAX_...`
|
|
158
|
-
*/
|
|
159
|
-
export declare const OAUTH_TIMEOUT_MS: number;
|
|
160
150
|
/**
|
|
161
151
|
* Short time interval to prevent race conditions in milliseconds
|
|
162
152
|
*
|
|
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
|
|
|
15
15
|
export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
|
|
16
16
|
/**
|
|
17
17
|
* Represents the version string of the Promptbook engine.
|
|
18
|
-
* It follows semantic versioning (e.g., `0.100.0-
|
|
18
|
+
* It follows semantic versioning (e.g., `0.100.0-1`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/remote-client",
|
|
3
|
-
"version": "0.100.0-
|
|
3
|
+
"version": "0.100.0-2",
|
|
4
4
|
"description": "Promptbook: Run AI apps in plain human language across multiple models and platforms",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"module": "./esm/index.es.js",
|
|
101
101
|
"typings": "./esm/typings/src/_packages/remote-client.index.d.ts",
|
|
102
102
|
"peerDependencies": {
|
|
103
|
-
"@promptbook/core": "0.100.0-
|
|
103
|
+
"@promptbook/core": "0.100.0-2"
|
|
104
104
|
},
|
|
105
105
|
"dependencies": {
|
|
106
106
|
"crypto": "1.0.1",
|
package/umd/index.umd.js
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* @generated
|
|
24
24
|
* @see https://github.com/webgptorg/promptbook
|
|
25
25
|
*/
|
|
26
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-
|
|
26
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-2';
|
|
27
27
|
/**
|
|
28
28
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
29
29
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -352,12 +352,9 @@
|
|
|
352
352
|
/**
|
|
353
353
|
* Timeout for the connections in milliseconds
|
|
354
354
|
*
|
|
355
|
-
* Note: Increased from 7 seconds to 30 seconds to accommodate OAuth flows
|
|
356
|
-
* like Facebook login which may require user interaction and redirects
|
|
357
|
-
*
|
|
358
355
|
* @private within the repository - too low-level in comparison with other `MAX_...`
|
|
359
356
|
*/
|
|
360
|
-
const CONNECTION_TIMEOUT_MS =
|
|
357
|
+
const CONNECTION_TIMEOUT_MS = 7 * 1000;
|
|
361
358
|
// <- TODO: [⏳] Standardize timeouts, Make DEFAULT_TIMEOUT_MS as global constant
|
|
362
359
|
/**
|
|
363
360
|
* How many times to retry the connections
|
|
@@ -623,39 +620,13 @@
|
|
|
623
620
|
transports: ['polling', 'websocket' /*, <- TODO: [🌬] Allow to pass `transports`, add 'webtransport' */],
|
|
624
621
|
});
|
|
625
622
|
// console.log('Connecting to', this.options.remoteServerUrl.href, { socket });
|
|
626
|
-
let isResolved = false;
|
|
627
623
|
socket.on('connect', () => {
|
|
628
|
-
|
|
629
|
-
isResolved = true;
|
|
630
|
-
resolve(socket);
|
|
631
|
-
}
|
|
632
|
-
});
|
|
633
|
-
socket.on('connect_error', (error) => {
|
|
634
|
-
if (!isResolved) {
|
|
635
|
-
isResolved = true;
|
|
636
|
-
reject(new Error(`Failed to connect to ${remoteServerUrl}: ${error.message || error}`));
|
|
637
|
-
}
|
|
638
|
-
});
|
|
639
|
-
socket.on('disconnect', (reason) => {
|
|
640
|
-
if (!isResolved) {
|
|
641
|
-
isResolved = true;
|
|
642
|
-
reject(new Error(`Connection to ${remoteServerUrl} was disconnected: ${reason}`));
|
|
643
|
-
}
|
|
624
|
+
resolve(socket);
|
|
644
625
|
});
|
|
645
|
-
// Better timeout handling
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
isResolved = true;
|
|
649
|
-
socket.disconnect();
|
|
650
|
-
reject(new Error(`Connection timeout after ${CONNECTION_TIMEOUT_MS / 1000} seconds while connecting to ${remoteServerUrl}. ` +
|
|
651
|
-
`This may indicate network issues or the server may be experiencing high load. ` +
|
|
652
|
-
`For authentication flows like social login, ensure sufficient time is allowed for user interaction.`));
|
|
653
|
-
}
|
|
626
|
+
// TODO: [💩] Better timeout handling
|
|
627
|
+
setTimeout(() => {
|
|
628
|
+
reject(new Error(`Timeout while connecting to ${remoteServerUrl}`));
|
|
654
629
|
}, CONNECTION_TIMEOUT_MS);
|
|
655
|
-
// Clean up timeout if connection succeeds
|
|
656
|
-
socket.on('connect', () => {
|
|
657
|
-
clearTimeout(timeoutId);
|
|
658
|
-
});
|
|
659
630
|
});
|
|
660
631
|
}
|
|
661
632
|
|
|
@@ -5661,33 +5632,8 @@
|
|
|
5661
5632
|
* Check the configuration of all execution tools
|
|
5662
5633
|
*/
|
|
5663
5634
|
async checkConfiguration() {
|
|
5664
|
-
|
|
5665
|
-
|
|
5666
|
-
socket.disconnect();
|
|
5667
|
-
}
|
|
5668
|
-
catch (error) {
|
|
5669
|
-
if (error instanceof Error) {
|
|
5670
|
-
// Provide user-friendly error messages for common connection issues
|
|
5671
|
-
if (error.message.includes('timeout') || error.message.includes('Timeout')) {
|
|
5672
|
-
throw new Error(`Connection to Promptbook server timed out. This may happen during authentication flows like Facebook login. ` +
|
|
5673
|
-
`Please ensure: 1) Server is running at ${this.options.remoteServerUrl}, ` +
|
|
5674
|
-
`2) Network connection is stable, 3) Authentication process is completed within the timeout period. ` +
|
|
5675
|
-
`Original error: ${error.message}`);
|
|
5676
|
-
}
|
|
5677
|
-
if (error.message.includes('connect') || error.message.includes('ECONNREFUSED')) {
|
|
5678
|
-
throw new Error(`Cannot connect to Promptbook server at ${this.options.remoteServerUrl}. ` +
|
|
5679
|
-
`Please check if the server is running and accessible. ` +
|
|
5680
|
-
`Original error: ${error.message}`);
|
|
5681
|
-
}
|
|
5682
|
-
if (error.message.includes('authentication') || error.message.includes('auth')) {
|
|
5683
|
-
throw new Error(`Authentication failed when connecting to Promptbook server. ` +
|
|
5684
|
-
`This may happen if social login (like Facebook) was not completed properly. ` +
|
|
5685
|
-
`Please retry the authentication process. ` +
|
|
5686
|
-
`Original error: ${error.message}`);
|
|
5687
|
-
}
|
|
5688
|
-
}
|
|
5689
|
-
throw error; // Re-throw if not a recognized error pattern
|
|
5690
|
-
}
|
|
5635
|
+
const socket = await createRemoteClient(this.options);
|
|
5636
|
+
socket.disconnect();
|
|
5691
5637
|
// TODO: [main] !!3 Check version of the remote server and compatibility
|
|
5692
5638
|
// TODO: [🎍] Send checkConfiguration
|
|
5693
5639
|
}
|