@promptbook/components 0.112.0-119 → 0.112.0-121

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 CHANGED
@@ -40,7 +40,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
40
40
  * @generated
41
41
  * @see https://github.com/webgptorg/promptbook
42
42
  */
43
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-119';
43
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-121';
44
44
  /**
45
45
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
46
46
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -22706,10 +22706,12 @@ function useBookEditorMonacoInteractions({ editor, handleFiles, }) {
22706
22706
  const AGENT_REFERENCE_URL_PATTERN = 'https?:\\/\\/[^\\s{}]+';
22707
22707
  /**
22708
22708
  * Regex source for compact `@id` references.
22709
+ * The negative lookbehind `(?<!\S)` ensures the `@` is preceded only by whitespace or is at the
22710
+ * start of the string, so email addresses like `team@foo.bar` are not treated as agent references.
22709
22711
  *
22710
22712
  * @private function of BookEditorMonaco
22711
22713
  */
22712
- const AGENT_REFERENCE_AT_PATTERN = '@[A-Za-z0-9_-]+';
22714
+ const AGENT_REFERENCE_AT_PATTERN = '(?<!\\S)@[A-Za-z0-9_-]+';
22713
22715
  /**
22714
22716
  * Regex source for braced references (`{Agent}`, `{Agent Name}`, `{https://...}`).
22715
22717
  *
@@ -22723,35 +22725,22 @@ const AGENT_REFERENCE_BRACED_PATTERN = '\\{[^{}\\r\\n]+\\}';
22723
22725
  */
22724
22726
  const AGENT_REFERENCE_COMMITMENT_TYPES = ['FROM', 'IMPORT', 'IMPORTS', 'TEAM'];
22725
22727
  /**
22726
- * Commitment types known to the browser editor tokenizer.
22728
+ * Regex matching any line that starts with one or more all-uppercase words (minimum 2 characters each).
22729
+ * Used to detect commitment line boundaries without a hardcoded list of commitment types.
22730
+ *
22731
+ * Single-letter uppercase words (e.g. "V", "A") are excluded to avoid false positives with
22732
+ * natural-language sentences that start with a short uppercase word.
22727
22733
  *
22728
22734
  * @private function of BookEditorMonaco
22729
22735
  */
22730
- const BOOK_EDITOR_COMMITMENT_TYPES = [
22731
- 'PERSONA',
22732
- 'KNOWLEDGE',
22733
- 'TASK',
22734
- 'PROMPT',
22735
- 'EXPECT',
22736
- 'FORMAT',
22737
- 'MODEL',
22738
- 'SAMPLE',
22739
- 'FROM',
22740
- 'IMPORT',
22741
- 'IMPORTS',
22742
- 'TEAM',
22743
- 'TODO',
22744
- 'NOTE',
22745
- 'NOTES',
22746
- 'NONCE',
22747
- ];
22736
+ const DYNAMIC_COMMITMENT_REGEX = /^\s*[A-Z][A-Z0-9]+(?:\s+[A-Z][A-Z0-9]+)*(?=\s|$)/;
22748
22737
  /**
22749
22738
  * Regex pattern to match horizontal lines.
22750
22739
  *
22751
22740
  * @private function of BookEditorMonaco
22752
22741
  */
22753
22742
  const HORIZONTAL_LINE_PATTERN$1 = /^[\s]*[-_*][\s]*[-_*][\s]*[-_*][\s]*[-_*]*[\s]*$/;
22754
- const BOOK_EDITOR_COMMITMENT_LINE_REGEX = createCommitmentLineRegex(BOOK_EDITOR_COMMITMENT_TYPES);
22743
+ const BOOK_EDITOR_COMMITMENT_LINE_REGEX = DYNAMIC_COMMITMENT_REGEX;
22755
22744
  const AGENT_REFERENCE_COMMITMENT_LINE_REGEX = createCommitmentLineRegex(AGENT_REFERENCE_COMMITMENT_TYPES);
22756
22745
  /**
22757
22746
  * Agent reference helpers for `BookEditorMonaco`.
@@ -22850,12 +22839,6 @@ const extractAgentReferenceMatches = (content) => {
22850
22839
  continue;
22851
22840
  }
22852
22841
  const absoluteIndex = lineStartOffset + indexInLine;
22853
- if (token.startsWith('@') && absoluteIndex > 0) {
22854
- const previousChar = content[absoluteIndex - 1] || '';
22855
- if (/[A-Za-z0-9_.-]/.test(previousChar)) {
22856
- continue;
22857
- }
22858
- }
22859
22842
  const value = extractAgentReferenceValue(token);
22860
22843
  const url = resolveAgentReferenceToUrl(value);
22861
22844
  if (!url) {
@@ -22967,6 +22950,7 @@ function findBookBodyStartLineIndex(sourceLines) {
22967
22950
  * @private function of BookEditorMonaco
22968
22951
  */
22969
22952
  const BookEditorMonacoTokenization = {
22953
+ DYNAMIC_COMMITMENT_REGEX,
22970
22954
  AGENT_URL_REFERENCE_REGEX,
22971
22955
  AGENT_REFERENCE_TOKEN_REGEX,
22972
22956
  AGENT_REFERENCE_BRACED_REGEX,
@@ -23115,28 +23099,18 @@ function createCommitmentRegex(commitmentTypes) {
23115
23099
  return new RegExp(`^\\s*(${commitmentPatterns})(?=\\s|$)`);
23116
23100
  }
23117
23101
  /**
23118
- * Creates regex-token-state triples for note-like commitment groups available in this runtime.
23102
+ * Creates regex-token-state triples for note-like commitment groups (TODO/NOTE/NOTES/NONCE).
23119
23103
  *
23120
- * @param commitmentTypes - All known commitment types.
23121
23104
  * @returns Tokenization metadata for TODO/NOTE-like commitment groups.
23122
23105
  *
23123
23106
  * @private function of BookEditorMonaco
23124
23107
  */
23125
- function createNoteLikeCommitmentStates(commitmentTypes) {
23126
- const commitmentTypeSet = new Set(commitmentTypes.map((type) => type.toUpperCase()));
23127
- return NOTE_LIKE_COMMITMENT_GROUPS.flatMap((group) => {
23128
- const matchingCommitmentTypes = group.commitmentTypes.filter((type) => commitmentTypeSet.has(type.toUpperCase()));
23129
- if (matchingCommitmentTypes.length === 0) {
23130
- return [];
23131
- }
23132
- return [
23133
- {
23134
- regex: createCommitmentRegex(matchingCommitmentTypes),
23135
- token: group.token,
23136
- state: group.state,
23137
- },
23138
- ];
23139
- });
23108
+ function createNoteLikeCommitmentStates() {
23109
+ return NOTE_LIKE_COMMITMENT_GROUPS.map((group) => ({
23110
+ regex: createCommitmentRegex([...group.commitmentTypes]),
23111
+ token: group.token,
23112
+ state: group.state,
23113
+ }));
23140
23114
  }
23141
23115
  /**
23142
23116
  * Builds tokenizer rules that switch between commitment-level Monaco states.
@@ -23188,7 +23162,7 @@ function ensureBookEditorMonacoLanguage(monaco, theme = BOOK_EDITOR_RENDER_THEME
23188
23162
  monacoWithLanguageState[BOOK_EDITOR_LANGUAGE_INITIALIZED_FLAG] = true;
23189
23163
  monacoWithLanguageState[BOOK_EDITOR_THEME_MODE_FLAG] = renderedTheme;
23190
23164
  monaco.languages.register({ id: BookEditorMonacoConstants.BOOK_LANGUAGE_ID });
23191
- const commitmentTypes = [
23165
+ const completionCommitmentTypes = [
23192
23166
  'GOAL',
23193
23167
  'RULE',
23194
23168
  'PERSONA',
@@ -23207,11 +23181,8 @@ function ensureBookEditorMonacoLanguage(monaco, theme = BOOK_EDITOR_RENDER_THEME
23207
23181
  ...NOTE_COMMITMENT_TYPES,
23208
23182
  'REMOVE',
23209
23183
  ];
23210
- const completionCommitmentTypes = [...commitmentTypes];
23211
- const noteLikeCommitmentTypeSet = new Set([...TODO_COMMITMENT_TYPES, ...NOTE_COMMITMENT_TYPES]);
23212
- const noteLikeCommitmentStates = createNoteLikeCommitmentStates(commitmentTypes);
23213
- const executableCommitmentTypes = commitmentTypes.filter((type) => !noteLikeCommitmentTypeSet.has(type.toUpperCase()));
23214
- const commitmentRegex = createCommitmentRegex(executableCommitmentTypes);
23184
+ const noteLikeCommitmentStates = createNoteLikeCommitmentStates();
23185
+ const commitmentRegex = BookEditorMonacoTokenization.DYNAMIC_COMMITMENT_REGEX;
23215
23186
  const agentReferenceCommitmentRegex = /^\s*(FROM|IMPORT|IMPORTS|TEAM)(?=\s|$)/;
23216
23187
  const commitmentTransitionRules = createCommitmentTransitionRules(noteLikeCommitmentStates, agentReferenceCommitmentRegex, commitmentRegex);
23217
23188
  const parameterRegex = /@([a-zA-Z0-9_á-žÁ-Žč-řČ-Řš-žŠ-Žа-яА-ЯёЁ]+)/;
@@ -23237,7 +23208,6 @@ function ensureBookEditorMonacoLanguage(monaco, theme = BOOK_EDITOR_RENDER_THEME
23237
23208
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
23238
23209
  const todoCommitmentBodyRules = createNoteLikeBodyRules('todo-commitment', commitmentTransitionRules);
23239
23210
  monaco.languages.setMonarchTokensProvider(BookEditorMonacoConstants.BOOK_LANGUAGE_ID, {
23240
- ignoreCase: true,
23241
23211
  tokenizer: {
23242
23212
  root: [
23243
23213
  [/^\s*$/, 'empty'],
@@ -50126,7 +50096,9 @@ class OpenAiAgentKitExecutionToolsToolBuilder {
50126
50096
  if (!executionTools || !executionTools.script) {
50127
50097
  throw new PipelineExecutionError(`Model requested tools but no executionTools.script were provided in OpenAiAgentKitExecutionTools options`);
50128
50098
  }
50129
- return Array.isArray(executionTools.script) ? executionTools.script : [executionTools.script];
50099
+ return Array.isArray(executionTools.script)
50100
+ ? executionTools.script
50101
+ : [executionTools.script];
50130
50102
  }
50131
50103
  /**
50132
50104
  * Resolves the assistant-visible AgentKit tool response while preserving structured tool result data.