@promptbook/cli 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/cli",
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,
package/umd/index.umd.js CHANGED
@@ -56,7 +56,7 @@
56
56
  * @generated
57
57
  * @see https://github.com/webgptorg/promptbook
58
58
  */
59
- const PROMPTBOOK_ENGINE_VERSION = '0.111.0-0';
59
+ const PROMPTBOOK_ENGINE_VERSION = '0.111.0-1';
60
60
  /**
61
61
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
62
62
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -20484,8 +20484,8 @@
20484
20484
  /**
20485
20485
  * USE IMAGE GENERATOR commitment definition
20486
20486
  *
20487
- * The `USE IMAGE GENERATOR` commitment indicates that the agent should utilize an image generation tool
20488
- * to create images based on text prompts.
20487
+ * The `USE IMAGE GENERATOR` commitment indicates that the agent can output
20488
+ * markdown placeholders for UI-driven image generation.
20489
20489
  *
20490
20490
  * Example usage in agent source:
20491
20491
  *
@@ -20500,11 +20500,14 @@
20500
20500
  constructor(type = 'USE IMAGE GENERATOR') {
20501
20501
  super(type, ['USE IMAGE GENERATION', 'IMAGE GENERATOR', 'IMAGE GENERATION', 'USE IMAGE']);
20502
20502
  }
20503
+ get requiresContent() {
20504
+ return false;
20505
+ }
20503
20506
  /**
20504
20507
  * Short one-line description of USE IMAGE GENERATOR.
20505
20508
  */
20506
20509
  get description() {
20507
- return 'Enable the agent to use an image generation tool for creating images from text prompts.';
20510
+ return 'Enable the agent to output markdown image placeholders that the UI turns into generated images.';
20508
20511
  }
20509
20512
  /**
20510
20513
  * Icon for this commitment.
@@ -20519,21 +20522,21 @@
20519
20522
  return spaceTrim$1.spaceTrim(`
20520
20523
  # USE IMAGE GENERATOR
20521
20524
 
20522
- Enables the agent to use an image generation tool to create images based on text prompts.
20525
+ Enables the agent to output markdown image placeholders that trigger image generation in the user interface.
20523
20526
 
20524
20527
  ## Key aspects
20525
20528
 
20526
20529
  - The content following \`USE IMAGE GENERATOR\` is an arbitrary text that the agent should know (e.g. style instructions or safety guidelines).
20527
- - The actual image generation is handled by the agent runtime using LLM execution tools.
20528
- - Allows the agent to generate visual content based on user requests.
20529
- - Returns the URL of the generated image.
20530
+ - The agent does **not** call an image-generation tool directly.
20531
+ - The agent inserts markdown notation: \`![alt](?image-prompt=...)\`.
20532
+ - The user interface detects the notation and generates the image asynchronously.
20530
20533
 
20531
20534
  ## Examples
20532
20535
 
20533
20536
  \`\`\`book
20534
20537
  Visual Artist
20535
20538
 
20536
- PERSONA You are a creative visual artist who can generate images.
20539
+ PERSONA You are a creative visual artist.
20537
20540
  USE IMAGE GENERATOR
20538
20541
  RULE Always describe the generated image to the user.
20539
20542
  \`\`\`
@@ -20543,80 +20546,28 @@
20543
20546
 
20544
20547
  PERSONA You are an interior designer who helps users visualize their space.
20545
20548
  USE IMAGE GENERATOR Professional interior design renders.
20546
- ACTION Generate a preview of the designed room.
20549
+ ACTION Add one generated image placeholder whenever a user asks for a visual.
20547
20550
  \`\`\`
20548
20551
  `);
20549
20552
  }
20550
20553
  applyToAgentModelRequirements(requirements, content) {
20551
- // Get existing tools array or create new one
20552
- const existingTools = requirements.tools || [];
20553
- // Add 'generate_image' to tools if not already present
20554
- const updatedTools = existingTools.some((tool) => tool.name === 'generate_image')
20555
- ? existingTools
20556
- : [
20557
- ...existingTools,
20558
- {
20559
- name: 'generate_image',
20560
- description: spaceTrim$1.spaceTrim(`
20561
- Generate an image from a text prompt.
20562
- Use this tool when the user asks to create, draw, or generate an image.
20563
- ${!content ? '' : `Style instructions / guidelines: ${content}`}
20564
- `),
20565
- parameters: {
20566
- type: 'object',
20567
- properties: {
20568
- prompt: {
20569
- type: 'string',
20570
- description: 'The detailed description of the image to generate',
20571
- },
20572
- },
20573
- required: ['prompt'],
20574
- },
20575
- },
20576
- ];
20577
- // Return requirements with updated tools and metadata
20554
+ const extraInstructions = formatOptionalInstructionBlock('Image instructions', content);
20578
20555
  return this.appendToSystemMessage({
20579
20556
  ...requirements,
20580
- tools: updatedTools,
20581
20557
  _metadata: {
20582
20558
  ...requirements._metadata,
20583
20559
  useImageGenerator: content || true,
20584
20560
  },
20585
- }, spaceTrim$1.spaceTrim(`
20586
- You have access to an image generator. Use it to create images based on user requests.
20587
- When you generate an image, you will receive a URL of the generated image.
20588
- `));
20589
- }
20590
- /**
20591
- * Gets human-readable titles for tool functions provided by this commitment.
20592
- */
20593
- getToolTitles() {
20594
- return {
20595
- generate_image: 'Generate image',
20596
- };
20597
- }
20598
- /**
20599
- * Gets the `generate_image` tool function implementation.
20600
- */
20601
- getToolFunctions() {
20602
- return {
20603
- async generate_image(args, ...extra) {
20604
- console.log('!!!! [Tool] generate_image called', { args });
20605
- const { prompt } = args;
20606
- if (!prompt) {
20607
- throw new Error('Image prompt is required');
20608
- }
20609
- const { llmTools } = extra[0] || {};
20610
- if (!llmTools || !llmTools.callImageGenerationModel) {
20611
- throw new Error('Image generation is not supported by the current model provider');
20612
- }
20613
- const result = await llmTools.callImageGenerationModel({
20614
- content: prompt,
20615
- modelName: 'dall-e-3', // Defaulting to dall-e-3, but this could be configurable
20616
- });
20617
- return result.content;
20618
- },
20619
- };
20561
+ }, spaceTrim$1.spaceTrim((block) => `
20562
+ Image generation:
20563
+ - You do not generate images directly and you do not call any image tool.
20564
+ - When the user asks for an image, include markdown notation in your message:
20565
+ \`![<alt text>](?image-prompt=<prompt>)\`
20566
+ - Keep \`<alt text>\` short and descriptive.
20567
+ - Keep \`<prompt>\` detailed so the generated image matches the request.
20568
+ - You can include normal explanatory text before and after the notation.
20569
+ ${block(extraInstructions)}
20570
+ `));
20620
20571
  }
20621
20572
  }
20622
20573
  /**