@promptbook/node 0.112.0-42 → 0.112.0-43

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.
@@ -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 {};
@@ -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-42`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/node",
3
- "version": "0.112.0-42",
3
+ "version": "0.112.0-43",
4
4
  "description": "Promptbook: Turn your company's scattered knowledge into AI ready books",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -96,7 +96,7 @@
96
96
  "module": "./esm/index.es.js",
97
97
  "typings": "./esm/typings/src/_packages/node.index.d.ts",
98
98
  "peerDependencies": {
99
- "@promptbook/core": "0.112.0-42"
99
+ "@promptbook/core": "0.112.0-43"
100
100
  },
101
101
  "dependencies": {
102
102
  "@mozilla/readability": "0.6.0",
package/umd/index.umd.js CHANGED
@@ -48,7 +48,7 @@
48
48
  * @generated
49
49
  * @see https://github.com/webgptorg/promptbook
50
50
  */
51
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-42';
51
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-43';
52
52
  /**
53
53
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
54
54
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -19001,6 +19001,15 @@
19001
19001
  * Map of team tool titles.
19002
19002
  */
19003
19003
  const teamToolTitles = {};
19004
+ /**
19005
+ * Shared TEAM usage rules appended ahead of teammate listings.
19006
+ *
19007
+ * @private
19008
+ */
19009
+ const TEAM_SYSTEM_MESSAGE_GUIDANCE_LINES = [
19010
+ '- If a teammate is relevant to the request, consult that teammate using the matching tool.',
19011
+ '- Do not ask the user for information that a listed teammate can provide directly.',
19012
+ ];
19004
19013
  /**
19005
19014
  * Constant for remote agents by Url.
19006
19015
  */
@@ -19090,12 +19099,9 @@
19090
19099
  if (updatedTools.some((tool) => tool.name === entry.toolName)) {
19091
19100
  continue;
19092
19101
  }
19093
- const toolDescription = entry.description
19094
- ? `Consult teammate ${entry.teammate.label}\n${entry.description}`
19095
- : `Consult teammate ${entry.teammate.label}`;
19096
19102
  updatedTools.push({
19097
19103
  name: entry.toolName,
19098
- description: toolDescription,
19104
+ description: buildTeamToolDescription(entry),
19099
19105
  parameters: {
19100
19106
  type: 'object',
19101
19107
  properties: {
@@ -19164,22 +19170,72 @@
19164
19170
  /**
19165
19171
  * Builds the textual TEAM section body for the final system message.
19166
19172
  *
19167
- * Each teammate is listed with its tool name and, when available, a one-line description.
19168
- * Uses `spaceTrim` to ensure consistent whitespace and indentation.
19173
+ * Each teammate is listed with its tool name, TEAM instructions, and optional profile hints.
19169
19174
  */
19170
19175
  function buildTeamSystemMessageBody(teamEntries) {
19171
- const lines = teamEntries.map((entry, index) => {
19172
- const toolLine = `${index + 1}) ${entry.teammate.label} tool \`${entry.toolName}\``;
19173
- if (!entry.description) {
19174
- return toolLine;
19175
- }
19176
- return _spaceTrim.spaceTrim(`
19177
- ${toolLine}
19178
- ${entry.description}
19179
- `);
19180
- });
19176
+ const lines = [
19177
+ ...TEAM_SYSTEM_MESSAGE_GUIDANCE_LINES,
19178
+ '',
19179
+ ...teamEntries.map((entry, index) => {
19180
+ const toolLine = `${index + 1}) ${entry.teammate.label} tool \`${entry.toolName}\``;
19181
+ const detailLines = collectTeamEntryDetails(entry).map(formatTeamEntryDetailLine);
19182
+ return [toolLine, ...detailLines].join('\n');
19183
+ }),
19184
+ ];
19181
19185
  return lines.join('\n');
19182
19186
  }
19187
+ /**
19188
+ * Builds the model-visible description for one teammate tool.
19189
+ *
19190
+ * @private
19191
+ */
19192
+ function buildTeamToolDescription(entry) {
19193
+ const detailLines = collectTeamEntryDetails(entry).map(({ label, content }) => `${label}: ${content}`);
19194
+ return [`Consult teammate ${entry.teammate.label}`, ...detailLines].join('\n');
19195
+ }
19196
+ /**
19197
+ * Collects structured teammate details that should stay visible to the model.
19198
+ *
19199
+ * @private
19200
+ */
19201
+ function collectTeamEntryDetails(entry) {
19202
+ var _a;
19203
+ const details = [];
19204
+ const instructions = entry.teammate.instructions.trim();
19205
+ const description = ((_a = entry.description) === null || _a === void 0 ? void 0 : _a.trim()) || '';
19206
+ if (instructions) {
19207
+ details.push({
19208
+ label: 'TEAM instructions',
19209
+ content: instructions,
19210
+ });
19211
+ }
19212
+ if (description) {
19213
+ details.push({
19214
+ label: 'Profile',
19215
+ content: description,
19216
+ });
19217
+ }
19218
+ return details;
19219
+ }
19220
+ /**
19221
+ * Formats one teammate detail line for the TEAM system-message section.
19222
+ *
19223
+ * @private
19224
+ */
19225
+ function formatTeamEntryDetailLine(detail) {
19226
+ return indentMultilineText(`${detail.label}: ${detail.content}`, ' ');
19227
+ }
19228
+ /**
19229
+ * Indents all lines of one potentially multi-line text block.
19230
+ *
19231
+ * @private
19232
+ */
19233
+ function indentMultilineText(text, prefix) {
19234
+ return text
19235
+ .split('\n')
19236
+ .map((line) => `${prefix}${line}`)
19237
+ .join('\n');
19238
+ }
19183
19239
  /**
19184
19240
  * Registers tool function and title for a teammate tool.
19185
19241
  */
@@ -28672,7 +28728,7 @@
28672
28728
  systemMessage: '',
28673
28729
  promptSuffix: '',
28674
28730
  // modelName: 'gpt-5',
28675
- modelName: 'gemini-2.5-flash-lite',
28731
+ modelName: 'gpt-5.4-mini',
28676
28732
  temperature: 0.7,
28677
28733
  topP: 0.9,
28678
28734
  topK: 50,
@@ -33266,7 +33322,7 @@
33266
33322
  /**
33267
33323
  * Constant for default agent kit model name.
33268
33324
  */
33269
- const DEFAULT_AGENT_KIT_MODEL_NAME = 'gpt-5.4-nano';
33325
+ const DEFAULT_AGENT_KIT_MODEL_NAME = 'gpt-5.4-mini';
33270
33326
  /**
33271
33327
  * Creates one structured log entry for streamed tool-call updates.
33272
33328
  *
@@ -35332,6 +35388,7 @@
35332
35388
  * @param agentSource The agent source string that defines the agent's behavior
35333
35389
  */
35334
35390
  constructor(options) {
35391
+ var _a;
35335
35392
  this.options = options;
35336
35393
  /**
35337
35394
  * Cached model requirements to avoid re-parsing the agent source
@@ -35341,6 +35398,7 @@
35341
35398
  * Cached parsed agent information
35342
35399
  */
35343
35400
  this._cachedAgentInfo = null;
35401
+ this.precomputedModelRequirements = (_a = options.precomputedModelRequirements) !== null && _a !== void 0 ? _a : null;
35344
35402
  }
35345
35403
  /**
35346
35404
  * Updates the agent source and clears the cache
@@ -35348,9 +35406,13 @@
35348
35406
  * @param agentSource The new agent source string
35349
35407
  */
35350
35408
  updateAgentSource(agentSource) {
35409
+ if (this.options.agentSource === agentSource) {
35410
+ return;
35411
+ }
35351
35412
  this.options.agentSource = agentSource;
35352
35413
  this._cachedAgentInfo = null;
35353
35414
  this._cachedModelRequirements = null;
35415
+ this.precomputedModelRequirements = null;
35354
35416
  }
35355
35417
  /**
35356
35418
  * Get cached or parse agent information
@@ -35367,6 +35429,16 @@
35367
35429
  * Note: [🐤] This is names `getModelRequirements` *(not `getAgentModelRequirements`)* because in future these two will be united
35368
35430
  */
35369
35431
  async getModelRequirements() {
35432
+ var _a, _b;
35433
+ if (this.precomputedModelRequirements !== null) {
35434
+ if (this.options.isVerbose) {
35435
+ console.info('[🤰]', 'Using precomputed agent model requirements', {
35436
+ agent: this.title,
35437
+ toolCount: (_b = (_a = this.precomputedModelRequirements.tools) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0,
35438
+ });
35439
+ }
35440
+ return this.precomputedModelRequirements;
35441
+ }
35370
35442
  if (this._cachedModelRequirements === null) {
35371
35443
  const preparationStartedAtMs = Date.now();
35372
35444
  if (this.options.isVerbose) {
@@ -35476,6 +35548,7 @@
35476
35548
  * Resolves agent requirements, attachments, and runtime overrides into one forwarded chat prompt.
35477
35549
  */
35478
35550
  async prepareChatPrompt(prompt) {
35551
+ var _a;
35479
35552
  const chatPrompt = this.requireChatPrompt(prompt);
35480
35553
  const { sanitizedRequirements, promptSuffix } = await this.getSanitizedAgentModelRequirements();
35481
35554
  const attachments = normalizeChatAttachments(chatPrompt.attachments);
@@ -35493,7 +35566,16 @@
35493
35566
  mergedTools,
35494
35567
  knowledgeSourcesForAgent,
35495
35568
  });
35496
- console.log('!!!! promptWithAgentModelRequirements:', forwardedPrompt);
35569
+ if (this.options.isVerbose) {
35570
+ console.info('[🤰]', 'Prepared agent chat prompt', {
35571
+ agent: this.title,
35572
+ usedPrecomputedModelRequirements: this.precomputedModelRequirements !== null,
35573
+ toolNames: mergedTools.map((tool) => tool.name),
35574
+ knowledgeSourcesCount: (_a = knowledgeSourcesForAgent === null || knowledgeSourcesForAgent === void 0 ? void 0 : knowledgeSourcesForAgent.length) !== null && _a !== void 0 ? _a : 0,
35575
+ promptSuffixLength: promptSuffix.length,
35576
+ systemMessageLength: sanitizedRequirements.systemMessage.length,
35577
+ });
35578
+ }
35497
35579
  return {
35498
35580
  forwardedPrompt,
35499
35581
  sanitizedRequirements,
@@ -35680,6 +35762,7 @@
35680
35762
  * Runs one prepared prompt through the deprecated OpenAI Assistant backend.
35681
35763
  */
35682
35764
  async callOpenAiAssistantChatModelStream(options) {
35765
+ var _a, _b, _c, _d;
35683
35766
  const assistant = await this.getOrPrepareOpenAiAssistant({
35684
35767
  llmTools: options.llmTools,
35685
35768
  originalPrompt: options.originalPrompt,
@@ -35687,7 +35770,14 @@
35687
35770
  onProgress: options.onProgress,
35688
35771
  });
35689
35772
  const promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools = createOpenAiAssistantPrompt(options.preparedChatPrompt.forwardedPrompt);
35690
- console.log('!!!! promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools:', promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools);
35773
+ if (this.options.isVerbose) {
35774
+ console.info('[🤰]', 'Prepared OpenAI Assistant prompt', {
35775
+ agent: this.title,
35776
+ toolNames: (_b = (_a = promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools.modelRequirements.tools) === null || _a === void 0 ? void 0 : _a.map((tool) => tool.name)) !== null && _b !== void 0 ? _b : [],
35777
+ knowledgeSourcesCount: (_d = (_c = promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools.modelRequirements
35778
+ .knowledgeSources) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0,
35779
+ });
35780
+ }
35691
35781
  return assistant.callChatModelStream(promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools, options.onProgress, options.streamOptions);
35692
35782
  }
35693
35783
  /**
@@ -36378,7 +36468,8 @@
36378
36468
  isVerbose: options.isVerbose,
36379
36469
  llmTools: getSingleLlmExecutionTools(options.executionTools.llm),
36380
36470
  assistantPreparationMode: options.assistantPreparationMode,
36381
- agentSource: agentSource.value, // <- TODO: [🐱‍🚀] Allow to pass BehaviorSubject<string_book> OR refresh llmExecutionTools.callChat on agentSource change
36471
+ agentSource: agentSource.value,
36472
+ precomputedModelRequirements: options.precomputedModelRequirements,
36382
36473
  });
36383
36474
  this._agentName = undefined;
36384
36475
  /**