@promptbook/google 0.105.0-3 → 0.105.0-30

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 (110) hide show
  1. package/README.md +36 -77
  2. package/esm/index.es.js +167 -24
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/browser.index.d.ts +4 -0
  5. package/esm/typings/src/_packages/components.index.d.ts +20 -0
  6. package/esm/typings/src/_packages/core.index.d.ts +19 -11
  7. package/esm/typings/src/_packages/node.index.d.ts +2 -0
  8. package/esm/typings/src/_packages/openai.index.d.ts +2 -0
  9. package/esm/typings/src/_packages/types.index.d.ts +44 -2
  10. package/esm/typings/src/_packages/utils.index.d.ts +4 -0
  11. package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +6 -1
  12. package/esm/typings/src/book-2.0/agent-source/parseTeamCommitment.d.ts +28 -0
  13. package/esm/typings/src/book-components/Chat/AgentChat/AgentChatProps.d.ts +5 -0
  14. package/esm/typings/src/book-components/Chat/AgentChip/AgentChip.d.ts +67 -0
  15. package/esm/typings/src/book-components/Chat/AgentChip/index.d.ts +2 -0
  16. package/esm/typings/src/book-components/Chat/Chat/ChatMessageItem.d.ts +33 -1
  17. package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +89 -11
  18. package/esm/typings/src/book-components/Chat/Chat/ChatSoundToggle.d.ts +23 -0
  19. package/esm/typings/src/book-components/Chat/Chat/ClockIcon.d.ts +9 -0
  20. package/esm/typings/src/book-components/Chat/LlmChat/FriendlyErrorMessage.d.ts +20 -0
  21. package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +13 -0
  22. package/esm/typings/src/book-components/Chat/SourceChip/SourceChip.d.ts +35 -0
  23. package/esm/typings/src/book-components/Chat/SourceChip/index.d.ts +2 -0
  24. package/esm/typings/src/book-components/Chat/effects/ChatEffectsSystem.d.ts +14 -0
  25. package/esm/typings/src/book-components/Chat/effects/components/ConfettiEffect.d.ts +18 -0
  26. package/esm/typings/src/book-components/Chat/effects/components/HeartsEffect.d.ts +18 -0
  27. package/esm/typings/src/book-components/Chat/effects/configs/defaultEffectConfigs.d.ts +7 -0
  28. package/esm/typings/src/book-components/Chat/effects/index.d.ts +18 -0
  29. package/esm/typings/src/book-components/Chat/effects/types/ChatEffect.d.ts +20 -0
  30. package/esm/typings/src/book-components/Chat/effects/types/ChatEffectConfig.d.ts +21 -0
  31. package/esm/typings/src/book-components/Chat/effects/types/ChatEffectType.d.ts +6 -0
  32. package/esm/typings/src/book-components/Chat/effects/types/ChatEffectsSystemProps.d.ts +32 -0
  33. package/esm/typings/src/book-components/Chat/effects/utils/detectEffects.d.ts +12 -0
  34. package/esm/typings/src/book-components/Chat/types/ChatMessage.d.ts +37 -0
  35. package/esm/typings/src/book-components/Chat/utils/createTeamToolNameFromUrl.d.ts +12 -0
  36. package/esm/typings/src/book-components/Chat/utils/getToolCallChipletText.d.ts +40 -0
  37. package/esm/typings/src/book-components/Chat/utils/loadAgentProfile.d.ts +69 -0
  38. package/esm/typings/src/book-components/Chat/utils/parseCitationsFromContent.d.ts +53 -0
  39. package/esm/typings/src/book-components/Chat/utils/resolveCitationUrl.d.ts +11 -0
  40. package/esm/typings/src/book-components/Chat/utils/toolCallParsing.d.ts +64 -0
  41. package/esm/typings/src/book-components/icons/EmailIcon.d.ts +15 -0
  42. package/esm/typings/src/commitments/NOTE/NOTE.d.ts +2 -2
  43. package/esm/typings/src/commitments/TEAM/TEAM.d.ts +45 -0
  44. package/esm/typings/src/commitments/TEMPLATE/TEMPLATE.d.ts +44 -0
  45. package/esm/typings/src/commitments/TEMPLATE/TEMPLATE.test.d.ts +1 -0
  46. package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.d.ts +19 -1
  47. package/esm/typings/src/commitments/USE_BROWSER/fetchUrlContent.d.ts +22 -0
  48. package/esm/typings/src/commitments/USE_BROWSER/fetchUrlContentViaBrowser.d.ts +13 -0
  49. package/esm/typings/src/commitments/USE_EMAIL/USE_EMAIL.d.ts +48 -0
  50. package/esm/typings/src/commitments/USE_EMAIL/resolveSendEmailToolForNode.d.ts +11 -0
  51. package/esm/typings/src/commitments/USE_EMAIL/sendEmailViaBrowser.d.ts +18 -0
  52. package/esm/typings/src/commitments/USE_IMAGE_GENERATOR/USE_IMAGE_GENERATOR.d.ts +46 -0
  53. package/esm/typings/src/commitments/USE_IMAGE_GENERATOR/USE_IMAGE_GENERATOR.test.d.ts +1 -0
  54. package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.d.ts +11 -0
  55. package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.test.d.ts +1 -0
  56. package/esm/typings/src/commitments/USE_TIME/USE_TIME.d.ts +6 -0
  57. package/esm/typings/src/commitments/_base/BaseCommitmentDefinition.d.ts +6 -0
  58. package/esm/typings/src/commitments/_base/CommitmentDefinition.d.ts +6 -0
  59. package/esm/typings/src/commitments/_base/formatOptionalInstructionBlock.d.ts +6 -0
  60. package/esm/typings/src/commitments/_common/commitmentToolFunctions.d.ts +26 -0
  61. package/esm/typings/src/commitments/_common/getAllCommitmentDefinitions.d.ts +8 -0
  62. package/esm/typings/src/commitments/_common/getAllCommitmentTypes.d.ts +8 -0
  63. package/esm/typings/src/commitments/_common/getAllCommitmentsToolFunctionsForBrowser.d.ts +9 -0
  64. package/esm/typings/src/commitments/_common/getAllCommitmentsToolFunctionsForNode.d.ts +13 -0
  65. package/esm/typings/src/commitments/_common/getAllCommitmentsToolTitles.d.ts +7 -0
  66. package/esm/typings/src/commitments/_common/getCommitmentDefinition.d.ts +10 -0
  67. package/esm/typings/src/commitments/_common/getGroupedCommitmentDefinitions.d.ts +17 -0
  68. package/esm/typings/src/commitments/_common/isCommitmentSupported.d.ts +9 -0
  69. package/esm/typings/src/commitments/index.d.ts +5 -58
  70. package/esm/typings/src/constants.d.ts +129 -0
  71. package/esm/typings/src/executables/$provideExecutablesForNode.d.ts +1 -0
  72. package/esm/typings/src/execution/AvailableModel.d.ts +5 -4
  73. package/esm/typings/src/execution/LlmExecutionTools.d.ts +3 -1
  74. package/esm/typings/src/execution/PromptResult.d.ts +2 -19
  75. package/esm/typings/src/execution/utils/$provideExecutionToolsForNode.d.ts +1 -0
  76. package/esm/typings/src/llm-providers/agent/Agent.d.ts +7 -1
  77. package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +6 -1
  78. package/esm/typings/src/llm-providers/agent/AgentOptions.d.ts +7 -0
  79. package/esm/typings/src/llm-providers/agent/RemoteAgent.d.ts +1 -0
  80. package/esm/typings/src/llm-providers/agent/RemoteAgentOptions.d.ts +1 -1
  81. package/esm/typings/src/llm-providers/google/createGoogleExecutionTools.d.ts +1 -0
  82. package/esm/typings/src/llm-providers/openai/OpenAiAgentExecutionTools.d.ts +43 -0
  83. package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +4 -2
  84. package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionTools.d.ts +8 -1
  85. package/esm/typings/src/llm-providers/openai/utils/uploadFilesToOpenAi.d.ts +7 -0
  86. package/esm/typings/src/pipeline/prompt-notation.d.ts +27 -2
  87. package/esm/typings/src/pipeline/prompt-notation.test.d.ts +1 -1
  88. package/esm/typings/src/scrapers/_common/register/$provideFilesystemForNode.d.ts +1 -0
  89. package/esm/typings/src/scrapers/_common/register/$provideScrapersForNode.d.ts +1 -0
  90. package/esm/typings/src/scrapers/_common/register/$provideScriptingForNode.d.ts +1 -0
  91. package/esm/typings/src/search-engines/SearchEngine.d.ts +1 -1
  92. package/esm/typings/src/search-engines/_index.d.ts +6 -0
  93. package/esm/typings/src/search-engines/bing/BingSearchEngine.d.ts +1 -1
  94. package/esm/typings/src/search-engines/dummy/DummySearchEngine.d.ts +1 -1
  95. package/esm/typings/src/search-engines/google/GoogleSearchEngine.d.ts +18 -0
  96. package/esm/typings/src/search-engines/serp/SerpSearchEngine.d.ts +15 -0
  97. package/esm/typings/src/speech-recognition/BrowserSpeechRecognition.d.ts +21 -0
  98. package/esm/typings/src/speech-recognition/OpenAiSpeechRecognition.d.ts +35 -0
  99. package/esm/typings/src/types/ModelRequirements.d.ts +6 -0
  100. package/esm/typings/src/types/Prompt.d.ts +12 -0
  101. package/esm/typings/src/types/SpeechRecognition.d.ts +58 -0
  102. package/esm/typings/src/types/ToolCall.d.ts +37 -0
  103. package/esm/typings/src/types/typeAliases.d.ts +4 -0
  104. package/esm/typings/src/utils/misc/linguisticHash.d.ts +6 -0
  105. package/esm/typings/src/utils/misc/linguisticHash.test.d.ts +1 -0
  106. package/esm/typings/src/version.d.ts +1 -1
  107. package/esm/typings/src/wizard/wizard.d.ts +1 -4
  108. package/package.json +2 -2
  109. package/umd/index.umd.js +170 -27
  110. package/umd/index.umd.js.map +1 -1
package/README.md CHANGED
@@ -251,19 +251,20 @@ Rest of the documentation is common for **entire promptbook ecosystem**:
251
251
 
252
252
  ## 📖 The Book Whitepaper
253
253
 
254
- For most business applications nowadays, the biggest challenge isn't about the raw capabilities of AI models. Large language models like GPT-5 or Claude-4.1 are extremely capable.
254
+ Nowadays, the biggest challenge for most business applications isn't the raw capabilities of AI models. Large language models such as GPT-5.2 and Claude-4.5 are incredibly capable.
255
255
 
256
- The main challenge is to narrow it down, constrain it, set the proper **context, rules, knowledge, and personality**. There are a lot of tools which can do exactly this. On one side, there are no-code platforms which can launch your agent in seconds. On the other side, there are heavy frameworks like Langchain or Semantic Kernel, which can give you deep control.
256
+ The main challenge lies in **managing the context**, providing rules and knowledge, and narrowing the personality.
257
257
 
258
- Promptbook takes the best from both worlds. You are defining your AI behavior by simple **books**, which are very explicit. They are automatically enforced, but they are very easy to understand, very easy to write, and very reliable and portable.
258
+ In Promptbook, you can define your context **using simple Books** that are very explicit, easy to understand and write, reliable, and highly portable.
259
259
 
260
260
  <table style="border: 1px solid #777; border-radius: 10px;"><tr><td>
261
261
 
262
- **<ins>Paul Smith & Associés</ins>**<br/>
262
+ **<ins>Paul Smith</ins>**<br/>
263
263
  <br/>
264
264
  **PERSONA** You are a company lawyer.<br/>
265
265
  Your job is to provide legal advice and support to the company and its employees.<br/>
266
- You are knowledgeable, professional, and detail-oriented.<br/>
266
+ **RULE** You are knowledgeable, professional, and detail-oriented.<br/>
267
+ TEAM You are part of the legal team of Paul Smith & Associés, you discuss with {Emily White}, the head of the compliance department. {George Brown} is expert in corporate law and {Sophia Black} is expert in labor law.<br/>
267
268
 
268
269
  </td></tr></table>
269
270
 
@@ -273,7 +274,9 @@ You are knowledgeable, professional, and detail-oriented.<br/>
273
274
 
274
275
  We have created a language called **Book**, which allows you to write AI agents in their native language and create your own AI persona. Book provides a guide to define all the traits and commitments.
275
276
 
276
- You can look at it as prompting (or writing a system message), but decorated by **commitments**.
277
+ You can look at it as "prompting" _(or writing a system message)_, but decorated by **commitments**.
278
+
279
+ **Commitments** are special syntax elements that define contracts between you and the AI agent. They are transformed by Promptbook Engine into low-level parameters like which model to use, its temperature, system message, RAG index, MCP servers, and many other parameters. For some commitments _(for example `RULE` commitment)_ Promptbook Engine can even create adversary agents and extra checks to enforce the rules.
277
280
 
278
281
  #### `Persona` commitment
279
282
 
@@ -284,8 +287,6 @@ Personas define the character of your AI persona, its role, and how it should in
284
287
  **<ins>Paul Smith & Associés</ins>**<br/>
285
288
  <br/>
286
289
  **PERSONA** You are a company lawyer.<br/>
287
- Your job is to provide legal advice and support to the company and its employees.<br/>
288
- You are knowledgeable, professional, and detail-oriented.<br/>
289
290
 
290
291
  </td></tr></table>
291
292
 
@@ -305,7 +306,7 @@ Promptbook Engine will automatically enforce this knowledge during interactions.
305
306
  Your job is to provide legal advice and support to the company and its employees.<br/>
306
307
  You are knowledgeable, professional, and detail-oriented.<br/>
307
308
  <br/>
308
- **KNOWLEDGE** https://company.com/company-policies.pdf<br/>
309
+ **KNOWLEDGE** https://company.com/company-policies.pdf<br/>
309
310
  **KNOWLEDGE** https://company.com/internal-documents/employee-handbook.docx<br/>
310
311
 
311
312
  </td></tr></table>
@@ -327,14 +328,14 @@ You are knowledgeable, professional, and detail-oriented.<br/>
327
328
  **RULE** Always ensure compliance with laws and regulations.<br/>
328
329
  **RULE** Never provide legal advice outside your area of expertise.<br/>
329
330
  **RULE** Never provide legal advice about criminal law.<br/>
330
- **KNOWLEDGE** https://company.com/company-policies.pdf<br/>
331
+ **KNOWLEDGE** https://company.com/company-policies.pdf<br/>
331
332
  **KNOWLEDGE** https://company.com/internal-documents/employee-handbook.docx<br/>
332
333
 
333
334
  </td></tr></table>
334
335
 
335
- #### `Action` commitment
336
+ #### `Team` commitment
336
337
 
337
- Action Commitment allows you to define specific actions that the AI can take during interactions. This can include things like posting on a social media platform, sending emails, creating calendar events, or interacting with your internal systems.
338
+ Team commitment allows you to define the team structure and advisory fellow members the AI can consult with. This allows the AI to simulate collaboration and consultation with other experts, enhancing the quality of its responses.
338
339
 
339
340
  <table style="border: 1px solid #777; border-radius: 10px;"><tr><td>
340
341
 
@@ -347,81 +348,36 @@ You are knowledgeable, professional, and detail-oriented.<br/>
347
348
  **RULE** Always ensure compliance with laws and regulations.<br/>
348
349
  **RULE** Never provide legal advice outside your area of expertise.<br/>
349
350
  **RULE** Never provide legal advice about criminal law.<br/>
350
- **KNOWLEDGE** https://company.com/company-policies.pdf<br/>
351
+ **KNOWLEDGE** https://company.com/company-policies.pdf<br/>
351
352
  **KNOWLEDGE** https://company.com/internal-documents/employee-handbook.docx<br/>
352
- **ACTION** When a user asks about an issue that could be treated as a crime, notify legal@company.com.<br/>
353
+ TEAM You are part of the legal team of Paul Smith & Associés, you discuss with {Emily White}, the head of the compliance department. {George Brown} is expert in corporate law and {Sophia Black} is expert in labor law.<br/>
353
354
 
354
355
  </td></tr></table>
355
356
 
356
- [Read more about the language](./BLUEPRINT.md)
357
-
358
- <div style="page-break-after: always;"></div>
359
-
360
- ### Where to use your AI agent in book
361
-
362
- Books can be useful in various applications and scenarios. Here are some examples:
363
-
364
- #### Chat apps:
365
357
 
366
- Create your own chat shopping assistant and place it in your eShop.
367
- You will be able to answer customer questions, help them find products, and provide personalized recommendations. Everything is tightly controlled by the book you have written.
368
358
 
369
- #### Reply Agent:
359
+ ### Promptbook Ecosystem
370
360
 
371
- Create your own AI agent, which will look at your emails and reply to them. It can even create drafts for you to review before sending.
361
+ !!!@@@
372
362
 
373
- #### Coding Agent:
374
-
375
- Do you love Vibecoding, but the AI code is not always aligned with your coding style and architecture, rules, security, etc.? Create your own coding agent to help enforce your specific coding standards and practices.
376
-
377
- This can be integrated to almost any Vibecoding platform, like GitHub Copilot, Amazon CodeWhisperer, Cursor, Cline, Kilocode, Roocode,...
378
-
379
- They will work the same as you are used to, but with your specific rules written in book.
380
-
381
- #### Internal Expertise
382
-
383
- Do you have an app written in TypeScript, Python, C#, Java, or any other language, and you are integrating the AI.
384
-
385
- You can avoid struggle with choosing the best model, its settings like temperature, max tokens, etc., by writing a book agent and using it as your AI expertise.
386
-
387
- Doesn't matter if you do automations, data analysis, customer support, sentiment analysis, classification, or any other task. Your AI agent will be tailored to your specific needs and requirements.
388
-
389
- Even works in no-code platforms!
390
-
391
- <div style="page-break-after: always;"></div>
363
+ #### Promptbook Server
392
364
 
393
- ### How to create your AI agent in book
365
+ !!!@@@
394
366
 
395
- Now you want to use it. There are several ways how to write your first book:
367
+ #### Promptbook Engine
396
368
 
397
- #### From scratch with help from Paul
369
+ !!!@@@
398
370
 
399
- We have written ai asistant in book who can help you with writing your first book.
400
371
 
401
- #### Your AI twin
402
372
 
403
- Copy your own behavior, personality, and knowledge into book and create your AI twin. It can help you with your work, personal life, or any other task.
404
373
 
405
- #### AI persona workpool
406
374
 
407
- Or you can pick from our library of pre-written books for various roles and tasks. You can find books for customer support, coding, marketing, sales, HR, legal, and many other roles.
408
375
 
409
376
 
410
377
 
411
378
 
412
379
 
413
380
 
414
- ## 🚀 Get started
415
-
416
- Take a look at the simple starter kit with books integrated into the **Hello World** sample applications:
417
-
418
- - [Hello Book](https://github.com/webgptorg/hello-world)
419
- - [Hello Book in Node.js](https://github.com/webgptorg/hello-world-node-js)
420
- - [Hello Book in Next.js](https://github.com/webgptorg/hello-world-next-js)
421
-
422
-
423
-
424
-
425
381
 
426
382
 
427
383
  ## 💜 The Promptbook Project
@@ -437,33 +393,32 @@ Promptbook project is ecosystem of multiple projects and tools, following is a l
437
393
  </thead>
438
394
  <tbody>
439
395
  <tr>
440
- <td><a href="https://github.com/webgptorg/book">Book language</a></td>
396
+ <td><a href="https://gallery.ptbk.io/">Agents Server</a></td>
441
397
  <td>
442
- Book is a human-understandable markup language for writing AI applications such as chatbots, knowledge bases, agents, avarars, translators, automations and more.
443
- <hr>
444
- There is also <a href="https://github.com/webgptorg/book-extension">a plugin for VSCode</a> to support <code>.book</code> file extension
398
+ Place where you "AI agents live". It allows to create, manage, deploy, and interact with AI agents created in Book language.
445
399
  </td>
446
400
  </tr>
447
401
  <tr>
448
- <td><a href="https://github.com/webgptorg/promptbook">Promptbook Engine</a></td>
402
+ <td><a href="https://github.com/webgptorg/book">Book language</a></td>
449
403
  <td>
450
- Promptbook engine can run applications written in Book language. It is released as <a href="https://www.npmjs.com/package/@promptbook/core#-packages-for-developers">multiple NPM packages</a> and <a href="https://hub.docker.com/r/hejny/promptbook">Docker HUB</a>
404
+ Human-friendly, high-level language that abstracts away low-level details of AI. It allows to focus on personality, behavior, knowledge, and rules of AI agents rather than on models, parameters, and prompt engineering.
405
+ <hr>
406
+ There is also <a href="https://github.com/webgptorg/book-extension">a plugin for VSCode</a> to support <code>.book</code> file extension
451
407
  </td>
452
408
  </tr>
453
409
  <tr>
454
- <td><a href="https://promptbook.studio">Promptbook Studio</a></td>
410
+ <td><a href="https://github.com/webgptorg/promptbook">Promptbook Engine</a></td>
455
411
  <td>
456
- Promptbook.studio is a web-based editor and runner for book applications. It is still in the experimental MVP stage.
412
+ Promptbook engine can run AI agents based on Book language.
413
+ It is released as <a href="https://www.npmjs.com/package/@promptbook/core#-packages-for-developers">multiple NPM packages</a> and <a href="https://hub.docker.com/r/hejny/promptbook">Promptbook Agent Server as Docker Package</a>
414
+ Agent Server is based on Promptbook Engine.
457
415
  </td>
458
416
  </tr>
417
+
459
418
  </tbody>
460
419
  </table>
461
420
 
462
- Hello world examples:
463
421
 
464
- - [Hello world](https://github.com/webgptorg/hello-world)
465
- - [Hello world in Node.js](https://github.com/webgptorg/hello-world-node-js)
466
- - [Hello world in Next.js](https://github.com/webgptorg/hello-world-next-js)
467
422
 
468
423
  ### 🌐 Community & Social Media
469
424
 
@@ -521,6 +476,8 @@ Join our growing community of developers and users:
521
476
 
522
477
 
523
478
 
479
+
480
+
524
481
  ## 📚 Documentation
525
482
 
526
483
  See detailed guides and API reference in the [docs](https://github.com/webgptorg/promptbook/discussions/categories/concepts) or [online](https://discord.gg/x3QWNaa89N).
@@ -597,6 +554,8 @@ The following glossary is used to clarify certain concepts:
597
554
 
598
555
  _Note: This section is not a complete dictionary, more list of general AI / LLM terms that has connection with Promptbook_
599
556
 
557
+
558
+
600
559
  ### 💯 Core concepts
601
560
 
602
561
  - [📚 Collection of pipelines](https://github.com/webgptorg/promptbook/discussions/65)
package/esm/index.es.js CHANGED
@@ -1,6 +1,6 @@
1
- import colors from 'colors';
2
- import spaceTrim$2, { spaceTrim as spaceTrim$1 } from 'spacetrim';
3
1
  import { randomBytes } from 'crypto';
2
+ import spaceTrim$2, { spaceTrim as spaceTrim$1 } from 'spacetrim';
3
+ import colors from 'colors';
4
4
 
5
5
  // ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
6
6
  /**
@@ -16,32 +16,12 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
16
16
  * @generated
17
17
  * @see https://github.com/webgptorg/promptbook
18
18
  */
19
- const PROMPTBOOK_ENGINE_VERSION = '0.105.0-3';
19
+ const PROMPTBOOK_ENGINE_VERSION = '0.105.0-30';
20
20
  /**
21
21
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
22
22
  * Note: [💞] Ignore a discrepancy between file name and entity name
23
23
  */
24
24
 
25
- /**
26
- * Detects if the code is running in jest environment
27
- *
28
- * Note: `$` is used to indicate that this function is not a pure function - it looks at the global object to determine the environment
29
- *
30
- * @public exported from `@promptbook/utils`
31
- */
32
- function $isRunningInJest() {
33
- var _a;
34
- try {
35
- return typeof process !== 'undefined' && ((_a = process.env) === null || _a === void 0 ? void 0 : _a.JEST_WORKER_ID) !== undefined;
36
- }
37
- catch (e) {
38
- return false;
39
- }
40
- }
41
- /**
42
- * TODO: [🎺]
43
- */
44
-
45
25
  /**
46
26
  * Generates random token
47
27
  *
@@ -597,6 +577,26 @@ function uncertainNumber(value, isUncertain) {
597
577
  return { value };
598
578
  }
599
579
 
580
+ /**
581
+ * Detects if the code is running in jest environment
582
+ *
583
+ * Note: `$` is used to indicate that this function is not a pure function - it looks at the global object to determine the environment
584
+ *
585
+ * @public exported from `@promptbook/utils`
586
+ */
587
+ function $isRunningInJest() {
588
+ var _a;
589
+ try {
590
+ return typeof process !== 'undefined' && ((_a = process.env) === null || _a === void 0 ? void 0 : _a.JEST_WORKER_ID) !== undefined;
591
+ }
592
+ catch (e) {
593
+ return false;
594
+ }
595
+ }
596
+ /**
597
+ * TODO: [🎺]
598
+ */
599
+
600
600
  /**
601
601
  * Simple wrapper `new Date().toISOString()`
602
602
  *
@@ -2543,7 +2543,20 @@ const GOOGLE_MODELS = exportJson({
2543
2543
  output: pricing(`$27.00 / 1M tokens`),
2544
2544
  },
2545
2545
  },
2546
- // …add any additional from https://ai.google.dev/models/gemini…
2546
+ {
2547
+ modelVariant: 'IMAGE_GENERATION',
2548
+ modelName: 'gemini-2.5-flash-image',
2549
+ modelTitle: 'Gemini 2.5 Flash Image (Nano Banana)',
2550
+ modelDescription: 'This model is designed for speed and efficiency, optimized for high-volume, low-latency tasks. All generated images include a SynthID watermark.',
2551
+ documentationUrl: 'https://ai.google.dev/gemini-api/docs/image-generation',
2552
+ },
2553
+ {
2554
+ modelVariant: 'IMAGE_GENERATION',
2555
+ modelName: 'gemini-3-pro-image-preview',
2556
+ modelTitle: 'Gemini 3 Pro Image Preview (Nano Banana Pro)',
2557
+ modelDescription: 'This model is designed for professional asset production, utilizing advanced reasoning ("Thinking") to follow complex instructions and render high-fidelity text. All generated images include a SynthID watermark.',
2558
+ documentationUrl: 'https://ai.google.dev/gemini-api/docs/image-generation',
2559
+ },
2547
2560
  ],
2548
2561
  });
2549
2562
  /**
@@ -2561,6 +2574,42 @@ const GOOGLE_PROVIDER_PROFILE = {
2561
2574
  fullname: 'Google Gemini',
2562
2575
  color: '#4285f4',
2563
2576
  };
2577
+ const DEFAULT_GOOGLE_GENERATIVE_AI_BASE_URL = 'https://generativelanguage.googleapis.com/v1beta';
2578
+ const GOOGLE_IMAGE_RESPONSE_MODALITIES = {
2579
+ responseModalities: ['TEXT', 'IMAGE'],
2580
+ };
2581
+ /**
2582
+ * Resolve the Google API key from options or environment.
2583
+ */
2584
+ function resolveGoogleApiKey(options) {
2585
+ const apiKey = options.apiKey || process.env.GOOGLE_GENERATIVE_AI_API_KEY;
2586
+ if (!apiKey) {
2587
+ throw new PipelineExecutionError('Missing Google Generative AI API key. Set GOOGLE_GENERATIVE_AI_API_KEY or pass apiKey.');
2588
+ }
2589
+ return apiKey;
2590
+ }
2591
+ /**
2592
+ * Normalize the Google Generative AI base URL.
2593
+ */
2594
+ function normalizeGoogleBaseUrl(baseUrl) {
2595
+ return (baseUrl || DEFAULT_GOOGLE_GENERATIVE_AI_BASE_URL).replace(/\/+$/u, '');
2596
+ }
2597
+ /**
2598
+ * Extract inline image data from a Google image generation response.
2599
+ */
2600
+ function extractGoogleImageData(rawResponse) {
2601
+ var _a, _b, _c;
2602
+ const parts = ((_c = (_b = (_a = rawResponse.candidates) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.content) === null || _c === void 0 ? void 0 : _c.parts) || [];
2603
+ const imagePart = parts.find((part) => { var _a, _b; return ((_a = part.inlineData) === null || _a === void 0 ? void 0 : _a.data) || ((_b = part.inline_data) === null || _b === void 0 ? void 0 : _b.data); });
2604
+ const inlineData = (imagePart === null || imagePart === void 0 ? void 0 : imagePart.inlineData) || (imagePart === null || imagePart === void 0 ? void 0 : imagePart.inline_data);
2605
+ if (!(inlineData === null || inlineData === void 0 ? void 0 : inlineData.data)) {
2606
+ throw new PipelineExecutionError('No image data returned by Google image generation model');
2607
+ }
2608
+ return {
2609
+ base64: inlineData.data,
2610
+ contentType: inlineData.mimeType || 'image/png',
2611
+ };
2612
+ }
2564
2613
  /**
2565
2614
  * Execution Tools for calling Google Gemini API.
2566
2615
  *
@@ -2588,12 +2637,106 @@ const createGoogleExecutionTools = Object.assign((options) => {
2588
2637
  return {
2589
2638
  ...baseTools,
2590
2639
  profile: GOOGLE_PROVIDER_PROFILE,
2640
+ async callImageGenerationModel(prompt) {
2641
+ const { content, parameters, modelRequirements } = prompt;
2642
+ // TODO: [☂] Use here more modelRequirements
2643
+ if (modelRequirements.modelVariant !== 'IMAGE_GENERATION') {
2644
+ throw new PipelineExecutionError('Use callImageGenerationModel only for IMAGE_GENERATION variant');
2645
+ }
2646
+ const modelName = modelRequirements.modelName || 'gemini-3-pro-image-preview';
2647
+ const rawPromptContent = templateParameters(content, { ...parameters, modelName });
2648
+ const start = $getCurrentDate();
2649
+ const apiKey = resolveGoogleApiKey(options);
2650
+ const baseUrl = normalizeGoogleBaseUrl(options.baseURL);
2651
+ const fetchFunction = options.fetch || fetch;
2652
+ const rawRequest = {
2653
+ contents: [
2654
+ {
2655
+ role: 'user',
2656
+ parts: [
2657
+ {
2658
+ text: rawPromptContent,
2659
+ },
2660
+ ],
2661
+ },
2662
+ ],
2663
+ generationConfig: GOOGLE_IMAGE_RESPONSE_MODALITIES,
2664
+ };
2665
+ const rawResponseText = await fetchFunction(`${baseUrl}/models/${modelName}:generateContent`, {
2666
+ method: 'POST',
2667
+ headers: {
2668
+ 'Content-Type': 'application/json',
2669
+ 'x-goog-api-key': apiKey,
2670
+ ...options.headers,
2671
+ },
2672
+ body: JSON.stringify(rawRequest),
2673
+ })
2674
+ .then(async (response) => {
2675
+ const responseText = await response.text();
2676
+ if (!response.ok) {
2677
+ throw new PipelineExecutionError(`Google image generation failed (${response.status} ${response.statusText}): ${responseText || 'No response body'}`);
2678
+ }
2679
+ return responseText;
2680
+ })
2681
+ .catch((error) => {
2682
+ if (error instanceof PipelineExecutionError) {
2683
+ throw error;
2684
+ }
2685
+ const message = error instanceof Error ? error.message : 'Unknown error';
2686
+ throw new PipelineExecutionError(`Google image generation request failed: ${message}`);
2687
+ });
2688
+ let rawResponse;
2689
+ try {
2690
+ rawResponse = JSON.parse(rawResponseText);
2691
+ }
2692
+ catch (error) {
2693
+ const message = error instanceof Error ? error.message : 'Unknown error';
2694
+ throw new PipelineExecutionError(`Failed to parse Google image response: ${message}`);
2695
+ }
2696
+ const image = extractGoogleImageData(rawResponse);
2697
+ const complete = $getCurrentDate();
2698
+ const usageMetadata = rawResponse.usageMetadata;
2699
+ return exportJson({
2700
+ name: 'promptResult',
2701
+ message: `Result of \`GoogleExecutionTools.callImageGenerationModel\``,
2702
+ order: [],
2703
+ value: {
2704
+ content: `data:${image.contentType};base64,${image.base64}`,
2705
+ modelName,
2706
+ timing: {
2707
+ start,
2708
+ complete,
2709
+ },
2710
+ usage: {
2711
+ price: uncertainNumber(),
2712
+ input: {
2713
+ tokensCount: uncertainNumber(usageMetadata === null || usageMetadata === void 0 ? void 0 : usageMetadata.promptTokenCount),
2714
+ ...computeUsageCounts(rawPromptContent),
2715
+ },
2716
+ output: {
2717
+ tokensCount: uncertainNumber(usageMetadata === null || usageMetadata === void 0 ? void 0 : usageMetadata.candidatesTokenCount),
2718
+ ...computeUsageCounts(''),
2719
+ },
2720
+ },
2721
+ rawPromptContent,
2722
+ rawRequest: {
2723
+ prompt: rawPromptContent,
2724
+ googleRequest: rawRequest,
2725
+ },
2726
+ rawResponse: {
2727
+ image,
2728
+ googleResponse: rawResponse,
2729
+ },
2730
+ },
2731
+ });
2732
+ },
2591
2733
  };
2592
2734
  }, {
2593
2735
  packageName: '@promptbook/google',
2594
2736
  className: 'GoogleExecutionTools',
2595
2737
  });
2596
2738
  /**
2739
+ * TODO: !!!!! Rename to `createGoogleLlmExecutionTools`, `...GoogleLlmExecutionTools`
2597
2740
  * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
2598
2741
  */
2599
2742