@promptbook/browser 0.114.0-10 → 0.114.0-12
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 +133 -60
- package/esm/index.es.js.map +1 -1
- package/esm/src/book-2.0/agent-source/AgentSourceParseResult.d.ts +5 -0
- package/esm/src/book-2.0/agent-source/ParsedUnknownCommitment.d.ts +26 -0
- package/esm/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments.unknown.test.d.ts +1 -0
- package/esm/src/book-2.0/agent-source/getBookCommitmentLineType.d.ts +19 -0
- package/esm/src/book-2.0/agent-source/parseAgentSourceWithCommitments.unknown.test.d.ts +1 -0
- package/esm/src/book-components/BookEditor/createUnknownCommitmentDiagnostics.d.ts +28 -0
- package/esm/src/book-components/BookEditor/createUnknownCommitmentDiagnostics.test.d.ts +1 -0
- package/esm/src/cli/cli-commands/common/harness/$checkHarnessInstallation.d.ts +3 -3
- package/esm/src/cli/cli-commands/common/harness/$checkHarnessInstallation.test.d.ts +1 -0
- package/esm/src/cli/cli-commands/common/harness/$ensureHarnessInstallations.d.ts +3 -3
- package/esm/src/cli/cli-commands/common/harness/HarnessInstallationStatus.d.ts +3 -2
- package/esm/src/cli/cli-commands/common/harnessUpdateCliOptions.d.ts +29 -0
- package/esm/src/cli/cli-commands/common/harnessUpdateCliOptions.test.d.ts +1 -0
- package/esm/src/executables/platforms/locateAppOnWindows.d.ts +1 -1
- package/esm/src/executables/platforms/locateAppOnWindows.test.d.ts +1 -0
- package/esm/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +133 -60
- package/umd/index.umd.js.map +1 -1
- package/umd/src/book-2.0/agent-source/AgentSourceParseResult.d.ts +5 -0
- package/umd/src/book-2.0/agent-source/ParsedUnknownCommitment.d.ts +26 -0
- package/umd/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments.unknown.test.d.ts +1 -0
- package/umd/src/book-2.0/agent-source/getBookCommitmentLineType.d.ts +19 -0
- package/umd/src/book-2.0/agent-source/parseAgentSourceWithCommitments.unknown.test.d.ts +1 -0
- package/umd/src/book-components/BookEditor/createUnknownCommitmentDiagnostics.d.ts +28 -0
- package/umd/src/book-components/BookEditor/createUnknownCommitmentDiagnostics.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/common/harness/$checkHarnessInstallation.d.ts +3 -3
- package/umd/src/cli/cli-commands/common/harness/$checkHarnessInstallation.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/common/harness/$ensureHarnessInstallations.d.ts +3 -3
- package/umd/src/cli/cli-commands/common/harness/HarnessInstallationStatus.d.ts +3 -2
- package/umd/src/cli/cli-commands/common/harnessUpdateCliOptions.d.ts +29 -0
- package/umd/src/cli/cli-commands/common/harnessUpdateCliOptions.test.d.ts +1 -0
- package/umd/src/executables/platforms/locateAppOnWindows.d.ts +1 -1
- package/umd/src/executables/platforms/locateAppOnWindows.test.d.ts +1 -0
- package/umd/src/version.d.ts +1 -1
package/esm/index.es.js
CHANGED
|
@@ -26,7 +26,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
26
26
|
* @generated
|
|
27
27
|
* @see https://github.com/webgptorg/promptbook
|
|
28
28
|
*/
|
|
29
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.114.0-
|
|
29
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.114.0-12';
|
|
30
30
|
/**
|
|
31
31
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
32
32
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -18560,6 +18560,30 @@ function createDefaultAgentName(agentSource) {
|
|
|
18560
18560
|
return normalizeAgentName(`Agent ${agentHash.substring(0, LIMITS.SHORT_NAME_LENGTH)}`);
|
|
18561
18561
|
}
|
|
18562
18562
|
|
|
18563
|
+
/**
|
|
18564
|
+
* Pattern shared by Book parsing and editor highlighting for a commitment-like line.
|
|
18565
|
+
*
|
|
18566
|
+
* A Book commitment keyword consists of one or more all-uppercase words with at least
|
|
18567
|
+
* two characters each. This deliberately mirrors the Book editor syntax rule so an
|
|
18568
|
+
* unknown keyword starts a new source block everywhere it is interpreted.
|
|
18569
|
+
*
|
|
18570
|
+
* @private internal constant of `getBookCommitmentLineType`
|
|
18571
|
+
*/
|
|
18572
|
+
const BOOK_COMMITMENT_LINE_TYPE_REGEX = /^\s*(?<type>[A-Z][A-Z0-9]+(?:\s+[A-Z][A-Z0-9]+)*)(?=\s|$)/;
|
|
18573
|
+
/**
|
|
18574
|
+
* Extracts the uppercase commitment type from a Book line, including types not registered by Promptbook.
|
|
18575
|
+
*
|
|
18576
|
+
* @param line - One raw Book source line.
|
|
18577
|
+
* @returns Matched commitment type or `null` when the line does not begin with commitment syntax.
|
|
18578
|
+
*
|
|
18579
|
+
* @private internal utility of Book parsing and `<BookEditor/>`
|
|
18580
|
+
*/
|
|
18581
|
+
function getBookCommitmentLineType(line) {
|
|
18582
|
+
var _a;
|
|
18583
|
+
const match = BOOK_COMMITMENT_LINE_TYPE_REGEX.exec(line);
|
|
18584
|
+
return ((_a = match === null || match === void 0 ? void 0 : match.groups) === null || _a === void 0 ? void 0 : _a.type) || null;
|
|
18585
|
+
}
|
|
18586
|
+
|
|
18563
18587
|
/**
|
|
18564
18588
|
* Consumes the agent-name prelude from raw source.
|
|
18565
18589
|
*
|
|
@@ -18617,13 +18641,15 @@ function parseAgentSourceWithCommitments(agentSource) {
|
|
|
18617
18641
|
return {
|
|
18618
18642
|
agentName: null,
|
|
18619
18643
|
commitments: [],
|
|
18644
|
+
unknownCommitments: [],
|
|
18620
18645
|
nonCommitmentLines: [],
|
|
18621
18646
|
};
|
|
18622
18647
|
}
|
|
18623
18648
|
const { lines, agentName, agentNameLineIndex, agentNameLineNumber } = parseAgentSourcePrelude(agentSource);
|
|
18624
18649
|
const commitments = [];
|
|
18650
|
+
const unknownCommitments = [];
|
|
18625
18651
|
const nonCommitmentLines = agentNameLineIndex >= 0 ? [lines[agentNameLineIndex]] : [];
|
|
18626
|
-
// Parse commitments with multiline support
|
|
18652
|
+
// Parse commitments with multiline support.
|
|
18627
18653
|
let currentCommitment = null;
|
|
18628
18654
|
// Process lines starting from after the agent name line
|
|
18629
18655
|
const startIndex = agentNameLineIndex >= 0 ? agentNameLineIndex + 1 : 0;
|
|
@@ -18637,25 +18663,11 @@ function parseAgentSourceWithCommitments(agentSource) {
|
|
|
18637
18663
|
// Check if this line starts or ends a code block
|
|
18638
18664
|
if (trimmedLine.startsWith('```')) {
|
|
18639
18665
|
isInsideCodeBlock = !isInsideCodeBlock;
|
|
18640
|
-
|
|
18641
|
-
// If we are inside a commitment, the code block is part of it
|
|
18642
|
-
currentCommitment.contentLines.push(line);
|
|
18643
|
-
}
|
|
18644
|
-
else {
|
|
18645
|
-
// If we are not inside a commitment, the code block is non-commitment
|
|
18646
|
-
nonCommitmentLines.push(line);
|
|
18647
|
-
}
|
|
18666
|
+
appendLineToCurrentCommitmentOrNonCommitmentLines(currentCommitment, line, nonCommitmentLines);
|
|
18648
18667
|
continue;
|
|
18649
18668
|
}
|
|
18650
18669
|
if (isInsideCodeBlock) {
|
|
18651
|
-
|
|
18652
|
-
// If we are inside a commitment and a code block, the line is part of the commitment
|
|
18653
|
-
currentCommitment.contentLines.push(line);
|
|
18654
|
-
}
|
|
18655
|
-
else {
|
|
18656
|
-
// If we are inside a code block but not a commitment, the line is non-commitment
|
|
18657
|
-
nonCommitmentLines.push(line);
|
|
18658
|
-
}
|
|
18670
|
+
appendLineToCurrentCommitmentOrNonCommitmentLines(currentCommitment, line, nonCommitmentLines);
|
|
18659
18671
|
continue;
|
|
18660
18672
|
}
|
|
18661
18673
|
// Check if this line starts a new commitment
|
|
@@ -18664,22 +18676,14 @@ function parseAgentSourceWithCommitments(agentSource) {
|
|
|
18664
18676
|
const typeRegex = definition.createTypeRegex();
|
|
18665
18677
|
const match = typeRegex.exec(line.trim());
|
|
18666
18678
|
if (match && ((_a = match.groups) === null || _a === void 0 ? void 0 : _a.type)) {
|
|
18667
|
-
|
|
18668
|
-
if (currentCommitment) {
|
|
18669
|
-
const fullContent = currentCommitment.contentLines.join('\n');
|
|
18670
|
-
commitments.push({
|
|
18671
|
-
type: currentCommitment.type,
|
|
18672
|
-
content: spaceTrim$1(fullContent),
|
|
18673
|
-
originalLine: currentCommitment.originalStartLine,
|
|
18674
|
-
lineNumber: currentCommitment.startLineNumber,
|
|
18675
|
-
});
|
|
18676
|
-
}
|
|
18679
|
+
appendCurrentCommitment(currentCommitment, commitments, unknownCommitments);
|
|
18677
18680
|
// Extract the initial content from the commitment line
|
|
18678
18681
|
const fullRegex = definition.createRegex();
|
|
18679
18682
|
const fullMatch = fullRegex.exec(line.trim());
|
|
18680
18683
|
const initialContent = ((_b = fullMatch === null || fullMatch === void 0 ? void 0 : fullMatch.groups) === null || _b === void 0 ? void 0 : _b.contents) || '';
|
|
18681
18684
|
// Start a new commitment
|
|
18682
18685
|
currentCommitment = {
|
|
18686
|
+
kind: 'known',
|
|
18683
18687
|
type: definition.type,
|
|
18684
18688
|
startLineNumber: i + 1,
|
|
18685
18689
|
originalStartLine: line,
|
|
@@ -18689,52 +18693,90 @@ function parseAgentSourceWithCommitments(agentSource) {
|
|
|
18689
18693
|
break;
|
|
18690
18694
|
}
|
|
18691
18695
|
}
|
|
18696
|
+
if (foundNewCommitment) {
|
|
18697
|
+
continue;
|
|
18698
|
+
}
|
|
18699
|
+
const unknownCommitmentType = getBookCommitmentLineType(line);
|
|
18700
|
+
if (unknownCommitmentType) {
|
|
18701
|
+
appendCurrentCommitment(currentCommitment, commitments, unknownCommitments);
|
|
18702
|
+
currentCommitment = {
|
|
18703
|
+
kind: 'unknown',
|
|
18704
|
+
type: unknownCommitmentType,
|
|
18705
|
+
startLineNumber: i + 1,
|
|
18706
|
+
originalStartLine: line,
|
|
18707
|
+
sourceLines: [line],
|
|
18708
|
+
};
|
|
18709
|
+
continue;
|
|
18710
|
+
}
|
|
18692
18711
|
// Check if this is a horizontal line (ends any current commitment)
|
|
18693
18712
|
const isHorizontalLine = HORIZONTAL_LINE_PATTERN$1.test(line);
|
|
18694
18713
|
if (isHorizontalLine) {
|
|
18695
|
-
|
|
18696
|
-
|
|
18697
|
-
const fullContent = currentCommitment.contentLines.join('\n');
|
|
18698
|
-
commitments.push({
|
|
18699
|
-
type: currentCommitment.type,
|
|
18700
|
-
content: spaceTrim$1(fullContent),
|
|
18701
|
-
originalLine: currentCommitment.originalStartLine,
|
|
18702
|
-
lineNumber: currentCommitment.startLineNumber,
|
|
18703
|
-
});
|
|
18704
|
-
currentCommitment = null;
|
|
18705
|
-
}
|
|
18714
|
+
appendCurrentCommitment(currentCommitment, commitments, unknownCommitments);
|
|
18715
|
+
currentCommitment = null;
|
|
18706
18716
|
// Add horizontal line to non-commitment lines
|
|
18707
18717
|
nonCommitmentLines.push(line);
|
|
18708
18718
|
continue;
|
|
18709
18719
|
}
|
|
18710
|
-
|
|
18711
|
-
if (currentCommitment) {
|
|
18712
|
-
// This line belongs to the current commitment
|
|
18713
|
-
currentCommitment.contentLines.push(line);
|
|
18714
|
-
}
|
|
18715
|
-
else {
|
|
18716
|
-
// This line is not part of any commitment
|
|
18717
|
-
nonCommitmentLines.push(line);
|
|
18718
|
-
}
|
|
18719
|
-
}
|
|
18720
|
-
}
|
|
18721
|
-
// Don't forget to save the last commitment if it exists
|
|
18722
|
-
if (currentCommitment) {
|
|
18723
|
-
const fullContent = currentCommitment.contentLines.join('\n');
|
|
18724
|
-
commitments.push({
|
|
18725
|
-
type: currentCommitment.type,
|
|
18726
|
-
content: spaceTrim$1(fullContent),
|
|
18727
|
-
originalLine: currentCommitment.originalStartLine,
|
|
18728
|
-
lineNumber: currentCommitment.startLineNumber,
|
|
18729
|
-
});
|
|
18720
|
+
appendLineToCurrentCommitmentOrNonCommitmentLines(currentCommitment, line, nonCommitmentLines);
|
|
18730
18721
|
}
|
|
18722
|
+
appendCurrentCommitment(currentCommitment, commitments, unknownCommitments);
|
|
18731
18723
|
return {
|
|
18732
18724
|
agentName,
|
|
18733
18725
|
agentNameLineNumber,
|
|
18734
18726
|
commitments,
|
|
18727
|
+
unknownCommitments,
|
|
18735
18728
|
nonCommitmentLines,
|
|
18736
18729
|
};
|
|
18737
18730
|
}
|
|
18731
|
+
/**
|
|
18732
|
+
* Stores the current known or unknown commitment in its appropriate parsed collection.
|
|
18733
|
+
*
|
|
18734
|
+
* @param currentCommitment - Commitment-like block collected so far.
|
|
18735
|
+
* @param commitments - Parsed registered commitments to append to.
|
|
18736
|
+
* @param unknownCommitments - Parsed unregistered commitments to append to.
|
|
18737
|
+
*
|
|
18738
|
+
* @private internal utility of `parseAgentSourceWithCommitments`
|
|
18739
|
+
*/
|
|
18740
|
+
function appendCurrentCommitment(currentCommitment, commitments, unknownCommitments) {
|
|
18741
|
+
if (!currentCommitment) {
|
|
18742
|
+
return;
|
|
18743
|
+
}
|
|
18744
|
+
if (currentCommitment.kind === 'unknown') {
|
|
18745
|
+
unknownCommitments.push({
|
|
18746
|
+
type: currentCommitment.type,
|
|
18747
|
+
originalLine: currentCommitment.originalStartLine,
|
|
18748
|
+
lineNumber: currentCommitment.startLineNumber,
|
|
18749
|
+
source: spaceTrim$1(currentCommitment.sourceLines.join('\n')),
|
|
18750
|
+
});
|
|
18751
|
+
return;
|
|
18752
|
+
}
|
|
18753
|
+
commitments.push({
|
|
18754
|
+
type: currentCommitment.type,
|
|
18755
|
+
content: spaceTrim$1(currentCommitment.contentLines.join('\n')),
|
|
18756
|
+
originalLine: currentCommitment.originalStartLine,
|
|
18757
|
+
lineNumber: currentCommitment.startLineNumber,
|
|
18758
|
+
});
|
|
18759
|
+
}
|
|
18760
|
+
/**
|
|
18761
|
+
* Adds one source line to the active commitment-like block, or to plain source content when none is active.
|
|
18762
|
+
*
|
|
18763
|
+
* @param currentCommitment - Commitment-like block currently being collected.
|
|
18764
|
+
* @param line - Source line to append.
|
|
18765
|
+
* @param nonCommitmentLines - Plain source lines to append to when no block is active.
|
|
18766
|
+
*
|
|
18767
|
+
* @private internal utility of `parseAgentSourceWithCommitments`
|
|
18768
|
+
*/
|
|
18769
|
+
function appendLineToCurrentCommitmentOrNonCommitmentLines(currentCommitment, line, nonCommitmentLines) {
|
|
18770
|
+
if (!currentCommitment) {
|
|
18771
|
+
nonCommitmentLines.push(line);
|
|
18772
|
+
return;
|
|
18773
|
+
}
|
|
18774
|
+
if (currentCommitment.kind === 'unknown') {
|
|
18775
|
+
currentCommitment.sourceLines.push(line);
|
|
18776
|
+
return;
|
|
18777
|
+
}
|
|
18778
|
+
currentCommitment.contentLines.push(line);
|
|
18779
|
+
}
|
|
18738
18780
|
|
|
18739
18781
|
/**
|
|
18740
18782
|
* Parses parameters from text using both supported notations:
|
|
@@ -26517,7 +26559,8 @@ async function augmentAgentModelRequirementsFromSource(requirements, parseResult
|
|
|
26517
26559
|
requirements = await importReferencedFiles(requirements);
|
|
26518
26560
|
requirements = appendMcpServers(requirements, agentSource);
|
|
26519
26561
|
requirements = appendNonCommitmentContent(requirements, parseResult);
|
|
26520
|
-
|
|
26562
|
+
requirements = appendExampleInteractions(requirements, parseResult);
|
|
26563
|
+
return appendUnknownCommitmentContent(requirements, parseResult);
|
|
26521
26564
|
}
|
|
26522
26565
|
/**
|
|
26523
26566
|
* Imports text files referenced by IMPORT commitments and appends their transformed content to the system message.
|
|
@@ -26639,6 +26682,36 @@ function appendNonCommitmentContent(requirements, parseResult) {
|
|
|
26639
26682
|
}
|
|
26640
26683
|
return appendSystemMessageSection(requirements, nonCommitmentContent);
|
|
26641
26684
|
}
|
|
26685
|
+
/**
|
|
26686
|
+
* Appends unknown commitment blocks as final extra context without applying commitment side effects.
|
|
26687
|
+
*
|
|
26688
|
+
* @param requirements - Current requirements snapshot.
|
|
26689
|
+
* @param parseResult - Parsed source including unknown commitment blocks.
|
|
26690
|
+
* @returns Requirements with unknown commitment context appended at the end of the system message.
|
|
26691
|
+
*
|
|
26692
|
+
* @private internal utility of `augmentAgentModelRequirementsFromSource`
|
|
26693
|
+
*/
|
|
26694
|
+
function appendUnknownCommitmentContent(requirements, parseResult) {
|
|
26695
|
+
const unknownCommitmentContent = getUnknownCommitmentContent(parseResult);
|
|
26696
|
+
if (!unknownCommitmentContent) {
|
|
26697
|
+
return requirements;
|
|
26698
|
+
}
|
|
26699
|
+
return appendSystemMessageSection(requirements, unknownCommitmentContent);
|
|
26700
|
+
}
|
|
26701
|
+
/**
|
|
26702
|
+
* Joins unknown commitment blocks into their final extra-context representation.
|
|
26703
|
+
*
|
|
26704
|
+
* @param parseResult - Parsed source including unknown commitment blocks.
|
|
26705
|
+
* @returns Unknown commitment source blocks in their original order.
|
|
26706
|
+
*
|
|
26707
|
+
* @private internal utility of `appendUnknownCommitmentContent`
|
|
26708
|
+
*/
|
|
26709
|
+
function getUnknownCommitmentContent(parseResult) {
|
|
26710
|
+
return parseResult.unknownCommitments
|
|
26711
|
+
.map((commitment) => commitment.source)
|
|
26712
|
+
.filter(Boolean)
|
|
26713
|
+
.join('\n\n');
|
|
26714
|
+
}
|
|
26642
26715
|
/**
|
|
26643
26716
|
* Collects plain-text lines that were not parsed as commitments and should still become part of the final system message.
|
|
26644
26717
|
*
|