@promptbook/wizard 0.104.0-2 → 0.104.0-3

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
@@ -36,7 +36,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
36
36
  * @generated
37
37
  * @see https://github.com/webgptorg/promptbook
38
38
  */
39
- const PROMPTBOOK_ENGINE_VERSION = '0.104.0-2';
39
+ const PROMPTBOOK_ENGINE_VERSION = '0.104.0-3';
40
40
  /**
41
41
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
42
42
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -5828,7 +5828,7 @@ class OpenAiCompatibleExecutionTools {
5828
5828
  let threadMessages = [];
5829
5829
  if ('thread' in prompt && Array.isArray(prompt.thread)) {
5830
5830
  threadMessages = prompt.thread.map((msg) => ({
5831
- role: msg.role === 'assistant' ? 'assistant' : 'user',
5831
+ role: msg.sender === 'assistant' ? 'assistant' : 'user',
5832
5832
  content: msg.content,
5833
5833
  }));
5834
5834
  }
@@ -17137,17 +17137,64 @@ function parseAgentSourceWithCommitments(agentSource) {
17137
17137
  };
17138
17138
  }
17139
17139
  const lines = agentSource.split('\n');
17140
- const agentName = (((_a = lines[0]) === null || _a === void 0 ? void 0 : _a.trim()) || null);
17140
+ let agentName = null;
17141
+ let agentNameLineIndex = -1;
17142
+ // Find the agent name: first non-empty line that is not a commitment and not a horizontal line
17143
+ for (let i = 0; i < lines.length; i++) {
17144
+ const line = lines[i];
17145
+ if (line === undefined) {
17146
+ continue;
17147
+ }
17148
+ const trimmed = line.trim();
17149
+ if (!trimmed) {
17150
+ continue;
17151
+ }
17152
+ const isHorizontal = HORIZONTAL_LINE_PATTERN.test(line);
17153
+ if (isHorizontal) {
17154
+ continue;
17155
+ }
17156
+ let isCommitment = false;
17157
+ for (const definition of COMMITMENT_REGISTRY) {
17158
+ const typeRegex = definition.createTypeRegex();
17159
+ const match = typeRegex.exec(trimmed);
17160
+ if (match && ((_a = match.groups) === null || _a === void 0 ? void 0 : _a.type)) {
17161
+ isCommitment = true;
17162
+ break;
17163
+ }
17164
+ }
17165
+ if (!isCommitment) {
17166
+ agentName = trimmed;
17167
+ agentNameLineIndex = i;
17168
+ break;
17169
+ }
17170
+ }
17141
17171
  const commitments = [];
17142
17172
  const nonCommitmentLines = [];
17143
- // Always add the first line (agent name) to non-commitment lines
17144
- if (lines[0] !== undefined) {
17145
- nonCommitmentLines.push(lines[0]);
17173
+ // Add lines before agentName that are horizontal lines (they are non-commitment)
17174
+ for (let i = 0; i < agentNameLineIndex; i++) {
17175
+ const line = lines[i];
17176
+ if (line === undefined) {
17177
+ continue;
17178
+ }
17179
+ const trimmed = line.trim();
17180
+ if (!trimmed) {
17181
+ continue;
17182
+ }
17183
+ const isHorizontal = HORIZONTAL_LINE_PATTERN.test(line);
17184
+ if (isHorizontal) {
17185
+ nonCommitmentLines.push(line);
17186
+ }
17187
+ // Note: Commitments before agentName are not added to nonCommitmentLines
17188
+ }
17189
+ // Add the agent name line to non-commitment lines
17190
+ if (agentNameLineIndex >= 0) {
17191
+ nonCommitmentLines.push(lines[agentNameLineIndex]);
17146
17192
  }
17147
17193
  // Parse commitments with multiline support
17148
17194
  let currentCommitment = null;
17149
- // Process lines starting from the second line (skip agent name)
17150
- for (let i = 1; i < lines.length; i++) {
17195
+ // Process lines starting from after the agent name line
17196
+ const startIndex = agentNameLineIndex >= 0 ? agentNameLineIndex + 1 : 0;
17197
+ for (let i = startIndex; i < lines.length; i++) {
17151
17198
  const line = lines[i];
17152
17199
  if (line === undefined) {
17153
17200
  continue;