@promptbook/remote-server 0.100.0-4 → 0.100.0-41
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 +153 -4
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/components.index.d.ts +14 -0
- package/esm/typings/src/_packages/core.index.d.ts +26 -0
- package/esm/typings/src/_packages/types.index.d.ts +34 -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 +38 -0
- package/esm/typings/src/book-2.0/commitments/FORMAT/FORMAT.d.ts +39 -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 +51 -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 +44 -0
- package/esm/typings/src/book-2.0/commitments/META_LINK/META_LINK.d.ts +56 -0
- package/esm/typings/src/book-2.0/commitments/MODEL/MODEL.d.ts +39 -0
- package/esm/typings/src/book-2.0/commitments/NOTE/NOTE.d.ts +49 -0
- package/esm/typings/src/book-2.0/commitments/PERSONA/PERSONA.d.ts +46 -0
- package/esm/typings/src/book-2.0/commitments/RULE/RULE.d.ts +44 -0
- package/esm/typings/src/book-2.0/commitments/SAMPLE/SAMPLE.d.ts +44 -0
- package/esm/typings/src/book-2.0/commitments/STYLE/STYLE.d.ts +38 -0
- package/esm/typings/src/book-2.0/commitments/_base/BaseCommitmentDefinition.d.ts +52 -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 +48 -0
- package/esm/typings/src/book-2.0/commitments/_base/NotYetImplementedCommitmentDefinition.d.ts +22 -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/book-components/AvatarProfile/AvatarChip/AvatarChip.d.ts +35 -0
- package/esm/typings/src/book-components/AvatarProfile/AvatarChip/AvatarChipFromSource.d.ts +21 -0
- package/esm/typings/src/book-components/AvatarProfile/AvatarChip/index.d.ts +2 -0
- package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +35 -0
- package/esm/typings/src/book-components/BookEditor/config.d.ts +10 -0
- package/esm/typings/src/book-components/BookEditor/injectCssModuleIntoShadowRoot.d.ts +11 -0
- package/esm/typings/src/book-components/_common/react-utils/classNames.d.ts +7 -0
- package/esm/typings/src/book-components/_common/react-utils/collectCssTextsForClass.d.ts +7 -0
- package/esm/typings/src/book-components/_common/react-utils/escapeHtml.d.ts +6 -0
- package/esm/typings/src/book-components/_common/react-utils/escapeRegex.d.ts +6 -0
- package/esm/typings/src/config.d.ts +6 -0
- package/esm/typings/src/execution/AvailableModel.d.ts +4 -0
- package/esm/typings/src/execution/ExecutionTask.d.ts +27 -0
- package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +6 -1
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +0 -5
- package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/deepseek/deepseek-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/google/google-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/ollama/ollama-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
- package/esm/typings/src/pipeline/book-notation.d.ts +2 -1
- package/esm/typings/src/types/ModelRequirements.d.ts +0 -2
- package/esm/typings/src/types/typeAliases.d.ts +6 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +153 -4
- package/umd/index.umd.js.map +1 -1
package/README.md
CHANGED
|
@@ -18,6 +18,7 @@ Write AI applications using plain human language across multiple models and plat
|
|
|
18
18
|
|
|
19
19
|
## 🌟 New Features
|
|
20
20
|
|
|
21
|
+
- 🚀 **GPT-5 Support** - Now includes OpenAI's most advanced language model with unprecedented reasoning capabilities and 200K context window
|
|
21
22
|
- 💡 VS Code support for `.book` files with syntax highlighting and IntelliSense
|
|
22
23
|
- 🐳 Official Docker image (`hejny/promptbook`) for seamless containerized usage
|
|
23
24
|
- 🔥 Native support for OpenAI `o3-mini`, GPT-4 and other leading LLMs
|
package/esm/index.es.js
CHANGED
|
@@ -33,7 +33,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
33
33
|
* @generated
|
|
34
34
|
* @see https://github.com/webgptorg/promptbook
|
|
35
35
|
*/
|
|
36
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-
|
|
36
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-41';
|
|
37
37
|
/**
|
|
38
38
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
39
39
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -216,6 +216,12 @@ let DEFAULT_IS_VERBOSE = false;
|
|
|
216
216
|
* @public exported from `@promptbook/core`
|
|
217
217
|
*/
|
|
218
218
|
const DEFAULT_IS_AUTO_INSTALLED = false;
|
|
219
|
+
/**
|
|
220
|
+
* Default simulated duration for a task in milliseconds (used for progress reporting)
|
|
221
|
+
*
|
|
222
|
+
* @public exported from `@promptbook/core`
|
|
223
|
+
*/
|
|
224
|
+
const DEFAULT_TASK_SIMULATED_DURATION_MS = 5 * 60 * 1000; // 5 minutes
|
|
219
225
|
/**
|
|
220
226
|
* Indicates whether pipeline logic validation is enabled. When true, the pipeline logic is checked for consistency.
|
|
221
227
|
*
|
|
@@ -2000,7 +2006,7 @@ function assertsTaskSuccessful(executionResult) {
|
|
|
2000
2006
|
* @private internal helper function
|
|
2001
2007
|
*/
|
|
2002
2008
|
function createTask(options) {
|
|
2003
|
-
const { taskType, taskProcessCallback } = options;
|
|
2009
|
+
const { taskType, taskProcessCallback, tldrProvider } = options;
|
|
2004
2010
|
let { title } = options;
|
|
2005
2011
|
// TODO: [🐙] DRY
|
|
2006
2012
|
const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid similar char conflicts */)}`;
|
|
@@ -2073,6 +2079,78 @@ function createTask(options) {
|
|
|
2073
2079
|
return status;
|
|
2074
2080
|
// <- Note: [1] --||--
|
|
2075
2081
|
},
|
|
2082
|
+
get tldr() {
|
|
2083
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2084
|
+
// Use custom tldr provider if available
|
|
2085
|
+
if (tldrProvider) {
|
|
2086
|
+
return tldrProvider(createdAt, status, currentValue, errors, warnings);
|
|
2087
|
+
}
|
|
2088
|
+
// Fallback to default implementation
|
|
2089
|
+
const cv = currentValue;
|
|
2090
|
+
// If explicit percent is provided, use it
|
|
2091
|
+
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;
|
|
2092
|
+
// Simulate progress if not provided
|
|
2093
|
+
if (typeof percentRaw !== 'number') {
|
|
2094
|
+
// Simulate progress: evenly split across subtasks, based on elapsed time
|
|
2095
|
+
const now = new Date();
|
|
2096
|
+
const elapsedMs = now.getTime() - createdAt.getTime();
|
|
2097
|
+
const totalMs = DEFAULT_TASK_SIMULATED_DURATION_MS;
|
|
2098
|
+
// If subtasks are defined, split progress evenly
|
|
2099
|
+
const subtaskCount = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) ? cv.subtasks.length : 1;
|
|
2100
|
+
const completedSubtasks = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks)
|
|
2101
|
+
? cv.subtasks.filter((s) => s.done || s.completed).length
|
|
2102
|
+
: 0;
|
|
2103
|
+
// Progress from completed subtasks
|
|
2104
|
+
const subtaskProgress = subtaskCount > 0 ? completedSubtasks / subtaskCount : 0;
|
|
2105
|
+
// Progress from elapsed time for current subtask
|
|
2106
|
+
const timeProgress = Math.min(elapsedMs / totalMs, 1);
|
|
2107
|
+
// Combine: completed subtasks + time progress for current subtask
|
|
2108
|
+
percentRaw = Math.min(subtaskProgress + (1 / subtaskCount) * timeProgress, 1);
|
|
2109
|
+
if (status === 'FINISHED')
|
|
2110
|
+
percentRaw = 1;
|
|
2111
|
+
if (status === 'ERROR')
|
|
2112
|
+
percentRaw = 0;
|
|
2113
|
+
}
|
|
2114
|
+
// Clamp to [0,1]
|
|
2115
|
+
let percent = Number(percentRaw) || 0;
|
|
2116
|
+
if (percent < 0)
|
|
2117
|
+
percent = 0;
|
|
2118
|
+
if (percent > 1)
|
|
2119
|
+
percent = 1;
|
|
2120
|
+
// Build a short message: prefer explicit tldr.message, then common summary/message fields, then errors/warnings, then status
|
|
2121
|
+
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;
|
|
2122
|
+
let message = messageFromResult;
|
|
2123
|
+
if (!message) {
|
|
2124
|
+
// If subtasks, show current subtask
|
|
2125
|
+
if (Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) && cv.subtasks.length > 0) {
|
|
2126
|
+
const current = cv.subtasks.find((s) => !s.done && !s.completed);
|
|
2127
|
+
if (current && current.title) {
|
|
2128
|
+
message = `Working on ${current.title}`;
|
|
2129
|
+
}
|
|
2130
|
+
}
|
|
2131
|
+
if (!message) {
|
|
2132
|
+
if (errors.length) {
|
|
2133
|
+
message = errors[errors.length - 1].message || 'Error';
|
|
2134
|
+
}
|
|
2135
|
+
else if (warnings.length) {
|
|
2136
|
+
message = warnings[warnings.length - 1].message || 'Warning';
|
|
2137
|
+
}
|
|
2138
|
+
else if (status === 'FINISHED') {
|
|
2139
|
+
message = 'Finished';
|
|
2140
|
+
}
|
|
2141
|
+
else if (status === 'ERROR') {
|
|
2142
|
+
message = 'Error';
|
|
2143
|
+
}
|
|
2144
|
+
else {
|
|
2145
|
+
message = 'Running';
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
}
|
|
2149
|
+
return {
|
|
2150
|
+
percent: percent,
|
|
2151
|
+
message,
|
|
2152
|
+
};
|
|
2153
|
+
},
|
|
2076
2154
|
get createdAt() {
|
|
2077
2155
|
return createdAt;
|
|
2078
2156
|
// <- Note: [1] --||--
|
|
@@ -5282,7 +5360,7 @@ function validatePromptResult(options) {
|
|
|
5282
5360
|
*/
|
|
5283
5361
|
async function executeAttempts(options) {
|
|
5284
5362
|
const { jokerParameterNames, priority, maxAttempts, // <- Note: [💂]
|
|
5285
|
-
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, } = options;
|
|
5363
|
+
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, } = options;
|
|
5286
5364
|
const $ongoingTaskResult = {
|
|
5287
5365
|
$result: null,
|
|
5288
5366
|
$resultString: null,
|
|
@@ -5526,6 +5604,10 @@ async function executeAttempts(options) {
|
|
|
5526
5604
|
result: $ongoingTaskResult.$resultString,
|
|
5527
5605
|
error: error,
|
|
5528
5606
|
});
|
|
5607
|
+
// Report failed attempt
|
|
5608
|
+
onProgress({
|
|
5609
|
+
errors: [error],
|
|
5610
|
+
});
|
|
5529
5611
|
}
|
|
5530
5612
|
finally {
|
|
5531
5613
|
if (!isJokerAttempt &&
|
|
@@ -6407,6 +6489,71 @@ function createPipelineExecutor(options) {
|
|
|
6407
6489
|
updateOngoingResult(newOngoingResult);
|
|
6408
6490
|
});
|
|
6409
6491
|
},
|
|
6492
|
+
tldrProvider(createdAt, status, currentValue, errors) {
|
|
6493
|
+
var _a;
|
|
6494
|
+
// Better progress estimation based on pipeline structure
|
|
6495
|
+
const cv = currentValue;
|
|
6496
|
+
// Handle finished/error states
|
|
6497
|
+
if (status === 'FINISHED') {
|
|
6498
|
+
return {
|
|
6499
|
+
percent: 1,
|
|
6500
|
+
message: 'Finished',
|
|
6501
|
+
};
|
|
6502
|
+
}
|
|
6503
|
+
if (status === 'ERROR') {
|
|
6504
|
+
const errorMessage = errors.length > 0 ? errors[errors.length - 1].message : 'Error';
|
|
6505
|
+
return {
|
|
6506
|
+
percent: 0,
|
|
6507
|
+
message: errorMessage,
|
|
6508
|
+
};
|
|
6509
|
+
}
|
|
6510
|
+
// Calculate progress based on pipeline tasks
|
|
6511
|
+
const totalTasks = pipeline.tasks.length;
|
|
6512
|
+
let completedTasks = 0;
|
|
6513
|
+
let currentTaskName = '';
|
|
6514
|
+
// Check execution report for completed tasks
|
|
6515
|
+
if ((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) {
|
|
6516
|
+
const executedTaskTitles = new Set(cv.executionReport.promptExecutions.map((execution) => execution.prompt.title));
|
|
6517
|
+
// Count completed tasks by matching titles
|
|
6518
|
+
const completedTasksByTitle = pipeline.tasks.filter(task => executedTaskTitles.has(task.title));
|
|
6519
|
+
completedTasks = completedTasksByTitle.length;
|
|
6520
|
+
// Find current task being executed (first task not yet completed)
|
|
6521
|
+
const remainingTasks = pipeline.tasks.filter(task => !executedTaskTitles.has(task.title));
|
|
6522
|
+
if (remainingTasks.length > 0) {
|
|
6523
|
+
currentTaskName = remainingTasks[0].name;
|
|
6524
|
+
}
|
|
6525
|
+
}
|
|
6526
|
+
// Calculate progress percentage
|
|
6527
|
+
let percent = totalTasks > 0 ? completedTasks / totalTasks : 0;
|
|
6528
|
+
// Add time-based progress for current task (assuming 5 minutes total)
|
|
6529
|
+
if (completedTasks < totalTasks) {
|
|
6530
|
+
const elapsedMs = new Date().getTime() - createdAt.getTime();
|
|
6531
|
+
const totalMs = 5 * 60 * 1000; // 5 minutes
|
|
6532
|
+
const timeProgress = Math.min(elapsedMs / totalMs, 1);
|
|
6533
|
+
// Add partial progress for current task
|
|
6534
|
+
percent += (1 / totalTasks) * timeProgress;
|
|
6535
|
+
}
|
|
6536
|
+
// Clamp to [0,1]
|
|
6537
|
+
percent = Math.min(Math.max(percent, 0), 1);
|
|
6538
|
+
// Generate message
|
|
6539
|
+
let message = '';
|
|
6540
|
+
if (currentTaskName) {
|
|
6541
|
+
// Find the task to get its title
|
|
6542
|
+
const currentTask = pipeline.tasks.find(task => task.name === currentTaskName);
|
|
6543
|
+
const taskTitle = (currentTask === null || currentTask === void 0 ? void 0 : currentTask.title) || currentTaskName;
|
|
6544
|
+
message = `Working on task ${taskTitle}`;
|
|
6545
|
+
}
|
|
6546
|
+
else if (completedTasks === 0) {
|
|
6547
|
+
message = 'Starting pipeline execution';
|
|
6548
|
+
}
|
|
6549
|
+
else {
|
|
6550
|
+
message = `Processing pipeline (${completedTasks}/${totalTasks} tasks completed)`;
|
|
6551
|
+
}
|
|
6552
|
+
return {
|
|
6553
|
+
percent,
|
|
6554
|
+
message,
|
|
6555
|
+
};
|
|
6556
|
+
},
|
|
6410
6557
|
});
|
|
6411
6558
|
// <- TODO: Make types such as there is no need to do `as` for `createTask`
|
|
6412
6559
|
return pipelineExecutor;
|
|
@@ -8144,7 +8291,7 @@ function startRemoteServer(options) {
|
|
|
8144
8291
|
});
|
|
8145
8292
|
function exportExecutionTask(executionTask, isFull) {
|
|
8146
8293
|
// <- TODO: [🧠] This should be maybe method of `ExecutionTask` itself
|
|
8147
|
-
const { taskType, promptbookVersion, taskId, title, status, errors, warnings, createdAt, updatedAt, currentValue, } = executionTask;
|
|
8294
|
+
const { taskType, promptbookVersion, taskId, title, status, errors, tldr, warnings, createdAt, updatedAt, currentValue, } = executionTask;
|
|
8148
8295
|
if (isFull) {
|
|
8149
8296
|
return {
|
|
8150
8297
|
taskId,
|
|
@@ -8152,6 +8299,7 @@ function startRemoteServer(options) {
|
|
|
8152
8299
|
taskType,
|
|
8153
8300
|
promptbookVersion,
|
|
8154
8301
|
status,
|
|
8302
|
+
tldr,
|
|
8155
8303
|
errors: errors.map(serializeError),
|
|
8156
8304
|
warnings: warnings.map(serializeError),
|
|
8157
8305
|
createdAt,
|
|
@@ -8166,6 +8314,7 @@ function startRemoteServer(options) {
|
|
|
8166
8314
|
taskType,
|
|
8167
8315
|
promptbookVersion,
|
|
8168
8316
|
status,
|
|
8317
|
+
tldr,
|
|
8169
8318
|
createdAt,
|
|
8170
8319
|
updatedAt,
|
|
8171
8320
|
};
|