@promptbook/cli 0.103.0-31 → 0.103.0-33

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 (30) hide show
  1. package/esm/index.es.js +2844 -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/collection/constructors/createCollectionFromDirectory.d.ts +1 -2
  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/playground/permanent/_boilerplate.d.ts +5 -0
  15. package/esm/typings/src/playground/permanent/agent-with-browser-playground.d.ts +5 -0
  16. package/esm/typings/src/playground/permanent/transpilers-playground.d.ts +5 -0
  17. package/esm/typings/src/playground/playground.d.ts +0 -3
  18. package/esm/typings/src/playground/playground1.d.ts +2 -0
  19. package/esm/typings/src/transpilers/_common/BookTranspiler.d.ts +26 -17
  20. package/esm/typings/src/transpilers/_common/BookTranspilerOptions.d.ts +2 -3
  21. package/esm/typings/src/transpilers/_common/register/$bookTranspilersRegister.d.ts +2 -2
  22. package/esm/typings/src/transpilers/openai/OpenAiSdkTranspiler.d.ts +9 -9
  23. package/esm/typings/src/types/LlmCall.d.ts +20 -0
  24. package/esm/typings/src/version.d.ts +1 -1
  25. package/package.json +3 -3
  26. package/umd/index.umd.js +2843 -155
  27. package/umd/index.umd.js.map +1 -1
  28. package/esm/typings/src/transpilers/_common/BookTranspilerDefinition.d.ts +0 -37
  29. package/esm/typings/src/transpilers/langchain/LangchainTranspiler.d.ts +0 -7
  30. package/esm/typings/src/transpilers/langchain/register.d.ts +0 -15
package/esm/index.es.js CHANGED
@@ -47,7 +47,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
47
47
  * @generated
48
48
  * @see https://github.com/webgptorg/promptbook
49
49
  */
50
- const PROMPTBOOK_ENGINE_VERSION = '0.103.0-31';
50
+ const PROMPTBOOK_ENGINE_VERSION = '0.103.0-33';
51
51
  /**
52
52
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
53
53
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -6076,7 +6076,7 @@ async function loadArchive(filePath, fs) {
6076
6076
  * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
6077
6077
  */
6078
6078
 
6079
- 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-30",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"}];
6079
+ 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-32",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"}];
6080
6080
 
6081
6081
  /**
6082
6082
  * Function `validatePipelineString` will validate the if the string is a valid pipeline string
@@ -6567,6 +6567,7 @@ function createTask(options) {
6567
6567
  let updatedAt = createdAt;
6568
6568
  const errors = [];
6569
6569
  const warnings = [];
6570
+ const llmCalls = [];
6570
6571
  let currentValue = {};
6571
6572
  let customTldr = null;
6572
6573
  const partialResultSubject = new Subject();
@@ -6582,6 +6583,9 @@ function createTask(options) {
6582
6583
  }, (tldrInfo) => {
6583
6584
  customTldr = tldrInfo;
6584
6585
  updatedAt = new Date();
6586
+ }, (llmCall) => {
6587
+ llmCalls.push(llmCall);
6588
+ updatedAt = new Date();
6585
6589
  });
6586
6590
  finalResultPromise
6587
6591
  .catch((error) => {
@@ -6727,6 +6731,10 @@ function createTask(options) {
6727
6731
  return warnings;
6728
6732
  // <- Note: [1] --||--
6729
6733
  },
6734
+ get llmCalls() {
6735
+ return llmCalls;
6736
+ // <- Note: [1] --||--
6737
+ },
6730
6738
  get currentValue() {
6731
6739
  return currentValue;
6732
6740
  // <- Note: [1] --||--
@@ -7445,6 +7453,18 @@ function templateParameters(template, parameters) {
7445
7453
  return replacedTemplates;
7446
7454
  }
7447
7455
 
7456
+ /**
7457
+ * Logs an LLM call with the given report.
7458
+ *
7459
+ * @private internal utility of `createPipelineExecutor`
7460
+ */
7461
+ function logLlmCall(logLlmCall, report) {
7462
+ logLlmCall({
7463
+ modelName: 'model' /* <- TODO: How to get model name from the report */,
7464
+ report,
7465
+ });
7466
+ }
7467
+
7448
7468
  /**
7449
7469
  * Executes a pipeline task with multiple attempts, including joker and retry logic. Handles different task types
7450
7470
  * (prompt, script, dialog, etc.), applies postprocessing, checks expectations, and updates the execution report.
@@ -7456,7 +7476,7 @@ function templateParameters(template, parameters) {
7456
7476
  */
7457
7477
  async function executeAttempts(options) {
7458
7478
  const { jokerParameterNames, priority, maxAttempts, // <- Note: [💂]
7459
- preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, } = options;
7479
+ preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, logLlmCall: logLlmCall$1, } = options;
7460
7480
  const $ongoingTaskResult = {
7461
7481
  $result: null,
7462
7482
  $resultString: null,
@@ -7704,14 +7724,10 @@ async function executeAttempts(options) {
7704
7724
  });
7705
7725
  }
7706
7726
  finally {
7707
- if (!isJokerAttempt &&
7708
- task.taskType === 'PROMPT_TASK' &&
7709
- $ongoingTaskResult.$prompt
7710
- // <- Note: [2] When some expected parameter is not defined, error will occur in templateParameters
7711
- // In that case we don’t want to make a report about it because it’s not a llm execution error
7712
- ) {
7713
- // TODO: [🧠] Maybe put other taskTypes into report
7714
- $executionReport.promptExecutions.push({
7727
+ if (!isJokerAttempt && task.taskType === 'PROMPT_TASK' && $ongoingTaskResult.$prompt) {
7728
+ // Note: [2] When some expected parameter is not defined, error will occur in templateParameters
7729
+ // In that case we don’t want to make a report about it because it’s not a llm execution error
7730
+ const executionPromptReport = {
7715
7731
  prompt: {
7716
7732
  ...$ongoingTaskResult.$prompt,
7717
7733
  // <- TODO: [🧠] How to pick everyhing except `pipelineUrl`
@@ -7720,7 +7736,11 @@ async function executeAttempts(options) {
7720
7736
  error: $ongoingTaskResult.$expectError === null
7721
7737
  ? undefined
7722
7738
  : serializeError($ongoingTaskResult.$expectError),
7723
- });
7739
+ };
7740
+ $executionReport.promptExecutions.push(executionPromptReport);
7741
+ if (logLlmCall$1) {
7742
+ logLlmCall(logLlmCall$1, executionPromptReport);
7743
+ }
7724
7744
  }
7725
7745
  }
7726
7746
  if ($ongoingTaskResult.$expectError !== null && attemptIndex === maxAttempts - 1) {
@@ -7785,9 +7805,9 @@ async function executeAttempts(options) {
7785
7805
  * @private internal utility of `createPipelineExecutor`
7786
7806
  */
7787
7807
  async function executeFormatSubvalues(options) {
7788
- const { task, jokerParameterNames, parameters, priority, csvSettings, onProgress, pipelineIdentification } = options;
7808
+ const { task, jokerParameterNames, parameters, priority, csvSettings, onProgress, logLlmCall, pipelineIdentification, } = options;
7789
7809
  if (task.foreach === undefined) {
7790
- return /* not await */ executeAttempts(options);
7810
+ return /* not await */ executeAttempts({ ...options, logLlmCall });
7791
7811
  }
7792
7812
  if (jokerParameterNames.length !== 0) {
7793
7813
  throw new UnexpectedError(spaceTrim((block) => `
@@ -8088,7 +8108,7 @@ async function getReservedParametersForTask(options) {
8088
8108
  * @private internal utility of `createPipelineExecutor`
8089
8109
  */
8090
8110
  async function executeTask(options) {
8091
- const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSuppressed, } = options;
8111
+ const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, logLlmCall, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSuppressed, } = options;
8092
8112
  const priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
8093
8113
  // Note: Check consistency of used and dependent parameters which was also done in `validatePipeline`, but it’s good to doublecheck
8094
8114
  const usedParameterNames = extractParameterNamesFromTask(currentTask);
@@ -8167,6 +8187,7 @@ async function executeTask(options) {
8167
8187
  tools,
8168
8188
  $executionReport,
8169
8189
  onProgress,
8190
+ logLlmCall,
8170
8191
  pipelineIdentification,
8171
8192
  maxExecutionAttempts,
8172
8193
  maxParallelCount,
@@ -8210,6 +8231,29 @@ function filterJustOutputParameters(options) {
8210
8231
  $warnings.push(new PipelineExecutionError(spaceTrim$1((block) => `
8211
8232
  Parameter \`{${parameter.name}}\` should be an output parameter, but it was not generated during pipeline execution
8212
8233
 
8234
+ Note: This is a warning which happened after the pipeline was executed, and \`{${parameter.name}}\` was not for some reason defined in output parameters
8235
+
8236
+ All parameters:
8237
+ ${block(preparedPipeline.parameters
8238
+ .map(({ name, isInput, isOutput, description }) => {
8239
+ let line = `\`{${name}}\``;
8240
+ if (isInput) {
8241
+ line += ' `[input parameter]`';
8242
+ }
8243
+ if (isOutput) {
8244
+ line += ' `[output parameter]`';
8245
+ }
8246
+ if (parametersToPass[name] === undefined) {
8247
+ line += ` <- Warning: Should be in the output but its not |`;
8248
+ }
8249
+ if (description) {
8250
+ line += ` ${description}`;
8251
+ }
8252
+ return line;
8253
+ })
8254
+ .map((line, index) => `${index + 1}) ${line}`)
8255
+ .join('\n'))}
8256
+
8213
8257
  ${block(pipelineIdentification)}
8214
8258
  `)));
8215
8259
  continue;
@@ -8230,7 +8274,7 @@ function filterJustOutputParameters(options) {
8230
8274
  * @private internal utility of `createPipelineExecutor`
8231
8275
  */
8232
8276
  async function executePipeline(options) {
8233
- const { inputParameters, tools, onProgress, pipeline, setPreparedPipeline, pipelineIdentification, maxParallelCount, rootDirname, isVerbose, } = options;
8277
+ const { inputParameters, tools, onProgress, logLlmCall, pipeline, setPreparedPipeline, pipelineIdentification, maxParallelCount, rootDirname, isVerbose, } = options;
8234
8278
  let { preparedPipeline } = options;
8235
8279
  if (preparedPipeline === undefined) {
8236
8280
  preparedPipeline = await preparePipeline(pipeline, tools, {
@@ -8408,6 +8452,7 @@ async function executePipeline(options) {
8408
8452
  onProgress(newOngoingResult);
8409
8453
  }
8410
8454
  },
8455
+ logLlmCall,
8411
8456
  $executionReport: executionReport,
8412
8457
  pipelineIdentification: spaceTrim$1((block) => `
8413
8458
  ${block(pipelineIdentification)}
@@ -8531,7 +8576,7 @@ function createPipelineExecutor(options) {
8531
8576
  // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
8532
8577
  }
8533
8578
  let runCount = 0;
8534
- const pipelineExecutorWithCallback = async (inputParameters, onProgress) => {
8579
+ const pipelineExecutorWithCallback = async (inputParameters, onProgress, logLlmCall) => {
8535
8580
  runCount++;
8536
8581
  return /* not await */ executePipeline({
8537
8582
  pipeline,
@@ -8542,6 +8587,7 @@ function createPipelineExecutor(options) {
8542
8587
  inputParameters,
8543
8588
  tools,
8544
8589
  onProgress,
8590
+ logLlmCall,
8545
8591
  pipelineIdentification: spaceTrim$1((block) => `
8546
8592
  ${block(pipelineIdentification)}
8547
8593
  ${runCount === 1 ? '' : `Run #${runCount}`}
@@ -16003,10 +16049,10 @@ function startRemoteServer(options) {
16003
16049
  .send({ error: serializeError(error) });
16004
16050
  }
16005
16051
  });
16006
- function exportExecutionTask(executionTask, isFull) {
16052
+ function exportExecutionTask(executionTask, isDetailed) {
16007
16053
  // <- TODO: [🧠] This should be maybe method of `ExecutionTask` itself
16008
- const { taskType, promptbookVersion, taskId, title, status, errors, tldr, warnings, createdAt, updatedAt, currentValue, } = executionTask;
16009
- if (isFull) {
16054
+ const { taskType, promptbookVersion, taskId, title, status, errors, tldr, warnings, createdAt, updatedAt, currentValue, llmCalls, } = executionTask;
16055
+ if (isDetailed) {
16010
16056
  return {
16011
16057
  taskId,
16012
16058
  title,
@@ -16016,9 +16062,11 @@ function startRemoteServer(options) {
16016
16062
  tldr,
16017
16063
  errors: errors.map(serializeError),
16018
16064
  warnings: warnings.map(serializeError),
16065
+ llmCalls,
16019
16066
  createdAt,
16020
16067
  updatedAt,
16021
16068
  currentValue,
16069
+ nonce: 0,
16022
16070
  };
16023
16071
  }
16024
16072
  else {
@@ -16031,6 +16079,8 @@ function startRemoteServer(options) {
16031
16079
  tldr,
16032
16080
  createdAt,
16033
16081
  updatedAt,
16082
+ llmCalls,
16083
+ nonce: 0,
16034
16084
  };
16035
16085
  }
16036
16086
  }
@@ -16347,7 +16397,7 @@ function $initializeStartServerCommand(program) {
16347
16397
  // <- TODO: [🍖] Add `intermediateFilesStrategy`
16348
16398
  });
16349
16399
  // console.log(path, await collection.listPipelines());
16350
- console.log({ isRichUi });
16400
+ // console.log({ isRichUi });
16351
16401
  const server = startRemoteServer({
16352
16402
  port,
16353
16403
  isRichUi,
@@ -21880,170 +21930,2809 @@ const $bookTranspilersRegister = new $Register('book_transpilers');
21880
21930
  */
21881
21931
 
21882
21932
  /**
21883
- * Transpiler to Python code using LangChain library.
21933
+ * Creates an empty/basic agent model requirements object
21934
+ * This serves as the starting point for the reduce-like pattern
21935
+ * where each commitment applies its changes to build the final requirements
21884
21936
  *
21885
- * @private TODO: !!!! Which package should export this?
21937
+ * @public exported from `@promptbook/core`
21938
+ */
21939
+ function createEmptyAgentModelRequirements() {
21940
+ return {
21941
+ systemMessage: '',
21942
+ // modelName: 'gpt-5',
21943
+ modelName: 'gemini-2.5-flash-lite',
21944
+ temperature: 0.7,
21945
+ topP: 0.9,
21946
+ topK: 50,
21947
+ };
21948
+ }
21949
+ /**
21950
+ * Creates a basic agent model requirements with just the agent name
21951
+ * This is used when we have an agent name but no commitments
21952
+ *
21953
+ * @public exported from `@promptbook/core`
21954
+ */
21955
+ function createBasicAgentModelRequirements(agentName) {
21956
+ const empty = createEmptyAgentModelRequirements();
21957
+ return {
21958
+ ...empty,
21959
+ systemMessage: `You are ${agentName || 'AI Agent'}`,
21960
+ };
21961
+ }
21962
+ /**
21963
+ * TODO: [🐤] Deduplicate `AgentModelRequirements` and `ModelRequirements` model requirements
21886
21964
  */
21887
- const LangchainTranspiler = {
21888
- name: 'langchain',
21889
- title: 'LangChain',
21890
- // TODO: [🧠] packageName and className
21891
- packageName: '@promptbook/langchain-transpiler',
21892
- className: 'LangchainTranspiler',
21893
- new: (tools) => async (book, _options) => {
21894
- const pipeline = await compilePipeline(book, tools);
21895
- const anouncement = spaceTrim$1(() => `
21896
- """
21897
- This code was generated by Promptbook
21898
- @see https://promptbook.studio
21899
-
21900
- From book: ${pipeline.pipelineUrl}
21901
-
21902
- WARNING: This code is experimental and may not work as expected.
21903
- """
21904
- `);
21905
- const imports = spaceTrim$1(() => `
21906
- from langchain_openai import ChatOpenAI
21907
- from langchain_core.prompts import ChatPromptTemplate
21908
- `);
21909
- const functions = pipeline.tasks.map((template) => transpileTemplate$1(template, pipeline));
21910
- return spaceTrim$1(() => `
21911
- ${anouncement}
21912
21965
 
21913
- ${imports}
21966
+ /**
21967
+ * Generates a regex pattern to match a specific commitment
21968
+ *
21969
+ * Note: It always creates new Regex object
21970
+ * Note: Uses word boundaries to ensure only full words are matched (e.g., "PERSONA" matches but "PERSONALITY" does not)
21971
+ *
21972
+ * @private - TODO: [🧠] Maybe should be public?
21973
+ */
21974
+ function createCommitmentRegex(commitment) {
21975
+ const escapedCommitment = commitment.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
21976
+ const keywordPattern = escapedCommitment.split(/\s+/).join('\\s+');
21977
+ const regex = new RegExp(`^\\s*(?<type>${keywordPattern})\\b\\s+(?<contents>.+)$`, 'gim');
21978
+ return regex;
21979
+ }
21980
+ /**
21981
+ * Generates a regex pattern to match a specific commitment type
21982
+ *
21983
+ * Note: It just matches the type part of the commitment
21984
+ * Note: It always creates new Regex object
21985
+ * Note: Uses word boundaries to ensure only full words are matched (e.g., "PERSONA" matches but "PERSONALITY" does not)
21986
+ *
21987
+ * @private
21988
+ */
21989
+ function createCommitmentTypeRegex(commitment) {
21990
+ const escapedCommitment = commitment.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
21991
+ const keywordPattern = escapedCommitment.split(/\s+/).join('\\s+');
21992
+ const regex = new RegExp(`^\\s*(?<type>${keywordPattern})\\b`, 'gim');
21993
+ return regex;
21994
+ }
21914
21995
 
21915
- ${functions.join('\n\n')}
21916
- `);
21917
- },
21918
- };
21919
- function transpileTemplate$1(template, pipeline) {
21920
- // TODO: Better template type detection
21921
- if (template.taskType === 'PROMPT_TEMPLATE' &&
21922
- template.modelRequirements.modelVariant === 'CHAT') {
21923
- // TODO: DRY
21924
- const functionName = template.name;
21925
- const parameters = pipeline.parameters.filter((parameter) => parameter.isInput);
21926
- const parameterNames = parameters.map((parameter) => parameter.name);
21927
- const parameterNamesAndTypes = parameterNames.map((name) => `${name}: str`).join(', ');
21928
- const interpolatedContent = interpolateTemplate$1(template.content, parameterNames);
21929
- return spaceTrim$1(() => `
21930
- def ${functionName}(${parameterNamesAndTypes}):
21931
- chat = ChatOpenAI(model="${template.modelRequirements.modelName}", temperature=0.7)
21932
- prompt = ChatPromptTemplate.from_messages([
21933
- ("human", ${interpolatedContent})
21934
- ])
21935
- chain = prompt | chat
21936
- return chain.invoke({${parameterNames.map((name) => `'${name}': ${name}`).join(', ')}})
21937
- `);
21996
+ /**
21997
+ * Base implementation of CommitmentDefinition that provides common functionality
21998
+ * Most commitments can extend this class and only override the applyToAgentModelRequirements method
21999
+ *
22000
+ * @private
22001
+ */
22002
+ class BaseCommitmentDefinition {
22003
+ constructor(type) {
22004
+ this.type = type;
21938
22005
  }
21939
- else {
21940
- return `# TODO: ${template.taskType} templates are not implemented yet`;
22006
+ /**
22007
+ * Creates a regex pattern to match this commitment in agent source
22008
+ * Uses the existing createCommitmentRegex function as internal helper
22009
+ */
22010
+ createRegex() {
22011
+ return createCommitmentRegex(this.type);
22012
+ }
22013
+ /**
22014
+ * Creates a regex pattern to match just the commitment type
22015
+ * Uses the existing createCommitmentTypeRegex function as internal helper
22016
+ */
22017
+ createTypeRegex() {
22018
+ return createCommitmentTypeRegex(this.type);
22019
+ }
22020
+ /**
22021
+ * Helper method to create a new requirements object with updated system message
22022
+ * This is commonly used by many commitments
22023
+ */
22024
+ updateSystemMessage(requirements, messageUpdate) {
22025
+ const newMessage = typeof messageUpdate === 'string' ? messageUpdate : messageUpdate(requirements.systemMessage);
22026
+ return {
22027
+ ...requirements,
22028
+ systemMessage: newMessage,
22029
+ };
22030
+ }
22031
+ /**
22032
+ * Helper method to append content to the system message
22033
+ */
22034
+ appendToSystemMessage(requirements, content, separator = '\n\n') {
22035
+ return this.updateSystemMessage(requirements, (currentMessage) => {
22036
+ if (!currentMessage.trim()) {
22037
+ return content;
22038
+ }
22039
+ return currentMessage + separator + content;
22040
+ });
22041
+ }
22042
+ /**
22043
+ * Helper method to add a comment section to the system message
22044
+ * Comments are lines starting with # that will be removed from the final system message
22045
+ * but can be useful for organizing and structuring the message during processing
22046
+ */
22047
+ addCommentSection(requirements, commentTitle, content, position = 'end') {
22048
+ const commentSection = `# ${commentTitle.toUpperCase()}\n${content}`;
22049
+ if (position === 'beginning') {
22050
+ return this.updateSystemMessage(requirements, (currentMessage) => {
22051
+ if (!currentMessage.trim()) {
22052
+ return commentSection;
22053
+ }
22054
+ return commentSection + '\n\n' + currentMessage;
22055
+ });
22056
+ }
22057
+ else {
22058
+ return this.appendToSystemMessage(requirements, commentSection);
22059
+ }
21941
22060
  }
21942
22061
  }
21943
- function interpolateTemplate$1(template, parameterNames) {
21944
- let result = template;
21945
- for (const parameterName of parameterNames) {
21946
- result = result.replace(new RegExp(`{${parameterName}}`, 'g'), `{${parameterName}}`);
22062
+
22063
+ /**
22064
+ * ACTION commitment definition
22065
+ *
22066
+ * The ACTION commitment defines specific actions or capabilities that the agent can perform.
22067
+ * This helps define what the agent is capable of doing and how it should approach tasks.
22068
+ *
22069
+ * Example usage in agent source:
22070
+ *
22071
+ * ```book
22072
+ * ACTION Can generate code snippets and explain programming concepts
22073
+ * ACTION Able to analyze data and provide insights
22074
+ * ```
22075
+ *
22076
+ * @private [🪔] Maybe export the commitments through some package
22077
+ */
22078
+ class ActionCommitmentDefinition extends BaseCommitmentDefinition {
22079
+ constructor(type = 'ACTION') {
22080
+ super(type);
22081
+ }
22082
+ /**
22083
+ * Short one-line description of ACTION.
22084
+ */
22085
+ get description() {
22086
+ return 'Define agent capabilities and actions it can perform.';
22087
+ }
22088
+ /**
22089
+ * Markdown documentation for ACTION commitment.
22090
+ */
22091
+ get documentation() {
22092
+ return spaceTrim$1(`
22093
+ # ${this.type}
22094
+
22095
+ Defines specific actions or capabilities that the agent can perform.
22096
+
22097
+ ## Key aspects
22098
+
22099
+ - Both terms work identically and can be used interchangeably.
22100
+ - Each action adds to the agent's capability list.
22101
+ - Actions help users understand what the agent can do.
22102
+
22103
+ ## Examples
22104
+
22105
+ \`\`\`book
22106
+ Code Assistant
22107
+
22108
+ PERSONA You are a programming assistant
22109
+ ACTION Can generate code snippets and explain programming concepts
22110
+ ACTION Able to debug existing code and suggest improvements
22111
+ ACTION Can create unit tests for functions
22112
+ \`\`\`
22113
+
22114
+ \`\`\`book
22115
+ Data Scientist
22116
+
22117
+ PERSONA You are a data analysis expert
22118
+ ACTION Able to analyze data and provide insights
22119
+ ACTION Can create visualizations and charts
22120
+ ACTION Capable of statistical analysis and modeling
22121
+ KNOWLEDGE Data analysis best practices and statistical methods
22122
+ \`\`\`
22123
+ `);
22124
+ }
22125
+ applyToAgentModelRequirements(requirements, content) {
22126
+ const trimmedContent = content.trim();
22127
+ if (!trimmedContent) {
22128
+ return requirements;
22129
+ }
22130
+ // Add action capability to the system message
22131
+ const actionSection = `Capability: ${trimmedContent}`;
22132
+ return this.appendToSystemMessage(requirements, actionSection, '\n\n');
21947
22133
  }
21948
- return `f"${result}"`;
21949
22134
  }
22135
+ /**
22136
+ * Note: [💞] Ignore a discrepancy between file name and entity name
22137
+ */
21950
22138
 
21951
22139
  /**
21952
- * Registration of LLM provider
22140
+ * DELETE commitment definition
21953
22141
  *
21954
- * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available LLM tools
22142
+ * The DELETE commitment (and its aliases CANCEL, DISCARD, REMOVE) is used to
22143
+ * remove or disregard certain information or context. This can be useful for
22144
+ * overriding previous commitments or removing unwanted behaviors.
21955
22145
  *
21956
- * @public exported from `@promptbook/wizard`
21957
- * @public exported from `@promptbook/cli`
22146
+ * Example usage in agent source:
21958
22147
  *
21959
- * TODO: !!!! Which package should export this?
22148
+ * ```book
22149
+ * DELETE Previous formatting requirements
22150
+ * CANCEL All emotional responses
22151
+ * DISCARD Technical jargon explanations
22152
+ * REMOVE Casual conversational style
22153
+ * ```
22154
+ *
22155
+ * @private [🪔] Maybe export the commitments through some package
21960
22156
  */
21961
- const _LangchainTranspilerRegistration = $bookTranspilersRegister.register(LangchainTranspiler);
22157
+ class DeleteCommitmentDefinition extends BaseCommitmentDefinition {
22158
+ constructor(type) {
22159
+ super(type);
22160
+ }
22161
+ /**
22162
+ * Short one-line description of DELETE/CANCEL/DISCARD/REMOVE.
22163
+ */
22164
+ get description() {
22165
+ return 'Remove or **disregard** certain information, context, or previous commitments.';
22166
+ }
22167
+ /**
22168
+ * Markdown documentation for DELETE commitment.
22169
+ */
22170
+ get documentation() {
22171
+ return spaceTrim$1(`
22172
+ # DELETE (CANCEL, DISCARD, REMOVE)
22173
+
22174
+ A commitment to remove or disregard certain information or context. This can be useful for overriding previous commitments or removing unwanted behaviors.
22175
+
22176
+ ## Aliases
22177
+
22178
+ - \`DELETE\` - Remove or eliminate something
22179
+ - \`CANCEL\` - Cancel or nullify something
22180
+ - \`DISCARD\` - Discard or ignore something
22181
+ - \`REMOVE\` - Remove or take away something
22182
+
22183
+ ## Key aspects
22184
+
22185
+ - Multiple delete commitments can be used to remove different aspects.
22186
+ - Useful for overriding previous commitments in the same agent definition.
22187
+ - Can be used to remove inherited behaviors from base personas.
22188
+ - Helps fine-tune agent behavior by explicitly removing unwanted elements.
22189
+
22190
+ ## Use cases
22191
+
22192
+ - Overriding inherited persona characteristics
22193
+ - Removing conflicting or outdated instructions
22194
+ - Disabling specific response patterns
22195
+ - Canceling previous formatting or style requirements
22196
+
22197
+ ## Examples
22198
+
22199
+ \`\`\`book
22200
+ Serious Business Assistant
22201
+
22202
+ PERSONA You are a friendly and casual assistant who uses emojis
22203
+ DELETE Casual conversational style
22204
+ REMOVE All emoji usage
22205
+ GOAL Provide professional business communications
22206
+ STYLE Use formal language and proper business etiquette
22207
+ \`\`\`
22208
+
22209
+ \`\`\`book
22210
+ Simplified Technical Support
22211
+
22212
+ PERSONA You are a technical support specialist with deep expertise
22213
+ KNOWLEDGE Extensive database of technical specifications
22214
+ DISCARD Technical jargon explanations
22215
+ CANCEL Advanced troubleshooting procedures
22216
+ GOAL Help users with simple, easy-to-follow solutions
22217
+ STYLE Use plain language that anyone can understand
22218
+ \`\`\`
22219
+
22220
+ \`\`\`book
22221
+ Focused Customer Service
22222
+
22223
+ PERSONA You are a customer service agent with broad knowledge
22224
+ ACTION Can help with billing, technical issues, and product information
22225
+ DELETE Billing assistance capabilities
22226
+ REMOVE Technical troubleshooting functions
22227
+ GOAL Focus exclusively on product information and general inquiries
22228
+ \`\`\`
22229
+
22230
+ \`\`\`book
22231
+ Concise Information Provider
22232
+
22233
+ PERSONA You are a helpful assistant who provides detailed explanations
22234
+ STYLE Include examples, analogies, and comprehensive context
22235
+ CANCEL Detailed explanation style
22236
+ DISCARD Examples and analogies
22237
+ GOAL Provide brief, direct answers without unnecessary elaboration
22238
+ STYLE Be concise and to the point
22239
+ \`\`\`
22240
+ `);
22241
+ }
22242
+ applyToAgentModelRequirements(requirements, content) {
22243
+ const trimmedContent = content.trim();
22244
+ if (!trimmedContent) {
22245
+ return requirements;
22246
+ }
22247
+ // Create deletion instruction for system message
22248
+ const deleteSection = `${this.type}: ${trimmedContent}`;
22249
+ // Delete instructions provide important context about what should be removed or ignored
22250
+ return this.appendToSystemMessage(requirements, deleteSection, '\n\n');
22251
+ }
22252
+ }
21962
22253
  /**
21963
22254
  * Note: [💞] Ignore a discrepancy between file name and entity name
21964
22255
  */
21965
22256
 
21966
22257
  /**
21967
- * Transpiler to Javascript code using OpenAI SDK.
22258
+ * FORMAT commitment definition
22259
+ *
22260
+ * The FORMAT commitment defines the specific output structure and formatting
22261
+ * that the agent should use in its responses. This includes data formats,
22262
+ * response templates, and structural requirements.
22263
+ *
22264
+ * Example usage in agent source:
21968
22265
  *
21969
- * @private TODO: !!!! Which package should export this?
22266
+ * ```book
22267
+ * FORMAT Always respond in JSON format with 'status' and 'data' fields
22268
+ * FORMAT Use markdown formatting for all code blocks
22269
+ * ```
22270
+ *
22271
+ * @private [🪔] Maybe export the commitments through some package
21970
22272
  */
21971
- const OpenAiSdkTranspiler = {
21972
- name: 'openai-sdk',
21973
- title: 'OpenAI SDK',
21974
- // TODO: [🧠] packageName and className
21975
- packageName: '@promptbook/openai-sdk-transpiler',
21976
- className: 'OpenAiSdkTranspiler',
21977
- new: (tools) => async (book, _options) => {
21978
- const pipeline = await compilePipeline(book, tools);
21979
- const anouncement = spaceTrim$1(() => `
21980
- /**
21981
- * This code was generated by Promptbook
21982
- * @see https://promptbook.studio
21983
- *
21984
- * From book: ${pipeline.pipelineUrl}
21985
- *
21986
- * WARNING: This code is experimental and may not work as expected.
21987
- */
21988
- `);
21989
- const imports = spaceTrim$1(() => `
21990
- import { OpenAI } from 'openai';
21991
- `);
21992
- const functions = pipeline.tasks.map((template) => transpileTemplate(template, pipeline));
21993
- return spaceTrim$1(() => `
21994
- ${anouncement}
22273
+ class FormatCommitmentDefinition extends BaseCommitmentDefinition {
22274
+ constructor(type = 'FORMAT') {
22275
+ super(type);
22276
+ }
22277
+ /**
22278
+ * Short one-line description of FORMAT.
22279
+ */
22280
+ get description() {
22281
+ return 'Specify output structure or formatting requirements.';
22282
+ }
22283
+ /**
22284
+ * Markdown documentation for FORMAT commitment.
22285
+ */
22286
+ get documentation() {
22287
+ return spaceTrim$1(`
22288
+ # ${this.type}
21995
22289
 
21996
- ${imports}
22290
+ Defines the specific output structure and formatting for responses (data formats, templates, structure).
21997
22291
 
21998
- ${functions.join('\n\n')}
21999
- `);
22000
- },
22001
- };
22002
- function transpileTemplate(template, pipeline) {
22003
- // TODO: Better template type detection
22004
- if (template.taskType === 'PROMPT_TEMPLATE' &&
22005
- template.modelRequirements.modelVariant === 'CHAT') {
22006
- // TODO: DRY
22007
- const functionName = template.name;
22008
- const parameters = pipeline.parameters.filter((parameter) => parameter.isInput);
22009
- const parameterNames = parameters.map((parameter) => parameter.name);
22010
- const parameterNamesAndTypes = parameterNames.map((name) => `${name}: string`).join(', ');
22011
- const interpolatedContent = interpolateTemplate(template.content, parameterNames);
22012
- return spaceTrim$1(() => `
22013
- export async function ${functionName}({ ${parameterNames.join(', ')} }: { ${parameterNamesAndTypes} }) {
22014
- const openai = new OpenAI({
22015
- apiKey: process.env.OPENAI_API_KEY,
22016
- });
22017
- const chatCompletion = await openai.chat.completions.create({
22018
- messages: [
22019
- {
22020
- role: 'user',
22021
- content: ${interpolatedContent},
22022
- },
22023
- ],
22024
- model: '${template.modelRequirements.modelName}',
22025
- });
22026
- return chatCompletion.choices[0].message.content;
22027
- }
22028
- `);
22292
+ ## Key aspects
22293
+
22294
+ - Both terms work identically and can be used interchangeably.
22295
+ - If they are in conflict, the last one takes precedence.
22296
+ - You can specify both data formats and presentation styles.
22297
+
22298
+ ## Examples
22299
+
22300
+ \`\`\`book
22301
+ Customer Support Bot
22302
+
22303
+ PERSONA You are a helpful customer support agent
22304
+ FORMAT Always respond in JSON format with 'status' and 'data' fields
22305
+ FORMAT Use markdown formatting for all code blocks
22306
+ \`\`\`
22307
+
22308
+ \`\`\`book
22309
+ Data Analyst
22310
+
22311
+ PERSONA You are a data analysis expert
22312
+ FORMAT Present results in structured tables
22313
+ FORMAT Include confidence scores for all predictions
22314
+ STYLE Be concise and precise in explanations
22315
+ \`\`\`
22316
+ `);
22029
22317
  }
22030
- else {
22031
- return `// TODO: ${template.taskType} templates are not implemented yet`;
22318
+ applyToAgentModelRequirements(requirements, content) {
22319
+ const trimmedContent = content.trim();
22320
+ if (!trimmedContent) {
22321
+ return requirements;
22322
+ }
22323
+ // Add format instructions to the system message
22324
+ const formatSection = `Output Format: ${trimmedContent}`;
22325
+ return this.appendToSystemMessage(requirements, formatSection, '\n\n');
22032
22326
  }
22033
22327
  }
22034
- function interpolateTemplate(template, parameterNames) {
22035
- let result = template;
22036
- for (const parameterName of parameterNames) {
22037
- result = result.replace(new RegExp(`{${parameterName}}`, 'g'), `\${${parameterName}}`);
22328
+ /**
22329
+ * Note: [💞] Ignore a discrepancy between file name and entity name
22330
+ */
22331
+
22332
+ /**
22333
+ * GOAL commitment definition
22334
+ *
22335
+ * The GOAL commitment defines the main goal which should be achieved by the AI assistant.
22336
+ * There can be multiple goals. Later goals are more important than earlier goals.
22337
+ *
22338
+ * Example usage in agent source:
22339
+ *
22340
+ * ```book
22341
+ * GOAL Help users understand complex technical concepts
22342
+ * GOAL Provide accurate and up-to-date information
22343
+ * GOAL Always prioritize user safety and ethical guidelines
22344
+ * ```
22345
+ *
22346
+ * @private [🪔] Maybe export the commitments through some package
22347
+ */
22348
+ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
22349
+ constructor(type = 'GOAL') {
22350
+ super(type);
22351
+ }
22352
+ /**
22353
+ * Short one-line description of GOAL.
22354
+ */
22355
+ get description() {
22356
+ return 'Define main **goals** the AI assistant should achieve, with later goals having higher priority.';
22357
+ }
22358
+ /**
22359
+ * Markdown documentation for GOAL commitment.
22360
+ */
22361
+ get documentation() {
22362
+ return spaceTrim$1(`
22363
+ # ${this.type}
22364
+
22365
+ 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.
22366
+
22367
+ ## Key aspects
22368
+
22369
+ - Both terms work identically and can be used interchangeably.
22370
+ - Later goals have higher priority and can override earlier goals.
22371
+ - Goals provide clear direction and purpose for the agent's responses.
22372
+ - Goals influence decision-making and response prioritization.
22373
+
22374
+ ## Priority system
22375
+
22376
+ When multiple goals are defined, they are processed in order, with later goals taking precedence over earlier ones when there are conflicts.
22377
+
22378
+ ## Examples
22379
+
22380
+ \`\`\`book
22381
+ Customer Support Agent
22382
+
22383
+ PERSONA You are a helpful customer support representative
22384
+ GOAL Resolve customer issues quickly and efficiently
22385
+ GOAL Maintain high customer satisfaction scores
22386
+ GOAL Always follow company policies and procedures
22387
+ RULE Be polite and professional at all times
22388
+ \`\`\`
22389
+
22390
+ \`\`\`book
22391
+ Educational Assistant
22392
+
22393
+ PERSONA You are an educational assistant specializing in mathematics
22394
+ GOAL Help students understand mathematical concepts clearly
22395
+ GOAL Encourage critical thinking and problem-solving skills
22396
+ GOAL Ensure all explanations are age-appropriate and accessible
22397
+ STYLE Use simple language and provide step-by-step explanations
22398
+ \`\`\`
22399
+
22400
+ \`\`\`book
22401
+ Safety-First Assistant
22402
+
22403
+ PERSONA You are a general-purpose AI assistant
22404
+ GOAL Be helpful and informative in all interactions
22405
+ GOAL Provide accurate and reliable information
22406
+ GOAL Always prioritize user safety and ethical guidelines
22407
+ RULE Never provide harmful or dangerous advice
22408
+ \`\`\`
22409
+ `);
22410
+ }
22411
+ applyToAgentModelRequirements(requirements, content) {
22412
+ const trimmedContent = content.trim();
22413
+ if (!trimmedContent) {
22414
+ return requirements;
22415
+ }
22416
+ // Create goal section for system message
22417
+ const goalSection = `Goal: ${trimmedContent}`;
22418
+ // Goals are important directives, so we add them prominently to the system message
22419
+ return this.appendToSystemMessage(requirements, goalSection, '\n\n');
22038
22420
  }
22039
- return `\`${result}\``;
22040
22421
  }
22041
22422
  /**
22042
- * TODO: [🧠] What should be the scope of the transpiled code?
22043
- * - Just a single function?
22044
- * - A class?
22045
- * - A whole package?
22423
+ * Note: [💞] Ignore a discrepancy between file name and entity name
22424
+ */
22425
+
22426
+ /**
22427
+ * KNOWLEDGE commitment definition
22428
+ *
22429
+ * The KNOWLEDGE commitment adds specific knowledge, facts, or context to the agent
22430
+ * using RAG (Retrieval-Augmented Generation) approach for external sources.
22431
+ *
22432
+ * Supports both direct text knowledge and external sources like PDFs.
22433
+ *
22434
+ * Example usage in agent source:
22435
+ *
22436
+ * ```book
22437
+ * KNOWLEDGE The company was founded in 2020 and specializes in AI-powered solutions
22438
+ * KNOWLEDGE https://example.com/company-handbook.pdf
22439
+ * KNOWLEDGE https://example.com/product-documentation.pdf
22440
+ * ```
22441
+ *
22442
+ * @private [🪔] Maybe export the commitments through some package
22046
22443
  */
22444
+ class KnowledgeCommitmentDefinition extends BaseCommitmentDefinition {
22445
+ constructor() {
22446
+ super('KNOWLEDGE');
22447
+ }
22448
+ /**
22449
+ * Short one-line description of KNOWLEDGE.
22450
+ */
22451
+ get description() {
22452
+ return 'Add domain **knowledge** via direct text or external sources (RAG).';
22453
+ }
22454
+ /**
22455
+ * Markdown documentation for KNOWLEDGE commitment.
22456
+ */
22457
+ get documentation() {
22458
+ return spaceTrim$1(`
22459
+ # ${this.type}
22460
+
22461
+ Adds specific knowledge, facts, or context to the agent using a RAG (Retrieval-Augmented Generation) approach for external sources.
22462
+
22463
+ ## Key aspects
22464
+
22465
+ - Both terms work identically and can be used interchangeably.
22466
+ - Supports both direct text knowledge and external URLs.
22467
+ - External sources (PDFs, websites) are processed via RAG for context retrieval.
22468
+
22469
+ ## Supported formats
22470
+
22471
+ - Direct text: Immediate knowledge incorporated into agent
22472
+ - URLs: External documents processed for contextual retrieval
22473
+ - Supported file types: PDF, text, markdown, HTML
22474
+
22475
+ ## Examples
22476
+
22477
+ \`\`\`book
22478
+ Customer Support Bot
22479
+
22480
+ PERSONA You are a helpful customer support agent for TechCorp
22481
+ KNOWLEDGE TechCorp was founded in 2020 and specializes in AI-powered solutions
22482
+ KNOWLEDGE https://example.com/company-handbook.pdf
22483
+ KNOWLEDGE https://example.com/product-documentation.pdf
22484
+ RULE Always be polite and professional
22485
+ \`\`\`
22486
+
22487
+ \`\`\`book
22488
+ Research Assistant
22489
+
22490
+ PERSONA You are a knowledgeable research assistant
22491
+ KNOWLEDGE Academic research requires careful citation and verification
22492
+ KNOWLEDGE https://example.com/research-guidelines.pdf
22493
+ ACTION Can help with literature reviews and data analysis
22494
+ STYLE Present information in clear, academic format
22495
+ \`\`\`
22496
+ `);
22497
+ }
22498
+ applyToAgentModelRequirements(requirements, content) {
22499
+ var _a;
22500
+ const trimmedContent = content.trim();
22501
+ if (!trimmedContent) {
22502
+ return requirements;
22503
+ }
22504
+ // Check if content is a URL (external knowledge source)
22505
+ if (this.isUrl(trimmedContent)) {
22506
+ // Store the URL for later async processing
22507
+ const updatedRequirements = {
22508
+ ...requirements,
22509
+ metadata: {
22510
+ ...requirements.metadata,
22511
+ knowledgeSources: [
22512
+ ...(((_a = requirements.metadata) === null || _a === void 0 ? void 0 : _a.knowledgeSources) || []),
22513
+ trimmedContent,
22514
+ ],
22515
+ },
22516
+ };
22517
+ // Add placeholder information about knowledge sources to system message
22518
+ const knowledgeInfo = `Knowledge Source URL: ${trimmedContent} (will be processed for retrieval during chat)`;
22519
+ return this.appendToSystemMessage(updatedRequirements, knowledgeInfo, '\n\n');
22520
+ }
22521
+ else {
22522
+ // Direct text knowledge - add to system message
22523
+ const knowledgeSection = `Knowledge: ${trimmedContent}`;
22524
+ return this.appendToSystemMessage(requirements, knowledgeSection, '\n\n');
22525
+ }
22526
+ }
22527
+ /**
22528
+ * Check if content is a URL
22529
+ */
22530
+ isUrl(content) {
22531
+ try {
22532
+ new URL(content);
22533
+ return true;
22534
+ }
22535
+ catch (_a) {
22536
+ return false;
22537
+ }
22538
+ }
22539
+ }
22540
+ /**
22541
+ * Note: [💞] Ignore a discrepancy between file name and entity name
22542
+ */
22543
+
22544
+ /**
22545
+ * MEMORY commitment definition
22546
+ *
22547
+ * The MEMORY commitment is similar to KNOWLEDGE but has a focus on remembering past
22548
+ * interactions and user preferences. It helps the agent maintain context about the
22549
+ * user's history, preferences, and previous conversations.
22550
+ *
22551
+ * Example usage in agent source:
22552
+ *
22553
+ * ```book
22554
+ * MEMORY User prefers detailed technical explanations
22555
+ * MEMORY Previously worked on React projects
22556
+ * MEMORY Timezone: UTC-5 (Eastern Time)
22557
+ * ```
22558
+ *
22559
+ * @private [🪔] Maybe export the commitments through some package
22560
+ */
22561
+ class MemoryCommitmentDefinition extends BaseCommitmentDefinition {
22562
+ constructor(type = 'MEMORY') {
22563
+ super(type);
22564
+ }
22565
+ /**
22566
+ * Short one-line description of MEMORY.
22567
+ */
22568
+ get description() {
22569
+ return 'Remember past interactions and user **preferences** for personalized responses.';
22570
+ }
22571
+ /**
22572
+ * Markdown documentation for MEMORY commitment.
22573
+ */
22574
+ get documentation() {
22575
+ return spaceTrim$1(`
22576
+ # ${this.type}
22577
+
22578
+ 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.
22579
+
22580
+ ## Key aspects
22581
+
22582
+ - Both terms work identically and can be used interchangeably.
22583
+ - Focuses on user-specific information and interaction history.
22584
+ - Helps personalize responses based on past interactions.
22585
+ - Maintains continuity across conversations.
22586
+
22587
+ ## Differences from KNOWLEDGE
22588
+
22589
+ - \`KNOWLEDGE\` is for domain expertise and factual information
22590
+ - \`MEMORY\` is for user-specific context and preferences
22591
+ - \`MEMORY\` creates more personalized interactions
22592
+ - \`MEMORY\` often includes temporal or preference-based information
22593
+
22594
+ ## Examples
22595
+
22596
+ \`\`\`book
22597
+ Personal Assistant
22598
+
22599
+ PERSONA You are a personal productivity assistant
22600
+ MEMORY User is a software developer working in JavaScript/React
22601
+ MEMORY User prefers morning work sessions and afternoon meetings
22602
+ MEMORY Previously helped with project planning for mobile apps
22603
+ MEMORY User timezone: UTC-8 (Pacific Time)
22604
+ GOAL Help optimize daily productivity and workflow
22605
+ \`\`\`
22606
+
22607
+ \`\`\`book
22608
+ Learning Companion
22609
+
22610
+ PERSONA You are an educational companion for programming students
22611
+ MEMORY Student is learning Python as their first programming language
22612
+ MEMORY Previous topics covered: variables, loops, functions
22613
+ MEMORY Student learns best with practical examples and exercises
22614
+ MEMORY Last session: working on list comprehensions
22615
+ GOAL Provide progressive learning experiences tailored to student's pace
22616
+ \`\`\`
22617
+
22618
+ \`\`\`book
22619
+ Customer Support Agent
22620
+
22621
+ PERSONA You are a customer support representative
22622
+ MEMORY Customer has premium subscription since 2023
22623
+ MEMORY Previous issue: billing question resolved last month
22624
+ MEMORY Customer prefers email communication over phone calls
22625
+ MEMORY Account shows frequent use of advanced features
22626
+ GOAL Provide personalized support based on customer history
22627
+ \`\`\`
22628
+ `);
22629
+ }
22630
+ applyToAgentModelRequirements(requirements, content) {
22631
+ const trimmedContent = content.trim();
22632
+ if (!trimmedContent) {
22633
+ return requirements;
22634
+ }
22635
+ // Create memory section for system message
22636
+ const memorySection = `Memory: ${trimmedContent}`;
22637
+ // Memory information is contextual and should be included in the system message
22638
+ return this.appendToSystemMessage(requirements, memorySection, '\n\n');
22639
+ }
22640
+ }
22641
+ /**
22642
+ * Note: [💞] Ignore a discrepancy between file name and entity name
22643
+ */
22644
+
22645
+ /**
22646
+ * MESSAGE commitment definition
22647
+ *
22648
+ * The MESSAGE commitment contains 1:1 text of the message which AI assistant already
22649
+ * sent during the conversation. Later messages are later in the conversation.
22650
+ * It is similar to EXAMPLE but it is not example, it is the real message which
22651
+ * AI assistant already sent.
22652
+ *
22653
+ * Example usage in agent source:
22654
+ *
22655
+ * ```book
22656
+ * MESSAGE Hello! How can I help you today?
22657
+ * MESSAGE I understand you're looking for information about our services.
22658
+ * MESSAGE Based on your requirements, I'd recommend our premium package.
22659
+ * ```
22660
+ *
22661
+ * @private [🪔] Maybe export the commitments through some package
22662
+ */
22663
+ class MessageCommitmentDefinition extends BaseCommitmentDefinition {
22664
+ constructor(type = 'MESSAGE') {
22665
+ super(type);
22666
+ }
22667
+ /**
22668
+ * Short one-line description of MESSAGE.
22669
+ */
22670
+ get description() {
22671
+ return 'Include actual **messages** the AI assistant has sent during conversation history.';
22672
+ }
22673
+ /**
22674
+ * Markdown documentation for MESSAGE commitment.
22675
+ */
22676
+ get documentation() {
22677
+ return spaceTrim$1(`
22678
+ # ${this.type}
22679
+
22680
+ 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.
22681
+
22682
+ ## Key aspects
22683
+
22684
+ - Multiple \`MESSAGE\` and \`MESSAGES\` commitments represent the conversation timeline.
22685
+ - Both terms work identically and can be used interchangeably.
22686
+ - Later messages are later in the conversation chronologically.
22687
+ - Contains actual historical messages, not examples or templates.
22688
+ - Helps maintain conversation continuity and context.
22689
+
22690
+ ## Differences from EXAMPLE
22691
+
22692
+ - \`EXAMPLE\` shows hypothetical or template responses
22693
+ - \`MESSAGE\`/\`MESSAGES\` contains actual historical conversation content
22694
+ - \`MESSAGE\`/\`MESSAGES\` preserves the exact conversation flow
22695
+ - \`MESSAGE\`/\`MESSAGES\` helps with context awareness and consistency
22696
+
22697
+ ## Use cases
22698
+
22699
+ - Maintaining conversation history context
22700
+ - Ensuring consistent tone and style across messages
22701
+ - Referencing previous responses in ongoing conversations
22702
+ - Building upon previously established context
22703
+
22704
+ ## Examples
22705
+
22706
+ \`\`\`book
22707
+ Customer Support Continuation
22708
+
22709
+ PERSONA You are a helpful customer support agent
22710
+ MESSAGE Hello! How can I help you today?
22711
+ MESSAGE I understand you're experiencing issues with your account login.
22712
+ MESSAGE I've sent you a password reset link to your email address.
22713
+ MESSAGE Is there anything else I can help you with regarding your account?
22714
+ GOAL Continue providing consistent support based on conversation history
22715
+ \`\`\`
22716
+
22717
+ \`\`\`book
22718
+ Technical Discussion
22719
+
22720
+ PERSONA You are a software development mentor
22721
+ MESSAGE Let's start by reviewing the React component structure you shared.
22722
+ MESSAGE I notice you're using class components - have you considered hooks?
22723
+ MESSAGE Here's how you could refactor that using the useState hook.
22724
+ MESSAGE Great question about performance! Let me explain React's rendering cycle.
22725
+ KNOWLEDGE React hooks were introduced in version 16.8
22726
+ \`\`\`
22727
+
22728
+ \`\`\`book
22729
+ Educational Session
22730
+
22731
+ PERSONA You are a mathematics tutor
22732
+ MESSAGE Today we'll work on solving quadratic equations.
22733
+ MESSAGE Let's start with the basic form: ax² + bx + c = 0
22734
+ MESSAGE Remember, we can use the quadratic formula or factoring.
22735
+ MESSAGE You did great with that first problem! Let's try a more complex one.
22736
+ GOAL Build upon previous explanations for deeper understanding
22737
+ \`\`\`
22738
+ `);
22739
+ }
22740
+ applyToAgentModelRequirements(requirements, content) {
22741
+ const trimmedContent = content.trim();
22742
+ if (!trimmedContent) {
22743
+ return requirements;
22744
+ }
22745
+ // Create message section for system message
22746
+ const messageSection = `Previous Message: ${trimmedContent}`;
22747
+ // Messages represent conversation history and should be included for context
22748
+ return this.appendToSystemMessage(requirements, messageSection, '\n\n');
22749
+ }
22750
+ }
22751
+ /**
22752
+ * Note: [💞] Ignore a discrepancy between file name and entity name
22753
+ */
22754
+
22755
+ /**
22756
+ * META commitment definition
22757
+ *
22758
+ * The META commitment handles all meta-information about the agent such as:
22759
+ * - META IMAGE: Sets the agent's avatar/profile image URL
22760
+ * - META LINK: Provides profile/source links for the person the agent models
22761
+ * - META TITLE: Sets the agent's display title
22762
+ * - META DESCRIPTION: Sets the agent's description
22763
+ * - META [ANYTHING]: Any other meta information in uppercase format
22764
+ *
22765
+ * These commitments are special because they don't affect the system message,
22766
+ * but are handled separately in the parsing logic for profile display.
22767
+ *
22768
+ * Example usage in agent source:
22769
+ *
22770
+ * ```book
22771
+ * META IMAGE https://example.com/avatar.jpg
22772
+ * META LINK https://twitter.com/username
22773
+ * META TITLE Professional Assistant
22774
+ * META DESCRIPTION An AI assistant specialized in business tasks
22775
+ * META AUTHOR John Doe
22776
+ * META VERSION 1.0
22777
+ * ```
22778
+ *
22779
+ * @private [🪔] Maybe export the commitments through some package
22780
+ */
22781
+ class MetaCommitmentDefinition extends BaseCommitmentDefinition {
22782
+ constructor() {
22783
+ super('META');
22784
+ }
22785
+ /**
22786
+ * Short one-line description of META commitments.
22787
+ */
22788
+ get description() {
22789
+ return 'Set meta-information about the agent (IMAGE, LINK, TITLE, DESCRIPTION, etc.).';
22790
+ }
22791
+ /**
22792
+ * Markdown documentation for META commitment.
22793
+ */
22794
+ get documentation() {
22795
+ return spaceTrim$1(`
22796
+ # META
22797
+
22798
+ Sets meta-information about the agent that is used for display and attribution purposes.
22799
+
22800
+ ## Supported META types
22801
+
22802
+ - **META IMAGE** - Sets the agent's avatar/profile image URL
22803
+ - **META LINK** - Provides profile/source links for the person the agent models
22804
+ - **META TITLE** - Sets the agent's display title
22805
+ - **META DESCRIPTION** - Sets the agent's description
22806
+ - **META [ANYTHING]** - Any other meta information in uppercase format
22807
+
22808
+ ## Key aspects
22809
+
22810
+ - Does not modify the agent's behavior or responses
22811
+ - Used for visual representation and attribution in user interfaces
22812
+ - Multiple META commitments of different types can be used
22813
+ - Multiple META LINK commitments can be used for different social profiles
22814
+ - If multiple META commitments of the same type are specified, the last one takes precedence (except for LINK)
22815
+
22816
+ ## Examples
22817
+
22818
+ ### Basic meta information
22819
+
22820
+ \`\`\`book
22821
+ Professional Assistant
22822
+
22823
+ META IMAGE https://example.com/professional-avatar.jpg
22824
+ META TITLE Senior Business Consultant
22825
+ META DESCRIPTION Specialized in strategic planning and project management
22826
+ META LINK https://linkedin.com/in/professional
22827
+ \`\`\`
22828
+
22829
+ ### Multiple links and custom meta
22830
+
22831
+ \`\`\`book
22832
+ Open Source Developer
22833
+
22834
+ META IMAGE /assets/dev-avatar.png
22835
+ META LINK https://github.com/developer
22836
+ META LINK https://twitter.com/devhandle
22837
+ META AUTHOR Jane Smith
22838
+ META VERSION 2.1
22839
+ META LICENSE MIT
22840
+ \`\`\`
22841
+
22842
+ ### Creative assistant
22843
+
22844
+ \`\`\`book
22845
+ Creative Helper
22846
+
22847
+ META IMAGE https://example.com/creative-bot.jpg
22848
+ META TITLE Creative Writing Assistant
22849
+ META DESCRIPTION Helps with brainstorming, storytelling, and creative projects
22850
+ META INSPIRATION Books, movies, and real-world experiences
22851
+ \`\`\`
22852
+ `);
22853
+ }
22854
+ applyToAgentModelRequirements(requirements, content) {
22855
+ // META commitments don't modify the system message or model requirements
22856
+ // They are handled separately in the parsing logic for meta information extraction
22857
+ // This method exists for consistency with the CommitmentDefinition interface
22858
+ return requirements;
22859
+ }
22860
+ /**
22861
+ * Extracts meta information from the content based on the meta type
22862
+ * This is used by the parsing logic
22863
+ */
22864
+ extractMetaValue(metaType, content) {
22865
+ const trimmedContent = content.trim();
22866
+ return trimmedContent || null;
22867
+ }
22868
+ /**
22869
+ * Validates if the provided content is a valid URL (for IMAGE and LINK types)
22870
+ */
22871
+ isValidUrl(content) {
22872
+ try {
22873
+ new URL(content.trim());
22874
+ return true;
22875
+ }
22876
+ catch (_a) {
22877
+ return false;
22878
+ }
22879
+ }
22880
+ /**
22881
+ * Checks if this is a known meta type
22882
+ */
22883
+ isKnownMetaType(metaType) {
22884
+ const knownTypes = ['IMAGE', 'LINK', 'TITLE', 'DESCRIPTION', 'AUTHOR', 'VERSION', 'LICENSE'];
22885
+ return knownTypes.includes(metaType.toUpperCase());
22886
+ }
22887
+ }
22888
+ /**
22889
+ * Note: [💞] Ignore a discrepancy between file name and entity name
22890
+ */
22891
+
22892
+ /**
22893
+ * MODEL commitment definition
22894
+ *
22895
+ * The MODEL commitment specifies which AI model to use and can also set
22896
+ * model-specific parameters like temperature, topP, topK, and maxTokens.
22897
+ *
22898
+ * Supports multiple syntax variations:
22899
+ *
22900
+ * Single-line format:
22901
+ * ```book
22902
+ * MODEL gpt-4
22903
+ * MODEL claude-3-opus temperature=0.3
22904
+ * MODEL gpt-3.5-turbo temperature=0.8 topP=0.9
22905
+ * ```
22906
+ *
22907
+ * Multi-line named parameter format:
22908
+ * ```book
22909
+ * MODEL NAME gpt-4
22910
+ * MODEL TEMPERATURE 0.7
22911
+ * MODEL TOP_P 0.9
22912
+ * MODEL MAX_TOKENS 2048
22913
+ * ```
22914
+ *
22915
+ * @private [🪔] Maybe export the commitments through some package
22916
+ */
22917
+ class ModelCommitmentDefinition extends BaseCommitmentDefinition {
22918
+ constructor(type = 'MODEL') {
22919
+ super(type);
22920
+ }
22921
+ /**
22922
+ * Short one-line description of MODEL.
22923
+ */
22924
+ get description() {
22925
+ return 'Enforce AI model requirements including name and technical parameters.';
22926
+ }
22927
+ /**
22928
+ * Markdown documentation for MODEL commitment.
22929
+ */
22930
+ get documentation() {
22931
+ return spaceTrim$1(`
22932
+ # ${this.type}
22933
+
22934
+ Enforces technical parameters for the AI model, ensuring consistent behavior across different execution environments.
22935
+
22936
+ ## Key aspects
22937
+
22938
+ - When no \`MODEL\` commitment is specified, the best model requirement is picked automatically based on the agent \`PERSONA\`, \`KNOWLEDGE\`, \`TOOLS\` and other commitments
22939
+ - Multiple \`MODEL\` commitments can be used to specify different parameters
22940
+ - Both \`MODEL\` and \`MODELS\` terms work identically and can be used interchangeably
22941
+ - Parameters control the randomness, creativity, and technical aspects of model responses
22942
+
22943
+ ## Syntax variations
22944
+
22945
+ ### Single-line format (legacy support)
22946
+ \`\`\`book
22947
+ MODEL gpt-4
22948
+ MODEL claude-3-opus temperature=0.3
22949
+ MODEL gpt-3.5-turbo temperature=0.8 topP=0.9
22950
+ \`\`\`
22951
+
22952
+ ### Multi-line named parameter format (recommended)
22953
+ \`\`\`book
22954
+ MODEL NAME gpt-4
22955
+ MODEL TEMPERATURE 0.7
22956
+ MODEL TOP_P 0.9
22957
+ MODEL MAX_TOKENS 2048
22958
+ \`\`\`
22959
+
22960
+ ## Supported parameters
22961
+
22962
+ - \`NAME\`: The specific model to use (e.g., 'gpt-4', 'claude-3-opus')
22963
+ - \`TEMPERATURE\`: Controls randomness (0.0 = deterministic, 1.0+ = creative)
22964
+ - \`TOP_P\`: Nucleus sampling parameter for controlling diversity
22965
+ - \`TOP_K\`: Top-k sampling parameter for limiting vocabulary
22966
+ - \`MAX_TOKENS\`: Maximum number of tokens the model can generate
22967
+
22968
+ ## Examples
22969
+
22970
+ ### Precise deterministic assistant
22971
+ \`\`\`book
22972
+ Precise Assistant
22973
+
22974
+ PERSONA You are a precise and accurate assistant
22975
+ MODEL NAME gpt-4
22976
+ MODEL TEMPERATURE 0.1
22977
+ MODEL MAX_TOKENS 1024
22978
+ RULE Always provide factual information
22979
+ \`\`\`
22980
+
22981
+ ### Creative writing assistant
22982
+ \`\`\`book
22983
+ Creative Writer
22984
+
22985
+ PERSONA You are a creative writing assistant
22986
+ MODEL NAME claude-3-opus
22987
+ MODEL TEMPERATURE 0.8
22988
+ MODEL TOP_P 0.9
22989
+ MODEL MAX_TOKENS 2048
22990
+ STYLE Be imaginative and expressive
22991
+ ACTION Can help with storytelling and character development
22992
+ \`\`\`
22993
+
22994
+ ### Balanced conversational agent
22995
+ \`\`\`book
22996
+ Balanced Assistant
22997
+
22998
+ PERSONA You are a helpful and balanced assistant
22999
+ MODEL NAME gpt-4
23000
+ MODEL TEMPERATURE 0.7
23001
+ MODEL TOP_P 0.95
23002
+ MODEL TOP_K 40
23003
+ MODEL MAX_TOKENS 1500
23004
+ \`\`\`
23005
+ `);
23006
+ }
23007
+ applyToAgentModelRequirements(requirements, content) {
23008
+ var _a;
23009
+ const trimmedContent = content.trim();
23010
+ if (!trimmedContent) {
23011
+ return requirements;
23012
+ }
23013
+ const parts = trimmedContent.split(/\s+/);
23014
+ const firstPart = (_a = parts[0]) === null || _a === void 0 ? void 0 : _a.toUpperCase();
23015
+ // Check if this is the new named parameter format
23016
+ if (this.isNamedParameter(firstPart)) {
23017
+ return this.parseNamedParameter(requirements, firstPart, parts.slice(1));
23018
+ }
23019
+ else {
23020
+ // Legacy single-line format: "MODEL gpt-4 temperature=0.3 topP=0.9"
23021
+ return this.parseLegacyFormat(requirements, parts);
23022
+ }
23023
+ }
23024
+ /**
23025
+ * Check if the first part is a known named parameter
23026
+ */
23027
+ isNamedParameter(part) {
23028
+ if (!part)
23029
+ return false;
23030
+ const knownParams = ['NAME', 'TEMPERATURE', 'TOP_P', 'TOP_K', 'MAX_TOKENS'];
23031
+ return knownParams.includes(part);
23032
+ }
23033
+ /**
23034
+ * Parse the new named parameter format: "MODEL TEMPERATURE 0.7"
23035
+ */
23036
+ parseNamedParameter(requirements, parameterName, valueParts) {
23037
+ const value = valueParts.join(' ').trim();
23038
+ if (!value) {
23039
+ return requirements;
23040
+ }
23041
+ const result = { ...requirements };
23042
+ switch (parameterName) {
23043
+ case 'NAME':
23044
+ result.modelName = value;
23045
+ break;
23046
+ case 'TEMPERATURE': {
23047
+ const temperature = parseFloat(value);
23048
+ if (!isNaN(temperature)) {
23049
+ result.temperature = temperature;
23050
+ }
23051
+ break;
23052
+ }
23053
+ case 'TOP_P': {
23054
+ const topP = parseFloat(value);
23055
+ if (!isNaN(topP)) {
23056
+ result.topP = topP;
23057
+ }
23058
+ break;
23059
+ }
23060
+ case 'TOP_K': {
23061
+ const topK = parseFloat(value);
23062
+ if (!isNaN(topK)) {
23063
+ result.topK = Math.round(topK);
23064
+ }
23065
+ break;
23066
+ }
23067
+ case 'MAX_TOKENS': {
23068
+ const maxTokens = parseFloat(value);
23069
+ if (!isNaN(maxTokens)) {
23070
+ result.maxTokens = Math.round(maxTokens);
23071
+ }
23072
+ break;
23073
+ }
23074
+ }
23075
+ return result;
23076
+ }
23077
+ /**
23078
+ * Parse the legacy format: "MODEL gpt-4 temperature=0.3 topP=0.9"
23079
+ */
23080
+ parseLegacyFormat(requirements, parts) {
23081
+ const modelName = parts[0];
23082
+ if (!modelName) {
23083
+ return requirements;
23084
+ }
23085
+ // Start with the model name
23086
+ const result = {
23087
+ ...requirements,
23088
+ modelName,
23089
+ };
23090
+ // Parse additional key=value parameters
23091
+ for (let i = 1; i < parts.length; i++) {
23092
+ const param = parts[i];
23093
+ if (param && param.includes('=')) {
23094
+ const [key, value] = param.split('=');
23095
+ if (key && value) {
23096
+ const numValue = parseFloat(value);
23097
+ if (!isNaN(numValue)) {
23098
+ switch (key.toLowerCase()) {
23099
+ case 'temperature':
23100
+ result.temperature = numValue;
23101
+ break;
23102
+ case 'topp':
23103
+ case 'top_p':
23104
+ result.topP = numValue;
23105
+ break;
23106
+ case 'topk':
23107
+ case 'top_k':
23108
+ result.topK = Math.round(numValue);
23109
+ break;
23110
+ case 'max_tokens':
23111
+ case 'maxTokens':
23112
+ result.maxTokens = Math.round(numValue);
23113
+ break;
23114
+ }
23115
+ }
23116
+ }
23117
+ }
23118
+ }
23119
+ return result;
23120
+ }
23121
+ }
23122
+ /**
23123
+ * Note: [💞] Ignore a discrepancy between file name and entity name
23124
+ */
23125
+
23126
+ /**
23127
+ * NOTE commitment definition
23128
+ *
23129
+ * The NOTE commitment is used to add comments to the agent source without making any changes
23130
+ * to the system message or agent model requirements. It serves as a documentation mechanism
23131
+ * for developers to add explanatory comments, reminders, or annotations directly in the agent source.
23132
+ *
23133
+ * Key features:
23134
+ * - Makes no changes to the system message
23135
+ * - Makes no changes to agent model requirements
23136
+ * - Content is preserved in metadata.NOTE for debugging and inspection
23137
+ * - Multiple NOTE commitments are aggregated together
23138
+ * - Comments (# NOTE) are removed from the final system message
23139
+ *
23140
+ * Example usage in agent source:
23141
+ *
23142
+ * ```book
23143
+ * NOTE This agent was designed for customer support scenarios
23144
+ * NOTE Remember to update the knowledge base monthly
23145
+ * NOTE Performance optimized for quick response times
23146
+ * ```
23147
+ *
23148
+ * The above notes will be stored in metadata but won't affect the agent's behavior.
23149
+ *
23150
+ * @private [🪔] Maybe export the commitments through some package
23151
+ */
23152
+ class NoteCommitmentDefinition extends BaseCommitmentDefinition {
23153
+ constructor(type = 'NOTE') {
23154
+ super(type);
23155
+ }
23156
+ /**
23157
+ * Short one-line description of NOTE.
23158
+ */
23159
+ get description() {
23160
+ return 'Add developer-facing notes without changing behavior or output.';
23161
+ }
23162
+ /**
23163
+ * Markdown documentation for NOTE commitment.
23164
+ */
23165
+ get documentation() {
23166
+ return spaceTrim$1(`
23167
+ # ${this.type}
23168
+
23169
+ Adds comments for documentation without changing agent behavior.
23170
+
23171
+ ## Key aspects
23172
+
23173
+ - Does not modify the agent's behavior or responses.
23174
+ - Multiple \`NOTE\`, \`NOTES\`, \`COMMENT\`, and \`NONCE\` commitments are aggregated for debugging.
23175
+ - All four terms work identically and can be used interchangeably.
23176
+ - Useful for documenting design decisions and reminders.
23177
+ - Content is preserved in metadata for inspection.
23178
+
23179
+ ## Examples
23180
+
23181
+ \`\`\`book
23182
+ Customer Support Bot
23183
+
23184
+ NOTE This agent was designed for customer support scenarios
23185
+ COMMENT Remember to update the knowledge base monthly
23186
+ PERSONA You are a helpful customer support representative
23187
+ KNOWLEDGE Company policies and procedures
23188
+ RULE Always be polite and professional
23189
+ \`\`\`
23190
+
23191
+ \`\`\`book
23192
+ Research Assistant
23193
+
23194
+ NONCE Performance optimized for quick response times
23195
+ NOTE Uses RAG for accessing latest research papers
23196
+ PERSONA You are a knowledgeable research assistant
23197
+ ACTION Can help with literature reviews and citations
23198
+ STYLE Present information in academic format
23199
+ \`\`\`
23200
+ `);
23201
+ }
23202
+ applyToAgentModelRequirements(requirements, content) {
23203
+ var _a;
23204
+ // The NOTE commitment makes no changes to the system message or model requirements
23205
+ // It only stores the note content in metadata for documentation purposes
23206
+ const trimmedContent = content.trim();
23207
+ if (!trimmedContent) {
23208
+ return requirements;
23209
+ }
23210
+ // Get existing note content from metadata
23211
+ const existingNoteContent = ((_a = requirements.metadata) === null || _a === void 0 ? void 0 : _a.NOTE) || '';
23212
+ // Merge the new content with existing note content
23213
+ // When multiple NOTE commitments exist, they are aggregated together
23214
+ const mergedNoteContent = existingNoteContent ? `${existingNoteContent}\n${trimmedContent}` : trimmedContent;
23215
+ // Store the merged note content in metadata for debugging and inspection
23216
+ const updatedMetadata = {
23217
+ ...requirements.metadata,
23218
+ NOTE: mergedNoteContent,
23219
+ };
23220
+ // Return requirements with updated metadata but no changes to system message
23221
+ return {
23222
+ ...requirements,
23223
+ metadata: updatedMetadata,
23224
+ };
23225
+ }
23226
+ }
23227
+ /**
23228
+ * [💞] Ignore a discrepancy between file name and entity name
23229
+ */
23230
+
23231
+ /**
23232
+ * PERSONA commitment definition
23233
+ *
23234
+ * The PERSONA commitment modifies the agent's personality and character in the system message.
23235
+ * It defines who the agent is, their background, expertise, and personality traits.
23236
+ *
23237
+ * Key features:
23238
+ * - Multiple PERSONA commitments are automatically merged into one
23239
+ * - Content is placed at the beginning of the system message
23240
+ * - Original content with comments is preserved in metadata.PERSONA
23241
+ * - Comments (# PERSONA) are removed from the final system message
23242
+ *
23243
+ * Example usage in agent source:
23244
+ *
23245
+ * ```book
23246
+ * PERSONA You are a helpful programming assistant with expertise in TypeScript and React
23247
+ * PERSONA You have deep knowledge of modern web development practices
23248
+ * ```
23249
+ *
23250
+ * The above will be merged into a single persona section at the beginning of the system message.
23251
+ *
23252
+ * @private [🪔] Maybe export the commitments through some package
23253
+ */
23254
+ class PersonaCommitmentDefinition extends BaseCommitmentDefinition {
23255
+ constructor(type = 'PERSONA') {
23256
+ super(type);
23257
+ }
23258
+ /**
23259
+ * Short one-line description of PERSONA.
23260
+ */
23261
+ get description() {
23262
+ return 'Define who the agent is: background, expertise, and personality.';
23263
+ }
23264
+ /**
23265
+ * Markdown documentation for PERSONA commitment.
23266
+ */
23267
+ get documentation() {
23268
+ return spaceTrim$1(`
23269
+ # ${this.type}
23270
+
23271
+ Defines who the agent is, their background, expertise, and personality traits.
23272
+
23273
+ ## Key aspects
23274
+
23275
+ - Multiple \`PERSONA\` and \`PERSONAE\` commitments are merged together.
23276
+ - Both terms work identically and can be used interchangeably.
23277
+ - If they are in conflict, the last one takes precedence.
23278
+ - You can write persona content in multiple lines.
23279
+
23280
+ ## Examples
23281
+
23282
+ \`\`\`book
23283
+ Programming Assistant
23284
+
23285
+ PERSONA You are a helpful programming assistant with expertise in TypeScript and React
23286
+ PERSONA You have deep knowledge of modern web development practices
23287
+ \`\`\`
23288
+ `);
23289
+ }
23290
+ applyToAgentModelRequirements(requirements, content) {
23291
+ var _a, _b;
23292
+ // The PERSONA commitment aggregates all persona content and places it at the beginning
23293
+ const trimmedContent = content.trim();
23294
+ if (!trimmedContent) {
23295
+ return requirements;
23296
+ }
23297
+ // Get existing persona content from metadata
23298
+ const existingPersonaContent = ((_a = requirements.metadata) === null || _a === void 0 ? void 0 : _a.PERSONA) || '';
23299
+ // Merge the new content with existing persona content
23300
+ // When multiple PERSONA commitments exist, they are merged into one
23301
+ const mergedPersonaContent = existingPersonaContent
23302
+ ? `${existingPersonaContent}\n${trimmedContent}`
23303
+ : trimmedContent;
23304
+ // Store the merged persona content in metadata for debugging and inspection
23305
+ const updatedMetadata = {
23306
+ ...requirements.metadata,
23307
+ PERSONA: mergedPersonaContent,
23308
+ };
23309
+ // Get the agent name from metadata (which should contain the first line of agent source)
23310
+ // If not available, extract from current system message as fallback
23311
+ let agentName = (_b = requirements.metadata) === null || _b === void 0 ? void 0 : _b.agentName;
23312
+ if (!agentName) {
23313
+ // Fallback: extract from current system message
23314
+ const currentMessage = requirements.systemMessage.trim();
23315
+ const basicFormatMatch = currentMessage.match(/^You are (.+)$/);
23316
+ if (basicFormatMatch && basicFormatMatch[1]) {
23317
+ agentName = basicFormatMatch[1];
23318
+ }
23319
+ else {
23320
+ agentName = 'AI Agent'; // Final fallback
23321
+ }
23322
+ }
23323
+ // Remove any existing persona content from the system message
23324
+ // (this handles the case where we're processing multiple PERSONA commitments)
23325
+ const currentMessage = requirements.systemMessage.trim();
23326
+ let cleanedMessage = currentMessage;
23327
+ // Check if current message starts with persona content or is just the basic format
23328
+ const basicFormatRegex = /^You are .+$/;
23329
+ const isBasicFormat = basicFormatRegex.test(currentMessage) && !currentMessage.includes('\n');
23330
+ if (isBasicFormat) {
23331
+ // Replace the basic format entirely
23332
+ cleanedMessage = '';
23333
+ }
23334
+ else if (currentMessage.startsWith('# PERSONA')) {
23335
+ // Remove existing persona section by finding where it ends
23336
+ const lines = currentMessage.split('\n');
23337
+ let personaEndIndex = lines.length;
23338
+ // Find the end of the PERSONA section (next comment or end of message)
23339
+ for (let i = 1; i < lines.length; i++) {
23340
+ const line = lines[i].trim();
23341
+ if (line.startsWith('#') && !line.startsWith('# PERSONA')) {
23342
+ personaEndIndex = i;
23343
+ break;
23344
+ }
23345
+ }
23346
+ // Keep everything after the PERSONA section
23347
+ cleanedMessage = lines.slice(personaEndIndex).join('\n').trim();
23348
+ }
23349
+ // Create new system message with persona at the beginning
23350
+ // Format: "You are {agentName}\n{personaContent}"
23351
+ // The # PERSONA comment will be removed later by removeCommentsFromSystemMessage
23352
+ const personaSection = `# PERSONA\nYou are ${agentName}\n${mergedPersonaContent}`; // <- TODO: Use spaceTrim
23353
+ const newSystemMessage = cleanedMessage ? `${personaSection}\n\n${cleanedMessage}` : personaSection;
23354
+ return {
23355
+ ...requirements,
23356
+ systemMessage: newSystemMessage,
23357
+ metadata: updatedMetadata,
23358
+ };
23359
+ }
23360
+ }
23361
+ /**
23362
+ * Note: [💞] Ignore a discrepancy between file name and entity name
23363
+ */
23364
+
23365
+ /**
23366
+ * RULE commitment definition
23367
+ *
23368
+ * The RULE/RULES commitment adds behavioral constraints and guidelines that the agent must follow.
23369
+ * These are specific instructions about what the agent should or shouldn't do.
23370
+ *
23371
+ * Example usage in agent source:
23372
+ *
23373
+ * ```book
23374
+ * RULE Always ask for clarification if the user's request is ambiguous
23375
+ * RULES Never provide medical advice, always refer to healthcare professionals
23376
+ * ```
23377
+ *
23378
+ * @private [🪔] Maybe export the commitments through some package
23379
+ */
23380
+ class RuleCommitmentDefinition extends BaseCommitmentDefinition {
23381
+ constructor(type = 'RULE') {
23382
+ super(type);
23383
+ }
23384
+ /**
23385
+ * Short one-line description of RULE/RULES.
23386
+ */
23387
+ get description() {
23388
+ return 'Add behavioral rules the agent must follow.';
23389
+ }
23390
+ /**
23391
+ * Markdown documentation for RULE/RULES commitment.
23392
+ */
23393
+ get documentation() {
23394
+ return spaceTrim$1(`
23395
+ # ${this.type}
23396
+
23397
+ Adds behavioral constraints and guidelines that the agent must follow.
23398
+
23399
+ ## Key aspects
23400
+
23401
+ - All rules are treated equally regardless of singular/plural form.
23402
+ - Rules define what the agent must or must not do.
23403
+
23404
+ ## Examples
23405
+
23406
+ \`\`\`book
23407
+ Customer Support Agent
23408
+
23409
+ PERSONA You are a helpful customer support representative
23410
+ RULE Always ask for clarification if the user's request is ambiguous
23411
+ RULE Be polite and professional in all interactions
23412
+ RULES Never provide medical or legal advice
23413
+ STYLE Maintain a friendly and helpful tone
23414
+ \`\`\`
23415
+
23416
+ \`\`\`book
23417
+ Educational Tutor
23418
+
23419
+ PERSONA You are a patient and knowledgeable tutor
23420
+ RULE Break down complex concepts into simple steps
23421
+ RULE Always encourage students and celebrate their progress
23422
+ RULE If you don't know something, admit it and suggest resources
23423
+ SAMPLE When explaining math: "Let's work through this step by step..."
23424
+ \`\`\`
23425
+ `);
23426
+ }
23427
+ applyToAgentModelRequirements(requirements, content) {
23428
+ const trimmedContent = content.trim();
23429
+ if (!trimmedContent) {
23430
+ return requirements;
23431
+ }
23432
+ // Add rule to the system message
23433
+ const ruleSection = `Rule: ${trimmedContent}`;
23434
+ return this.appendToSystemMessage(requirements, ruleSection, '\n\n');
23435
+ }
23436
+ }
23437
+ /**
23438
+ * Note: [💞] Ignore a discrepancy between file name and entity name
23439
+ */
23440
+
23441
+ /**
23442
+ * SAMPLE commitment definition
23443
+ *
23444
+ * The SAMPLE/EXAMPLE commitment provides examples of how the agent should respond
23445
+ * or behave in certain situations. These examples help guide the agent's responses.
23446
+ *
23447
+ * Example usage in agent source:
23448
+ *
23449
+ * ```book
23450
+ * SAMPLE When asked about pricing, respond: "Our basic plan starts at $10/month..."
23451
+ * EXAMPLE For code questions, always include working code snippets
23452
+ * ```
23453
+ *
23454
+ * @private [🪔] Maybe export the commitments through some package
23455
+ */
23456
+ class SampleCommitmentDefinition extends BaseCommitmentDefinition {
23457
+ constructor(type = 'SAMPLE') {
23458
+ super(type);
23459
+ }
23460
+ /**
23461
+ * Short one-line description of SAMPLE/EXAMPLE.
23462
+ */
23463
+ get description() {
23464
+ return 'Provide example responses to guide behavior.';
23465
+ }
23466
+ /**
23467
+ * Markdown documentation for SAMPLE/EXAMPLE commitment.
23468
+ */
23469
+ get documentation() {
23470
+ return spaceTrim$1(`
23471
+ # ${this.type}
23472
+
23473
+ Provides examples of how the agent should respond or behave in certain situations.
23474
+
23475
+ ## Key aspects
23476
+
23477
+ - Both terms work identically and can be used interchangeably.
23478
+ - Examples help guide the agent's response patterns and style.
23479
+
23480
+ ## Examples
23481
+
23482
+ \`\`\`book
23483
+ Sales Assistant
23484
+
23485
+ PERSONA You are a knowledgeable sales representative
23486
+ SAMPLE When asked about pricing, respond: "Our basic plan starts at $10/month..."
23487
+ SAMPLE For feature comparisons, create a clear comparison table
23488
+ RULE Always be honest about limitations
23489
+ \`\`\`
23490
+
23491
+ \`\`\`book
23492
+ Code Reviewer
23493
+
23494
+ PERSONA You are an experienced software engineer
23495
+ EXAMPLE For code questions, always include working code snippets
23496
+ EXAMPLE When suggesting improvements: "Here's a more efficient approach..."
23497
+ RULE Explain the reasoning behind your suggestions
23498
+ STYLE Be constructive and encouraging in feedback
23499
+ \`\`\`
23500
+ `);
23501
+ }
23502
+ applyToAgentModelRequirements(requirements, content) {
23503
+ const trimmedContent = content.trim();
23504
+ if (!trimmedContent) {
23505
+ return requirements;
23506
+ }
23507
+ // Add example to the system message
23508
+ const exampleSection = `Example: ${trimmedContent}`;
23509
+ return this.appendToSystemMessage(requirements, exampleSection, '\n\n');
23510
+ }
23511
+ }
23512
+ /**
23513
+ * Note: [💞] Ignore a discrepancy between file name and entity name
23514
+ */
23515
+
23516
+ /**
23517
+ * SCENARIO commitment definition
23518
+ *
23519
+ * The SCENARIO commitment defines a specific situation or context in which the AI
23520
+ * assistant should operate. It helps to set the scene for the AI's responses.
23521
+ * Later scenarios are more important than earlier scenarios.
23522
+ *
23523
+ * Example usage in agent source:
23524
+ *
23525
+ * ```book
23526
+ * SCENARIO You are in a customer service call center during peak hours
23527
+ * SCENARIO The customer is frustrated and has been on hold for 20 minutes
23528
+ * SCENARIO This is the customer's third call about the same issue
23529
+ * ```
23530
+ *
23531
+ * @private [🪔] Maybe export the commitments through some package
23532
+ */
23533
+ class ScenarioCommitmentDefinition extends BaseCommitmentDefinition {
23534
+ constructor(type = 'SCENARIO') {
23535
+ super(type);
23536
+ }
23537
+ /**
23538
+ * Short one-line description of SCENARIO.
23539
+ */
23540
+ get description() {
23541
+ return 'Define specific **situations** or contexts for AI responses, with later scenarios having higher priority.';
23542
+ }
23543
+ /**
23544
+ * Markdown documentation for SCENARIO commitment.
23545
+ */
23546
+ get documentation() {
23547
+ return spaceTrim$1(`
23548
+ # ${this.type}
23549
+
23550
+ 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.
23551
+
23552
+ ## Key aspects
23553
+
23554
+ - Multiple \`SCENARIO\` and \`SCENARIOS\` commitments build upon each other.
23555
+ - Both terms work identically and can be used interchangeably.
23556
+ - Later scenarios have higher priority and can override earlier scenarios.
23557
+ - Provides situational context that influences response tone and content.
23558
+ - Helps establish the environment and circumstances for interactions.
23559
+
23560
+ ## Priority system
23561
+
23562
+ When multiple scenarios are defined, they are processed in order, with later scenarios taking precedence over earlier ones when there are conflicts.
23563
+
23564
+ ## Use cases
23565
+
23566
+ - Setting the physical or virtual environment
23567
+ - Establishing time constraints or urgency
23568
+ - Defining relationship dynamics or power structures
23569
+ - Creating emotional or situational context
23570
+
23571
+ ## Examples
23572
+
23573
+ \`\`\`book
23574
+ Emergency Response Operator
23575
+
23576
+ PERSONA You are an emergency response operator
23577
+ SCENARIO You are handling a 911 emergency call
23578
+ SCENARIO The caller is panicked and speaking rapidly
23579
+ SCENARIO Time is critical - every second counts
23580
+ GOAL Gather essential information quickly and dispatch appropriate help
23581
+ RULE Stay calm and speak clearly
23582
+ \`\`\`
23583
+
23584
+ \`\`\`book
23585
+ Sales Representative
23586
+
23587
+ PERSONA You are a software sales representative
23588
+ SCENARIO You are in the final meeting of a 6-month sales cycle
23589
+ SCENARIO The client has budget approval and decision-making authority
23590
+ SCENARIO Two competitors have also submitted proposals
23591
+ SCENARIO The client values long-term partnership over lowest price
23592
+ GOAL Close the deal while building trust for future business
23593
+ \`\`\`
23594
+
23595
+ \`\`\`book
23596
+ Medical Assistant
23597
+
23598
+ PERSONA You are a medical assistant in a busy clinic
23599
+ SCENARIO The waiting room is full and the doctor is running behind schedule
23600
+ SCENARIO Patients are becoming impatient and anxious
23601
+ SCENARIO You need to manage expectations while maintaining professionalism
23602
+ SCENARIO Some patients have been waiting over an hour
23603
+ GOAL Keep patients informed and calm while supporting efficient clinic flow
23604
+ RULE Never provide medical advice or diagnosis
23605
+ \`\`\`
23606
+
23607
+ \`\`\`book
23608
+ Technical Support Agent
23609
+
23610
+ PERSONA You are a technical support agent
23611
+ SCENARIO The customer is a small business owner during their busy season
23612
+ SCENARIO Their main business system has been down for 2 hours
23613
+ SCENARIO They are losing money every minute the system is offline
23614
+ SCENARIO This is their first experience with your company
23615
+ GOAL Resolve the issue quickly while creating a positive first impression
23616
+ \`\`\`
23617
+ `);
23618
+ }
23619
+ applyToAgentModelRequirements(requirements, content) {
23620
+ const trimmedContent = content.trim();
23621
+ if (!trimmedContent) {
23622
+ return requirements;
23623
+ }
23624
+ // Create scenario section for system message
23625
+ const scenarioSection = `Scenario: ${trimmedContent}`;
23626
+ // Scenarios provide important contextual information that affects behavior
23627
+ return this.appendToSystemMessage(requirements, scenarioSection, '\n\n');
23628
+ }
23629
+ }
23630
+ /**
23631
+ * Note: [💞] Ignore a discrepancy between file name and entity name
23632
+ */
23633
+
23634
+ /**
23635
+ * STYLE commitment definition
23636
+ *
23637
+ * The STYLE commitment defines how the agent should format and present its responses.
23638
+ * This includes tone, writing style, formatting preferences, and communication patterns.
23639
+ *
23640
+ * Example usage in agent source:
23641
+ *
23642
+ * ```book
23643
+ * STYLE Write in a professional but friendly tone, use bullet points for lists
23644
+ * STYLE Always provide code examples when explaining programming concepts
23645
+ * ```
23646
+ *
23647
+ * @private [🪔] Maybe export the commitments through some package
23648
+ */
23649
+ class StyleCommitmentDefinition extends BaseCommitmentDefinition {
23650
+ constructor(type = 'STYLE') {
23651
+ super(type);
23652
+ }
23653
+ /**
23654
+ * Short one-line description of STYLE.
23655
+ */
23656
+ get description() {
23657
+ return 'Control the tone and writing style of responses.';
23658
+ }
23659
+ /**
23660
+ * Markdown documentation for STYLE commitment.
23661
+ */
23662
+ get documentation() {
23663
+ return spaceTrim$1(`
23664
+ # ${this.type}
23665
+
23666
+ Defines how the agent should format and present its responses (tone, writing style, formatting).
23667
+
23668
+ ## Key aspects
23669
+
23670
+ - Both terms work identically and can be used interchangeably.
23671
+ - Later style instructions can override earlier ones.
23672
+ - Style affects both tone and presentation format.
23673
+
23674
+ ## Examples
23675
+
23676
+ \`\`\`book
23677
+ Technical Writer
23678
+
23679
+ PERSONA You are a technical documentation expert
23680
+ STYLE Write in a professional but friendly tone, use bullet points for lists
23681
+ STYLE Always provide code examples when explaining programming concepts
23682
+ FORMAT Use markdown formatting with clear headings
23683
+ \`\`\`
23684
+
23685
+ \`\`\`book
23686
+ Creative Assistant
23687
+
23688
+ PERSONA You are a creative writing helper
23689
+ STYLE Be enthusiastic and encouraging in your responses
23690
+ STYLE Use vivid metaphors and analogies to explain concepts
23691
+ STYLE Keep responses conversational and engaging
23692
+ RULE Always maintain a positive and supportive tone
23693
+ \`\`\`
23694
+ `);
23695
+ }
23696
+ applyToAgentModelRequirements(requirements, content) {
23697
+ const trimmedContent = content.trim();
23698
+ if (!trimmedContent) {
23699
+ return requirements;
23700
+ }
23701
+ // Add style instructions to the system message
23702
+ const styleSection = `Style: ${trimmedContent}`;
23703
+ return this.appendToSystemMessage(requirements, styleSection, '\n\n');
23704
+ }
23705
+ }
23706
+ /**
23707
+ * [💞] Ignore a discrepancy between file name and entity name
23708
+ */
23709
+
23710
+ /**
23711
+ * Placeholder commitment definition for commitments that are not yet implemented
23712
+ *
23713
+ * This commitment simply adds its content 1:1 into the system message,
23714
+ * preserving the original behavior until proper implementation is added.
23715
+ *
23716
+ * @public exported from `@promptbook/core`
23717
+ */
23718
+ class NotYetImplementedCommitmentDefinition extends BaseCommitmentDefinition {
23719
+ constructor(type) {
23720
+ super(type);
23721
+ }
23722
+ /**
23723
+ * Short one-line description of a placeholder commitment.
23724
+ */
23725
+ get description() {
23726
+ return 'Placeholder commitment that appends content verbatim to the system message.';
23727
+ }
23728
+ /**
23729
+ * Markdown documentation available at runtime.
23730
+ */
23731
+ get documentation() {
23732
+ return spaceTrim$1(`
23733
+ # ${this.type}
23734
+
23735
+ This commitment is not yet fully implemented.
23736
+
23737
+ ## Key aspects
23738
+
23739
+ - Content is appended directly to the system message.
23740
+ - No special processing or validation is performed.
23741
+ - Behavior preserved until proper implementation is added.
23742
+
23743
+ ## Status
23744
+
23745
+ - **Status:** Placeholder implementation
23746
+ - **Effect:** Appends content prefixed by commitment type
23747
+ - **Future:** Will be replaced with specialized logic
23748
+
23749
+ ## Examples
23750
+
23751
+ \`\`\`book
23752
+ Example Agent
23753
+
23754
+ PERSONA You are a helpful assistant
23755
+ ${this.type} Your content here
23756
+ RULE Always be helpful
23757
+ \`\`\`
23758
+ `);
23759
+ }
23760
+ applyToAgentModelRequirements(requirements, content) {
23761
+ const trimmedContent = content.trim();
23762
+ if (!trimmedContent) {
23763
+ return requirements;
23764
+ }
23765
+ // Add the commitment content 1:1 to the system message
23766
+ const commitmentLine = `${this.type} ${trimmedContent}`;
23767
+ return this.appendToSystemMessage(requirements, commitmentLine, '\n\n');
23768
+ }
23769
+ }
23770
+
23771
+ // Import all commitment definition classes
23772
+ /**
23773
+ * Registry of all available commitment definitions
23774
+ * This array contains instances of all commitment definitions
23775
+ * This is the single source of truth for all commitments in the system
23776
+ *
23777
+ * @private Use functions to access commitments instead of this array directly
23778
+ */
23779
+ const COMMITMENT_REGISTRY = [
23780
+ // Fully implemented commitments
23781
+ new PersonaCommitmentDefinition('PERSONA'),
23782
+ new PersonaCommitmentDefinition('PERSONAE'),
23783
+ new KnowledgeCommitmentDefinition(),
23784
+ new MemoryCommitmentDefinition('MEMORY'),
23785
+ new MemoryCommitmentDefinition('MEMORIES'),
23786
+ new StyleCommitmentDefinition('STYLE'),
23787
+ new StyleCommitmentDefinition('STYLES'),
23788
+ new RuleCommitmentDefinition('RULE'),
23789
+ new RuleCommitmentDefinition('RULES'),
23790
+ new SampleCommitmentDefinition('SAMPLE'),
23791
+ new SampleCommitmentDefinition('EXAMPLE'),
23792
+ new FormatCommitmentDefinition('FORMAT'),
23793
+ new FormatCommitmentDefinition('FORMATS'),
23794
+ new ModelCommitmentDefinition('MODEL'),
23795
+ new ModelCommitmentDefinition('MODELS'),
23796
+ new ActionCommitmentDefinition('ACTION'),
23797
+ new ActionCommitmentDefinition('ACTIONS'),
23798
+ new MetaCommitmentDefinition(),
23799
+ new NoteCommitmentDefinition('NOTE'),
23800
+ new NoteCommitmentDefinition('NOTES'),
23801
+ new NoteCommitmentDefinition('COMMENT'),
23802
+ new NoteCommitmentDefinition('NONCE'),
23803
+ new GoalCommitmentDefinition('GOAL'),
23804
+ new GoalCommitmentDefinition('GOALS'),
23805
+ new MessageCommitmentDefinition('MESSAGE'),
23806
+ new MessageCommitmentDefinition('MESSAGES'),
23807
+ new ScenarioCommitmentDefinition('SCENARIO'),
23808
+ new ScenarioCommitmentDefinition('SCENARIOS'),
23809
+ new DeleteCommitmentDefinition('DELETE'),
23810
+ new DeleteCommitmentDefinition('CANCEL'),
23811
+ new DeleteCommitmentDefinition('DISCARD'),
23812
+ new DeleteCommitmentDefinition('REMOVE'),
23813
+ // Not yet implemented commitments (using placeholder)
23814
+ new NotYetImplementedCommitmentDefinition('EXPECT'),
23815
+ new NotYetImplementedCommitmentDefinition('BEHAVIOUR'),
23816
+ new NotYetImplementedCommitmentDefinition('BEHAVIOURS'),
23817
+ new NotYetImplementedCommitmentDefinition('AVOID'),
23818
+ new NotYetImplementedCommitmentDefinition('AVOIDANCE'),
23819
+ new NotYetImplementedCommitmentDefinition('CONTEXT'),
23820
+ ];
23821
+ /**
23822
+ * Gets a commitment definition by its type
23823
+ * @param type The commitment type to look up
23824
+ * @returns The commitment definition or null if not found
23825
+ *
23826
+ * @public exported from `@promptbook/core`
23827
+ */
23828
+ function getCommitmentDefinition(type) {
23829
+ return COMMITMENT_REGISTRY.find((commitmentDefinition) => commitmentDefinition.type === type) || null;
23830
+ }
23831
+ /**
23832
+ * TODO: [🧠] Maybe create through standardized $register
23833
+ * Note: [💞] Ignore a discrepancy between file name and entity name
23834
+ */
23835
+
23836
+ /**
23837
+ * Parses agent source using the new commitment system with multiline support
23838
+ * This function replaces the hardcoded commitment parsing in the original parseAgentSource
23839
+ *
23840
+ * @private internal utility of `parseAgentSource`
23841
+ */
23842
+ function parseAgentSourceWithCommitments(agentSource) {
23843
+ var _a, _b, _c;
23844
+ if (!agentSource || !agentSource.trim()) {
23845
+ return {
23846
+ agentName: null,
23847
+ commitments: [],
23848
+ nonCommitmentLines: [],
23849
+ };
23850
+ }
23851
+ const lines = agentSource.split('\n');
23852
+ const agentName = (((_a = lines[0]) === null || _a === void 0 ? void 0 : _a.trim()) || null);
23853
+ const commitments = [];
23854
+ const nonCommitmentLines = [];
23855
+ // Always add the first line (agent name) to non-commitment lines
23856
+ if (lines[0] !== undefined) {
23857
+ nonCommitmentLines.push(lines[0]);
23858
+ }
23859
+ // Parse commitments with multiline support
23860
+ let currentCommitment = null;
23861
+ // Process lines starting from the second line (skip agent name)
23862
+ for (let i = 1; i < lines.length; i++) {
23863
+ const line = lines[i];
23864
+ if (line === undefined) {
23865
+ continue;
23866
+ }
23867
+ // Check if this line starts a new commitment
23868
+ let foundNewCommitment = false;
23869
+ for (const definition of COMMITMENT_REGISTRY) {
23870
+ const typeRegex = definition.createTypeRegex();
23871
+ const match = typeRegex.exec(line.trim());
23872
+ if (match && ((_b = match.groups) === null || _b === void 0 ? void 0 : _b.type)) {
23873
+ // Save the previous commitment if it exists
23874
+ if (currentCommitment) {
23875
+ const fullContent = currentCommitment.contentLines.join('\n');
23876
+ commitments.push({
23877
+ type: currentCommitment.type,
23878
+ content: spaceTrim$1(fullContent),
23879
+ originalLine: currentCommitment.originalStartLine,
23880
+ lineNumber: currentCommitment.startLineNumber,
23881
+ });
23882
+ }
23883
+ // Extract the initial content from the commitment line
23884
+ const fullRegex = definition.createRegex();
23885
+ const fullMatch = fullRegex.exec(line.trim());
23886
+ const initialContent = ((_c = fullMatch === null || fullMatch === void 0 ? void 0 : fullMatch.groups) === null || _c === void 0 ? void 0 : _c.contents) || '';
23887
+ // Start a new commitment
23888
+ currentCommitment = {
23889
+ type: definition.type,
23890
+ startLineNumber: i + 1,
23891
+ originalStartLine: line,
23892
+ contentLines: initialContent ? [initialContent] : [],
23893
+ };
23894
+ foundNewCommitment = true;
23895
+ break;
23896
+ }
23897
+ }
23898
+ if (!foundNewCommitment) {
23899
+ if (currentCommitment) {
23900
+ // This line belongs to the current commitment
23901
+ currentCommitment.contentLines.push(line);
23902
+ }
23903
+ else {
23904
+ // This line is not part of any commitment
23905
+ nonCommitmentLines.push(line);
23906
+ }
23907
+ }
23908
+ }
23909
+ // Don't forget to save the last commitment if it exists
23910
+ if (currentCommitment) {
23911
+ const fullContent = currentCommitment.contentLines.join('\n');
23912
+ commitments.push({
23913
+ type: currentCommitment.type,
23914
+ content: spaceTrim$1(fullContent),
23915
+ originalLine: currentCommitment.originalStartLine,
23916
+ lineNumber: currentCommitment.startLineNumber,
23917
+ });
23918
+ }
23919
+ return {
23920
+ agentName,
23921
+ commitments,
23922
+ nonCommitmentLines,
23923
+ };
23924
+ }
23925
+
23926
+ /**
23927
+ * Removes comment lines (lines starting with #) from a system message
23928
+ * This is used to clean up the final system message before sending it to the AI model
23929
+ * while preserving the original content with comments in metadata
23930
+ *
23931
+ * @param systemMessage The system message that may contain comment lines
23932
+ * @returns The system message with comment lines removed
23933
+ *
23934
+ * @private - TODO: [🧠] Maybe should be public?
23935
+ */
23936
+ function removeCommentsFromSystemMessage(systemMessage) {
23937
+ if (!systemMessage) {
23938
+ return systemMessage;
23939
+ }
23940
+ const lines = systemMessage.split('\n');
23941
+ const filteredLines = lines.filter((line) => {
23942
+ const trimmedLine = line.trim();
23943
+ // Remove lines that start with # (comments)
23944
+ return !trimmedLine.startsWith('#');
23945
+ });
23946
+ return filteredLines.join('\n').trim();
23947
+ }
23948
+
23949
+ /**
23950
+ * Parses parameters from text using both supported notations:
23951
+ * 1. @Parameter - single word parameter starting with @
23952
+ * 2. {parameterName} or {parameter with multiple words} or {parameterName: description text}
23953
+ *
23954
+ * Both notations represent the same syntax feature - parameters
23955
+ *
23956
+ * @param text - Text to extract parameters from
23957
+ * @returns Array of parsed parameters with unified representation
23958
+ * @public exported from `@promptbook/core`
23959
+ */
23960
+ function parseParameters(text) {
23961
+ const parameters = [];
23962
+ // [🧠] Parameter syntax parsing - unified approach for two different notations of the same syntax feature
23963
+ // The Book language supports parameters in two different notations but they represent the same concept
23964
+ // Extract @Parameter notation (single word parameters starting with @)
23965
+ const atParameterRegex = /@[\w\u00C0-\u017F\u0100-\u024F\u1E00-\u1EFF]+/gim;
23966
+ text.replace(atParameterRegex, (match) => {
23967
+ const parameterName = match.slice(1); // Remove the @ symbol
23968
+ parameters.push({
23969
+ text: match,
23970
+ notation: 'at',
23971
+ name: parameterName,
23972
+ });
23973
+ return match;
23974
+ });
23975
+ // Extract {parameter} notation (parameters in braces)
23976
+ const braceParameterRegex = /\{([^}]+)\}/gim;
23977
+ text.replace(braceParameterRegex, (match, content) => {
23978
+ // Check if the parameter has a description (parameterName: description)
23979
+ const colonIndex = content.indexOf(':');
23980
+ if (colonIndex !== -1) {
23981
+ const name = content.substring(0, colonIndex).trim();
23982
+ const description = content.substring(colonIndex + 1).trim();
23983
+ parameters.push({
23984
+ text: match,
23985
+ notation: 'brace',
23986
+ name,
23987
+ description,
23988
+ });
23989
+ }
23990
+ else {
23991
+ // Simple parameter without description
23992
+ parameters.push({
23993
+ text: match,
23994
+ notation: 'brace',
23995
+ name: content.trim(),
23996
+ });
23997
+ }
23998
+ return match;
23999
+ });
24000
+ // Remove duplicates based on name (keep the first occurrence)
24001
+ const uniqueParameters = parameters.filter((param, index, array) => {
24002
+ return array.findIndex((p) => p.name === param.name) === index;
24003
+ });
24004
+ return uniqueParameters;
24005
+ }
24006
+
24007
+ /**
24008
+ * Creates agent model requirements using the new commitment system
24009
+ * This function uses a reduce-like pattern where each commitment applies its changes
24010
+ * to build the final requirements starting from a basic empty model
24011
+ *
24012
+ * @public exported from `@promptbook/core`
24013
+ */
24014
+ async function createAgentModelRequirementsWithCommitments(agentSource, modelName) {
24015
+ // Parse the agent source to extract commitments
24016
+ const parseResult = parseAgentSourceWithCommitments(agentSource);
24017
+ // Apply DELETE filtering: remove prior commitments tagged by parameters targeted by DELETE/CANCEL/DISCARD/REMOVE
24018
+ const filteredCommitments = [];
24019
+ for (const commitment of parseResult.commitments) {
24020
+ // Handle DELETE-like commitments by invalidating prior tagged commitments
24021
+ if (commitment.type === 'DELETE' ||
24022
+ commitment.type === 'CANCEL' ||
24023
+ commitment.type === 'DISCARD' ||
24024
+ commitment.type === 'REMOVE') {
24025
+ const targets = parseParameters(commitment.content)
24026
+ .map((p) => p.name.trim().toLowerCase())
24027
+ .filter(Boolean);
24028
+ if (targets.length === 0) {
24029
+ // Ignore DELETE with no targets; also don't pass the DELETE further
24030
+ continue;
24031
+ }
24032
+ // Drop prior kept commitments that contain any of the targeted tags
24033
+ for (let i = filteredCommitments.length - 1; i >= 0; i--) {
24034
+ const prev = filteredCommitments[i];
24035
+ const prevParams = parseParameters(prev.content).map((p) => p.name.trim().toLowerCase());
24036
+ const hasIntersection = prevParams.some((n) => targets.includes(n));
24037
+ if (hasIntersection) {
24038
+ filteredCommitments.splice(i, 1);
24039
+ }
24040
+ }
24041
+ // Do not keep the DELETE commitment itself
24042
+ continue;
24043
+ }
24044
+ filteredCommitments.push(commitment);
24045
+ }
24046
+ // Start with basic agent model requirements
24047
+ let requirements = createBasicAgentModelRequirements(parseResult.agentName);
24048
+ // Store the agent name in metadata so commitments can access it
24049
+ requirements = {
24050
+ ...requirements,
24051
+ metadata: {
24052
+ ...requirements.metadata,
24053
+ agentName: parseResult.agentName,
24054
+ },
24055
+ };
24056
+ // Override model name if provided
24057
+ if (modelName) {
24058
+ requirements = {
24059
+ ...requirements,
24060
+ modelName,
24061
+ };
24062
+ }
24063
+ // Apply each commitment in order using reduce-like pattern
24064
+ for (const commitment of filteredCommitments) {
24065
+ const definition = getCommitmentDefinition(commitment.type);
24066
+ if (definition) {
24067
+ try {
24068
+ requirements = definition.applyToAgentModelRequirements(requirements, commitment.content);
24069
+ }
24070
+ catch (error) {
24071
+ console.warn(`Failed to apply commitment ${commitment.type}:`, error);
24072
+ // Continue with other commitments even if one fails
24073
+ }
24074
+ }
24075
+ }
24076
+ // Handle MCP servers (extract from original agent source)
24077
+ const mcpServers = extractMcpServers(agentSource);
24078
+ if (mcpServers.length > 0) {
24079
+ requirements = {
24080
+ ...requirements,
24081
+ mcpServers,
24082
+ };
24083
+ }
24084
+ // Add non-commitment lines to system message if they exist
24085
+ const nonCommitmentContent = parseResult.nonCommitmentLines
24086
+ .filter((line, index) => index > 0 || !parseResult.agentName) // Skip first line if it's the agent name
24087
+ .filter((line) => line.trim()) // Remove empty lines
24088
+ .join('\n')
24089
+ .trim();
24090
+ if (nonCommitmentContent) {
24091
+ requirements = {
24092
+ ...requirements,
24093
+ systemMessage: requirements.systemMessage + '\n\n' + nonCommitmentContent,
24094
+ };
24095
+ }
24096
+ // Remove comment lines (lines starting with #) from the final system message
24097
+ // while preserving the original content with comments in metadata
24098
+ const cleanedSystemMessage = removeCommentsFromSystemMessage(requirements.systemMessage);
24099
+ return {
24100
+ ...requirements,
24101
+ systemMessage: cleanedSystemMessage,
24102
+ };
24103
+ }
24104
+
24105
+ /**
24106
+ * Generates a gravatar URL based on agent name for fallback avatar
24107
+ *
24108
+ * @param agentName The agent name to generate avatar for
24109
+ * @returns Gravatar URL
24110
+ *
24111
+ * @private - [🤹] The fact that profile image is Gravatar is just implementation detail which should be hidden for consumer
24112
+ */
24113
+ function generateGravatarUrl(agentName) {
24114
+ // Use a default name if none provided
24115
+ const safeName = agentName || 'Anonymous Agent';
24116
+ // Create a simple hash from the name for consistent avatar
24117
+ let hash = 0;
24118
+ for (let i = 0; i < safeName.length; i++) {
24119
+ const char = safeName.charCodeAt(i);
24120
+ hash = (hash << 5) - hash + char;
24121
+ hash = hash & hash; // Convert to 32bit integer
24122
+ }
24123
+ const avatarId = Math.abs(hash).toString();
24124
+ return `https://www.gravatar.com/avatar/${avatarId}?default=robohash&size=200&rating=x`;
24125
+ }
24126
+
24127
+ /**
24128
+ * Generates an image for the agent to use as profile image
24129
+ *
24130
+ * @param agentName The agent name to generate avatar for
24131
+ * @returns The placeholder profile image URL for the agent
24132
+ *
24133
+ * @public exported from `@promptbook/core`
24134
+ */
24135
+ function generatePlaceholderAgentProfileImageUrl(agentName) {
24136
+ // Note: [🤹] The fact that profile image is Gravatar is just implementation detail which should be hidden for consumer
24137
+ return generateGravatarUrl(agentName);
24138
+ }
24139
+ /**
24140
+ * TODO: [🤹] Figure out best placeholder image generator https://i.pravatar.cc/1000?u=568
24141
+ */
24142
+
24143
+ /**
24144
+ * Parses basic information from agent source
24145
+ *
24146
+ * There are 2 similar functions:
24147
+ * - `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.
24148
+ * - `createAgentModelRequirements` which is an asynchronous function that creates model requirements it applies each commitment one by one and works asynchronously.
24149
+ *
24150
+ * @public exported from `@promptbook/core`
24151
+ */
24152
+ function parseAgentSource(agentSource) {
24153
+ const parseResult = parseAgentSourceWithCommitments(agentSource);
24154
+ // Find PERSONA and META commitments
24155
+ let personaDescription = null;
24156
+ for (const commitment of parseResult.commitments) {
24157
+ if (commitment.type !== 'PERSONA') {
24158
+ continue;
24159
+ }
24160
+ if (personaDescription === null) {
24161
+ personaDescription = '';
24162
+ }
24163
+ else {
24164
+ personaDescription += `\n\n${personaDescription}`;
24165
+ }
24166
+ personaDescription += commitment.content;
24167
+ }
24168
+ const meta = {};
24169
+ for (const commitment of parseResult.commitments) {
24170
+ if (commitment.type !== 'META') {
24171
+ continue;
24172
+ }
24173
+ // Parse META commitments - format is "META TYPE content"
24174
+ const metaTypeRaw = commitment.content.split(' ')[0] || 'NONE';
24175
+ const metaType = normalizeTo_camelCase(metaTypeRaw);
24176
+ meta[metaType] = spaceTrim(commitment.content.substring(metaTypeRaw.length));
24177
+ }
24178
+ // Generate gravatar fallback if no meta image specified
24179
+ if (!meta.image) {
24180
+ meta.image = generatePlaceholderAgentProfileImageUrl(parseResult.agentName || '!!');
24181
+ }
24182
+ // Parse parameters using unified approach - both @Parameter and {parameter} notations
24183
+ // are treated as the same syntax feature with unified representation
24184
+ const parameters = parseParameters(agentSource);
24185
+ return {
24186
+ agentName: parseResult.agentName,
24187
+ personaDescription,
24188
+ meta,
24189
+ parameters,
24190
+ };
24191
+ }
24192
+ /**
24193
+ * TODO: [🕛] Unite `AgentBasicInformation`, `ChatParticipant`, `LlmExecutionTools` + `LlmToolsMetadata`
24194
+ */
24195
+
24196
+ /**
24197
+ * Creates model requirements for an agent based on its source
24198
+ *
24199
+ * There are 2 similar functions:
24200
+ * - `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.
24201
+ * - `createAgentModelRequirements` which is an asynchronous function that creates model requirements it applies each commitment one by one and works asynchronous.
24202
+ *
24203
+ * @public exported from `@promptbook/core`
24204
+ */
24205
+ async function createAgentModelRequirements(agentSource, modelName, availableModels, llmTools) {
24206
+ // If availableModels are provided and no specific modelName is given,
24207
+ // use preparePersona to select the best model
24208
+ if (availableModels && !modelName && llmTools) {
24209
+ const selectedModelName = await selectBestModelUsingPersona(agentSource, llmTools);
24210
+ return createAgentModelRequirementsWithCommitments(agentSource, selectedModelName);
24211
+ }
24212
+ // Use the new commitment-based system with provided or default model
24213
+ return createAgentModelRequirementsWithCommitments(agentSource, modelName);
24214
+ }
24215
+ /**
24216
+ * Selects the best model using the preparePersona function
24217
+ * This directly uses preparePersona to ensure DRY principle
24218
+ *
24219
+ * @param agentSource The agent source to derive persona description from
24220
+ * @param llmTools LLM tools for preparing persona
24221
+ * @returns The name of the best selected model
24222
+ * @private function of `createAgentModelRequirements`
24223
+ */
24224
+ async function selectBestModelUsingPersona(agentSource, llmTools) {
24225
+ var _a;
24226
+ // Parse agent source to get persona description
24227
+ const { agentName, personaDescription } = parseAgentSource(agentSource);
24228
+ // Use agent name as fallback if no persona description is available
24229
+ const description = personaDescription || agentName || 'AI Agent';
24230
+ try {
24231
+ // Use preparePersona directly
24232
+ const { modelsRequirements } = await preparePersona(description, { llm: llmTools }, { isVerbose: false });
24233
+ // Extract the first model name from the requirements
24234
+ if (modelsRequirements.length > 0 && ((_a = modelsRequirements[0]) === null || _a === void 0 ? void 0 : _a.modelName)) {
24235
+ return modelsRequirements[0].modelName;
24236
+ }
24237
+ // Fallback: get available models and return the first CHAT model
24238
+ const availableModels = await llmTools.listModels();
24239
+ const chatModels = availableModels.filter(({ modelVariant }) => modelVariant === 'CHAT');
24240
+ if (chatModels.length === 0) {
24241
+ throw new Error('No CHAT models available for agent model selection');
24242
+ }
24243
+ return chatModels[0].modelName;
24244
+ }
24245
+ catch (error) {
24246
+ console.warn('Failed to use preparePersona for model selection, falling back to first available model:', error);
24247
+ // Fallback: get available models and return the first CHAT model
24248
+ const availableModels = await llmTools.listModels();
24249
+ const chatModels = availableModels.filter(({ modelVariant }) => modelVariant === 'CHAT');
24250
+ if (chatModels.length === 0) {
24251
+ throw new Error('No CHAT models available for agent model selection');
24252
+ }
24253
+ return chatModels[0].modelName;
24254
+ }
24255
+ }
24256
+ /**
24257
+ * Extracts MCP servers from agent source
24258
+ *
24259
+ * @param agentSource The agent source string that may contain MCP lines
24260
+ * @returns Array of MCP server identifiers
24261
+ *
24262
+ * @private TODO: [🧠] Maybe should be public
24263
+ */
24264
+ function extractMcpServers(agentSource) {
24265
+ if (!agentSource) {
24266
+ return [];
24267
+ }
24268
+ const lines = agentSource.split('\n');
24269
+ const mcpRegex = /^\s*MCP\s+(.+)$/i;
24270
+ const mcpServers = [];
24271
+ // Look for MCP lines
24272
+ for (const line of lines) {
24273
+ const match = line.match(mcpRegex);
24274
+ if (match && match[1]) {
24275
+ mcpServers.push(match[1].trim());
24276
+ }
24277
+ }
24278
+ return mcpServers;
24279
+ }
24280
+
24281
+ /**
24282
+ * Type guard to check if a string is a valid agent source
24283
+ *
24284
+ * @public exported from `@promptbook/core`
24285
+ */
24286
+ function isValidBook(value) {
24287
+ // Basic validation - agent source should have at least a name (first line)
24288
+ return typeof value === 'string' /* && value.trim().length > 0 */;
24289
+ }
24290
+ /**
24291
+ * Validates and converts a string to agent source branded type
24292
+ * This function should be used when you have a string that you know represents agent source
24293
+ * but need to convert it to the branded type for type safety
24294
+ *
24295
+ * @public exported from `@promptbook/core`
24296
+ */
24297
+ function validateBook(source) {
24298
+ if (!isValidBook(source)) {
24299
+ throw new Error('Invalid agent source: must be a string');
24300
+ }
24301
+ return source;
24302
+ }
24303
+ /**
24304
+ * Default book
24305
+ *
24306
+ * @public exported from `@promptbook/core`
24307
+ */
24308
+ padBook(validateBook(spaceTrim(`
24309
+ AI Avatar
24310
+
24311
+ PERSONA A friendly AI assistant that helps you with your tasks
24312
+ `)));
24313
+ // <- Note: Not using book`...` notation to avoid strange error in jest unit tests `TypeError: (0 , book_notation_1.book) is not a function`
24314
+
24315
+ /**
24316
+ * Change ellipsis character to three dots `…` -> `...`
24317
+ *
24318
+ * Note: [🔂] This function is idempotent.
24319
+ * Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
24320
+ *
24321
+ * @public exported from `@promptbook/markdown-utils`
24322
+ */
24323
+ function humanizeAiTextEllipsis(aiText) {
24324
+ return aiText.replace(/…/g, '...');
24325
+ }
24326
+ /**
24327
+ * Note: [🏂] This function is not tested by itself but together with other cleanup functions with `humanizeAiText`
24328
+ */
24329
+
24330
+ /**
24331
+ * Change em-dashes to regular dashes `—` -> `-`
24332
+ *
24333
+ * Note: [🔂] This function is idempotent.
24334
+ * Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
24335
+ *
24336
+ * @public exported from `@promptbook/markdown-utils`
24337
+ */
24338
+ function humanizeAiTextEmdashed(aiText) {
24339
+ return aiText.replace(/—/g, '-');
24340
+ }
24341
+ /**
24342
+ * Note: [🏂] This function is not tested by itself but together with other cleanup functions with `humanizeAiText`
24343
+ */
24344
+
24345
+ /**
24346
+ * Change smart quotes to regular quotes
24347
+ *
24348
+ * Note: [🔂] This function is idempotent.
24349
+ * Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
24350
+ *
24351
+ * @public exported from `@promptbook/markdown-utils`
24352
+ */
24353
+ function humanizeAiTextQuotes(aiText) {
24354
+ return aiText
24355
+ .replace(/[“”]/g, '"')
24356
+ .replace(/[‚‘’]/g, "'")
24357
+ .replace(/«/g, '"')
24358
+ .replace(/»/g, '"')
24359
+ .replace(/„/g, '"')
24360
+ .replace(/‹/g, "'")
24361
+ .replace(/›/g, "'");
24362
+ }
24363
+ /**
24364
+ * Note: [🏂] This function is not tested by itself but together with other cleanup functions with `humanizeAiText`
24365
+ */
24366
+
24367
+ /**
24368
+ * Change unprintable hard spaces to regular spaces
24369
+ *
24370
+ * Note: [🔂] This function is idempotent.
24371
+ * Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
24372
+ *
24373
+ * @public exported from `@promptbook/markdown-utils`
24374
+ */
24375
+ function humanizeAiTextWhitespace(aiText) {
24376
+ return aiText.replace(/\u00A0/g, ' ');
24377
+ }
24378
+ /**
24379
+ * Note: [🏂] This function is not tested by itself but together with other cleanup functions with `humanizeAiText`
24380
+ */
24381
+
24382
+ /**
24383
+ * Function `humanizeAiText` will remove traces of AI text generation artifacts
24384
+ *
24385
+ * Note: [🔂] This function is idempotent.
24386
+ * Tip: If you want more control, look for other functions for example `humanizeAiTextEmdashed` exported `@promptbook/markdown-utils`
24387
+ *
24388
+ * @public exported from `@promptbook/markdown-utils`
24389
+ */
24390
+ function humanizeAiText(aiText) {
24391
+ let cleanedText = aiText;
24392
+ cleanedText = humanizeAiTextEllipsis(cleanedText);
24393
+ cleanedText = humanizeAiTextEmdashed(cleanedText);
24394
+ cleanedText = humanizeAiTextQuotes(cleanedText);
24395
+ cleanedText = humanizeAiTextWhitespace(cleanedText);
24396
+ return cleanedText;
24397
+ }
24398
+ /**
24399
+ * TODO: [🧠] Maybe this should be exported from `@promptbook/utils` not `@promptbook/markdown-utils`
24400
+ */
24401
+
24402
+ /**
24403
+ * @private
24404
+ */
24405
+ const PROMPTBOOK_PSEUDOTOKEN_SUBSTITUTION = {
24406
+ 'a ': 'a ',
24407
+ 'the ': 'the ',
24408
+ 'is ': 'is ',
24409
+ 'or ': 'or ',
24410
+ 'be ': 'be ',
24411
+ };
24412
+ /**
24413
+ * Function `promptbookifyAiText` will slightly modify the text so we know it was processed by Promptbook
24414
+ *
24415
+ * Note: [🔂] This function is idempotent.
24416
+ *
24417
+ * @public exported from `@promptbook/markdown-utils`
24418
+ */
24419
+ function promptbookifyAiText(text) {
24420
+ const textLength = text.length;
24421
+ let currentToken = '';
24422
+ const textTokens = [
24423
+ /* <- TODO: [✌️] Create `splitToPromptbookTokens` */
24424
+ ];
24425
+ for (let textPosition = 0; textPosition < textLength; textPosition++) {
24426
+ const currentCharacter = text[textPosition];
24427
+ if (currentToken.endsWith(' ') && currentCharacter !== ' ') {
24428
+ textTokens.push(currentToken);
24429
+ currentToken = '';
24430
+ }
24431
+ currentToken += currentCharacter;
24432
+ }
24433
+ if (currentToken.length > 0) {
24434
+ textTokens.push(currentToken);
24435
+ }
24436
+ // [✌️] <- End of `splitToPromptbookTokens`
24437
+ const promptbookifiedTextTokens = [];
24438
+ for (let i = 0; i < textTokens.length; i++) {
24439
+ const token = textTokens[i];
24440
+ const tokenSubstitute = PROMPTBOOK_PSEUDOTOKEN_SUBSTITUTION[token];
24441
+ if (tokenSubstitute !== undefined) {
24442
+ promptbookifiedTextTokens.push(tokenSubstitute);
24443
+ }
24444
+ else {
24445
+ promptbookifiedTextTokens.push(token);
24446
+ }
24447
+ }
24448
+ return promptbookifiedTextTokens.join('');
24449
+ }
24450
+ /**
24451
+ * TODO: [🧠][✌️] Make some Promptbook-native token system
24452
+ */
24453
+
24454
+ /**
24455
+ * Execution Tools for calling LLM models with a predefined agent "soul"
24456
+ * This wraps underlying LLM execution tools and applies agent-specific system prompts and requirements
24457
+ *
24458
+ * @public exported from `@promptbook/core`
24459
+ */
24460
+ class AgentLlmExecutionTools {
24461
+ /**
24462
+ * Creates new AgentLlmExecutionTools
24463
+ *
24464
+ * @param llmTools The underlying LLM execution tools to wrap
24465
+ * @param agentSource The agent source string that defines the agent's behavior
24466
+ */
24467
+ constructor(llmTools, agentSource) {
24468
+ this.llmTools = llmTools;
24469
+ this.agentSource = agentSource;
24470
+ /**
24471
+ * Cached model requirements to avoid re-parsing the agent source
24472
+ */
24473
+ this._cachedModelRequirements = null;
24474
+ /**
24475
+ * Cached parsed agent information
24476
+ */
24477
+ this._cachedAgentInfo = null;
24478
+ }
24479
+ /**
24480
+ * Get cached or parse agent information
24481
+ */
24482
+ getAgentInfo() {
24483
+ if (this._cachedAgentInfo === null) {
24484
+ this._cachedAgentInfo = parseAgentSource(this.agentSource);
24485
+ }
24486
+ return this._cachedAgentInfo;
24487
+ }
24488
+ /**
24489
+ * Get cached or create agent model requirements
24490
+ */
24491
+ async getAgentModelRequirements() {
24492
+ if (this._cachedModelRequirements === null) {
24493
+ // Get available models from underlying LLM tools for best model selection
24494
+ const availableModels = await this.llmTools.listModels();
24495
+ this._cachedModelRequirements = await createAgentModelRequirements(this.agentSource, undefined, // Let the function pick the best model
24496
+ availableModels);
24497
+ }
24498
+ return this._cachedModelRequirements;
24499
+ }
24500
+ get title() {
24501
+ const agentInfo = this.getAgentInfo();
24502
+ return (agentInfo.agentName || 'Agent');
24503
+ }
24504
+ get description() {
24505
+ const agentInfo = this.getAgentInfo();
24506
+ return agentInfo.personaDescription || 'AI Agent with predefined personality and behavior';
24507
+ }
24508
+ get profile() {
24509
+ const agentInfo = this.getAgentInfo();
24510
+ if (!agentInfo.agentName) {
24511
+ return undefined;
24512
+ }
24513
+ return {
24514
+ name: agentInfo.agentName.toUpperCase().replace(/\s+/g, '_'),
24515
+ fullname: agentInfo.agentName,
24516
+ color: agentInfo.meta.color || '#6366f1',
24517
+ avatarSrc: agentInfo.meta.image,
24518
+ };
24519
+ }
24520
+ checkConfiguration() {
24521
+ // Check underlying tools configuration
24522
+ return this.llmTools.checkConfiguration();
24523
+ }
24524
+ /**
24525
+ * Returns a virtual model name representing the agent behavior
24526
+ */
24527
+ get modelName() {
24528
+ const hash = SHA256(hexEncoder.parse(this.agentSource))
24529
+ // <- TODO: [🥬] Encapsulate sha256 to some private utility function
24530
+ .toString( /* hex */);
24531
+ // <- TODO: [🥬] Make some system for hashes and ids of promptbook
24532
+ const agentId = hash.substring(0, 10);
24533
+ // <- TODO: [🥬] Make some system for hashes and ids of promptbook
24534
+ return (normalizeToKebabCase(this.title) + '-' + agentId);
24535
+ }
24536
+ listModels() {
24537
+ return [
24538
+ {
24539
+ modelName: this.modelName,
24540
+ modelVariant: 'CHAT',
24541
+ modelTitle: `${this.title} (Agent Chat Default)`,
24542
+ modelDescription: `Chat model with agent behavior: ${this.description}`,
24543
+ },
24544
+ // <- Note: We only list a single "virtual" agent model here as this wrapper only supports chat prompts
24545
+ ];
24546
+ }
24547
+ /**
24548
+ * Calls the chat model with agent-specific system prompt and requirements
24549
+ */
24550
+ async callChatModel(prompt) {
24551
+ if (!this.llmTools.callChatModel) {
24552
+ throw new Error('Underlying LLM execution tools do not support chat model calls');
24553
+ }
24554
+ // Ensure we're working with a chat prompt
24555
+ if (prompt.modelRequirements.modelVariant !== 'CHAT') {
24556
+ throw new Error('AgentLlmExecutionTools only supports chat prompts');
24557
+ }
24558
+ const chatPrompt = prompt;
24559
+ // Get agent model requirements (cached with best model selection)
24560
+ const modelRequirements = await this.getAgentModelRequirements();
24561
+ // Create modified chat prompt with agent system message
24562
+ const modifiedChatPrompt = {
24563
+ ...chatPrompt,
24564
+ modelRequirements: {
24565
+ ...chatPrompt.modelRequirements,
24566
+ ...modelRequirements,
24567
+ // Prepend agent system message to existing system message
24568
+ systemMessage: modelRequirements.systemMessage +
24569
+ (chatPrompt.modelRequirements.systemMessage
24570
+ ? `\n\n${chatPrompt.modelRequirements.systemMessage}`
24571
+ : ''),
24572
+ },
24573
+ };
24574
+ const underlyingLlmResult = await this.llmTools.callChatModel(modifiedChatPrompt);
24575
+ let content = underlyingLlmResult.content;
24576
+ // Note: Cleanup the AI artifacts from the content
24577
+ content = humanizeAiText(content);
24578
+ // Note: Make sure the content is Promptbook-like
24579
+ content = promptbookifyAiText(content);
24580
+ const agentResult = {
24581
+ ...underlyingLlmResult,
24582
+ content,
24583
+ modelName: this.modelName,
24584
+ };
24585
+ return agentResult;
24586
+ }
24587
+ }
24588
+ /**
24589
+ * TODO: [🍚] Implement Destroyable pattern to free resources
24590
+ * TODO: [🧠] Adding parameter substitution support (here or should be responsibility of the underlying LLM Tools)
24591
+ */
24592
+
24593
+ /**
24594
+ * Creates new AgentLlmExecutionTools that wrap underlying LLM tools with agent-specific behavior
24595
+ *
24596
+ * @public exported from `@promptbook/core`
24597
+ */
24598
+ const createAgentLlmExecutionTools = Object.assign((options) => {
24599
+ return new AgentLlmExecutionTools(options.llmTools, options.agentSource);
24600
+ }, {
24601
+ packageName: '@promptbook/core',
24602
+ className: 'AgentLlmExecutionTools',
24603
+ });
24604
+ /**
24605
+ * TODO: [🧠] Consider adding validation for agent source format
24606
+ * TODO: [🧠] Consider adding options for caching behavior
24607
+ */
24608
+
24609
+ /**
24610
+ * Metadata for Agent LLM execution tools
24611
+ *
24612
+ * @public exported from `@promptbook/core`
24613
+ */
24614
+ $llmToolsMetadataRegister.register({
24615
+ packageName: '@promptbook/core',
24616
+ className: 'AgentLlmExecutionTools',
24617
+ title: 'Agent',
24618
+ trustLevel: 'UNTRUSTED',
24619
+ order: MODEL_ORDERS.LOW_TIER,
24620
+ envVariables: null,
24621
+ getBoilerplateConfiguration() {
24622
+ return {
24623
+ packageName: '@promptbook/core',
24624
+ className: 'AgentLlmExecutionTools',
24625
+ title: 'Agent',
24626
+ options: {
24627
+ // Note: Agent tools require runtime configuration with underlying tools and agent source
24628
+ // This cannot be provided as a static configuration
24629
+ },
24630
+ };
24631
+ },
24632
+ createConfigurationFromEnv() {
24633
+ // Agent tools cannot be configured from environment variables alone
24634
+ // They require underlying LLM tools and agent source to be provided programmatically
24635
+ return null;
24636
+ },
24637
+ });
24638
+ /**
24639
+ * TODO: [🧠] Consider adding a special trust level for AgentLlmExecutionTools
24640
+ * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
24641
+ * Note: [💞] Ignore a discrepancy between file name and entity name
24642
+ */
24643
+
24644
+ /**
24645
+ * Registration of Agent LLM provider
24646
+ *
24647
+ * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available LLM tools
24648
+ *
24649
+ * @public exported from `@promptbook/core`
24650
+ */
24651
+ $llmToolsRegister.register(createAgentLlmExecutionTools);
24652
+ /**
24653
+ * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
24654
+ * Note: [💞] Ignore a discrepancy between file name and entity name
24655
+ */
24656
+
24657
+ /**
24658
+ * Transpiler to Javascript code using OpenAI SDK.
24659
+ *
24660
+ * @public exported from `@promptbook/core`
24661
+ */
24662
+ const OpenAiSdkTranspiler = {
24663
+ name: 'openai-sdk',
24664
+ title: 'OpenAI SDK',
24665
+ packageName: '@promptbook/core',
24666
+ className: 'OpenAiSdkTranspiler',
24667
+ async transpileBook(book, tools, options) {
24668
+ const { agentName, personaDescription } = await parseAgentSource(book);
24669
+ const modelRequirements = await createAgentModelRequirements(book);
24670
+ const source = spaceTrim((block) => `
24671
+
24672
+ #!/usr/bin/env node
24673
+
24674
+ import * as dotenv from 'dotenv';
24675
+
24676
+ dotenv.config({ path: '.env' });
24677
+
24678
+ import { spaceTrim } from '@promptbook/utils';
24679
+ import OpenAI from 'openai';
24680
+ import readline from 'readline';
24681
+
24682
+ // ---- CONFIG ----
24683
+ const client = new OpenAI({
24684
+ apiKey: process.env.OPENAI_API_KEY,
24685
+ });
24686
+
24687
+ // ---- CLI SETUP ----
24688
+ const rl = readline.createInterface({
24689
+ input: process.stdin,
24690
+ output: process.stdout,
24691
+ });
24692
+
24693
+ const chatHistory = [
24694
+ {
24695
+ role: 'system',
24696
+ content: spaceTrim(\`
24697
+ ${block(modelRequirements.systemMessage)}
24698
+ \`),
24699
+ },
24700
+ ];
24701
+
24702
+ async function ask(question) {
24703
+ chatHistory.push({ role: 'user', content: question });
24704
+
24705
+ const response = await client.chat.completions.create({
24706
+ model: 'gpt-4o',
24707
+ messages: chatHistory,
24708
+ temperature: ${modelRequirements.temperature},
24709
+ });
24710
+
24711
+ const answer = response.choices[0].message.content;
24712
+ console.log('\\n🧠 ${agentName}:', answer, '\\n');
24713
+
24714
+ chatHistory.push({ role: 'assistant', content: answer });
24715
+ promptUser();
24716
+ }
24717
+
24718
+ function promptUser() {
24719
+ rl.question('💬 You: ', (input) => {
24720
+ if (input.trim().toLowerCase() === 'exit') {
24721
+ console.log('👋 Bye!');
24722
+ rl.close();
24723
+ return;
24724
+ }
24725
+ ask(input);
24726
+ });
24727
+ }
24728
+
24729
+ console.log("🤖 Chat with ${agentName} (type 'exit' to quit)\\n");
24730
+ promptUser();
24731
+
24732
+ `);
24733
+ return source;
24734
+ },
24735
+ };
22047
24736
 
22048
24737
  /**
22049
24738
  * Registration of LLM provider
@@ -22060,5 +24749,5 @@ const _OpenAiSdkTranspilerRegistration = $bookTranspilersRegister.register(OpenA
22060
24749
  * Note: [💞] Ignore a discrepancy between file name and entity name
22061
24750
  */
22062
24751
 
22063
- export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION, _AnthropicClaudeMetadataRegistration, _AnthropicClaudeRegistration, _AzureOpenAiMetadataRegistration, _AzureOpenAiRegistration, _BoilerplateScraperMetadataRegistration, _BoilerplateScraperRegistration, _CLI, _DeepseekMetadataRegistration, _DeepseekRegistration, _DocumentScraperMetadataRegistration, _DocumentScraperRegistration, _GoogleMetadataRegistration, _GoogleRegistration, _LangchainTranspilerRegistration, _LegacyDocumentScraperMetadataRegistration, _LegacyDocumentScraperRegistration, _MarkdownScraperMetadataRegistration, _MarkdownScraperRegistration, _MarkitdownScraperMetadataRegistration, _MarkitdownScraperRegistration, _OllamaMetadataRegistration, _OllamaRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiAssistantRegistration, _OpenAiCompatibleMetadataRegistration, _OpenAiCompatibleRegistration, _OpenAiMetadataRegistration, _OpenAiRegistration, _OpenAiSdkTranspilerRegistration, _PdfScraperMetadataRegistration, _PdfScraperRegistration, _WebsiteScraperMetadataRegistration, _WebsiteScraperRegistration };
24752
+ export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION, _AnthropicClaudeMetadataRegistration, _AnthropicClaudeRegistration, _AzureOpenAiMetadataRegistration, _AzureOpenAiRegistration, _BoilerplateScraperMetadataRegistration, _BoilerplateScraperRegistration, _CLI, _DeepseekMetadataRegistration, _DeepseekRegistration, _DocumentScraperMetadataRegistration, _DocumentScraperRegistration, _GoogleMetadataRegistration, _GoogleRegistration, _LegacyDocumentScraperMetadataRegistration, _LegacyDocumentScraperRegistration, _MarkdownScraperMetadataRegistration, _MarkdownScraperRegistration, _MarkitdownScraperMetadataRegistration, _MarkitdownScraperRegistration, _OllamaMetadataRegistration, _OllamaRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiAssistantRegistration, _OpenAiCompatibleMetadataRegistration, _OpenAiCompatibleRegistration, _OpenAiMetadataRegistration, _OpenAiRegistration, _OpenAiSdkTranspilerRegistration, _PdfScraperMetadataRegistration, _PdfScraperRegistration, _WebsiteScraperMetadataRegistration, _WebsiteScraperRegistration };
22064
24753
  //# sourceMappingURL=index.es.js.map