@promptbook/cli 0.103.0-32 → 0.103.0-34

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 (25) hide show
  1. package/esm/index.es.js +2821 -155
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/cli.index.d.ts +0 -2
  4. package/esm/typings/src/_packages/core.index.d.ts +2 -0
  5. package/esm/typings/src/_packages/types.index.d.ts +2 -2
  6. package/esm/typings/src/_packages/wizard.index.d.ts +0 -2
  7. package/esm/typings/src/book-2.0/agent-source/padBook.d.ts +1 -1
  8. package/esm/typings/src/execution/ExecutionTask.d.ts +12 -3
  9. package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +5 -0
  10. package/esm/typings/src/execution/createPipelineExecutor/20-executeTask.d.ts +5 -0
  11. package/esm/typings/src/execution/createPipelineExecutor/30-executeFormatSubvalues.d.ts +5 -0
  12. package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +5 -0
  13. package/esm/typings/src/execution/utils/logLlmCall.d.ts +8 -0
  14. package/esm/typings/src/transpilers/_common/BookTranspiler.d.ts +26 -17
  15. package/esm/typings/src/transpilers/_common/BookTranspilerOptions.d.ts +2 -3
  16. package/esm/typings/src/transpilers/_common/register/$bookTranspilersRegister.d.ts +2 -2
  17. package/esm/typings/src/transpilers/openai/OpenAiSdkTranspiler.d.ts +9 -9
  18. package/esm/typings/src/types/LlmCall.d.ts +20 -0
  19. package/esm/typings/src/version.d.ts +1 -1
  20. package/package.json +1 -1
  21. package/umd/index.umd.js +2820 -155
  22. package/umd/index.umd.js.map +1 -1
  23. package/esm/typings/src/transpilers/_common/BookTranspilerDefinition.d.ts +0 -37
  24. package/esm/typings/src/transpilers/langchain/LangchainTranspiler.d.ts +0 -7
  25. package/esm/typings/src/transpilers/langchain/register.d.ts +0 -15
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.103.0-32';
59
+ const PROMPTBOOK_ENGINE_VERSION = '0.103.0-34';
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
@@ -6085,7 +6085,7 @@
6085
6085
  * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
6086
6086
  */
6087
6087
 
6088
- var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book",formfactorName:"GENERIC",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge from Markdown\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book`\n- INPUT PARAMETER `{knowledgeContent}` Markdown document content\n- OUTPUT PARAMETER `{knowledgePieces}` The knowledge JSON object\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}\n```\n\n`-> {knowledgePieces}`\n"}],sourceFile:"./books/prepare-knowledge-from-markdown.book"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Keywords\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-keywords.book`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{keywords}` Keywords separated by comma\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}\n```\n\n`-> {keywords}`\n"}],sourceFile:"./books/prepare-knowledge-keywords.book"},{title:"Prepare Knowledge-piece Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge-piece Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-title.book`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{title}` The title of the document\n\n## Knowledge\n\n- EXPECT MIN 1 WORD\n- EXPECT MAX 8 WORDS\n\n```markdown\nYou are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-knowledge-title.book"},{title:"Prepare Persona",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book",formfactorName:"GENERIC",parameters:[{name:"availableModels",description:"List of available model names together with their descriptions as JSON",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelsRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-model-requirements",title:"Make modelRequirements",content:"You are an experienced AI engineer, you need to find the best models for virtual assistants:\n\n## Example\n\n```json\n[\n {\n \"modelName\": \"gpt-4o\",\n \"systemMessage\": \"You are experienced AI engineer and helpful assistant.\",\n \"temperature\": 0.7\n },\n {\n \"modelName\": \"claude-3-5-sonnet\",\n \"systemMessage\": \"You are a friendly and knowledgeable chatbot.\",\n \"temperature\": 0.5\n }\n]\n```\n\n## Instructions\n\n- Your output format is JSON array\n- Sort best-fitting models first\n- Omit any models that are not suitable\n- Write just the JSON, no other text should be present\n- Array contain items with following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nHere are the available models:\n\n```json\n{availableModels}\n```\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelsRequirements",format:"JSON",dependentParameterNames:["availableModels","personaDescription"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Persona\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-persona.book`\n- INPUT PARAMETER `{availableModels}` List of available model names together with their descriptions as JSON\n- INPUT PARAMETER `{personaDescription}` Description of the persona\n- OUTPUT PARAMETER `{modelsRequirements}` Specific requirements for the model\n\n## Make modelRequirements\n\n- FORMAT JSON\n\n```markdown\nYou are an experienced AI engineer, you need to find the best models for virtual assistants:\n\n## Example\n\n\\`\\`\\`json\n[\n {\n \"modelName\": \"gpt-4o\",\n \"systemMessage\": \"You are experienced AI engineer and helpful assistant.\",\n \"temperature\": 0.7\n },\n {\n \"modelName\": \"claude-3-5-sonnet\",\n \"systemMessage\": \"You are a friendly and knowledgeable chatbot.\",\n \"temperature\": 0.5\n }\n]\n\\`\\`\\`\n\n## Instructions\n\n- Your output format is JSON array\n- Sort best-fitting models first\n- Omit any models that are not suitable\n- Write just the JSON, no other text should be present\n- Array contain items with following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nHere are the available models:\n\n\\`\\`\\`json\n{availableModels}\n\\`\\`\\`\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}\n```\n\n`-> {modelsRequirements}`\n"}],sourceFile:"./books/prepare-persona.book"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-title.book",formfactorName:"GENERIC",parameters:[{name:"book",description:"The book to prepare the title for",isInput:true,isOutput:false},{name:"title",description:"Best title for the book",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-title",title:"Make title",content:"Make best title for given text which describes the workflow:\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\n- Title starts with emoticon\n- Title should not mention the input and output of the workflow but the main purpose of the workflow\n _For example, not \"✍ Convert Knowledge-piece to title\" but \"✍ Title\"_\n\n## The workflow\n\n> {book}",resultingParameterName:"title",expectations:{words:{min:1,max:8},lines:{min:1,max:1}},dependentParameterNames:["book"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-title.book`\n- INPUT PARAMETER `{book}` The book to prepare the title for\n- OUTPUT PARAMETER `{title}` Best title for the book\n\n## Make title\n\n- EXPECT MIN 1 Word\n- EXPECT MAX 8 Words\n- EXPECT EXACTLY 1 Line\n\n```markdown\nMake best title for given text which describes the workflow:\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\n- Title starts with emoticon\n- Title should not mention the input and output of the workflow but the main purpose of the workflow\n _For example, not \"✍ Convert Knowledge-piece to title\" but \"✍ Title\"_\n\n## The workflow\n\n> {book}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-title.book"},{title:"📊 Curriculum Audit",pipelineUrl:"https://promptbook.studio/promptbook//examples/lsvp-asistent.book",formfactorName:"GENERIC",parameters:[{name:"result",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"prompt",title:"Prompt",content:"Asistent pro LŠVP\n\nPERSONA Jsi asistent pro RVP Lyceum v rámci Národního pedagogického institutu České Republiky\nMETA IMAGE https://edulk.cz/getFile/id:475818/type:large/02%20zna%C4%8Dka%20npi.jpg\nRULE Pokud jsi nejsi jistý, napiš nevím\nKNOWLEDGE ./241129_Lyceum_final.pdf\nCONTEXT Obecně dokážeš řešit libovolné ŠVP, aktuálně řešíš {Školní vzdělávací program LYCEUM}\nRULE Z {Porovnání RVP a ŠVP - postup} je nejdůležitější fáze 3\nKNOWLEDGE {Školní vzdělávací program LYCEUM} ./ŠVP Lyceum - Finance v digitální době.pdf\nKNOWLEDGE @Slovník\n\n**Interní slovník - RVP/ŠVP**\n\n**RVP**\n\nRámcový vzdělávací program pro obor vzdělání Lyceum je dokument na národní úrovni, který formuluje požadavky na školní vzdělávací programy ve formě především očekávaných výsledků učení, kterých mají žáci absolvováním tohoto programu na dané škole dosáhnout.\n\n**ŠVP**\n\nŠkolní vzdělávací program pro obor vzdělání Lyceum je dokument každé jednotlivé školy, který popisuje v jakých vyučovacích předmětech/ vzdělávacích modulech a v jakých ročnících budou požadované očekávané výsledky učení naplněny. Zároveň formuluje další očekávané výsledky učení, které naplňují disponibilní část vyučovacího času určeného RVP pro tento obor vzdělání.\n\n**Očekávaný výsledek učení (OVU)**\n\nVyjadřuje jednotlivý požadavek na to, co mají žáci umět na konci vzdělávacího programu, tzn. jejich požadované kompetence. Je vyjádřen formulací, která je uvozena činnostním slovesem a dále obsahuje předmět této činnosti. Formulace je konkretizována resp. doplněna zpravidla formou odrážek vymezením dílčích znalostí, dovedností, postojů, jejichž splnění je předpokladem dosažení OVU jako celku.\n\n_Příklad:_\n\n<div class=\"joplin-table-wrapper\"><table><tbody><tr><th><p><strong>Žák/žákyně řídí realizaci jednoduchého projektu</strong></p></th></tr><tr><td><ul><li>naplánuje aktivity projektu</li></ul></td></tr><tr><td><ul><li>navrhne rozpočet projektu vzhledem k navrženým aktivitám</li></ul></td></tr><tr><td><ul><li>stanoví základní ukazatele a sleduje jejich naplňování</li></ul></td></tr><tr><td><ul><li>vede projektový tým</li></ul></td></tr><tr><td><ul><li>uvede, jak by řešil krizové situace v projektu</li></ul></td></tr><tr><td><ul><li>vyhodnotí úspěšnost projektu</li></ul></td></tr></tbody></table></div>\n\n**Vzdělávací oblasti**\n\nOčekávané výsledky učení jsou v **_RVP členěny do 4 vzdělávacích oblastí_**, které tvoří společný všeobecně vzdělávací základ:\n\n- Osobnostní rozvoj, vzdělávání ke zdraví, bezpečí a produktivnímu pracovnímu životu (kariéře)\n- Komunikační a jazykové vzdělávání\n- Aplikované vzdělávání STEM (Science, Technology, Engeneering, Math), tj. přírodní vědy, informatika, technika, matematika\n- Prakticky orientované vzdělávání společenskovědní a humanitní\n\nKaždá vzdělávací oblast se dále člení na okruhy, v jejichž rámci jsou OVU samostatně číslované.\n\n<div class=\"joplin-table-wrapper\"><table><tbody><tr><th rowspan=\"21\"><ul><li>Prakticky orientované vzdělávání společenskovědní a humanitní</li></ul></th><th rowspan=\"21\"><p><strong>Člověk, ekonomie a podnikání</strong></p></th><th rowspan=\"7\"><p><strong>1</strong></p></th><th><p><strong>zpracuje podklady související s podnikáním</strong></p></th></tr><tr><td><p>připraví podnikatelský záměr</p></td></tr><tr><td><p>sestaví zakladatelský rozpočet</p></td></tr><tr><td><p>zkalkuluje cenu zboží nebo služby</p></td></tr><tr><td><p>vysvětlí na příkladu základní povinnosti podnikatele vůči státu a zaměstnancům</p></td></tr><tr><td><p>vede daňovou evidenci</p></td></tr><tr><td><p>vysvětlí na příkladech etiku v podnikání</p></td></tr><tr><td rowspan=\"7\"><p><strong>2</strong></p></td><td><p><strong>řídí realizaci jednoduchého projektu</strong></p></td></tr><tr><td><p>naplánuje aktivity projektu</p></td></tr><tr><td><p>navrhne rozpočet projektu vzhledem k navrženým aktivitám</p></td></tr><tr><td><p>stanoví základní ukazatele a sleduje jejich naplňování</p></td></tr><tr><td><p>vede projektový tým</p></td></tr><tr><td><p>uvede, jak by řešil krizové situace v projektu</p></td></tr><tr><td><p>vyhodnotí úspěšnost projektu</p></td></tr><tr><td rowspan=\"7\"><p><strong>3</strong></p></td><td><p><strong>aplikuje ekonomické teorie v osobním a profesním životě</strong></p></td></tr><tr><td><p>vysvětlí základní ekonomické otázky</p></td></tr><tr><td><p>vysvětí stanovení rovnovážné ceny na dokonalém i nedokonalém trhu</p></td></tr><tr><td><p>charakterizuje výrobní faktory a vysvětlí hranici produkčních možností a náklady obětované příležitosti</p></td></tr><tr><td><p>uvede nejdůležitější makroekonomické pojmy a vliv jejich výše na kvalitu života a podnikání v daném státě</p></td></tr><tr><td><p>vysvětlí podstatu inflace a její důsledky na finanční situaci obyvatel a na příkladu ukáže jak se bránit jejím nepříznivým důsledkům</p></td></tr><tr><td><p>uvede hlavní výhody a nevýhody mezinárodního obchodu a vliv ochranářských opatření na ekonomickou situaci dané země</p></td></tr><tr><td></td><td></td><td><p><strong>4</strong></p></td><td><p>Atd.</p></td></tr></tbody></table></div>\n\n**Vyučovací předmět / vzdělávací modul**\n\nOčekávané výsledky učení jsou v **ŠVP** členěny do vyučovacích předmětů nebo vzdělávacích modulů, které jsou dále zařazeny do jednoho nebo více ročníků 4letého studia. Vyučovací předmět / vzdělávací modul tvoří vyučovací jednotku, kde jsou očekávané výsledky učení dále rozpracovány pro potřeby výuky podle následující šablony\n\n| **A. VSTUPNÍ ČÁST** |\n| --- |\n| **1\\. Název** |\n| **2\\. Kód** (kódy by měly být navázány na obory vzdělání a výsledky učení) |\n| **2a) Kategorie vzdělání** - v případě, že nebude součástí kódu |\n| **3\\. Typ vyučovací jednotky** (modul, předmět, stáž apod.) |\n| **4\\. Délka** (počet hodin - dělitelný čtyřmi (optimální modul 16, 32 hodin = týden výuky) |\n| **5\\. Platnost** (datum, od kterého platí) |\n| **6\\. Vstupní předpoklady** (vymezení požadované úrovně vstupních vědomostí a dovedností, které jsou předpokladem úspěšného studia) |\n| |\n| **B. JÁDRO VYUČOVACÍ JEDNOTKY** |\n| **1\\. Charakteristika** (stručná anotace popisující obecné cíle a pojetí) |\n| **2\\. Očekávané výsledky učení a jejich indikátory (převzaté z RVP nebo dále konkretizované)** |\n| **3\\. Podpora rozvoje klíčových kompetencí a základních gramotností** (které klíčové kompetence jsou v rozvíjeny) |\n| **4\\. Obsah vzdělávání** (rozpis učiva) |\n| **5\\. Vzdělávací strategie** (strategie výuky, resp. učební činnosti žáků, které jsou doporučené pro dosažení výsledků) |\n| |\n| **C. VÝSTUPNÍ ČÁST** |\n| **1\\. Způsob ověřování dosažených výsledků** (ve vazbě na jednotlivé výsledky učení) |\n| **2\\. Kritéria hodnocení** (co znamená splnění výsledků učení, kdy je splněna celá vyučovací jednotka, kritéria pro známky, příp. procentuální, slovní hodnocení) |\n| **3\\. Doporučená studijní literatura, odkazy na ilustrační zdroje** |\n| **4\\. Poznámky** |\n\n**Soulad OVU RVP a ŠVP**\n\nTento soulad je předmětem zjišťování. Soulad nastává, jestliže jsou očekávané výsledky učení z jednotlivých vzdělávacích oblastí RVP **obsaženy** ve vyučovacích předmětech/ vzdělávacích modulech ŠVP jednotlivých škol, tzn. že v ŠVP se objevuje jejich formulace buď v doslovném nebo podobném znění v jednom nebo více vyučovacích předmětech/ vzdělávacích modulech.\n\n_Příklad souladu:_\n\nRVP ŠVP - komunikace a marketing (SŠ obchodní Č.\n\n| **2** | **řídí realizaci jednoduchého projektu** |\n| --- | --- |\n| naplánuje aktivity projektu |\n| navrhne rozpočet projektu vzhledem k navrženým aktivitám |\n| stanoví základní ukazatele a sleduje jejich naplňování |\n| vede projektový tým |\n| uvede, jak by řešil krizové situace v projektu |\n| vyhodnotí úspěšnost projektu |\n\nKNOWLEDGE {Porovnání RVP a ŠVP - postup}\n\n\n# AUDITNÍ PROTOKOL ŠVP-RVP\n\n# (POPIS KONTROLNÍHO ALGORITMU)\n\nMetodika je určena pro **Kvantifikaci Shody** školního vzdělávacího programu (ŠVP) s Rámcovým vzdělávacím programem (RVP).\n\n## FÁZE 1: VALIDACE DOKUMENTACE\n\n**Cíl:** Ověřit platnost, aktuálnost a strukturu zdrojových dokumentů.\n\n- **RVP Verifikace:** Otevřít aktuální verzi RVP (např. RVP ZV/G/SOŠ).\n- **Typová shoda:** Ověřit, že RVP se vztahuje k danému typu školy.\n- **ŠVP Dimenze:** Identifikovat a izolovat relevantní části ŠVP: Profil absolventa, Klíčové kompetence (KK), Vzdělávací oblasti (VO), případně Učební plán (UP).\n- **Verzování:** Potvrdit, že obě verze (RVP a ŠVP) jsou nejnovější a platné (včetně dodatků RVP).\n\n## FÁZE 2: DATABÁZOVÉ MAPOVÁNÍ VÝSTUPŮ (MASTER MATICE)\n\n**Cíl:** Vytvořit systémovou databázi pro křížové porovnání všech povinných komponent RVP se ŠVP.\n\n- **Dekompozice RVP:** Rozložit RVP na základní povinné komponenty: Klíčové kompetence, Vzdělávací oblasti a obory, Očekávané výstupy (OVU), Průřezová témata (PT).\n- **Přiřazovací mapa:** Vytvořit hlavní kontrolní matici (Master Matice) pro záznam vazeb.\n\n| Oblast RVP | Výstup RVP (OVU) | Odpovídající Část ŠVP (Předmět/Ročník) | Konkrétní Tématický Celek v ŠVP | Stav Shody (Protokol) |\n| --- | --- | --- | --- | --- |\n| ... | ... | ... | ... | ... |\n| --- | --- | --- | --- | --- |\n\n## FÁZE 3: ALGORITMICKÁ KONTROLA POKRYTÍ A HLOUBKY\n\n**Cíl:** Posoudit, zda každý povinný výstup RVP je adekvátně reflektován v obsahu ŠVP, a přidělit bodovou hodnotu pro kvantifikaci.\n\n- **Audit OVU:** Projít každý jednotlivý Očekávaný výstup (OVU) z RVP.\n- **Kódování stavu a bodování:** U každého OVU v matici označit stav pokrytí dle následujícího schématu:\n\n| Kód (Protokol) | Popis (Kvalitativní zjištění) | Bodová hodnota (Kvantifikace) |\n| --- | --- | --- |\n| ✅ | Plná shoda (Výstup pokryt v plném rozsahu, odpovídající úrovni RVP) | 1,0 |\n| --- | --- | --- |\n| ⚠️ | Částečná shoda (Formální pokrytí, omezený rozsah, chybná návaznost) | 0,5 |\n| --- | --- | --- |\n| ❌ | Absence (Výstup zcela chybí v obsahu ŠVP) | 0,0 |\n| --- | --- | --- |\n\n- **Defektologie ŠVP:** Identifikovat a zaznamenat deficity ŠVP: Chybějící výstupy (❌), Sémantické překryvy, Přetížení obsahu.\n- **Kvalitativní posun:** Ověřit, zda je formulace výstupů v ŠVP **aktivní, měřitelná a v souladu** s úrovní RVP.\n\n## FÁZE 4: STRUKTURÁLNÍ VERIFIKACE NÁVAZNOSTI (VERTIKÁLA/HORIZONTÁLA)\n\n**Cíl:** Zkontrolovat logickou posloupnost a provázanost učiva v rámci ŠVP.\n\n- **Vertikální Kontrola:** Ověřit posloupnost OVU a učiva uvnitř jednoho předmětu/oblasti (postup od jednodušších ke složitějším konceptům napříč ročníky).\n- **Horizontální Kontrola:** Zkontrolovat logické provázání napříč vzdělávacími oblastmi a předměty (např. fyzika ↔ matematika).\n- **PT Integrace:** Audit reálné integrace Průřezových témat (PT) do konkrétních částí obsahu, metod a projektů.\n\n## FÁZE 5: ANALÝZA ŠKOLNÍ PROFILACE A ROZŠÍŘENÍ RVP\n\n**Cíl:** Validovat, že profilace školy je **v souladu** s RVP a nejedná se o **rozpor**.\n\n- **Nekonfliktnost:** Porovnat definovaný Profil absolventa školy s Klíčovými kompetencemi RVP. Profil ŠVP musí RVP rozvíjet, nikoli mu odporovat.\n- **Modularita:** Zkontrolovat, zda volitelné předměty a rozšiřující moduly logicky navazují na vzdělávací oblasti RVP.\n- **Implementace specializace:** Popisně uvést, jak je školní profilace (např. STEM zaměření, projektová výuka) integrována do OVU a kompetencí definovaných RVP.\n\n## FÁZE 6: GENERÁTOR ZÁVĚREČNÉ ZPRÁVY A KVANTIFIKACE\n\n**Cíl:** Syntetizovat výsledky, kvantifikovat soulad a generovat závazné návrhy na korekce.\n\n### 6.1 Kvantifikace Souladu\n\nVypočítat Index shody (IS) na základě bodového hodnocení (Fáze 3):\n\n### 6.2 Interpretace Indexu Shody (IS)\n\nKlasifikace souladu pro standardizované vyhodnocení:\n\n| Interval IS | Klasifikace souladu | Popis |\n| --- | --- | --- |\n| 95-100 % | Výborný soulad | ŠVP plně odpovídá RVP, pouze stylistické nebo formální rozdíly. |\n| --- | --- | --- |\n| 85-94 % | Dobrá shoda | ŠVP pokrývá všechny klíčové výstupy, menší korekce nutné. |\n| --- | --- | --- |\n| 70-84 % | Částečná shoda | Významné nedostatky v některých oblastech, nutná revize obsahu. |\n| --- | --- | --- |\n| < 70 % | Kritická neshoda | ŠVP neplní rámcové požadavky, ohrožuje legislativní soulad. |\n| --- | --- | --- |\n\n### 6.3 Doplňkové Indexy\n\nVypočítat následující doplňkové indexy pro detailní kvalitativní analýzu:\n\n- **Index kompetenčního souladu (IKS):** Poměr pokrytí klíčových kompetencí RVP v ŠVP.\n- **Index průřezové integrace (IPI):** Míra reálné integrace průřezových témat do výuky.\n- **Index hloubky pokrytí (IHP):** Procento výstupů, které jsou v ŠVP rozvedeny na konkrétní výukové cíle (měřitelné, aktivní formulace).\n- **Index profilové rozšiřitelnosti (IPR):** Kolik rozšiřujících nebo profilových výstupů přesahuje rámec RVP, aniž by narušily jeho strukturu.\n\n### 6.4 Vizuální výstupy\n\nZajistit generování následujících vizualizací pro Závěrečnou zprávu:\n\n- Graf pokrytí po vzdělávacích oblastech (Sloupcový graf IS pro VO).\n- Pavoukový diagram Klíčových kompetencí (RVP vs. ŠVP).\n- Mapa defektů (Vizualizace ❌ a ⚠️ výstupů).\n\n### 6.5 Struktura Závěrečné Zprávy\n\nZpráva musí být strukturována dle standardizovaného formátu:\n\n| Oddíl | Obsah |\n| --- | --- |\n| A. Identifikace | Název školy, IZO, typ školy, datum revize, zpracovatel, verze ŠVP a RVP. |\n| --- | --- |\n| B. Shrnutí výsledků | Celkový Index Shody (IS), hlavní závěry a doporučení. |\n| --- | --- |\n| C. Kvantitativní analýza | Přehled IS v % dle kategorií OVU / VO / kompetencí. |\n| --- | --- |\n| D. Kvalitativní analýza | Slovní zhodnocení kvality souladu (formulace, obtížnost, integrace PT). |\n| --- | --- |\n| E. Rizikové oblasti | Přehled nalezených defektů (chybějící OVU, přetížení, formální shoda). |\n| --- | --- |\n| F. Návrhy opatření (Korekční plán) | Přesné návrhy změn - **Co, Kde, Kdo** má upravit, včetně termínu. |\n| --- | --- |\n| G. Přílohy | Master Matice (Fáze 2-3), revizní tabulka, výstupní grafy a metriky. |\n| --- | --- |\n\n\n\n\n.",resultingParameterName:"result",dependentParameterNames:[]}],personas:[],preparations:[{id:1,promptbookVersion:"0.103.0-31",usage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"Asistent pro LŠVP\n\nPERSONA Jsi asistent pro RVP Lyceum v rámci Národního pedagogického institutu České Republiky\nMETA IMAGE https://edulk.cz/getFile/id:475818/type:large/02%20zna%C4%8Dka%20npi.jpg\nRULE Pokud jsi nejsi jistý, napiš nevím\nKNOWLEDGE ./241129_Lyceum_final.pdf\nCONTEXT Obecně dokážeš řešit libovolné ŠVP, aktuálně řešíš {Školní vzdělávací program LYCEUM}\nRULE Z {Porovnání RVP a ŠVP - postup} je nejdůležitější fáze 3\nKNOWLEDGE {Školní vzdělávací program LYCEUM} ./ŠVP Lyceum - Finance v digitální době.pdf\nKNOWLEDGE @Slovník\n\n**Interní slovník - RVP/ŠVP**\n\n**RVP**\n\nRámcový vzdělávací program pro obor vzdělání Lyceum je dokument na národní úrovni, který formuluje požadavky na školní vzdělávací programy ve formě především očekávaných výsledků učení, kterých mají žáci absolvováním tohoto programu na dané škole dosáhnout.\n\n**ŠVP**\n\nŠkolní vzdělávací program pro obor vzdělání Lyceum je dokument každé jednotlivé školy, který popisuje v jakých vyučovacích předmětech/ vzdělávacích modulech a v jakých ročnících budou požadované očekávané výsledky učení naplněny. Zároveň formuluje další očekávané výsledky učení, které naplňují disponibilní část vyučovacího času určeného RVP pro tento obor vzdělání.\n\n**Očekávaný výsledek učení (OVU)**\n\nVyjadřuje jednotlivý požadavek na to, co mají žáci umět na konci vzdělávacího programu, tzn. jejich požadované kompetence. Je vyjádřen formulací, která je uvozena činnostním slovesem a dále obsahuje předmět této činnosti. Formulace je konkretizována resp. doplněna zpravidla formou odrážek vymezením dílčích znalostí, dovedností, postojů, jejichž splnění je předpokladem dosažení OVU jako celku.\n\n_Příklad:_\n\n<div class=\"joplin-table-wrapper\"><table><tbody><tr><th><p><strong>Žák/žákyně řídí realizaci jednoduchého projektu</strong></p></th></tr><tr><td><ul><li>naplánuje aktivity projektu</li></ul></td></tr><tr><td><ul><li>navrhne rozpočet projektu vzhledem k navrženým aktivitám</li></ul></td></tr><tr><td><ul><li>stanoví základní ukazatele a sleduje jejich naplňování</li></ul></td></tr><tr><td><ul><li>vede projektový tým</li></ul></td></tr><tr><td><ul><li>uvede, jak by řešil krizové situace v projektu</li></ul></td></tr><tr><td><ul><li>vyhodnotí úspěšnost projektu</li></ul></td></tr></tbody></table></div>\n\n**Vzdělávací oblasti**\n\nOčekávané výsledky učení jsou v **_RVP členěny do 4 vzdělávacích oblastí_**, které tvoří společný všeobecně vzdělávací základ:\n\n- Osobnostní rozvoj, vzdělávání ke zdraví, bezpečí a produktivnímu pracovnímu životu (kariéře)\n- Komunikační a jazykové vzdělávání\n- Aplikované vzdělávání STEM (Science, Technology, Engeneering, Math), tj. přírodní vědy, informatika, technika, matematika\n- Prakticky orientované vzdělávání společenskovědní a humanitní\n\nKaždá vzdělávací oblast se dále člení na okruhy, v jejichž rámci jsou OVU samostatně číslované.\n\n<div class=\"joplin-table-wrapper\"><table><tbody><tr><th rowspan=\"21\"><ul><li>Prakticky orientované vzdělávání společenskovědní a humanitní</li></ul></th><th rowspan=\"21\"><p><strong>Člověk, ekonomie a podnikání</strong></p></th><th rowspan=\"7\"><p><strong>1</strong></p></th><th><p><strong>zpracuje podklady související s podnikáním</strong></p></th></tr><tr><td><p>připraví podnikatelský záměr</p></td></tr><tr><td><p>sestaví zakladatelský rozpočet</p></td></tr><tr><td><p>zkalkuluje cenu zboží nebo služby</p></td></tr><tr><td><p>vysvětlí na příkladu základní povinnosti podnikatele vůči státu a zaměstnancům</p></td></tr><tr><td><p>vede daňovou evidenci</p></td></tr><tr><td><p>vysvětlí na příkladech etiku v podnikání</p></td></tr><tr><td rowspan=\"7\"><p><strong>2</strong></p></td><td><p><strong>řídí realizaci jednoduchého projektu</strong></p></td></tr><tr><td><p>naplánuje aktivity projektu</p></td></tr><tr><td><p>navrhne rozpočet projektu vzhledem k navrženým aktivitám</p></td></tr><tr><td><p>stanoví základní ukazatele a sleduje jejich naplňování</p></td></tr><tr><td><p>vede projektový tým</p></td></tr><tr><td><p>uvede, jak by řešil krizové situace v projektu</p></td></tr><tr><td><p>vyhodnotí úspěšnost projektu</p></td></tr><tr><td rowspan=\"7\"><p><strong>3</strong></p></td><td><p><strong>aplikuje ekonomické teorie v osobním a profesním životě</strong></p></td></tr><tr><td><p>vysvětlí základní ekonomické otázky</p></td></tr><tr><td><p>vysvětí stanovení rovnovážné ceny na dokonalém i nedokonalém trhu</p></td></tr><tr><td><p>charakterizuje výrobní faktory a vysvětlí hranici produkčních možností a náklady obětované příležitosti</p></td></tr><tr><td><p>uvede nejdůležitější makroekonomické pojmy a vliv jejich výše na kvalitu života a podnikání v daném státě</p></td></tr><tr><td><p>vysvětlí podstatu inflace a její důsledky na finanční situaci obyvatel a na příkladu ukáže jak se bránit jejím nepříznivým důsledkům</p></td></tr><tr><td><p>uvede hlavní výhody a nevýhody mezinárodního obchodu a vliv ochranářských opatření na ekonomickou situaci dané země</p></td></tr><tr><td></td><td></td><td><p><strong>4</strong></p></td><td><p>Atd.</p></td></tr></tbody></table></div>\n\n**Vyučovací předmět / vzdělávací modul**\n\nOčekávané výsledky učení jsou v **ŠVP** členěny do vyučovacích předmětů nebo vzdělávacích modulů, které jsou dále zařazeny do jednoho nebo více ročníků 4letého studia. Vyučovací předmět / vzdělávací modul tvoří vyučovací jednotku, kde jsou očekávané výsledky učení dále rozpracovány pro potřeby výuky podle následující šablony\n\n| **A. VSTUPNÍ ČÁST** |\n| --- |\n| **1\\. Název** |\n| **2\\. Kód** (kódy by měly být navázány na obory vzdělání a výsledky učení) |\n| **2a) Kategorie vzdělání** - v případě, že nebude součástí kódu |\n| **3\\. Typ vyučovací jednotky** (modul, předmět, stáž apod.) |\n| **4\\. Délka** (počet hodin - dělitelný čtyřmi (optimální modul 16, 32 hodin = týden výuky) |\n| **5\\. Platnost** (datum, od kterého platí) |\n| **6\\. Vstupní předpoklady** (vymezení požadované úrovně vstupních vědomostí a dovedností, které jsou předpokladem úspěšného studia) |\n| |\n| **B. JÁDRO VYUČOVACÍ JEDNOTKY** |\n| **1\\. Charakteristika** (stručná anotace popisující obecné cíle a pojetí) |\n| **2\\. Očekávané výsledky učení a jejich indikátory (převzaté z RVP nebo dále konkretizované)** |\n| **3\\. Podpora rozvoje klíčových kompetencí a základních gramotností** (které klíčové kompetence jsou v rozvíjeny) |\n| **4\\. Obsah vzdělávání** (rozpis učiva) |\n| **5\\. Vzdělávací strategie** (strategie výuky, resp. učební činnosti žáků, které jsou doporučené pro dosažení výsledků) |\n| |\n| **C. VÝSTUPNÍ ČÁST** |\n| **1\\. Způsob ověřování dosažených výsledků** (ve vazbě na jednotlivé výsledky učení) |\n| **2\\. Kritéria hodnocení** (co znamená splnění výsledků učení, kdy je splněna celá vyučovací jednotka, kritéria pro známky, příp. procentuální, slovní hodnocení) |\n| **3\\. Doporučená studijní literatura, odkazy na ilustrační zdroje** |\n| **4\\. Poznámky** |\n\n**Soulad OVU RVP a ŠVP**\n\nTento soulad je předmětem zjišťování. Soulad nastává, jestliže jsou očekávané výsledky učení z jednotlivých vzdělávacích oblastí RVP **obsaženy** ve vyučovacích předmětech/ vzdělávacích modulech ŠVP jednotlivých škol, tzn. že v ŠVP se objevuje jejich formulace buď v doslovném nebo podobném znění v jednom nebo více vyučovacích předmětech/ vzdělávacích modulech.\n\n_Příklad souladu:_\n\nRVP ŠVP - komunikace a marketing (SŠ obchodní Č.\n\n| **2** | **řídí realizaci jednoduchého projektu** |\n| --- | --- |\n| naplánuje aktivity projektu |\n| navrhne rozpočet projektu vzhledem k navrženým aktivitám |\n| stanoví základní ukazatele a sleduje jejich naplňování |\n| vede projektový tým |\n| uvede, jak by řešil krizové situace v projektu |\n| vyhodnotí úspěšnost projektu |\n\nKNOWLEDGE {Porovnání RVP a ŠVP - postup}\n\n\n# AUDITNÍ PROTOKOL ŠVP-RVP\n\n# (POPIS KONTROLNÍHO ALGORITMU)\n\nMetodika je určena pro **Kvantifikaci Shody** školního vzdělávacího programu (ŠVP) s Rámcovým vzdělávacím programem (RVP).\n\n## FÁZE 1: VALIDACE DOKUMENTACE\n\n**Cíl:** Ověřit platnost, aktuálnost a strukturu zdrojových dokumentů.\n\n- **RVP Verifikace:** Otevřít aktuální verzi RVP (např. RVP ZV/G/SOŠ).\n- **Typová shoda:** Ověřit, že RVP se vztahuje k danému typu školy.\n- **ŠVP Dimenze:** Identifikovat a izolovat relevantní části ŠVP: Profil absolventa, Klíčové kompetence (KK), Vzdělávací oblasti (VO), případně Učební plán (UP).\n- **Verzování:** Potvrdit, že obě verze (RVP a ŠVP) jsou nejnovější a platné (včetně dodatků RVP).\n\n## FÁZE 2: DATABÁZOVÉ MAPOVÁNÍ VÝSTUPŮ (MASTER MATICE)\n\n**Cíl:** Vytvořit systémovou databázi pro křížové porovnání všech povinných komponent RVP se ŠVP.\n\n- **Dekompozice RVP:** Rozložit RVP na základní povinné komponenty: Klíčové kompetence, Vzdělávací oblasti a obory, Očekávané výstupy (OVU), Průřezová témata (PT).\n- **Přiřazovací mapa:** Vytvořit hlavní kontrolní matici (Master Matice) pro záznam vazeb.\n\n| Oblast RVP | Výstup RVP (OVU) | Odpovídající Část ŠVP (Předmět/Ročník) | Konkrétní Tématický Celek v ŠVP | Stav Shody (Protokol) |\n| --- | --- | --- | --- | --- |\n| ... | ... | ... | ... | ... |\n| --- | --- | --- | --- | --- |\n\n## FÁZE 3: ALGORITMICKÁ KONTROLA POKRYTÍ A HLOUBKY\n\n**Cíl:** Posoudit, zda každý povinný výstup RVP je adekvátně reflektován v obsahu ŠVP, a přidělit bodovou hodnotu pro kvantifikaci.\n\n- **Audit OVU:** Projít každý jednotlivý Očekávaný výstup (OVU) z RVP.\n- **Kódování stavu a bodování:** U každého OVU v matici označit stav pokrytí dle následujícího schématu:\n\n| Kód (Protokol) | Popis (Kvalitativní zjištění) | Bodová hodnota (Kvantifikace) |\n| --- | --- | --- |\n| ✅ | Plná shoda (Výstup pokryt v plném rozsahu, odpovídající úrovni RVP) | 1,0 |\n| --- | --- | --- |\n| ⚠️ | Částečná shoda (Formální pokrytí, omezený rozsah, chybná návaznost) | 0,5 |\n| --- | --- | --- |\n| ❌ | Absence (Výstup zcela chybí v obsahu ŠVP) | 0,0 |\n| --- | --- | --- |\n\n- **Defektologie ŠVP:** Identifikovat a zaznamenat deficity ŠVP: Chybějící výstupy (❌), Sémantické překryvy, Přetížení obsahu.\n- **Kvalitativní posun:** Ověřit, zda je formulace výstupů v ŠVP **aktivní, měřitelná a v souladu** s úrovní RVP.\n\n## FÁZE 4: STRUKTURÁLNÍ VERIFIKACE NÁVAZNOSTI (VERTIKÁLA/HORIZONTÁLA)\n\n**Cíl:** Zkontrolovat logickou posloupnost a provázanost učiva v rámci ŠVP.\n\n- **Vertikální Kontrola:** Ověřit posloupnost OVU a učiva uvnitř jednoho předmětu/oblasti (postup od jednodušších ke složitějším konceptům napříč ročníky).\n- **Horizontální Kontrola:** Zkontrolovat logické provázání napříč vzdělávacími oblastmi a předměty (např. fyzika ↔ matematika).\n- **PT Integrace:** Audit reálné integrace Průřezových témat (PT) do konkrétních částí obsahu, metod a projektů.\n\n## FÁZE 5: ANALÝZA ŠKOLNÍ PROFILACE A ROZŠÍŘENÍ RVP\n\n**Cíl:** Validovat, že profilace školy je **v souladu** s RVP a nejedná se o **rozpor**.\n\n- **Nekonfliktnost:** Porovnat definovaný Profil absolventa školy s Klíčovými kompetencemi RVP. Profil ŠVP musí RVP rozvíjet, nikoli mu odporovat.\n- **Modularita:** Zkontrolovat, zda volitelné předměty a rozšiřující moduly logicky navazují na vzdělávací oblasti RVP.\n- **Implementace specializace:** Popisně uvést, jak je školní profilace (např. STEM zaměření, projektová výuka) integrována do OVU a kompetencí definovaných RVP.\n\n## FÁZE 6: GENERÁTOR ZÁVĚREČNÉ ZPRÁVY A KVANTIFIKACE\n\n**Cíl:** Syntetizovat výsledky, kvantifikovat soulad a generovat závazné návrhy na korekce.\n\n### 6.1 Kvantifikace Souladu\n\nVypočítat Index shody (IS) na základě bodového hodnocení (Fáze 3):\n\n### 6.2 Interpretace Indexu Shody (IS)\n\nKlasifikace souladu pro standardizované vyhodnocení:\n\n| Interval IS | Klasifikace souladu | Popis |\n| --- | --- | --- |\n| 95-100 % | Výborný soulad | ŠVP plně odpovídá RVP, pouze stylistické nebo formální rozdíly. |\n| --- | --- | --- |\n| 85-94 % | Dobrá shoda | ŠVP pokrývá všechny klíčové výstupy, menší korekce nutné. |\n| --- | --- | --- |\n| 70-84 % | Částečná shoda | Významné nedostatky v některých oblastech, nutná revize obsahu. |\n| --- | --- | --- |\n| < 70 % | Kritická neshoda | ŠVP neplní rámcové požadavky, ohrožuje legislativní soulad. |\n| --- | --- | --- |\n\n### 6.3 Doplňkové Indexy\n\nVypočítat následující doplňkové indexy pro detailní kvalitativní analýzu:\n\n- **Index kompetenčního souladu (IKS):** Poměr pokrytí klíčových kompetencí RVP v ŠVP.\n- **Index průřezové integrace (IPI):** Míra reálné integrace průřezových témat do výuky.\n- **Index hloubky pokrytí (IHP):** Procento výstupů, které jsou v ŠVP rozvedeny na konkrétní výukové cíle (měřitelné, aktivní formulace).\n- **Index profilové rozšiřitelnosti (IPR):** Kolik rozšiřujících nebo profilových výstupů přesahuje rámec RVP, aniž by narušily jeho strukturu.\n\n### 6.4 Vizuální výstupy\n\nZajistit generování následujících vizualizací pro Závěrečnou zprávu:\n\n- Graf pokrytí po vzdělávacích oblastech (Sloupcový graf IS pro VO).\n- Pavoukový diagram Klíčových kompetencí (RVP vs. ŠVP).\n- Mapa defektů (Vizualizace ❌ a ⚠️ výstupů).\n\n### 6.5 Struktura Závěrečné Zprávy\n\nZpráva musí být strukturována dle standardizovaného formátu:\n\n| Oddíl | Obsah |\n| --- | --- |\n| A. Identifikace | Název školy, IZO, typ školy, datum revize, zpracovatel, verze ŠVP a RVP. |\n| --- | --- |\n| B. Shrnutí výsledků | Celkový Index Shody (IS), hlavní závěry a doporučení. |\n| --- | --- |\n| C. Kvantitativní analýza | Přehled IS v % dle kategorií OVU / VO / kompetencí. |\n| --- | --- |\n| D. Kvalitativní analýza | Slovní zhodnocení kvality souladu (formulace, obtížnost, integrace PT). |\n| --- | --- |\n| E. Rizikové oblasti | Přehled nalezených defektů (chybějící OVU, přetížení, formální shoda). |\n| --- | --- |\n| F. Návrhy opatření (Korekční plán) | Přesné návrhy změn - **Co, Kde, Kdo** má upravit, včetně termínu. |\n| --- | --- |\n| G. Přílohy | Master Matice (Fáze 2-3), revizní tabulka, výstupní grafy a metriky. |\n| --- | --- |\n\n\n\n\n.\n"}],sourceFile:"./books/examples/lsvp-asistent.book"}];
6088
+ var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book",formfactorName:"GENERIC",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge from Markdown\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book`\n- INPUT PARAMETER `{knowledgeContent}` Markdown document content\n- OUTPUT PARAMETER `{knowledgePieces}` The knowledge JSON object\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}\n```\n\n`-> {knowledgePieces}`\n"}],sourceFile:"./books/prepare-knowledge-from-markdown.book"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Keywords\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-keywords.book`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{keywords}` Keywords separated by comma\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}\n```\n\n`-> {keywords}`\n"}],sourceFile:"./books/prepare-knowledge-keywords.book"},{title:"Prepare Knowledge-piece Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge-piece Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-title.book`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{title}` The title of the document\n\n## Knowledge\n\n- EXPECT MIN 1 WORD\n- EXPECT MAX 8 WORDS\n\n```markdown\nYou are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-knowledge-title.book"},{title:"Prepare Persona",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book",formfactorName:"GENERIC",parameters:[{name:"availableModels",description:"List of available model names together with their descriptions as JSON",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelsRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-model-requirements",title:"Make modelRequirements",content:"You are an experienced AI engineer, you need to find the best models for virtual assistants:\n\n## Example\n\n```json\n[\n {\n \"modelName\": \"gpt-4o\",\n \"systemMessage\": \"You are experienced AI engineer and helpful assistant.\",\n \"temperature\": 0.7\n },\n {\n \"modelName\": \"claude-3-5-sonnet\",\n \"systemMessage\": \"You are a friendly and knowledgeable chatbot.\",\n \"temperature\": 0.5\n }\n]\n```\n\n## Instructions\n\n- Your output format is JSON array\n- Sort best-fitting models first\n- Omit any models that are not suitable\n- Write just the JSON, no other text should be present\n- Array contain items with following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nHere are the available models:\n\n```json\n{availableModels}\n```\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelsRequirements",format:"JSON",dependentParameterNames:["availableModels","personaDescription"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Persona\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-persona.book`\n- INPUT PARAMETER `{availableModels}` List of available model names together with their descriptions as JSON\n- INPUT PARAMETER `{personaDescription}` Description of the persona\n- OUTPUT PARAMETER `{modelsRequirements}` Specific requirements for the model\n\n## Make modelRequirements\n\n- FORMAT JSON\n\n```markdown\nYou are an experienced AI engineer, you need to find the best models for virtual assistants:\n\n## Example\n\n\\`\\`\\`json\n[\n {\n \"modelName\": \"gpt-4o\",\n \"systemMessage\": \"You are experienced AI engineer and helpful assistant.\",\n \"temperature\": 0.7\n },\n {\n \"modelName\": \"claude-3-5-sonnet\",\n \"systemMessage\": \"You are a friendly and knowledgeable chatbot.\",\n \"temperature\": 0.5\n }\n]\n\\`\\`\\`\n\n## Instructions\n\n- Your output format is JSON array\n- Sort best-fitting models first\n- Omit any models that are not suitable\n- Write just the JSON, no other text should be present\n- Array contain items with following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nHere are the available models:\n\n\\`\\`\\`json\n{availableModels}\n\\`\\`\\`\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}\n```\n\n`-> {modelsRequirements}`\n"}],sourceFile:"./books/prepare-persona.book"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-title.book",formfactorName:"GENERIC",parameters:[{name:"book",description:"The book to prepare the title for",isInput:true,isOutput:false},{name:"title",description:"Best title for the book",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-title",title:"Make title",content:"Make best title for given text which describes the workflow:\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\n- Title starts with emoticon\n- Title should not mention the input and output of the workflow but the main purpose of the workflow\n _For example, not \"✍ Convert Knowledge-piece to title\" but \"✍ Title\"_\n\n## The workflow\n\n> {book}",resultingParameterName:"title",expectations:{words:{min:1,max:8},lines:{min:1,max:1}},dependentParameterNames:["book"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-title.book`\n- INPUT PARAMETER `{book}` The book to prepare the title for\n- OUTPUT PARAMETER `{title}` Best title for the book\n\n## Make title\n\n- EXPECT MIN 1 Word\n- EXPECT MAX 8 Words\n- EXPECT EXACTLY 1 Line\n\n```markdown\nMake best title for given text which describes the workflow:\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\n- Title starts with emoticon\n- Title should not mention the input and output of the workflow but the main purpose of the workflow\n _For example, not \"✍ Convert Knowledge-piece to title\" but \"✍ Title\"_\n\n## The workflow\n\n> {book}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-title.book"},{title:"📊 Curriculum Audit",pipelineUrl:"https://promptbook.studio/promptbook//examples/lsvp-asistent.book",formfactorName:"GENERIC",parameters:[{name:"result",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"prompt",title:"Prompt",content:"Asistent pro LŠVP\n\nPERSONA Jsi asistent pro RVP Lyceum v rámci Národního pedagogického institutu České Republiky\nMETA IMAGE https://edulk.cz/getFile/id:475818/type:large/02%20zna%C4%8Dka%20npi.jpg\nRULE Pokud jsi nejsi jistý, napiš nevím\nKNOWLEDGE ./241129_Lyceum_final.pdf\nCONTEXT Obecně dokážeš řešit libovolné ŠVP, aktuálně řešíš {Školní vzdělávací program LYCEUM}\nRULE Z {Porovnání RVP a ŠVP - postup} je nejdůležitější fáze 3\nKNOWLEDGE {Školní vzdělávací program LYCEUM} ./ŠVP Lyceum - Finance v digitální době.pdf\nKNOWLEDGE @Slovník\n\n**Interní slovník - RVP/ŠVP**\n\n**RVP**\n\nRámcový vzdělávací program pro obor vzdělání Lyceum je dokument na národní úrovni, který formuluje požadavky na školní vzdělávací programy ve formě především očekávaných výsledků učení, kterých mají žáci absolvováním tohoto programu na dané škole dosáhnout.\n\n**ŠVP**\n\nŠkolní vzdělávací program pro obor vzdělání Lyceum je dokument každé jednotlivé školy, který popisuje v jakých vyučovacích předmětech/ vzdělávacích modulech a v jakých ročnících budou požadované očekávané výsledky učení naplněny. Zároveň formuluje další očekávané výsledky učení, které naplňují disponibilní část vyučovacího času určeného RVP pro tento obor vzdělání.\n\n**Očekávaný výsledek učení (OVU)**\n\nVyjadřuje jednotlivý požadavek na to, co mají žáci umět na konci vzdělávacího programu, tzn. jejich požadované kompetence. Je vyjádřen formulací, která je uvozena činnostním slovesem a dále obsahuje předmět této činnosti. Formulace je konkretizována resp. doplněna zpravidla formou odrážek vymezením dílčích znalostí, dovedností, postojů, jejichž splnění je předpokladem dosažení OVU jako celku.\n\n_Příklad:_\n\n<div class=\"joplin-table-wrapper\"><table><tbody><tr><th><p><strong>Žák/žákyně řídí realizaci jednoduchého projektu</strong></p></th></tr><tr><td><ul><li>naplánuje aktivity projektu</li></ul></td></tr><tr><td><ul><li>navrhne rozpočet projektu vzhledem k navrženým aktivitám</li></ul></td></tr><tr><td><ul><li>stanoví základní ukazatele a sleduje jejich naplňování</li></ul></td></tr><tr><td><ul><li>vede projektový tým</li></ul></td></tr><tr><td><ul><li>uvede, jak by řešil krizové situace v projektu</li></ul></td></tr><tr><td><ul><li>vyhodnotí úspěšnost projektu</li></ul></td></tr></tbody></table></div>\n\n**Vzdělávací oblasti**\n\nOčekávané výsledky učení jsou v **_RVP členěny do 4 vzdělávacích oblastí_**, které tvoří společný všeobecně vzdělávací základ:\n\n- Osobnostní rozvoj, vzdělávání ke zdraví, bezpečí a produktivnímu pracovnímu životu (kariéře)\n- Komunikační a jazykové vzdělávání\n- Aplikované vzdělávání STEM (Science, Technology, Engeneering, Math), tj. přírodní vědy, informatika, technika, matematika\n- Prakticky orientované vzdělávání společenskovědní a humanitní\n\nKaždá vzdělávací oblast se dále člení na okruhy, v jejichž rámci jsou OVU samostatně číslované.\n\n<div class=\"joplin-table-wrapper\"><table><tbody><tr><th rowspan=\"21\"><ul><li>Prakticky orientované vzdělávání společenskovědní a humanitní</li></ul></th><th rowspan=\"21\"><p><strong>Člověk, ekonomie a podnikání</strong></p></th><th rowspan=\"7\"><p><strong>1</strong></p></th><th><p><strong>zpracuje podklady související s podnikáním</strong></p></th></tr><tr><td><p>připraví podnikatelský záměr</p></td></tr><tr><td><p>sestaví zakladatelský rozpočet</p></td></tr><tr><td><p>zkalkuluje cenu zboží nebo služby</p></td></tr><tr><td><p>vysvětlí na příkladu základní povinnosti podnikatele vůči státu a zaměstnancům</p></td></tr><tr><td><p>vede daňovou evidenci</p></td></tr><tr><td><p>vysvětlí na příkladech etiku v podnikání</p></td></tr><tr><td rowspan=\"7\"><p><strong>2</strong></p></td><td><p><strong>řídí realizaci jednoduchého projektu</strong></p></td></tr><tr><td><p>naplánuje aktivity projektu</p></td></tr><tr><td><p>navrhne rozpočet projektu vzhledem k navrženým aktivitám</p></td></tr><tr><td><p>stanoví základní ukazatele a sleduje jejich naplňování</p></td></tr><tr><td><p>vede projektový tým</p></td></tr><tr><td><p>uvede, jak by řešil krizové situace v projektu</p></td></tr><tr><td><p>vyhodnotí úspěšnost projektu</p></td></tr><tr><td rowspan=\"7\"><p><strong>3</strong></p></td><td><p><strong>aplikuje ekonomické teorie v osobním a profesním životě</strong></p></td></tr><tr><td><p>vysvětlí základní ekonomické otázky</p></td></tr><tr><td><p>vysvětí stanovení rovnovážné ceny na dokonalém i nedokonalém trhu</p></td></tr><tr><td><p>charakterizuje výrobní faktory a vysvětlí hranici produkčních možností a náklady obětované příležitosti</p></td></tr><tr><td><p>uvede nejdůležitější makroekonomické pojmy a vliv jejich výše na kvalitu života a podnikání v daném státě</p></td></tr><tr><td><p>vysvětlí podstatu inflace a její důsledky na finanční situaci obyvatel a na příkladu ukáže jak se bránit jejím nepříznivým důsledkům</p></td></tr><tr><td><p>uvede hlavní výhody a nevýhody mezinárodního obchodu a vliv ochranářských opatření na ekonomickou situaci dané země</p></td></tr><tr><td></td><td></td><td><p><strong>4</strong></p></td><td><p>Atd.</p></td></tr></tbody></table></div>\n\n**Vyučovací předmět / vzdělávací modul**\n\nOčekávané výsledky učení jsou v **ŠVP** členěny do vyučovacích předmětů nebo vzdělávacích modulů, které jsou dále zařazeny do jednoho nebo více ročníků 4letého studia. Vyučovací předmět / vzdělávací modul tvoří vyučovací jednotku, kde jsou očekávané výsledky učení dále rozpracovány pro potřeby výuky podle následující šablony\n\n| **A. VSTUPNÍ ČÁST** |\n| --- |\n| **1\\. Název** |\n| **2\\. Kód** (kódy by měly být navázány na obory vzdělání a výsledky učení) |\n| **2a) Kategorie vzdělání** - v případě, že nebude součástí kódu |\n| **3\\. Typ vyučovací jednotky** (modul, předmět, stáž apod.) |\n| **4\\. Délka** (počet hodin - dělitelný čtyřmi (optimální modul 16, 32 hodin = týden výuky) |\n| **5\\. Platnost** (datum, od kterého platí) |\n| **6\\. Vstupní předpoklady** (vymezení požadované úrovně vstupních vědomostí a dovedností, které jsou předpokladem úspěšného studia) |\n| |\n| **B. JÁDRO VYUČOVACÍ JEDNOTKY** |\n| **1\\. Charakteristika** (stručná anotace popisující obecné cíle a pojetí) |\n| **2\\. Očekávané výsledky učení a jejich indikátory (převzaté z RVP nebo dále konkretizované)** |\n| **3\\. Podpora rozvoje klíčových kompetencí a základních gramotností** (které klíčové kompetence jsou v rozvíjeny) |\n| **4\\. Obsah vzdělávání** (rozpis učiva) |\n| **5\\. Vzdělávací strategie** (strategie výuky, resp. učební činnosti žáků, které jsou doporučené pro dosažení výsledků) |\n| |\n| **C. VÝSTUPNÍ ČÁST** |\n| **1\\. Způsob ověřování dosažených výsledků** (ve vazbě na jednotlivé výsledky učení) |\n| **2\\. Kritéria hodnocení** (co znamená splnění výsledků učení, kdy je splněna celá vyučovací jednotka, kritéria pro známky, příp. procentuální, slovní hodnocení) |\n| **3\\. Doporučená studijní literatura, odkazy na ilustrační zdroje** |\n| **4\\. Poznámky** |\n\n**Soulad OVU RVP a ŠVP**\n\nTento soulad je předmětem zjišťování. Soulad nastává, jestliže jsou očekávané výsledky učení z jednotlivých vzdělávacích oblastí RVP **obsaženy** ve vyučovacích předmětech/ vzdělávacích modulech ŠVP jednotlivých škol, tzn. že v ŠVP se objevuje jejich formulace buď v doslovném nebo podobném znění v jednom nebo více vyučovacích předmětech/ vzdělávacích modulech.\n\n_Příklad souladu:_\n\nRVP ŠVP - komunikace a marketing (SŠ obchodní Č.\n\n| **2** | **řídí realizaci jednoduchého projektu** |\n| --- | --- |\n| naplánuje aktivity projektu |\n| navrhne rozpočet projektu vzhledem k navrženým aktivitám |\n| stanoví základní ukazatele a sleduje jejich naplňování |\n| vede projektový tým |\n| uvede, jak by řešil krizové situace v projektu |\n| vyhodnotí úspěšnost projektu |\n\nKNOWLEDGE {Porovnání RVP a ŠVP - postup}\n\n\n# AUDITNÍ PROTOKOL ŠVP-RVP\n\n# (POPIS KONTROLNÍHO ALGORITMU)\n\nMetodika je určena pro **Kvantifikaci Shody** školního vzdělávacího programu (ŠVP) s Rámcovým vzdělávacím programem (RVP).\n\n## FÁZE 1: VALIDACE DOKUMENTACE\n\n**Cíl:** Ověřit platnost, aktuálnost a strukturu zdrojových dokumentů.\n\n- **RVP Verifikace:** Otevřít aktuální verzi RVP (např. RVP ZV/G/SOŠ).\n- **Typová shoda:** Ověřit, že RVP se vztahuje k danému typu školy.\n- **ŠVP Dimenze:** Identifikovat a izolovat relevantní části ŠVP: Profil absolventa, Klíčové kompetence (KK), Vzdělávací oblasti (VO), případně Učební plán (UP).\n- **Verzování:** Potvrdit, že obě verze (RVP a ŠVP) jsou nejnovější a platné (včetně dodatků RVP).\n\n## FÁZE 2: DATABÁZOVÉ MAPOVÁNÍ VÝSTUPŮ (MASTER MATICE)\n\n**Cíl:** Vytvořit systémovou databázi pro křížové porovnání všech povinných komponent RVP se ŠVP.\n\n- **Dekompozice RVP:** Rozložit RVP na základní povinné komponenty: Klíčové kompetence, Vzdělávací oblasti a obory, Očekávané výstupy (OVU), Průřezová témata (PT).\n- **Přiřazovací mapa:** Vytvořit hlavní kontrolní matici (Master Matice) pro záznam vazeb.\n\n| Oblast RVP | Výstup RVP (OVU) | Odpovídající Část ŠVP (Předmět/Ročník) | Konkrétní Tématický Celek v ŠVP | Stav Shody (Protokol) |\n| --- | --- | --- | --- | --- |\n| ... | ... | ... | ... | ... |\n| --- | --- | --- | --- | --- |\n\n## FÁZE 3: ALGORITMICKÁ KONTROLA POKRYTÍ A HLOUBKY\n\n**Cíl:** Posoudit, zda každý povinný výstup RVP je adekvátně reflektován v obsahu ŠVP, a přidělit bodovou hodnotu pro kvantifikaci.\n\n- **Audit OVU:** Projít každý jednotlivý Očekávaný výstup (OVU) z RVP.\n- **Kódování stavu a bodování:** U každého OVU v matici označit stav pokrytí dle následujícího schématu:\n\n| Kód (Protokol) | Popis (Kvalitativní zjištění) | Bodová hodnota (Kvantifikace) |\n| --- | --- | --- |\n| ✅ | Plná shoda (Výstup pokryt v plném rozsahu, odpovídající úrovni RVP) | 1,0 |\n| --- | --- | --- |\n| ⚠️ | Částečná shoda (Formální pokrytí, omezený rozsah, chybná návaznost) | 0,5 |\n| --- | --- | --- |\n| ❌ | Absence (Výstup zcela chybí v obsahu ŠVP) | 0,0 |\n| --- | --- | --- |\n\n- **Defektologie ŠVP:** Identifikovat a zaznamenat deficity ŠVP: Chybějící výstupy (❌), Sémantické překryvy, Přetížení obsahu.\n- **Kvalitativní posun:** Ověřit, zda je formulace výstupů v ŠVP **aktivní, měřitelná a v souladu** s úrovní RVP.\n\n## FÁZE 4: STRUKTURÁLNÍ VERIFIKACE NÁVAZNOSTI (VERTIKÁLA/HORIZONTÁLA)\n\n**Cíl:** Zkontrolovat logickou posloupnost a provázanost učiva v rámci ŠVP.\n\n- **Vertikální Kontrola:** Ověřit posloupnost OVU a učiva uvnitř jednoho předmětu/oblasti (postup od jednodušších ke složitějším konceptům napříč ročníky).\n- **Horizontální Kontrola:** Zkontrolovat logické provázání napříč vzdělávacími oblastmi a předměty (např. fyzika ↔ matematika).\n- **PT Integrace:** Audit reálné integrace Průřezových témat (PT) do konkrétních částí obsahu, metod a projektů.\n\n## FÁZE 5: ANALÝZA ŠKOLNÍ PROFILACE A ROZŠÍŘENÍ RVP\n\n**Cíl:** Validovat, že profilace školy je **v souladu** s RVP a nejedná se o **rozpor**.\n\n- **Nekonfliktnost:** Porovnat definovaný Profil absolventa školy s Klíčovými kompetencemi RVP. Profil ŠVP musí RVP rozvíjet, nikoli mu odporovat.\n- **Modularita:** Zkontrolovat, zda volitelné předměty a rozšiřující moduly logicky navazují na vzdělávací oblasti RVP.\n- **Implementace specializace:** Popisně uvést, jak je školní profilace (např. STEM zaměření, projektová výuka) integrována do OVU a kompetencí definovaných RVP.\n\n## FÁZE 6: GENERÁTOR ZÁVĚREČNÉ ZPRÁVY A KVANTIFIKACE\n\n**Cíl:** Syntetizovat výsledky, kvantifikovat soulad a generovat závazné návrhy na korekce.\n\n### 6.1 Kvantifikace Souladu\n\nVypočítat Index shody (IS) na základě bodového hodnocení (Fáze 3):\n\n### 6.2 Interpretace Indexu Shody (IS)\n\nKlasifikace souladu pro standardizované vyhodnocení:\n\n| Interval IS | Klasifikace souladu | Popis |\n| --- | --- | --- |\n| 95-100 % | Výborný soulad | ŠVP plně odpovídá RVP, pouze stylistické nebo formální rozdíly. |\n| --- | --- | --- |\n| 85-94 % | Dobrá shoda | ŠVP pokrývá všechny klíčové výstupy, menší korekce nutné. |\n| --- | --- | --- |\n| 70-84 % | Částečná shoda | Významné nedostatky v některých oblastech, nutná revize obsahu. |\n| --- | --- | --- |\n| < 70 % | Kritická neshoda | ŠVP neplní rámcové požadavky, ohrožuje legislativní soulad. |\n| --- | --- | --- |\n\n### 6.3 Doplňkové Indexy\n\nVypočítat následující doplňkové indexy pro detailní kvalitativní analýzu:\n\n- **Index kompetenčního souladu (IKS):** Poměr pokrytí klíčových kompetencí RVP v ŠVP.\n- **Index průřezové integrace (IPI):** Míra reálné integrace průřezových témat do výuky.\n- **Index hloubky pokrytí (IHP):** Procento výstupů, které jsou v ŠVP rozvedeny na konkrétní výukové cíle (měřitelné, aktivní formulace).\n- **Index profilové rozšiřitelnosti (IPR):** Kolik rozšiřujících nebo profilových výstupů přesahuje rámec RVP, aniž by narušily jeho strukturu.\n\n### 6.4 Vizuální výstupy\n\nZajistit generování následujících vizualizací pro Závěrečnou zprávu:\n\n- Graf pokrytí po vzdělávacích oblastech (Sloupcový graf IS pro VO).\n- Pavoukový diagram Klíčových kompetencí (RVP vs. ŠVP).\n- Mapa defektů (Vizualizace ❌ a ⚠️ výstupů).\n\n### 6.5 Struktura Závěrečné Zprávy\n\nZpráva musí být strukturována dle standardizovaného formátu:\n\n| Oddíl | Obsah |\n| --- | --- |\n| A. Identifikace | Název školy, IZO, typ školy, datum revize, zpracovatel, verze ŠVP a RVP. |\n| --- | --- |\n| B. Shrnutí výsledků | Celkový Index Shody (IS), hlavní závěry a doporučení. |\n| --- | --- |\n| C. Kvantitativní analýza | Přehled IS v % dle kategorií OVU / VO / kompetencí. |\n| --- | --- |\n| D. Kvalitativní analýza | Slovní zhodnocení kvality souladu (formulace, obtížnost, integrace PT). |\n| --- | --- |\n| E. Rizikové oblasti | Přehled nalezených defektů (chybějící OVU, přetížení, formální shoda). |\n| --- | --- |\n| F. Návrhy opatření (Korekční plán) | Přesné návrhy změn - **Co, Kde, Kdo** má upravit, včetně termínu. |\n| --- | --- |\n| G. Přílohy | Master Matice (Fáze 2-3), revizní tabulka, výstupní grafy a metriky. |\n| --- | --- |\n\n\n\n\n.",resultingParameterName:"result",dependentParameterNames:[]}],personas:[],preparations:[{id:1,promptbookVersion:"0.103.0-33",usage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"Asistent pro LŠVP\n\nPERSONA Jsi asistent pro RVP Lyceum v rámci Národního pedagogického institutu České Republiky\nMETA IMAGE https://edulk.cz/getFile/id:475818/type:large/02%20zna%C4%8Dka%20npi.jpg\nRULE Pokud jsi nejsi jistý, napiš nevím\nKNOWLEDGE ./241129_Lyceum_final.pdf\nCONTEXT Obecně dokážeš řešit libovolné ŠVP, aktuálně řešíš {Školní vzdělávací program LYCEUM}\nRULE Z {Porovnání RVP a ŠVP - postup} je nejdůležitější fáze 3\nKNOWLEDGE {Školní vzdělávací program LYCEUM} ./ŠVP Lyceum - Finance v digitální době.pdf\nKNOWLEDGE @Slovník\n\n**Interní slovník - RVP/ŠVP**\n\n**RVP**\n\nRámcový vzdělávací program pro obor vzdělání Lyceum je dokument na národní úrovni, který formuluje požadavky na školní vzdělávací programy ve formě především očekávaných výsledků učení, kterých mají žáci absolvováním tohoto programu na dané škole dosáhnout.\n\n**ŠVP**\n\nŠkolní vzdělávací program pro obor vzdělání Lyceum je dokument každé jednotlivé školy, který popisuje v jakých vyučovacích předmětech/ vzdělávacích modulech a v jakých ročnících budou požadované očekávané výsledky učení naplněny. Zároveň formuluje další očekávané výsledky učení, které naplňují disponibilní část vyučovacího času určeného RVP pro tento obor vzdělání.\n\n**Očekávaný výsledek učení (OVU)**\n\nVyjadřuje jednotlivý požadavek na to, co mají žáci umět na konci vzdělávacího programu, tzn. jejich požadované kompetence. Je vyjádřen formulací, která je uvozena činnostním slovesem a dále obsahuje předmět této činnosti. Formulace je konkretizována resp. doplněna zpravidla formou odrážek vymezením dílčích znalostí, dovedností, postojů, jejichž splnění je předpokladem dosažení OVU jako celku.\n\n_Příklad:_\n\n<div class=\"joplin-table-wrapper\"><table><tbody><tr><th><p><strong>Žák/žákyně řídí realizaci jednoduchého projektu</strong></p></th></tr><tr><td><ul><li>naplánuje aktivity projektu</li></ul></td></tr><tr><td><ul><li>navrhne rozpočet projektu vzhledem k navrženým aktivitám</li></ul></td></tr><tr><td><ul><li>stanoví základní ukazatele a sleduje jejich naplňování</li></ul></td></tr><tr><td><ul><li>vede projektový tým</li></ul></td></tr><tr><td><ul><li>uvede, jak by řešil krizové situace v projektu</li></ul></td></tr><tr><td><ul><li>vyhodnotí úspěšnost projektu</li></ul></td></tr></tbody></table></div>\n\n**Vzdělávací oblasti**\n\nOčekávané výsledky učení jsou v **_RVP členěny do 4 vzdělávacích oblastí_**, které tvoří společný všeobecně vzdělávací základ:\n\n- Osobnostní rozvoj, vzdělávání ke zdraví, bezpečí a produktivnímu pracovnímu životu (kariéře)\n- Komunikační a jazykové vzdělávání\n- Aplikované vzdělávání STEM (Science, Technology, Engeneering, Math), tj. přírodní vědy, informatika, technika, matematika\n- Prakticky orientované vzdělávání společenskovědní a humanitní\n\nKaždá vzdělávací oblast se dále člení na okruhy, v jejichž rámci jsou OVU samostatně číslované.\n\n<div class=\"joplin-table-wrapper\"><table><tbody><tr><th rowspan=\"21\"><ul><li>Prakticky orientované vzdělávání společenskovědní a humanitní</li></ul></th><th rowspan=\"21\"><p><strong>Člověk, ekonomie a podnikání</strong></p></th><th rowspan=\"7\"><p><strong>1</strong></p></th><th><p><strong>zpracuje podklady související s podnikáním</strong></p></th></tr><tr><td><p>připraví podnikatelský záměr</p></td></tr><tr><td><p>sestaví zakladatelský rozpočet</p></td></tr><tr><td><p>zkalkuluje cenu zboží nebo služby</p></td></tr><tr><td><p>vysvětlí na příkladu základní povinnosti podnikatele vůči státu a zaměstnancům</p></td></tr><tr><td><p>vede daňovou evidenci</p></td></tr><tr><td><p>vysvětlí na příkladech etiku v podnikání</p></td></tr><tr><td rowspan=\"7\"><p><strong>2</strong></p></td><td><p><strong>řídí realizaci jednoduchého projektu</strong></p></td></tr><tr><td><p>naplánuje aktivity projektu</p></td></tr><tr><td><p>navrhne rozpočet projektu vzhledem k navrženým aktivitám</p></td></tr><tr><td><p>stanoví základní ukazatele a sleduje jejich naplňování</p></td></tr><tr><td><p>vede projektový tým</p></td></tr><tr><td><p>uvede, jak by řešil krizové situace v projektu</p></td></tr><tr><td><p>vyhodnotí úspěšnost projektu</p></td></tr><tr><td rowspan=\"7\"><p><strong>3</strong></p></td><td><p><strong>aplikuje ekonomické teorie v osobním a profesním životě</strong></p></td></tr><tr><td><p>vysvětlí základní ekonomické otázky</p></td></tr><tr><td><p>vysvětí stanovení rovnovážné ceny na dokonalém i nedokonalém trhu</p></td></tr><tr><td><p>charakterizuje výrobní faktory a vysvětlí hranici produkčních možností a náklady obětované příležitosti</p></td></tr><tr><td><p>uvede nejdůležitější makroekonomické pojmy a vliv jejich výše na kvalitu života a podnikání v daném státě</p></td></tr><tr><td><p>vysvětlí podstatu inflace a její důsledky na finanční situaci obyvatel a na příkladu ukáže jak se bránit jejím nepříznivým důsledkům</p></td></tr><tr><td><p>uvede hlavní výhody a nevýhody mezinárodního obchodu a vliv ochranářských opatření na ekonomickou situaci dané země</p></td></tr><tr><td></td><td></td><td><p><strong>4</strong></p></td><td><p>Atd.</p></td></tr></tbody></table></div>\n\n**Vyučovací předmět / vzdělávací modul**\n\nOčekávané výsledky učení jsou v **ŠVP** členěny do vyučovacích předmětů nebo vzdělávacích modulů, které jsou dále zařazeny do jednoho nebo více ročníků 4letého studia. Vyučovací předmět / vzdělávací modul tvoří vyučovací jednotku, kde jsou očekávané výsledky učení dále rozpracovány pro potřeby výuky podle následující šablony\n\n| **A. VSTUPNÍ ČÁST** |\n| --- |\n| **1\\. Název** |\n| **2\\. Kód** (kódy by měly být navázány na obory vzdělání a výsledky učení) |\n| **2a) Kategorie vzdělání** - v případě, že nebude součástí kódu |\n| **3\\. Typ vyučovací jednotky** (modul, předmět, stáž apod.) |\n| **4\\. Délka** (počet hodin - dělitelný čtyřmi (optimální modul 16, 32 hodin = týden výuky) |\n| **5\\. Platnost** (datum, od kterého platí) |\n| **6\\. Vstupní předpoklady** (vymezení požadované úrovně vstupních vědomostí a dovedností, které jsou předpokladem úspěšného studia) |\n| |\n| **B. JÁDRO VYUČOVACÍ JEDNOTKY** |\n| **1\\. Charakteristika** (stručná anotace popisující obecné cíle a pojetí) |\n| **2\\. Očekávané výsledky učení a jejich indikátory (převzaté z RVP nebo dále konkretizované)** |\n| **3\\. Podpora rozvoje klíčových kompetencí a základních gramotností** (které klíčové kompetence jsou v rozvíjeny) |\n| **4\\. Obsah vzdělávání** (rozpis učiva) |\n| **5\\. Vzdělávací strategie** (strategie výuky, resp. učební činnosti žáků, které jsou doporučené pro dosažení výsledků) |\n| |\n| **C. VÝSTUPNÍ ČÁST** |\n| **1\\. Způsob ověřování dosažených výsledků** (ve vazbě na jednotlivé výsledky učení) |\n| **2\\. Kritéria hodnocení** (co znamená splnění výsledků učení, kdy je splněna celá vyučovací jednotka, kritéria pro známky, příp. procentuální, slovní hodnocení) |\n| **3\\. Doporučená studijní literatura, odkazy na ilustrační zdroje** |\n| **4\\. Poznámky** |\n\n**Soulad OVU RVP a ŠVP**\n\nTento soulad je předmětem zjišťování. Soulad nastává, jestliže jsou očekávané výsledky učení z jednotlivých vzdělávacích oblastí RVP **obsaženy** ve vyučovacích předmětech/ vzdělávacích modulech ŠVP jednotlivých škol, tzn. že v ŠVP se objevuje jejich formulace buď v doslovném nebo podobném znění v jednom nebo více vyučovacích předmětech/ vzdělávacích modulech.\n\n_Příklad souladu:_\n\nRVP ŠVP - komunikace a marketing (SŠ obchodní Č.\n\n| **2** | **řídí realizaci jednoduchého projektu** |\n| --- | --- |\n| naplánuje aktivity projektu |\n| navrhne rozpočet projektu vzhledem k navrženým aktivitám |\n| stanoví základní ukazatele a sleduje jejich naplňování |\n| vede projektový tým |\n| uvede, jak by řešil krizové situace v projektu |\n| vyhodnotí úspěšnost projektu |\n\nKNOWLEDGE {Porovnání RVP a ŠVP - postup}\n\n\n# AUDITNÍ PROTOKOL ŠVP-RVP\n\n# (POPIS KONTROLNÍHO ALGORITMU)\n\nMetodika je určena pro **Kvantifikaci Shody** školního vzdělávacího programu (ŠVP) s Rámcovým vzdělávacím programem (RVP).\n\n## FÁZE 1: VALIDACE DOKUMENTACE\n\n**Cíl:** Ověřit platnost, aktuálnost a strukturu zdrojových dokumentů.\n\n- **RVP Verifikace:** Otevřít aktuální verzi RVP (např. RVP ZV/G/SOŠ).\n- **Typová shoda:** Ověřit, že RVP se vztahuje k danému typu školy.\n- **ŠVP Dimenze:** Identifikovat a izolovat relevantní části ŠVP: Profil absolventa, Klíčové kompetence (KK), Vzdělávací oblasti (VO), případně Učební plán (UP).\n- **Verzování:** Potvrdit, že obě verze (RVP a ŠVP) jsou nejnovější a platné (včetně dodatků RVP).\n\n## FÁZE 2: DATABÁZOVÉ MAPOVÁNÍ VÝSTUPŮ (MASTER MATICE)\n\n**Cíl:** Vytvořit systémovou databázi pro křížové porovnání všech povinných komponent RVP se ŠVP.\n\n- **Dekompozice RVP:** Rozložit RVP na základní povinné komponenty: Klíčové kompetence, Vzdělávací oblasti a obory, Očekávané výstupy (OVU), Průřezová témata (PT).\n- **Přiřazovací mapa:** Vytvořit hlavní kontrolní matici (Master Matice) pro záznam vazeb.\n\n| Oblast RVP | Výstup RVP (OVU) | Odpovídající Část ŠVP (Předmět/Ročník) | Konkrétní Tématický Celek v ŠVP | Stav Shody (Protokol) |\n| --- | --- | --- | --- | --- |\n| ... | ... | ... | ... | ... |\n| --- | --- | --- | --- | --- |\n\n## FÁZE 3: ALGORITMICKÁ KONTROLA POKRYTÍ A HLOUBKY\n\n**Cíl:** Posoudit, zda každý povinný výstup RVP je adekvátně reflektován v obsahu ŠVP, a přidělit bodovou hodnotu pro kvantifikaci.\n\n- **Audit OVU:** Projít každý jednotlivý Očekávaný výstup (OVU) z RVP.\n- **Kódování stavu a bodování:** U každého OVU v matici označit stav pokrytí dle následujícího schématu:\n\n| Kód (Protokol) | Popis (Kvalitativní zjištění) | Bodová hodnota (Kvantifikace) |\n| --- | --- | --- |\n| ✅ | Plná shoda (Výstup pokryt v plném rozsahu, odpovídající úrovni RVP) | 1,0 |\n| --- | --- | --- |\n| ⚠️ | Částečná shoda (Formální pokrytí, omezený rozsah, chybná návaznost) | 0,5 |\n| --- | --- | --- |\n| ❌ | Absence (Výstup zcela chybí v obsahu ŠVP) | 0,0 |\n| --- | --- | --- |\n\n- **Defektologie ŠVP:** Identifikovat a zaznamenat deficity ŠVP: Chybějící výstupy (❌), Sémantické překryvy, Přetížení obsahu.\n- **Kvalitativní posun:** Ověřit, zda je formulace výstupů v ŠVP **aktivní, měřitelná a v souladu** s úrovní RVP.\n\n## FÁZE 4: STRUKTURÁLNÍ VERIFIKACE NÁVAZNOSTI (VERTIKÁLA/HORIZONTÁLA)\n\n**Cíl:** Zkontrolovat logickou posloupnost a provázanost učiva v rámci ŠVP.\n\n- **Vertikální Kontrola:** Ověřit posloupnost OVU a učiva uvnitř jednoho předmětu/oblasti (postup od jednodušších ke složitějším konceptům napříč ročníky).\n- **Horizontální Kontrola:** Zkontrolovat logické provázání napříč vzdělávacími oblastmi a předměty (např. fyzika ↔ matematika).\n- **PT Integrace:** Audit reálné integrace Průřezových témat (PT) do konkrétních částí obsahu, metod a projektů.\n\n## FÁZE 5: ANALÝZA ŠKOLNÍ PROFILACE A ROZŠÍŘENÍ RVP\n\n**Cíl:** Validovat, že profilace školy je **v souladu** s RVP a nejedná se o **rozpor**.\n\n- **Nekonfliktnost:** Porovnat definovaný Profil absolventa školy s Klíčovými kompetencemi RVP. Profil ŠVP musí RVP rozvíjet, nikoli mu odporovat.\n- **Modularita:** Zkontrolovat, zda volitelné předměty a rozšiřující moduly logicky navazují na vzdělávací oblasti RVP.\n- **Implementace specializace:** Popisně uvést, jak je školní profilace (např. STEM zaměření, projektová výuka) integrována do OVU a kompetencí definovaných RVP.\n\n## FÁZE 6: GENERÁTOR ZÁVĚREČNÉ ZPRÁVY A KVANTIFIKACE\n\n**Cíl:** Syntetizovat výsledky, kvantifikovat soulad a generovat závazné návrhy na korekce.\n\n### 6.1 Kvantifikace Souladu\n\nVypočítat Index shody (IS) na základě bodového hodnocení (Fáze 3):\n\n### 6.2 Interpretace Indexu Shody (IS)\n\nKlasifikace souladu pro standardizované vyhodnocení:\n\n| Interval IS | Klasifikace souladu | Popis |\n| --- | --- | --- |\n| 95-100 % | Výborný soulad | ŠVP plně odpovídá RVP, pouze stylistické nebo formální rozdíly. |\n| --- | --- | --- |\n| 85-94 % | Dobrá shoda | ŠVP pokrývá všechny klíčové výstupy, menší korekce nutné. |\n| --- | --- | --- |\n| 70-84 % | Částečná shoda | Významné nedostatky v některých oblastech, nutná revize obsahu. |\n| --- | --- | --- |\n| < 70 % | Kritická neshoda | ŠVP neplní rámcové požadavky, ohrožuje legislativní soulad. |\n| --- | --- | --- |\n\n### 6.3 Doplňkové Indexy\n\nVypočítat následující doplňkové indexy pro detailní kvalitativní analýzu:\n\n- **Index kompetenčního souladu (IKS):** Poměr pokrytí klíčových kompetencí RVP v ŠVP.\n- **Index průřezové integrace (IPI):** Míra reálné integrace průřezových témat do výuky.\n- **Index hloubky pokrytí (IHP):** Procento výstupů, které jsou v ŠVP rozvedeny na konkrétní výukové cíle (měřitelné, aktivní formulace).\n- **Index profilové rozšiřitelnosti (IPR):** Kolik rozšiřujících nebo profilových výstupů přesahuje rámec RVP, aniž by narušily jeho strukturu.\n\n### 6.4 Vizuální výstupy\n\nZajistit generování následujících vizualizací pro Závěrečnou zprávu:\n\n- Graf pokrytí po vzdělávacích oblastech (Sloupcový graf IS pro VO).\n- Pavoukový diagram Klíčových kompetencí (RVP vs. ŠVP).\n- Mapa defektů (Vizualizace ❌ a ⚠️ výstupů).\n\n### 6.5 Struktura Závěrečné Zprávy\n\nZpráva musí být strukturována dle standardizovaného formátu:\n\n| Oddíl | Obsah |\n| --- | --- |\n| A. Identifikace | Název školy, IZO, typ školy, datum revize, zpracovatel, verze ŠVP a RVP. |\n| --- | --- |\n| B. Shrnutí výsledků | Celkový Index Shody (IS), hlavní závěry a doporučení. |\n| --- | --- |\n| C. Kvantitativní analýza | Přehled IS v % dle kategorií OVU / VO / kompetencí. |\n| --- | --- |\n| D. Kvalitativní analýza | Slovní zhodnocení kvality souladu (formulace, obtížnost, integrace PT). |\n| --- | --- |\n| E. Rizikové oblasti | Přehled nalezených defektů (chybějící OVU, přetížení, formální shoda). |\n| --- | --- |\n| F. Návrhy opatření (Korekční plán) | Přesné návrhy změn - **Co, Kde, Kdo** má upravit, včetně termínu. |\n| --- | --- |\n| G. Přílohy | Master Matice (Fáze 2-3), revizní tabulka, výstupní grafy a metriky. |\n| --- | --- |\n\n\n\n\n.\n"}],sourceFile:"./books/examples/lsvp-asistent.book"}];
6089
6089
 
6090
6090
  /**
6091
6091
  * Function `validatePipelineString` will validate the if the string is a valid pipeline string
@@ -6576,6 +6576,7 @@
6576
6576
  let updatedAt = createdAt;
6577
6577
  const errors = [];
6578
6578
  const warnings = [];
6579
+ const llmCalls = [];
6579
6580
  let currentValue = {};
6580
6581
  let customTldr = null;
6581
6582
  const partialResultSubject = new rxjs.Subject();
@@ -6591,6 +6592,9 @@
6591
6592
  }, (tldrInfo) => {
6592
6593
  customTldr = tldrInfo;
6593
6594
  updatedAt = new Date();
6595
+ }, (llmCall) => {
6596
+ llmCalls.push(llmCall);
6597
+ updatedAt = new Date();
6594
6598
  });
6595
6599
  finalResultPromise
6596
6600
  .catch((error) => {
@@ -6736,6 +6740,10 @@
6736
6740
  return warnings;
6737
6741
  // <- Note: [1] --||--
6738
6742
  },
6743
+ get llmCalls() {
6744
+ return llmCalls;
6745
+ // <- Note: [1] --||--
6746
+ },
6739
6747
  get currentValue() {
6740
6748
  return currentValue;
6741
6749
  // <- Note: [1] --||--
@@ -7454,6 +7462,18 @@
7454
7462
  return replacedTemplates;
7455
7463
  }
7456
7464
 
7465
+ /**
7466
+ * Logs an LLM call with the given report.
7467
+ *
7468
+ * @private internal utility of `createPipelineExecutor`
7469
+ */
7470
+ function logLlmCall(logLlmCall, report) {
7471
+ logLlmCall({
7472
+ modelName: 'model' /* <- TODO: How to get model name from the report */,
7473
+ report,
7474
+ });
7475
+ }
7476
+
7457
7477
  /**
7458
7478
  * Executes a pipeline task with multiple attempts, including joker and retry logic. Handles different task types
7459
7479
  * (prompt, script, dialog, etc.), applies postprocessing, checks expectations, and updates the execution report.
@@ -7465,7 +7485,7 @@
7465
7485
  */
7466
7486
  async function executeAttempts(options) {
7467
7487
  const { jokerParameterNames, priority, maxAttempts, // <- Note: [💂]
7468
- preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, } = options;
7488
+ preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, logLlmCall: logLlmCall$1, } = options;
7469
7489
  const $ongoingTaskResult = {
7470
7490
  $result: null,
7471
7491
  $resultString: null,
@@ -7713,14 +7733,10 @@
7713
7733
  });
7714
7734
  }
7715
7735
  finally {
7716
- if (!isJokerAttempt &&
7717
- task.taskType === 'PROMPT_TASK' &&
7718
- $ongoingTaskResult.$prompt
7719
- // <- Note: [2] When some expected parameter is not defined, error will occur in templateParameters
7720
- // In that case we don’t want to make a report about it because it’s not a llm execution error
7721
- ) {
7722
- // TODO: [🧠] Maybe put other taskTypes into report
7723
- $executionReport.promptExecutions.push({
7736
+ if (!isJokerAttempt && task.taskType === 'PROMPT_TASK' && $ongoingTaskResult.$prompt) {
7737
+ // Note: [2] When some expected parameter is not defined, error will occur in templateParameters
7738
+ // In that case we don’t want to make a report about it because it’s not a llm execution error
7739
+ const executionPromptReport = {
7724
7740
  prompt: {
7725
7741
  ...$ongoingTaskResult.$prompt,
7726
7742
  // <- TODO: [🧠] How to pick everyhing except `pipelineUrl`
@@ -7729,7 +7745,11 @@
7729
7745
  error: $ongoingTaskResult.$expectError === null
7730
7746
  ? undefined
7731
7747
  : serializeError($ongoingTaskResult.$expectError),
7732
- });
7748
+ };
7749
+ $executionReport.promptExecutions.push(executionPromptReport);
7750
+ if (logLlmCall$1) {
7751
+ logLlmCall(logLlmCall$1, executionPromptReport);
7752
+ }
7733
7753
  }
7734
7754
  }
7735
7755
  if ($ongoingTaskResult.$expectError !== null && attemptIndex === maxAttempts - 1) {
@@ -7794,9 +7814,9 @@
7794
7814
  * @private internal utility of `createPipelineExecutor`
7795
7815
  */
7796
7816
  async function executeFormatSubvalues(options) {
7797
- const { task, jokerParameterNames, parameters, priority, csvSettings, onProgress, pipelineIdentification } = options;
7817
+ const { task, jokerParameterNames, parameters, priority, csvSettings, onProgress, logLlmCall, pipelineIdentification, } = options;
7798
7818
  if (task.foreach === undefined) {
7799
- return /* not await */ executeAttempts(options);
7819
+ return /* not await */ executeAttempts({ ...options, logLlmCall });
7800
7820
  }
7801
7821
  if (jokerParameterNames.length !== 0) {
7802
7822
  throw new UnexpectedError(spaceTrim__default["default"]((block) => `
@@ -8097,7 +8117,7 @@
8097
8117
  * @private internal utility of `createPipelineExecutor`
8098
8118
  */
8099
8119
  async function executeTask(options) {
8100
- const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSuppressed, } = options;
8120
+ const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, logLlmCall, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSuppressed, } = options;
8101
8121
  const priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
8102
8122
  // Note: Check consistency of used and dependent parameters which was also done in `validatePipeline`, but it’s good to doublecheck
8103
8123
  const usedParameterNames = extractParameterNamesFromTask(currentTask);
@@ -8176,6 +8196,7 @@
8176
8196
  tools,
8177
8197
  $executionReport,
8178
8198
  onProgress,
8199
+ logLlmCall,
8179
8200
  pipelineIdentification,
8180
8201
  maxExecutionAttempts,
8181
8202
  maxParallelCount,
@@ -8262,7 +8283,7 @@
8262
8283
  * @private internal utility of `createPipelineExecutor`
8263
8284
  */
8264
8285
  async function executePipeline(options) {
8265
- const { inputParameters, tools, onProgress, pipeline, setPreparedPipeline, pipelineIdentification, maxParallelCount, rootDirname, isVerbose, } = options;
8286
+ const { inputParameters, tools, onProgress, logLlmCall, pipeline, setPreparedPipeline, pipelineIdentification, maxParallelCount, rootDirname, isVerbose, } = options;
8266
8287
  let { preparedPipeline } = options;
8267
8288
  if (preparedPipeline === undefined) {
8268
8289
  preparedPipeline = await preparePipeline(pipeline, tools, {
@@ -8440,6 +8461,7 @@
8440
8461
  onProgress(newOngoingResult);
8441
8462
  }
8442
8463
  },
8464
+ logLlmCall,
8443
8465
  $executionReport: executionReport,
8444
8466
  pipelineIdentification: spaceTrim.spaceTrim((block) => `
8445
8467
  ${block(pipelineIdentification)}
@@ -8563,7 +8585,7 @@
8563
8585
  // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
8564
8586
  }
8565
8587
  let runCount = 0;
8566
- const pipelineExecutorWithCallback = async (inputParameters, onProgress) => {
8588
+ const pipelineExecutorWithCallback = async (inputParameters, onProgress, logLlmCall) => {
8567
8589
  runCount++;
8568
8590
  return /* not await */ executePipeline({
8569
8591
  pipeline,
@@ -8574,6 +8596,7 @@
8574
8596
  inputParameters,
8575
8597
  tools,
8576
8598
  onProgress,
8599
+ logLlmCall,
8577
8600
  pipelineIdentification: spaceTrim.spaceTrim((block) => `
8578
8601
  ${block(pipelineIdentification)}
8579
8602
  ${runCount === 1 ? '' : `Run #${runCount}`}
@@ -12108,7 +12131,7 @@
12108
12131
  *
12109
12132
  * @public exported from `@promptbook/core`
12110
12133
  */
12111
- const PADDING_LINES = 4;
12134
+ const PADDING_LINES = 11;
12112
12135
  /**
12113
12136
  * A function that adds padding to the book content
12114
12137
  *
@@ -16035,10 +16058,10 @@
16035
16058
  .send({ error: serializeError(error) });
16036
16059
  }
16037
16060
  });
16038
- function exportExecutionTask(executionTask, isFull) {
16061
+ function exportExecutionTask(executionTask, isDetailed) {
16039
16062
  // <- TODO: [🧠] This should be maybe method of `ExecutionTask` itself
16040
- const { taskType, promptbookVersion, taskId, title, status, errors, tldr, warnings, createdAt, updatedAt, currentValue, } = executionTask;
16041
- if (isFull) {
16063
+ const { taskType, promptbookVersion, taskId, title, status, errors, tldr, warnings, createdAt, updatedAt, currentValue, llmCalls, } = executionTask;
16064
+ if (isDetailed) {
16042
16065
  return {
16043
16066
  taskId,
16044
16067
  title,
@@ -16048,9 +16071,11 @@
16048
16071
  tldr,
16049
16072
  errors: errors.map(serializeError),
16050
16073
  warnings: warnings.map(serializeError),
16074
+ llmCalls,
16051
16075
  createdAt,
16052
16076
  updatedAt,
16053
16077
  currentValue,
16078
+ ptbkNonce: 0,
16054
16079
  };
16055
16080
  }
16056
16081
  else {
@@ -16063,6 +16088,8 @@
16063
16088
  tldr,
16064
16089
  createdAt,
16065
16090
  updatedAt,
16091
+ llmCalls,
16092
+ ptbkNonce: 0,
16066
16093
  };
16067
16094
  }
16068
16095
  }
@@ -21912,170 +21939,2809 @@
21912
21939
  */
21913
21940
 
21914
21941
  /**
21915
- * Transpiler to Python code using LangChain library.
21942
+ * Creates an empty/basic agent model requirements object
21943
+ * This serves as the starting point for the reduce-like pattern
21944
+ * where each commitment applies its changes to build the final requirements
21916
21945
  *
21917
- * @private TODO: !!!! Which package should export this?
21946
+ * @public exported from `@promptbook/core`
21947
+ */
21948
+ function createEmptyAgentModelRequirements() {
21949
+ return {
21950
+ systemMessage: '',
21951
+ // modelName: 'gpt-5',
21952
+ modelName: 'gemini-2.5-flash-lite',
21953
+ temperature: 0.7,
21954
+ topP: 0.9,
21955
+ topK: 50,
21956
+ };
21957
+ }
21958
+ /**
21959
+ * Creates a basic agent model requirements with just the agent name
21960
+ * This is used when we have an agent name but no commitments
21961
+ *
21962
+ * @public exported from `@promptbook/core`
21963
+ */
21964
+ function createBasicAgentModelRequirements(agentName) {
21965
+ const empty = createEmptyAgentModelRequirements();
21966
+ return {
21967
+ ...empty,
21968
+ systemMessage: `You are ${agentName || 'AI Agent'}`,
21969
+ };
21970
+ }
21971
+ /**
21972
+ * TODO: [🐤] Deduplicate `AgentModelRequirements` and `ModelRequirements` model requirements
21918
21973
  */
21919
- const LangchainTranspiler = {
21920
- name: 'langchain',
21921
- title: 'LangChain',
21922
- // TODO: [🧠] packageName and className
21923
- packageName: '@promptbook/langchain-transpiler',
21924
- className: 'LangchainTranspiler',
21925
- new: (tools) => async (book, _options) => {
21926
- const pipeline = await compilePipeline(book, tools);
21927
- const anouncement = spaceTrim.spaceTrim(() => `
21928
- """
21929
- This code was generated by Promptbook
21930
- @see https://promptbook.studio
21931
-
21932
- From book: ${pipeline.pipelineUrl}
21933
-
21934
- WARNING: This code is experimental and may not work as expected.
21935
- """
21936
- `);
21937
- const imports = spaceTrim.spaceTrim(() => `
21938
- from langchain_openai import ChatOpenAI
21939
- from langchain_core.prompts import ChatPromptTemplate
21940
- `);
21941
- const functions = pipeline.tasks.map((template) => transpileTemplate$1(template, pipeline));
21942
- return spaceTrim.spaceTrim(() => `
21943
- ${anouncement}
21944
21974
 
21945
- ${imports}
21975
+ /**
21976
+ * Generates a regex pattern to match a specific commitment
21977
+ *
21978
+ * Note: It always creates new Regex object
21979
+ * Note: Uses word boundaries to ensure only full words are matched (e.g., "PERSONA" matches but "PERSONALITY" does not)
21980
+ *
21981
+ * @private - TODO: [🧠] Maybe should be public?
21982
+ */
21983
+ function createCommitmentRegex(commitment) {
21984
+ const escapedCommitment = commitment.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
21985
+ const keywordPattern = escapedCommitment.split(/\s+/).join('\\s+');
21986
+ const regex = new RegExp(`^\\s*(?<type>${keywordPattern})\\b\\s+(?<contents>.+)$`, 'gim');
21987
+ return regex;
21988
+ }
21989
+ /**
21990
+ * Generates a regex pattern to match a specific commitment type
21991
+ *
21992
+ * Note: It just matches the type part of the commitment
21993
+ * Note: It always creates new Regex object
21994
+ * Note: Uses word boundaries to ensure only full words are matched (e.g., "PERSONA" matches but "PERSONALITY" does not)
21995
+ *
21996
+ * @private
21997
+ */
21998
+ function createCommitmentTypeRegex(commitment) {
21999
+ const escapedCommitment = commitment.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
22000
+ const keywordPattern = escapedCommitment.split(/\s+/).join('\\s+');
22001
+ const regex = new RegExp(`^\\s*(?<type>${keywordPattern})\\b`, 'gim');
22002
+ return regex;
22003
+ }
21946
22004
 
21947
- ${functions.join('\n\n')}
21948
- `);
21949
- },
21950
- };
21951
- function transpileTemplate$1(template, pipeline) {
21952
- // TODO: Better template type detection
21953
- if (template.taskType === 'PROMPT_TEMPLATE' &&
21954
- template.modelRequirements.modelVariant === 'CHAT') {
21955
- // TODO: DRY
21956
- const functionName = template.name;
21957
- const parameters = pipeline.parameters.filter((parameter) => parameter.isInput);
21958
- const parameterNames = parameters.map((parameter) => parameter.name);
21959
- const parameterNamesAndTypes = parameterNames.map((name) => `${name}: str`).join(', ');
21960
- const interpolatedContent = interpolateTemplate$1(template.content, parameterNames);
21961
- return spaceTrim.spaceTrim(() => `
21962
- def ${functionName}(${parameterNamesAndTypes}):
21963
- chat = ChatOpenAI(model="${template.modelRequirements.modelName}", temperature=0.7)
21964
- prompt = ChatPromptTemplate.from_messages([
21965
- ("human", ${interpolatedContent})
21966
- ])
21967
- chain = prompt | chat
21968
- return chain.invoke({${parameterNames.map((name) => `'${name}': ${name}`).join(', ')}})
21969
- `);
22005
+ /**
22006
+ * Base implementation of CommitmentDefinition that provides common functionality
22007
+ * Most commitments can extend this class and only override the applyToAgentModelRequirements method
22008
+ *
22009
+ * @private
22010
+ */
22011
+ class BaseCommitmentDefinition {
22012
+ constructor(type) {
22013
+ this.type = type;
21970
22014
  }
21971
- else {
21972
- return `# TODO: ${template.taskType} templates are not implemented yet`;
22015
+ /**
22016
+ * Creates a regex pattern to match this commitment in agent source
22017
+ * Uses the existing createCommitmentRegex function as internal helper
22018
+ */
22019
+ createRegex() {
22020
+ return createCommitmentRegex(this.type);
22021
+ }
22022
+ /**
22023
+ * Creates a regex pattern to match just the commitment type
22024
+ * Uses the existing createCommitmentTypeRegex function as internal helper
22025
+ */
22026
+ createTypeRegex() {
22027
+ return createCommitmentTypeRegex(this.type);
22028
+ }
22029
+ /**
22030
+ * Helper method to create a new requirements object with updated system message
22031
+ * This is commonly used by many commitments
22032
+ */
22033
+ updateSystemMessage(requirements, messageUpdate) {
22034
+ const newMessage = typeof messageUpdate === 'string' ? messageUpdate : messageUpdate(requirements.systemMessage);
22035
+ return {
22036
+ ...requirements,
22037
+ systemMessage: newMessage,
22038
+ };
22039
+ }
22040
+ /**
22041
+ * Helper method to append content to the system message
22042
+ */
22043
+ appendToSystemMessage(requirements, content, separator = '\n\n') {
22044
+ return this.updateSystemMessage(requirements, (currentMessage) => {
22045
+ if (!currentMessage.trim()) {
22046
+ return content;
22047
+ }
22048
+ return currentMessage + separator + content;
22049
+ });
22050
+ }
22051
+ /**
22052
+ * Helper method to add a comment section to the system message
22053
+ * Comments are lines starting with # that will be removed from the final system message
22054
+ * but can be useful for organizing and structuring the message during processing
22055
+ */
22056
+ addCommentSection(requirements, commentTitle, content, position = 'end') {
22057
+ const commentSection = `# ${commentTitle.toUpperCase()}\n${content}`;
22058
+ if (position === 'beginning') {
22059
+ return this.updateSystemMessage(requirements, (currentMessage) => {
22060
+ if (!currentMessage.trim()) {
22061
+ return commentSection;
22062
+ }
22063
+ return commentSection + '\n\n' + currentMessage;
22064
+ });
22065
+ }
22066
+ else {
22067
+ return this.appendToSystemMessage(requirements, commentSection);
22068
+ }
21973
22069
  }
21974
22070
  }
21975
- function interpolateTemplate$1(template, parameterNames) {
21976
- let result = template;
21977
- for (const parameterName of parameterNames) {
21978
- result = result.replace(new RegExp(`{${parameterName}}`, 'g'), `{${parameterName}}`);
22071
+
22072
+ /**
22073
+ * ACTION commitment definition
22074
+ *
22075
+ * The ACTION commitment defines specific actions or capabilities that the agent can perform.
22076
+ * This helps define what the agent is capable of doing and how it should approach tasks.
22077
+ *
22078
+ * Example usage in agent source:
22079
+ *
22080
+ * ```book
22081
+ * ACTION Can generate code snippets and explain programming concepts
22082
+ * ACTION Able to analyze data and provide insights
22083
+ * ```
22084
+ *
22085
+ * @private [🪔] Maybe export the commitments through some package
22086
+ */
22087
+ class ActionCommitmentDefinition extends BaseCommitmentDefinition {
22088
+ constructor(type = 'ACTION') {
22089
+ super(type);
22090
+ }
22091
+ /**
22092
+ * Short one-line description of ACTION.
22093
+ */
22094
+ get description() {
22095
+ return 'Define agent capabilities and actions it can perform.';
22096
+ }
22097
+ /**
22098
+ * Markdown documentation for ACTION commitment.
22099
+ */
22100
+ get documentation() {
22101
+ return spaceTrim.spaceTrim(`
22102
+ # ${this.type}
22103
+
22104
+ Defines specific actions or capabilities that the agent can perform.
22105
+
22106
+ ## Key aspects
22107
+
22108
+ - Both terms work identically and can be used interchangeably.
22109
+ - Each action adds to the agent's capability list.
22110
+ - Actions help users understand what the agent can do.
22111
+
22112
+ ## Examples
22113
+
22114
+ \`\`\`book
22115
+ Code Assistant
22116
+
22117
+ PERSONA You are a programming assistant
22118
+ ACTION Can generate code snippets and explain programming concepts
22119
+ ACTION Able to debug existing code and suggest improvements
22120
+ ACTION Can create unit tests for functions
22121
+ \`\`\`
22122
+
22123
+ \`\`\`book
22124
+ Data Scientist
22125
+
22126
+ PERSONA You are a data analysis expert
22127
+ ACTION Able to analyze data and provide insights
22128
+ ACTION Can create visualizations and charts
22129
+ ACTION Capable of statistical analysis and modeling
22130
+ KNOWLEDGE Data analysis best practices and statistical methods
22131
+ \`\`\`
22132
+ `);
22133
+ }
22134
+ applyToAgentModelRequirements(requirements, content) {
22135
+ const trimmedContent = content.trim();
22136
+ if (!trimmedContent) {
22137
+ return requirements;
22138
+ }
22139
+ // Add action capability to the system message
22140
+ const actionSection = `Capability: ${trimmedContent}`;
22141
+ return this.appendToSystemMessage(requirements, actionSection, '\n\n');
21979
22142
  }
21980
- return `f"${result}"`;
21981
22143
  }
22144
+ /**
22145
+ * Note: [💞] Ignore a discrepancy between file name and entity name
22146
+ */
21982
22147
 
21983
22148
  /**
21984
- * Registration of LLM provider
22149
+ * DELETE commitment definition
21985
22150
  *
21986
- * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available LLM tools
22151
+ * The DELETE commitment (and its aliases CANCEL, DISCARD, REMOVE) is used to
22152
+ * remove or disregard certain information or context. This can be useful for
22153
+ * overriding previous commitments or removing unwanted behaviors.
21987
22154
  *
21988
- * @public exported from `@promptbook/wizard`
21989
- * @public exported from `@promptbook/cli`
22155
+ * Example usage in agent source:
21990
22156
  *
21991
- * TODO: !!!! Which package should export this? - `@promptbook/core` vs `@promptbook/transpilers` vs `@promptbook/langchain`
22157
+ * ```book
22158
+ * DELETE Previous formatting requirements
22159
+ * CANCEL All emotional responses
22160
+ * DISCARD Technical jargon explanations
22161
+ * REMOVE Casual conversational style
22162
+ * ```
22163
+ *
22164
+ * @private [🪔] Maybe export the commitments through some package
21992
22165
  */
21993
- const _LangchainTranspilerRegistration = $bookTranspilersRegister.register(LangchainTranspiler);
22166
+ class DeleteCommitmentDefinition extends BaseCommitmentDefinition {
22167
+ constructor(type) {
22168
+ super(type);
22169
+ }
22170
+ /**
22171
+ * Short one-line description of DELETE/CANCEL/DISCARD/REMOVE.
22172
+ */
22173
+ get description() {
22174
+ return 'Remove or **disregard** certain information, context, or previous commitments.';
22175
+ }
22176
+ /**
22177
+ * Markdown documentation for DELETE commitment.
22178
+ */
22179
+ get documentation() {
22180
+ return spaceTrim.spaceTrim(`
22181
+ # DELETE (CANCEL, DISCARD, REMOVE)
22182
+
22183
+ A commitment to remove or disregard certain information or context. This can be useful for overriding previous commitments or removing unwanted behaviors.
22184
+
22185
+ ## Aliases
22186
+
22187
+ - \`DELETE\` - Remove or eliminate something
22188
+ - \`CANCEL\` - Cancel or nullify something
22189
+ - \`DISCARD\` - Discard or ignore something
22190
+ - \`REMOVE\` - Remove or take away something
22191
+
22192
+ ## Key aspects
22193
+
22194
+ - Multiple delete commitments can be used to remove different aspects.
22195
+ - Useful for overriding previous commitments in the same agent definition.
22196
+ - Can be used to remove inherited behaviors from base personas.
22197
+ - Helps fine-tune agent behavior by explicitly removing unwanted elements.
22198
+
22199
+ ## Use cases
22200
+
22201
+ - Overriding inherited persona characteristics
22202
+ - Removing conflicting or outdated instructions
22203
+ - Disabling specific response patterns
22204
+ - Canceling previous formatting or style requirements
22205
+
22206
+ ## Examples
22207
+
22208
+ \`\`\`book
22209
+ Serious Business Assistant
22210
+
22211
+ PERSONA You are a friendly and casual assistant who uses emojis
22212
+ DELETE Casual conversational style
22213
+ REMOVE All emoji usage
22214
+ GOAL Provide professional business communications
22215
+ STYLE Use formal language and proper business etiquette
22216
+ \`\`\`
22217
+
22218
+ \`\`\`book
22219
+ Simplified Technical Support
22220
+
22221
+ PERSONA You are a technical support specialist with deep expertise
22222
+ KNOWLEDGE Extensive database of technical specifications
22223
+ DISCARD Technical jargon explanations
22224
+ CANCEL Advanced troubleshooting procedures
22225
+ GOAL Help users with simple, easy-to-follow solutions
22226
+ STYLE Use plain language that anyone can understand
22227
+ \`\`\`
22228
+
22229
+ \`\`\`book
22230
+ Focused Customer Service
22231
+
22232
+ PERSONA You are a customer service agent with broad knowledge
22233
+ ACTION Can help with billing, technical issues, and product information
22234
+ DELETE Billing assistance capabilities
22235
+ REMOVE Technical troubleshooting functions
22236
+ GOAL Focus exclusively on product information and general inquiries
22237
+ \`\`\`
22238
+
22239
+ \`\`\`book
22240
+ Concise Information Provider
22241
+
22242
+ PERSONA You are a helpful assistant who provides detailed explanations
22243
+ STYLE Include examples, analogies, and comprehensive context
22244
+ CANCEL Detailed explanation style
22245
+ DISCARD Examples and analogies
22246
+ GOAL Provide brief, direct answers without unnecessary elaboration
22247
+ STYLE Be concise and to the point
22248
+ \`\`\`
22249
+ `);
22250
+ }
22251
+ applyToAgentModelRequirements(requirements, content) {
22252
+ const trimmedContent = content.trim();
22253
+ if (!trimmedContent) {
22254
+ return requirements;
22255
+ }
22256
+ // Create deletion instruction for system message
22257
+ const deleteSection = `${this.type}: ${trimmedContent}`;
22258
+ // Delete instructions provide important context about what should be removed or ignored
22259
+ return this.appendToSystemMessage(requirements, deleteSection, '\n\n');
22260
+ }
22261
+ }
21994
22262
  /**
21995
22263
  * Note: [💞] Ignore a discrepancy between file name and entity name
21996
22264
  */
21997
22265
 
21998
22266
  /**
21999
- * Transpiler to Javascript code using OpenAI SDK.
22267
+ * FORMAT commitment definition
22268
+ *
22269
+ * The FORMAT commitment defines the specific output structure and formatting
22270
+ * that the agent should use in its responses. This includes data formats,
22271
+ * response templates, and structural requirements.
22272
+ *
22273
+ * Example usage in agent source:
22000
22274
  *
22001
- * @private TODO: !!!! Which package should export this?
22275
+ * ```book
22276
+ * FORMAT Always respond in JSON format with 'status' and 'data' fields
22277
+ * FORMAT Use markdown formatting for all code blocks
22278
+ * ```
22279
+ *
22280
+ * @private [🪔] Maybe export the commitments through some package
22002
22281
  */
22003
- const OpenAiSdkTranspiler = {
22004
- name: 'openai-sdk',
22005
- title: 'OpenAI SDK',
22006
- // TODO: [🧠] packageName and className
22007
- packageName: '@promptbook/openai-sdk-transpiler',
22008
- className: 'OpenAiSdkTranspiler',
22009
- new: (tools) => async (book, _options) => {
22010
- const pipeline = await compilePipeline(book, tools);
22011
- const anouncement = spaceTrim.spaceTrim(() => `
22012
- /**
22013
- * This code was generated by Promptbook
22014
- * @see https://promptbook.studio
22015
- *
22016
- * From book: ${pipeline.pipelineUrl}
22017
- *
22018
- * WARNING: This code is experimental and may not work as expected.
22019
- */
22020
- `);
22021
- const imports = spaceTrim.spaceTrim(() => `
22022
- import { OpenAI } from 'openai';
22023
- `);
22024
- const functions = pipeline.tasks.map((template) => transpileTemplate(template, pipeline));
22025
- return spaceTrim.spaceTrim(() => `
22026
- ${anouncement}
22282
+ class FormatCommitmentDefinition extends BaseCommitmentDefinition {
22283
+ constructor(type = 'FORMAT') {
22284
+ super(type);
22285
+ }
22286
+ /**
22287
+ * Short one-line description of FORMAT.
22288
+ */
22289
+ get description() {
22290
+ return 'Specify output structure or formatting requirements.';
22291
+ }
22292
+ /**
22293
+ * Markdown documentation for FORMAT commitment.
22294
+ */
22295
+ get documentation() {
22296
+ return spaceTrim.spaceTrim(`
22297
+ # ${this.type}
22027
22298
 
22028
- ${imports}
22299
+ Defines the specific output structure and formatting for responses (data formats, templates, structure).
22029
22300
 
22030
- ${functions.join('\n\n')}
22031
- `);
22032
- },
22033
- };
22034
- function transpileTemplate(template, pipeline) {
22035
- // TODO: Better template type detection
22036
- if (template.taskType === 'PROMPT_TEMPLATE' &&
22037
- template.modelRequirements.modelVariant === 'CHAT') {
22038
- // TODO: DRY
22039
- const functionName = template.name;
22040
- const parameters = pipeline.parameters.filter((parameter) => parameter.isInput);
22041
- const parameterNames = parameters.map((parameter) => parameter.name);
22042
- const parameterNamesAndTypes = parameterNames.map((name) => `${name}: string`).join(', ');
22043
- const interpolatedContent = interpolateTemplate(template.content, parameterNames);
22044
- return spaceTrim.spaceTrim(() => `
22045
- export async function ${functionName}({ ${parameterNames.join(', ')} }: { ${parameterNamesAndTypes} }) {
22046
- const openai = new OpenAI({
22047
- apiKey: process.env.OPENAI_API_KEY,
22048
- });
22049
- const chatCompletion = await openai.chat.completions.create({
22050
- messages: [
22051
- {
22052
- role: 'user',
22053
- content: ${interpolatedContent},
22054
- },
22055
- ],
22056
- model: '${template.modelRequirements.modelName}',
22057
- });
22058
- return chatCompletion.choices[0].message.content;
22059
- }
22060
- `);
22301
+ ## Key aspects
22302
+
22303
+ - Both terms work identically and can be used interchangeably.
22304
+ - If they are in conflict, the last one takes precedence.
22305
+ - You can specify both data formats and presentation styles.
22306
+
22307
+ ## Examples
22308
+
22309
+ \`\`\`book
22310
+ Customer Support Bot
22311
+
22312
+ PERSONA You are a helpful customer support agent
22313
+ FORMAT Always respond in JSON format with 'status' and 'data' fields
22314
+ FORMAT Use markdown formatting for all code blocks
22315
+ \`\`\`
22316
+
22317
+ \`\`\`book
22318
+ Data Analyst
22319
+
22320
+ PERSONA You are a data analysis expert
22321
+ FORMAT Present results in structured tables
22322
+ FORMAT Include confidence scores for all predictions
22323
+ STYLE Be concise and precise in explanations
22324
+ \`\`\`
22325
+ `);
22061
22326
  }
22062
- else {
22063
- return `// TODO: ${template.taskType} templates are not implemented yet`;
22327
+ applyToAgentModelRequirements(requirements, content) {
22328
+ const trimmedContent = content.trim();
22329
+ if (!trimmedContent) {
22330
+ return requirements;
22331
+ }
22332
+ // Add format instructions to the system message
22333
+ const formatSection = `Output Format: ${trimmedContent}`;
22334
+ return this.appendToSystemMessage(requirements, formatSection, '\n\n');
22064
22335
  }
22065
22336
  }
22066
- function interpolateTemplate(template, parameterNames) {
22067
- let result = template;
22068
- for (const parameterName of parameterNames) {
22069
- result = result.replace(new RegExp(`{${parameterName}}`, 'g'), `\${${parameterName}}`);
22337
+ /**
22338
+ * Note: [💞] Ignore a discrepancy between file name and entity name
22339
+ */
22340
+
22341
+ /**
22342
+ * GOAL commitment definition
22343
+ *
22344
+ * The GOAL commitment defines the main goal which should be achieved by the AI assistant.
22345
+ * There can be multiple goals. Later goals are more important than earlier goals.
22346
+ *
22347
+ * Example usage in agent source:
22348
+ *
22349
+ * ```book
22350
+ * GOAL Help users understand complex technical concepts
22351
+ * GOAL Provide accurate and up-to-date information
22352
+ * GOAL Always prioritize user safety and ethical guidelines
22353
+ * ```
22354
+ *
22355
+ * @private [🪔] Maybe export the commitments through some package
22356
+ */
22357
+ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
22358
+ constructor(type = 'GOAL') {
22359
+ super(type);
22360
+ }
22361
+ /**
22362
+ * Short one-line description of GOAL.
22363
+ */
22364
+ get description() {
22365
+ return 'Define main **goals** the AI assistant should achieve, with later goals having higher priority.';
22366
+ }
22367
+ /**
22368
+ * Markdown documentation for GOAL commitment.
22369
+ */
22370
+ get documentation() {
22371
+ return spaceTrim.spaceTrim(`
22372
+ # ${this.type}
22373
+
22374
+ 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.
22375
+
22376
+ ## Key aspects
22377
+
22378
+ - Both terms work identically and can be used interchangeably.
22379
+ - Later goals have higher priority and can override earlier goals.
22380
+ - Goals provide clear direction and purpose for the agent's responses.
22381
+ - Goals influence decision-making and response prioritization.
22382
+
22383
+ ## Priority system
22384
+
22385
+ When multiple goals are defined, they are processed in order, with later goals taking precedence over earlier ones when there are conflicts.
22386
+
22387
+ ## Examples
22388
+
22389
+ \`\`\`book
22390
+ Customer Support Agent
22391
+
22392
+ PERSONA You are a helpful customer support representative
22393
+ GOAL Resolve customer issues quickly and efficiently
22394
+ GOAL Maintain high customer satisfaction scores
22395
+ GOAL Always follow company policies and procedures
22396
+ RULE Be polite and professional at all times
22397
+ \`\`\`
22398
+
22399
+ \`\`\`book
22400
+ Educational Assistant
22401
+
22402
+ PERSONA You are an educational assistant specializing in mathematics
22403
+ GOAL Help students understand mathematical concepts clearly
22404
+ GOAL Encourage critical thinking and problem-solving skills
22405
+ GOAL Ensure all explanations are age-appropriate and accessible
22406
+ STYLE Use simple language and provide step-by-step explanations
22407
+ \`\`\`
22408
+
22409
+ \`\`\`book
22410
+ Safety-First Assistant
22411
+
22412
+ PERSONA You are a general-purpose AI assistant
22413
+ GOAL Be helpful and informative in all interactions
22414
+ GOAL Provide accurate and reliable information
22415
+ GOAL Always prioritize user safety and ethical guidelines
22416
+ RULE Never provide harmful or dangerous advice
22417
+ \`\`\`
22418
+ `);
22419
+ }
22420
+ applyToAgentModelRequirements(requirements, content) {
22421
+ const trimmedContent = content.trim();
22422
+ if (!trimmedContent) {
22423
+ return requirements;
22424
+ }
22425
+ // Create goal section for system message
22426
+ const goalSection = `Goal: ${trimmedContent}`;
22427
+ // Goals are important directives, so we add them prominently to the system message
22428
+ return this.appendToSystemMessage(requirements, goalSection, '\n\n');
22070
22429
  }
22071
- return `\`${result}\``;
22072
22430
  }
22073
22431
  /**
22074
- * TODO: [🧠] What should be the scope of the transpiled code?
22075
- * - Just a single function?
22076
- * - A class?
22077
- * - A whole package?
22432
+ * Note: [💞] Ignore a discrepancy between file name and entity name
22433
+ */
22434
+
22435
+ /**
22436
+ * KNOWLEDGE commitment definition
22437
+ *
22438
+ * The KNOWLEDGE commitment adds specific knowledge, facts, or context to the agent
22439
+ * using RAG (Retrieval-Augmented Generation) approach for external sources.
22440
+ *
22441
+ * Supports both direct text knowledge and external sources like PDFs.
22442
+ *
22443
+ * Example usage in agent source:
22444
+ *
22445
+ * ```book
22446
+ * KNOWLEDGE The company was founded in 2020 and specializes in AI-powered solutions
22447
+ * KNOWLEDGE https://example.com/company-handbook.pdf
22448
+ * KNOWLEDGE https://example.com/product-documentation.pdf
22449
+ * ```
22450
+ *
22451
+ * @private [🪔] Maybe export the commitments through some package
22078
22452
  */
22453
+ class KnowledgeCommitmentDefinition extends BaseCommitmentDefinition {
22454
+ constructor() {
22455
+ super('KNOWLEDGE');
22456
+ }
22457
+ /**
22458
+ * Short one-line description of KNOWLEDGE.
22459
+ */
22460
+ get description() {
22461
+ return 'Add domain **knowledge** via direct text or external sources (RAG).';
22462
+ }
22463
+ /**
22464
+ * Markdown documentation for KNOWLEDGE commitment.
22465
+ */
22466
+ get documentation() {
22467
+ return spaceTrim.spaceTrim(`
22468
+ # ${this.type}
22469
+
22470
+ Adds specific knowledge, facts, or context to the agent using a RAG (Retrieval-Augmented Generation) approach for external sources.
22471
+
22472
+ ## Key aspects
22473
+
22474
+ - Both terms work identically and can be used interchangeably.
22475
+ - Supports both direct text knowledge and external URLs.
22476
+ - External sources (PDFs, websites) are processed via RAG for context retrieval.
22477
+
22478
+ ## Supported formats
22479
+
22480
+ - Direct text: Immediate knowledge incorporated into agent
22481
+ - URLs: External documents processed for contextual retrieval
22482
+ - Supported file types: PDF, text, markdown, HTML
22483
+
22484
+ ## Examples
22485
+
22486
+ \`\`\`book
22487
+ Customer Support Bot
22488
+
22489
+ PERSONA You are a helpful customer support agent for TechCorp
22490
+ KNOWLEDGE TechCorp was founded in 2020 and specializes in AI-powered solutions
22491
+ KNOWLEDGE https://example.com/company-handbook.pdf
22492
+ KNOWLEDGE https://example.com/product-documentation.pdf
22493
+ RULE Always be polite and professional
22494
+ \`\`\`
22495
+
22496
+ \`\`\`book
22497
+ Research Assistant
22498
+
22499
+ PERSONA You are a knowledgeable research assistant
22500
+ KNOWLEDGE Academic research requires careful citation and verification
22501
+ KNOWLEDGE https://example.com/research-guidelines.pdf
22502
+ ACTION Can help with literature reviews and data analysis
22503
+ STYLE Present information in clear, academic format
22504
+ \`\`\`
22505
+ `);
22506
+ }
22507
+ applyToAgentModelRequirements(requirements, content) {
22508
+ var _a;
22509
+ const trimmedContent = content.trim();
22510
+ if (!trimmedContent) {
22511
+ return requirements;
22512
+ }
22513
+ // Check if content is a URL (external knowledge source)
22514
+ if (this.isUrl(trimmedContent)) {
22515
+ // Store the URL for later async processing
22516
+ const updatedRequirements = {
22517
+ ...requirements,
22518
+ metadata: {
22519
+ ...requirements.metadata,
22520
+ knowledgeSources: [
22521
+ ...(((_a = requirements.metadata) === null || _a === void 0 ? void 0 : _a.knowledgeSources) || []),
22522
+ trimmedContent,
22523
+ ],
22524
+ },
22525
+ };
22526
+ // Add placeholder information about knowledge sources to system message
22527
+ const knowledgeInfo = `Knowledge Source URL: ${trimmedContent} (will be processed for retrieval during chat)`;
22528
+ return this.appendToSystemMessage(updatedRequirements, knowledgeInfo, '\n\n');
22529
+ }
22530
+ else {
22531
+ // Direct text knowledge - add to system message
22532
+ const knowledgeSection = `Knowledge: ${trimmedContent}`;
22533
+ return this.appendToSystemMessage(requirements, knowledgeSection, '\n\n');
22534
+ }
22535
+ }
22536
+ /**
22537
+ * Check if content is a URL
22538
+ */
22539
+ isUrl(content) {
22540
+ try {
22541
+ new URL(content);
22542
+ return true;
22543
+ }
22544
+ catch (_a) {
22545
+ return false;
22546
+ }
22547
+ }
22548
+ }
22549
+ /**
22550
+ * Note: [💞] Ignore a discrepancy between file name and entity name
22551
+ */
22552
+
22553
+ /**
22554
+ * MEMORY commitment definition
22555
+ *
22556
+ * The MEMORY commitment is similar to KNOWLEDGE but has a focus on remembering past
22557
+ * interactions and user preferences. It helps the agent maintain context about the
22558
+ * user's history, preferences, and previous conversations.
22559
+ *
22560
+ * Example usage in agent source:
22561
+ *
22562
+ * ```book
22563
+ * MEMORY User prefers detailed technical explanations
22564
+ * MEMORY Previously worked on React projects
22565
+ * MEMORY Timezone: UTC-5 (Eastern Time)
22566
+ * ```
22567
+ *
22568
+ * @private [🪔] Maybe export the commitments through some package
22569
+ */
22570
+ class MemoryCommitmentDefinition extends BaseCommitmentDefinition {
22571
+ constructor(type = 'MEMORY') {
22572
+ super(type);
22573
+ }
22574
+ /**
22575
+ * Short one-line description of MEMORY.
22576
+ */
22577
+ get description() {
22578
+ return 'Remember past interactions and user **preferences** for personalized responses.';
22579
+ }
22580
+ /**
22581
+ * Markdown documentation for MEMORY commitment.
22582
+ */
22583
+ get documentation() {
22584
+ return spaceTrim.spaceTrim(`
22585
+ # ${this.type}
22586
+
22587
+ Similar to KNOWLEDGE but focuses on remembering past interactions and user preferences. This commitment helps the agent maintain context about the user's history, preferences, and previous conversations.
22588
+
22589
+ ## Key aspects
22590
+
22591
+ - Both terms work identically and can be used interchangeably.
22592
+ - Focuses on user-specific information and interaction history.
22593
+ - Helps personalize responses based on past interactions.
22594
+ - Maintains continuity across conversations.
22595
+
22596
+ ## Differences from KNOWLEDGE
22597
+
22598
+ - \`KNOWLEDGE\` is for domain expertise and factual information
22599
+ - \`MEMORY\` is for user-specific context and preferences
22600
+ - \`MEMORY\` creates more personalized interactions
22601
+ - \`MEMORY\` often includes temporal or preference-based information
22602
+
22603
+ ## Examples
22604
+
22605
+ \`\`\`book
22606
+ Personal Assistant
22607
+
22608
+ PERSONA You are a personal productivity assistant
22609
+ MEMORY User is a software developer working in JavaScript/React
22610
+ MEMORY User prefers morning work sessions and afternoon meetings
22611
+ MEMORY Previously helped with project planning for mobile apps
22612
+ MEMORY User timezone: UTC-8 (Pacific Time)
22613
+ GOAL Help optimize daily productivity and workflow
22614
+ \`\`\`
22615
+
22616
+ \`\`\`book
22617
+ Learning Companion
22618
+
22619
+ PERSONA You are an educational companion for programming students
22620
+ MEMORY Student is learning Python as their first programming language
22621
+ MEMORY Previous topics covered: variables, loops, functions
22622
+ MEMORY Student learns best with practical examples and exercises
22623
+ MEMORY Last session: working on list comprehensions
22624
+ GOAL Provide progressive learning experiences tailored to student's pace
22625
+ \`\`\`
22626
+
22627
+ \`\`\`book
22628
+ Customer Support Agent
22629
+
22630
+ PERSONA You are a customer support representative
22631
+ MEMORY Customer has premium subscription since 2023
22632
+ MEMORY Previous issue: billing question resolved last month
22633
+ MEMORY Customer prefers email communication over phone calls
22634
+ MEMORY Account shows frequent use of advanced features
22635
+ GOAL Provide personalized support based on customer history
22636
+ \`\`\`
22637
+ `);
22638
+ }
22639
+ applyToAgentModelRequirements(requirements, content) {
22640
+ const trimmedContent = content.trim();
22641
+ if (!trimmedContent) {
22642
+ return requirements;
22643
+ }
22644
+ // Create memory section for system message
22645
+ const memorySection = `Memory: ${trimmedContent}`;
22646
+ // Memory information is contextual and should be included in the system message
22647
+ return this.appendToSystemMessage(requirements, memorySection, '\n\n');
22648
+ }
22649
+ }
22650
+ /**
22651
+ * Note: [💞] Ignore a discrepancy between file name and entity name
22652
+ */
22653
+
22654
+ /**
22655
+ * MESSAGE commitment definition
22656
+ *
22657
+ * The MESSAGE commitment contains 1:1 text of the message which AI assistant already
22658
+ * sent during the conversation. Later messages are later in the conversation.
22659
+ * It is similar to EXAMPLE but it is not example, it is the real message which
22660
+ * AI assistant already sent.
22661
+ *
22662
+ * Example usage in agent source:
22663
+ *
22664
+ * ```book
22665
+ * MESSAGE Hello! How can I help you today?
22666
+ * MESSAGE I understand you're looking for information about our services.
22667
+ * MESSAGE Based on your requirements, I'd recommend our premium package.
22668
+ * ```
22669
+ *
22670
+ * @private [🪔] Maybe export the commitments through some package
22671
+ */
22672
+ class MessageCommitmentDefinition extends BaseCommitmentDefinition {
22673
+ constructor(type = 'MESSAGE') {
22674
+ super(type);
22675
+ }
22676
+ /**
22677
+ * Short one-line description of MESSAGE.
22678
+ */
22679
+ get description() {
22680
+ return 'Include actual **messages** the AI assistant has sent during conversation history.';
22681
+ }
22682
+ /**
22683
+ * Markdown documentation for MESSAGE commitment.
22684
+ */
22685
+ get documentation() {
22686
+ return spaceTrim.spaceTrim(`
22687
+ # ${this.type}
22688
+
22689
+ Contains 1:1 text of the message which AI assistant already sent during the conversation. Later messages are later in the conversation. It is similar to EXAMPLE but it is not example, it is the real message which AI assistant already sent.
22690
+
22691
+ ## Key aspects
22692
+
22693
+ - Multiple \`MESSAGE\` and \`MESSAGES\` commitments represent the conversation timeline.
22694
+ - Both terms work identically and can be used interchangeably.
22695
+ - Later messages are later in the conversation chronologically.
22696
+ - Contains actual historical messages, not examples or templates.
22697
+ - Helps maintain conversation continuity and context.
22698
+
22699
+ ## Differences from EXAMPLE
22700
+
22701
+ - \`EXAMPLE\` shows hypothetical or template responses
22702
+ - \`MESSAGE\`/\`MESSAGES\` contains actual historical conversation content
22703
+ - \`MESSAGE\`/\`MESSAGES\` preserves the exact conversation flow
22704
+ - \`MESSAGE\`/\`MESSAGES\` helps with context awareness and consistency
22705
+
22706
+ ## Use cases
22707
+
22708
+ - Maintaining conversation history context
22709
+ - Ensuring consistent tone and style across messages
22710
+ - Referencing previous responses in ongoing conversations
22711
+ - Building upon previously established context
22712
+
22713
+ ## Examples
22714
+
22715
+ \`\`\`book
22716
+ Customer Support Continuation
22717
+
22718
+ PERSONA You are a helpful customer support agent
22719
+ MESSAGE Hello! How can I help you today?
22720
+ MESSAGE I understand you're experiencing issues with your account login.
22721
+ MESSAGE I've sent you a password reset link to your email address.
22722
+ MESSAGE Is there anything else I can help you with regarding your account?
22723
+ GOAL Continue providing consistent support based on conversation history
22724
+ \`\`\`
22725
+
22726
+ \`\`\`book
22727
+ Technical Discussion
22728
+
22729
+ PERSONA You are a software development mentor
22730
+ MESSAGE Let's start by reviewing the React component structure you shared.
22731
+ MESSAGE I notice you're using class components - have you considered hooks?
22732
+ MESSAGE Here's how you could refactor that using the useState hook.
22733
+ MESSAGE Great question about performance! Let me explain React's rendering cycle.
22734
+ KNOWLEDGE React hooks were introduced in version 16.8
22735
+ \`\`\`
22736
+
22737
+ \`\`\`book
22738
+ Educational Session
22739
+
22740
+ PERSONA You are a mathematics tutor
22741
+ MESSAGE Today we'll work on solving quadratic equations.
22742
+ MESSAGE Let's start with the basic form: ax² + bx + c = 0
22743
+ MESSAGE Remember, we can use the quadratic formula or factoring.
22744
+ MESSAGE You did great with that first problem! Let's try a more complex one.
22745
+ GOAL Build upon previous explanations for deeper understanding
22746
+ \`\`\`
22747
+ `);
22748
+ }
22749
+ applyToAgentModelRequirements(requirements, content) {
22750
+ const trimmedContent = content.trim();
22751
+ if (!trimmedContent) {
22752
+ return requirements;
22753
+ }
22754
+ // Create message section for system message
22755
+ const messageSection = `Previous Message: ${trimmedContent}`;
22756
+ // Messages represent conversation history and should be included for context
22757
+ return this.appendToSystemMessage(requirements, messageSection, '\n\n');
22758
+ }
22759
+ }
22760
+ /**
22761
+ * Note: [💞] Ignore a discrepancy between file name and entity name
22762
+ */
22763
+
22764
+ /**
22765
+ * META commitment definition
22766
+ *
22767
+ * The META commitment handles all meta-information about the agent such as:
22768
+ * - META IMAGE: Sets the agent's avatar/profile image URL
22769
+ * - META LINK: Provides profile/source links for the person the agent models
22770
+ * - META TITLE: Sets the agent's display title
22771
+ * - META DESCRIPTION: Sets the agent's description
22772
+ * - META [ANYTHING]: Any other meta information in uppercase format
22773
+ *
22774
+ * These commitments are special because they don't affect the system message,
22775
+ * but are handled separately in the parsing logic for profile display.
22776
+ *
22777
+ * Example usage in agent source:
22778
+ *
22779
+ * ```book
22780
+ * META IMAGE https://example.com/avatar.jpg
22781
+ * META LINK https://twitter.com/username
22782
+ * META TITLE Professional Assistant
22783
+ * META DESCRIPTION An AI assistant specialized in business tasks
22784
+ * META AUTHOR John Doe
22785
+ * META VERSION 1.0
22786
+ * ```
22787
+ *
22788
+ * @private [🪔] Maybe export the commitments through some package
22789
+ */
22790
+ class MetaCommitmentDefinition extends BaseCommitmentDefinition {
22791
+ constructor() {
22792
+ super('META');
22793
+ }
22794
+ /**
22795
+ * Short one-line description of META commitments.
22796
+ */
22797
+ get description() {
22798
+ return 'Set meta-information about the agent (IMAGE, LINK, TITLE, DESCRIPTION, etc.).';
22799
+ }
22800
+ /**
22801
+ * Markdown documentation for META commitment.
22802
+ */
22803
+ get documentation() {
22804
+ return spaceTrim.spaceTrim(`
22805
+ # META
22806
+
22807
+ Sets meta-information about the agent that is used for display and attribution purposes.
22808
+
22809
+ ## Supported META types
22810
+
22811
+ - **META IMAGE** - Sets the agent's avatar/profile image URL
22812
+ - **META LINK** - Provides profile/source links for the person the agent models
22813
+ - **META TITLE** - Sets the agent's display title
22814
+ - **META DESCRIPTION** - Sets the agent's description
22815
+ - **META [ANYTHING]** - Any other meta information in uppercase format
22816
+
22817
+ ## Key aspects
22818
+
22819
+ - Does not modify the agent's behavior or responses
22820
+ - Used for visual representation and attribution in user interfaces
22821
+ - Multiple META commitments of different types can be used
22822
+ - Multiple META LINK commitments can be used for different social profiles
22823
+ - If multiple META commitments of the same type are specified, the last one takes precedence (except for LINK)
22824
+
22825
+ ## Examples
22826
+
22827
+ ### Basic meta information
22828
+
22829
+ \`\`\`book
22830
+ Professional Assistant
22831
+
22832
+ META IMAGE https://example.com/professional-avatar.jpg
22833
+ META TITLE Senior Business Consultant
22834
+ META DESCRIPTION Specialized in strategic planning and project management
22835
+ META LINK https://linkedin.com/in/professional
22836
+ \`\`\`
22837
+
22838
+ ### Multiple links and custom meta
22839
+
22840
+ \`\`\`book
22841
+ Open Source Developer
22842
+
22843
+ META IMAGE /assets/dev-avatar.png
22844
+ META LINK https://github.com/developer
22845
+ META LINK https://twitter.com/devhandle
22846
+ META AUTHOR Jane Smith
22847
+ META VERSION 2.1
22848
+ META LICENSE MIT
22849
+ \`\`\`
22850
+
22851
+ ### Creative assistant
22852
+
22853
+ \`\`\`book
22854
+ Creative Helper
22855
+
22856
+ META IMAGE https://example.com/creative-bot.jpg
22857
+ META TITLE Creative Writing Assistant
22858
+ META DESCRIPTION Helps with brainstorming, storytelling, and creative projects
22859
+ META INSPIRATION Books, movies, and real-world experiences
22860
+ \`\`\`
22861
+ `);
22862
+ }
22863
+ applyToAgentModelRequirements(requirements, content) {
22864
+ // META commitments don't modify the system message or model requirements
22865
+ // They are handled separately in the parsing logic for meta information extraction
22866
+ // This method exists for consistency with the CommitmentDefinition interface
22867
+ return requirements;
22868
+ }
22869
+ /**
22870
+ * Extracts meta information from the content based on the meta type
22871
+ * This is used by the parsing logic
22872
+ */
22873
+ extractMetaValue(metaType, content) {
22874
+ const trimmedContent = content.trim();
22875
+ return trimmedContent || null;
22876
+ }
22877
+ /**
22878
+ * Validates if the provided content is a valid URL (for IMAGE and LINK types)
22879
+ */
22880
+ isValidUrl(content) {
22881
+ try {
22882
+ new URL(content.trim());
22883
+ return true;
22884
+ }
22885
+ catch (_a) {
22886
+ return false;
22887
+ }
22888
+ }
22889
+ /**
22890
+ * Checks if this is a known meta type
22891
+ */
22892
+ isKnownMetaType(metaType) {
22893
+ const knownTypes = ['IMAGE', 'LINK', 'TITLE', 'DESCRIPTION', 'AUTHOR', 'VERSION', 'LICENSE'];
22894
+ return knownTypes.includes(metaType.toUpperCase());
22895
+ }
22896
+ }
22897
+ /**
22898
+ * Note: [💞] Ignore a discrepancy between file name and entity name
22899
+ */
22900
+
22901
+ /**
22902
+ * MODEL commitment definition
22903
+ *
22904
+ * The MODEL commitment specifies which AI model to use and can also set
22905
+ * model-specific parameters like temperature, topP, topK, and maxTokens.
22906
+ *
22907
+ * Supports multiple syntax variations:
22908
+ *
22909
+ * Single-line format:
22910
+ * ```book
22911
+ * MODEL gpt-4
22912
+ * MODEL claude-3-opus temperature=0.3
22913
+ * MODEL gpt-3.5-turbo temperature=0.8 topP=0.9
22914
+ * ```
22915
+ *
22916
+ * Multi-line named parameter format:
22917
+ * ```book
22918
+ * MODEL NAME gpt-4
22919
+ * MODEL TEMPERATURE 0.7
22920
+ * MODEL TOP_P 0.9
22921
+ * MODEL MAX_TOKENS 2048
22922
+ * ```
22923
+ *
22924
+ * @private [🪔] Maybe export the commitments through some package
22925
+ */
22926
+ class ModelCommitmentDefinition extends BaseCommitmentDefinition {
22927
+ constructor(type = 'MODEL') {
22928
+ super(type);
22929
+ }
22930
+ /**
22931
+ * Short one-line description of MODEL.
22932
+ */
22933
+ get description() {
22934
+ return 'Enforce AI model requirements including name and technical parameters.';
22935
+ }
22936
+ /**
22937
+ * Markdown documentation for MODEL commitment.
22938
+ */
22939
+ get documentation() {
22940
+ return spaceTrim.spaceTrim(`
22941
+ # ${this.type}
22942
+
22943
+ Enforces technical parameters for the AI model, ensuring consistent behavior across different execution environments.
22944
+
22945
+ ## Key aspects
22946
+
22947
+ - When no \`MODEL\` commitment is specified, the best model requirement is picked automatically based on the agent \`PERSONA\`, \`KNOWLEDGE\`, \`TOOLS\` and other commitments
22948
+ - Multiple \`MODEL\` commitments can be used to specify different parameters
22949
+ - Both \`MODEL\` and \`MODELS\` terms work identically and can be used interchangeably
22950
+ - Parameters control the randomness, creativity, and technical aspects of model responses
22951
+
22952
+ ## Syntax variations
22953
+
22954
+ ### Single-line format (legacy support)
22955
+ \`\`\`book
22956
+ MODEL gpt-4
22957
+ MODEL claude-3-opus temperature=0.3
22958
+ MODEL gpt-3.5-turbo temperature=0.8 topP=0.9
22959
+ \`\`\`
22960
+
22961
+ ### Multi-line named parameter format (recommended)
22962
+ \`\`\`book
22963
+ MODEL NAME gpt-4
22964
+ MODEL TEMPERATURE 0.7
22965
+ MODEL TOP_P 0.9
22966
+ MODEL MAX_TOKENS 2048
22967
+ \`\`\`
22968
+
22969
+ ## Supported parameters
22970
+
22971
+ - \`NAME\`: The specific model to use (e.g., 'gpt-4', 'claude-3-opus')
22972
+ - \`TEMPERATURE\`: Controls randomness (0.0 = deterministic, 1.0+ = creative)
22973
+ - \`TOP_P\`: Nucleus sampling parameter for controlling diversity
22974
+ - \`TOP_K\`: Top-k sampling parameter for limiting vocabulary
22975
+ - \`MAX_TOKENS\`: Maximum number of tokens the model can generate
22976
+
22977
+ ## Examples
22978
+
22979
+ ### Precise deterministic assistant
22980
+ \`\`\`book
22981
+ Precise Assistant
22982
+
22983
+ PERSONA You are a precise and accurate assistant
22984
+ MODEL NAME gpt-4
22985
+ MODEL TEMPERATURE 0.1
22986
+ MODEL MAX_TOKENS 1024
22987
+ RULE Always provide factual information
22988
+ \`\`\`
22989
+
22990
+ ### Creative writing assistant
22991
+ \`\`\`book
22992
+ Creative Writer
22993
+
22994
+ PERSONA You are a creative writing assistant
22995
+ MODEL NAME claude-3-opus
22996
+ MODEL TEMPERATURE 0.8
22997
+ MODEL TOP_P 0.9
22998
+ MODEL MAX_TOKENS 2048
22999
+ STYLE Be imaginative and expressive
23000
+ ACTION Can help with storytelling and character development
23001
+ \`\`\`
23002
+
23003
+ ### Balanced conversational agent
23004
+ \`\`\`book
23005
+ Balanced Assistant
23006
+
23007
+ PERSONA You are a helpful and balanced assistant
23008
+ MODEL NAME gpt-4
23009
+ MODEL TEMPERATURE 0.7
23010
+ MODEL TOP_P 0.95
23011
+ MODEL TOP_K 40
23012
+ MODEL MAX_TOKENS 1500
23013
+ \`\`\`
23014
+ `);
23015
+ }
23016
+ applyToAgentModelRequirements(requirements, content) {
23017
+ var _a;
23018
+ const trimmedContent = content.trim();
23019
+ if (!trimmedContent) {
23020
+ return requirements;
23021
+ }
23022
+ const parts = trimmedContent.split(/\s+/);
23023
+ const firstPart = (_a = parts[0]) === null || _a === void 0 ? void 0 : _a.toUpperCase();
23024
+ // Check if this is the new named parameter format
23025
+ if (this.isNamedParameter(firstPart)) {
23026
+ return this.parseNamedParameter(requirements, firstPart, parts.slice(1));
23027
+ }
23028
+ else {
23029
+ // Legacy single-line format: "MODEL gpt-4 temperature=0.3 topP=0.9"
23030
+ return this.parseLegacyFormat(requirements, parts);
23031
+ }
23032
+ }
23033
+ /**
23034
+ * Check if the first part is a known named parameter
23035
+ */
23036
+ isNamedParameter(part) {
23037
+ if (!part)
23038
+ return false;
23039
+ const knownParams = ['NAME', 'TEMPERATURE', 'TOP_P', 'TOP_K', 'MAX_TOKENS'];
23040
+ return knownParams.includes(part);
23041
+ }
23042
+ /**
23043
+ * Parse the new named parameter format: "MODEL TEMPERATURE 0.7"
23044
+ */
23045
+ parseNamedParameter(requirements, parameterName, valueParts) {
23046
+ const value = valueParts.join(' ').trim();
23047
+ if (!value) {
23048
+ return requirements;
23049
+ }
23050
+ const result = { ...requirements };
23051
+ switch (parameterName) {
23052
+ case 'NAME':
23053
+ result.modelName = value;
23054
+ break;
23055
+ case 'TEMPERATURE': {
23056
+ const temperature = parseFloat(value);
23057
+ if (!isNaN(temperature)) {
23058
+ result.temperature = temperature;
23059
+ }
23060
+ break;
23061
+ }
23062
+ case 'TOP_P': {
23063
+ const topP = parseFloat(value);
23064
+ if (!isNaN(topP)) {
23065
+ result.topP = topP;
23066
+ }
23067
+ break;
23068
+ }
23069
+ case 'TOP_K': {
23070
+ const topK = parseFloat(value);
23071
+ if (!isNaN(topK)) {
23072
+ result.topK = Math.round(topK);
23073
+ }
23074
+ break;
23075
+ }
23076
+ case 'MAX_TOKENS': {
23077
+ const maxTokens = parseFloat(value);
23078
+ if (!isNaN(maxTokens)) {
23079
+ result.maxTokens = Math.round(maxTokens);
23080
+ }
23081
+ break;
23082
+ }
23083
+ }
23084
+ return result;
23085
+ }
23086
+ /**
23087
+ * Parse the legacy format: "MODEL gpt-4 temperature=0.3 topP=0.9"
23088
+ */
23089
+ parseLegacyFormat(requirements, parts) {
23090
+ const modelName = parts[0];
23091
+ if (!modelName) {
23092
+ return requirements;
23093
+ }
23094
+ // Start with the model name
23095
+ const result = {
23096
+ ...requirements,
23097
+ modelName,
23098
+ };
23099
+ // Parse additional key=value parameters
23100
+ for (let i = 1; i < parts.length; i++) {
23101
+ const param = parts[i];
23102
+ if (param && param.includes('=')) {
23103
+ const [key, value] = param.split('=');
23104
+ if (key && value) {
23105
+ const numValue = parseFloat(value);
23106
+ if (!isNaN(numValue)) {
23107
+ switch (key.toLowerCase()) {
23108
+ case 'temperature':
23109
+ result.temperature = numValue;
23110
+ break;
23111
+ case 'topp':
23112
+ case 'top_p':
23113
+ result.topP = numValue;
23114
+ break;
23115
+ case 'topk':
23116
+ case 'top_k':
23117
+ result.topK = Math.round(numValue);
23118
+ break;
23119
+ case 'max_tokens':
23120
+ case 'maxTokens':
23121
+ result.maxTokens = Math.round(numValue);
23122
+ break;
23123
+ }
23124
+ }
23125
+ }
23126
+ }
23127
+ }
23128
+ return result;
23129
+ }
23130
+ }
23131
+ /**
23132
+ * Note: [💞] Ignore a discrepancy between file name and entity name
23133
+ */
23134
+
23135
+ /**
23136
+ * NOTE commitment definition
23137
+ *
23138
+ * The NOTE commitment is used to add comments to the agent source without making any changes
23139
+ * to the system message or agent model requirements. It serves as a documentation mechanism
23140
+ * for developers to add explanatory comments, reminders, or annotations directly in the agent source.
23141
+ *
23142
+ * Key features:
23143
+ * - Makes no changes to the system message
23144
+ * - Makes no changes to agent model requirements
23145
+ * - Content is preserved in metadata.NOTE for debugging and inspection
23146
+ * - Multiple NOTE commitments are aggregated together
23147
+ * - Comments (# NOTE) are removed from the final system message
23148
+ *
23149
+ * Example usage in agent source:
23150
+ *
23151
+ * ```book
23152
+ * NOTE This agent was designed for customer support scenarios
23153
+ * NOTE Remember to update the knowledge base monthly
23154
+ * NOTE Performance optimized for quick response times
23155
+ * ```
23156
+ *
23157
+ * The above notes will be stored in metadata but won't affect the agent's behavior.
23158
+ *
23159
+ * @private [🪔] Maybe export the commitments through some package
23160
+ */
23161
+ class NoteCommitmentDefinition extends BaseCommitmentDefinition {
23162
+ constructor(type = 'NOTE') {
23163
+ super(type);
23164
+ }
23165
+ /**
23166
+ * Short one-line description of NOTE.
23167
+ */
23168
+ get description() {
23169
+ return 'Add developer-facing notes without changing behavior or output.';
23170
+ }
23171
+ /**
23172
+ * Markdown documentation for NOTE commitment.
23173
+ */
23174
+ get documentation() {
23175
+ return spaceTrim.spaceTrim(`
23176
+ # ${this.type}
23177
+
23178
+ Adds comments for documentation without changing agent behavior.
23179
+
23180
+ ## Key aspects
23181
+
23182
+ - Does not modify the agent's behavior or responses.
23183
+ - Multiple \`NOTE\`, \`NOTES\`, \`COMMENT\`, and \`NONCE\` commitments are aggregated for debugging.
23184
+ - All four terms work identically and can be used interchangeably.
23185
+ - Useful for documenting design decisions and reminders.
23186
+ - Content is preserved in metadata for inspection.
23187
+
23188
+ ## Examples
23189
+
23190
+ \`\`\`book
23191
+ Customer Support Bot
23192
+
23193
+ NOTE This agent was designed for customer support scenarios
23194
+ COMMENT Remember to update the knowledge base monthly
23195
+ PERSONA You are a helpful customer support representative
23196
+ KNOWLEDGE Company policies and procedures
23197
+ RULE Always be polite and professional
23198
+ \`\`\`
23199
+
23200
+ \`\`\`book
23201
+ Research Assistant
23202
+
23203
+ NONCE Performance optimized for quick response times
23204
+ NOTE Uses RAG for accessing latest research papers
23205
+ PERSONA You are a knowledgeable research assistant
23206
+ ACTION Can help with literature reviews and citations
23207
+ STYLE Present information in academic format
23208
+ \`\`\`
23209
+ `);
23210
+ }
23211
+ applyToAgentModelRequirements(requirements, content) {
23212
+ var _a;
23213
+ // The NOTE commitment makes no changes to the system message or model requirements
23214
+ // It only stores the note content in metadata for documentation purposes
23215
+ const trimmedContent = content.trim();
23216
+ if (!trimmedContent) {
23217
+ return requirements;
23218
+ }
23219
+ // Get existing note content from metadata
23220
+ const existingNoteContent = ((_a = requirements.metadata) === null || _a === void 0 ? void 0 : _a.NOTE) || '';
23221
+ // Merge the new content with existing note content
23222
+ // When multiple NOTE commitments exist, they are aggregated together
23223
+ const mergedNoteContent = existingNoteContent ? `${existingNoteContent}\n${trimmedContent}` : trimmedContent;
23224
+ // Store the merged note content in metadata for debugging and inspection
23225
+ const updatedMetadata = {
23226
+ ...requirements.metadata,
23227
+ NOTE: mergedNoteContent,
23228
+ };
23229
+ // Return requirements with updated metadata but no changes to system message
23230
+ return {
23231
+ ...requirements,
23232
+ metadata: updatedMetadata,
23233
+ };
23234
+ }
23235
+ }
23236
+ /**
23237
+ * [💞] Ignore a discrepancy between file name and entity name
23238
+ */
23239
+
23240
+ /**
23241
+ * PERSONA commitment definition
23242
+ *
23243
+ * The PERSONA commitment modifies the agent's personality and character in the system message.
23244
+ * It defines who the agent is, their background, expertise, and personality traits.
23245
+ *
23246
+ * Key features:
23247
+ * - Multiple PERSONA commitments are automatically merged into one
23248
+ * - Content is placed at the beginning of the system message
23249
+ * - Original content with comments is preserved in metadata.PERSONA
23250
+ * - Comments (# PERSONA) are removed from the final system message
23251
+ *
23252
+ * Example usage in agent source:
23253
+ *
23254
+ * ```book
23255
+ * PERSONA You are a helpful programming assistant with expertise in TypeScript and React
23256
+ * PERSONA You have deep knowledge of modern web development practices
23257
+ * ```
23258
+ *
23259
+ * The above will be merged into a single persona section at the beginning of the system message.
23260
+ *
23261
+ * @private [🪔] Maybe export the commitments through some package
23262
+ */
23263
+ class PersonaCommitmentDefinition extends BaseCommitmentDefinition {
23264
+ constructor(type = 'PERSONA') {
23265
+ super(type);
23266
+ }
23267
+ /**
23268
+ * Short one-line description of PERSONA.
23269
+ */
23270
+ get description() {
23271
+ return 'Define who the agent is: background, expertise, and personality.';
23272
+ }
23273
+ /**
23274
+ * Markdown documentation for PERSONA commitment.
23275
+ */
23276
+ get documentation() {
23277
+ return spaceTrim.spaceTrim(`
23278
+ # ${this.type}
23279
+
23280
+ Defines who the agent is, their background, expertise, and personality traits.
23281
+
23282
+ ## Key aspects
23283
+
23284
+ - Multiple \`PERSONA\` and \`PERSONAE\` commitments are merged together.
23285
+ - Both terms work identically and can be used interchangeably.
23286
+ - If they are in conflict, the last one takes precedence.
23287
+ - You can write persona content in multiple lines.
23288
+
23289
+ ## Examples
23290
+
23291
+ \`\`\`book
23292
+ Programming Assistant
23293
+
23294
+ PERSONA You are a helpful programming assistant with expertise in TypeScript and React
23295
+ PERSONA You have deep knowledge of modern web development practices
23296
+ \`\`\`
23297
+ `);
23298
+ }
23299
+ applyToAgentModelRequirements(requirements, content) {
23300
+ var _a, _b;
23301
+ // The PERSONA commitment aggregates all persona content and places it at the beginning
23302
+ const trimmedContent = content.trim();
23303
+ if (!trimmedContent) {
23304
+ return requirements;
23305
+ }
23306
+ // Get existing persona content from metadata
23307
+ const existingPersonaContent = ((_a = requirements.metadata) === null || _a === void 0 ? void 0 : _a.PERSONA) || '';
23308
+ // Merge the new content with existing persona content
23309
+ // When multiple PERSONA commitments exist, they are merged into one
23310
+ const mergedPersonaContent = existingPersonaContent
23311
+ ? `${existingPersonaContent}\n${trimmedContent}`
23312
+ : trimmedContent;
23313
+ // Store the merged persona content in metadata for debugging and inspection
23314
+ const updatedMetadata = {
23315
+ ...requirements.metadata,
23316
+ PERSONA: mergedPersonaContent,
23317
+ };
23318
+ // Get the agent name from metadata (which should contain the first line of agent source)
23319
+ // If not available, extract from current system message as fallback
23320
+ let agentName = (_b = requirements.metadata) === null || _b === void 0 ? void 0 : _b.agentName;
23321
+ if (!agentName) {
23322
+ // Fallback: extract from current system message
23323
+ const currentMessage = requirements.systemMessage.trim();
23324
+ const basicFormatMatch = currentMessage.match(/^You are (.+)$/);
23325
+ if (basicFormatMatch && basicFormatMatch[1]) {
23326
+ agentName = basicFormatMatch[1];
23327
+ }
23328
+ else {
23329
+ agentName = 'AI Agent'; // Final fallback
23330
+ }
23331
+ }
23332
+ // Remove any existing persona content from the system message
23333
+ // (this handles the case where we're processing multiple PERSONA commitments)
23334
+ const currentMessage = requirements.systemMessage.trim();
23335
+ let cleanedMessage = currentMessage;
23336
+ // Check if current message starts with persona content or is just the basic format
23337
+ const basicFormatRegex = /^You are .+$/;
23338
+ const isBasicFormat = basicFormatRegex.test(currentMessage) && !currentMessage.includes('\n');
23339
+ if (isBasicFormat) {
23340
+ // Replace the basic format entirely
23341
+ cleanedMessage = '';
23342
+ }
23343
+ else if (currentMessage.startsWith('# PERSONA')) {
23344
+ // Remove existing persona section by finding where it ends
23345
+ const lines = currentMessage.split('\n');
23346
+ let personaEndIndex = lines.length;
23347
+ // Find the end of the PERSONA section (next comment or end of message)
23348
+ for (let i = 1; i < lines.length; i++) {
23349
+ const line = lines[i].trim();
23350
+ if (line.startsWith('#') && !line.startsWith('# PERSONA')) {
23351
+ personaEndIndex = i;
23352
+ break;
23353
+ }
23354
+ }
23355
+ // Keep everything after the PERSONA section
23356
+ cleanedMessage = lines.slice(personaEndIndex).join('\n').trim();
23357
+ }
23358
+ // Create new system message with persona at the beginning
23359
+ // Format: "You are {agentName}\n{personaContent}"
23360
+ // The # PERSONA comment will be removed later by removeCommentsFromSystemMessage
23361
+ const personaSection = `# PERSONA\nYou are ${agentName}\n${mergedPersonaContent}`; // <- TODO: Use spaceTrim
23362
+ const newSystemMessage = cleanedMessage ? `${personaSection}\n\n${cleanedMessage}` : personaSection;
23363
+ return {
23364
+ ...requirements,
23365
+ systemMessage: newSystemMessage,
23366
+ metadata: updatedMetadata,
23367
+ };
23368
+ }
23369
+ }
23370
+ /**
23371
+ * Note: [💞] Ignore a discrepancy between file name and entity name
23372
+ */
23373
+
23374
+ /**
23375
+ * RULE commitment definition
23376
+ *
23377
+ * The RULE/RULES commitment adds behavioral constraints and guidelines that the agent must follow.
23378
+ * These are specific instructions about what the agent should or shouldn't do.
23379
+ *
23380
+ * Example usage in agent source:
23381
+ *
23382
+ * ```book
23383
+ * RULE Always ask for clarification if the user's request is ambiguous
23384
+ * RULES Never provide medical advice, always refer to healthcare professionals
23385
+ * ```
23386
+ *
23387
+ * @private [🪔] Maybe export the commitments through some package
23388
+ */
23389
+ class RuleCommitmentDefinition extends BaseCommitmentDefinition {
23390
+ constructor(type = 'RULE') {
23391
+ super(type);
23392
+ }
23393
+ /**
23394
+ * Short one-line description of RULE/RULES.
23395
+ */
23396
+ get description() {
23397
+ return 'Add behavioral rules the agent must follow.';
23398
+ }
23399
+ /**
23400
+ * Markdown documentation for RULE/RULES commitment.
23401
+ */
23402
+ get documentation() {
23403
+ return spaceTrim.spaceTrim(`
23404
+ # ${this.type}
23405
+
23406
+ Adds behavioral constraints and guidelines that the agent must follow.
23407
+
23408
+ ## Key aspects
23409
+
23410
+ - All rules are treated equally regardless of singular/plural form.
23411
+ - Rules define what the agent must or must not do.
23412
+
23413
+ ## Examples
23414
+
23415
+ \`\`\`book
23416
+ Customer Support Agent
23417
+
23418
+ PERSONA You are a helpful customer support representative
23419
+ RULE Always ask for clarification if the user's request is ambiguous
23420
+ RULE Be polite and professional in all interactions
23421
+ RULES Never provide medical or legal advice
23422
+ STYLE Maintain a friendly and helpful tone
23423
+ \`\`\`
23424
+
23425
+ \`\`\`book
23426
+ Educational Tutor
23427
+
23428
+ PERSONA You are a patient and knowledgeable tutor
23429
+ RULE Break down complex concepts into simple steps
23430
+ RULE Always encourage students and celebrate their progress
23431
+ RULE If you don't know something, admit it and suggest resources
23432
+ SAMPLE When explaining math: "Let's work through this step by step..."
23433
+ \`\`\`
23434
+ `);
23435
+ }
23436
+ applyToAgentModelRequirements(requirements, content) {
23437
+ const trimmedContent = content.trim();
23438
+ if (!trimmedContent) {
23439
+ return requirements;
23440
+ }
23441
+ // Add rule to the system message
23442
+ const ruleSection = `Rule: ${trimmedContent}`;
23443
+ return this.appendToSystemMessage(requirements, ruleSection, '\n\n');
23444
+ }
23445
+ }
23446
+ /**
23447
+ * Note: [💞] Ignore a discrepancy between file name and entity name
23448
+ */
23449
+
23450
+ /**
23451
+ * SAMPLE commitment definition
23452
+ *
23453
+ * The SAMPLE/EXAMPLE commitment provides examples of how the agent should respond
23454
+ * or behave in certain situations. These examples help guide the agent's responses.
23455
+ *
23456
+ * Example usage in agent source:
23457
+ *
23458
+ * ```book
23459
+ * SAMPLE When asked about pricing, respond: "Our basic plan starts at $10/month..."
23460
+ * EXAMPLE For code questions, always include working code snippets
23461
+ * ```
23462
+ *
23463
+ * @private [🪔] Maybe export the commitments through some package
23464
+ */
23465
+ class SampleCommitmentDefinition extends BaseCommitmentDefinition {
23466
+ constructor(type = 'SAMPLE') {
23467
+ super(type);
23468
+ }
23469
+ /**
23470
+ * Short one-line description of SAMPLE/EXAMPLE.
23471
+ */
23472
+ get description() {
23473
+ return 'Provide example responses to guide behavior.';
23474
+ }
23475
+ /**
23476
+ * Markdown documentation for SAMPLE/EXAMPLE commitment.
23477
+ */
23478
+ get documentation() {
23479
+ return spaceTrim.spaceTrim(`
23480
+ # ${this.type}
23481
+
23482
+ Provides examples of how the agent should respond or behave in certain situations.
23483
+
23484
+ ## Key aspects
23485
+
23486
+ - Both terms work identically and can be used interchangeably.
23487
+ - Examples help guide the agent's response patterns and style.
23488
+
23489
+ ## Examples
23490
+
23491
+ \`\`\`book
23492
+ Sales Assistant
23493
+
23494
+ PERSONA You are a knowledgeable sales representative
23495
+ SAMPLE When asked about pricing, respond: "Our basic plan starts at $10/month..."
23496
+ SAMPLE For feature comparisons, create a clear comparison table
23497
+ RULE Always be honest about limitations
23498
+ \`\`\`
23499
+
23500
+ \`\`\`book
23501
+ Code Reviewer
23502
+
23503
+ PERSONA You are an experienced software engineer
23504
+ EXAMPLE For code questions, always include working code snippets
23505
+ EXAMPLE When suggesting improvements: "Here's a more efficient approach..."
23506
+ RULE Explain the reasoning behind your suggestions
23507
+ STYLE Be constructive and encouraging in feedback
23508
+ \`\`\`
23509
+ `);
23510
+ }
23511
+ applyToAgentModelRequirements(requirements, content) {
23512
+ const trimmedContent = content.trim();
23513
+ if (!trimmedContent) {
23514
+ return requirements;
23515
+ }
23516
+ // Add example to the system message
23517
+ const exampleSection = `Example: ${trimmedContent}`;
23518
+ return this.appendToSystemMessage(requirements, exampleSection, '\n\n');
23519
+ }
23520
+ }
23521
+ /**
23522
+ * Note: [💞] Ignore a discrepancy between file name and entity name
23523
+ */
23524
+
23525
+ /**
23526
+ * SCENARIO commitment definition
23527
+ *
23528
+ * The SCENARIO commitment defines a specific situation or context in which the AI
23529
+ * assistant should operate. It helps to set the scene for the AI's responses.
23530
+ * Later scenarios are more important than earlier scenarios.
23531
+ *
23532
+ * Example usage in agent source:
23533
+ *
23534
+ * ```book
23535
+ * SCENARIO You are in a customer service call center during peak hours
23536
+ * SCENARIO The customer is frustrated and has been on hold for 20 minutes
23537
+ * SCENARIO This is the customer's third call about the same issue
23538
+ * ```
23539
+ *
23540
+ * @private [🪔] Maybe export the commitments through some package
23541
+ */
23542
+ class ScenarioCommitmentDefinition extends BaseCommitmentDefinition {
23543
+ constructor(type = 'SCENARIO') {
23544
+ super(type);
23545
+ }
23546
+ /**
23547
+ * Short one-line description of SCENARIO.
23548
+ */
23549
+ get description() {
23550
+ return 'Define specific **situations** or contexts for AI responses, with later scenarios having higher priority.';
23551
+ }
23552
+ /**
23553
+ * Markdown documentation for SCENARIO commitment.
23554
+ */
23555
+ get documentation() {
23556
+ return spaceTrim.spaceTrim(`
23557
+ # ${this.type}
23558
+
23559
+ Defines a specific situation or context in which the AI assistant should operate. It helps to set the scene for the AI's responses. Later scenarios are more important than earlier scenarios.
23560
+
23561
+ ## Key aspects
23562
+
23563
+ - Multiple \`SCENARIO\` and \`SCENARIOS\` commitments build upon each other.
23564
+ - Both terms work identically and can be used interchangeably.
23565
+ - Later scenarios have higher priority and can override earlier scenarios.
23566
+ - Provides situational context that influences response tone and content.
23567
+ - Helps establish the environment and circumstances for interactions.
23568
+
23569
+ ## Priority system
23570
+
23571
+ When multiple scenarios are defined, they are processed in order, with later scenarios taking precedence over earlier ones when there are conflicts.
23572
+
23573
+ ## Use cases
23574
+
23575
+ - Setting the physical or virtual environment
23576
+ - Establishing time constraints or urgency
23577
+ - Defining relationship dynamics or power structures
23578
+ - Creating emotional or situational context
23579
+
23580
+ ## Examples
23581
+
23582
+ \`\`\`book
23583
+ Emergency Response Operator
23584
+
23585
+ PERSONA You are an emergency response operator
23586
+ SCENARIO You are handling a 911 emergency call
23587
+ SCENARIO The caller is panicked and speaking rapidly
23588
+ SCENARIO Time is critical - every second counts
23589
+ GOAL Gather essential information quickly and dispatch appropriate help
23590
+ RULE Stay calm and speak clearly
23591
+ \`\`\`
23592
+
23593
+ \`\`\`book
23594
+ Sales Representative
23595
+
23596
+ PERSONA You are a software sales representative
23597
+ SCENARIO You are in the final meeting of a 6-month sales cycle
23598
+ SCENARIO The client has budget approval and decision-making authority
23599
+ SCENARIO Two competitors have also submitted proposals
23600
+ SCENARIO The client values long-term partnership over lowest price
23601
+ GOAL Close the deal while building trust for future business
23602
+ \`\`\`
23603
+
23604
+ \`\`\`book
23605
+ Medical Assistant
23606
+
23607
+ PERSONA You are a medical assistant in a busy clinic
23608
+ SCENARIO The waiting room is full and the doctor is running behind schedule
23609
+ SCENARIO Patients are becoming impatient and anxious
23610
+ SCENARIO You need to manage expectations while maintaining professionalism
23611
+ SCENARIO Some patients have been waiting over an hour
23612
+ GOAL Keep patients informed and calm while supporting efficient clinic flow
23613
+ RULE Never provide medical advice or diagnosis
23614
+ \`\`\`
23615
+
23616
+ \`\`\`book
23617
+ Technical Support Agent
23618
+
23619
+ PERSONA You are a technical support agent
23620
+ SCENARIO The customer is a small business owner during their busy season
23621
+ SCENARIO Their main business system has been down for 2 hours
23622
+ SCENARIO They are losing money every minute the system is offline
23623
+ SCENARIO This is their first experience with your company
23624
+ GOAL Resolve the issue quickly while creating a positive first impression
23625
+ \`\`\`
23626
+ `);
23627
+ }
23628
+ applyToAgentModelRequirements(requirements, content) {
23629
+ const trimmedContent = content.trim();
23630
+ if (!trimmedContent) {
23631
+ return requirements;
23632
+ }
23633
+ // Create scenario section for system message
23634
+ const scenarioSection = `Scenario: ${trimmedContent}`;
23635
+ // Scenarios provide important contextual information that affects behavior
23636
+ return this.appendToSystemMessage(requirements, scenarioSection, '\n\n');
23637
+ }
23638
+ }
23639
+ /**
23640
+ * Note: [💞] Ignore a discrepancy between file name and entity name
23641
+ */
23642
+
23643
+ /**
23644
+ * STYLE commitment definition
23645
+ *
23646
+ * The STYLE commitment defines how the agent should format and present its responses.
23647
+ * This includes tone, writing style, formatting preferences, and communication patterns.
23648
+ *
23649
+ * Example usage in agent source:
23650
+ *
23651
+ * ```book
23652
+ * STYLE Write in a professional but friendly tone, use bullet points for lists
23653
+ * STYLE Always provide code examples when explaining programming concepts
23654
+ * ```
23655
+ *
23656
+ * @private [🪔] Maybe export the commitments through some package
23657
+ */
23658
+ class StyleCommitmentDefinition extends BaseCommitmentDefinition {
23659
+ constructor(type = 'STYLE') {
23660
+ super(type);
23661
+ }
23662
+ /**
23663
+ * Short one-line description of STYLE.
23664
+ */
23665
+ get description() {
23666
+ return 'Control the tone and writing style of responses.';
23667
+ }
23668
+ /**
23669
+ * Markdown documentation for STYLE commitment.
23670
+ */
23671
+ get documentation() {
23672
+ return spaceTrim.spaceTrim(`
23673
+ # ${this.type}
23674
+
23675
+ Defines how the agent should format and present its responses (tone, writing style, formatting).
23676
+
23677
+ ## Key aspects
23678
+
23679
+ - Both terms work identically and can be used interchangeably.
23680
+ - Later style instructions can override earlier ones.
23681
+ - Style affects both tone and presentation format.
23682
+
23683
+ ## Examples
23684
+
23685
+ \`\`\`book
23686
+ Technical Writer
23687
+
23688
+ PERSONA You are a technical documentation expert
23689
+ STYLE Write in a professional but friendly tone, use bullet points for lists
23690
+ STYLE Always provide code examples when explaining programming concepts
23691
+ FORMAT Use markdown formatting with clear headings
23692
+ \`\`\`
23693
+
23694
+ \`\`\`book
23695
+ Creative Assistant
23696
+
23697
+ PERSONA You are a creative writing helper
23698
+ STYLE Be enthusiastic and encouraging in your responses
23699
+ STYLE Use vivid metaphors and analogies to explain concepts
23700
+ STYLE Keep responses conversational and engaging
23701
+ RULE Always maintain a positive and supportive tone
23702
+ \`\`\`
23703
+ `);
23704
+ }
23705
+ applyToAgentModelRequirements(requirements, content) {
23706
+ const trimmedContent = content.trim();
23707
+ if (!trimmedContent) {
23708
+ return requirements;
23709
+ }
23710
+ // Add style instructions to the system message
23711
+ const styleSection = `Style: ${trimmedContent}`;
23712
+ return this.appendToSystemMessage(requirements, styleSection, '\n\n');
23713
+ }
23714
+ }
23715
+ /**
23716
+ * [💞] Ignore a discrepancy between file name and entity name
23717
+ */
23718
+
23719
+ /**
23720
+ * Placeholder commitment definition for commitments that are not yet implemented
23721
+ *
23722
+ * This commitment simply adds its content 1:1 into the system message,
23723
+ * preserving the original behavior until proper implementation is added.
23724
+ *
23725
+ * @public exported from `@promptbook/core`
23726
+ */
23727
+ class NotYetImplementedCommitmentDefinition extends BaseCommitmentDefinition {
23728
+ constructor(type) {
23729
+ super(type);
23730
+ }
23731
+ /**
23732
+ * Short one-line description of a placeholder commitment.
23733
+ */
23734
+ get description() {
23735
+ return 'Placeholder commitment that appends content verbatim to the system message.';
23736
+ }
23737
+ /**
23738
+ * Markdown documentation available at runtime.
23739
+ */
23740
+ get documentation() {
23741
+ return spaceTrim.spaceTrim(`
23742
+ # ${this.type}
23743
+
23744
+ This commitment is not yet fully implemented.
23745
+
23746
+ ## Key aspects
23747
+
23748
+ - Content is appended directly to the system message.
23749
+ - No special processing or validation is performed.
23750
+ - Behavior preserved until proper implementation is added.
23751
+
23752
+ ## Status
23753
+
23754
+ - **Status:** Placeholder implementation
23755
+ - **Effect:** Appends content prefixed by commitment type
23756
+ - **Future:** Will be replaced with specialized logic
23757
+
23758
+ ## Examples
23759
+
23760
+ \`\`\`book
23761
+ Example Agent
23762
+
23763
+ PERSONA You are a helpful assistant
23764
+ ${this.type} Your content here
23765
+ RULE Always be helpful
23766
+ \`\`\`
23767
+ `);
23768
+ }
23769
+ applyToAgentModelRequirements(requirements, content) {
23770
+ const trimmedContent = content.trim();
23771
+ if (!trimmedContent) {
23772
+ return requirements;
23773
+ }
23774
+ // Add the commitment content 1:1 to the system message
23775
+ const commitmentLine = `${this.type} ${trimmedContent}`;
23776
+ return this.appendToSystemMessage(requirements, commitmentLine, '\n\n');
23777
+ }
23778
+ }
23779
+
23780
+ // Import all commitment definition classes
23781
+ /**
23782
+ * Registry of all available commitment definitions
23783
+ * This array contains instances of all commitment definitions
23784
+ * This is the single source of truth for all commitments in the system
23785
+ *
23786
+ * @private Use functions to access commitments instead of this array directly
23787
+ */
23788
+ const COMMITMENT_REGISTRY = [
23789
+ // Fully implemented commitments
23790
+ new PersonaCommitmentDefinition('PERSONA'),
23791
+ new PersonaCommitmentDefinition('PERSONAE'),
23792
+ new KnowledgeCommitmentDefinition(),
23793
+ new MemoryCommitmentDefinition('MEMORY'),
23794
+ new MemoryCommitmentDefinition('MEMORIES'),
23795
+ new StyleCommitmentDefinition('STYLE'),
23796
+ new StyleCommitmentDefinition('STYLES'),
23797
+ new RuleCommitmentDefinition('RULE'),
23798
+ new RuleCommitmentDefinition('RULES'),
23799
+ new SampleCommitmentDefinition('SAMPLE'),
23800
+ new SampleCommitmentDefinition('EXAMPLE'),
23801
+ new FormatCommitmentDefinition('FORMAT'),
23802
+ new FormatCommitmentDefinition('FORMATS'),
23803
+ new ModelCommitmentDefinition('MODEL'),
23804
+ new ModelCommitmentDefinition('MODELS'),
23805
+ new ActionCommitmentDefinition('ACTION'),
23806
+ new ActionCommitmentDefinition('ACTIONS'),
23807
+ new MetaCommitmentDefinition(),
23808
+ new NoteCommitmentDefinition('NOTE'),
23809
+ new NoteCommitmentDefinition('NOTES'),
23810
+ new NoteCommitmentDefinition('COMMENT'),
23811
+ new NoteCommitmentDefinition('NONCE'),
23812
+ new GoalCommitmentDefinition('GOAL'),
23813
+ new GoalCommitmentDefinition('GOALS'),
23814
+ new MessageCommitmentDefinition('MESSAGE'),
23815
+ new MessageCommitmentDefinition('MESSAGES'),
23816
+ new ScenarioCommitmentDefinition('SCENARIO'),
23817
+ new ScenarioCommitmentDefinition('SCENARIOS'),
23818
+ new DeleteCommitmentDefinition('DELETE'),
23819
+ new DeleteCommitmentDefinition('CANCEL'),
23820
+ new DeleteCommitmentDefinition('DISCARD'),
23821
+ new DeleteCommitmentDefinition('REMOVE'),
23822
+ // Not yet implemented commitments (using placeholder)
23823
+ new NotYetImplementedCommitmentDefinition('EXPECT'),
23824
+ new NotYetImplementedCommitmentDefinition('BEHAVIOUR'),
23825
+ new NotYetImplementedCommitmentDefinition('BEHAVIOURS'),
23826
+ new NotYetImplementedCommitmentDefinition('AVOID'),
23827
+ new NotYetImplementedCommitmentDefinition('AVOIDANCE'),
23828
+ new NotYetImplementedCommitmentDefinition('CONTEXT'),
23829
+ ];
23830
+ /**
23831
+ * Gets a commitment definition by its type
23832
+ * @param type The commitment type to look up
23833
+ * @returns The commitment definition or null if not found
23834
+ *
23835
+ * @public exported from `@promptbook/core`
23836
+ */
23837
+ function getCommitmentDefinition(type) {
23838
+ return COMMITMENT_REGISTRY.find((commitmentDefinition) => commitmentDefinition.type === type) || null;
23839
+ }
23840
+ /**
23841
+ * TODO: [🧠] Maybe create through standardized $register
23842
+ * Note: [💞] Ignore a discrepancy between file name and entity name
23843
+ */
23844
+
23845
+ /**
23846
+ * Parses agent source using the new commitment system with multiline support
23847
+ * This function replaces the hardcoded commitment parsing in the original parseAgentSource
23848
+ *
23849
+ * @private internal utility of `parseAgentSource`
23850
+ */
23851
+ function parseAgentSourceWithCommitments(agentSource) {
23852
+ var _a, _b, _c;
23853
+ if (!agentSource || !agentSource.trim()) {
23854
+ return {
23855
+ agentName: null,
23856
+ commitments: [],
23857
+ nonCommitmentLines: [],
23858
+ };
23859
+ }
23860
+ const lines = agentSource.split('\n');
23861
+ const agentName = (((_a = lines[0]) === null || _a === void 0 ? void 0 : _a.trim()) || null);
23862
+ const commitments = [];
23863
+ const nonCommitmentLines = [];
23864
+ // Always add the first line (agent name) to non-commitment lines
23865
+ if (lines[0] !== undefined) {
23866
+ nonCommitmentLines.push(lines[0]);
23867
+ }
23868
+ // Parse commitments with multiline support
23869
+ let currentCommitment = null;
23870
+ // Process lines starting from the second line (skip agent name)
23871
+ for (let i = 1; i < lines.length; i++) {
23872
+ const line = lines[i];
23873
+ if (line === undefined) {
23874
+ continue;
23875
+ }
23876
+ // Check if this line starts a new commitment
23877
+ let foundNewCommitment = false;
23878
+ for (const definition of COMMITMENT_REGISTRY) {
23879
+ const typeRegex = definition.createTypeRegex();
23880
+ const match = typeRegex.exec(line.trim());
23881
+ if (match && ((_b = match.groups) === null || _b === void 0 ? void 0 : _b.type)) {
23882
+ // Save the previous commitment if it exists
23883
+ if (currentCommitment) {
23884
+ const fullContent = currentCommitment.contentLines.join('\n');
23885
+ commitments.push({
23886
+ type: currentCommitment.type,
23887
+ content: spaceTrim.spaceTrim(fullContent),
23888
+ originalLine: currentCommitment.originalStartLine,
23889
+ lineNumber: currentCommitment.startLineNumber,
23890
+ });
23891
+ }
23892
+ // Extract the initial content from the commitment line
23893
+ const fullRegex = definition.createRegex();
23894
+ const fullMatch = fullRegex.exec(line.trim());
23895
+ const initialContent = ((_c = fullMatch === null || fullMatch === void 0 ? void 0 : fullMatch.groups) === null || _c === void 0 ? void 0 : _c.contents) || '';
23896
+ // Start a new commitment
23897
+ currentCommitment = {
23898
+ type: definition.type,
23899
+ startLineNumber: i + 1,
23900
+ originalStartLine: line,
23901
+ contentLines: initialContent ? [initialContent] : [],
23902
+ };
23903
+ foundNewCommitment = true;
23904
+ break;
23905
+ }
23906
+ }
23907
+ if (!foundNewCommitment) {
23908
+ if (currentCommitment) {
23909
+ // This line belongs to the current commitment
23910
+ currentCommitment.contentLines.push(line);
23911
+ }
23912
+ else {
23913
+ // This line is not part of any commitment
23914
+ nonCommitmentLines.push(line);
23915
+ }
23916
+ }
23917
+ }
23918
+ // Don't forget to save the last commitment if it exists
23919
+ if (currentCommitment) {
23920
+ const fullContent = currentCommitment.contentLines.join('\n');
23921
+ commitments.push({
23922
+ type: currentCommitment.type,
23923
+ content: spaceTrim.spaceTrim(fullContent),
23924
+ originalLine: currentCommitment.originalStartLine,
23925
+ lineNumber: currentCommitment.startLineNumber,
23926
+ });
23927
+ }
23928
+ return {
23929
+ agentName,
23930
+ commitments,
23931
+ nonCommitmentLines,
23932
+ };
23933
+ }
23934
+
23935
+ /**
23936
+ * Removes comment lines (lines starting with #) from a system message
23937
+ * This is used to clean up the final system message before sending it to the AI model
23938
+ * while preserving the original content with comments in metadata
23939
+ *
23940
+ * @param systemMessage The system message that may contain comment lines
23941
+ * @returns The system message with comment lines removed
23942
+ *
23943
+ * @private - TODO: [🧠] Maybe should be public?
23944
+ */
23945
+ function removeCommentsFromSystemMessage(systemMessage) {
23946
+ if (!systemMessage) {
23947
+ return systemMessage;
23948
+ }
23949
+ const lines = systemMessage.split('\n');
23950
+ const filteredLines = lines.filter((line) => {
23951
+ const trimmedLine = line.trim();
23952
+ // Remove lines that start with # (comments)
23953
+ return !trimmedLine.startsWith('#');
23954
+ });
23955
+ return filteredLines.join('\n').trim();
23956
+ }
23957
+
23958
+ /**
23959
+ * Parses parameters from text using both supported notations:
23960
+ * 1. @Parameter - single word parameter starting with @
23961
+ * 2. {parameterName} or {parameter with multiple words} or {parameterName: description text}
23962
+ *
23963
+ * Both notations represent the same syntax feature - parameters
23964
+ *
23965
+ * @param text - Text to extract parameters from
23966
+ * @returns Array of parsed parameters with unified representation
23967
+ * @public exported from `@promptbook/core`
23968
+ */
23969
+ function parseParameters(text) {
23970
+ const parameters = [];
23971
+ // [🧠] Parameter syntax parsing - unified approach for two different notations of the same syntax feature
23972
+ // The Book language supports parameters in two different notations but they represent the same concept
23973
+ // Extract @Parameter notation (single word parameters starting with @)
23974
+ const atParameterRegex = /@[\w\u00C0-\u017F\u0100-\u024F\u1E00-\u1EFF]+/gim;
23975
+ text.replace(atParameterRegex, (match) => {
23976
+ const parameterName = match.slice(1); // Remove the @ symbol
23977
+ parameters.push({
23978
+ text: match,
23979
+ notation: 'at',
23980
+ name: parameterName,
23981
+ });
23982
+ return match;
23983
+ });
23984
+ // Extract {parameter} notation (parameters in braces)
23985
+ const braceParameterRegex = /\{([^}]+)\}/gim;
23986
+ text.replace(braceParameterRegex, (match, content) => {
23987
+ // Check if the parameter has a description (parameterName: description)
23988
+ const colonIndex = content.indexOf(':');
23989
+ if (colonIndex !== -1) {
23990
+ const name = content.substring(0, colonIndex).trim();
23991
+ const description = content.substring(colonIndex + 1).trim();
23992
+ parameters.push({
23993
+ text: match,
23994
+ notation: 'brace',
23995
+ name,
23996
+ description,
23997
+ });
23998
+ }
23999
+ else {
24000
+ // Simple parameter without description
24001
+ parameters.push({
24002
+ text: match,
24003
+ notation: 'brace',
24004
+ name: content.trim(),
24005
+ });
24006
+ }
24007
+ return match;
24008
+ });
24009
+ // Remove duplicates based on name (keep the first occurrence)
24010
+ const uniqueParameters = parameters.filter((param, index, array) => {
24011
+ return array.findIndex((p) => p.name === param.name) === index;
24012
+ });
24013
+ return uniqueParameters;
24014
+ }
24015
+
24016
+ /**
24017
+ * Creates agent model requirements using the new commitment system
24018
+ * This function uses a reduce-like pattern where each commitment applies its changes
24019
+ * to build the final requirements starting from a basic empty model
24020
+ *
24021
+ * @public exported from `@promptbook/core`
24022
+ */
24023
+ async function createAgentModelRequirementsWithCommitments(agentSource, modelName) {
24024
+ // Parse the agent source to extract commitments
24025
+ const parseResult = parseAgentSourceWithCommitments(agentSource);
24026
+ // Apply DELETE filtering: remove prior commitments tagged by parameters targeted by DELETE/CANCEL/DISCARD/REMOVE
24027
+ const filteredCommitments = [];
24028
+ for (const commitment of parseResult.commitments) {
24029
+ // Handle DELETE-like commitments by invalidating prior tagged commitments
24030
+ if (commitment.type === 'DELETE' ||
24031
+ commitment.type === 'CANCEL' ||
24032
+ commitment.type === 'DISCARD' ||
24033
+ commitment.type === 'REMOVE') {
24034
+ const targets = parseParameters(commitment.content)
24035
+ .map((p) => p.name.trim().toLowerCase())
24036
+ .filter(Boolean);
24037
+ if (targets.length === 0) {
24038
+ // Ignore DELETE with no targets; also don't pass the DELETE further
24039
+ continue;
24040
+ }
24041
+ // Drop prior kept commitments that contain any of the targeted tags
24042
+ for (let i = filteredCommitments.length - 1; i >= 0; i--) {
24043
+ const prev = filteredCommitments[i];
24044
+ const prevParams = parseParameters(prev.content).map((p) => p.name.trim().toLowerCase());
24045
+ const hasIntersection = prevParams.some((n) => targets.includes(n));
24046
+ if (hasIntersection) {
24047
+ filteredCommitments.splice(i, 1);
24048
+ }
24049
+ }
24050
+ // Do not keep the DELETE commitment itself
24051
+ continue;
24052
+ }
24053
+ filteredCommitments.push(commitment);
24054
+ }
24055
+ // Start with basic agent model requirements
24056
+ let requirements = createBasicAgentModelRequirements(parseResult.agentName);
24057
+ // Store the agent name in metadata so commitments can access it
24058
+ requirements = {
24059
+ ...requirements,
24060
+ metadata: {
24061
+ ...requirements.metadata,
24062
+ agentName: parseResult.agentName,
24063
+ },
24064
+ };
24065
+ // Override model name if provided
24066
+ if (modelName) {
24067
+ requirements = {
24068
+ ...requirements,
24069
+ modelName,
24070
+ };
24071
+ }
24072
+ // Apply each commitment in order using reduce-like pattern
24073
+ for (const commitment of filteredCommitments) {
24074
+ const definition = getCommitmentDefinition(commitment.type);
24075
+ if (definition) {
24076
+ try {
24077
+ requirements = definition.applyToAgentModelRequirements(requirements, commitment.content);
24078
+ }
24079
+ catch (error) {
24080
+ console.warn(`Failed to apply commitment ${commitment.type}:`, error);
24081
+ // Continue with other commitments even if one fails
24082
+ }
24083
+ }
24084
+ }
24085
+ // Handle MCP servers (extract from original agent source)
24086
+ const mcpServers = extractMcpServers(agentSource);
24087
+ if (mcpServers.length > 0) {
24088
+ requirements = {
24089
+ ...requirements,
24090
+ mcpServers,
24091
+ };
24092
+ }
24093
+ // Add non-commitment lines to system message if they exist
24094
+ const nonCommitmentContent = parseResult.nonCommitmentLines
24095
+ .filter((line, index) => index > 0 || !parseResult.agentName) // Skip first line if it's the agent name
24096
+ .filter((line) => line.trim()) // Remove empty lines
24097
+ .join('\n')
24098
+ .trim();
24099
+ if (nonCommitmentContent) {
24100
+ requirements = {
24101
+ ...requirements,
24102
+ systemMessage: requirements.systemMessage + '\n\n' + nonCommitmentContent,
24103
+ };
24104
+ }
24105
+ // Remove comment lines (lines starting with #) from the final system message
24106
+ // while preserving the original content with comments in metadata
24107
+ const cleanedSystemMessage = removeCommentsFromSystemMessage(requirements.systemMessage);
24108
+ return {
24109
+ ...requirements,
24110
+ systemMessage: cleanedSystemMessage,
24111
+ };
24112
+ }
24113
+
24114
+ /**
24115
+ * Generates a gravatar URL based on agent name for fallback avatar
24116
+ *
24117
+ * @param agentName The agent name to generate avatar for
24118
+ * @returns Gravatar URL
24119
+ *
24120
+ * @private - [🤹] The fact that profile image is Gravatar is just implementation detail which should be hidden for consumer
24121
+ */
24122
+ function generateGravatarUrl(agentName) {
24123
+ // Use a default name if none provided
24124
+ const safeName = agentName || 'Anonymous Agent';
24125
+ // Create a simple hash from the name for consistent avatar
24126
+ let hash = 0;
24127
+ for (let i = 0; i < safeName.length; i++) {
24128
+ const char = safeName.charCodeAt(i);
24129
+ hash = (hash << 5) - hash + char;
24130
+ hash = hash & hash; // Convert to 32bit integer
24131
+ }
24132
+ const avatarId = Math.abs(hash).toString();
24133
+ return `https://www.gravatar.com/avatar/${avatarId}?default=robohash&size=200&rating=x`;
24134
+ }
24135
+
24136
+ /**
24137
+ * Generates an image for the agent to use as profile image
24138
+ *
24139
+ * @param agentName The agent name to generate avatar for
24140
+ * @returns The placeholder profile image URL for the agent
24141
+ *
24142
+ * @public exported from `@promptbook/core`
24143
+ */
24144
+ function generatePlaceholderAgentProfileImageUrl(agentName) {
24145
+ // Note: [🤹] The fact that profile image is Gravatar is just implementation detail which should be hidden for consumer
24146
+ return generateGravatarUrl(agentName);
24147
+ }
24148
+ /**
24149
+ * TODO: [🤹] Figure out best placeholder image generator https://i.pravatar.cc/1000?u=568
24150
+ */
24151
+
24152
+ /**
24153
+ * Parses basic information from agent source
24154
+ *
24155
+ * There are 2 similar functions:
24156
+ * - `parseAgentSource` which is a lightweight parser for agent source, it parses basic information and its purpose is to be quick and synchronous. The commitments there are hardcoded.
24157
+ * - `createAgentModelRequirements` which is an asynchronous function that creates model requirements it applies each commitment one by one and works asynchronously.
24158
+ *
24159
+ * @public exported from `@promptbook/core`
24160
+ */
24161
+ function parseAgentSource(agentSource) {
24162
+ const parseResult = parseAgentSourceWithCommitments(agentSource);
24163
+ // Find PERSONA and META commitments
24164
+ let personaDescription = null;
24165
+ for (const commitment of parseResult.commitments) {
24166
+ if (commitment.type !== 'PERSONA') {
24167
+ continue;
24168
+ }
24169
+ if (personaDescription === null) {
24170
+ personaDescription = '';
24171
+ }
24172
+ else {
24173
+ personaDescription += `\n\n${personaDescription}`;
24174
+ }
24175
+ personaDescription += commitment.content;
24176
+ }
24177
+ const meta = {};
24178
+ for (const commitment of parseResult.commitments) {
24179
+ if (commitment.type !== 'META') {
24180
+ continue;
24181
+ }
24182
+ // Parse META commitments - format is "META TYPE content"
24183
+ const metaTypeRaw = commitment.content.split(' ')[0] || 'NONE';
24184
+ const metaType = normalizeTo_camelCase(metaTypeRaw);
24185
+ meta[metaType] = spaceTrim__default["default"](commitment.content.substring(metaTypeRaw.length));
24186
+ }
24187
+ // Generate gravatar fallback if no meta image specified
24188
+ if (!meta.image) {
24189
+ meta.image = generatePlaceholderAgentProfileImageUrl(parseResult.agentName || '!!');
24190
+ }
24191
+ // Parse parameters using unified approach - both @Parameter and {parameter} notations
24192
+ // are treated as the same syntax feature with unified representation
24193
+ const parameters = parseParameters(agentSource);
24194
+ return {
24195
+ agentName: parseResult.agentName,
24196
+ personaDescription,
24197
+ meta,
24198
+ parameters,
24199
+ };
24200
+ }
24201
+ /**
24202
+ * TODO: [🕛] Unite `AgentBasicInformation`, `ChatParticipant`, `LlmExecutionTools` + `LlmToolsMetadata`
24203
+ */
24204
+
24205
+ /**
24206
+ * Creates model requirements for an agent based on its source
24207
+ *
24208
+ * There are 2 similar functions:
24209
+ * - `parseAgentSource` which is a lightweight parser for agent source, it parses basic information and its purpose is to be quick and synchronous. The commitments there are hardcoded.
24210
+ * - `createAgentModelRequirements` which is an asynchronous function that creates model requirements it applies each commitment one by one and works asynchronous.
24211
+ *
24212
+ * @public exported from `@promptbook/core`
24213
+ */
24214
+ async function createAgentModelRequirements(agentSource, modelName, availableModels, llmTools) {
24215
+ // If availableModels are provided and no specific modelName is given,
24216
+ // use preparePersona to select the best model
24217
+ if (availableModels && !modelName && llmTools) {
24218
+ const selectedModelName = await selectBestModelUsingPersona(agentSource, llmTools);
24219
+ return createAgentModelRequirementsWithCommitments(agentSource, selectedModelName);
24220
+ }
24221
+ // Use the new commitment-based system with provided or default model
24222
+ return createAgentModelRequirementsWithCommitments(agentSource, modelName);
24223
+ }
24224
+ /**
24225
+ * Selects the best model using the preparePersona function
24226
+ * This directly uses preparePersona to ensure DRY principle
24227
+ *
24228
+ * @param agentSource The agent source to derive persona description from
24229
+ * @param llmTools LLM tools for preparing persona
24230
+ * @returns The name of the best selected model
24231
+ * @private function of `createAgentModelRequirements`
24232
+ */
24233
+ async function selectBestModelUsingPersona(agentSource, llmTools) {
24234
+ var _a;
24235
+ // Parse agent source to get persona description
24236
+ const { agentName, personaDescription } = parseAgentSource(agentSource);
24237
+ // Use agent name as fallback if no persona description is available
24238
+ const description = personaDescription || agentName || 'AI Agent';
24239
+ try {
24240
+ // Use preparePersona directly
24241
+ const { modelsRequirements } = await preparePersona(description, { llm: llmTools }, { isVerbose: false });
24242
+ // Extract the first model name from the requirements
24243
+ if (modelsRequirements.length > 0 && ((_a = modelsRequirements[0]) === null || _a === void 0 ? void 0 : _a.modelName)) {
24244
+ return modelsRequirements[0].modelName;
24245
+ }
24246
+ // Fallback: get available models and return the first CHAT model
24247
+ const availableModels = await llmTools.listModels();
24248
+ const chatModels = availableModels.filter(({ modelVariant }) => modelVariant === 'CHAT');
24249
+ if (chatModels.length === 0) {
24250
+ throw new Error('No CHAT models available for agent model selection');
24251
+ }
24252
+ return chatModels[0].modelName;
24253
+ }
24254
+ catch (error) {
24255
+ console.warn('Failed to use preparePersona for model selection, falling back to first available model:', error);
24256
+ // Fallback: get available models and return the first CHAT model
24257
+ const availableModels = await llmTools.listModels();
24258
+ const chatModels = availableModels.filter(({ modelVariant }) => modelVariant === 'CHAT');
24259
+ if (chatModels.length === 0) {
24260
+ throw new Error('No CHAT models available for agent model selection');
24261
+ }
24262
+ return chatModels[0].modelName;
24263
+ }
24264
+ }
24265
+ /**
24266
+ * Extracts MCP servers from agent source
24267
+ *
24268
+ * @param agentSource The agent source string that may contain MCP lines
24269
+ * @returns Array of MCP server identifiers
24270
+ *
24271
+ * @private TODO: [🧠] Maybe should be public
24272
+ */
24273
+ function extractMcpServers(agentSource) {
24274
+ if (!agentSource) {
24275
+ return [];
24276
+ }
24277
+ const lines = agentSource.split('\n');
24278
+ const mcpRegex = /^\s*MCP\s+(.+)$/i;
24279
+ const mcpServers = [];
24280
+ // Look for MCP lines
24281
+ for (const line of lines) {
24282
+ const match = line.match(mcpRegex);
24283
+ if (match && match[1]) {
24284
+ mcpServers.push(match[1].trim());
24285
+ }
24286
+ }
24287
+ return mcpServers;
24288
+ }
24289
+
24290
+ /**
24291
+ * Type guard to check if a string is a valid agent source
24292
+ *
24293
+ * @public exported from `@promptbook/core`
24294
+ */
24295
+ function isValidBook(value) {
24296
+ // Basic validation - agent source should have at least a name (first line)
24297
+ return typeof value === 'string' /* && value.trim().length > 0 */;
24298
+ }
24299
+ /**
24300
+ * Validates and converts a string to agent source branded type
24301
+ * This function should be used when you have a string that you know represents agent source
24302
+ * but need to convert it to the branded type for type safety
24303
+ *
24304
+ * @public exported from `@promptbook/core`
24305
+ */
24306
+ function validateBook(source) {
24307
+ if (!isValidBook(source)) {
24308
+ throw new Error('Invalid agent source: must be a string');
24309
+ }
24310
+ return source;
24311
+ }
24312
+ /**
24313
+ * Default book
24314
+ *
24315
+ * @public exported from `@promptbook/core`
24316
+ */
24317
+ padBook(validateBook(spaceTrim__default["default"](`
24318
+ AI Avatar
24319
+
24320
+ PERSONA A friendly AI assistant that helps you with your tasks
24321
+ `)));
24322
+ // <- Note: Not using book`...` notation to avoid strange error in jest unit tests `TypeError: (0 , book_notation_1.book) is not a function`
24323
+
24324
+ /**
24325
+ * Change ellipsis character to three dots `…` -> `...`
24326
+ *
24327
+ * Note: [🔂] This function is idempotent.
24328
+ * Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
24329
+ *
24330
+ * @public exported from `@promptbook/markdown-utils`
24331
+ */
24332
+ function humanizeAiTextEllipsis(aiText) {
24333
+ return aiText.replace(/…/g, '...');
24334
+ }
24335
+ /**
24336
+ * Note: [🏂] This function is not tested by itself but together with other cleanup functions with `humanizeAiText`
24337
+ */
24338
+
24339
+ /**
24340
+ * Change em-dashes to regular dashes `—` -> `-`
24341
+ *
24342
+ * Note: [🔂] This function is idempotent.
24343
+ * Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
24344
+ *
24345
+ * @public exported from `@promptbook/markdown-utils`
24346
+ */
24347
+ function humanizeAiTextEmdashed(aiText) {
24348
+ return aiText.replace(/—/g, '-');
24349
+ }
24350
+ /**
24351
+ * Note: [🏂] This function is not tested by itself but together with other cleanup functions with `humanizeAiText`
24352
+ */
24353
+
24354
+ /**
24355
+ * Change smart quotes to regular quotes
24356
+ *
24357
+ * Note: [🔂] This function is idempotent.
24358
+ * Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
24359
+ *
24360
+ * @public exported from `@promptbook/markdown-utils`
24361
+ */
24362
+ function humanizeAiTextQuotes(aiText) {
24363
+ return aiText
24364
+ .replace(/[“”]/g, '"')
24365
+ .replace(/[‚‘’]/g, "'")
24366
+ .replace(/«/g, '"')
24367
+ .replace(/»/g, '"')
24368
+ .replace(/„/g, '"')
24369
+ .replace(/‹/g, "'")
24370
+ .replace(/›/g, "'");
24371
+ }
24372
+ /**
24373
+ * Note: [🏂] This function is not tested by itself but together with other cleanup functions with `humanizeAiText`
24374
+ */
24375
+
24376
+ /**
24377
+ * Change unprintable hard spaces to regular spaces
24378
+ *
24379
+ * Note: [🔂] This function is idempotent.
24380
+ * Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
24381
+ *
24382
+ * @public exported from `@promptbook/markdown-utils`
24383
+ */
24384
+ function humanizeAiTextWhitespace(aiText) {
24385
+ return aiText.replace(/\u00A0/g, ' ');
24386
+ }
24387
+ /**
24388
+ * Note: [🏂] This function is not tested by itself but together with other cleanup functions with `humanizeAiText`
24389
+ */
24390
+
24391
+ /**
24392
+ * Function `humanizeAiText` will remove traces of AI text generation artifacts
24393
+ *
24394
+ * Note: [🔂] This function is idempotent.
24395
+ * Tip: If you want more control, look for other functions for example `humanizeAiTextEmdashed` exported `@promptbook/markdown-utils`
24396
+ *
24397
+ * @public exported from `@promptbook/markdown-utils`
24398
+ */
24399
+ function humanizeAiText(aiText) {
24400
+ let cleanedText = aiText;
24401
+ cleanedText = humanizeAiTextEllipsis(cleanedText);
24402
+ cleanedText = humanizeAiTextEmdashed(cleanedText);
24403
+ cleanedText = humanizeAiTextQuotes(cleanedText);
24404
+ cleanedText = humanizeAiTextWhitespace(cleanedText);
24405
+ return cleanedText;
24406
+ }
24407
+ /**
24408
+ * TODO: [🧠] Maybe this should be exported from `@promptbook/utils` not `@promptbook/markdown-utils`
24409
+ */
24410
+
24411
+ /**
24412
+ * @private
24413
+ */
24414
+ const PROMPTBOOK_PSEUDOTOKEN_SUBSTITUTION = {
24415
+ 'a ': 'a ',
24416
+ 'the ': 'the ',
24417
+ 'is ': 'is ',
24418
+ 'or ': 'or ',
24419
+ 'be ': 'be ',
24420
+ };
24421
+ /**
24422
+ * Function `promptbookifyAiText` will slightly modify the text so we know it was processed by Promptbook
24423
+ *
24424
+ * Note: [🔂] This function is idempotent.
24425
+ *
24426
+ * @public exported from `@promptbook/markdown-utils`
24427
+ */
24428
+ function promptbookifyAiText(text) {
24429
+ const textLength = text.length;
24430
+ let currentToken = '';
24431
+ const textTokens = [
24432
+ /* <- TODO: [✌️] Create `splitToPromptbookTokens` */
24433
+ ];
24434
+ for (let textPosition = 0; textPosition < textLength; textPosition++) {
24435
+ const currentCharacter = text[textPosition];
24436
+ if (currentToken.endsWith(' ') && currentCharacter !== ' ') {
24437
+ textTokens.push(currentToken);
24438
+ currentToken = '';
24439
+ }
24440
+ currentToken += currentCharacter;
24441
+ }
24442
+ if (currentToken.length > 0) {
24443
+ textTokens.push(currentToken);
24444
+ }
24445
+ // [✌️] <- End of `splitToPromptbookTokens`
24446
+ const promptbookifiedTextTokens = [];
24447
+ for (let i = 0; i < textTokens.length; i++) {
24448
+ const token = textTokens[i];
24449
+ const tokenSubstitute = PROMPTBOOK_PSEUDOTOKEN_SUBSTITUTION[token];
24450
+ if (tokenSubstitute !== undefined) {
24451
+ promptbookifiedTextTokens.push(tokenSubstitute);
24452
+ }
24453
+ else {
24454
+ promptbookifiedTextTokens.push(token);
24455
+ }
24456
+ }
24457
+ return promptbookifiedTextTokens.join('');
24458
+ }
24459
+ /**
24460
+ * TODO: [🧠][✌️] Make some Promptbook-native token system
24461
+ */
24462
+
24463
+ /**
24464
+ * Execution Tools for calling LLM models with a predefined agent "soul"
24465
+ * This wraps underlying LLM execution tools and applies agent-specific system prompts and requirements
24466
+ *
24467
+ * @public exported from `@promptbook/core`
24468
+ */
24469
+ class AgentLlmExecutionTools {
24470
+ /**
24471
+ * Creates new AgentLlmExecutionTools
24472
+ *
24473
+ * @param llmTools The underlying LLM execution tools to wrap
24474
+ * @param agentSource The agent source string that defines the agent's behavior
24475
+ */
24476
+ constructor(llmTools, agentSource) {
24477
+ this.llmTools = llmTools;
24478
+ this.agentSource = agentSource;
24479
+ /**
24480
+ * Cached model requirements to avoid re-parsing the agent source
24481
+ */
24482
+ this._cachedModelRequirements = null;
24483
+ /**
24484
+ * Cached parsed agent information
24485
+ */
24486
+ this._cachedAgentInfo = null;
24487
+ }
24488
+ /**
24489
+ * Get cached or parse agent information
24490
+ */
24491
+ getAgentInfo() {
24492
+ if (this._cachedAgentInfo === null) {
24493
+ this._cachedAgentInfo = parseAgentSource(this.agentSource);
24494
+ }
24495
+ return this._cachedAgentInfo;
24496
+ }
24497
+ /**
24498
+ * Get cached or create agent model requirements
24499
+ */
24500
+ async getAgentModelRequirements() {
24501
+ if (this._cachedModelRequirements === null) {
24502
+ // Get available models from underlying LLM tools for best model selection
24503
+ const availableModels = await this.llmTools.listModels();
24504
+ this._cachedModelRequirements = await createAgentModelRequirements(this.agentSource, undefined, // Let the function pick the best model
24505
+ availableModels);
24506
+ }
24507
+ return this._cachedModelRequirements;
24508
+ }
24509
+ get title() {
24510
+ const agentInfo = this.getAgentInfo();
24511
+ return (agentInfo.agentName || 'Agent');
24512
+ }
24513
+ get description() {
24514
+ const agentInfo = this.getAgentInfo();
24515
+ return agentInfo.personaDescription || 'AI Agent with predefined personality and behavior';
24516
+ }
24517
+ get profile() {
24518
+ const agentInfo = this.getAgentInfo();
24519
+ if (!agentInfo.agentName) {
24520
+ return undefined;
24521
+ }
24522
+ return {
24523
+ name: agentInfo.agentName.toUpperCase().replace(/\s+/g, '_'),
24524
+ fullname: agentInfo.agentName,
24525
+ color: agentInfo.meta.color || '#6366f1',
24526
+ avatarSrc: agentInfo.meta.image,
24527
+ };
24528
+ }
24529
+ checkConfiguration() {
24530
+ // Check underlying tools configuration
24531
+ return this.llmTools.checkConfiguration();
24532
+ }
24533
+ /**
24534
+ * Returns a virtual model name representing the agent behavior
24535
+ */
24536
+ get modelName() {
24537
+ const hash = cryptoJs.SHA256(hexEncoder__default["default"].parse(this.agentSource))
24538
+ // <- TODO: [🥬] Encapsulate sha256 to some private utility function
24539
+ .toString( /* hex */);
24540
+ // <- TODO: [🥬] Make some system for hashes and ids of promptbook
24541
+ const agentId = hash.substring(0, 10);
24542
+ // <- TODO: [🥬] Make some system for hashes and ids of promptbook
24543
+ return (normalizeToKebabCase(this.title) + '-' + agentId);
24544
+ }
24545
+ listModels() {
24546
+ return [
24547
+ {
24548
+ modelName: this.modelName,
24549
+ modelVariant: 'CHAT',
24550
+ modelTitle: `${this.title} (Agent Chat Default)`,
24551
+ modelDescription: `Chat model with agent behavior: ${this.description}`,
24552
+ },
24553
+ // <- Note: We only list a single "virtual" agent model here as this wrapper only supports chat prompts
24554
+ ];
24555
+ }
24556
+ /**
24557
+ * Calls the chat model with agent-specific system prompt and requirements
24558
+ */
24559
+ async callChatModel(prompt) {
24560
+ if (!this.llmTools.callChatModel) {
24561
+ throw new Error('Underlying LLM execution tools do not support chat model calls');
24562
+ }
24563
+ // Ensure we're working with a chat prompt
24564
+ if (prompt.modelRequirements.modelVariant !== 'CHAT') {
24565
+ throw new Error('AgentLlmExecutionTools only supports chat prompts');
24566
+ }
24567
+ const chatPrompt = prompt;
24568
+ // Get agent model requirements (cached with best model selection)
24569
+ const modelRequirements = await this.getAgentModelRequirements();
24570
+ // Create modified chat prompt with agent system message
24571
+ const modifiedChatPrompt = {
24572
+ ...chatPrompt,
24573
+ modelRequirements: {
24574
+ ...chatPrompt.modelRequirements,
24575
+ ...modelRequirements,
24576
+ // Prepend agent system message to existing system message
24577
+ systemMessage: modelRequirements.systemMessage +
24578
+ (chatPrompt.modelRequirements.systemMessage
24579
+ ? `\n\n${chatPrompt.modelRequirements.systemMessage}`
24580
+ : ''),
24581
+ },
24582
+ };
24583
+ const underlyingLlmResult = await this.llmTools.callChatModel(modifiedChatPrompt);
24584
+ let content = underlyingLlmResult.content;
24585
+ // Note: Cleanup the AI artifacts from the content
24586
+ content = humanizeAiText(content);
24587
+ // Note: Make sure the content is Promptbook-like
24588
+ content = promptbookifyAiText(content);
24589
+ const agentResult = {
24590
+ ...underlyingLlmResult,
24591
+ content,
24592
+ modelName: this.modelName,
24593
+ };
24594
+ return agentResult;
24595
+ }
24596
+ }
24597
+ /**
24598
+ * TODO: [🍚] Implement Destroyable pattern to free resources
24599
+ * TODO: [🧠] Adding parameter substitution support (here or should be responsibility of the underlying LLM Tools)
24600
+ */
24601
+
24602
+ /**
24603
+ * Creates new AgentLlmExecutionTools that wrap underlying LLM tools with agent-specific behavior
24604
+ *
24605
+ * @public exported from `@promptbook/core`
24606
+ */
24607
+ const createAgentLlmExecutionTools = Object.assign((options) => {
24608
+ return new AgentLlmExecutionTools(options.llmTools, options.agentSource);
24609
+ }, {
24610
+ packageName: '@promptbook/core',
24611
+ className: 'AgentLlmExecutionTools',
24612
+ });
24613
+ /**
24614
+ * TODO: [🧠] Consider adding validation for agent source format
24615
+ * TODO: [🧠] Consider adding options for caching behavior
24616
+ */
24617
+
24618
+ /**
24619
+ * Metadata for Agent LLM execution tools
24620
+ *
24621
+ * @public exported from `@promptbook/core`
24622
+ */
24623
+ $llmToolsMetadataRegister.register({
24624
+ packageName: '@promptbook/core',
24625
+ className: 'AgentLlmExecutionTools',
24626
+ title: 'Agent',
24627
+ trustLevel: 'UNTRUSTED',
24628
+ order: MODEL_ORDERS.LOW_TIER,
24629
+ envVariables: null,
24630
+ getBoilerplateConfiguration() {
24631
+ return {
24632
+ packageName: '@promptbook/core',
24633
+ className: 'AgentLlmExecutionTools',
24634
+ title: 'Agent',
24635
+ options: {
24636
+ // Note: Agent tools require runtime configuration with underlying tools and agent source
24637
+ // This cannot be provided as a static configuration
24638
+ },
24639
+ };
24640
+ },
24641
+ createConfigurationFromEnv() {
24642
+ // Agent tools cannot be configured from environment variables alone
24643
+ // They require underlying LLM tools and agent source to be provided programmatically
24644
+ return null;
24645
+ },
24646
+ });
24647
+ /**
24648
+ * TODO: [🧠] Consider adding a special trust level for AgentLlmExecutionTools
24649
+ * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
24650
+ * Note: [💞] Ignore a discrepancy between file name and entity name
24651
+ */
24652
+
24653
+ /**
24654
+ * Registration of Agent LLM provider
24655
+ *
24656
+ * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available LLM tools
24657
+ *
24658
+ * @public exported from `@promptbook/core`
24659
+ */
24660
+ $llmToolsRegister.register(createAgentLlmExecutionTools);
24661
+ /**
24662
+ * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
24663
+ * Note: [💞] Ignore a discrepancy between file name and entity name
24664
+ */
24665
+
24666
+ /**
24667
+ * Transpiler to Javascript code using OpenAI SDK.
24668
+ *
24669
+ * @public exported from `@promptbook/core`
24670
+ */
24671
+ const OpenAiSdkTranspiler = {
24672
+ name: 'openai-sdk',
24673
+ title: 'OpenAI SDK',
24674
+ packageName: '@promptbook/core',
24675
+ className: 'OpenAiSdkTranspiler',
24676
+ async transpileBook(book, tools, options) {
24677
+ const { agentName, personaDescription } = await parseAgentSource(book);
24678
+ const modelRequirements = await createAgentModelRequirements(book);
24679
+ const source = spaceTrim__default["default"]((block) => `
24680
+
24681
+ #!/usr/bin/env node
24682
+
24683
+ import * as dotenv from 'dotenv';
24684
+
24685
+ dotenv.config({ path: '.env' });
24686
+
24687
+ import { spaceTrim } from '@promptbook/utils';
24688
+ import OpenAI from 'openai';
24689
+ import readline from 'readline';
24690
+
24691
+ // ---- CONFIG ----
24692
+ const client = new OpenAI({
24693
+ apiKey: process.env.OPENAI_API_KEY,
24694
+ });
24695
+
24696
+ // ---- CLI SETUP ----
24697
+ const rl = readline.createInterface({
24698
+ input: process.stdin,
24699
+ output: process.stdout,
24700
+ });
24701
+
24702
+ const chatHistory = [
24703
+ {
24704
+ role: 'system',
24705
+ content: spaceTrim(\`
24706
+ ${block(modelRequirements.systemMessage)}
24707
+ \`),
24708
+ },
24709
+ ];
24710
+
24711
+ async function ask(question) {
24712
+ chatHistory.push({ role: 'user', content: question });
24713
+
24714
+ const response = await client.chat.completions.create({
24715
+ model: 'gpt-4o',
24716
+ messages: chatHistory,
24717
+ temperature: ${modelRequirements.temperature},
24718
+ });
24719
+
24720
+ const answer = response.choices[0].message.content;
24721
+ console.log('\\n🧠 ${agentName}:', answer, '\\n');
24722
+
24723
+ chatHistory.push({ role: 'assistant', content: answer });
24724
+ promptUser();
24725
+ }
24726
+
24727
+ function promptUser() {
24728
+ rl.question('💬 You: ', (input) => {
24729
+ if (input.trim().toLowerCase() === 'exit') {
24730
+ console.log('👋 Bye!');
24731
+ rl.close();
24732
+ return;
24733
+ }
24734
+ ask(input);
24735
+ });
24736
+ }
24737
+
24738
+ console.log("🤖 Chat with ${agentName} (type 'exit' to quit)\\n");
24739
+ promptUser();
24740
+
24741
+ `);
24742
+ return source;
24743
+ },
24744
+ };
22079
24745
 
22080
24746
  /**
22081
24747
  * Registration of LLM provider
@@ -22107,7 +24773,6 @@
22107
24773
  exports._DocumentScraperRegistration = _DocumentScraperRegistration;
22108
24774
  exports._GoogleMetadataRegistration = _GoogleMetadataRegistration;
22109
24775
  exports._GoogleRegistration = _GoogleRegistration;
22110
- exports._LangchainTranspilerRegistration = _LangchainTranspilerRegistration;
22111
24776
  exports._LegacyDocumentScraperMetadataRegistration = _LegacyDocumentScraperMetadataRegistration;
22112
24777
  exports._LegacyDocumentScraperRegistration = _LegacyDocumentScraperRegistration;
22113
24778
  exports._MarkdownScraperMetadataRegistration = _MarkdownScraperMetadataRegistration;