@promptbook/node 0.111.0-0 → 0.111.0-1

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.
@@ -17,6 +17,12 @@ export type ChatActionsOverlapConfig = {
17
17
  * Selector used to locate message elements for overlap checks.
18
18
  */
19
19
  messageSelector: string;
20
+ /**
21
+ * Optional selector for the actual message content region used for overlap checks.
22
+ *
23
+ * When not provided or when no matching element is found, the full message element is used.
24
+ */
25
+ messageCollisionSelector?: string;
20
26
  /**
21
27
  * Messages used to trigger overlap recalculation.
22
28
  */
@@ -1,12 +1,10 @@
1
- import { string_javascript_name } from '../../_packages/types.index';
2
1
  import type { AgentModelRequirements } from '../../book-2.0/agent-source/AgentModelRequirements';
3
- import { ToolFunction } from '../../scripting/javascript/JavascriptExecutionToolsOptions';
4
2
  import { BaseCommitmentDefinition } from '../_base/BaseCommitmentDefinition';
5
3
  /**
6
4
  * USE IMAGE GENERATOR commitment definition
7
5
  *
8
- * The `USE IMAGE GENERATOR` commitment indicates that the agent should utilize an image generation tool
9
- * to create images based on text prompts.
6
+ * The `USE IMAGE GENERATOR` commitment indicates that the agent can output
7
+ * markdown placeholders for UI-driven image generation.
10
8
  *
11
9
  * Example usage in agent source:
12
10
  *
@@ -19,6 +17,7 @@ import { BaseCommitmentDefinition } from '../_base/BaseCommitmentDefinition';
19
17
  */
20
18
  export declare class UseImageGeneratorCommitmentDefinition extends BaseCommitmentDefinition<'USE IMAGE GENERATOR' | 'USE IMAGE GENERATION' | 'IMAGE GENERATOR' | 'IMAGE GENERATION' | 'USE IMAGE'> {
21
19
  constructor(type?: 'USE IMAGE GENERATOR' | 'USE IMAGE GENERATION' | 'IMAGE GENERATOR' | 'IMAGE GENERATION' | 'USE IMAGE');
20
+ get requiresContent(): boolean;
22
21
  /**
23
22
  * Short one-line description of USE IMAGE GENERATOR.
24
23
  */
@@ -32,14 +31,6 @@ export declare class UseImageGeneratorCommitmentDefinition extends BaseCommitmen
32
31
  */
33
32
  get documentation(): string;
34
33
  applyToAgentModelRequirements(requirements: AgentModelRequirements, content: string): AgentModelRequirements;
35
- /**
36
- * Gets human-readable titles for tool functions provided by this commitment.
37
- */
38
- getToolTitles(): Record<string_javascript_name, string>;
39
- /**
40
- * Gets the `generate_image` tool function implementation.
41
- */
42
- getToolFunctions(): Record<string_javascript_name, ToolFunction>;
43
34
  }
44
35
  /**
45
36
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Simplifies knowledge labels for UI chips by:
3
+ * - extracting filename from URL/path-like values,
4
+ * - removing extension,
5
+ * - removing trailing random ID segment when detected,
6
+ * - truncating to 20 characters with ellipsis.
7
+ *
8
+ * @param label - Raw knowledge label or source value.
9
+ * @returns Display-friendly chip label.
10
+ * @private utility of knowledge/source chip rendering
11
+ */
12
+ export declare function simplifyKnowledgeLabel(label: string): string;
13
+ /**
14
+ * Heuristic that classifies a short text as human-readable, identifier-like, or unknown.
15
+ *
16
+ * @param text - Candidate value (typically a filename segment).
17
+ * @returns `'HUMAN'`, `'ID'`, or `'UNKNOWN'`.
18
+ * @private utility of knowledge/source chip rendering
19
+ */
20
+ export declare function isHumanOrID(text: string): 'HUMAN' | 'ID' | 'UNKNOWN';
@@ -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.110.0`).
18
+ * It follows semantic versioning (e.g., `0.111.0-0`).
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.111.0-0",
3
+ "version": "0.111.0-1",
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.111.0-0"
99
+ "@promptbook/core": "0.111.0-1"
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.111.0-0';
51
+ const PROMPTBOOK_ENGINE_VERSION = '0.111.0-1';
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
@@ -18371,8 +18371,8 @@
18371
18371
  /**
18372
18372
  * USE IMAGE GENERATOR commitment definition
18373
18373
  *
18374
- * The `USE IMAGE GENERATOR` commitment indicates that the agent should utilize an image generation tool
18375
- * to create images based on text prompts.
18374
+ * The `USE IMAGE GENERATOR` commitment indicates that the agent can output
18375
+ * markdown placeholders for UI-driven image generation.
18376
18376
  *
18377
18377
  * Example usage in agent source:
18378
18378
  *
@@ -18387,11 +18387,14 @@
18387
18387
  constructor(type = 'USE IMAGE GENERATOR') {
18388
18388
  super(type, ['USE IMAGE GENERATION', 'IMAGE GENERATOR', 'IMAGE GENERATION', 'USE IMAGE']);
18389
18389
  }
18390
+ get requiresContent() {
18391
+ return false;
18392
+ }
18390
18393
  /**
18391
18394
  * Short one-line description of USE IMAGE GENERATOR.
18392
18395
  */
18393
18396
  get description() {
18394
- return 'Enable the agent to use an image generation tool for creating images from text prompts.';
18397
+ return 'Enable the agent to output markdown image placeholders that the UI turns into generated images.';
18395
18398
  }
18396
18399
  /**
18397
18400
  * Icon for this commitment.
@@ -18406,21 +18409,21 @@
18406
18409
  return spaceTrim$1.spaceTrim(`
18407
18410
  # USE IMAGE GENERATOR
18408
18411
 
18409
- Enables the agent to use an image generation tool to create images based on text prompts.
18412
+ Enables the agent to output markdown image placeholders that trigger image generation in the user interface.
18410
18413
 
18411
18414
  ## Key aspects
18412
18415
 
18413
18416
  - The content following \`USE IMAGE GENERATOR\` is an arbitrary text that the agent should know (e.g. style instructions or safety guidelines).
18414
- - The actual image generation is handled by the agent runtime using LLM execution tools.
18415
- - Allows the agent to generate visual content based on user requests.
18416
- - Returns the URL of the generated image.
18417
+ - The agent does **not** call an image-generation tool directly.
18418
+ - The agent inserts markdown notation: \`![alt](?image-prompt=...)\`.
18419
+ - The user interface detects the notation and generates the image asynchronously.
18417
18420
 
18418
18421
  ## Examples
18419
18422
 
18420
18423
  \`\`\`book
18421
18424
  Visual Artist
18422
18425
 
18423
- PERSONA You are a creative visual artist who can generate images.
18426
+ PERSONA You are a creative visual artist.
18424
18427
  USE IMAGE GENERATOR
18425
18428
  RULE Always describe the generated image to the user.
18426
18429
  \`\`\`
@@ -18430,80 +18433,28 @@
18430
18433
 
18431
18434
  PERSONA You are an interior designer who helps users visualize their space.
18432
18435
  USE IMAGE GENERATOR Professional interior design renders.
18433
- ACTION Generate a preview of the designed room.
18436
+ ACTION Add one generated image placeholder whenever a user asks for a visual.
18434
18437
  \`\`\`
18435
18438
  `);
18436
18439
  }
18437
18440
  applyToAgentModelRequirements(requirements, content) {
18438
- // Get existing tools array or create new one
18439
- const existingTools = requirements.tools || [];
18440
- // Add 'generate_image' to tools if not already present
18441
- const updatedTools = existingTools.some((tool) => tool.name === 'generate_image')
18442
- ? existingTools
18443
- : [
18444
- ...existingTools,
18445
- {
18446
- name: 'generate_image',
18447
- description: spaceTrim$1.spaceTrim(`
18448
- Generate an image from a text prompt.
18449
- Use this tool when the user asks to create, draw, or generate an image.
18450
- ${!content ? '' : `Style instructions / guidelines: ${content}`}
18451
- `),
18452
- parameters: {
18453
- type: 'object',
18454
- properties: {
18455
- prompt: {
18456
- type: 'string',
18457
- description: 'The detailed description of the image to generate',
18458
- },
18459
- },
18460
- required: ['prompt'],
18461
- },
18462
- },
18463
- ];
18464
- // Return requirements with updated tools and metadata
18441
+ const extraInstructions = formatOptionalInstructionBlock('Image instructions', content);
18465
18442
  return this.appendToSystemMessage({
18466
18443
  ...requirements,
18467
- tools: updatedTools,
18468
18444
  _metadata: {
18469
18445
  ...requirements._metadata,
18470
18446
  useImageGenerator: content || true,
18471
18447
  },
18472
- }, spaceTrim$1.spaceTrim(`
18473
- You have access to an image generator. Use it to create images based on user requests.
18474
- When you generate an image, you will receive a URL of the generated image.
18475
- `));
18476
- }
18477
- /**
18478
- * Gets human-readable titles for tool functions provided by this commitment.
18479
- */
18480
- getToolTitles() {
18481
- return {
18482
- generate_image: 'Generate image',
18483
- };
18484
- }
18485
- /**
18486
- * Gets the `generate_image` tool function implementation.
18487
- */
18488
- getToolFunctions() {
18489
- return {
18490
- async generate_image(args, ...extra) {
18491
- console.log('!!!! [Tool] generate_image called', { args });
18492
- const { prompt } = args;
18493
- if (!prompt) {
18494
- throw new Error('Image prompt is required');
18495
- }
18496
- const { llmTools } = extra[0] || {};
18497
- if (!llmTools || !llmTools.callImageGenerationModel) {
18498
- throw new Error('Image generation is not supported by the current model provider');
18499
- }
18500
- const result = await llmTools.callImageGenerationModel({
18501
- content: prompt,
18502
- modelName: 'dall-e-3', // Defaulting to dall-e-3, but this could be configurable
18503
- });
18504
- return result.content;
18505
- },
18506
- };
18448
+ }, spaceTrim$1.spaceTrim((block) => `
18449
+ Image generation:
18450
+ - You do not generate images directly and you do not call any image tool.
18451
+ - When the user asks for an image, include markdown notation in your message:
18452
+ \`![<alt text>](?image-prompt=<prompt>)\`
18453
+ - Keep \`<alt text>\` short and descriptive.
18454
+ - Keep \`<prompt>\` detailed so the generated image matches the request.
18455
+ - You can include normal explanatory text before and after the notation.
18456
+ ${block(extraInstructions)}
18457
+ `));
18507
18458
  }
18508
18459
  }
18509
18460
  /**