@promptbook/remote-server 0.114.0-11 → 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 +145 -68
- 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/package.json +2 -2
- package/umd/index.umd.js +144 -67
- 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/esm/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { join, basename, dirname, isAbsolute } from 'path';
|
|
1
|
+
import { join, basename, dirname, isAbsolute, delimiter } from 'path';
|
|
2
2
|
import { spawn } from 'child_process';
|
|
3
3
|
import colors from 'colors';
|
|
4
4
|
import _spaceTrim, { spaceTrim as spaceTrim$1 } from 'spacetrim';
|
|
@@ -34,7 +34,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
34
34
|
* @generated
|
|
35
35
|
* @see https://github.com/webgptorg/promptbook
|
|
36
36
|
*/
|
|
37
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.114.0-
|
|
37
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.114.0-12';
|
|
38
38
|
/**
|
|
39
39
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
40
40
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -8721,23 +8721,27 @@ async function locateAppOnMacOs({ macOsName, }) {
|
|
|
8721
8721
|
// TODO: [🧠][♿] Maybe export through `@promptbook/node`
|
|
8722
8722
|
|
|
8723
8723
|
/**
|
|
8724
|
-
* Attempts to locate the specified application on a Windows system by searching common installation directories.
|
|
8724
|
+
* Attempts to locate the specified application on a Windows system by searching PATH and common installation directories.
|
|
8725
8725
|
* Returns the path to the executable if found, or null otherwise.
|
|
8726
8726
|
*
|
|
8727
8727
|
* @private within the repository
|
|
8728
8728
|
*/
|
|
8729
8729
|
async function locateAppOnWindows({ appName, windowsSuffix, }) {
|
|
8730
8730
|
try {
|
|
8731
|
-
const
|
|
8731
|
+
const EXECUTABLE_FILENAME = windowsSuffix.replace(/^.*[\\/]/, '');
|
|
8732
|
+
const PATH_EXECUTABLE_PATHS = (process.env.PATH || '')
|
|
8733
|
+
.split(delimiter)
|
|
8734
|
+
.filter(Boolean)
|
|
8735
|
+
.map((pathPrefix) => join(pathPrefix, EXECUTABLE_FILENAME));
|
|
8736
|
+
const INSTALLATION_EXECUTABLE_PATHS = [
|
|
8732
8737
|
process.env.LOCALAPPDATA,
|
|
8733
8738
|
join(process.env.LOCALAPPDATA || '', 'Programs'),
|
|
8734
8739
|
process.env.PROGRAMFILES,
|
|
8735
8740
|
process.env['PROGRAMFILES(X86)'],
|
|
8736
|
-
];
|
|
8737
|
-
for (const
|
|
8738
|
-
|
|
8739
|
-
|
|
8740
|
-
return path;
|
|
8741
|
+
].map((pathPrefix) => pathPrefix + windowsSuffix);
|
|
8742
|
+
for (const executablePath of [...PATH_EXECUTABLE_PATHS, ...INSTALLATION_EXECUTABLE_PATHS]) {
|
|
8743
|
+
if (await isExecutable(executablePath, $provideFilesystemForNode())) {
|
|
8744
|
+
return executablePath;
|
|
8741
8745
|
}
|
|
8742
8746
|
}
|
|
8743
8747
|
throw new Error(`Can not locate app ${appName} on Windows.`);
|
|
@@ -29298,6 +29302,30 @@ function createDefaultAgentName(agentSource) {
|
|
|
29298
29302
|
return normalizeAgentName(`Agent ${agentHash.substring(0, LIMITS.SHORT_NAME_LENGTH)}`);
|
|
29299
29303
|
}
|
|
29300
29304
|
|
|
29305
|
+
/**
|
|
29306
|
+
* Pattern shared by Book parsing and editor highlighting for a commitment-like line.
|
|
29307
|
+
*
|
|
29308
|
+
* A Book commitment keyword consists of one or more all-uppercase words with at least
|
|
29309
|
+
* two characters each. This deliberately mirrors the Book editor syntax rule so an
|
|
29310
|
+
* unknown keyword starts a new source block everywhere it is interpreted.
|
|
29311
|
+
*
|
|
29312
|
+
* @private internal constant of `getBookCommitmentLineType`
|
|
29313
|
+
*/
|
|
29314
|
+
const BOOK_COMMITMENT_LINE_TYPE_REGEX = /^\s*(?<type>[A-Z][A-Z0-9]+(?:\s+[A-Z][A-Z0-9]+)*)(?=\s|$)/;
|
|
29315
|
+
/**
|
|
29316
|
+
* Extracts the uppercase commitment type from a Book line, including types not registered by Promptbook.
|
|
29317
|
+
*
|
|
29318
|
+
* @param line - One raw Book source line.
|
|
29319
|
+
* @returns Matched commitment type or `null` when the line does not begin with commitment syntax.
|
|
29320
|
+
*
|
|
29321
|
+
* @private internal utility of Book parsing and `<BookEditor/>`
|
|
29322
|
+
*/
|
|
29323
|
+
function getBookCommitmentLineType(line) {
|
|
29324
|
+
var _a;
|
|
29325
|
+
const match = BOOK_COMMITMENT_LINE_TYPE_REGEX.exec(line);
|
|
29326
|
+
return ((_a = match === null || match === void 0 ? void 0 : match.groups) === null || _a === void 0 ? void 0 : _a.type) || null;
|
|
29327
|
+
}
|
|
29328
|
+
|
|
29301
29329
|
/**
|
|
29302
29330
|
* Consumes the agent-name prelude from raw source.
|
|
29303
29331
|
*
|
|
@@ -29355,13 +29383,15 @@ function parseAgentSourceWithCommitments(agentSource) {
|
|
|
29355
29383
|
return {
|
|
29356
29384
|
agentName: null,
|
|
29357
29385
|
commitments: [],
|
|
29386
|
+
unknownCommitments: [],
|
|
29358
29387
|
nonCommitmentLines: [],
|
|
29359
29388
|
};
|
|
29360
29389
|
}
|
|
29361
29390
|
const { lines, agentName, agentNameLineIndex, agentNameLineNumber } = parseAgentSourcePrelude(agentSource);
|
|
29362
29391
|
const commitments = [];
|
|
29392
|
+
const unknownCommitments = [];
|
|
29363
29393
|
const nonCommitmentLines = agentNameLineIndex >= 0 ? [lines[agentNameLineIndex]] : [];
|
|
29364
|
-
// Parse commitments with multiline support
|
|
29394
|
+
// Parse commitments with multiline support.
|
|
29365
29395
|
let currentCommitment = null;
|
|
29366
29396
|
// Process lines starting from after the agent name line
|
|
29367
29397
|
const startIndex = agentNameLineIndex >= 0 ? agentNameLineIndex + 1 : 0;
|
|
@@ -29375,25 +29405,11 @@ function parseAgentSourceWithCommitments(agentSource) {
|
|
|
29375
29405
|
// Check if this line starts or ends a code block
|
|
29376
29406
|
if (trimmedLine.startsWith('```')) {
|
|
29377
29407
|
isInsideCodeBlock = !isInsideCodeBlock;
|
|
29378
|
-
|
|
29379
|
-
// If we are inside a commitment, the code block is part of it
|
|
29380
|
-
currentCommitment.contentLines.push(line);
|
|
29381
|
-
}
|
|
29382
|
-
else {
|
|
29383
|
-
// If we are not inside a commitment, the code block is non-commitment
|
|
29384
|
-
nonCommitmentLines.push(line);
|
|
29385
|
-
}
|
|
29408
|
+
appendLineToCurrentCommitmentOrNonCommitmentLines(currentCommitment, line, nonCommitmentLines);
|
|
29386
29409
|
continue;
|
|
29387
29410
|
}
|
|
29388
29411
|
if (isInsideCodeBlock) {
|
|
29389
|
-
|
|
29390
|
-
// If we are inside a commitment and a code block, the line is part of the commitment
|
|
29391
|
-
currentCommitment.contentLines.push(line);
|
|
29392
|
-
}
|
|
29393
|
-
else {
|
|
29394
|
-
// If we are inside a code block but not a commitment, the line is non-commitment
|
|
29395
|
-
nonCommitmentLines.push(line);
|
|
29396
|
-
}
|
|
29412
|
+
appendLineToCurrentCommitmentOrNonCommitmentLines(currentCommitment, line, nonCommitmentLines);
|
|
29397
29413
|
continue;
|
|
29398
29414
|
}
|
|
29399
29415
|
// Check if this line starts a new commitment
|
|
@@ -29402,22 +29418,14 @@ function parseAgentSourceWithCommitments(agentSource) {
|
|
|
29402
29418
|
const typeRegex = definition.createTypeRegex();
|
|
29403
29419
|
const match = typeRegex.exec(line.trim());
|
|
29404
29420
|
if (match && ((_a = match.groups) === null || _a === void 0 ? void 0 : _a.type)) {
|
|
29405
|
-
|
|
29406
|
-
if (currentCommitment) {
|
|
29407
|
-
const fullContent = currentCommitment.contentLines.join('\n');
|
|
29408
|
-
commitments.push({
|
|
29409
|
-
type: currentCommitment.type,
|
|
29410
|
-
content: spaceTrim$1(fullContent),
|
|
29411
|
-
originalLine: currentCommitment.originalStartLine,
|
|
29412
|
-
lineNumber: currentCommitment.startLineNumber,
|
|
29413
|
-
});
|
|
29414
|
-
}
|
|
29421
|
+
appendCurrentCommitment(currentCommitment, commitments, unknownCommitments);
|
|
29415
29422
|
// Extract the initial content from the commitment line
|
|
29416
29423
|
const fullRegex = definition.createRegex();
|
|
29417
29424
|
const fullMatch = fullRegex.exec(line.trim());
|
|
29418
29425
|
const initialContent = ((_b = fullMatch === null || fullMatch === void 0 ? void 0 : fullMatch.groups) === null || _b === void 0 ? void 0 : _b.contents) || '';
|
|
29419
29426
|
// Start a new commitment
|
|
29420
29427
|
currentCommitment = {
|
|
29428
|
+
kind: 'known',
|
|
29421
29429
|
type: definition.type,
|
|
29422
29430
|
startLineNumber: i + 1,
|
|
29423
29431
|
originalStartLine: line,
|
|
@@ -29427,52 +29435,90 @@ function parseAgentSourceWithCommitments(agentSource) {
|
|
|
29427
29435
|
break;
|
|
29428
29436
|
}
|
|
29429
29437
|
}
|
|
29438
|
+
if (foundNewCommitment) {
|
|
29439
|
+
continue;
|
|
29440
|
+
}
|
|
29441
|
+
const unknownCommitmentType = getBookCommitmentLineType(line);
|
|
29442
|
+
if (unknownCommitmentType) {
|
|
29443
|
+
appendCurrentCommitment(currentCommitment, commitments, unknownCommitments);
|
|
29444
|
+
currentCommitment = {
|
|
29445
|
+
kind: 'unknown',
|
|
29446
|
+
type: unknownCommitmentType,
|
|
29447
|
+
startLineNumber: i + 1,
|
|
29448
|
+
originalStartLine: line,
|
|
29449
|
+
sourceLines: [line],
|
|
29450
|
+
};
|
|
29451
|
+
continue;
|
|
29452
|
+
}
|
|
29430
29453
|
// Check if this is a horizontal line (ends any current commitment)
|
|
29431
29454
|
const isHorizontalLine = HORIZONTAL_LINE_PATTERN$1.test(line);
|
|
29432
29455
|
if (isHorizontalLine) {
|
|
29433
|
-
|
|
29434
|
-
|
|
29435
|
-
const fullContent = currentCommitment.contentLines.join('\n');
|
|
29436
|
-
commitments.push({
|
|
29437
|
-
type: currentCommitment.type,
|
|
29438
|
-
content: spaceTrim$1(fullContent),
|
|
29439
|
-
originalLine: currentCommitment.originalStartLine,
|
|
29440
|
-
lineNumber: currentCommitment.startLineNumber,
|
|
29441
|
-
});
|
|
29442
|
-
currentCommitment = null;
|
|
29443
|
-
}
|
|
29456
|
+
appendCurrentCommitment(currentCommitment, commitments, unknownCommitments);
|
|
29457
|
+
currentCommitment = null;
|
|
29444
29458
|
// Add horizontal line to non-commitment lines
|
|
29445
29459
|
nonCommitmentLines.push(line);
|
|
29446
29460
|
continue;
|
|
29447
29461
|
}
|
|
29448
|
-
|
|
29449
|
-
if (currentCommitment) {
|
|
29450
|
-
// This line belongs to the current commitment
|
|
29451
|
-
currentCommitment.contentLines.push(line);
|
|
29452
|
-
}
|
|
29453
|
-
else {
|
|
29454
|
-
// This line is not part of any commitment
|
|
29455
|
-
nonCommitmentLines.push(line);
|
|
29456
|
-
}
|
|
29457
|
-
}
|
|
29458
|
-
}
|
|
29459
|
-
// Don't forget to save the last commitment if it exists
|
|
29460
|
-
if (currentCommitment) {
|
|
29461
|
-
const fullContent = currentCommitment.contentLines.join('\n');
|
|
29462
|
-
commitments.push({
|
|
29463
|
-
type: currentCommitment.type,
|
|
29464
|
-
content: spaceTrim$1(fullContent),
|
|
29465
|
-
originalLine: currentCommitment.originalStartLine,
|
|
29466
|
-
lineNumber: currentCommitment.startLineNumber,
|
|
29467
|
-
});
|
|
29462
|
+
appendLineToCurrentCommitmentOrNonCommitmentLines(currentCommitment, line, nonCommitmentLines);
|
|
29468
29463
|
}
|
|
29464
|
+
appendCurrentCommitment(currentCommitment, commitments, unknownCommitments);
|
|
29469
29465
|
return {
|
|
29470
29466
|
agentName,
|
|
29471
29467
|
agentNameLineNumber,
|
|
29472
29468
|
commitments,
|
|
29469
|
+
unknownCommitments,
|
|
29473
29470
|
nonCommitmentLines,
|
|
29474
29471
|
};
|
|
29475
29472
|
}
|
|
29473
|
+
/**
|
|
29474
|
+
* Stores the current known or unknown commitment in its appropriate parsed collection.
|
|
29475
|
+
*
|
|
29476
|
+
* @param currentCommitment - Commitment-like block collected so far.
|
|
29477
|
+
* @param commitments - Parsed registered commitments to append to.
|
|
29478
|
+
* @param unknownCommitments - Parsed unregistered commitments to append to.
|
|
29479
|
+
*
|
|
29480
|
+
* @private internal utility of `parseAgentSourceWithCommitments`
|
|
29481
|
+
*/
|
|
29482
|
+
function appendCurrentCommitment(currentCommitment, commitments, unknownCommitments) {
|
|
29483
|
+
if (!currentCommitment) {
|
|
29484
|
+
return;
|
|
29485
|
+
}
|
|
29486
|
+
if (currentCommitment.kind === 'unknown') {
|
|
29487
|
+
unknownCommitments.push({
|
|
29488
|
+
type: currentCommitment.type,
|
|
29489
|
+
originalLine: currentCommitment.originalStartLine,
|
|
29490
|
+
lineNumber: currentCommitment.startLineNumber,
|
|
29491
|
+
source: spaceTrim$1(currentCommitment.sourceLines.join('\n')),
|
|
29492
|
+
});
|
|
29493
|
+
return;
|
|
29494
|
+
}
|
|
29495
|
+
commitments.push({
|
|
29496
|
+
type: currentCommitment.type,
|
|
29497
|
+
content: spaceTrim$1(currentCommitment.contentLines.join('\n')),
|
|
29498
|
+
originalLine: currentCommitment.originalStartLine,
|
|
29499
|
+
lineNumber: currentCommitment.startLineNumber,
|
|
29500
|
+
});
|
|
29501
|
+
}
|
|
29502
|
+
/**
|
|
29503
|
+
* Adds one source line to the active commitment-like block, or to plain source content when none is active.
|
|
29504
|
+
*
|
|
29505
|
+
* @param currentCommitment - Commitment-like block currently being collected.
|
|
29506
|
+
* @param line - Source line to append.
|
|
29507
|
+
* @param nonCommitmentLines - Plain source lines to append to when no block is active.
|
|
29508
|
+
*
|
|
29509
|
+
* @private internal utility of `parseAgentSourceWithCommitments`
|
|
29510
|
+
*/
|
|
29511
|
+
function appendLineToCurrentCommitmentOrNonCommitmentLines(currentCommitment, line, nonCommitmentLines) {
|
|
29512
|
+
if (!currentCommitment) {
|
|
29513
|
+
nonCommitmentLines.push(line);
|
|
29514
|
+
return;
|
|
29515
|
+
}
|
|
29516
|
+
if (currentCommitment.kind === 'unknown') {
|
|
29517
|
+
currentCommitment.sourceLines.push(line);
|
|
29518
|
+
return;
|
|
29519
|
+
}
|
|
29520
|
+
currentCommitment.contentLines.push(line);
|
|
29521
|
+
}
|
|
29476
29522
|
|
|
29477
29523
|
/**
|
|
29478
29524
|
* Parses parameters from text using both supported notations:
|
|
@@ -30565,7 +30611,8 @@ async function augmentAgentModelRequirementsFromSource(requirements, parseResult
|
|
|
30565
30611
|
requirements = await importReferencedFiles(requirements);
|
|
30566
30612
|
requirements = appendMcpServers(requirements, agentSource);
|
|
30567
30613
|
requirements = appendNonCommitmentContent(requirements, parseResult);
|
|
30568
|
-
|
|
30614
|
+
requirements = appendExampleInteractions(requirements, parseResult);
|
|
30615
|
+
return appendUnknownCommitmentContent(requirements, parseResult);
|
|
30569
30616
|
}
|
|
30570
30617
|
/**
|
|
30571
30618
|
* Imports text files referenced by IMPORT commitments and appends their transformed content to the system message.
|
|
@@ -30687,6 +30734,36 @@ function appendNonCommitmentContent(requirements, parseResult) {
|
|
|
30687
30734
|
}
|
|
30688
30735
|
return appendSystemMessageSection(requirements, nonCommitmentContent);
|
|
30689
30736
|
}
|
|
30737
|
+
/**
|
|
30738
|
+
* Appends unknown commitment blocks as final extra context without applying commitment side effects.
|
|
30739
|
+
*
|
|
30740
|
+
* @param requirements - Current requirements snapshot.
|
|
30741
|
+
* @param parseResult - Parsed source including unknown commitment blocks.
|
|
30742
|
+
* @returns Requirements with unknown commitment context appended at the end of the system message.
|
|
30743
|
+
*
|
|
30744
|
+
* @private internal utility of `augmentAgentModelRequirementsFromSource`
|
|
30745
|
+
*/
|
|
30746
|
+
function appendUnknownCommitmentContent(requirements, parseResult) {
|
|
30747
|
+
const unknownCommitmentContent = getUnknownCommitmentContent(parseResult);
|
|
30748
|
+
if (!unknownCommitmentContent) {
|
|
30749
|
+
return requirements;
|
|
30750
|
+
}
|
|
30751
|
+
return appendSystemMessageSection(requirements, unknownCommitmentContent);
|
|
30752
|
+
}
|
|
30753
|
+
/**
|
|
30754
|
+
* Joins unknown commitment blocks into their final extra-context representation.
|
|
30755
|
+
*
|
|
30756
|
+
* @param parseResult - Parsed source including unknown commitment blocks.
|
|
30757
|
+
* @returns Unknown commitment source blocks in their original order.
|
|
30758
|
+
*
|
|
30759
|
+
* @private internal utility of `appendUnknownCommitmentContent`
|
|
30760
|
+
*/
|
|
30761
|
+
function getUnknownCommitmentContent(parseResult) {
|
|
30762
|
+
return parseResult.unknownCommitments
|
|
30763
|
+
.map((commitment) => commitment.source)
|
|
30764
|
+
.filter(Boolean)
|
|
30765
|
+
.join('\n\n');
|
|
30766
|
+
}
|
|
30690
30767
|
/**
|
|
30691
30768
|
* Collects plain-text lines that were not parsed as commitments and should still become part of the final system message.
|
|
30692
30769
|
*
|