@promptbook/pdf 0.100.0-1 โ 0.100.0-13
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 +83 -5
- 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/esm/typings/src/wizard/wizard.d.ts +14 -4
- package/package.json +2 -2
- package/umd/index.umd.js +83 -5
- 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-12`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
|
@@ -6,6 +6,15 @@ import type { InputParameters } from '../types/typeAliases';
|
|
|
6
6
|
import type { string_filename } from '../types/typeAliases';
|
|
7
7
|
import type { string_parameter_value } from '../types/typeAliases';
|
|
8
8
|
import type { string_pipeline_url } from '../types/typeAliases';
|
|
9
|
+
/**
|
|
10
|
+
* Options for wizard methods
|
|
11
|
+
*/
|
|
12
|
+
interface WizardOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Whether to enable verbose logging
|
|
15
|
+
*/
|
|
16
|
+
isVerbose?: boolean;
|
|
17
|
+
}
|
|
9
18
|
/**
|
|
10
19
|
* Wizard for simple usage of the Promptbook
|
|
11
20
|
* Look at `wizard` for more details
|
|
@@ -26,7 +35,7 @@ declare class Wizard {
|
|
|
26
35
|
*
|
|
27
36
|
* Note: This works similar to the `ptbk run` command
|
|
28
37
|
*/
|
|
29
|
-
execute(book: string_pipeline_url | string_filename | PipelineString, inputParameters: InputParameters): Promise<{
|
|
38
|
+
execute(book: string_pipeline_url | string_filename | PipelineString, inputParameters: InputParameters, options?: WizardOptions): Promise<{
|
|
30
39
|
/**
|
|
31
40
|
* Simple result of the execution
|
|
32
41
|
*/
|
|
@@ -36,9 +45,9 @@ declare class Wizard {
|
|
|
36
45
|
/**
|
|
37
46
|
* Provides the tools automatically for the Node.js environment
|
|
38
47
|
*
|
|
39
|
-
* @param
|
|
48
|
+
* @param options
|
|
40
49
|
*/
|
|
41
|
-
getExecutionTools(): Promise<Required<Pick<ExecutionTools, 'fs' | 'fetch'>>>;
|
|
50
|
+
getExecutionTools(options?: WizardOptions): Promise<Required<Pick<ExecutionTools, 'fs' | 'fetch'>>>;
|
|
42
51
|
/**
|
|
43
52
|
* Load book from the source
|
|
44
53
|
*
|
|
@@ -49,8 +58,9 @@ declare class Wizard {
|
|
|
49
58
|
* 3) As a string
|
|
50
59
|
*
|
|
51
60
|
* @param pipelineSource
|
|
61
|
+
* @param options
|
|
52
62
|
*/
|
|
53
|
-
getCompiledBook(pipelineSource: string_filename | string_pipeline_url | PipelineString): Promise<PipelineJson>;
|
|
63
|
+
getCompiledBook(pipelineSource: string_filename | string_pipeline_url | PipelineString, options?: WizardOptions): Promise<PipelineJson>;
|
|
54
64
|
}
|
|
55
65
|
/**
|
|
56
66
|
* Wizard for simple usage of the Promptbook
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/pdf",
|
|
3
|
-
"version": "0.100.0-
|
|
3
|
+
"version": "0.100.0-13",
|
|
4
4
|
"description": "Promptbook: Run AI apps in plain human language across multiple models and platforms",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"module": "./esm/index.es.js",
|
|
95
95
|
"typings": "./esm/typings/src/_packages/pdf.index.d.ts",
|
|
96
96
|
"peerDependencies": {
|
|
97
|
-
"@promptbook/core": "0.100.0-
|
|
97
|
+
"@promptbook/core": "0.100.0-13"
|
|
98
98
|
},
|
|
99
99
|
"dependencies": {
|
|
100
100
|
"crypto": "1.0.1",
|
package/umd/index.umd.js
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* @generated
|
|
26
26
|
* @see https://github.com/webgptorg/promptbook
|
|
27
27
|
*/
|
|
28
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-
|
|
28
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-13';
|
|
29
29
|
/**
|
|
30
30
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
31
31
|
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
@@ -846,7 +846,23 @@
|
|
|
846
846
|
.join('/') +
|
|
847
847
|
'.' +
|
|
848
848
|
extension;
|
|
849
|
-
|
|
849
|
+
// Note: Try to create cache directory, but don't fail if filesystem has issues
|
|
850
|
+
try {
|
|
851
|
+
await promises.mkdir(path.dirname(cacheFilename), { recursive: true });
|
|
852
|
+
}
|
|
853
|
+
catch (error) {
|
|
854
|
+
// Note: If we can't create cache directory, continue without it
|
|
855
|
+
// This handles read-only filesystems, permission issues, and missing parent directories
|
|
856
|
+
if (error instanceof Error && (error.message.includes('EROFS') ||
|
|
857
|
+
error.message.includes('read-only') ||
|
|
858
|
+
error.message.includes('EACCES') ||
|
|
859
|
+
error.message.includes('EPERM') ||
|
|
860
|
+
error.message.includes('ENOENT'))) ;
|
|
861
|
+
else {
|
|
862
|
+
// Re-throw other unexpected errors
|
|
863
|
+
throw error;
|
|
864
|
+
}
|
|
865
|
+
}
|
|
850
866
|
let isDestroyed = true;
|
|
851
867
|
const fileHandler = {
|
|
852
868
|
filename: cacheFilename,
|
|
@@ -3496,12 +3512,58 @@
|
|
|
3496
3512
|
// <- TODO: [๐ฅฌ] Encapsulate sha256 to some private utility function
|
|
3497
3513
|
const rootDirname = path.join(process.cwd(), DEFAULT_DOWNLOAD_CACHE_DIRNAME);
|
|
3498
3514
|
const filepath = path.join(...nameToSubfolderPath(hash /* <- TODO: [๐] Maybe add some SHA256 prefix */), `${basename.substring(0, MAX_FILENAME_LENGTH)}.${mimeTypeToExtension(mimeType)}`);
|
|
3499
|
-
|
|
3515
|
+
// Note: Try to create cache directory, but don't fail if filesystem has issues
|
|
3516
|
+
try {
|
|
3517
|
+
await tools.fs.mkdir(path.dirname(path.join(rootDirname, filepath)), { recursive: true });
|
|
3518
|
+
}
|
|
3519
|
+
catch (error) {
|
|
3520
|
+
// Note: If we can't create cache directory, we'll handle it when trying to write the file
|
|
3521
|
+
// This handles read-only filesystems, permission issues, and missing parent directories
|
|
3522
|
+
if (error instanceof Error && (error.message.includes('EROFS') ||
|
|
3523
|
+
error.message.includes('read-only') ||
|
|
3524
|
+
error.message.includes('EACCES') ||
|
|
3525
|
+
error.message.includes('EPERM') ||
|
|
3526
|
+
error.message.includes('ENOENT'))) ;
|
|
3527
|
+
else {
|
|
3528
|
+
// Re-throw other unexpected errors
|
|
3529
|
+
throw error;
|
|
3530
|
+
}
|
|
3531
|
+
}
|
|
3500
3532
|
const fileContent = Buffer.from(await response.arrayBuffer());
|
|
3501
3533
|
if (fileContent.length > DEFAULT_MAX_FILE_SIZE /* <- TODO: Allow to pass different value to remote server */) {
|
|
3502
3534
|
throw new LimitReachedError(`File is too large (${Math.round(fileContent.length / 1024 / 1024)}MB). Maximum allowed size is ${Math.round(DEFAULT_MAX_FILE_SIZE / 1024 / 1024)}MB.`);
|
|
3503
3535
|
}
|
|
3504
|
-
|
|
3536
|
+
// Note: Try to cache the downloaded file, but don't fail if the filesystem is read-only
|
|
3537
|
+
try {
|
|
3538
|
+
await tools.fs.writeFile(path.join(rootDirname, filepath), fileContent);
|
|
3539
|
+
}
|
|
3540
|
+
catch (error) {
|
|
3541
|
+
// Note: If we can't write to cache, we'll process the file directly from memory
|
|
3542
|
+
// This handles read-only filesystems like Vercel
|
|
3543
|
+
if (error instanceof Error && (error.message.includes('EROFS') ||
|
|
3544
|
+
error.message.includes('read-only') ||
|
|
3545
|
+
error.message.includes('EACCES') ||
|
|
3546
|
+
error.message.includes('EPERM') ||
|
|
3547
|
+
error.message.includes('ENOENT'))) {
|
|
3548
|
+
// Return a handler that works directly with the downloaded content
|
|
3549
|
+
return {
|
|
3550
|
+
source: name,
|
|
3551
|
+
filename: null,
|
|
3552
|
+
url,
|
|
3553
|
+
mimeType,
|
|
3554
|
+
async asJson() {
|
|
3555
|
+
return JSON.parse(fileContent.toString('utf-8'));
|
|
3556
|
+
},
|
|
3557
|
+
async asText() {
|
|
3558
|
+
return fileContent.toString('utf-8');
|
|
3559
|
+
},
|
|
3560
|
+
};
|
|
3561
|
+
}
|
|
3562
|
+
else {
|
|
3563
|
+
// Re-throw other unexpected errors
|
|
3564
|
+
throw error;
|
|
3565
|
+
}
|
|
3566
|
+
}
|
|
3505
3567
|
// TODO: [๐ต] Check the file security
|
|
3506
3568
|
// TODO: [๐งน][๐ง ] Delete the file after the scraping is done
|
|
3507
3569
|
return makeKnowledgeSourceHandler({ name, knowledgeSourceContent: filepath }, tools, {
|
|
@@ -6287,7 +6349,23 @@
|
|
|
6287
6349
|
// <- TODO: [๐] Make MarkitdownError
|
|
6288
6350
|
}
|
|
6289
6351
|
// console.log('!!', { result, cacheFilehandler });
|
|
6290
|
-
|
|
6352
|
+
// Note: Try to cache the converted content, but don't fail if the filesystem is read-only
|
|
6353
|
+
try {
|
|
6354
|
+
await this.tools.fs.writeFile(cacheFilehandler.filename, result.text_content);
|
|
6355
|
+
}
|
|
6356
|
+
catch (error) {
|
|
6357
|
+
// Note: If we can't write to cache, we'll continue without caching
|
|
6358
|
+
// This handles read-only filesystems like Vercel
|
|
6359
|
+
if (error instanceof Error && (error.message.includes('EROFS') ||
|
|
6360
|
+
error.message.includes('read-only') ||
|
|
6361
|
+
error.message.includes('EACCES') ||
|
|
6362
|
+
error.message.includes('EPERM') ||
|
|
6363
|
+
error.message.includes('ENOENT'))) ;
|
|
6364
|
+
else {
|
|
6365
|
+
// Re-throw other unexpected errors
|
|
6366
|
+
throw error;
|
|
6367
|
+
}
|
|
6368
|
+
}
|
|
6291
6369
|
}
|
|
6292
6370
|
return cacheFilehandler;
|
|
6293
6371
|
}
|