@promptbook/core 0.100.0-35 → 0.100.0-37
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 +120 -26
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +2 -0
- package/esm/typings/src/config.d.ts +6 -0
- package/esm/typings/src/execution/ExecutionTask.d.ts +13 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +120 -25
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -27,7 +27,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
27
27
|
* @generated
|
|
28
28
|
* @see https://github.com/webgptorg/promptbook
|
|
29
29
|
*/
|
|
30
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-
|
|
30
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-37';
|
|
31
31
|
/**
|
|
32
32
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
33
33
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -686,6 +686,12 @@ function SET_IS_VERBOSE(isVerbose) {
|
|
|
686
686
|
* @public exported from `@promptbook/core`
|
|
687
687
|
*/
|
|
688
688
|
const DEFAULT_IS_AUTO_INSTALLED = false;
|
|
689
|
+
/**
|
|
690
|
+
* Default simulated duration for a task in milliseconds (used for progress reporting)
|
|
691
|
+
*
|
|
692
|
+
* @public exported from `@promptbook/core`
|
|
693
|
+
*/
|
|
694
|
+
const DEFAULT_TASK_SIMULATED_DURATION_MS = 5 * 60 * 1000; // 5 minutes
|
|
689
695
|
/**
|
|
690
696
|
* Function name for generated function via `ptbk make` to get the pipeline collection
|
|
691
697
|
*
|
|
@@ -4361,7 +4367,7 @@ function assertsTaskSuccessful(executionResult) {
|
|
|
4361
4367
|
* @private internal helper function
|
|
4362
4368
|
*/
|
|
4363
4369
|
function createTask(options) {
|
|
4364
|
-
const { taskType, taskProcessCallback } = options;
|
|
4370
|
+
const { taskType, taskProcessCallback, tldrProvider } = options;
|
|
4365
4371
|
let { title } = options;
|
|
4366
4372
|
// TODO: [🐙] DRY
|
|
4367
4373
|
const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid similar char conflicts */)}`;
|
|
@@ -4436,21 +4442,35 @@ function createTask(options) {
|
|
|
4436
4442
|
},
|
|
4437
4443
|
get tldr() {
|
|
4438
4444
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
4439
|
-
//
|
|
4445
|
+
// Use custom tldr provider if available
|
|
4446
|
+
if (tldrProvider) {
|
|
4447
|
+
return tldrProvider(createdAt, status, currentValue, errors, warnings);
|
|
4448
|
+
}
|
|
4449
|
+
// Fallback to default implementation
|
|
4440
4450
|
const cv = currentValue;
|
|
4441
|
-
//
|
|
4451
|
+
// If explicit percent is provided, use it
|
|
4442
4452
|
let percentRaw = (_f = (_d = (_b = (_a = cv === null || cv === void 0 ? void 0 : cv.tldr) === null || _a === void 0 ? void 0 : _a.percent) !== null && _b !== void 0 ? _b : (_c = cv === null || cv === void 0 ? void 0 : cv.usage) === null || _c === void 0 ? void 0 : _c.percent) !== null && _d !== void 0 ? _d : (_e = cv === null || cv === void 0 ? void 0 : cv.progress) === null || _e === void 0 ? void 0 : _e.percent) !== null && _f !== void 0 ? _f : cv === null || cv === void 0 ? void 0 : cv.percent;
|
|
4443
|
-
//
|
|
4453
|
+
// Simulate progress if not provided
|
|
4444
4454
|
if (typeof percentRaw !== 'number') {
|
|
4445
|
-
|
|
4455
|
+
// Simulate progress: evenly split across subtasks, based on elapsed time
|
|
4456
|
+
const now = new Date();
|
|
4457
|
+
const elapsedMs = now.getTime() - createdAt.getTime();
|
|
4458
|
+
const totalMs = DEFAULT_TASK_SIMULATED_DURATION_MS;
|
|
4459
|
+
// If subtasks are defined, split progress evenly
|
|
4460
|
+
const subtaskCount = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) ? cv.subtasks.length : 1;
|
|
4461
|
+
const completedSubtasks = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks)
|
|
4462
|
+
? cv.subtasks.filter((s) => s.done || s.completed).length
|
|
4463
|
+
: 0;
|
|
4464
|
+
// Progress from completed subtasks
|
|
4465
|
+
const subtaskProgress = subtaskCount > 0 ? completedSubtasks / subtaskCount : 0;
|
|
4466
|
+
// Progress from elapsed time for current subtask
|
|
4467
|
+
const timeProgress = Math.min(elapsedMs / totalMs, 1);
|
|
4468
|
+
// Combine: completed subtasks + time progress for current subtask
|
|
4469
|
+
percentRaw = Math.min(subtaskProgress + (1 / subtaskCount) * timeProgress, 1);
|
|
4470
|
+
if (status === 'FINISHED')
|
|
4446
4471
|
percentRaw = 1;
|
|
4447
|
-
|
|
4448
|
-
else if (status === 'ERROR') {
|
|
4472
|
+
if (status === 'ERROR')
|
|
4449
4473
|
percentRaw = 0;
|
|
4450
|
-
}
|
|
4451
|
-
else {
|
|
4452
|
-
percentRaw = 0;
|
|
4453
|
-
}
|
|
4454
4474
|
}
|
|
4455
4475
|
// Clamp to [0,1]
|
|
4456
4476
|
let percent = Number(percentRaw) || 0;
|
|
@@ -4462,20 +4482,29 @@ function createTask(options) {
|
|
|
4462
4482
|
const messageFromResult = (_k = (_j = (_h = (_g = cv === null || cv === void 0 ? void 0 : cv.tldr) === null || _g === void 0 ? void 0 : _g.message) !== null && _h !== void 0 ? _h : cv === null || cv === void 0 ? void 0 : cv.message) !== null && _j !== void 0 ? _j : cv === null || cv === void 0 ? void 0 : cv.summary) !== null && _k !== void 0 ? _k : cv === null || cv === void 0 ? void 0 : cv.statusMessage;
|
|
4463
4483
|
let message = messageFromResult;
|
|
4464
4484
|
if (!message) {
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
else if (status === 'FINISHED') {
|
|
4472
|
-
message = 'Finished';
|
|
4473
|
-
}
|
|
4474
|
-
else if (status === 'ERROR') {
|
|
4475
|
-
message = 'Error';
|
|
4485
|
+
// If subtasks, show current subtask
|
|
4486
|
+
if (Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) && cv.subtasks.length > 0) {
|
|
4487
|
+
const current = cv.subtasks.find((s) => !s.done && !s.completed);
|
|
4488
|
+
if (current && current.title) {
|
|
4489
|
+
message = `Working on ${current.title}`;
|
|
4490
|
+
}
|
|
4476
4491
|
}
|
|
4477
|
-
|
|
4478
|
-
|
|
4492
|
+
if (!message) {
|
|
4493
|
+
if (errors.length) {
|
|
4494
|
+
message = errors[errors.length - 1].message || 'Error';
|
|
4495
|
+
}
|
|
4496
|
+
else if (warnings.length) {
|
|
4497
|
+
message = warnings[warnings.length - 1].message || 'Warning';
|
|
4498
|
+
}
|
|
4499
|
+
else if (status === 'FINISHED') {
|
|
4500
|
+
message = 'Finished';
|
|
4501
|
+
}
|
|
4502
|
+
else if (status === 'ERROR') {
|
|
4503
|
+
message = 'Error';
|
|
4504
|
+
}
|
|
4505
|
+
else {
|
|
4506
|
+
message = 'Running';
|
|
4507
|
+
}
|
|
4479
4508
|
}
|
|
4480
4509
|
}
|
|
4481
4510
|
return {
|
|
@@ -7287,6 +7316,71 @@ function createPipelineExecutor(options) {
|
|
|
7287
7316
|
updateOngoingResult(newOngoingResult);
|
|
7288
7317
|
});
|
|
7289
7318
|
},
|
|
7319
|
+
tldrProvider(createdAt, status, currentValue, errors) {
|
|
7320
|
+
var _a;
|
|
7321
|
+
// Better progress estimation based on pipeline structure
|
|
7322
|
+
const cv = currentValue;
|
|
7323
|
+
// Handle finished/error states
|
|
7324
|
+
if (status === 'FINISHED') {
|
|
7325
|
+
return {
|
|
7326
|
+
percent: 1,
|
|
7327
|
+
message: 'Finished',
|
|
7328
|
+
};
|
|
7329
|
+
}
|
|
7330
|
+
if (status === 'ERROR') {
|
|
7331
|
+
const errorMessage = errors.length > 0 ? errors[errors.length - 1].message : 'Error';
|
|
7332
|
+
return {
|
|
7333
|
+
percent: 0,
|
|
7334
|
+
message: errorMessage,
|
|
7335
|
+
};
|
|
7336
|
+
}
|
|
7337
|
+
// Calculate progress based on pipeline tasks
|
|
7338
|
+
const totalTasks = pipeline.tasks.length;
|
|
7339
|
+
let completedTasks = 0;
|
|
7340
|
+
let currentTaskName = '';
|
|
7341
|
+
// Check execution report for completed tasks
|
|
7342
|
+
if ((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) {
|
|
7343
|
+
const executedTaskTitles = new Set(cv.executionReport.promptExecutions.map((execution) => execution.prompt.title));
|
|
7344
|
+
// Count completed tasks by matching titles
|
|
7345
|
+
const completedTasksByTitle = pipeline.tasks.filter(task => executedTaskTitles.has(task.title));
|
|
7346
|
+
completedTasks = completedTasksByTitle.length;
|
|
7347
|
+
// Find current task being executed (first task not yet completed)
|
|
7348
|
+
const remainingTasks = pipeline.tasks.filter(task => !executedTaskTitles.has(task.title));
|
|
7349
|
+
if (remainingTasks.length > 0) {
|
|
7350
|
+
currentTaskName = remainingTasks[0].name;
|
|
7351
|
+
}
|
|
7352
|
+
}
|
|
7353
|
+
// Calculate progress percentage
|
|
7354
|
+
let percent = totalTasks > 0 ? completedTasks / totalTasks : 0;
|
|
7355
|
+
// Add time-based progress for current task (assuming 5 minutes total)
|
|
7356
|
+
if (completedTasks < totalTasks) {
|
|
7357
|
+
const elapsedMs = new Date().getTime() - createdAt.getTime();
|
|
7358
|
+
const totalMs = 5 * 60 * 1000; // 5 minutes
|
|
7359
|
+
const timeProgress = Math.min(elapsedMs / totalMs, 1);
|
|
7360
|
+
// Add partial progress for current task
|
|
7361
|
+
percent += (1 / totalTasks) * timeProgress;
|
|
7362
|
+
}
|
|
7363
|
+
// Clamp to [0,1]
|
|
7364
|
+
percent = Math.min(Math.max(percent, 0), 1);
|
|
7365
|
+
// Generate message
|
|
7366
|
+
let message = '';
|
|
7367
|
+
if (currentTaskName) {
|
|
7368
|
+
// Find the task to get its title
|
|
7369
|
+
const currentTask = pipeline.tasks.find(task => task.name === currentTaskName);
|
|
7370
|
+
const taskTitle = (currentTask === null || currentTask === void 0 ? void 0 : currentTask.title) || currentTaskName;
|
|
7371
|
+
message = `Working on task ${taskTitle}`;
|
|
7372
|
+
}
|
|
7373
|
+
else if (completedTasks === 0) {
|
|
7374
|
+
message = 'Starting pipeline execution';
|
|
7375
|
+
}
|
|
7376
|
+
else {
|
|
7377
|
+
message = `Processing pipeline (${completedTasks}/${totalTasks} tasks completed)`;
|
|
7378
|
+
}
|
|
7379
|
+
return {
|
|
7380
|
+
percent,
|
|
7381
|
+
message,
|
|
7382
|
+
};
|
|
7383
|
+
},
|
|
7290
7384
|
});
|
|
7291
7385
|
// <- TODO: Make types such as there is no need to do `as` for `createTask`
|
|
7292
7386
|
return pipelineExecutor;
|
|
@@ -14019,5 +14113,5 @@ class PrefixStorage {
|
|
|
14019
14113
|
}
|
|
14020
14114
|
}
|
|
14021
14115
|
|
|
14022
|
-
export { $llmToolsMetadataRegister, $llmToolsRegister, $scrapersMetadataRegister, $scrapersRegister, ADMIN_EMAIL, ADMIN_GITHUB_NAME, AbstractFormatError, AuthenticationError, BIG_DATASET_TRESHOLD, BOOK_LANGUAGE_VERSION, BlackholeStorage, BoilerplateError, BoilerplateFormfactorDefinition, CLAIM, CLI_APP_ID, CallbackInterfaceTools, ChatbotFormfactorDefinition, CollectionError, CompletionFormfactorDefinition, CsvFormatError, CsvFormatParser, DEFAULT_BOOK, DEFAULT_BOOKS_DIRNAME, DEFAULT_BOOK_OUTPUT_PARAMETER_NAME, DEFAULT_BOOK_TITLE, DEFAULT_CSV_SETTINGS, DEFAULT_DOWNLOAD_CACHE_DIRNAME, DEFAULT_EXECUTION_CACHE_DIRNAME, DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME, DEFAULT_INTERMEDIATE_FILES_STRATEGY, DEFAULT_IS_AUTO_INSTALLED, DEFAULT_IS_VERBOSE, DEFAULT_MAX_EXECUTION_ATTEMPTS, DEFAULT_MAX_FILE_SIZE, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, DEFAULT_MAX_PARALLEL_COUNT, DEFAULT_MAX_REQUESTS_PER_MINUTE, DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME, DEFAULT_PROMPT_TASK_TITLE, DEFAULT_REMOTE_SERVER_URL, DEFAULT_SCRAPE_CACHE_DIRNAME, DEFAULT_TASK_TITLE, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, FAILED_VALUE_PLACEHOLDER, FORMFACTOR_DEFINITIONS, GENERIC_PIPELINE_INTERFACE, GeneratorFormfactorDefinition, GenericFormfactorDefinition, ImageGeneratorFormfactorDefinition, KnowledgeScrapeError, LimitReachedError, MANDATORY_CSV_SETTINGS, MAX_FILENAME_LENGTH, MODEL_ORDERS, MODEL_TRUST_LEVELS, MODEL_VARIANTS, MatcherFormfactorDefinition, MemoryStorage, MissingToolsError, MultipleLlmExecutionTools, NAME, NonTaskSectionTypes, NotFoundError, NotYetImplementedCommitmentDefinition, NotYetImplementedError, ORDER_OF_PIPELINE_JSON, PENDING_VALUE_PLACEHOLDER, PLAYGROUND_APP_ID, PROMPTBOOK_ENGINE_VERSION, PROMPTBOOK_ERRORS, ParseError, PipelineExecutionError, PipelineLogicError, PipelineUrlError, PrefixStorage, PromptbookFetchError, REMOTE_SERVER_URLS, RESERVED_PARAMETER_NAMES, SET_IS_VERBOSE, SectionTypes, SheetsFormfactorDefinition, TaskTypes, TextFormatParser, TranslatorFormfactorDefinition, UNCERTAIN_USAGE, UNCERTAIN_ZERO_VALUE, UnexpectedError, WrappedError, ZERO_USAGE, ZERO_VALUE, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _BoilerplateScraperMetadataRegistration, _DeepseekMetadataRegistration, _DocumentScraperMetadataRegistration, _GoogleMetadataRegistration, _LegacyDocumentScraperMetadataRegistration, _MarkdownScraperMetadataRegistration, _MarkitdownScraperMetadataRegistration, _OllamaMetadataRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiCompatibleMetadataRegistration, _OpenAiMetadataRegistration, _PdfScraperMetadataRegistration, _WebsiteScraperMetadataRegistration, addUsage, book, cacheLlmTools, collectionToJson, compilePipeline, computeCosineSimilarity, countUsage, createAgentModelRequirements, createBasicAgentModelRequirements, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createEmptyAgentModelRequirements, createLlmToolsFromConfiguration, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, extractParameterNamesFromTask, filterModels, getAllCommitmentDefinitions, getAllCommitmentTypes, getCommitmentDefinition, getPipelineInterface, identificationToPromptbookToken, isCommitmentSupported, isPassingExpectations, isPipelineImplementingInterface, isPipelineInterfacesEqual, isPipelinePrepared, isValidBook, isValidPipelineString, joinLlmExecutionTools, limitTotalUsage, makeKnowledgeSourceHandler, migratePipeline, parseAgentSource, parsePipeline, pipelineJsonToString, prepareKnowledgePieces, preparePersona, preparePipeline, prettifyPipelineString, promptbookFetch, promptbookTokenToIdentification, unpreparePipeline, usageToHuman, usageToWorktime, validateBook, validatePipeline, validatePipelineString };
|
|
14116
|
+
export { $llmToolsMetadataRegister, $llmToolsRegister, $scrapersMetadataRegister, $scrapersRegister, ADMIN_EMAIL, ADMIN_GITHUB_NAME, AbstractFormatError, AuthenticationError, BIG_DATASET_TRESHOLD, BOOK_LANGUAGE_VERSION, BlackholeStorage, BoilerplateError, BoilerplateFormfactorDefinition, CLAIM, CLI_APP_ID, CallbackInterfaceTools, ChatbotFormfactorDefinition, CollectionError, CompletionFormfactorDefinition, CsvFormatError, CsvFormatParser, DEFAULT_BOOK, DEFAULT_BOOKS_DIRNAME, DEFAULT_BOOK_OUTPUT_PARAMETER_NAME, DEFAULT_BOOK_TITLE, DEFAULT_CSV_SETTINGS, DEFAULT_DOWNLOAD_CACHE_DIRNAME, DEFAULT_EXECUTION_CACHE_DIRNAME, DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME, DEFAULT_INTERMEDIATE_FILES_STRATEGY, DEFAULT_IS_AUTO_INSTALLED, DEFAULT_IS_VERBOSE, DEFAULT_MAX_EXECUTION_ATTEMPTS, DEFAULT_MAX_FILE_SIZE, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, DEFAULT_MAX_PARALLEL_COUNT, DEFAULT_MAX_REQUESTS_PER_MINUTE, DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME, DEFAULT_PROMPT_TASK_TITLE, DEFAULT_REMOTE_SERVER_URL, DEFAULT_SCRAPE_CACHE_DIRNAME, DEFAULT_TASK_SIMULATED_DURATION_MS, DEFAULT_TASK_TITLE, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, FAILED_VALUE_PLACEHOLDER, FORMFACTOR_DEFINITIONS, GENERIC_PIPELINE_INTERFACE, GeneratorFormfactorDefinition, GenericFormfactorDefinition, ImageGeneratorFormfactorDefinition, KnowledgeScrapeError, LimitReachedError, MANDATORY_CSV_SETTINGS, MAX_FILENAME_LENGTH, MODEL_ORDERS, MODEL_TRUST_LEVELS, MODEL_VARIANTS, MatcherFormfactorDefinition, MemoryStorage, MissingToolsError, MultipleLlmExecutionTools, NAME, NonTaskSectionTypes, NotFoundError, NotYetImplementedCommitmentDefinition, NotYetImplementedError, ORDER_OF_PIPELINE_JSON, PENDING_VALUE_PLACEHOLDER, PLAYGROUND_APP_ID, PROMPTBOOK_ENGINE_VERSION, PROMPTBOOK_ERRORS, ParseError, PipelineExecutionError, PipelineLogicError, PipelineUrlError, PrefixStorage, PromptbookFetchError, REMOTE_SERVER_URLS, RESERVED_PARAMETER_NAMES, SET_IS_VERBOSE, SectionTypes, SheetsFormfactorDefinition, TaskTypes, TextFormatParser, TranslatorFormfactorDefinition, UNCERTAIN_USAGE, UNCERTAIN_ZERO_VALUE, UnexpectedError, WrappedError, ZERO_USAGE, ZERO_VALUE, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _BoilerplateScraperMetadataRegistration, _DeepseekMetadataRegistration, _DocumentScraperMetadataRegistration, _GoogleMetadataRegistration, _LegacyDocumentScraperMetadataRegistration, _MarkdownScraperMetadataRegistration, _MarkitdownScraperMetadataRegistration, _OllamaMetadataRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiCompatibleMetadataRegistration, _OpenAiMetadataRegistration, _PdfScraperMetadataRegistration, _WebsiteScraperMetadataRegistration, addUsage, book, cacheLlmTools, collectionToJson, compilePipeline, computeCosineSimilarity, countUsage, createAgentModelRequirements, createBasicAgentModelRequirements, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createEmptyAgentModelRequirements, createLlmToolsFromConfiguration, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, extractParameterNamesFromTask, filterModels, getAllCommitmentDefinitions, getAllCommitmentTypes, getCommitmentDefinition, getPipelineInterface, identificationToPromptbookToken, isCommitmentSupported, isPassingExpectations, isPipelineImplementingInterface, isPipelineInterfacesEqual, isPipelinePrepared, isValidBook, isValidPipelineString, joinLlmExecutionTools, limitTotalUsage, makeKnowledgeSourceHandler, migratePipeline, parseAgentSource, parsePipeline, pipelineJsonToString, prepareKnowledgePieces, preparePersona, preparePipeline, prettifyPipelineString, promptbookFetch, promptbookTokenToIdentification, unpreparePipeline, usageToHuman, usageToWorktime, validateBook, validatePipeline, validatePipelineString };
|
|
14023
14117
|
//# sourceMappingURL=index.es.js.map
|