@promptbook/wizard 0.98.0-9 → 0.99.0-0

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.
@@ -138,6 +138,9 @@ 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
+ *
141
144
  * @private within the repository - too low-level in comparison with other `MAX_...`
142
145
  */
143
146
  export declare const CONNECTION_TIMEOUT_MS: number;
@@ -147,6 +150,13 @@ export declare const CONNECTION_TIMEOUT_MS: number;
147
150
  * @private within the repository - too low-level in comparison with other `MAX_...`
148
151
  */
149
152
  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;
150
160
  /**
151
161
  * Short time interval to prevent race conditions in milliseconds
152
162
  *
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Connection progress utilities for better user experience during authentication
3
+ */
4
+ /**
5
+ * Connection status types for better progress indication
6
+ *
7
+ * @private
8
+ */
9
+ export type ConnectionStatus = 'connecting' | 'authenticating' | 'connected' | 'disconnected' | 'error' | 'timeout';
10
+ /**
11
+ * Progress callback function type for connection status updates
12
+ *
13
+ * @private
14
+ */
15
+ export type ConnectionProgressCallback = (status: ConnectionStatus, message?: string) => void;
16
+ /**
17
+ * Enhanced connection options with progress reporting
18
+ *
19
+ * @private
20
+ */
21
+ export interface ConnectionProgressOptions {
22
+ onProgress?: ConnectionProgressCallback;
23
+ enableProgressReporting?: boolean;
24
+ }
25
+ /**
26
+ * Default progress messages for different connection states
27
+ *
28
+ * @private
29
+ */
30
+ export declare const DEFAULT_PROGRESS_MESSAGES: {
31
+ readonly connecting: "Connecting to Promptbook server...";
32
+ readonly authenticating: "Authenticating with social provider (Facebook, Google, etc.)...";
33
+ readonly connected: "Successfully connected to Promptbook server";
34
+ readonly disconnected: "Disconnected from Promptbook server";
35
+ readonly error: "Connection failed";
36
+ readonly timeout: "Connection timed out - this may happen during social login flows";
37
+ };
38
+ /**
39
+ * Creates a progress reporter for connection status
40
+ * This can be used by frontend applications to show connection progress
41
+ *
42
+ * @private
43
+ */
44
+ export declare function createConnectionProgressReporter(callback?: ConnectionProgressCallback): ConnectionProgressCallback;
45
+ /**
46
+ * Timeout constants with descriptions for different connection types
47
+ *
48
+ * @private
49
+ */
50
+ export declare const CONNECTION_TIMEOUTS: {
51
+ /** Standard timeout for regular connections */
52
+ readonly STANDARD: number;
53
+ /** Extended timeout for OAuth flows that require user interaction */
54
+ readonly OAUTH: number;
55
+ /** Short timeout for quick health checks */
56
+ readonly HEALTH_CHECK: number;
57
+ };
58
+ /**
59
+ * Helper function to get appropriate timeout based on connection type
60
+ *
61
+ * @private
62
+ */
63
+ export declare function getConnectionTimeout(type: 'standard' | 'oauth' | 'health_check'): number;
64
+ /**
65
+ * Creates a timeout wrapper with progress reporting
66
+ *
67
+ * @private
68
+ */
69
+ export declare function createTimeoutWithProgress(timeoutMs: number, onProgress?: ConnectionProgressCallback): Promise<never>;
70
+ /**
71
+ * Note: [💞] Ignore a discrepancy between file name and entity name
72
+ */
@@ -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.98.0-8`).
18
+ * It follows semantic versioning (e.g., `0.98.0`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/wizard",
3
- "version": "0.98.0-9",
3
+ "version": "0.99.0-0",
4
4
  "description": "Promptbook: Run AI apps in plain human language across multiple models and platforms",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -15,51 +15,72 @@
15
15
  ],
16
16
  "keywords": [
17
17
  "ai",
18
- "llm",
19
- "prompt",
20
- "template",
18
+ "ai-agents",
19
+ "ai-application-framework",
20
+ "ai-assistant",
21
+ "ai-automation",
22
+ "ai-development",
23
+ "ai-framework",
24
+ "ai-ops",
25
+ "ai-orchestration",
26
+ "ai-pipeline",
27
+ "ai-platform",
28
+ "ai-scripting",
29
+ "ai-sdk",
30
+ "ai-workflow",
31
+ "api-integration",
32
+ "automation-framework",
33
+ "book-language",
34
+ "browser",
35
+ "chatbot",
36
+ "configuration",
37
+ "content-generation",
38
+ "conversational-ai",
39
+ "cross-platform",
40
+ "cross-provider",
41
+ "developer-tools",
42
+ "embeddings",
43
+ "function-calling",
44
+ "generative-ai",
45
+ "getting-started",
46
+ "human-readable",
47
+ "javascript",
48
+ "knowledge-base",
21
49
  "language-model",
22
- "chatgpt",
23
- "autogpt",
50
+ "large-language-models",
51
+ "llm",
52
+ "llmops",
24
53
  "machine-learning",
54
+ "markdown-dsl",
55
+ "mlops",
56
+ "model-agnostic",
57
+ "multi-model",
58
+ "multimodal",
59
+ "natural-language",
25
60
  "natural-language-processing",
26
61
  "nlp",
27
- "openai",
28
- "o3",
29
- "o3-mini",
30
- "deepseek",
31
- "gpt-3",
32
- "gpt-4",
33
- "gpt-4o",
34
- "gpt-4o-mini",
35
- "o1",
36
- "o1-mini",
37
- "o1-preview",
38
- "anthropic",
39
- "claude",
40
- "claude-3",
41
- "claude-3-opus",
42
- "claude-3-sonnet",
43
- "claude-3-haiku",
44
- "gemini",
45
- "gemini-pro",
46
- "gemini-flash",
47
- "mixtral",
48
- "mistral",
49
- "ollama",
50
- "ai-orchestration",
62
+ "nodejs",
63
+ "orchestration",
64
+ "pipeline",
65
+ "plain-english",
66
+ "prompt",
67
+ "prompt-chaining",
51
68
  "prompt-engineering",
52
- "llmops",
53
- "multimodal",
54
- "reasoning",
69
+ "prompt-management",
70
+ "prompt-template",
55
71
  "rag",
56
- "embeddings",
57
- "function-calling",
58
- "large-language-models",
59
- "ai-application-framework",
72
+ "reasoning",
73
+ "setup",
74
+ "task-automation",
75
+ "template",
60
76
  "text-generation",
61
- "ai-agents",
62
- "LLMOps"
77
+ "text-processing",
78
+ "typescript",
79
+ "unified-interface",
80
+ "vendor-agnostic",
81
+ "wizard",
82
+ "workflow",
83
+ "workflow-engine"
63
84
  ],
64
85
  "license": "BUSL-1.1",
65
86
  "bugs": {
@@ -74,7 +95,7 @@
74
95
  "module": "./esm/index.es.js",
75
96
  "typings": "./esm/typings/src/_packages/wizard.index.d.ts",
76
97
  "peerDependencies": {
77
- "@promptbook/core": "0.98.0-9"
98
+ "@promptbook/core": "0.99.0-0"
78
99
  },
79
100
  "dependencies": {
80
101
  "@ai-sdk/deepseek": "0.1.6",
package/umd/index.umd.js CHANGED
@@ -49,7 +49,7 @@
49
49
  * @generated
50
50
  * @see https://github.com/webgptorg/promptbook
51
51
  */
52
- const PROMPTBOOK_ENGINE_VERSION = '0.98.0-9';
52
+ const PROMPTBOOK_ENGINE_VERSION = '0.99.0-0';
53
53
  /**
54
54
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
55
55
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -203,9 +203,12 @@
203
203
  /**
204
204
  * Timeout for the connections in milliseconds
205
205
  *
206
+ * Note: Increased from 7 seconds to 30 seconds to accommodate OAuth flows
207
+ * like Facebook login which may require user interaction and redirects
208
+ *
206
209
  * @private within the repository - too low-level in comparison with other `MAX_...`
207
210
  */
208
- const CONNECTION_TIMEOUT_MS = 7 * 1000;
211
+ const CONNECTION_TIMEOUT_MS = 30 * 1000;
209
212
  // <- TODO: [⏳] Standardize timeouts, Make DEFAULT_TIMEOUT_MS as global constant
210
213
  /**
211
214
  * How many times to retry the connections
@@ -1397,13 +1400,39 @@
1397
1400
  transports: ['polling', 'websocket' /*, <- TODO: [🌬] Allow to pass `transports`, add 'webtransport' */],
1398
1401
  });
1399
1402
  // console.log('Connecting to', this.options.remoteServerUrl.href, { socket });
1403
+ let isResolved = false;
1400
1404
  socket.on('connect', () => {
1401
- resolve(socket);
1405
+ if (!isResolved) {
1406
+ isResolved = true;
1407
+ resolve(socket);
1408
+ }
1409
+ });
1410
+ socket.on('connect_error', (error) => {
1411
+ if (!isResolved) {
1412
+ isResolved = true;
1413
+ reject(new Error(`Failed to connect to ${remoteServerUrl}: ${error.message || error}`));
1414
+ }
1415
+ });
1416
+ socket.on('disconnect', (reason) => {
1417
+ if (!isResolved) {
1418
+ isResolved = true;
1419
+ reject(new Error(`Connection to ${remoteServerUrl} was disconnected: ${reason}`));
1420
+ }
1402
1421
  });
1403
- // TODO: [💩] Better timeout handling
1404
- setTimeout(() => {
1405
- reject(new Error(`Timeout while connecting to ${remoteServerUrl}`));
1422
+ // Better timeout handling with more descriptive error message
1423
+ const timeoutId = setTimeout(() => {
1424
+ if (!isResolved) {
1425
+ isResolved = true;
1426
+ socket.disconnect();
1427
+ reject(new Error(`Connection timeout after ${CONNECTION_TIMEOUT_MS / 1000} seconds while connecting to ${remoteServerUrl}. ` +
1428
+ `This may indicate network issues or the server may be experiencing high load. ` +
1429
+ `For authentication flows like social login, ensure sufficient time is allowed for user interaction.`));
1430
+ }
1406
1431
  }, CONNECTION_TIMEOUT_MS);
1432
+ // Clean up timeout if connection succeeds
1433
+ socket.on('connect', () => {
1434
+ clearTimeout(timeoutId);
1435
+ });
1407
1436
  });
1408
1437
  }
1409
1438
 
@@ -1449,8 +1478,33 @@
1449
1478
  * Check the configuration of all execution tools
1450
1479
  */
1451
1480
  async checkConfiguration() {
1452
- const socket = await createRemoteClient(this.options);
1453
- socket.disconnect();
1481
+ try {
1482
+ const socket = await createRemoteClient(this.options);
1483
+ socket.disconnect();
1484
+ }
1485
+ catch (error) {
1486
+ if (error instanceof Error) {
1487
+ // Provide user-friendly error messages for common connection issues
1488
+ if (error.message.includes('timeout') || error.message.includes('Timeout')) {
1489
+ throw new Error(`Connection to Promptbook server timed out. This may happen during authentication flows like Facebook login. ` +
1490
+ `Please ensure: 1) Server is running at ${this.options.remoteServerUrl}, ` +
1491
+ `2) Network connection is stable, 3) Authentication process is completed within the timeout period. ` +
1492
+ `Original error: ${error.message}`);
1493
+ }
1494
+ if (error.message.includes('connect') || error.message.includes('ECONNREFUSED')) {
1495
+ throw new Error(`Cannot connect to Promptbook server at ${this.options.remoteServerUrl}. ` +
1496
+ `Please check if the server is running and accessible. ` +
1497
+ `Original error: ${error.message}`);
1498
+ }
1499
+ if (error.message.includes('authentication') || error.message.includes('auth')) {
1500
+ throw new Error(`Authentication failed when connecting to Promptbook server. ` +
1501
+ `This may happen if social login (like Facebook) was not completed properly. ` +
1502
+ `Please retry the authentication process. ` +
1503
+ `Original error: ${error.message}`);
1504
+ }
1505
+ }
1506
+ throw error; // Re-throw if not a recognized error pattern
1507
+ }
1454
1508
  // TODO: [main] !!3 Check version of the remote server and compatibility
1455
1509
  // TODO: [🎍] Send checkConfiguration
1456
1510
  }
@@ -5124,6 +5178,7 @@
5124
5178
  options: {
5125
5179
  apiKey: 'sk-',
5126
5180
  baseURL: 'https://api.openai.com/v1',
5181
+ defaultModelName: 'gpt-4-turbo',
5127
5182
  isProxied: false,
5128
5183
  remoteServerUrl: DEFAULT_REMOTE_SERVER_URL,
5129
5184
  maxRequestsPerMinute: DEFAULT_MAX_REQUESTS_PER_MINUTE,
@@ -12141,9 +12196,10 @@
12141
12196
  .list()
12142
12197
  .find(({ packageName, className }) => llmConfiguration.packageName === packageName && llmConfiguration.className === className);
12143
12198
  if (registeredItem === undefined) {
12144
- console.log('!!! $llmToolsRegister.list()', $llmToolsRegister.list());
12199
+ // console.log('$llmToolsRegister.list()', $llmToolsRegister.list());
12145
12200
  throw new Error(spaceTrim__default["default"]((block) => `
12146
12201
  There is no constructor for LLM provider \`${llmConfiguration.className}\` from \`${llmConfiguration.packageName}\`
12202
+ Running in ${!$isRunningInBrowser() ? '' : 'browser environment'}${!$isRunningInNode() ? '' : 'node environment'}${!$isRunningInWebWorker() ? '' : 'worker environment'}
12147
12203
 
12148
12204
  You have probably forgotten install and import the provider package.
12149
12205
  To fix this issue, you can: