@promptbook/remote-server 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 +207 -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 +2 -2
  17. package/umd/index.umd.js +207 -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/remote-server",
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,
@@ -98,7 +98,7 @@
98
98
  "module": "./esm/index.es.js",
99
99
  "typings": "./esm/typings/src/_packages/remote-server.index.d.ts",
100
100
  "peerDependencies": {
101
- "@promptbook/core": "0.112.0-42"
101
+ "@promptbook/core": "0.112.0-44"
102
102
  },
103
103
  "dependencies": {
104
104
  "@mozilla/readability": "0.6.0",
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.112.0-42';
53
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-44';
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
@@ -12193,7 +12193,7 @@
12193
12193
  * Short one-line description of GOAL.
12194
12194
  */
12195
12195
  get description() {
12196
- return 'Define main **goals** the AI assistant should achieve, with later goals having higher priority.';
12196
+ return 'Define the effective agent **goal**; when multiple goals exist, only the last one stays effective.';
12197
12197
  }
12198
12198
  /**
12199
12199
  * Icon for this commitment.
@@ -12208,12 +12208,14 @@
12208
12208
  return _spaceTrim.spaceTrim(`
12209
12209
  # ${this.type}
12210
12210
 
12211
- 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.
12211
+ Defines the main goal which should be achieved by the AI assistant.
12212
+ There can be multiple goals in source, but after inheritance/source rewriting only the last \`GOAL\` /\`GOALS\` remains effective.
12212
12213
 
12213
12214
  ## Key aspects
12214
12215
 
12215
12216
  - Both terms work identically and can be used interchangeably.
12216
- - Later goals have higher priority and can override earlier goals.
12217
+ - Later goals overwrite earlier goals.
12218
+ - The public agent profile text is derived from the last goal.
12217
12219
  - Goals provide clear direction and purpose for the agent's responses.
12218
12220
  - Goals influence decision-making and response prioritization.
12219
12221
 
@@ -12226,9 +12228,7 @@
12226
12228
  \`\`\`book
12227
12229
  Customer Support Agent
12228
12230
 
12229
- PERSONA You are a helpful customer support representative
12230
12231
  GOAL Resolve customer issues quickly and efficiently
12231
- GOAL Maintain high customer satisfaction scores
12232
12232
  GOAL Always follow company policies and procedures
12233
12233
  RULE Be polite and professional at all times
12234
12234
  \`\`\`
@@ -12236,9 +12236,7 @@
12236
12236
  \`\`\`book
12237
12237
  Educational Assistant
12238
12238
 
12239
- PERSONA You are an educational assistant specializing in mathematics
12240
12239
  GOAL Help students understand mathematical concepts clearly
12241
- GOAL Encourage critical thinking and problem-solving skills
12242
12240
  GOAL Ensure all explanations are age-appropriate and accessible
12243
12241
  STYLE Use simple language and provide step-by-step explanations
12244
12242
  \`\`\`
@@ -12246,9 +12244,7 @@
12246
12244
  \`\`\`book
12247
12245
  Safety-First Assistant
12248
12246
 
12249
- PERSONA You are a general-purpose AI assistant
12250
12247
  GOAL Be helpful and informative in all interactions
12251
- GOAL Provide accurate and reliable information
12252
12248
  GOAL Always prioritize user safety and ethical guidelines
12253
12249
  RULE Never provide harmful or dangerous advice
12254
12250
  \`\`\`
@@ -15107,7 +15103,16 @@
15107
15103
  * Short one-line description of PERSONA.
15108
15104
  */
15109
15105
  get description() {
15110
- return 'Define who the agent is: background, expertise, and personality.';
15106
+ return 'Deprecated legacy profile commitment. Prefer `GOAL` for agent profile text and inheritance-safe rewrites.';
15107
+ }
15108
+ /**
15109
+ * Optional UI/docs-only deprecation metadata.
15110
+ */
15111
+ get deprecation() {
15112
+ return {
15113
+ message: 'Use `GOAL` for agent profile text and inheritance-safe rewrites.',
15114
+ replacedBy: ['GOAL'],
15115
+ };
15111
15116
  }
15112
15117
  /**
15113
15118
  * Icon for this commitment.
@@ -15122,16 +15127,24 @@
15122
15127
  return _spaceTrim.spaceTrim(`
15123
15128
  # ${this.type}
15124
15129
 
15125
- Defines who the agent is, their background, expertise, and personality traits.
15130
+ Deprecated legacy commitment that defines who the agent is, their background, expertise, and personality traits.
15126
15131
 
15127
- ## Key aspects
15132
+ ## Migration
15128
15133
 
15129
- - Multiple \`PERSONA\` and \`PERSONAE\` commitments are merged together.
15130
- - Both terms work identically and can be used interchangeably.
15131
- - If they are in conflict, the last one takes precedence.
15132
- - You can write persona content in multiple lines.
15134
+ - Existing \`${this.type}\` books still parse and compile.
15135
+ - New books should prefer \`GOAL\`.
15136
+ - Agent profile rendering now prefers the last \`GOAL\` and only falls back to \`${this.type}\` when no goal exists.
15137
+ - Runtime compilation keeps the legacy multi-\`PERSONA\` merge behavior for backward compatibility.
15133
15138
 
15134
- ## Examples
15139
+ ## Preferred replacement
15140
+
15141
+ \`\`\`book
15142
+ Programming Assistant
15143
+
15144
+ GOAL Help the user solve programming problems with practical TypeScript and React guidance.
15145
+ \`\`\`
15146
+
15147
+ ## Legacy compatibility example
15135
15148
 
15136
15149
  \`\`\`book
15137
15150
  Programming Assistant
@@ -15839,6 +15852,15 @@
15839
15852
  * Map of team tool titles.
15840
15853
  */
15841
15854
  const teamToolTitles = {};
15855
+ /**
15856
+ * Shared TEAM usage rules appended ahead of teammate listings.
15857
+ *
15858
+ * @private
15859
+ */
15860
+ const TEAM_SYSTEM_MESSAGE_GUIDANCE_LINES = [
15861
+ '- If a teammate is relevant to the request, consult that teammate using the matching tool.',
15862
+ '- Do not ask the user for information that a listed teammate can provide directly.',
15863
+ ];
15842
15864
  /**
15843
15865
  * Constant for remote agents by Url.
15844
15866
  */
@@ -15887,7 +15909,7 @@
15887
15909
  \`\`\`book
15888
15910
  Legal Assistant
15889
15911
 
15890
- PERSONA An expert software developer
15912
+ GOAL Get expert software-development advice from the teammate when legal discussion needs technical context.
15891
15913
  TEAM You can talk with http://localhost:4440/agents/GMw67JN8TXxN7y to discuss the legal aspects.
15892
15914
  \`\`\`
15893
15915
  `);
@@ -15928,12 +15950,9 @@
15928
15950
  if (updatedTools.some((tool) => tool.name === entry.toolName)) {
15929
15951
  continue;
15930
15952
  }
15931
- const toolDescription = entry.description
15932
- ? `Consult teammate ${entry.teammate.label}\n${entry.description}`
15933
- : `Consult teammate ${entry.teammate.label}`;
15934
15953
  updatedTools.push({
15935
15954
  name: entry.toolName,
15936
- description: toolDescription,
15955
+ description: buildTeamToolDescription(entry),
15937
15956
  parameters: {
15938
15957
  type: 'object',
15939
15958
  properties: {
@@ -16002,22 +16021,72 @@
16002
16021
  /**
16003
16022
  * Builds the textual TEAM section body for the final system message.
16004
16023
  *
16005
- * Each teammate is listed with its tool name and, when available, a one-line description.
16006
- * Uses `spaceTrim` to ensure consistent whitespace and indentation.
16024
+ * Each teammate is listed with its tool name, TEAM instructions, and optional profile hints.
16007
16025
  */
16008
16026
  function buildTeamSystemMessageBody(teamEntries) {
16009
- const lines = teamEntries.map((entry, index) => {
16010
- const toolLine = `${index + 1}) ${entry.teammate.label} tool \`${entry.toolName}\``;
16011
- if (!entry.description) {
16012
- return toolLine;
16013
- }
16014
- return _spaceTrim.spaceTrim(`
16015
- ${toolLine}
16016
- ${entry.description}
16017
- `);
16018
- });
16027
+ const lines = [
16028
+ ...TEAM_SYSTEM_MESSAGE_GUIDANCE_LINES,
16029
+ '',
16030
+ ...teamEntries.map((entry, index) => {
16031
+ const toolLine = `${index + 1}) ${entry.teammate.label} tool \`${entry.toolName}\``;
16032
+ const detailLines = collectTeamEntryDetails(entry).map(formatTeamEntryDetailLine);
16033
+ return [toolLine, ...detailLines].join('\n');
16034
+ }),
16035
+ ];
16019
16036
  return lines.join('\n');
16020
16037
  }
16038
+ /**
16039
+ * Builds the model-visible description for one teammate tool.
16040
+ *
16041
+ * @private
16042
+ */
16043
+ function buildTeamToolDescription(entry) {
16044
+ const detailLines = collectTeamEntryDetails(entry).map(({ label, content }) => `${label}: ${content}`);
16045
+ return [`Consult teammate ${entry.teammate.label}`, ...detailLines].join('\n');
16046
+ }
16047
+ /**
16048
+ * Collects structured teammate details that should stay visible to the model.
16049
+ *
16050
+ * @private
16051
+ */
16052
+ function collectTeamEntryDetails(entry) {
16053
+ var _a;
16054
+ const details = [];
16055
+ const instructions = entry.teammate.instructions.trim();
16056
+ const description = ((_a = entry.description) === null || _a === void 0 ? void 0 : _a.trim()) || '';
16057
+ if (instructions) {
16058
+ details.push({
16059
+ label: 'TEAM instructions',
16060
+ content: instructions,
16061
+ });
16062
+ }
16063
+ if (description) {
16064
+ details.push({
16065
+ label: 'Profile',
16066
+ content: description,
16067
+ });
16068
+ }
16069
+ return details;
16070
+ }
16071
+ /**
16072
+ * Formats one teammate detail line for the TEAM system-message section.
16073
+ *
16074
+ * @private
16075
+ */
16076
+ function formatTeamEntryDetailLine(detail) {
16077
+ return indentMultilineText(`${detail.label}: ${detail.content}`, ' ');
16078
+ }
16079
+ /**
16080
+ * Indents all lines of one potentially multi-line text block.
16081
+ *
16082
+ * @private
16083
+ */
16084
+ function indentMultilineText(text, prefix) {
16085
+ return text
16086
+ .split('\n')
16087
+ .map((line) => `${prefix}${line}`)
16088
+ .join('\n');
16089
+ }
16021
16090
  /**
16022
16091
  * Registers tool function and title for a teammate tool.
16023
16092
  */
@@ -25008,7 +25077,7 @@
25008
25077
  function parseAgentSource(agentSource) {
25009
25078
  const parseResult = parseAgentSourceWithCommitments(agentSource);
25010
25079
  const resolvedAgentName = parseResult.agentName || createDefaultAgentName(agentSource);
25011
- const personaDescription = extractPersonaDescription(parseResult.commitments);
25080
+ const personaDescription = extractAgentProfileText(parseResult.commitments);
25012
25081
  const initialMessage = extractInitialMessage(parseResult.commitments);
25013
25082
  const parsedProfile = extractParsedAgentProfile(parseResult.commitments);
25014
25083
  ensureMetaFullname(parsedProfile.meta, resolvedAgentName);
@@ -25112,25 +25181,33 @@
25112
25181
  */
25113
25182
  const LOCAL_AGENT_REFERENCE_PREFIXES = ['./', '../', '/'];
25114
25183
  /**
25115
- * Builds the combined persona description from PERSONA commitments.
25184
+ * Resolves the public agent profile text from the last GOAL/GOALS commitment,
25185
+ * falling back to the deprecated PERSONA/PERSONAE commitments when no goal exists.
25116
25186
  *
25117
25187
  * @private internal utility of `parseAgentSource`
25118
25188
  */
25119
- function extractPersonaDescription(commitments) {
25120
- let personaDescription = null;
25189
+ function extractAgentProfileText(commitments) {
25190
+ let goalDescription = '';
25191
+ let hasGoalDescription = false;
25192
+ let personaDescription = '';
25193
+ let hasPersonaDescription = false;
25121
25194
  for (const commitment of commitments) {
25122
- if (commitment.type !== 'PERSONA') {
25123
- continue;
25195
+ if (commitment.type === 'GOAL' || commitment.type === 'GOALS') {
25196
+ goalDescription = commitment.content;
25197
+ hasGoalDescription = true;
25124
25198
  }
25125
- if (personaDescription === null) {
25126
- personaDescription = '';
25199
+ if (commitment.type === 'PERSONA' || commitment.type === 'PERSONAE') {
25200
+ personaDescription = commitment.content;
25201
+ hasPersonaDescription = true;
25127
25202
  }
25128
- else {
25129
- personaDescription += `\n\n${personaDescription}`;
25130
- }
25131
- personaDescription += commitment.content;
25132
25203
  }
25133
- return personaDescription;
25204
+ if (hasGoalDescription) {
25205
+ return goalDescription;
25206
+ }
25207
+ if (hasPersonaDescription) {
25208
+ return personaDescription;
25209
+ }
25210
+ return null;
25134
25211
  }
25135
25212
  /**
25136
25213
  * Resolves the last INITIAL MESSAGE commitment, which is the public initial-message value.
@@ -25651,7 +25728,7 @@
25651
25728
  systemMessage: '',
25652
25729
  promptSuffix: '',
25653
25730
  // modelName: 'gpt-5',
25654
- modelName: 'gemini-2.5-flash-lite',
25731
+ modelName: 'gpt-5.4-mini',
25655
25732
  temperature: 0.7,
25656
25733
  topP: 0.9,
25657
25734
  topK: 50,
@@ -25812,6 +25889,15 @@
25812
25889
  * @private internal constant of `createAgentModelRequirementsWithCommitments`
25813
25890
  */
25814
25891
  const DELETE_COMMITMENT_TYPES = new Set(['DELETE', 'CANCEL', 'DISCARD', 'REMOVE']);
25892
+ /**
25893
+ * Commitments whose earlier occurrences are overwritten by the last occurrence in source order.
25894
+ *
25895
+ * @private internal constant of `createAgentModelRequirementsWithCommitments`
25896
+ */
25897
+ const OVERWRITTEN_COMMITMENT_GROUP_BY_TYPE = new Map([
25898
+ ['GOAL', 'GOAL'],
25899
+ ['GOALS', 'GOAL'],
25900
+ ]);
25815
25901
  /**
25816
25902
  * Regex pattern matching markdown horizontal lines that should not be copied into the final system message.
25817
25903
  *
@@ -25862,7 +25948,7 @@
25862
25948
  */
25863
25949
  async function createAgentModelRequirementsWithCommitments(agentSource, modelName, options) {
25864
25950
  const parseResult = parseAgentSourceWithCommitments(agentSource);
25865
- const filteredCommitments = filterDeletedCommitments(parseResult.commitments);
25951
+ const filteredCommitments = filterOverwrittenCommitments(filterDeletedCommitments(parseResult.commitments));
25866
25952
  let requirements = createInitialAgentModelRequirements(parseResult.agentName, modelName);
25867
25953
  requirements = await applyCommitmentsToRequirements(requirements, filteredCommitments, options);
25868
25954
  requirements = aggregateUseCommitmentSystemMessages(requirements, filteredCommitments);
@@ -25873,6 +25959,35 @@
25873
25959
  requirements = await applyPendingInlineKnowledgeSources(requirements, options === null || options === void 0 ? void 0 : options.inlineKnowledgeSourceUploader);
25874
25960
  return finalizeRequirements(requirements);
25875
25961
  }
25962
+ /**
25963
+ * Removes earlier commitments that are overwritten by later commitments of the same semantic group.
25964
+ *
25965
+ * This currently keeps only the last `GOAL` / `GOALS` commitment so inheritance rewrites
25966
+ * and multi-goal sources expose one effective goal to the runtime.
25967
+ *
25968
+ * @param commitments - Parsed commitments after DELETE-like filtering.
25969
+ * @returns Commitments with overwritten entries removed while preserving source order.
25970
+ *
25971
+ * @private internal utility of `createAgentModelRequirementsWithCommitments`
25972
+ */
25973
+ function filterOverwrittenCommitments(commitments) {
25974
+ const seenOverwriteGroups = new Set();
25975
+ const keptCommitments = [];
25976
+ for (let index = commitments.length - 1; index >= 0; index--) {
25977
+ const commitment = commitments[index];
25978
+ const overwriteGroup = OVERWRITTEN_COMMITMENT_GROUP_BY_TYPE.get(commitment.type);
25979
+ if (!overwriteGroup) {
25980
+ keptCommitments.push(commitment);
25981
+ continue;
25982
+ }
25983
+ if (seenOverwriteGroups.has(overwriteGroup)) {
25984
+ continue;
25985
+ }
25986
+ seenOverwriteGroups.add(overwriteGroup);
25987
+ keptCommitments.push(commitment);
25988
+ }
25989
+ return keptCommitments.reverse();
25990
+ }
25876
25991
  /**
25877
25992
  * Creates the initial requirements object with the parsed agent name stored in metadata and an optional model override.
25878
25993
  *
@@ -26464,7 +26579,7 @@
26464
26579
  * Selects the best model using the preparePersona function
26465
26580
  * This directly uses preparePersona to ensure DRY principle
26466
26581
  *
26467
- * @param agentSource The agent source to derive persona description from
26582
+ * @param agentSource The agent source to derive effective profile text from
26468
26583
  * @param llmTools LLM tools for preparing persona
26469
26584
  * @returns The name of the best selected model
26470
26585
  *
@@ -26472,9 +26587,9 @@
26472
26587
  */
26473
26588
  async function selectBestModelUsingPersona(agentSource, llmTools) {
26474
26589
  var _a;
26475
- // Parse agent source to get persona description
26590
+ // Parse agent source to get the effective profile description
26476
26591
  const { agentName, personaDescription } = parseAgentSource(agentSource);
26477
- // Use agent name as fallback if no persona description is available
26592
+ // Use agent name as fallback if no profile description is available
26478
26593
  const description = personaDescription || agentName || 'AI Agent';
26479
26594
  try {
26480
26595
  // Use preparePersona directly
@@ -30245,7 +30360,7 @@
30245
30360
  /**
30246
30361
  * Constant for default agent kit model name.
30247
30362
  */
30248
- const DEFAULT_AGENT_KIT_MODEL_NAME = 'gpt-5.4-nano';
30363
+ const DEFAULT_AGENT_KIT_MODEL_NAME = 'gpt-5.4-mini';
30249
30364
  /**
30250
30365
  * Creates one structured log entry for streamed tool-call updates.
30251
30366
  *
@@ -32311,6 +32426,7 @@
32311
32426
  * @param agentSource The agent source string that defines the agent's behavior
32312
32427
  */
32313
32428
  constructor(options) {
32429
+ var _a;
32314
32430
  this.options = options;
32315
32431
  /**
32316
32432
  * Cached model requirements to avoid re-parsing the agent source
@@ -32320,6 +32436,7 @@
32320
32436
  * Cached parsed agent information
32321
32437
  */
32322
32438
  this._cachedAgentInfo = null;
32439
+ this.precomputedModelRequirements = (_a = options.precomputedModelRequirements) !== null && _a !== void 0 ? _a : null;
32323
32440
  }
32324
32441
  /**
32325
32442
  * Updates the agent source and clears the cache
@@ -32327,9 +32444,13 @@
32327
32444
  * @param agentSource The new agent source string
32328
32445
  */
32329
32446
  updateAgentSource(agentSource) {
32447
+ if (this.options.agentSource === agentSource) {
32448
+ return;
32449
+ }
32330
32450
  this.options.agentSource = agentSource;
32331
32451
  this._cachedAgentInfo = null;
32332
32452
  this._cachedModelRequirements = null;
32453
+ this.precomputedModelRequirements = null;
32333
32454
  }
32334
32455
  /**
32335
32456
  * Get cached or parse agent information
@@ -32346,6 +32467,16 @@
32346
32467
  * Note: [🐤] This is names `getModelRequirements` *(not `getAgentModelRequirements`)* because in future these two will be united
32347
32468
  */
32348
32469
  async getModelRequirements() {
32470
+ var _a, _b;
32471
+ if (this.precomputedModelRequirements !== null) {
32472
+ if (this.options.isVerbose) {
32473
+ console.info('[🤰]', 'Using precomputed agent model requirements', {
32474
+ agent: this.title,
32475
+ toolCount: (_b = (_a = this.precomputedModelRequirements.tools) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0,
32476
+ });
32477
+ }
32478
+ return this.precomputedModelRequirements;
32479
+ }
32349
32480
  if (this._cachedModelRequirements === null) {
32350
32481
  const preparationStartedAtMs = Date.now();
32351
32482
  if (this.options.isVerbose) {
@@ -32455,6 +32586,7 @@
32455
32586
  * Resolves agent requirements, attachments, and runtime overrides into one forwarded chat prompt.
32456
32587
  */
32457
32588
  async prepareChatPrompt(prompt) {
32589
+ var _a;
32458
32590
  const chatPrompt = this.requireChatPrompt(prompt);
32459
32591
  const { sanitizedRequirements, promptSuffix } = await this.getSanitizedAgentModelRequirements();
32460
32592
  const attachments = normalizeChatAttachments(chatPrompt.attachments);
@@ -32472,7 +32604,16 @@
32472
32604
  mergedTools,
32473
32605
  knowledgeSourcesForAgent,
32474
32606
  });
32475
- console.log('!!!! promptWithAgentModelRequirements:', forwardedPrompt);
32607
+ if (this.options.isVerbose) {
32608
+ console.info('[🤰]', 'Prepared agent chat prompt', {
32609
+ agent: this.title,
32610
+ usedPrecomputedModelRequirements: this.precomputedModelRequirements !== null,
32611
+ toolNames: mergedTools.map((tool) => tool.name),
32612
+ knowledgeSourcesCount: (_a = knowledgeSourcesForAgent === null || knowledgeSourcesForAgent === void 0 ? void 0 : knowledgeSourcesForAgent.length) !== null && _a !== void 0 ? _a : 0,
32613
+ promptSuffixLength: promptSuffix.length,
32614
+ systemMessageLength: sanitizedRequirements.systemMessage.length,
32615
+ });
32616
+ }
32476
32617
  return {
32477
32618
  forwardedPrompt,
32478
32619
  sanitizedRequirements,
@@ -32659,6 +32800,7 @@
32659
32800
  * Runs one prepared prompt through the deprecated OpenAI Assistant backend.
32660
32801
  */
32661
32802
  async callOpenAiAssistantChatModelStream(options) {
32803
+ var _a, _b, _c, _d;
32662
32804
  const assistant = await this.getOrPrepareOpenAiAssistant({
32663
32805
  llmTools: options.llmTools,
32664
32806
  originalPrompt: options.originalPrompt,
@@ -32666,7 +32808,14 @@
32666
32808
  onProgress: options.onProgress,
32667
32809
  });
32668
32810
  const promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools = createOpenAiAssistantPrompt(options.preparedChatPrompt.forwardedPrompt);
32669
- console.log('!!!! promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools:', promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools);
32811
+ if (this.options.isVerbose) {
32812
+ console.info('[🤰]', 'Prepared OpenAI Assistant prompt', {
32813
+ agent: this.title,
32814
+ toolNames: (_b = (_a = promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools.modelRequirements.tools) === null || _a === void 0 ? void 0 : _a.map((tool) => tool.name)) !== null && _b !== void 0 ? _b : [],
32815
+ knowledgeSourcesCount: (_d = (_c = promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools.modelRequirements
32816
+ .knowledgeSources) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0,
32817
+ });
32818
+ }
32670
32819
  return assistant.callChatModelStream(promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools, options.onProgress, options.streamOptions);
32671
32820
  }
32672
32821
  /**
@@ -33357,7 +33506,8 @@
33357
33506
  isVerbose: options.isVerbose,
33358
33507
  llmTools: getSingleLlmExecutionTools(options.executionTools.llm),
33359
33508
  assistantPreparationMode: options.assistantPreparationMode,
33360
- agentSource: agentSource.value, // <- TODO: [🐱‍🚀] Allow to pass BehaviorSubject<string_book> OR refresh llmExecutionTools.callChat on agentSource change
33509
+ agentSource: agentSource.value,
33510
+ precomputedModelRequirements: options.precomputedModelRequirements,
33361
33511
  });
33362
33512
  this._agentName = undefined;
33363
33513
  /**