@promptbook/cli 0.103.0-46 → 0.103.0-47
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.
- package/apps/agents-server/config.ts.todo +4 -4
- package/apps/agents-server/next.config.ts +3 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/book/route.ts +1 -1
- package/apps/agents-server/src/app/agents/[agentName]/api/book/test.http +2 -2
- package/apps/agents-server/src/app/agents/[agentName]/api/chat/route.ts +6 -4
- package/apps/agents-server/src/app/agents/[agentName]/api/modelRequirements/TODO.txt +1 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/modelRequirements/route.ts +53 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/modelRequirements/systemMessage/route.ts +45 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/profile/route.ts +54 -0
- package/apps/agents-server/src/app/agents/[agentName]/book/BookEditorWrapper.tsx +83 -17
- package/apps/agents-server/src/app/agents/[agentName]/book/page.tsx +9 -5
- package/apps/agents-server/src/app/agents/[agentName]/book+chat/{SelfLearningBook.tsx → AgentBookAndChatComponent.tsx} +5 -46
- package/apps/agents-server/src/app/agents/[agentName]/book+chat/page.tsx +7 -4
- package/apps/agents-server/src/app/agents/[agentName]/chat/AgentChatWrapper.tsx +38 -0
- package/apps/agents-server/src/app/agents/[agentName]/chat/page.tsx +23 -0
- package/apps/agents-server/src/app/agents/[agentName]/page.tsx +6 -4
- package/apps/agents-server/src/app/agents/page.tsx +11 -0
- package/apps/agents-server/src/app/api/chat/route.ts +1 -1
- package/apps/agents-server/src/app/api/chat-streaming/route.ts +5 -1
- package/apps/agents-server/src/app/api/upload/route.ts +75 -0
- package/apps/agents-server/src/tools/$provideAgentCollectionForServer.ts +1 -0
- package/apps/agents-server/src/tools/$provideCdnForServer.ts +28 -0
- package/apps/agents-server/src/utils/cdn/classes/DigitalOceanSpaces.ts +119 -0
- package/apps/agents-server/src/utils/cdn/interfaces/IFilesStorage.ts +32 -0
- package/apps/agents-server/src/utils/cdn/interfaces/IStorage.ts +14 -0
- package/apps/agents-server/src/utils/cdn/utils/getUserFileCdnKey.ts +27 -0
- package/apps/agents-server/src/utils/cdn/utils/nameToSubfolderPath.ts +9 -0
- package/apps/agents-server/src/utils/cdn/utils/nextRequestToNodeRequest.ts +27 -0
- package/apps/agents-server/src/utils/validators/validateMimeType.ts +24 -0
- package/apps/agents-server/tsconfig.json +1 -1
- package/esm/index.es.js +154 -161
- package/esm/index.es.js.map +1 -1
- package/esm/typings/servers.d.ts +1 -7
- package/esm/typings/src/_packages/components.index.d.ts +4 -0
- package/esm/typings/src/_packages/core.index.d.ts +16 -14
- package/esm/typings/src/_packages/types.index.d.ts +12 -6
- package/esm/typings/src/book-2.0/agent-source/AgentModelRequirements.d.ts +6 -1
- package/esm/typings/src/book-2.0/agent-source/AgentSourceParseResult.d.ts +1 -1
- package/esm/typings/src/book-2.0/agent-source/createCommitmentRegex.d.ts +1 -1
- package/esm/typings/src/book-components/Chat/AgentChat/AgentChat.d.ts +14 -0
- package/esm/typings/src/book-components/Chat/AgentChat/AgentChat.test.d.ts +1 -0
- package/esm/typings/src/book-components/Chat/AgentChat/AgentChatProps.d.ts +13 -0
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +1 -60
- package/esm/typings/src/{book-2.0/commitments → commitments}/ACTION/ACTION.d.ts +1 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/DELETE/DELETE.d.ts +1 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/FORMAT/FORMAT.d.ts +1 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/GOAL/GOAL.d.ts +1 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/KNOWLEDGE/KNOWLEDGE.d.ts +1 -5
- package/esm/typings/src/{book-2.0/commitments → commitments}/MEMORY/MEMORY.d.ts +1 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/MESSAGE/MESSAGE.d.ts +1 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/META/META.d.ts +1 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/META_IMAGE/META_IMAGE.d.ts +1 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/META_LINK/META_LINK.d.ts +1 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/MODEL/MODEL.d.ts +1 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/NOTE/NOTE.d.ts +1 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/PERSONA/PERSONA.d.ts +1 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/RULE/RULE.d.ts +1 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/SAMPLE/SAMPLE.d.ts +1 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/SCENARIO/SCENARIO.d.ts +1 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/STYLE/STYLE.d.ts +1 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/_base/BaseCommitmentDefinition.d.ts +1 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/_base/CommitmentDefinition.d.ts +1 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/_base/NotYetImplementedCommitmentDefinition.d.ts +1 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/_base/createEmptyAgentModelRequirements.d.ts +1 -1
- package/esm/typings/src/execution/LlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/agent/Agent.d.ts +3 -7
- package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/agent/CreateAgentLlmExecutionToolsOptions.d.ts +1 -1
- package/esm/typings/src/llm-providers/agent/RemoteAgent.d.ts +32 -0
- package/esm/typings/src/llm-providers/agent/RemoteAgentOptions.d.ts +11 -0
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +5 -1
- package/esm/typings/src/storage/_common/PromptbookStorage.d.ts +1 -0
- package/esm/typings/src/types/typeAliases.d.ts +6 -0
- package/esm/typings/src/utils/color/internal-utils/checkChannelValue.d.ts +0 -3
- package/esm/typings/src/utils/random/$generateBookBoilerplate.d.ts +2 -2
- package/esm/typings/src/utils/random/$randomFullnameWithColor.d.ts +1 -1
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +154 -161
- package/umd/index.umd.js.map +1 -1
- /package/esm/typings/src/{book-2.0/commitments → commitments}/_base/BookCommitment.d.ts +0 -0
- /package/esm/typings/src/{book-2.0/commitments → commitments}/_base/ParsedCommitment.d.ts +0 -0
- /package/esm/typings/src/{book-2.0/commitments → commitments}/index.d.ts +0 -0
package/esm/index.es.js
CHANGED
|
@@ -47,7 +47,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
47
47
|
* @generated
|
|
48
48
|
* @see https://github.com/webgptorg/promptbook
|
|
49
49
|
*/
|
|
50
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-
|
|
50
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-47';
|
|
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
|
|
@@ -60,15 +60,20 @@ const PROMPTBOOK_ENGINE_VERSION = '0.103.0-46';
|
|
|
60
60
|
*/
|
|
61
61
|
const REMOTE_SERVER_URLS = [
|
|
62
62
|
{
|
|
63
|
-
title: 'Promptbook',
|
|
64
|
-
description: `
|
|
63
|
+
title: 'Promptbook.Studio',
|
|
64
|
+
description: `Server of Promptbook.studio`,
|
|
65
65
|
owner: 'AI Web, LLC <legal@ptbk.io> (https://www.ptbk.io/)',
|
|
66
|
-
isAnonymousModeAllowed: true,
|
|
67
66
|
urls: [
|
|
68
67
|
'https://promptbook.s5.ptbk.io/',
|
|
69
68
|
// Note: Servers 1-4 are not running
|
|
70
69
|
],
|
|
71
70
|
},
|
|
71
|
+
{
|
|
72
|
+
title: 'Testing Agents',
|
|
73
|
+
description: `Testing Agents server on Vercel`,
|
|
74
|
+
owner: 'AI Web, LLC <legal@ptbk.io> (https://www.ptbk.io/)',
|
|
75
|
+
urls: ['https://s6.ptbk.io/'],
|
|
76
|
+
},
|
|
72
77
|
/*
|
|
73
78
|
Note: Working on older version of Promptbook and not supported anymore
|
|
74
79
|
{
|
|
@@ -326,9 +331,6 @@ function checkChannelValue(channelName, value) {
|
|
|
326
331
|
throw new Error(`${channelName} channel is greater than 255, it is ${value}`);
|
|
327
332
|
}
|
|
328
333
|
}
|
|
329
|
-
/**
|
|
330
|
-
* TODO: [🧠][🚓] Is/which combination it better to use asserts/check, validate or is utility function?
|
|
331
|
-
*/
|
|
332
334
|
|
|
333
335
|
/**
|
|
334
336
|
* Color object represents an RGB color with alpha channel
|
|
@@ -15085,11 +15087,13 @@ function $initializeRunCommand(program) {
|
|
|
15085
15087
|
async function startAgentServer(options) {
|
|
15086
15088
|
const { port = 4440 } = options;
|
|
15087
15089
|
// TODO: !!!! [🌕]
|
|
15090
|
+
const agentsServerRoot = join(__dirname, '../apps/agents-server');
|
|
15088
15091
|
console.trace(`!!! Starting agents server on port ${port}...`);
|
|
15089
15092
|
console.log(`!!! cwd`, process.cwd());
|
|
15090
15093
|
console.log(`!!! __dirname`, __dirname);
|
|
15094
|
+
console.log(`!!! agentsServerRoot`, agentsServerRoot);
|
|
15091
15095
|
await $execCommand({
|
|
15092
|
-
cwd:
|
|
15096
|
+
cwd: agentsServerRoot,
|
|
15093
15097
|
command: `next dev --port ${port} `,
|
|
15094
15098
|
isVerbose: true,
|
|
15095
15099
|
});
|
|
@@ -18842,26 +18846,6 @@ const GOOGLE_MODELS = exportJson({
|
|
|
18842
18846
|
output: pricing(`$0.45 / 1M tokens`),
|
|
18843
18847
|
},
|
|
18844
18848
|
},
|
|
18845
|
-
{
|
|
18846
|
-
modelVariant: 'CHAT',
|
|
18847
|
-
modelTitle: 'Gemini 2.0 Flash',
|
|
18848
|
-
modelName: 'gemini-2.0-flash',
|
|
18849
|
-
modelDescription: 'Fast, efficient model with 128K context window optimized for rapid response times. Balances performance and cost with 2x lower latency than Pro models while maintaining strong capabilities in text generation, code completion, and logical reasoning. Excellent for interactive applications, chatbots, and services requiring quick responses with good quality.',
|
|
18850
|
-
pricing: {
|
|
18851
|
-
prompt: pricing(`$0.35 / 1M tokens`),
|
|
18852
|
-
output: pricing(`$1.05 / 1M tokens`),
|
|
18853
|
-
},
|
|
18854
|
-
},
|
|
18855
|
-
{
|
|
18856
|
-
modelVariant: 'CHAT',
|
|
18857
|
-
modelTitle: 'Gemini 2.0 Flash Lite',
|
|
18858
|
-
modelName: 'gemini-2.0-flash-lite',
|
|
18859
|
-
modelDescription: 'Streamlined version of Gemini 2.0 Flash with 64K context window, designed for extremely low-latency applications. Features 40% smaller model size and 3x faster inference while retaining core capabilities for text and simple reasoning tasks. Perfect for mobile applications, edge deployments, and high-volume services with strict latency requirements.',
|
|
18860
|
-
pricing: {
|
|
18861
|
-
prompt: pricing(`$0.20 / 1M tokens`),
|
|
18862
|
-
output: pricing(`$0.60 / 1M tokens`),
|
|
18863
|
-
},
|
|
18864
|
-
},
|
|
18865
18849
|
{
|
|
18866
18850
|
modelVariant: 'CHAT',
|
|
18867
18851
|
modelTitle: 'Gemini 2.0 Flash Thinking',
|
|
@@ -20398,7 +20382,7 @@ class OpenAiExecutionTools extends OpenAiCompatibleExecutionTools {
|
|
|
20398
20382
|
*
|
|
20399
20383
|
* This is useful for calling OpenAI API with a single assistant, for more wide usage use `OpenAiExecutionTools`.
|
|
20400
20384
|
*
|
|
20401
|
-
* Note: [🦖] There are several different things in Promptbook:
|
|
20385
|
+
* !!! Note: [🦖] There are several different things in Promptbook:
|
|
20402
20386
|
* - `Agent` - which represents an AI Agent with its source, memories, actions, etc. Agent is a higher-level abstraction which is internally using:
|
|
20403
20387
|
* - `LlmExecutionTools` - which wraps one or more LLM models and provides an interface to execute them
|
|
20404
20388
|
* - `AgentLlmExecutionTools` - which is a specific implementation of `LlmExecutionTools` that wraps another LlmExecutionTools and applies agent-specific system prompts and requirements
|
|
@@ -20504,17 +20488,21 @@ class OpenAiAssistantExecutionTools extends OpenAiExecutionTools {
|
|
|
20504
20488
|
console.info('connect', stream.currentEvent);
|
|
20505
20489
|
}
|
|
20506
20490
|
});
|
|
20491
|
+
/*
|
|
20507
20492
|
stream.on('messageDelta', (messageDelta) => {
|
|
20508
|
-
|
|
20509
|
-
|
|
20493
|
+
if (
|
|
20494
|
+
this.options.isVerbose &&
|
|
20510
20495
|
messageDelta &&
|
|
20511
20496
|
messageDelta.content &&
|
|
20512
20497
|
messageDelta.content[0] &&
|
|
20513
|
-
messageDelta.content[0].type === 'text'
|
|
20514
|
-
|
|
20498
|
+
messageDelta.content[0].type === 'text'
|
|
20499
|
+
) {
|
|
20500
|
+
console.info('messageDelta', messageDelta.content[0].text?.value);
|
|
20515
20501
|
}
|
|
20502
|
+
|
|
20516
20503
|
// <- TODO: [🐚] Make streaming and running tasks working
|
|
20517
20504
|
});
|
|
20505
|
+
*/
|
|
20518
20506
|
stream.on('messageCreated', (message) => {
|
|
20519
20507
|
if (this.options.isVerbose) {
|
|
20520
20508
|
console.info('messageCreated', message);
|
|
@@ -20594,64 +20582,85 @@ class OpenAiAssistantExecutionTools extends OpenAiExecutionTools {
|
|
|
20594
20582
|
throw new NotAllowed(`Creating new assistants is not allowed. Set \`isCreatingNewAssistantsAllowed: true\` in options to enable this feature.`);
|
|
20595
20583
|
}
|
|
20596
20584
|
// await this.playground();
|
|
20597
|
-
const { name, instructions } = options;
|
|
20585
|
+
const { name, instructions, knowledgeSources } = options;
|
|
20598
20586
|
const client = await this.getClient();
|
|
20599
|
-
|
|
20600
|
-
//
|
|
20601
|
-
|
|
20602
|
-
|
|
20603
|
-
|
|
20604
|
-
|
|
20605
|
-
|
|
20606
|
-
|
|
20607
|
-
|
|
20608
|
-
if (!res.ok) throw new Error(`Download error: ${url}`);
|
|
20609
|
-
const buffer = await res.arrayBuffer();
|
|
20610
|
-
fs.writeFileSync(filepath, Buffer.from(buffer));
|
|
20611
|
-
console.log(`📥 File downloaded: ${filename}`);
|
|
20612
|
-
|
|
20613
|
-
return filepath;
|
|
20614
|
-
}
|
|
20615
|
-
|
|
20616
|
-
async function uploadFileToOpenAI(filepath: string) {
|
|
20617
|
-
const file = await client.files.create({
|
|
20618
|
-
file: fs.createReadStream(filepath),
|
|
20619
|
-
purpose: 'assistants',
|
|
20587
|
+
let vectorStoreId;
|
|
20588
|
+
// If knowledge sources are provided, create a vector store with them
|
|
20589
|
+
if (knowledgeSources && knowledgeSources.length > 0) {
|
|
20590
|
+
if (this.options.isVerbose) {
|
|
20591
|
+
console.info(`📚 Creating vector store with ${knowledgeSources.length} knowledge sources...`);
|
|
20592
|
+
}
|
|
20593
|
+
// Create a vector store
|
|
20594
|
+
const vectorStore = await client.beta.vectorStores.create({
|
|
20595
|
+
name: `${name} Knowledge Base`,
|
|
20620
20596
|
});
|
|
20621
|
-
|
|
20622
|
-
|
|
20623
|
-
|
|
20624
|
-
|
|
20625
|
-
|
|
20626
|
-
|
|
20627
|
-
|
|
20628
|
-
|
|
20629
|
-
|
|
20630
|
-
|
|
20631
|
-
|
|
20632
|
-
|
|
20633
|
-
|
|
20634
|
-
|
|
20635
|
-
|
|
20636
|
-
|
|
20637
|
-
|
|
20638
|
-
|
|
20639
|
-
|
|
20640
|
-
|
|
20641
|
-
|
|
20642
|
-
|
|
20597
|
+
vectorStoreId = vectorStore.id;
|
|
20598
|
+
if (this.options.isVerbose) {
|
|
20599
|
+
console.info(`✅ Vector store created: ${vectorStoreId}`);
|
|
20600
|
+
}
|
|
20601
|
+
// Upload files from knowledge sources to the vector store
|
|
20602
|
+
const fileStreams = [];
|
|
20603
|
+
for (const source of knowledgeSources) {
|
|
20604
|
+
try {
|
|
20605
|
+
// Check if it's a URL
|
|
20606
|
+
if (source.startsWith('http://') || source.startsWith('https://')) {
|
|
20607
|
+
// Download the file
|
|
20608
|
+
const response = await fetch(source);
|
|
20609
|
+
if (!response.ok) {
|
|
20610
|
+
console.error(`Failed to download ${source}: ${response.statusText}`);
|
|
20611
|
+
continue;
|
|
20612
|
+
}
|
|
20613
|
+
const buffer = await response.arrayBuffer();
|
|
20614
|
+
const filename = source.split('/').pop() || 'downloaded-file';
|
|
20615
|
+
const blob = new Blob([buffer]);
|
|
20616
|
+
const file = new File([blob], filename);
|
|
20617
|
+
fileStreams.push(file);
|
|
20618
|
+
}
|
|
20619
|
+
else {
|
|
20620
|
+
// Assume it's a local file path
|
|
20621
|
+
// Note: This will work in Node.js environment
|
|
20622
|
+
// For browser environments, this would need different handling
|
|
20623
|
+
const fs = await import('fs');
|
|
20624
|
+
const fileStream = fs.createReadStream(source);
|
|
20625
|
+
fileStreams.push(fileStream);
|
|
20626
|
+
}
|
|
20627
|
+
}
|
|
20628
|
+
catch (error) {
|
|
20629
|
+
console.error(`Error processing knowledge source ${source}:`, error);
|
|
20630
|
+
}
|
|
20631
|
+
}
|
|
20632
|
+
// Batch upload files to the vector store
|
|
20633
|
+
if (fileStreams.length > 0) {
|
|
20634
|
+
try {
|
|
20635
|
+
await client.beta.vectorStores.fileBatches.uploadAndPoll(vectorStoreId, {
|
|
20636
|
+
files: fileStreams,
|
|
20637
|
+
});
|
|
20638
|
+
if (this.options.isVerbose) {
|
|
20639
|
+
console.info(`✅ Uploaded ${fileStreams.length} files to vector store`);
|
|
20640
|
+
}
|
|
20641
|
+
}
|
|
20642
|
+
catch (error) {
|
|
20643
|
+
console.error('Error uploading files to vector store:', error);
|
|
20644
|
+
}
|
|
20645
|
+
}
|
|
20643
20646
|
}
|
|
20644
|
-
|
|
20645
|
-
|
|
20646
|
-
// 3️⃣ Create assistant with uploaded files
|
|
20647
|
-
const assistant = await client.beta.assistants.create({
|
|
20647
|
+
// Create assistant with vector store attached
|
|
20648
|
+
const assistantConfig = {
|
|
20648
20649
|
name,
|
|
20649
20650
|
description: 'Assistant created via Promptbook',
|
|
20650
20651
|
model: 'gpt-4o',
|
|
20651
20652
|
instructions,
|
|
20652
20653
|
tools: [/* TODO: [🧠] Maybe add { type: 'code_interpreter' }, */ { type: 'file_search' }],
|
|
20653
|
-
|
|
20654
|
-
|
|
20654
|
+
};
|
|
20655
|
+
// Attach vector store if created
|
|
20656
|
+
if (vectorStoreId) {
|
|
20657
|
+
assistantConfig.tool_resources = {
|
|
20658
|
+
file_search: {
|
|
20659
|
+
vector_store_ids: [vectorStoreId],
|
|
20660
|
+
},
|
|
20661
|
+
};
|
|
20662
|
+
}
|
|
20663
|
+
const assistant = await client.beta.assistants.create(assistantConfig);
|
|
20655
20664
|
console.log(`✅ Assistant created: ${assistant.id}`);
|
|
20656
20665
|
// TODO: !!!! Try listing existing assistants
|
|
20657
20666
|
// TODO: !!!! Try marking existing assistants by DISCRIMINANT
|
|
@@ -22225,40 +22234,6 @@ const _FormattedBookInMarkdownTranspilerRegistration = $bookTranspilersRegister.
|
|
|
22225
22234
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
22226
22235
|
*/
|
|
22227
22236
|
|
|
22228
|
-
/**
|
|
22229
|
-
* Creates an empty/basic agent model requirements object
|
|
22230
|
-
* This serves as the starting point for the reduce-like pattern
|
|
22231
|
-
* where each commitment applies its changes to build the final requirements
|
|
22232
|
-
*
|
|
22233
|
-
* @public exported from `@promptbook/core`
|
|
22234
|
-
*/
|
|
22235
|
-
function createEmptyAgentModelRequirements() {
|
|
22236
|
-
return {
|
|
22237
|
-
systemMessage: '',
|
|
22238
|
-
// modelName: 'gpt-5',
|
|
22239
|
-
modelName: 'gemini-2.5-flash-lite',
|
|
22240
|
-
temperature: 0.7,
|
|
22241
|
-
topP: 0.9,
|
|
22242
|
-
topK: 50,
|
|
22243
|
-
};
|
|
22244
|
-
}
|
|
22245
|
-
/**
|
|
22246
|
-
* Creates a basic agent model requirements with just the agent name
|
|
22247
|
-
* This is used when we have an agent name but no commitments
|
|
22248
|
-
*
|
|
22249
|
-
* @public exported from `@promptbook/core`
|
|
22250
|
-
*/
|
|
22251
|
-
function createBasicAgentModelRequirements(agentName) {
|
|
22252
|
-
const empty = createEmptyAgentModelRequirements();
|
|
22253
|
-
return {
|
|
22254
|
-
...empty,
|
|
22255
|
-
systemMessage: `You are ${agentName || 'AI Agent'}`,
|
|
22256
|
-
};
|
|
22257
|
-
}
|
|
22258
|
-
/**
|
|
22259
|
-
* TODO: [🐤] Deduplicate `AgentModelRequirements` and `ModelRequirements` model requirements
|
|
22260
|
-
*/
|
|
22261
|
-
|
|
22262
22237
|
/**
|
|
22263
22238
|
* Generates a regex pattern to match a specific commitment
|
|
22264
22239
|
*
|
|
@@ -22792,23 +22767,19 @@ class KnowledgeCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
22792
22767
|
`);
|
|
22793
22768
|
}
|
|
22794
22769
|
applyToAgentModelRequirements(requirements, content) {
|
|
22795
|
-
var _a;
|
|
22796
22770
|
const trimmedContent = content.trim();
|
|
22797
22771
|
if (!trimmedContent) {
|
|
22798
22772
|
return requirements;
|
|
22799
22773
|
}
|
|
22800
22774
|
// Check if content is a URL (external knowledge source)
|
|
22801
|
-
if (
|
|
22775
|
+
if (isValidUrl(trimmedContent)) {
|
|
22802
22776
|
// Store the URL for later async processing
|
|
22803
22777
|
const updatedRequirements = {
|
|
22804
22778
|
...requirements,
|
|
22805
|
-
|
|
22806
|
-
...requirements.
|
|
22807
|
-
|
|
22808
|
-
|
|
22809
|
-
trimmedContent,
|
|
22810
|
-
],
|
|
22811
|
-
},
|
|
22779
|
+
knowledgeSources: [
|
|
22780
|
+
...(requirements.knowledgeSources || []),
|
|
22781
|
+
trimmedContent,
|
|
22782
|
+
],
|
|
22812
22783
|
};
|
|
22813
22784
|
// Add placeholder information about knowledge sources to system message
|
|
22814
22785
|
const knowledgeInfo = `Knowledge Source URL: ${trimmedContent} (will be processed for retrieval during chat)`;
|
|
@@ -22820,18 +22791,6 @@ class KnowledgeCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
22820
22791
|
return this.appendToSystemMessage(requirements, knowledgeSection, '\n\n');
|
|
22821
22792
|
}
|
|
22822
22793
|
}
|
|
22823
|
-
/**
|
|
22824
|
-
* Check if content is a URL
|
|
22825
|
-
*/
|
|
22826
|
-
isUrl(content) {
|
|
22827
|
-
try {
|
|
22828
|
-
new URL(content);
|
|
22829
|
-
return true;
|
|
22830
|
-
}
|
|
22831
|
-
catch (_a) {
|
|
22832
|
-
return false;
|
|
22833
|
-
}
|
|
22834
|
-
}
|
|
22835
22794
|
}
|
|
22836
22795
|
/**
|
|
22837
22796
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -24129,6 +24088,40 @@ function getCommitmentDefinition(type) {
|
|
|
24129
24088
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
24130
24089
|
*/
|
|
24131
24090
|
|
|
24091
|
+
/**
|
|
24092
|
+
* Creates an empty/basic agent model requirements object
|
|
24093
|
+
* This serves as the starting point for the reduce-like pattern
|
|
24094
|
+
* where each commitment applies its changes to build the final requirements
|
|
24095
|
+
*
|
|
24096
|
+
* @public exported from `@promptbook/core`
|
|
24097
|
+
*/
|
|
24098
|
+
function createEmptyAgentModelRequirements() {
|
|
24099
|
+
return {
|
|
24100
|
+
systemMessage: '',
|
|
24101
|
+
// modelName: 'gpt-5',
|
|
24102
|
+
modelName: 'gemini-2.5-flash-lite',
|
|
24103
|
+
temperature: 0.7,
|
|
24104
|
+
topP: 0.9,
|
|
24105
|
+
topK: 50,
|
|
24106
|
+
};
|
|
24107
|
+
}
|
|
24108
|
+
/**
|
|
24109
|
+
* Creates a basic agent model requirements with just the agent name
|
|
24110
|
+
* This is used when we have an agent name but no commitments
|
|
24111
|
+
*
|
|
24112
|
+
* @public exported from `@promptbook/core`
|
|
24113
|
+
*/
|
|
24114
|
+
function createBasicAgentModelRequirements(agentName) {
|
|
24115
|
+
const empty = createEmptyAgentModelRequirements();
|
|
24116
|
+
return {
|
|
24117
|
+
...empty,
|
|
24118
|
+
systemMessage: `You are ${agentName || 'AI Agent'}`,
|
|
24119
|
+
};
|
|
24120
|
+
}
|
|
24121
|
+
/**
|
|
24122
|
+
* TODO: [🐤] Deduplicate `AgentModelRequirements` and `ModelRequirements` model requirements
|
|
24123
|
+
*/
|
|
24124
|
+
|
|
24132
24125
|
/**
|
|
24133
24126
|
* Parses agent source using the new commitment system with multiline support
|
|
24134
24127
|
* This function replaces the hardcoded commitment parsing in the original parseAgentSource
|
|
@@ -24219,29 +24212,6 @@ function parseAgentSourceWithCommitments(agentSource) {
|
|
|
24219
24212
|
};
|
|
24220
24213
|
}
|
|
24221
24214
|
|
|
24222
|
-
/**
|
|
24223
|
-
* Removes comment lines (lines starting with #) from a system message
|
|
24224
|
-
* This is used to clean up the final system message before sending it to the AI model
|
|
24225
|
-
* while preserving the original content with comments in metadata
|
|
24226
|
-
*
|
|
24227
|
-
* @param systemMessage The system message that may contain comment lines
|
|
24228
|
-
* @returns The system message with comment lines removed
|
|
24229
|
-
*
|
|
24230
|
-
* @private - TODO: [🧠] Maybe should be public?
|
|
24231
|
-
*/
|
|
24232
|
-
function removeCommentsFromSystemMessage(systemMessage) {
|
|
24233
|
-
if (!systemMessage) {
|
|
24234
|
-
return systemMessage;
|
|
24235
|
-
}
|
|
24236
|
-
const lines = systemMessage.split('\n');
|
|
24237
|
-
const filteredLines = lines.filter((line) => {
|
|
24238
|
-
const trimmedLine = line.trim();
|
|
24239
|
-
// Remove lines that start with # (comments)
|
|
24240
|
-
return !trimmedLine.startsWith('#');
|
|
24241
|
-
});
|
|
24242
|
-
return filteredLines.join('\n').trim();
|
|
24243
|
-
}
|
|
24244
|
-
|
|
24245
24215
|
/**
|
|
24246
24216
|
* Parses parameters from text using both supported notations:
|
|
24247
24217
|
* 1. @Parameter - single word parameter starting with @
|
|
@@ -24300,6 +24270,29 @@ function parseParameters(text) {
|
|
|
24300
24270
|
return uniqueParameters;
|
|
24301
24271
|
}
|
|
24302
24272
|
|
|
24273
|
+
/**
|
|
24274
|
+
* Removes comment lines (lines starting with #) from a system message
|
|
24275
|
+
* This is used to clean up the final system message before sending it to the AI model
|
|
24276
|
+
* while preserving the original content with comments in metadata
|
|
24277
|
+
*
|
|
24278
|
+
* @param systemMessage The system message that may contain comment lines
|
|
24279
|
+
* @returns The system message with comment lines removed
|
|
24280
|
+
*
|
|
24281
|
+
* @private - TODO: [🧠] Maybe should be public?
|
|
24282
|
+
*/
|
|
24283
|
+
function removeCommentsFromSystemMessage(systemMessage) {
|
|
24284
|
+
if (!systemMessage) {
|
|
24285
|
+
return systemMessage;
|
|
24286
|
+
}
|
|
24287
|
+
const lines = systemMessage.split('\n');
|
|
24288
|
+
const filteredLines = lines.filter((line) => {
|
|
24289
|
+
const trimmedLine = line.trim();
|
|
24290
|
+
// Remove lines that start with # (comments)
|
|
24291
|
+
return !trimmedLine.startsWith('#');
|
|
24292
|
+
});
|
|
24293
|
+
return filteredLines.join('\n').trim();
|
|
24294
|
+
}
|
|
24295
|
+
|
|
24303
24296
|
/**
|
|
24304
24297
|
* Creates agent model requirements using the new commitment system
|
|
24305
24298
|
* This function uses a reduce-like pattern where each commitment applies its changes
|