@promptbook/cli 0.100.0-2 → 0.100.0-20
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/README.md +1 -0
- package/esm/index.es.js +77 -10
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +24 -0
- package/esm/typings/src/_packages/types.index.d.ts +28 -0
- package/esm/typings/src/book-2.0/agent-source/parseAgentSource.d.ts +30 -0
- package/esm/typings/src/book-2.0/agent-source/parseAgentSource.test.d.ts +1 -0
- package/esm/typings/src/book-2.0/agent-source/string_book.d.ts +26 -0
- package/esm/typings/src/book-2.0/commitments/ACTION/ACTION.d.ts +30 -0
- package/esm/typings/src/book-2.0/commitments/FORMAT/FORMAT.d.ts +31 -0
- package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/FrontendRAGService.d.ts +48 -0
- package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/KNOWLEDGE.d.ts +43 -0
- package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/RAGService.d.ts +54 -0
- package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/processors/BaseKnowledgeProcessor.d.ts +45 -0
- package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/processors/PdfProcessor.d.ts +31 -0
- package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/processors/ProcessorFactory.d.ts +23 -0
- package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/processors/TextProcessor.d.ts +18 -0
- package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/types.d.ts +56 -0
- package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/utils/ragHelper.d.ts +34 -0
- package/esm/typings/src/book-2.0/commitments/META_IMAGE/META_IMAGE.d.ts +36 -0
- package/esm/typings/src/book-2.0/commitments/META_LINK/META_LINK.d.ts +48 -0
- package/esm/typings/src/book-2.0/commitments/MODEL/MODEL.d.ts +31 -0
- package/esm/typings/src/book-2.0/commitments/NOTE/NOTE.d.ts +41 -0
- package/esm/typings/src/book-2.0/commitments/PERSONA/PERSONA.d.ts +38 -0
- package/esm/typings/src/book-2.0/commitments/RULE/RULE.d.ts +36 -0
- package/esm/typings/src/book-2.0/commitments/SAMPLE/SAMPLE.d.ts +36 -0
- package/esm/typings/src/book-2.0/commitments/STYLE/STYLE.d.ts +30 -0
- package/esm/typings/src/book-2.0/commitments/_base/BaseCommitmentDefinition.d.ts +42 -0
- package/esm/typings/src/book-2.0/commitments/_base/BookCommitment.d.ts +5 -0
- package/esm/typings/src/book-2.0/commitments/_base/CommitmentDefinition.d.ts +37 -0
- package/esm/typings/src/book-2.0/commitments/_base/NotYetImplementedCommitmentDefinition.d.ts +14 -0
- package/esm/typings/src/book-2.0/commitments/_base/createEmptyAgentModelRequirements.d.ts +19 -0
- package/esm/typings/src/book-2.0/commitments/_misc/AgentModelRequirements.d.ts +37 -0
- package/esm/typings/src/book-2.0/commitments/_misc/AgentSourceParseResult.d.ts +18 -0
- package/esm/typings/src/book-2.0/commitments/_misc/ParsedCommitment.d.ts +22 -0
- package/esm/typings/src/book-2.0/commitments/_misc/createAgentModelRequirements.d.ts +61 -0
- package/esm/typings/src/book-2.0/commitments/_misc/createAgentModelRequirementsWithCommitments.d.ts +35 -0
- package/esm/typings/src/book-2.0/commitments/_misc/createCommitmentRegex.d.ts +20 -0
- package/esm/typings/src/book-2.0/commitments/_misc/parseAgentSourceWithCommitments.d.ts +24 -0
- package/esm/typings/src/book-2.0/commitments/_misc/removeCommentsFromSystemMessage.d.ts +11 -0
- package/esm/typings/src/book-2.0/commitments/index.d.ts +56 -0
- package/esm/typings/src/book-2.0/utils/profileImageUtils.d.ts +39 -0
- package/esm/typings/src/pipeline/book-notation.d.ts +2 -1
- package/esm/typings/src/types/typeAliases.d.ts +6 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/esm/typings/src/wizard/wizard.d.ts +14 -4
- package/package.json +1 -1
- package/umd/index.umd.js +77 -10
- package/umd/index.umd.js.map +1 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { string_url_image } from '../../types/typeAliases';
|
|
2
|
+
/**
|
|
3
|
+
* Extracts profile image URL from agent definition text and returns cleaned system message
|
|
4
|
+
* @param systemMessage The original system message that may contain META IMAGE line
|
|
5
|
+
* @returns Object with profileImageUrl (if found) and cleanedSystemMessage (without META IMAGE line)
|
|
6
|
+
*
|
|
7
|
+
* @private - TODO: [🧠] Maybe should be public?
|
|
8
|
+
*/
|
|
9
|
+
export declare function extractProfileImageFromSystemMessage(systemMessage: string): {
|
|
10
|
+
profileImageUrl?: string_url_image;
|
|
11
|
+
cleanedSystemMessage: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Extracts persona, examples, and profile image from agent definition text
|
|
15
|
+
* @param systemMessage The original system message that may contain PERSONA, EXAMPLE, and META IMAGE lines
|
|
16
|
+
* @returns Object with extracted information and cleaned system message
|
|
17
|
+
*
|
|
18
|
+
* @private - TODO: [🧠] Maybe should be public?
|
|
19
|
+
*/
|
|
20
|
+
export declare function extractAgentMetadata(systemMessage: string): {
|
|
21
|
+
persona?: {
|
|
22
|
+
name: string;
|
|
23
|
+
description?: string;
|
|
24
|
+
};
|
|
25
|
+
examples: string[];
|
|
26
|
+
profileImageUrl?: string_url_image;
|
|
27
|
+
cleanedSystemMessage: string;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Generates a gravatar URL based on agent name for fallback avatar
|
|
31
|
+
* @param name The agent name to generate avatar for
|
|
32
|
+
* @returns Gravatar URL
|
|
33
|
+
*
|
|
34
|
+
* @private - TODO: [🧠] Maybe should be public?
|
|
35
|
+
*/
|
|
36
|
+
export declare function generateGravatarUrl(name?: string | null): string;
|
|
37
|
+
/**
|
|
38
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
39
|
+
*/
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { string_book } from '../book-2.0/agent-source/string_book';
|
|
1
2
|
import type { PipelineString } from './PipelineString';
|
|
2
3
|
/**
|
|
3
4
|
* Tag function for notating a pipeline with a book\`...\ notation as template literal
|
|
@@ -12,7 +13,7 @@ import type { PipelineString } from './PipelineString';
|
|
|
12
13
|
* @returns the pipeline string
|
|
13
14
|
* @public exported from `@promptbook/core`
|
|
14
15
|
*/
|
|
15
|
-
export declare function book(strings: TemplateStringsArray, ...values: Array<string>): PipelineString;
|
|
16
|
+
export declare function book(strings: TemplateStringsArray, ...values: Array<string>): string_book & PipelineString;
|
|
16
17
|
/**
|
|
17
18
|
* TODO: [🧠][🈴] Where is the best location for this file
|
|
18
19
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -136,6 +136,12 @@ export type ReservedParameters = Record<string_reserved_parameter_name, string_p
|
|
|
136
136
|
* For example `"Ai*nautes"`
|
|
137
137
|
*/
|
|
138
138
|
export type string_title = string;
|
|
139
|
+
/**
|
|
140
|
+
* Semantic helper
|
|
141
|
+
*
|
|
142
|
+
* For example `"My AI Assistant"`
|
|
143
|
+
*/
|
|
144
|
+
export type string_agent_name = string;
|
|
139
145
|
/**
|
|
140
146
|
* Unstructured description of the persona
|
|
141
147
|
*
|
|
@@ -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-19`).
|
|
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
package/umd/index.umd.js
CHANGED
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
* @generated
|
|
58
58
|
* @see https://github.com/webgptorg/promptbook
|
|
59
59
|
*/
|
|
60
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-
|
|
60
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-20';
|
|
61
61
|
/**
|
|
62
62
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
63
63
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -2208,8 +2208,27 @@
|
|
|
2208
2208
|
throw new UnexpectedError(`The "${key}" you want to store in JSON file is not serializable as JSON`);
|
|
2209
2209
|
}
|
|
2210
2210
|
const fileContent = stringifyPipelineJson(value);
|
|
2211
|
-
|
|
2212
|
-
|
|
2211
|
+
// Note: Try to create cache directory and write file, but don't fail if filesystem is read-only or has permission issues
|
|
2212
|
+
try {
|
|
2213
|
+
await promises.mkdir(path.dirname(filename), { recursive: true }); // <- [0]
|
|
2214
|
+
await promises.writeFile(filename, fileContent, 'utf-8');
|
|
2215
|
+
}
|
|
2216
|
+
catch (error) {
|
|
2217
|
+
// Note: If we can't write to cache, silently ignore the error
|
|
2218
|
+
// This handles read-only filesystems, permission issues, and missing parent directories
|
|
2219
|
+
if (error instanceof Error && (error.message.includes('EROFS') ||
|
|
2220
|
+
error.message.includes('read-only') ||
|
|
2221
|
+
error.message.includes('EACCES') ||
|
|
2222
|
+
error.message.includes('EPERM') ||
|
|
2223
|
+
error.message.includes('ENOENT'))) {
|
|
2224
|
+
// Silently ignore filesystem errors - caching is optional
|
|
2225
|
+
return;
|
|
2226
|
+
}
|
|
2227
|
+
else {
|
|
2228
|
+
// Re-throw other unexpected errors
|
|
2229
|
+
throw error;
|
|
2230
|
+
}
|
|
2231
|
+
}
|
|
2213
2232
|
}
|
|
2214
2233
|
/**
|
|
2215
2234
|
* Removes the key/value pair with the given key from the storage, if a key/value pair with the given key exists.
|
|
@@ -7716,7 +7735,23 @@
|
|
|
7716
7735
|
// <- TODO: [🥬] Encapsulate sha256 to some private utility function
|
|
7717
7736
|
const rootDirname = path.join(process.cwd(), DEFAULT_DOWNLOAD_CACHE_DIRNAME);
|
|
7718
7737
|
const filepath = path.join(...nameToSubfolderPath(hash /* <- TODO: [🎎] Maybe add some SHA256 prefix */), `${basename.substring(0, MAX_FILENAME_LENGTH)}.${mimeTypeToExtension(mimeType)}`);
|
|
7719
|
-
|
|
7738
|
+
// Note: Try to create cache directory, but don't fail if filesystem has issues
|
|
7739
|
+
try {
|
|
7740
|
+
await tools.fs.mkdir(path.dirname(path.join(rootDirname, filepath)), { recursive: true });
|
|
7741
|
+
}
|
|
7742
|
+
catch (error) {
|
|
7743
|
+
// Note: If we can't create cache directory, we'll handle it when trying to write the file
|
|
7744
|
+
// This handles read-only filesystems, permission issues, and missing parent directories
|
|
7745
|
+
if (error instanceof Error && (error.message.includes('EROFS') ||
|
|
7746
|
+
error.message.includes('read-only') ||
|
|
7747
|
+
error.message.includes('EACCES') ||
|
|
7748
|
+
error.message.includes('EPERM') ||
|
|
7749
|
+
error.message.includes('ENOENT'))) ;
|
|
7750
|
+
else {
|
|
7751
|
+
// Re-throw other unexpected errors
|
|
7752
|
+
throw error;
|
|
7753
|
+
}
|
|
7754
|
+
}
|
|
7720
7755
|
const fileContent = Buffer.from(await response.arrayBuffer());
|
|
7721
7756
|
if (fileContent.length > DEFAULT_MAX_FILE_SIZE /* <- TODO: Allow to pass different value to remote server */) {
|
|
7722
7757
|
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.`);
|
|
@@ -7731,7 +7766,8 @@
|
|
|
7731
7766
|
if (error instanceof Error && (error.message.includes('EROFS') ||
|
|
7732
7767
|
error.message.includes('read-only') ||
|
|
7733
7768
|
error.message.includes('EACCES') ||
|
|
7734
|
-
error.message.includes('EPERM')
|
|
7769
|
+
error.message.includes('EPERM') ||
|
|
7770
|
+
error.message.includes('ENOENT'))) {
|
|
7735
7771
|
// Return a handler that works directly with the downloaded content
|
|
7736
7772
|
return {
|
|
7737
7773
|
source: name,
|
|
@@ -13377,7 +13413,8 @@
|
|
|
13377
13413
|
if (error instanceof Error && (error.message.includes('EROFS') ||
|
|
13378
13414
|
error.message.includes('read-only') ||
|
|
13379
13415
|
error.message.includes('EACCES') ||
|
|
13380
|
-
error.message.includes('EPERM')
|
|
13416
|
+
error.message.includes('EPERM') ||
|
|
13417
|
+
error.message.includes('ENOENT'))) ;
|
|
13381
13418
|
else {
|
|
13382
13419
|
// Re-throw other unexpected errors
|
|
13383
13420
|
throw error;
|
|
@@ -15872,6 +15909,18 @@
|
|
|
15872
15909
|
const OPENAI_MODELS = exportJson({
|
|
15873
15910
|
name: 'OPENAI_MODELS',
|
|
15874
15911
|
value: [
|
|
15912
|
+
/**/
|
|
15913
|
+
{
|
|
15914
|
+
modelVariant: 'CHAT',
|
|
15915
|
+
modelTitle: 'gpt-5',
|
|
15916
|
+
modelName: 'gpt-5',
|
|
15917
|
+
modelDescription: "OpenAI's most advanced language model with unprecedented reasoning capabilities and 200K context window. Features revolutionary improvements in complex problem-solving, scientific reasoning, and creative tasks. Demonstrates human-level performance across diverse domains with enhanced safety measures and alignment. Represents the next generation of AI with superior understanding, nuanced responses, and advanced multimodal capabilities.",
|
|
15918
|
+
pricing: {
|
|
15919
|
+
prompt: pricing(`$10.00 / 1M tokens`),
|
|
15920
|
+
output: pricing(`$30.00 / 1M tokens`),
|
|
15921
|
+
},
|
|
15922
|
+
},
|
|
15923
|
+
/**/
|
|
15875
15924
|
/*/
|
|
15876
15925
|
{
|
|
15877
15926
|
modelTitle: 'dall-e-3',
|
|
@@ -18278,7 +18327,7 @@
|
|
|
18278
18327
|
* Default model for chat variant.
|
|
18279
18328
|
*/
|
|
18280
18329
|
getDefaultChatModel() {
|
|
18281
|
-
return this.getDefaultModel('gpt-
|
|
18330
|
+
return this.getDefaultModel('gpt-5');
|
|
18282
18331
|
}
|
|
18283
18332
|
/**
|
|
18284
18333
|
* Default model for completion variant.
|
|
@@ -18677,7 +18726,23 @@
|
|
|
18677
18726
|
.join('/') +
|
|
18678
18727
|
'.' +
|
|
18679
18728
|
extension;
|
|
18680
|
-
|
|
18729
|
+
// Note: Try to create cache directory, but don't fail if filesystem has issues
|
|
18730
|
+
try {
|
|
18731
|
+
await promises.mkdir(path.dirname(cacheFilename), { recursive: true });
|
|
18732
|
+
}
|
|
18733
|
+
catch (error) {
|
|
18734
|
+
// Note: If we can't create cache directory, continue without it
|
|
18735
|
+
// This handles read-only filesystems, permission issues, and missing parent directories
|
|
18736
|
+
if (error instanceof Error && (error.message.includes('EROFS') ||
|
|
18737
|
+
error.message.includes('read-only') ||
|
|
18738
|
+
error.message.includes('EACCES') ||
|
|
18739
|
+
error.message.includes('EPERM') ||
|
|
18740
|
+
error.message.includes('ENOENT'))) ;
|
|
18741
|
+
else {
|
|
18742
|
+
// Re-throw other unexpected errors
|
|
18743
|
+
throw error;
|
|
18744
|
+
}
|
|
18745
|
+
}
|
|
18681
18746
|
let isDestroyed = true;
|
|
18682
18747
|
const fileHandler = {
|
|
18683
18748
|
filename: cacheFilename,
|
|
@@ -19537,7 +19602,8 @@
|
|
|
19537
19602
|
if (error instanceof Error && (error.message.includes('EROFS') ||
|
|
19538
19603
|
error.message.includes('read-only') ||
|
|
19539
19604
|
error.message.includes('EACCES') ||
|
|
19540
|
-
error.message.includes('EPERM')
|
|
19605
|
+
error.message.includes('EPERM') ||
|
|
19606
|
+
error.message.includes('ENOENT'))) ;
|
|
19541
19607
|
else {
|
|
19542
19608
|
// Re-throw other unexpected errors
|
|
19543
19609
|
throw error;
|
|
@@ -19840,7 +19906,8 @@
|
|
|
19840
19906
|
if (error instanceof Error && (error.message.includes('EROFS') ||
|
|
19841
19907
|
error.message.includes('read-only') ||
|
|
19842
19908
|
error.message.includes('EACCES') ||
|
|
19843
|
-
error.message.includes('EPERM')
|
|
19909
|
+
error.message.includes('EPERM') ||
|
|
19910
|
+
error.message.includes('ENOENT'))) ;
|
|
19844
19911
|
else {
|
|
19845
19912
|
// Re-throw other unexpected errors
|
|
19846
19913
|
throw error;
|