@promptbook/core 0.112.0-42 → 0.112.0-44

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 (30) hide show
  1. package/README.md +10 -3
  2. package/esm/index.es.js +208 -57
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/src/book-2.0/agent-source/AgentBasicInformation.d.ts +2 -1
  5. package/esm/src/book-2.0/agent-source/TeammateProfileResolver.d.ts +2 -1
  6. package/esm/src/book-components/Chat/Chat/ChatProps.d.ts +1 -1
  7. package/esm/src/cli/cli-commands/coder/getTypescriptModule.d.ts +19 -0
  8. package/esm/src/cli/cli-commands/coder/getTypescriptModule.test.d.ts +1 -0
  9. package/esm/src/cli/cli-commands/coder/mergeStringRecordJsonFile.test.d.ts +1 -0
  10. package/esm/src/commitments/PERSONA/PERSONA.d.ts +7 -0
  11. package/esm/src/llm-providers/agent/Agent.test.d.ts +1 -0
  12. package/esm/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +4 -0
  13. package/esm/src/llm-providers/agent/AgentOptions.d.ts +8 -0
  14. package/esm/src/llm-providers/agent/CreateAgentLlmExecutionToolsOptions.d.ts +9 -0
  15. package/esm/src/version.d.ts +1 -1
  16. package/package.json +1 -1
  17. package/umd/index.umd.js +208 -57
  18. package/umd/index.umd.js.map +1 -1
  19. package/umd/src/book-2.0/agent-source/AgentBasicInformation.d.ts +2 -1
  20. package/umd/src/book-2.0/agent-source/TeammateProfileResolver.d.ts +2 -1
  21. package/umd/src/book-components/Chat/Chat/ChatProps.d.ts +1 -1
  22. package/umd/src/cli/cli-commands/coder/getTypescriptModule.d.ts +19 -0
  23. package/umd/src/cli/cli-commands/coder/getTypescriptModule.test.d.ts +1 -0
  24. package/umd/src/cli/cli-commands/coder/mergeStringRecordJsonFile.test.d.ts +1 -0
  25. package/umd/src/commitments/PERSONA/PERSONA.d.ts +7 -0
  26. package/umd/src/llm-providers/agent/Agent.test.d.ts +1 -0
  27. package/umd/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +4 -0
  28. package/umd/src/llm-providers/agent/AgentOptions.d.ts +8 -0
  29. package/umd/src/llm-providers/agent/CreateAgentLlmExecutionToolsOptions.d.ts +9 -0
  30. package/umd/src/version.d.ts +1 -1
@@ -66,7 +66,8 @@ export type AgentBasicInformation = {
66
66
  permanentId?: string_agent_permanent_id;
67
67
  /**
68
68
  * Optional description of the agent
69
- * This is the line starting with "PERSONA"
69
+ * This is derived from the last `GOAL` / `GOALS` commitment,
70
+ * falling back to deprecated `PERSONA` / `PERSONAE` for backward compatibility.
70
71
  */
71
72
  personaDescription: string | null;
72
73
  /**
@@ -9,7 +9,8 @@ export type TeammateProfile = {
9
9
  */
10
10
  readonly agentName: string;
11
11
  /**
12
- * Short description of what the agent does, from its PERSONA commitment.
12
+ * Short profile text for what the agent does, from the last GOAL commitment
13
+ * or deprecated PERSONA fallback.
13
14
  */
14
15
  readonly personaDescription: string | null;
15
16
  };
@@ -745,7 +745,7 @@ export type ChatProps = {
745
745
  * - `BUBBLE_MODE`: keeps the default bubble appearance for all messages.
746
746
  * - `ARTICLE_MODE`: keeps user bubbles while rendering assistant replies as borderless article blocks.
747
747
  *
748
- * @default 'BUBBLE_MODE'
748
+ * @default 'ARTICLE_MODE'
749
749
  */
750
750
  readonly CHAT_VISUAL_MODE?: ChatVisualMode;
751
751
  /**
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Possible runtime shapes returned when importing the `typescript` package.
3
+ */
4
+ type ImportedTypescriptModule = typeof import('typescript') | {
5
+ default: typeof import('typescript');
6
+ };
7
+ /**
8
+ * Loads the TypeScript runtime used for parsing JSONC-style project files.
9
+ *
10
+ * @private internal utility of `coder init`
11
+ */
12
+ export declare function getTypescriptModule(): Promise<typeof import('typescript')>;
13
+ /**
14
+ * Normalizes CommonJS-via-`default` and direct namespace imports of TypeScript.
15
+ *
16
+ * @private internal utility of `getTypescriptModule`
17
+ */
18
+ export declare function normalizeImportedTypescriptModule(importedTypescriptModule: ImportedTypescriptModule): typeof import('typescript');
19
+ export {};
@@ -29,6 +29,13 @@ export declare class PersonaCommitmentDefinition extends BaseCommitmentDefinitio
29
29
  * Short one-line description of PERSONA.
30
30
  */
31
31
  get description(): string;
32
+ /**
33
+ * Optional UI/docs-only deprecation metadata.
34
+ */
35
+ get deprecation(): {
36
+ readonly message: "Use `GOAL` for agent profile text and inheritance-safe rewrites.";
37
+ readonly replacedBy: readonly ["GOAL"];
38
+ };
32
39
  /**
33
40
  * Icon for this commitment.
34
41
  */
@@ -0,0 +1 @@
1
+ export {};
@@ -44,6 +44,10 @@ export declare class AgentLlmExecutionTools implements LlmExecutionTools {
44
44
  * Cached parsed agent information
45
45
  */
46
46
  private _cachedAgentInfo;
47
+ /**
48
+ * Optional server-precomputed model requirements reused until the source changes.
49
+ */
50
+ private precomputedModelRequirements;
47
51
  /**
48
52
  * Creates new AgentLlmExecutionTools
49
53
  *
@@ -1,4 +1,5 @@
1
1
  import type { string_book } from '../../book-2.0/agent-source/string_book';
2
+ import type { AgentModelRequirements } from '../../book-2.0/agent-source/AgentModelRequirements';
2
3
  import type { CommonToolsOptions } from '../../execution/CommonToolsOptions';
3
4
  import type { ExecutionTools } from '../../execution/ExecutionTools';
4
5
  import type { Updatable } from '../../types/Updatable';
@@ -27,6 +28,13 @@ export type AgentOptions = CommonToolsOptions & {
27
28
  * The source of the agent
28
29
  */
29
30
  agentSource: Updatable<string_book>;
31
+ /**
32
+ * Optional precomputed model requirements reused until `agentSource` changes.
33
+ *
34
+ * This keeps the actual runtime prompt aligned with server-prepared requirements
35
+ * such as compact-reference-resolved `TEAM` tools.
36
+ */
37
+ precomputedModelRequirements?: AgentModelRequirements;
30
38
  /**
31
39
  * Teacher agent for self-learning
32
40
  *
@@ -1,4 +1,5 @@
1
1
  import type { string_book } from '../../book-2.0/agent-source/string_book';
2
+ import type { AgentModelRequirements } from '../../book-2.0/agent-source/AgentModelRequirements';
2
3
  import type { CommonToolsOptions } from '../../execution/CommonToolsOptions';
3
4
  import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
4
5
  import type { OpenAiAgentKitExecutionTools } from '../openai/OpenAiAgentKitExecutionTools';
@@ -25,4 +26,12 @@ export type CreateAgentLlmExecutionToolsOptions = CommonToolsOptions & {
25
26
  * The agent source string that defines the agent's behavior
26
27
  */
27
28
  agentSource: string_book;
29
+ /**
30
+ * Optional precomputed model requirements reused until `agentSource` changes.
31
+ *
32
+ * This is useful for runtimes such as Agents Server that already resolved compact
33
+ * references (for example in `TEAM`) and need the executed prompt to stay aligned
34
+ * with the server-prepared tool list.
35
+ */
36
+ precomputedModelRequirements?: AgentModelRequirements;
28
37
  };
@@ -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.112.0-41`).
18
+ * It follows semantic versioning (e.g., `0.112.0-43`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/core",
3
- "version": "0.112.0-42",
3
+ "version": "0.112.0-44",
4
4
  "description": "Promptbook: Turn your company's scattered knowledge into AI ready books",
5
5
  "private": false,
6
6
  "sideEffects": false,
package/umd/index.umd.js CHANGED
@@ -27,7 +27,7 @@
27
27
  * @generated
28
28
  * @see https://github.com/webgptorg/promptbook
29
29
  */
30
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-42';
30
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-44';
31
31
  /**
32
32
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
33
33
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -7867,7 +7867,7 @@
7867
7867
  systemMessage: '',
7868
7868
  promptSuffix: '',
7869
7869
  // modelName: 'gpt-5',
7870
- modelName: 'gemini-2.5-flash-lite',
7870
+ modelName: 'gpt-5.4-mini',
7871
7871
  temperature: 0.7,
7872
7872
  topP: 0.9,
7873
7873
  topK: 50,
@@ -11409,7 +11409,7 @@
11409
11409
  * Short one-line description of GOAL.
11410
11410
  */
11411
11411
  get description() {
11412
- return 'Define main **goals** the AI assistant should achieve, with later goals having higher priority.';
11412
+ return 'Define the effective agent **goal**; when multiple goals exist, only the last one stays effective.';
11413
11413
  }
11414
11414
  /**
11415
11415
  * Icon for this commitment.
@@ -11424,12 +11424,14 @@
11424
11424
  return spacetrim.spaceTrim(`
11425
11425
  # ${this.type}
11426
11426
 
11427
- Defines the main goal which should be achieved by the AI assistant. There can be multiple goals, and later goals are more important than earlier goals.
11427
+ Defines the main goal which should be achieved by the AI assistant.
11428
+ There can be multiple goals in source, but after inheritance/source rewriting only the last \`GOAL\` /\`GOALS\` remains effective.
11428
11429
 
11429
11430
  ## Key aspects
11430
11431
 
11431
11432
  - Both terms work identically and can be used interchangeably.
11432
- - Later goals have higher priority and can override earlier goals.
11433
+ - Later goals overwrite earlier goals.
11434
+ - The public agent profile text is derived from the last goal.
11433
11435
  - Goals provide clear direction and purpose for the agent's responses.
11434
11436
  - Goals influence decision-making and response prioritization.
11435
11437
 
@@ -11442,9 +11444,7 @@
11442
11444
  \`\`\`book
11443
11445
  Customer Support Agent
11444
11446
 
11445
- PERSONA You are a helpful customer support representative
11446
11447
  GOAL Resolve customer issues quickly and efficiently
11447
- GOAL Maintain high customer satisfaction scores
11448
11448
  GOAL Always follow company policies and procedures
11449
11449
  RULE Be polite and professional at all times
11450
11450
  \`\`\`
@@ -11452,9 +11452,7 @@
11452
11452
  \`\`\`book
11453
11453
  Educational Assistant
11454
11454
 
11455
- PERSONA You are an educational assistant specializing in mathematics
11456
11455
  GOAL Help students understand mathematical concepts clearly
11457
- GOAL Encourage critical thinking and problem-solving skills
11458
11456
  GOAL Ensure all explanations are age-appropriate and accessible
11459
11457
  STYLE Use simple language and provide step-by-step explanations
11460
11458
  \`\`\`
@@ -11462,9 +11460,7 @@
11462
11460
  \`\`\`book
11463
11461
  Safety-First Assistant
11464
11462
 
11465
- PERSONA You are a general-purpose AI assistant
11466
11463
  GOAL Be helpful and informative in all interactions
11467
- GOAL Provide accurate and reliable information
11468
11464
  GOAL Always prioritize user safety and ethical guidelines
11469
11465
  RULE Never provide harmful or dangerous advice
11470
11466
  \`\`\`
@@ -14323,7 +14319,16 @@
14323
14319
  * Short one-line description of PERSONA.
14324
14320
  */
14325
14321
  get description() {
14326
- return 'Define who the agent is: background, expertise, and personality.';
14322
+ return 'Deprecated legacy profile commitment. Prefer `GOAL` for agent profile text and inheritance-safe rewrites.';
14323
+ }
14324
+ /**
14325
+ * Optional UI/docs-only deprecation metadata.
14326
+ */
14327
+ get deprecation() {
14328
+ return {
14329
+ message: 'Use `GOAL` for agent profile text and inheritance-safe rewrites.',
14330
+ replacedBy: ['GOAL'],
14331
+ };
14327
14332
  }
14328
14333
  /**
14329
14334
  * Icon for this commitment.
@@ -14338,16 +14343,24 @@
14338
14343
  return spacetrim.spaceTrim(`
14339
14344
  # ${this.type}
14340
14345
 
14341
- Defines who the agent is, their background, expertise, and personality traits.
14346
+ Deprecated legacy commitment that defines who the agent is, their background, expertise, and personality traits.
14342
14347
 
14343
- ## Key aspects
14348
+ ## Migration
14344
14349
 
14345
- - Multiple \`PERSONA\` and \`PERSONAE\` commitments are merged together.
14346
- - Both terms work identically and can be used interchangeably.
14347
- - If they are in conflict, the last one takes precedence.
14348
- - You can write persona content in multiple lines.
14350
+ - Existing \`${this.type}\` books still parse and compile.
14351
+ - New books should prefer \`GOAL\`.
14352
+ - Agent profile rendering now prefers the last \`GOAL\` and only falls back to \`${this.type}\` when no goal exists.
14353
+ - Runtime compilation keeps the legacy multi-\`PERSONA\` merge behavior for backward compatibility.
14349
14354
 
14350
- ## Examples
14355
+ ## Preferred replacement
14356
+
14357
+ \`\`\`book
14358
+ Programming Assistant
14359
+
14360
+ GOAL Help the user solve programming problems with practical TypeScript and React guidance.
14361
+ \`\`\`
14362
+
14363
+ ## Legacy compatibility example
14351
14364
 
14352
14365
  \`\`\`book
14353
14366
  Programming Assistant
@@ -15055,6 +15068,15 @@
15055
15068
  * Map of team tool titles.
15056
15069
  */
15057
15070
  const teamToolTitles = {};
15071
+ /**
15072
+ * Shared TEAM usage rules appended ahead of teammate listings.
15073
+ *
15074
+ * @private
15075
+ */
15076
+ const TEAM_SYSTEM_MESSAGE_GUIDANCE_LINES = [
15077
+ '- If a teammate is relevant to the request, consult that teammate using the matching tool.',
15078
+ '- Do not ask the user for information that a listed teammate can provide directly.',
15079
+ ];
15058
15080
  /**
15059
15081
  * Constant for remote agents by Url.
15060
15082
  */
@@ -15103,7 +15125,7 @@
15103
15125
  \`\`\`book
15104
15126
  Legal Assistant
15105
15127
 
15106
- PERSONA An expert software developer
15128
+ GOAL Get expert software-development advice from the teammate when legal discussion needs technical context.
15107
15129
  TEAM You can talk with http://localhost:4440/agents/GMw67JN8TXxN7y to discuss the legal aspects.
15108
15130
  \`\`\`
15109
15131
  `);
@@ -15144,12 +15166,9 @@
15144
15166
  if (updatedTools.some((tool) => tool.name === entry.toolName)) {
15145
15167
  continue;
15146
15168
  }
15147
- const toolDescription = entry.description
15148
- ? `Consult teammate ${entry.teammate.label}\n${entry.description}`
15149
- : `Consult teammate ${entry.teammate.label}`;
15150
15169
  updatedTools.push({
15151
15170
  name: entry.toolName,
15152
- description: toolDescription,
15171
+ description: buildTeamToolDescription(entry),
15153
15172
  parameters: {
15154
15173
  type: 'object',
15155
15174
  properties: {
@@ -15218,22 +15237,72 @@
15218
15237
  /**
15219
15238
  * Builds the textual TEAM section body for the final system message.
15220
15239
  *
15221
- * Each teammate is listed with its tool name and, when available, a one-line description.
15222
- * Uses `spaceTrim` to ensure consistent whitespace and indentation.
15240
+ * Each teammate is listed with its tool name, TEAM instructions, and optional profile hints.
15223
15241
  */
15224
15242
  function buildTeamSystemMessageBody(teamEntries) {
15225
- const lines = teamEntries.map((entry, index) => {
15226
- const toolLine = `${index + 1}) ${entry.teammate.label} tool \`${entry.toolName}\``;
15227
- if (!entry.description) {
15228
- return toolLine;
15229
- }
15230
- return spacetrim.spaceTrim(`
15231
- ${toolLine}
15232
- ${entry.description}
15233
- `);
15234
- });
15243
+ const lines = [
15244
+ ...TEAM_SYSTEM_MESSAGE_GUIDANCE_LINES,
15245
+ '',
15246
+ ...teamEntries.map((entry, index) => {
15247
+ const toolLine = `${index + 1}) ${entry.teammate.label} tool \`${entry.toolName}\``;
15248
+ const detailLines = collectTeamEntryDetails(entry).map(formatTeamEntryDetailLine);
15249
+ return [toolLine, ...detailLines].join('\n');
15250
+ }),
15251
+ ];
15235
15252
  return lines.join('\n');
15236
15253
  }
15254
+ /**
15255
+ * Builds the model-visible description for one teammate tool.
15256
+ *
15257
+ * @private
15258
+ */
15259
+ function buildTeamToolDescription(entry) {
15260
+ const detailLines = collectTeamEntryDetails(entry).map(({ label, content }) => `${label}: ${content}`);
15261
+ return [`Consult teammate ${entry.teammate.label}`, ...detailLines].join('\n');
15262
+ }
15263
+ /**
15264
+ * Collects structured teammate details that should stay visible to the model.
15265
+ *
15266
+ * @private
15267
+ */
15268
+ function collectTeamEntryDetails(entry) {
15269
+ var _a;
15270
+ const details = [];
15271
+ const instructions = entry.teammate.instructions.trim();
15272
+ const description = ((_a = entry.description) === null || _a === void 0 ? void 0 : _a.trim()) || '';
15273
+ if (instructions) {
15274
+ details.push({
15275
+ label: 'TEAM instructions',
15276
+ content: instructions,
15277
+ });
15278
+ }
15279
+ if (description) {
15280
+ details.push({
15281
+ label: 'Profile',
15282
+ content: description,
15283
+ });
15284
+ }
15285
+ return details;
15286
+ }
15287
+ /**
15288
+ * Formats one teammate detail line for the TEAM system-message section.
15289
+ *
15290
+ * @private
15291
+ */
15292
+ function formatTeamEntryDetailLine(detail) {
15293
+ return indentMultilineText(`${detail.label}: ${detail.content}`, ' ');
15294
+ }
15295
+ /**
15296
+ * Indents all lines of one potentially multi-line text block.
15297
+ *
15298
+ * @private
15299
+ */
15300
+ function indentMultilineText(text, prefix) {
15301
+ return text
15302
+ .split('\n')
15303
+ .map((line) => `${prefix}${line}`)
15304
+ .join('\n');
15305
+ }
15237
15306
  /**
15238
15307
  * Registers tool function and title for a teammate tool.
15239
15308
  */
@@ -21927,6 +21996,15 @@
21927
21996
  * @private internal constant of `createAgentModelRequirementsWithCommitments`
21928
21997
  */
21929
21998
  const DELETE_COMMITMENT_TYPES = new Set(['DELETE', 'CANCEL', 'DISCARD', 'REMOVE']);
21999
+ /**
22000
+ * Commitments whose earlier occurrences are overwritten by the last occurrence in source order.
22001
+ *
22002
+ * @private internal constant of `createAgentModelRequirementsWithCommitments`
22003
+ */
22004
+ const OVERWRITTEN_COMMITMENT_GROUP_BY_TYPE = new Map([
22005
+ ['GOAL', 'GOAL'],
22006
+ ['GOALS', 'GOAL'],
22007
+ ]);
21930
22008
  /**
21931
22009
  * Regex pattern matching markdown horizontal lines that should not be copied into the final system message.
21932
22010
  *
@@ -21977,7 +22055,7 @@
21977
22055
  */
21978
22056
  async function createAgentModelRequirementsWithCommitments(agentSource, modelName, options) {
21979
22057
  const parseResult = parseAgentSourceWithCommitments(agentSource);
21980
- const filteredCommitments = filterDeletedCommitments(parseResult.commitments);
22058
+ const filteredCommitments = filterOverwrittenCommitments(filterDeletedCommitments(parseResult.commitments));
21981
22059
  let requirements = createInitialAgentModelRequirements(parseResult.agentName, modelName);
21982
22060
  requirements = await applyCommitmentsToRequirements(requirements, filteredCommitments, options);
21983
22061
  requirements = aggregateUseCommitmentSystemMessages(requirements, filteredCommitments);
@@ -21988,6 +22066,35 @@
21988
22066
  requirements = await applyPendingInlineKnowledgeSources(requirements, options === null || options === void 0 ? void 0 : options.inlineKnowledgeSourceUploader);
21989
22067
  return finalizeRequirements(requirements);
21990
22068
  }
22069
+ /**
22070
+ * Removes earlier commitments that are overwritten by later commitments of the same semantic group.
22071
+ *
22072
+ * This currently keeps only the last `GOAL` / `GOALS` commitment so inheritance rewrites
22073
+ * and multi-goal sources expose one effective goal to the runtime.
22074
+ *
22075
+ * @param commitments - Parsed commitments after DELETE-like filtering.
22076
+ * @returns Commitments with overwritten entries removed while preserving source order.
22077
+ *
22078
+ * @private internal utility of `createAgentModelRequirementsWithCommitments`
22079
+ */
22080
+ function filterOverwrittenCommitments(commitments) {
22081
+ const seenOverwriteGroups = new Set();
22082
+ const keptCommitments = [];
22083
+ for (let index = commitments.length - 1; index >= 0; index--) {
22084
+ const commitment = commitments[index];
22085
+ const overwriteGroup = OVERWRITTEN_COMMITMENT_GROUP_BY_TYPE.get(commitment.type);
22086
+ if (!overwriteGroup) {
22087
+ keptCommitments.push(commitment);
22088
+ continue;
22089
+ }
22090
+ if (seenOverwriteGroups.has(overwriteGroup)) {
22091
+ continue;
22092
+ }
22093
+ seenOverwriteGroups.add(overwriteGroup);
22094
+ keptCommitments.push(commitment);
22095
+ }
22096
+ return keptCommitments.reverse();
22097
+ }
21991
22098
  /**
21992
22099
  * Creates the initial requirements object with the parsed agent name stored in metadata and an optional model override.
21993
22100
  *
@@ -22621,7 +22728,7 @@
22621
22728
  function parseAgentSource(agentSource) {
22622
22729
  const parseResult = parseAgentSourceWithCommitments(agentSource);
22623
22730
  const resolvedAgentName = parseResult.agentName || createDefaultAgentName(agentSource);
22624
- const personaDescription = extractPersonaDescription(parseResult.commitments);
22731
+ const personaDescription = extractAgentProfileText(parseResult.commitments);
22625
22732
  const initialMessage = extractInitialMessage(parseResult.commitments);
22626
22733
  const parsedProfile = extractParsedAgentProfile(parseResult.commitments);
22627
22734
  ensureMetaFullname(parsedProfile.meta, resolvedAgentName);
@@ -22725,25 +22832,33 @@
22725
22832
  */
22726
22833
  const LOCAL_AGENT_REFERENCE_PREFIXES = ['./', '../', '/'];
22727
22834
  /**
22728
- * Builds the combined persona description from PERSONA commitments.
22835
+ * Resolves the public agent profile text from the last GOAL/GOALS commitment,
22836
+ * falling back to the deprecated PERSONA/PERSONAE commitments when no goal exists.
22729
22837
  *
22730
22838
  * @private internal utility of `parseAgentSource`
22731
22839
  */
22732
- function extractPersonaDescription(commitments) {
22733
- let personaDescription = null;
22840
+ function extractAgentProfileText(commitments) {
22841
+ let goalDescription = '';
22842
+ let hasGoalDescription = false;
22843
+ let personaDescription = '';
22844
+ let hasPersonaDescription = false;
22734
22845
  for (const commitment of commitments) {
22735
- if (commitment.type !== 'PERSONA') {
22736
- continue;
22737
- }
22738
- if (personaDescription === null) {
22739
- personaDescription = '';
22846
+ if (commitment.type === 'GOAL' || commitment.type === 'GOALS') {
22847
+ goalDescription = commitment.content;
22848
+ hasGoalDescription = true;
22740
22849
  }
22741
- else {
22742
- personaDescription += `\n\n${personaDescription}`;
22850
+ if (commitment.type === 'PERSONA' || commitment.type === 'PERSONAE') {
22851
+ personaDescription = commitment.content;
22852
+ hasPersonaDescription = true;
22743
22853
  }
22744
- personaDescription += commitment.content;
22745
22854
  }
22746
- return personaDescription;
22855
+ if (hasGoalDescription) {
22856
+ return goalDescription;
22857
+ }
22858
+ if (hasPersonaDescription) {
22859
+ return personaDescription;
22860
+ }
22861
+ return null;
22747
22862
  }
22748
22863
  /**
22749
22864
  * Resolves the last INITIAL MESSAGE commitment, which is the public initial-message value.
@@ -23230,7 +23345,7 @@
23230
23345
  * Selects the best model using the preparePersona function
23231
23346
  * This directly uses preparePersona to ensure DRY principle
23232
23347
  *
23233
- * @param agentSource The agent source to derive persona description from
23348
+ * @param agentSource The agent source to derive effective profile text from
23234
23349
  * @param llmTools LLM tools for preparing persona
23235
23350
  * @returns The name of the best selected model
23236
23351
  *
@@ -23238,9 +23353,9 @@
23238
23353
  */
23239
23354
  async function selectBestModelUsingPersona(agentSource, llmTools) {
23240
23355
  var _a;
23241
- // Parse agent source to get persona description
23356
+ // Parse agent source to get the effective profile description
23242
23357
  const { agentName, personaDescription } = parseAgentSource(agentSource);
23243
- // Use agent name as fallback if no persona description is available
23358
+ // Use agent name as fallback if no profile description is available
23244
23359
  const description = personaDescription || agentName || 'AI Agent';
23245
23360
  try {
23246
23361
  // Use preparePersona directly
@@ -32700,7 +32815,7 @@
32700
32815
  /**
32701
32816
  * Constant for default agent kit model name.
32702
32817
  */
32703
- const DEFAULT_AGENT_KIT_MODEL_NAME = 'gpt-5.4-nano';
32818
+ const DEFAULT_AGENT_KIT_MODEL_NAME = 'gpt-5.4-mini';
32704
32819
  /**
32705
32820
  * Creates one structured log entry for streamed tool-call updates.
32706
32821
  *
@@ -34766,6 +34881,7 @@
34766
34881
  * @param agentSource The agent source string that defines the agent's behavior
34767
34882
  */
34768
34883
  constructor(options) {
34884
+ var _a;
34769
34885
  this.options = options;
34770
34886
  /**
34771
34887
  * Cached model requirements to avoid re-parsing the agent source
@@ -34775,6 +34891,7 @@
34775
34891
  * Cached parsed agent information
34776
34892
  */
34777
34893
  this._cachedAgentInfo = null;
34894
+ this.precomputedModelRequirements = (_a = options.precomputedModelRequirements) !== null && _a !== void 0 ? _a : null;
34778
34895
  }
34779
34896
  /**
34780
34897
  * Updates the agent source and clears the cache
@@ -34782,9 +34899,13 @@
34782
34899
  * @param agentSource The new agent source string
34783
34900
  */
34784
34901
  updateAgentSource(agentSource) {
34902
+ if (this.options.agentSource === agentSource) {
34903
+ return;
34904
+ }
34785
34905
  this.options.agentSource = agentSource;
34786
34906
  this._cachedAgentInfo = null;
34787
34907
  this._cachedModelRequirements = null;
34908
+ this.precomputedModelRequirements = null;
34788
34909
  }
34789
34910
  /**
34790
34911
  * Get cached or parse agent information
@@ -34801,6 +34922,16 @@
34801
34922
  * Note: [🐤] This is names `getModelRequirements` *(not `getAgentModelRequirements`)* because in future these two will be united
34802
34923
  */
34803
34924
  async getModelRequirements() {
34925
+ var _a, _b;
34926
+ if (this.precomputedModelRequirements !== null) {
34927
+ if (this.options.isVerbose) {
34928
+ console.info('[🤰]', 'Using precomputed agent model requirements', {
34929
+ agent: this.title,
34930
+ toolCount: (_b = (_a = this.precomputedModelRequirements.tools) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0,
34931
+ });
34932
+ }
34933
+ return this.precomputedModelRequirements;
34934
+ }
34804
34935
  if (this._cachedModelRequirements === null) {
34805
34936
  const preparationStartedAtMs = Date.now();
34806
34937
  if (this.options.isVerbose) {
@@ -34910,6 +35041,7 @@
34910
35041
  * Resolves agent requirements, attachments, and runtime overrides into one forwarded chat prompt.
34911
35042
  */
34912
35043
  async prepareChatPrompt(prompt) {
35044
+ var _a;
34913
35045
  const chatPrompt = this.requireChatPrompt(prompt);
34914
35046
  const { sanitizedRequirements, promptSuffix } = await this.getSanitizedAgentModelRequirements();
34915
35047
  const attachments = normalizeChatAttachments(chatPrompt.attachments);
@@ -34927,7 +35059,16 @@
34927
35059
  mergedTools,
34928
35060
  knowledgeSourcesForAgent,
34929
35061
  });
34930
- console.log('!!!! promptWithAgentModelRequirements:', forwardedPrompt);
35062
+ if (this.options.isVerbose) {
35063
+ console.info('[🤰]', 'Prepared agent chat prompt', {
35064
+ agent: this.title,
35065
+ usedPrecomputedModelRequirements: this.precomputedModelRequirements !== null,
35066
+ toolNames: mergedTools.map((tool) => tool.name),
35067
+ knowledgeSourcesCount: (_a = knowledgeSourcesForAgent === null || knowledgeSourcesForAgent === void 0 ? void 0 : knowledgeSourcesForAgent.length) !== null && _a !== void 0 ? _a : 0,
35068
+ promptSuffixLength: promptSuffix.length,
35069
+ systemMessageLength: sanitizedRequirements.systemMessage.length,
35070
+ });
35071
+ }
34931
35072
  return {
34932
35073
  forwardedPrompt,
34933
35074
  sanitizedRequirements,
@@ -35114,6 +35255,7 @@
35114
35255
  * Runs one prepared prompt through the deprecated OpenAI Assistant backend.
35115
35256
  */
35116
35257
  async callOpenAiAssistantChatModelStream(options) {
35258
+ var _a, _b, _c, _d;
35117
35259
  const assistant = await this.getOrPrepareOpenAiAssistant({
35118
35260
  llmTools: options.llmTools,
35119
35261
  originalPrompt: options.originalPrompt,
@@ -35121,7 +35263,14 @@
35121
35263
  onProgress: options.onProgress,
35122
35264
  });
35123
35265
  const promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools = createOpenAiAssistantPrompt(options.preparedChatPrompt.forwardedPrompt);
35124
- console.log('!!!! promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools:', promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools);
35266
+ if (this.options.isVerbose) {
35267
+ console.info('[🤰]', 'Prepared OpenAI Assistant prompt', {
35268
+ agent: this.title,
35269
+ toolNames: (_b = (_a = promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools.modelRequirements.tools) === null || _a === void 0 ? void 0 : _a.map((tool) => tool.name)) !== null && _b !== void 0 ? _b : [],
35270
+ knowledgeSourcesCount: (_d = (_c = promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools.modelRequirements
35271
+ .knowledgeSources) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0,
35272
+ });
35273
+ }
35125
35274
  return assistant.callChatModelStream(promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools, options.onProgress, options.streamOptions);
35126
35275
  }
35127
35276
  /**
@@ -35812,7 +35961,8 @@
35812
35961
  isVerbose: options.isVerbose,
35813
35962
  llmTools: getSingleLlmExecutionTools(options.executionTools.llm),
35814
35963
  assistantPreparationMode: options.assistantPreparationMode,
35815
- agentSource: agentSource.value, // <- TODO: [🐱‍🚀] Allow to pass BehaviorSubject<string_book> OR refresh llmExecutionTools.callChat on agentSource change
35964
+ agentSource: agentSource.value,
35965
+ precomputedModelRequirements: options.precomputedModelRequirements,
35816
35966
  });
35817
35967
  this._agentName = undefined;
35818
35968
  /**
@@ -38430,6 +38580,7 @@
38430
38580
 
38431
38581
  PERSONA ${block(personaDescription)}
38432
38582
  ${block(initialRules.map((rule) => `RULE ${rule}`).join('\n'))}
38583
+ CLOSED
38433
38584
  `));
38434
38585
  // Note: `META COLOR ${color || PROMPTBOOK_COLOR.toHex()}` was removed for now
38435
38586
  // Note: `META FONT Playfair Display, sans-serif` was removed for now