@promptbook/cli 0.103.0-45 → 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.
Files changed (89) hide show
  1. package/apps/agents-server/config.ts.todo +4 -4
  2. package/apps/agents-server/next.config.ts +3 -0
  3. package/apps/agents-server/src/app/agents/[agentName]/api/book/route.ts +86 -0
  4. package/apps/agents-server/src/app/agents/[agentName]/api/book/test.http +37 -0
  5. package/apps/agents-server/src/app/agents/[agentName]/api/chat/route.ts +6 -4
  6. package/apps/agents-server/src/app/agents/[agentName]/api/modelRequirements/TODO.txt +1 -0
  7. package/apps/agents-server/src/app/agents/[agentName]/api/modelRequirements/route.ts +53 -0
  8. package/apps/agents-server/src/app/agents/[agentName]/api/modelRequirements/systemMessage/route.ts +45 -0
  9. package/apps/agents-server/src/app/agents/[agentName]/api/profile/route.ts +54 -0
  10. package/apps/agents-server/src/app/agents/[agentName]/book/BookEditorWrapper.tsx +140 -0
  11. package/apps/agents-server/src/app/agents/[agentName]/book/page.tsx +25 -0
  12. package/apps/agents-server/src/app/agents/[agentName]/book+chat/{SelfLearningBook.tsx → AgentBookAndChatComponent.tsx} +5 -46
  13. package/apps/agents-server/src/app/agents/[agentName]/book+chat/page.tsx +7 -4
  14. package/apps/agents-server/src/app/agents/[agentName]/chat/AgentChatWrapper.tsx +38 -0
  15. package/apps/agents-server/src/app/agents/[agentName]/chat/page.tsx +23 -0
  16. package/apps/agents-server/src/app/agents/[agentName]/page.tsx +13 -6
  17. package/apps/agents-server/src/app/agents/page.tsx +11 -0
  18. package/apps/agents-server/src/app/api/chat/route.ts +1 -1
  19. package/apps/agents-server/src/app/api/chat-streaming/route.ts +5 -1
  20. package/apps/agents-server/src/app/api/upload/route.ts +75 -0
  21. package/apps/agents-server/src/tools/$provideAgentCollectionForServer.ts +1 -0
  22. package/apps/agents-server/src/tools/$provideCdnForServer.ts +28 -0
  23. package/apps/agents-server/src/utils/cdn/classes/DigitalOceanSpaces.ts +119 -0
  24. package/apps/agents-server/src/utils/cdn/interfaces/IFilesStorage.ts +32 -0
  25. package/apps/agents-server/src/utils/cdn/interfaces/IStorage.ts +14 -0
  26. package/apps/agents-server/src/utils/cdn/utils/getUserFileCdnKey.ts +27 -0
  27. package/apps/agents-server/src/utils/cdn/utils/nameToSubfolderPath.ts +9 -0
  28. package/apps/agents-server/src/utils/cdn/utils/nextRequestToNodeRequest.ts +27 -0
  29. package/apps/agents-server/src/utils/validators/validateMimeType.ts +24 -0
  30. package/apps/agents-server/tsconfig.json +1 -1
  31. package/esm/index.es.js +191 -165
  32. package/esm/index.es.js.map +1 -1
  33. package/esm/typings/servers.d.ts +1 -7
  34. package/esm/typings/src/_packages/components.index.d.ts +4 -0
  35. package/esm/typings/src/_packages/core.index.d.ts +16 -14
  36. package/esm/typings/src/_packages/types.index.d.ts +12 -6
  37. package/esm/typings/src/book-2.0/agent-source/AgentModelRequirements.d.ts +6 -1
  38. package/esm/typings/src/book-2.0/agent-source/AgentSourceParseResult.d.ts +1 -1
  39. package/esm/typings/src/book-2.0/agent-source/createCommitmentRegex.d.ts +1 -1
  40. package/esm/typings/src/book-2.0/agent-source/padBook.d.ts +2 -0
  41. package/esm/typings/src/book-2.0/agent-source/string_book.d.ts +2 -0
  42. package/esm/typings/src/book-components/Chat/AgentChat/AgentChat.d.ts +14 -0
  43. package/esm/typings/src/book-components/Chat/AgentChat/AgentChat.test.d.ts +1 -0
  44. package/esm/typings/src/book-components/Chat/AgentChat/AgentChatProps.d.ts +13 -0
  45. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +5 -60
  46. package/esm/typings/src/{book-2.0/commitments → commitments}/ACTION/ACTION.d.ts +1 -1
  47. package/esm/typings/src/{book-2.0/commitments → commitments}/DELETE/DELETE.d.ts +1 -1
  48. package/esm/typings/src/{book-2.0/commitments → commitments}/FORMAT/FORMAT.d.ts +1 -1
  49. package/esm/typings/src/{book-2.0/commitments → commitments}/GOAL/GOAL.d.ts +1 -1
  50. package/esm/typings/src/{book-2.0/commitments → commitments}/KNOWLEDGE/KNOWLEDGE.d.ts +1 -5
  51. package/esm/typings/src/{book-2.0/commitments → commitments}/MEMORY/MEMORY.d.ts +1 -1
  52. package/esm/typings/src/{book-2.0/commitments → commitments}/MESSAGE/MESSAGE.d.ts +1 -1
  53. package/esm/typings/src/{book-2.0/commitments → commitments}/META/META.d.ts +1 -1
  54. package/esm/typings/src/{book-2.0/commitments → commitments}/META_IMAGE/META_IMAGE.d.ts +1 -1
  55. package/esm/typings/src/{book-2.0/commitments → commitments}/META_LINK/META_LINK.d.ts +1 -1
  56. package/esm/typings/src/{book-2.0/commitments → commitments}/MODEL/MODEL.d.ts +1 -1
  57. package/esm/typings/src/{book-2.0/commitments → commitments}/NOTE/NOTE.d.ts +1 -1
  58. package/esm/typings/src/{book-2.0/commitments → commitments}/PERSONA/PERSONA.d.ts +1 -1
  59. package/esm/typings/src/{book-2.0/commitments → commitments}/RULE/RULE.d.ts +1 -1
  60. package/esm/typings/src/{book-2.0/commitments → commitments}/SAMPLE/SAMPLE.d.ts +1 -1
  61. package/esm/typings/src/{book-2.0/commitments → commitments}/SCENARIO/SCENARIO.d.ts +1 -1
  62. package/esm/typings/src/{book-2.0/commitments → commitments}/STYLE/STYLE.d.ts +1 -1
  63. package/esm/typings/src/{book-2.0/commitments → commitments}/_base/BaseCommitmentDefinition.d.ts +1 -1
  64. package/esm/typings/src/{book-2.0/commitments → commitments}/_base/CommitmentDefinition.d.ts +1 -1
  65. package/esm/typings/src/{book-2.0/commitments → commitments}/_base/NotYetImplementedCommitmentDefinition.d.ts +1 -1
  66. package/esm/typings/src/{book-2.0/commitments → commitments}/_base/createEmptyAgentModelRequirements.d.ts +1 -1
  67. package/esm/typings/src/conversion/validation/validatePipeline.d.ts +2 -0
  68. package/esm/typings/src/execution/LlmExecutionTools.d.ts +1 -1
  69. package/esm/typings/src/execution/utils/validatePromptResult.d.ts +2 -0
  70. package/esm/typings/src/llm-providers/agent/Agent.d.ts +3 -7
  71. package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +1 -1
  72. package/esm/typings/src/llm-providers/agent/CreateAgentLlmExecutionToolsOptions.d.ts +1 -1
  73. package/esm/typings/src/llm-providers/agent/RemoteAgent.d.ts +32 -0
  74. package/esm/typings/src/llm-providers/agent/RemoteAgentOptions.d.ts +11 -0
  75. package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +5 -1
  76. package/esm/typings/src/pipeline/validatePipelineString.d.ts +2 -0
  77. package/esm/typings/src/storage/_common/PromptbookStorage.d.ts +1 -0
  78. package/esm/typings/src/types/typeAliases.d.ts +6 -0
  79. package/esm/typings/src/utils/color/internal-utils/checkChannelValue.d.ts +0 -3
  80. package/esm/typings/src/utils/random/$generateBookBoilerplate.d.ts +2 -2
  81. package/esm/typings/src/utils/random/$randomFullnameWithColor.d.ts +1 -1
  82. package/esm/typings/src/utils/validators/parameterName/validateParameterName.d.ts +2 -0
  83. package/esm/typings/src/version.d.ts +1 -1
  84. package/package.json +1 -1
  85. package/umd/index.umd.js +191 -165
  86. package/umd/index.umd.js.map +1 -1
  87. /package/esm/typings/src/{book-2.0/commitments → commitments}/_base/BookCommitment.d.ts +0 -0
  88. /package/esm/typings/src/{book-2.0/commitments → commitments}/_base/ParsedCommitment.d.ts +0 -0
  89. /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-45';
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-45';
60
60
  */
61
61
  const REMOTE_SERVER_URLS = [
62
62
  {
63
- title: 'Promptbook',
64
- description: `Servers of Promptbook.studio`,
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
@@ -3947,6 +3949,8 @@ function checkExpectations(expectations, value) {
3947
3949
  * This function provides a common abstraction for result validation that can be used
3948
3950
  * by both execution logic and caching logic to ensure consistency.
3949
3951
  *
3952
+ * Note: [🔂] This function is idempotent.
3953
+ *
3950
3954
  * @param options - The validation options including result string, expectations, and format
3951
3955
  * @returns Validation result with processed string and validity status
3952
3956
  * @private internal function of `createPipelineExecutor` and `cacheLlmTools`
@@ -5714,6 +5718,8 @@ function isValidPipelineUrl(url) {
5714
5718
  * - if it is valid json
5715
5719
  * - if it is meaningful
5716
5720
  *
5721
+ * Note: [🔂] This function is idempotent.
5722
+ *
5717
5723
  * @param pipeline valid or invalid PipelineJson
5718
5724
  * @returns the same pipeline if it is logically valid
5719
5725
  * @throws {PipelineLogicError} on logical error in the pipeline
@@ -6030,6 +6036,8 @@ var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"
6030
6036
  * Function `validatePipelineString` will validate the if the string is a valid pipeline string
6031
6037
  * It does not check if the string is fully logically correct, but if it is a string that can be a pipeline string or the string looks completely different.
6032
6038
  *
6039
+ * Note: [🔂] This function is idempotent.
6040
+ *
6033
6041
  * @param {string} pipelineString the candidate for a pipeline string
6034
6042
  * @returns {PipelineString} the same string as input, but validated as valid
6035
6043
  * @throws {ParseError} if the string is not a valid pipeline string
@@ -10086,6 +10094,8 @@ function removeQuotes(text) {
10086
10094
  * Function `validateParameterName` will normalize and validate a parameter name for use in pipelines.
10087
10095
  * It removes diacritics, emojis, and quotes, normalizes to camelCase, and checks for reserved names and invalid characters.
10088
10096
  *
10097
+ * Note: [🔂] This function is idempotent.
10098
+ *
10089
10099
  * @param parameterName The parameter name to validate and normalize.
10090
10100
  * @returns The validated and normalized parameter name.
10091
10101
  * @throws {ParseError} If the parameter name is empty, reserved, or contains invalid characters.
@@ -12066,6 +12076,8 @@ const PADDING_LINES = 11;
12066
12076
  /**
12067
12077
  * A function that adds padding to the book content
12068
12078
  *
12079
+ * Note: [🔂] This function is idempotent.
12080
+ *
12069
12081
  * @public exported from `@promptbook/core`
12070
12082
  */
12071
12083
  function padBook(content) {
@@ -15061,6 +15073,35 @@ function $initializeRunCommand(program) {
15061
15073
  * TODO: [🖇] What about symlinks? Maybe flag --follow-symlinks
15062
15074
  */
15063
15075
 
15076
+ /**
15077
+ * !!!!!
15078
+ * Remote server is a proxy server that uses its execution tools internally and exposes the executor interface externally.
15079
+ *
15080
+ * You can simply use `RemoteExecutionTools` on client-side javascript and connect to your remote server.
15081
+ * This is useful to make all logic on browser side but not expose your API keys or no need to use customer's GPU.
15082
+ *
15083
+ * @see https://github.com/webgptorg/promptbook#remote-server
15084
+ * @public exported from `@promptbook/remote-server`
15085
+ * <- TODO: !!!! Maybe change to `@promptbook/agent-server`
15086
+ */
15087
+ async function startAgentServer(options) {
15088
+ const { port = 4440 } = options;
15089
+ // TODO: !!!! [🌕]
15090
+ const agentsServerRoot = join(__dirname, '../apps/agents-server');
15091
+ console.trace(`!!! Starting agents server on port ${port}...`);
15092
+ console.log(`!!! cwd`, process.cwd());
15093
+ console.log(`!!! __dirname`, __dirname);
15094
+ console.log(`!!! agentsServerRoot`, agentsServerRoot);
15095
+ await $execCommand({
15096
+ cwd: agentsServerRoot,
15097
+ command: `next dev --port ${port} `,
15098
+ isVerbose: true,
15099
+ });
15100
+ }
15101
+ /**
15102
+ * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
15103
+ */
15104
+
15064
15105
  /**
15065
15106
  * Initializes `start-agents-server` command for Promptbook CLI utilities
15066
15107
  *
@@ -15140,11 +15181,7 @@ function $initializeStartAgentsServerCommand(program) {
15140
15181
  isVerbose: true,
15141
15182
  });
15142
15183
  */
15143
- await $execCommand({
15144
- cwd: './apps/agents-server',
15145
- command: `next dev --port ${port} `,
15146
- isVerbose: true,
15147
- });
15184
+ await startAgentServer({ port });
15148
15185
  }));
15149
15186
  }
15150
15187
  /**
@@ -18809,26 +18846,6 @@ const GOOGLE_MODELS = exportJson({
18809
18846
  output: pricing(`$0.45 / 1M tokens`),
18810
18847
  },
18811
18848
  },
18812
- {
18813
- modelVariant: 'CHAT',
18814
- modelTitle: 'Gemini 2.0 Flash',
18815
- modelName: 'gemini-2.0-flash',
18816
- 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.',
18817
- pricing: {
18818
- prompt: pricing(`$0.35 / 1M tokens`),
18819
- output: pricing(`$1.05 / 1M tokens`),
18820
- },
18821
- },
18822
- {
18823
- modelVariant: 'CHAT',
18824
- modelTitle: 'Gemini 2.0 Flash Lite',
18825
- modelName: 'gemini-2.0-flash-lite',
18826
- 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.',
18827
- pricing: {
18828
- prompt: pricing(`$0.20 / 1M tokens`),
18829
- output: pricing(`$0.60 / 1M tokens`),
18830
- },
18831
- },
18832
18849
  {
18833
18850
  modelVariant: 'CHAT',
18834
18851
  modelTitle: 'Gemini 2.0 Flash Thinking',
@@ -20365,7 +20382,7 @@ class OpenAiExecutionTools extends OpenAiCompatibleExecutionTools {
20365
20382
  *
20366
20383
  * This is useful for calling OpenAI API with a single assistant, for more wide usage use `OpenAiExecutionTools`.
20367
20384
  *
20368
- * Note: [🦖] There are several different things in Promptbook:
20385
+ * !!! Note: [🦖] There are several different things in Promptbook:
20369
20386
  * - `Agent` - which represents an AI Agent with its source, memories, actions, etc. Agent is a higher-level abstraction which is internally using:
20370
20387
  * - `LlmExecutionTools` - which wraps one or more LLM models and provides an interface to execute them
20371
20388
  * - `AgentLlmExecutionTools` - which is a specific implementation of `LlmExecutionTools` that wraps another LlmExecutionTools and applies agent-specific system prompts and requirements
@@ -20471,17 +20488,21 @@ class OpenAiAssistantExecutionTools extends OpenAiExecutionTools {
20471
20488
  console.info('connect', stream.currentEvent);
20472
20489
  }
20473
20490
  });
20491
+ /*
20474
20492
  stream.on('messageDelta', (messageDelta) => {
20475
- var _a;
20476
- if (this.options.isVerbose &&
20493
+ if (
20494
+ this.options.isVerbose &&
20477
20495
  messageDelta &&
20478
20496
  messageDelta.content &&
20479
20497
  messageDelta.content[0] &&
20480
- messageDelta.content[0].type === 'text') {
20481
- console.info('messageDelta', (_a = messageDelta.content[0].text) === null || _a === void 0 ? void 0 : _a.value);
20498
+ messageDelta.content[0].type === 'text'
20499
+ ) {
20500
+ console.info('messageDelta', messageDelta.content[0].text?.value);
20482
20501
  }
20502
+
20483
20503
  // <- TODO: [🐚] Make streaming and running tasks working
20484
20504
  });
20505
+ */
20485
20506
  stream.on('messageCreated', (message) => {
20486
20507
  if (this.options.isVerbose) {
20487
20508
  console.info('messageCreated', message);
@@ -20561,64 +20582,85 @@ class OpenAiAssistantExecutionTools extends OpenAiExecutionTools {
20561
20582
  throw new NotAllowed(`Creating new assistants is not allowed. Set \`isCreatingNewAssistantsAllowed: true\` in options to enable this feature.`);
20562
20583
  }
20563
20584
  // await this.playground();
20564
- const { name, instructions } = options;
20585
+ const { name, instructions, knowledgeSources } = options;
20565
20586
  const client = await this.getClient();
20566
- /*/
20567
- //TODO: !!!
20568
- async function downloadFile(url: string, folder = './tmp'): Promise<string> {
20569
- const filename = path.basename(url.split('?')[0]);
20570
- const filepath = path.join(folder, filename);
20571
-
20572
- if (!fs.existsSync(folder)) fs.mkdirSync(folder);
20573
-
20574
- const res = await fetch(url);
20575
- if (!res.ok) throw new Error(`Download error: ${url}`);
20576
- const buffer = await res.arrayBuffer();
20577
- fs.writeFileSync(filepath, Buffer.from(buffer));
20578
- console.log(`📥 File downloaded: ${filename}`);
20579
-
20580
- return filepath;
20581
- }
20582
-
20583
- async function uploadFileToOpenAI(filepath: string) {
20584
- const file = await client.files.create({
20585
- file: fs.createReadStream(filepath),
20586
- 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`,
20587
20596
  });
20588
- console.log(`⬆️ File uploaded to OpenAI: ${file.filename} (${file.id})`);
20589
- return file;
20590
- }
20591
-
20592
- // 🌐 URL addresses of files to upload
20593
- const fileUrls = [
20594
- 'https://raw.githubusercontent.com/vercel/next.js/canary/packages/next/README.md',
20595
- 'https://raw.githubusercontent.com/openai/openai-cookbook/main/examples/How_to_call_the_Assistants_API_with_Node.js.ipynb',
20596
- ];
20597
-
20598
- // 1️⃣ Download files from URL
20599
- const localFiles = [];
20600
- for (const url of fileUrls) {
20601
- const filepath = await downloadFile(url);
20602
- localFiles.push(filepath);
20603
- }
20604
-
20605
- // 2️⃣ Upload files to OpenAI
20606
- const uploadedFiles = [];
20607
- for (const filepath of localFiles) {
20608
- const file = await uploadFileToOpenAI(filepath);
20609
- uploadedFiles.push(file.id);
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
+ }
20610
20646
  }
20611
- /**/
20612
- // alert('!!!! Creating new OpenAI assistant');
20613
- // 3️⃣ Create assistant with uploaded files
20614
- const assistant = await client.beta.assistants.create({
20647
+ // Create assistant with vector store attached
20648
+ const assistantConfig = {
20615
20649
  name,
20616
20650
  description: 'Assistant created via Promptbook',
20617
20651
  model: 'gpt-4o',
20618
20652
  instructions,
20619
20653
  tools: [/* TODO: [🧠] Maybe add { type: 'code_interpreter' }, */ { type: 'file_search' }],
20620
- // !!!! file_ids: uploadedFiles,
20621
- });
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);
20622
20664
  console.log(`✅ Assistant created: ${assistant.id}`);
20623
20665
  // TODO: !!!! Try listing existing assistants
20624
20666
  // TODO: !!!! Try marking existing assistants by DISCRIMINANT
@@ -22192,40 +22234,6 @@ const _FormattedBookInMarkdownTranspilerRegistration = $bookTranspilersRegister.
22192
22234
  * Note: [💞] Ignore a discrepancy between file name and entity name
22193
22235
  */
22194
22236
 
22195
- /**
22196
- * Creates an empty/basic agent model requirements object
22197
- * This serves as the starting point for the reduce-like pattern
22198
- * where each commitment applies its changes to build the final requirements
22199
- *
22200
- * @public exported from `@promptbook/core`
22201
- */
22202
- function createEmptyAgentModelRequirements() {
22203
- return {
22204
- systemMessage: '',
22205
- // modelName: 'gpt-5',
22206
- modelName: 'gemini-2.5-flash-lite',
22207
- temperature: 0.7,
22208
- topP: 0.9,
22209
- topK: 50,
22210
- };
22211
- }
22212
- /**
22213
- * Creates a basic agent model requirements with just the agent name
22214
- * This is used when we have an agent name but no commitments
22215
- *
22216
- * @public exported from `@promptbook/core`
22217
- */
22218
- function createBasicAgentModelRequirements(agentName) {
22219
- const empty = createEmptyAgentModelRequirements();
22220
- return {
22221
- ...empty,
22222
- systemMessage: `You are ${agentName || 'AI Agent'}`,
22223
- };
22224
- }
22225
- /**
22226
- * TODO: [🐤] Deduplicate `AgentModelRequirements` and `ModelRequirements` model requirements
22227
- */
22228
-
22229
22237
  /**
22230
22238
  * Generates a regex pattern to match a specific commitment
22231
22239
  *
@@ -22759,23 +22767,19 @@ class KnowledgeCommitmentDefinition extends BaseCommitmentDefinition {
22759
22767
  `);
22760
22768
  }
22761
22769
  applyToAgentModelRequirements(requirements, content) {
22762
- var _a;
22763
22770
  const trimmedContent = content.trim();
22764
22771
  if (!trimmedContent) {
22765
22772
  return requirements;
22766
22773
  }
22767
22774
  // Check if content is a URL (external knowledge source)
22768
- if (this.isUrl(trimmedContent)) {
22775
+ if (isValidUrl(trimmedContent)) {
22769
22776
  // Store the URL for later async processing
22770
22777
  const updatedRequirements = {
22771
22778
  ...requirements,
22772
- metadata: {
22773
- ...requirements.metadata,
22774
- knowledgeSources: [
22775
- ...(((_a = requirements.metadata) === null || _a === void 0 ? void 0 : _a.knowledgeSources) || []),
22776
- trimmedContent,
22777
- ],
22778
- },
22779
+ knowledgeSources: [
22780
+ ...(requirements.knowledgeSources || []),
22781
+ trimmedContent,
22782
+ ],
22779
22783
  };
22780
22784
  // Add placeholder information about knowledge sources to system message
22781
22785
  const knowledgeInfo = `Knowledge Source URL: ${trimmedContent} (will be processed for retrieval during chat)`;
@@ -22787,18 +22791,6 @@ class KnowledgeCommitmentDefinition extends BaseCommitmentDefinition {
22787
22791
  return this.appendToSystemMessage(requirements, knowledgeSection, '\n\n');
22788
22792
  }
22789
22793
  }
22790
- /**
22791
- * Check if content is a URL
22792
- */
22793
- isUrl(content) {
22794
- try {
22795
- new URL(content);
22796
- return true;
22797
- }
22798
- catch (_a) {
22799
- return false;
22800
- }
22801
- }
22802
22794
  }
22803
22795
  /**
22804
22796
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -24096,6 +24088,40 @@ function getCommitmentDefinition(type) {
24096
24088
  * Note: [💞] Ignore a discrepancy between file name and entity name
24097
24089
  */
24098
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
+
24099
24125
  /**
24100
24126
  * Parses agent source using the new commitment system with multiline support
24101
24127
  * This function replaces the hardcoded commitment parsing in the original parseAgentSource
@@ -24186,29 +24212,6 @@ function parseAgentSourceWithCommitments(agentSource) {
24186
24212
  };
24187
24213
  }
24188
24214
 
24189
- /**
24190
- * Removes comment lines (lines starting with #) from a system message
24191
- * This is used to clean up the final system message before sending it to the AI model
24192
- * while preserving the original content with comments in metadata
24193
- *
24194
- * @param systemMessage The system message that may contain comment lines
24195
- * @returns The system message with comment lines removed
24196
- *
24197
- * @private - TODO: [🧠] Maybe should be public?
24198
- */
24199
- function removeCommentsFromSystemMessage(systemMessage) {
24200
- if (!systemMessage) {
24201
- return systemMessage;
24202
- }
24203
- const lines = systemMessage.split('\n');
24204
- const filteredLines = lines.filter((line) => {
24205
- const trimmedLine = line.trim();
24206
- // Remove lines that start with # (comments)
24207
- return !trimmedLine.startsWith('#');
24208
- });
24209
- return filteredLines.join('\n').trim();
24210
- }
24211
-
24212
24215
  /**
24213
24216
  * Parses parameters from text using both supported notations:
24214
24217
  * 1. @Parameter - single word parameter starting with @
@@ -24267,6 +24270,29 @@ function parseParameters(text) {
24267
24270
  return uniqueParameters;
24268
24271
  }
24269
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
+
24270
24296
  /**
24271
24297
  * Creates agent model requirements using the new commitment system
24272
24298
  * This function uses a reduce-like pattern where each commitment applies its changes