@promptbook/remote-server 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.
Files changed (37) hide show
  1. package/esm/index.es.js +145 -68
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/src/book-2.0/agent-source/AgentSourceParseResult.d.ts +5 -0
  4. package/esm/src/book-2.0/agent-source/ParsedUnknownCommitment.d.ts +26 -0
  5. package/esm/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments.unknown.test.d.ts +1 -0
  6. package/esm/src/book-2.0/agent-source/getBookCommitmentLineType.d.ts +19 -0
  7. package/esm/src/book-2.0/agent-source/parseAgentSourceWithCommitments.unknown.test.d.ts +1 -0
  8. package/esm/src/book-components/BookEditor/createUnknownCommitmentDiagnostics.d.ts +28 -0
  9. package/esm/src/book-components/BookEditor/createUnknownCommitmentDiagnostics.test.d.ts +1 -0
  10. package/esm/src/cli/cli-commands/common/harness/$checkHarnessInstallation.d.ts +3 -3
  11. package/esm/src/cli/cli-commands/common/harness/$checkHarnessInstallation.test.d.ts +1 -0
  12. package/esm/src/cli/cli-commands/common/harness/$ensureHarnessInstallations.d.ts +3 -3
  13. package/esm/src/cli/cli-commands/common/harness/HarnessInstallationStatus.d.ts +3 -2
  14. package/esm/src/cli/cli-commands/common/harnessUpdateCliOptions.d.ts +29 -0
  15. package/esm/src/cli/cli-commands/common/harnessUpdateCliOptions.test.d.ts +1 -0
  16. package/esm/src/executables/platforms/locateAppOnWindows.d.ts +1 -1
  17. package/esm/src/executables/platforms/locateAppOnWindows.test.d.ts +1 -0
  18. package/esm/src/version.d.ts +1 -1
  19. package/package.json +2 -2
  20. package/umd/index.umd.js +144 -67
  21. package/umd/index.umd.js.map +1 -1
  22. package/umd/src/book-2.0/agent-source/AgentSourceParseResult.d.ts +5 -0
  23. package/umd/src/book-2.0/agent-source/ParsedUnknownCommitment.d.ts +26 -0
  24. package/umd/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments.unknown.test.d.ts +1 -0
  25. package/umd/src/book-2.0/agent-source/getBookCommitmentLineType.d.ts +19 -0
  26. package/umd/src/book-2.0/agent-source/parseAgentSourceWithCommitments.unknown.test.d.ts +1 -0
  27. package/umd/src/book-components/BookEditor/createUnknownCommitmentDiagnostics.d.ts +28 -0
  28. package/umd/src/book-components/BookEditor/createUnknownCommitmentDiagnostics.test.d.ts +1 -0
  29. package/umd/src/cli/cli-commands/common/harness/$checkHarnessInstallation.d.ts +3 -3
  30. package/umd/src/cli/cli-commands/common/harness/$checkHarnessInstallation.test.d.ts +1 -0
  31. package/umd/src/cli/cli-commands/common/harness/$ensureHarnessInstallations.d.ts +3 -3
  32. package/umd/src/cli/cli-commands/common/harness/HarnessInstallationStatus.d.ts +3 -2
  33. package/umd/src/cli/cli-commands/common/harnessUpdateCliOptions.d.ts +29 -0
  34. package/umd/src/cli/cli-commands/common/harnessUpdateCliOptions.test.d.ts +1 -0
  35. package/umd/src/executables/platforms/locateAppOnWindows.d.ts +1 -1
  36. package/umd/src/executables/platforms/locateAppOnWindows.test.d.ts +1 -0
  37. package/umd/src/version.d.ts +1 -1
@@ -1,5 +1,6 @@
1
1
  import type { ParsedCommitment } from '../../commitments/_base/ParsedCommitment';
2
2
  import type { string_agent_name } from '../../types/string_agent_name';
3
+ import type { ParsedUnknownCommitment } from './ParsedUnknownCommitment';
3
4
  /**
4
5
  * Result of parsing agent source for commitments
5
6
  *
@@ -18,6 +19,10 @@ export type AgentSourceParseResult = {
18
19
  * All parsed commitments
19
20
  */
20
21
  commitments: ParsedCommitment[];
22
+ /**
23
+ * Uppercase commitment blocks whose types are not registered by Promptbook.
24
+ */
25
+ unknownCommitments: ParsedUnknownCommitment[];
21
26
  /**
22
27
  * Lines that are not commitments (for system message)
23
28
  */
@@ -0,0 +1,26 @@
1
+ /**
2
+ * An uppercase Book commitment block whose keyword is not registered by Promptbook.
3
+ *
4
+ * Unknown commitments are retained as system-message context instead of being applied
5
+ * as executable commitments.
6
+ *
7
+ * @private internal type of `parseAgentSourceWithCommitments`
8
+ */
9
+ export type ParsedUnknownCommitment = {
10
+ /**
11
+ * Uppercase unknown commitment type, for example `FOO` or `BAR BZZ`.
12
+ */
13
+ readonly type: string;
14
+ /**
15
+ * Original first line, retained for precise editor diagnostics.
16
+ */
17
+ readonly originalLine: string;
18
+ /**
19
+ * Line number in the agent source (1-based).
20
+ */
21
+ readonly lineNumber: number;
22
+ /**
23
+ * Complete unknown commitment block, including its keyword and continuation lines.
24
+ */
25
+ readonly source: string;
26
+ };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Creates the regex used to recognize the uppercase commitment type at the beginning of a Book line.
3
+ *
4
+ * A fresh regular expression keeps Monaco tokenizer state isolated from parser calls.
5
+ *
6
+ * @returns Regular expression matching one Book commitment-like line.
7
+ *
8
+ * @private internal utility of Book parsing and `<BookEditor/>`
9
+ */
10
+ export declare function createBookCommitmentLineTypeRegex(): RegExp;
11
+ /**
12
+ * Extracts the uppercase commitment type from a Book line, including types not registered by Promptbook.
13
+ *
14
+ * @param line - One raw Book source line.
15
+ * @returns Matched commitment type or `null` when the line does not begin with commitment syntax.
16
+ *
17
+ * @private internal utility of Book parsing and `<BookEditor/>`
18
+ */
19
+ export declare function getBookCommitmentLineType(line: string): string | null;
@@ -0,0 +1,28 @@
1
+ import type { string_book } from '../../book-2.0/agent-source/string_book';
2
+ /**
3
+ * Monaco diagnostic shown when a Book source uses an uppercase commitment not registered by Promptbook.
4
+ *
5
+ * @private internal type of `BookEditorMonaco`
6
+ */
7
+ type UnknownCommitmentDiagnostic = {
8
+ readonly startLineNumber: number;
9
+ readonly startColumn: number;
10
+ readonly endLineNumber: number;
11
+ readonly endColumn: number;
12
+ readonly message: string;
13
+ readonly source: string;
14
+ readonly severity: 'error';
15
+ };
16
+ /**
17
+ * Creates Book editor diagnostics for uppercase commitments not registered by Promptbook.
18
+ *
19
+ * Unknown commitment blocks remain valid extra context in the generated system message,
20
+ * but the editor marks their keywords so authors can spot likely typos immediately.
21
+ *
22
+ * @param agentSource - Current editor content.
23
+ * @returns Error markers for all unknown commitment keywords.
24
+ *
25
+ * @private internal utility of `BookEditorMonaco`
26
+ */
27
+ export declare function createUnknownCommitmentDiagnostics(agentSource?: string_book): ReadonlyArray<UnknownCommitmentDiagnostic>;
28
+ export {};
@@ -1,10 +1,10 @@
1
1
  import type { HarnessDefinition } from './HarnessDefinition';
2
2
  import type { HarnessInstallationStatus } from './HarnessInstallationStatus';
3
3
  /**
4
- * Detects whether one CLI coding harness is installed globally and whether it is up to date.
4
+ * Detects whether one CLI coding harness is installed globally and, when enabled, whether it is up to date.
5
5
  *
6
- * Note: `$` is used to indicate that this function is not a pure function - it runs the harness command and queries npm
6
+ * Note: `$` is used to indicate that this function is not a pure function - it runs the harness command and may query npm
7
7
  *
8
8
  * @private internal utility of `promptbookCli`
9
9
  */
10
- export declare function $checkHarnessInstallation(definition: HarnessDefinition): Promise<HarnessInstallationStatus>;
10
+ export declare function $checkHarnessInstallation(definition: HarnessDefinition, isHarnessUpdateCheckEnabled?: boolean): Promise<HarnessInstallationStatus>;
@@ -1,7 +1,7 @@
1
1
  import type { PromptRunnerHarnessName } from '../promptRunnerCliOptions';
2
2
  /**
3
- * Checks that every given CLI coding harness is installed globally and up to date and offers to
4
- * install or update the ones which are not.
3
+ * Checks that every given CLI coding harness is installed globally and, when enabled, up to date.
4
+ * Offers to install missing harnesses and update outdated ones.
5
5
  *
6
6
  * Harness names which are `undefined`, for example when no `--harness` is selected in a dry run,
7
7
  * are ignored so that every call site can pass its raw selection.
@@ -10,4 +10,4 @@ import type { PromptRunnerHarnessName } from '../promptRunnerCliOptions';
10
10
  *
11
11
  * @private internal utility of `promptbookCli`
12
12
  */
13
- export declare function $ensureHarnessInstallations(harnessNames: ReadonlyArray<PromptRunnerHarnessName | undefined>): Promise<void>;
13
+ export declare function $ensureHarnessInstallations(harnessNames: ReadonlyArray<PromptRunnerHarnessName | undefined>, isHarnessUpdateCheckEnabled?: boolean): Promise<void>;
@@ -5,11 +5,12 @@ import type { HarnessDefinition } from './HarnessDefinition';
5
5
  * - `up-to-date` the newest published version is installed
6
6
  * - `outdated` an older version is installed
7
7
  * - `not-installed` the harness command is not available globally
8
+ * - `installed` the harness is installed and automatic update checking was disabled
8
9
  * - `unknown` the harness is installed but the newest published version could not be resolved, for example when offline
9
10
  *
10
11
  * @private internal utility of `promptbookCli`
11
12
  */
12
- export type HarnessInstallationState = 'up-to-date' | 'outdated' | 'not-installed' | 'unknown';
13
+ export type HarnessInstallationState = 'up-to-date' | 'outdated' | 'not-installed' | 'installed' | 'unknown';
13
14
  /**
14
15
  * Installation state of one CLI coding harness on the current machine.
15
16
  *
@@ -21,7 +22,7 @@ export type HarnessInstallationStatus = {
21
22
  */
22
23
  readonly definition: HarnessDefinition;
23
24
  /**
24
- * Comparison of the installed version with the newest published one.
25
+ * Installation state, including whether the newest published version was checked.
25
26
  */
26
27
  readonly installationState: HarnessInstallationState;
27
28
  /**
@@ -0,0 +1,29 @@
1
+ import type { Command as Program } from 'commander';
2
+ /**
3
+ * Commander option bag for opting out of automatic coding-harness update checks.
4
+ *
5
+ * @private internal utility of `promptbookCli`
6
+ */
7
+ export type HarnessUpdateCliOptions = {
8
+ readonly harnessUpdate: boolean;
9
+ };
10
+ /**
11
+ * Normalized automatic coding-harness update-check option.
12
+ *
13
+ * @private internal utility of `promptbookCli`
14
+ */
15
+ export type NormalizedHarnessUpdateCliOptions = {
16
+ readonly isHarnessUpdateCheckEnabled: boolean;
17
+ };
18
+ /**
19
+ * Registers the shared `--no-harness-update` option on a `ptbk coder` command that uses a coding harness.
20
+ *
21
+ * @private internal utility of `promptbookCli`
22
+ */
23
+ export declare function addHarnessUpdateOption(command: Program): void;
24
+ /**
25
+ * Converts the Commander harness-update flag into the normalized harness-check option.
26
+ *
27
+ * @private internal utility of `promptbookCli`
28
+ */
29
+ export declare function normalizeHarnessUpdateCliOptions(cliOptions: HarnessUpdateCliOptions): NormalizedHarnessUpdateCliOptions;
@@ -1,7 +1,7 @@
1
1
  import type { string_executable_path } from '../../types/string_filename';
2
2
  import type { LocateAppOptions } from '../locateApp';
3
3
  /**
4
- * Attempts to locate the specified application on a Windows system by searching common installation directories.
4
+ * Attempts to locate the specified application on a Windows system by searching PATH and common installation directories.
5
5
  * Returns the path to the executable if found, or null otherwise.
6
6
  *
7
7
  * @private within the repository
@@ -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.114.0-9`).
18
+ * It follows semantic versioning (e.g., `0.114.0-10`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/remote-server",
3
- "version": "0.114.0-10",
3
+ "version": "0.114.0-12",
4
4
  "description": "Promptbook: Create persistent AI agents that turn your company's scattered knowledge into action",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -99,7 +99,7 @@
99
99
  "types": "./esm/src/_packages/remote-server.index.d.ts",
100
100
  "typings": "./esm/src/_packages/remote-server.index.d.ts",
101
101
  "peerDependencies": {
102
- "@promptbook/core": "0.114.0-10"
102
+ "@promptbook/core": "0.114.0-12"
103
103
  },
104
104
  "dependencies": {
105
105
  "@openai/agents": "0.4.15",
package/umd/index.umd.js CHANGED
@@ -50,7 +50,7 @@
50
50
  * @generated
51
51
  * @see https://github.com/webgptorg/promptbook
52
52
  */
53
- const PROMPTBOOK_ENGINE_VERSION = '0.114.0-10';
53
+ const PROMPTBOOK_ENGINE_VERSION = '0.114.0-12';
54
54
  /**
55
55
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
56
56
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -8737,23 +8737,27 @@
8737
8737
  // TODO: [🧠][♿] Maybe export through `@promptbook/node`
8738
8738
 
8739
8739
  /**
8740
- * Attempts to locate the specified application on a Windows system by searching common installation directories.
8740
+ * Attempts to locate the specified application on a Windows system by searching PATH and common installation directories.
8741
8741
  * Returns the path to the executable if found, or null otherwise.
8742
8742
  *
8743
8743
  * @private within the repository
8744
8744
  */
8745
8745
  async function locateAppOnWindows({ appName, windowsSuffix, }) {
8746
8746
  try {
8747
- const prefixes = [
8747
+ const EXECUTABLE_FILENAME = windowsSuffix.replace(/^.*[\\/]/, '');
8748
+ const PATH_EXECUTABLE_PATHS = (process.env.PATH || '')
8749
+ .split(path.delimiter)
8750
+ .filter(Boolean)
8751
+ .map((pathPrefix) => path.join(pathPrefix, EXECUTABLE_FILENAME));
8752
+ const INSTALLATION_EXECUTABLE_PATHS = [
8748
8753
  process.env.LOCALAPPDATA,
8749
8754
  path.join(process.env.LOCALAPPDATA || '', 'Programs'),
8750
8755
  process.env.PROGRAMFILES,
8751
8756
  process.env['PROGRAMFILES(X86)'],
8752
- ];
8753
- for (const prefix of prefixes) {
8754
- const path = prefix + windowsSuffix;
8755
- if (await isExecutable(path, $provideFilesystemForNode())) {
8756
- return path;
8757
+ ].map((pathPrefix) => pathPrefix + windowsSuffix);
8758
+ for (const executablePath of [...PATH_EXECUTABLE_PATHS, ...INSTALLATION_EXECUTABLE_PATHS]) {
8759
+ if (await isExecutable(executablePath, $provideFilesystemForNode())) {
8760
+ return executablePath;
8757
8761
  }
8758
8762
  }
8759
8763
  throw new Error(`Can not locate app ${appName} on Windows.`);
@@ -29314,6 +29318,30 @@
29314
29318
  return normalizeAgentName(`Agent ${agentHash.substring(0, LIMITS.SHORT_NAME_LENGTH)}`);
29315
29319
  }
29316
29320
 
29321
+ /**
29322
+ * Pattern shared by Book parsing and editor highlighting for a commitment-like line.
29323
+ *
29324
+ * A Book commitment keyword consists of one or more all-uppercase words with at least
29325
+ * two characters each. This deliberately mirrors the Book editor syntax rule so an
29326
+ * unknown keyword starts a new source block everywhere it is interpreted.
29327
+ *
29328
+ * @private internal constant of `getBookCommitmentLineType`
29329
+ */
29330
+ const BOOK_COMMITMENT_LINE_TYPE_REGEX = /^\s*(?<type>[A-Z][A-Z0-9]+(?:\s+[A-Z][A-Z0-9]+)*)(?=\s|$)/;
29331
+ /**
29332
+ * Extracts the uppercase commitment type from a Book line, including types not registered by Promptbook.
29333
+ *
29334
+ * @param line - One raw Book source line.
29335
+ * @returns Matched commitment type or `null` when the line does not begin with commitment syntax.
29336
+ *
29337
+ * @private internal utility of Book parsing and `<BookEditor/>`
29338
+ */
29339
+ function getBookCommitmentLineType(line) {
29340
+ var _a;
29341
+ const match = BOOK_COMMITMENT_LINE_TYPE_REGEX.exec(line);
29342
+ return ((_a = match === null || match === void 0 ? void 0 : match.groups) === null || _a === void 0 ? void 0 : _a.type) || null;
29343
+ }
29344
+
29317
29345
  /**
29318
29346
  * Consumes the agent-name prelude from raw source.
29319
29347
  *
@@ -29371,13 +29399,15 @@
29371
29399
  return {
29372
29400
  agentName: null,
29373
29401
  commitments: [],
29402
+ unknownCommitments: [],
29374
29403
  nonCommitmentLines: [],
29375
29404
  };
29376
29405
  }
29377
29406
  const { lines, agentName, agentNameLineIndex, agentNameLineNumber } = parseAgentSourcePrelude(agentSource);
29378
29407
  const commitments = [];
29408
+ const unknownCommitments = [];
29379
29409
  const nonCommitmentLines = agentNameLineIndex >= 0 ? [lines[agentNameLineIndex]] : [];
29380
- // Parse commitments with multiline support
29410
+ // Parse commitments with multiline support.
29381
29411
  let currentCommitment = null;
29382
29412
  // Process lines starting from after the agent name line
29383
29413
  const startIndex = agentNameLineIndex >= 0 ? agentNameLineIndex + 1 : 0;
@@ -29391,25 +29421,11 @@
29391
29421
  // Check if this line starts or ends a code block
29392
29422
  if (trimmedLine.startsWith('```')) {
29393
29423
  isInsideCodeBlock = !isInsideCodeBlock;
29394
- if (currentCommitment) {
29395
- // If we are inside a commitment, the code block is part of it
29396
- currentCommitment.contentLines.push(line);
29397
- }
29398
- else {
29399
- // If we are not inside a commitment, the code block is non-commitment
29400
- nonCommitmentLines.push(line);
29401
- }
29424
+ appendLineToCurrentCommitmentOrNonCommitmentLines(currentCommitment, line, nonCommitmentLines);
29402
29425
  continue;
29403
29426
  }
29404
29427
  if (isInsideCodeBlock) {
29405
- if (currentCommitment) {
29406
- // If we are inside a commitment and a code block, the line is part of the commitment
29407
- currentCommitment.contentLines.push(line);
29408
- }
29409
- else {
29410
- // If we are inside a code block but not a commitment, the line is non-commitment
29411
- nonCommitmentLines.push(line);
29412
- }
29428
+ appendLineToCurrentCommitmentOrNonCommitmentLines(currentCommitment, line, nonCommitmentLines);
29413
29429
  continue;
29414
29430
  }
29415
29431
  // Check if this line starts a new commitment
@@ -29418,22 +29434,14 @@
29418
29434
  const typeRegex = definition.createTypeRegex();
29419
29435
  const match = typeRegex.exec(line.trim());
29420
29436
  if (match && ((_a = match.groups) === null || _a === void 0 ? void 0 : _a.type)) {
29421
- // Save the previous commitment if it exists
29422
- if (currentCommitment) {
29423
- const fullContent = currentCommitment.contentLines.join('\n');
29424
- commitments.push({
29425
- type: currentCommitment.type,
29426
- content: _spaceTrim.spaceTrim(fullContent),
29427
- originalLine: currentCommitment.originalStartLine,
29428
- lineNumber: currentCommitment.startLineNumber,
29429
- });
29430
- }
29437
+ appendCurrentCommitment(currentCommitment, commitments, unknownCommitments);
29431
29438
  // Extract the initial content from the commitment line
29432
29439
  const fullRegex = definition.createRegex();
29433
29440
  const fullMatch = fullRegex.exec(line.trim());
29434
29441
  const initialContent = ((_b = fullMatch === null || fullMatch === void 0 ? void 0 : fullMatch.groups) === null || _b === void 0 ? void 0 : _b.contents) || '';
29435
29442
  // Start a new commitment
29436
29443
  currentCommitment = {
29444
+ kind: 'known',
29437
29445
  type: definition.type,
29438
29446
  startLineNumber: i + 1,
29439
29447
  originalStartLine: line,
@@ -29443,52 +29451,90 @@
29443
29451
  break;
29444
29452
  }
29445
29453
  }
29454
+ if (foundNewCommitment) {
29455
+ continue;
29456
+ }
29457
+ const unknownCommitmentType = getBookCommitmentLineType(line);
29458
+ if (unknownCommitmentType) {
29459
+ appendCurrentCommitment(currentCommitment, commitments, unknownCommitments);
29460
+ currentCommitment = {
29461
+ kind: 'unknown',
29462
+ type: unknownCommitmentType,
29463
+ startLineNumber: i + 1,
29464
+ originalStartLine: line,
29465
+ sourceLines: [line],
29466
+ };
29467
+ continue;
29468
+ }
29446
29469
  // Check if this is a horizontal line (ends any current commitment)
29447
29470
  const isHorizontalLine = HORIZONTAL_LINE_PATTERN$1.test(line);
29448
29471
  if (isHorizontalLine) {
29449
- // Save the current commitment if it exists
29450
- if (currentCommitment) {
29451
- const fullContent = currentCommitment.contentLines.join('\n');
29452
- commitments.push({
29453
- type: currentCommitment.type,
29454
- content: _spaceTrim.spaceTrim(fullContent),
29455
- originalLine: currentCommitment.originalStartLine,
29456
- lineNumber: currentCommitment.startLineNumber,
29457
- });
29458
- currentCommitment = null;
29459
- }
29472
+ appendCurrentCommitment(currentCommitment, commitments, unknownCommitments);
29473
+ currentCommitment = null;
29460
29474
  // Add horizontal line to non-commitment lines
29461
29475
  nonCommitmentLines.push(line);
29462
29476
  continue;
29463
29477
  }
29464
- if (!foundNewCommitment) {
29465
- if (currentCommitment) {
29466
- // This line belongs to the current commitment
29467
- currentCommitment.contentLines.push(line);
29468
- }
29469
- else {
29470
- // This line is not part of any commitment
29471
- nonCommitmentLines.push(line);
29472
- }
29473
- }
29474
- }
29475
- // Don't forget to save the last commitment if it exists
29476
- if (currentCommitment) {
29477
- const fullContent = currentCommitment.contentLines.join('\n');
29478
- commitments.push({
29479
- type: currentCommitment.type,
29480
- content: _spaceTrim.spaceTrim(fullContent),
29481
- originalLine: currentCommitment.originalStartLine,
29482
- lineNumber: currentCommitment.startLineNumber,
29483
- });
29478
+ appendLineToCurrentCommitmentOrNonCommitmentLines(currentCommitment, line, nonCommitmentLines);
29484
29479
  }
29480
+ appendCurrentCommitment(currentCommitment, commitments, unknownCommitments);
29485
29481
  return {
29486
29482
  agentName,
29487
29483
  agentNameLineNumber,
29488
29484
  commitments,
29485
+ unknownCommitments,
29489
29486
  nonCommitmentLines,
29490
29487
  };
29491
29488
  }
29489
+ /**
29490
+ * Stores the current known or unknown commitment in its appropriate parsed collection.
29491
+ *
29492
+ * @param currentCommitment - Commitment-like block collected so far.
29493
+ * @param commitments - Parsed registered commitments to append to.
29494
+ * @param unknownCommitments - Parsed unregistered commitments to append to.
29495
+ *
29496
+ * @private internal utility of `parseAgentSourceWithCommitments`
29497
+ */
29498
+ function appendCurrentCommitment(currentCommitment, commitments, unknownCommitments) {
29499
+ if (!currentCommitment) {
29500
+ return;
29501
+ }
29502
+ if (currentCommitment.kind === 'unknown') {
29503
+ unknownCommitments.push({
29504
+ type: currentCommitment.type,
29505
+ originalLine: currentCommitment.originalStartLine,
29506
+ lineNumber: currentCommitment.startLineNumber,
29507
+ source: _spaceTrim.spaceTrim(currentCommitment.sourceLines.join('\n')),
29508
+ });
29509
+ return;
29510
+ }
29511
+ commitments.push({
29512
+ type: currentCommitment.type,
29513
+ content: _spaceTrim.spaceTrim(currentCommitment.contentLines.join('\n')),
29514
+ originalLine: currentCommitment.originalStartLine,
29515
+ lineNumber: currentCommitment.startLineNumber,
29516
+ });
29517
+ }
29518
+ /**
29519
+ * Adds one source line to the active commitment-like block, or to plain source content when none is active.
29520
+ *
29521
+ * @param currentCommitment - Commitment-like block currently being collected.
29522
+ * @param line - Source line to append.
29523
+ * @param nonCommitmentLines - Plain source lines to append to when no block is active.
29524
+ *
29525
+ * @private internal utility of `parseAgentSourceWithCommitments`
29526
+ */
29527
+ function appendLineToCurrentCommitmentOrNonCommitmentLines(currentCommitment, line, nonCommitmentLines) {
29528
+ if (!currentCommitment) {
29529
+ nonCommitmentLines.push(line);
29530
+ return;
29531
+ }
29532
+ if (currentCommitment.kind === 'unknown') {
29533
+ currentCommitment.sourceLines.push(line);
29534
+ return;
29535
+ }
29536
+ currentCommitment.contentLines.push(line);
29537
+ }
29492
29538
 
29493
29539
  /**
29494
29540
  * Parses parameters from text using both supported notations:
@@ -30581,7 +30627,8 @@
30581
30627
  requirements = await importReferencedFiles(requirements);
30582
30628
  requirements = appendMcpServers(requirements, agentSource);
30583
30629
  requirements = appendNonCommitmentContent(requirements, parseResult);
30584
- return appendExampleInteractions(requirements, parseResult);
30630
+ requirements = appendExampleInteractions(requirements, parseResult);
30631
+ return appendUnknownCommitmentContent(requirements, parseResult);
30585
30632
  }
30586
30633
  /**
30587
30634
  * Imports text files referenced by IMPORT commitments and appends their transformed content to the system message.
@@ -30703,6 +30750,36 @@
30703
30750
  }
30704
30751
  return appendSystemMessageSection(requirements, nonCommitmentContent);
30705
30752
  }
30753
+ /**
30754
+ * Appends unknown commitment blocks as final extra context without applying commitment side effects.
30755
+ *
30756
+ * @param requirements - Current requirements snapshot.
30757
+ * @param parseResult - Parsed source including unknown commitment blocks.
30758
+ * @returns Requirements with unknown commitment context appended at the end of the system message.
30759
+ *
30760
+ * @private internal utility of `augmentAgentModelRequirementsFromSource`
30761
+ */
30762
+ function appendUnknownCommitmentContent(requirements, parseResult) {
30763
+ const unknownCommitmentContent = getUnknownCommitmentContent(parseResult);
30764
+ if (!unknownCommitmentContent) {
30765
+ return requirements;
30766
+ }
30767
+ return appendSystemMessageSection(requirements, unknownCommitmentContent);
30768
+ }
30769
+ /**
30770
+ * Joins unknown commitment blocks into their final extra-context representation.
30771
+ *
30772
+ * @param parseResult - Parsed source including unknown commitment blocks.
30773
+ * @returns Unknown commitment source blocks in their original order.
30774
+ *
30775
+ * @private internal utility of `appendUnknownCommitmentContent`
30776
+ */
30777
+ function getUnknownCommitmentContent(parseResult) {
30778
+ return parseResult.unknownCommitments
30779
+ .map((commitment) => commitment.source)
30780
+ .filter(Boolean)
30781
+ .join('\n\n');
30782
+ }
30706
30783
  /**
30707
30784
  * Collects plain-text lines that were not parsed as commitments and should still become part of the final system message.
30708
30785
  *