@promptbook/remote-client 0.100.0-1 → 0.100.0-3

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 CHANGED
@@ -20,7 +20,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
20
20
  * @generated
21
21
  * @see https://github.com/webgptorg/promptbook
22
22
  */
23
- const PROMPTBOOK_ENGINE_VERSION = '0.100.0-1';
23
+ const PROMPTBOOK_ENGINE_VERSION = '0.100.0-3';
24
24
  /**
25
25
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
26
26
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -349,12 +349,9 @@ const LOOP_LIMIT = 1000;
349
349
  /**
350
350
  * Timeout for the connections in milliseconds
351
351
  *
352
- * Note: Increased from 7 seconds to 30 seconds to accommodate OAuth flows
353
- * like Facebook login which may require user interaction and redirects
354
- *
355
352
  * @private within the repository - too low-level in comparison with other `MAX_...`
356
353
  */
357
- const CONNECTION_TIMEOUT_MS = 30 * 1000;
354
+ const CONNECTION_TIMEOUT_MS = 7 * 1000;
358
355
  // <- TODO: [⏳] Standardize timeouts, Make DEFAULT_TIMEOUT_MS as global constant
359
356
  /**
360
357
  * How many times to retry the connections
@@ -620,39 +617,13 @@ async function createRemoteClient(options) {
620
617
  transports: ['polling', 'websocket' /*, <- TODO: [🌬] Allow to pass `transports`, add 'webtransport' */],
621
618
  });
622
619
  // console.log('Connecting to', this.options.remoteServerUrl.href, { socket });
623
- let isResolved = false;
624
620
  socket.on('connect', () => {
625
- if (!isResolved) {
626
- isResolved = true;
627
- resolve(socket);
628
- }
629
- });
630
- socket.on('connect_error', (error) => {
631
- if (!isResolved) {
632
- isResolved = true;
633
- reject(new Error(`Failed to connect to ${remoteServerUrl}: ${error.message || error}`));
634
- }
635
- });
636
- socket.on('disconnect', (reason) => {
637
- if (!isResolved) {
638
- isResolved = true;
639
- reject(new Error(`Connection to ${remoteServerUrl} was disconnected: ${reason}`));
640
- }
621
+ resolve(socket);
641
622
  });
642
- // Better timeout handling with more descriptive error message
643
- const timeoutId = setTimeout(() => {
644
- if (!isResolved) {
645
- isResolved = true;
646
- socket.disconnect();
647
- reject(new Error(`Connection timeout after ${CONNECTION_TIMEOUT_MS / 1000} seconds while connecting to ${remoteServerUrl}. ` +
648
- `This may indicate network issues or the server may be experiencing high load. ` +
649
- `For authentication flows like social login, ensure sufficient time is allowed for user interaction.`));
650
- }
623
+ // TODO: [💩] Better timeout handling
624
+ setTimeout(() => {
625
+ reject(new Error(`Timeout while connecting to ${remoteServerUrl}`));
651
626
  }, CONNECTION_TIMEOUT_MS);
652
- // Clean up timeout if connection succeeds
653
- socket.on('connect', () => {
654
- clearTimeout(timeoutId);
655
- });
656
627
  });
657
628
  }
658
629
 
@@ -5658,33 +5629,8 @@ class RemoteLlmExecutionTools {
5658
5629
  * Check the configuration of all execution tools
5659
5630
  */
5660
5631
  async checkConfiguration() {
5661
- try {
5662
- const socket = await createRemoteClient(this.options);
5663
- socket.disconnect();
5664
- }
5665
- catch (error) {
5666
- if (error instanceof Error) {
5667
- // Provide user-friendly error messages for common connection issues
5668
- if (error.message.includes('timeout') || error.message.includes('Timeout')) {
5669
- throw new Error(`Connection to Promptbook server timed out. This may happen during authentication flows like Facebook login. ` +
5670
- `Please ensure: 1) Server is running at ${this.options.remoteServerUrl}, ` +
5671
- `2) Network connection is stable, 3) Authentication process is completed within the timeout period. ` +
5672
- `Original error: ${error.message}`);
5673
- }
5674
- if (error.message.includes('connect') || error.message.includes('ECONNREFUSED')) {
5675
- throw new Error(`Cannot connect to Promptbook server at ${this.options.remoteServerUrl}. ` +
5676
- `Please check if the server is running and accessible. ` +
5677
- `Original error: ${error.message}`);
5678
- }
5679
- if (error.message.includes('authentication') || error.message.includes('auth')) {
5680
- throw new Error(`Authentication failed when connecting to Promptbook server. ` +
5681
- `This may happen if social login (like Facebook) was not completed properly. ` +
5682
- `Please retry the authentication process. ` +
5683
- `Original error: ${error.message}`);
5684
- }
5685
- }
5686
- throw error; // Re-throw if not a recognized error pattern
5687
- }
5632
+ const socket = await createRemoteClient(this.options);
5633
+ socket.disconnect();
5688
5634
  // TODO: [main] !!3 Check version of the remote server and compatibility
5689
5635
  // TODO: [🎍] Send checkConfiguration
5690
5636
  }