@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/umd/index.umd.js CHANGED
@@ -56,7 +56,7 @@
56
56
  * @generated
57
57
  * @see https://github.com/webgptorg/promptbook
58
58
  */
59
- const PROMPTBOOK_ENGINE_VERSION = '0.103.0-45';
59
+ const PROMPTBOOK_ENGINE_VERSION = '0.103.0-47';
60
60
  /**
61
61
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
62
62
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -69,15 +69,20 @@
69
69
  */
70
70
  const REMOTE_SERVER_URLS = [
71
71
  {
72
- title: 'Promptbook',
73
- description: `Servers of Promptbook.studio`,
72
+ title: 'Promptbook.Studio',
73
+ description: `Server of Promptbook.studio`,
74
74
  owner: 'AI Web, LLC <legal@ptbk.io> (https://www.ptbk.io/)',
75
- isAnonymousModeAllowed: true,
76
75
  urls: [
77
76
  'https://promptbook.s5.ptbk.io/',
78
77
  // Note: Servers 1-4 are not running
79
78
  ],
80
79
  },
80
+ {
81
+ title: 'Testing Agents',
82
+ description: `Testing Agents server on Vercel`,
83
+ owner: 'AI Web, LLC <legal@ptbk.io> (https://www.ptbk.io/)',
84
+ urls: ['https://s6.ptbk.io/'],
85
+ },
81
86
  /*
82
87
  Note: Working on older version of Promptbook and not supported anymore
83
88
  {
@@ -335,9 +340,6 @@
335
340
  throw new Error(`${channelName} channel is greater than 255, it is ${value}`);
336
341
  }
337
342
  }
338
- /**
339
- * TODO: [🧠][🚓] Is/which combination it better to use asserts/check, validate or is utility function?
340
- */
341
343
 
342
344
  /**
343
345
  * Color object represents an RGB color with alpha channel
@@ -3956,6 +3958,8 @@
3956
3958
  * This function provides a common abstraction for result validation that can be used
3957
3959
  * by both execution logic and caching logic to ensure consistency.
3958
3960
  *
3961
+ * Note: [🔂] This function is idempotent.
3962
+ *
3959
3963
  * @param options - The validation options including result string, expectations, and format
3960
3964
  * @returns Validation result with processed string and validity status
3961
3965
  * @private internal function of `createPipelineExecutor` and `cacheLlmTools`
@@ -5723,6 +5727,8 @@
5723
5727
  * - if it is valid json
5724
5728
  * - if it is meaningful
5725
5729
  *
5730
+ * Note: [🔂] This function is idempotent.
5731
+ *
5726
5732
  * @param pipeline valid or invalid PipelineJson
5727
5733
  * @returns the same pipeline if it is logically valid
5728
5734
  * @throws {PipelineLogicError} on logical error in the pipeline
@@ -6039,6 +6045,8 @@
6039
6045
  * Function `validatePipelineString` will validate the if the string is a valid pipeline string
6040
6046
  * 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.
6041
6047
  *
6048
+ * Note: [🔂] This function is idempotent.
6049
+ *
6042
6050
  * @param {string} pipelineString the candidate for a pipeline string
6043
6051
  * @returns {PipelineString} the same string as input, but validated as valid
6044
6052
  * @throws {ParseError} if the string is not a valid pipeline string
@@ -10095,6 +10103,8 @@
10095
10103
  * Function `validateParameterName` will normalize and validate a parameter name for use in pipelines.
10096
10104
  * It removes diacritics, emojis, and quotes, normalizes to camelCase, and checks for reserved names and invalid characters.
10097
10105
  *
10106
+ * Note: [🔂] This function is idempotent.
10107
+ *
10098
10108
  * @param parameterName The parameter name to validate and normalize.
10099
10109
  * @returns The validated and normalized parameter name.
10100
10110
  * @throws {ParseError} If the parameter name is empty, reserved, or contains invalid characters.
@@ -12075,6 +12085,8 @@
12075
12085
  /**
12076
12086
  * A function that adds padding to the book content
12077
12087
  *
12088
+ * Note: [🔂] This function is idempotent.
12089
+ *
12078
12090
  * @public exported from `@promptbook/core`
12079
12091
  */
12080
12092
  function padBook(content) {
@@ -15070,6 +15082,35 @@
15070
15082
  * TODO: [🖇] What about symlinks? Maybe flag --follow-symlinks
15071
15083
  */
15072
15084
 
15085
+ /**
15086
+ * !!!!!
15087
+ * Remote server is a proxy server that uses its execution tools internally and exposes the executor interface externally.
15088
+ *
15089
+ * You can simply use `RemoteExecutionTools` on client-side javascript and connect to your remote server.
15090
+ * This is useful to make all logic on browser side but not expose your API keys or no need to use customer's GPU.
15091
+ *
15092
+ * @see https://github.com/webgptorg/promptbook#remote-server
15093
+ * @public exported from `@promptbook/remote-server`
15094
+ * <- TODO: !!!! Maybe change to `@promptbook/agent-server`
15095
+ */
15096
+ async function startAgentServer(options) {
15097
+ const { port = 4440 } = options;
15098
+ // TODO: !!!! [🌕]
15099
+ const agentsServerRoot = path.join(__dirname, '../apps/agents-server');
15100
+ console.trace(`!!! Starting agents server on port ${port}...`);
15101
+ console.log(`!!! cwd`, process.cwd());
15102
+ console.log(`!!! __dirname`, __dirname);
15103
+ console.log(`!!! agentsServerRoot`, agentsServerRoot);
15104
+ await $execCommand({
15105
+ cwd: agentsServerRoot,
15106
+ command: `next dev --port ${port} `,
15107
+ isVerbose: true,
15108
+ });
15109
+ }
15110
+ /**
15111
+ * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
15112
+ */
15113
+
15073
15114
  /**
15074
15115
  * Initializes `start-agents-server` command for Promptbook CLI utilities
15075
15116
  *
@@ -15149,11 +15190,7 @@
15149
15190
  isVerbose: true,
15150
15191
  });
15151
15192
  */
15152
- await $execCommand({
15153
- cwd: './apps/agents-server',
15154
- command: `next dev --port ${port} `,
15155
- isVerbose: true,
15156
- });
15193
+ await startAgentServer({ port });
15157
15194
  }));
15158
15195
  }
15159
15196
  /**
@@ -18818,26 +18855,6 @@
18818
18855
  output: pricing(`$0.45 / 1M tokens`),
18819
18856
  },
18820
18857
  },
18821
- {
18822
- modelVariant: 'CHAT',
18823
- modelTitle: 'Gemini 2.0 Flash',
18824
- modelName: 'gemini-2.0-flash',
18825
- 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.',
18826
- pricing: {
18827
- prompt: pricing(`$0.35 / 1M tokens`),
18828
- output: pricing(`$1.05 / 1M tokens`),
18829
- },
18830
- },
18831
- {
18832
- modelVariant: 'CHAT',
18833
- modelTitle: 'Gemini 2.0 Flash Lite',
18834
- modelName: 'gemini-2.0-flash-lite',
18835
- 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.',
18836
- pricing: {
18837
- prompt: pricing(`$0.20 / 1M tokens`),
18838
- output: pricing(`$0.60 / 1M tokens`),
18839
- },
18840
- },
18841
18858
  {
18842
18859
  modelVariant: 'CHAT',
18843
18860
  modelTitle: 'Gemini 2.0 Flash Thinking',
@@ -20374,7 +20391,7 @@
20374
20391
  *
20375
20392
  * This is useful for calling OpenAI API with a single assistant, for more wide usage use `OpenAiExecutionTools`.
20376
20393
  *
20377
- * Note: [🦖] There are several different things in Promptbook:
20394
+ * !!! Note: [🦖] There are several different things in Promptbook:
20378
20395
  * - `Agent` - which represents an AI Agent with its source, memories, actions, etc. Agent is a higher-level abstraction which is internally using:
20379
20396
  * - `LlmExecutionTools` - which wraps one or more LLM models and provides an interface to execute them
20380
20397
  * - `AgentLlmExecutionTools` - which is a specific implementation of `LlmExecutionTools` that wraps another LlmExecutionTools and applies agent-specific system prompts and requirements
@@ -20480,17 +20497,21 @@
20480
20497
  console.info('connect', stream.currentEvent);
20481
20498
  }
20482
20499
  });
20500
+ /*
20483
20501
  stream.on('messageDelta', (messageDelta) => {
20484
- var _a;
20485
- if (this.options.isVerbose &&
20502
+ if (
20503
+ this.options.isVerbose &&
20486
20504
  messageDelta &&
20487
20505
  messageDelta.content &&
20488
20506
  messageDelta.content[0] &&
20489
- messageDelta.content[0].type === 'text') {
20490
- console.info('messageDelta', (_a = messageDelta.content[0].text) === null || _a === void 0 ? void 0 : _a.value);
20507
+ messageDelta.content[0].type === 'text'
20508
+ ) {
20509
+ console.info('messageDelta', messageDelta.content[0].text?.value);
20491
20510
  }
20511
+
20492
20512
  // <- TODO: [🐚] Make streaming and running tasks working
20493
20513
  });
20514
+ */
20494
20515
  stream.on('messageCreated', (message) => {
20495
20516
  if (this.options.isVerbose) {
20496
20517
  console.info('messageCreated', message);
@@ -20570,64 +20591,85 @@
20570
20591
  throw new NotAllowed(`Creating new assistants is not allowed. Set \`isCreatingNewAssistantsAllowed: true\` in options to enable this feature.`);
20571
20592
  }
20572
20593
  // await this.playground();
20573
- const { name, instructions } = options;
20594
+ const { name, instructions, knowledgeSources } = options;
20574
20595
  const client = await this.getClient();
20575
- /*/
20576
- //TODO: !!!
20577
- async function downloadFile(url: string, folder = './tmp'): Promise<string> {
20578
- const filename = path.basename(url.split('?')[0]);
20579
- const filepath = path.join(folder, filename);
20580
-
20581
- if (!fs.existsSync(folder)) fs.mkdirSync(folder);
20582
-
20583
- const res = await fetch(url);
20584
- if (!res.ok) throw new Error(`Download error: ${url}`);
20585
- const buffer = await res.arrayBuffer();
20586
- fs.writeFileSync(filepath, Buffer.from(buffer));
20587
- console.log(`📥 File downloaded: ${filename}`);
20588
-
20589
- return filepath;
20590
- }
20591
-
20592
- async function uploadFileToOpenAI(filepath: string) {
20593
- const file = await client.files.create({
20594
- file: fs.createReadStream(filepath),
20595
- purpose: 'assistants',
20596
+ let vectorStoreId;
20597
+ // If knowledge sources are provided, create a vector store with them
20598
+ if (knowledgeSources && knowledgeSources.length > 0) {
20599
+ if (this.options.isVerbose) {
20600
+ console.info(`📚 Creating vector store with ${knowledgeSources.length} knowledge sources...`);
20601
+ }
20602
+ // Create a vector store
20603
+ const vectorStore = await client.beta.vectorStores.create({
20604
+ name: `${name} Knowledge Base`,
20596
20605
  });
20597
- console.log(`⬆️ File uploaded to OpenAI: ${file.filename} (${file.id})`);
20598
- return file;
20599
- }
20600
-
20601
- // 🌐 URL addresses of files to upload
20602
- const fileUrls = [
20603
- 'https://raw.githubusercontent.com/vercel/next.js/canary/packages/next/README.md',
20604
- 'https://raw.githubusercontent.com/openai/openai-cookbook/main/examples/How_to_call_the_Assistants_API_with_Node.js.ipynb',
20605
- ];
20606
-
20607
- // 1️⃣ Download files from URL
20608
- const localFiles = [];
20609
- for (const url of fileUrls) {
20610
- const filepath = await downloadFile(url);
20611
- localFiles.push(filepath);
20612
- }
20613
-
20614
- // 2️⃣ Upload files to OpenAI
20615
- const uploadedFiles = [];
20616
- for (const filepath of localFiles) {
20617
- const file = await uploadFileToOpenAI(filepath);
20618
- uploadedFiles.push(file.id);
20606
+ vectorStoreId = vectorStore.id;
20607
+ if (this.options.isVerbose) {
20608
+ console.info(`✅ Vector store created: ${vectorStoreId}`);
20609
+ }
20610
+ // Upload files from knowledge sources to the vector store
20611
+ const fileStreams = [];
20612
+ for (const source of knowledgeSources) {
20613
+ try {
20614
+ // Check if it's a URL
20615
+ if (source.startsWith('http://') || source.startsWith('https://')) {
20616
+ // Download the file
20617
+ const response = await fetch(source);
20618
+ if (!response.ok) {
20619
+ console.error(`Failed to download ${source}: ${response.statusText}`);
20620
+ continue;
20621
+ }
20622
+ const buffer = await response.arrayBuffer();
20623
+ const filename = source.split('/').pop() || 'downloaded-file';
20624
+ const blob = new Blob([buffer]);
20625
+ const file = new File([blob], filename);
20626
+ fileStreams.push(file);
20627
+ }
20628
+ else {
20629
+ // Assume it's a local file path
20630
+ // Note: This will work in Node.js environment
20631
+ // For browser environments, this would need different handling
20632
+ const fs = await import('fs');
20633
+ const fileStream = fs.createReadStream(source);
20634
+ fileStreams.push(fileStream);
20635
+ }
20636
+ }
20637
+ catch (error) {
20638
+ console.error(`Error processing knowledge source ${source}:`, error);
20639
+ }
20640
+ }
20641
+ // Batch upload files to the vector store
20642
+ if (fileStreams.length > 0) {
20643
+ try {
20644
+ await client.beta.vectorStores.fileBatches.uploadAndPoll(vectorStoreId, {
20645
+ files: fileStreams,
20646
+ });
20647
+ if (this.options.isVerbose) {
20648
+ console.info(`✅ Uploaded ${fileStreams.length} files to vector store`);
20649
+ }
20650
+ }
20651
+ catch (error) {
20652
+ console.error('Error uploading files to vector store:', error);
20653
+ }
20654
+ }
20619
20655
  }
20620
- /**/
20621
- // alert('!!!! Creating new OpenAI assistant');
20622
- // 3️⃣ Create assistant with uploaded files
20623
- const assistant = await client.beta.assistants.create({
20656
+ // Create assistant with vector store attached
20657
+ const assistantConfig = {
20624
20658
  name,
20625
20659
  description: 'Assistant created via Promptbook',
20626
20660
  model: 'gpt-4o',
20627
20661
  instructions,
20628
20662
  tools: [/* TODO: [🧠] Maybe add { type: 'code_interpreter' }, */ { type: 'file_search' }],
20629
- // !!!! file_ids: uploadedFiles,
20630
- });
20663
+ };
20664
+ // Attach vector store if created
20665
+ if (vectorStoreId) {
20666
+ assistantConfig.tool_resources = {
20667
+ file_search: {
20668
+ vector_store_ids: [vectorStoreId],
20669
+ },
20670
+ };
20671
+ }
20672
+ const assistant = await client.beta.assistants.create(assistantConfig);
20631
20673
  console.log(`✅ Assistant created: ${assistant.id}`);
20632
20674
  // TODO: !!!! Try listing existing assistants
20633
20675
  // TODO: !!!! Try marking existing assistants by DISCRIMINANT
@@ -22201,40 +22243,6 @@
22201
22243
  * Note: [💞] Ignore a discrepancy between file name and entity name
22202
22244
  */
22203
22245
 
22204
- /**
22205
- * Creates an empty/basic agent model requirements object
22206
- * This serves as the starting point for the reduce-like pattern
22207
- * where each commitment applies its changes to build the final requirements
22208
- *
22209
- * @public exported from `@promptbook/core`
22210
- */
22211
- function createEmptyAgentModelRequirements() {
22212
- return {
22213
- systemMessage: '',
22214
- // modelName: 'gpt-5',
22215
- modelName: 'gemini-2.5-flash-lite',
22216
- temperature: 0.7,
22217
- topP: 0.9,
22218
- topK: 50,
22219
- };
22220
- }
22221
- /**
22222
- * Creates a basic agent model requirements with just the agent name
22223
- * This is used when we have an agent name but no commitments
22224
- *
22225
- * @public exported from `@promptbook/core`
22226
- */
22227
- function createBasicAgentModelRequirements(agentName) {
22228
- const empty = createEmptyAgentModelRequirements();
22229
- return {
22230
- ...empty,
22231
- systemMessage: `You are ${agentName || 'AI Agent'}`,
22232
- };
22233
- }
22234
- /**
22235
- * TODO: [🐤] Deduplicate `AgentModelRequirements` and `ModelRequirements` model requirements
22236
- */
22237
-
22238
22246
  /**
22239
22247
  * Generates a regex pattern to match a specific commitment
22240
22248
  *
@@ -22768,23 +22776,19 @@
22768
22776
  `);
22769
22777
  }
22770
22778
  applyToAgentModelRequirements(requirements, content) {
22771
- var _a;
22772
22779
  const trimmedContent = content.trim();
22773
22780
  if (!trimmedContent) {
22774
22781
  return requirements;
22775
22782
  }
22776
22783
  // Check if content is a URL (external knowledge source)
22777
- if (this.isUrl(trimmedContent)) {
22784
+ if (isValidUrl(trimmedContent)) {
22778
22785
  // Store the URL for later async processing
22779
22786
  const updatedRequirements = {
22780
22787
  ...requirements,
22781
- metadata: {
22782
- ...requirements.metadata,
22783
- knowledgeSources: [
22784
- ...(((_a = requirements.metadata) === null || _a === void 0 ? void 0 : _a.knowledgeSources) || []),
22785
- trimmedContent,
22786
- ],
22787
- },
22788
+ knowledgeSources: [
22789
+ ...(requirements.knowledgeSources || []),
22790
+ trimmedContent,
22791
+ ],
22788
22792
  };
22789
22793
  // Add placeholder information about knowledge sources to system message
22790
22794
  const knowledgeInfo = `Knowledge Source URL: ${trimmedContent} (will be processed for retrieval during chat)`;
@@ -22796,18 +22800,6 @@
22796
22800
  return this.appendToSystemMessage(requirements, knowledgeSection, '\n\n');
22797
22801
  }
22798
22802
  }
22799
- /**
22800
- * Check if content is a URL
22801
- */
22802
- isUrl(content) {
22803
- try {
22804
- new URL(content);
22805
- return true;
22806
- }
22807
- catch (_a) {
22808
- return false;
22809
- }
22810
- }
22811
22803
  }
22812
22804
  /**
22813
22805
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -24105,6 +24097,40 @@
24105
24097
  * Note: [💞] Ignore a discrepancy between file name and entity name
24106
24098
  */
24107
24099
 
24100
+ /**
24101
+ * Creates an empty/basic agent model requirements object
24102
+ * This serves as the starting point for the reduce-like pattern
24103
+ * where each commitment applies its changes to build the final requirements
24104
+ *
24105
+ * @public exported from `@promptbook/core`
24106
+ */
24107
+ function createEmptyAgentModelRequirements() {
24108
+ return {
24109
+ systemMessage: '',
24110
+ // modelName: 'gpt-5',
24111
+ modelName: 'gemini-2.5-flash-lite',
24112
+ temperature: 0.7,
24113
+ topP: 0.9,
24114
+ topK: 50,
24115
+ };
24116
+ }
24117
+ /**
24118
+ * Creates a basic agent model requirements with just the agent name
24119
+ * This is used when we have an agent name but no commitments
24120
+ *
24121
+ * @public exported from `@promptbook/core`
24122
+ */
24123
+ function createBasicAgentModelRequirements(agentName) {
24124
+ const empty = createEmptyAgentModelRequirements();
24125
+ return {
24126
+ ...empty,
24127
+ systemMessage: `You are ${agentName || 'AI Agent'}`,
24128
+ };
24129
+ }
24130
+ /**
24131
+ * TODO: [🐤] Deduplicate `AgentModelRequirements` and `ModelRequirements` model requirements
24132
+ */
24133
+
24108
24134
  /**
24109
24135
  * Parses agent source using the new commitment system with multiline support
24110
24136
  * This function replaces the hardcoded commitment parsing in the original parseAgentSource
@@ -24195,29 +24221,6 @@
24195
24221
  };
24196
24222
  }
24197
24223
 
24198
- /**
24199
- * Removes comment lines (lines starting with #) from a system message
24200
- * This is used to clean up the final system message before sending it to the AI model
24201
- * while preserving the original content with comments in metadata
24202
- *
24203
- * @param systemMessage The system message that may contain comment lines
24204
- * @returns The system message with comment lines removed
24205
- *
24206
- * @private - TODO: [🧠] Maybe should be public?
24207
- */
24208
- function removeCommentsFromSystemMessage(systemMessage) {
24209
- if (!systemMessage) {
24210
- return systemMessage;
24211
- }
24212
- const lines = systemMessage.split('\n');
24213
- const filteredLines = lines.filter((line) => {
24214
- const trimmedLine = line.trim();
24215
- // Remove lines that start with # (comments)
24216
- return !trimmedLine.startsWith('#');
24217
- });
24218
- return filteredLines.join('\n').trim();
24219
- }
24220
-
24221
24224
  /**
24222
24225
  * Parses parameters from text using both supported notations:
24223
24226
  * 1. @Parameter - single word parameter starting with @
@@ -24276,6 +24279,29 @@
24276
24279
  return uniqueParameters;
24277
24280
  }
24278
24281
 
24282
+ /**
24283
+ * Removes comment lines (lines starting with #) from a system message
24284
+ * This is used to clean up the final system message before sending it to the AI model
24285
+ * while preserving the original content with comments in metadata
24286
+ *
24287
+ * @param systemMessage The system message that may contain comment lines
24288
+ * @returns The system message with comment lines removed
24289
+ *
24290
+ * @private - TODO: [🧠] Maybe should be public?
24291
+ */
24292
+ function removeCommentsFromSystemMessage(systemMessage) {
24293
+ if (!systemMessage) {
24294
+ return systemMessage;
24295
+ }
24296
+ const lines = systemMessage.split('\n');
24297
+ const filteredLines = lines.filter((line) => {
24298
+ const trimmedLine = line.trim();
24299
+ // Remove lines that start with # (comments)
24300
+ return !trimmedLine.startsWith('#');
24301
+ });
24302
+ return filteredLines.join('\n').trim();
24303
+ }
24304
+
24279
24305
  /**
24280
24306
  * Creates agent model requirements using the new commitment system
24281
24307
  * This function uses a reduce-like pattern where each commitment applies its changes