@promptbook/cli 0.104.0-1 → 0.104.0-2

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 (113) hide show
  1. package/apps/agents-server/next.config.ts +2 -2
  2. package/apps/agents-server/package.json +6 -1
  3. package/apps/agents-server/public/fonts/OpenMoji-color-cbdt.woff2 +0 -0
  4. package/apps/agents-server/scripts/generate-reserved-paths/generate-reserved-paths.ts +50 -0
  5. package/apps/agents-server/scripts/generate-reserved-paths/tsconfig.json +19 -0
  6. package/apps/agents-server/src/app/AddAgentButton.tsx +4 -3
  7. package/apps/agents-server/src/app/actions.ts +17 -5
  8. package/apps/agents-server/src/app/admin/metadata/MetadataClient.tsx +15 -11
  9. package/apps/agents-server/src/app/agents/[agentName]/AgentOptionsMenu.tsx +51 -7
  10. package/apps/agents-server/src/app/agents/[agentName]/AgentProfileChat.tsx +32 -2
  11. package/apps/agents-server/src/app/agents/[agentName]/AgentProfileWrapper.tsx +2 -0
  12. package/apps/agents-server/src/app/agents/[agentName]/_utils.ts +18 -0
  13. package/apps/agents-server/src/app/agents/[agentName]/agentLinks.tsx +8 -8
  14. package/apps/agents-server/src/app/agents/[agentName]/api/agents/route.ts +17 -26
  15. package/apps/agents-server/src/app/agents/[agentName]/api/chat/route.ts +17 -0
  16. package/apps/agents-server/src/app/agents/[agentName]/api/profile/route.ts +1 -1
  17. package/apps/agents-server/src/app/agents/[agentName]/api/voice/route.ts +1 -1
  18. package/apps/agents-server/src/app/agents/[agentName]/book/BookEditorWrapper.tsx +20 -16
  19. package/apps/agents-server/src/app/agents/[agentName]/book/page.tsx +15 -2
  20. package/apps/agents-server/src/app/agents/[agentName]/book+chat/page.tsx +15 -2
  21. package/apps/agents-server/src/app/agents/[agentName]/chat/page.tsx +12 -0
  22. package/apps/agents-server/src/app/agents/[agentName]/code/api/route.ts +66 -0
  23. package/apps/agents-server/src/app/agents/[agentName]/code/page.tsx +211 -0
  24. package/apps/agents-server/src/app/agents/[agentName]/generateAgentMetadata.ts +5 -0
  25. package/apps/agents-server/src/app/agents/[agentName]/history/actions.ts +2 -2
  26. package/apps/agents-server/src/app/agents/[agentName]/integration/page.tsx +1 -1
  27. package/apps/agents-server/src/app/agents/[agentName]/links/page.tsx +2 -2
  28. package/apps/agents-server/src/app/agents/[agentName]/page.tsx +12 -6
  29. package/apps/agents-server/src/app/agents/[agentName]/system-message/page.tsx +87 -0
  30. package/apps/agents-server/src/app/api/admin-email/route.ts +12 -0
  31. package/apps/agents-server/src/app/api/agents/[agentName]/restore/route.ts +19 -0
  32. package/apps/agents-server/src/app/api/agents/[agentName]/route.ts +42 -0
  33. package/apps/agents-server/src/app/api/agents/route.ts +29 -4
  34. package/apps/agents-server/src/app/api/docs/book.md/route.ts +58 -0
  35. package/apps/agents-server/src/app/api/federated-agents/route.ts +12 -0
  36. package/apps/agents-server/src/app/api/images/[filename]/route.ts +107 -0
  37. package/apps/agents-server/src/app/api/upload/route.ts +119 -45
  38. package/apps/agents-server/src/app/docs/[docId]/page.tsx +2 -3
  39. package/apps/agents-server/src/app/docs/page.tsx +12 -12
  40. package/apps/agents-server/src/app/globals.css +140 -33
  41. package/apps/agents-server/src/app/layout.tsx +27 -22
  42. package/apps/agents-server/src/app/page.tsx +50 -4
  43. package/apps/agents-server/src/app/recycle-bin/actions.ts +20 -14
  44. package/apps/agents-server/src/app/recycle-bin/page.tsx +25 -41
  45. package/apps/agents-server/src/app/sitemap.xml/route.ts +6 -3
  46. package/apps/agents-server/src/components/AgentProfile/AgentProfile.tsx +6 -97
  47. package/apps/agents-server/src/components/AgentProfile/useAgentBackground.ts +97 -0
  48. package/apps/agents-server/src/components/DeletedAgentBanner.tsx +26 -0
  49. package/apps/agents-server/src/components/DocsToolbar/DocsToolbar.tsx +38 -0
  50. package/apps/agents-server/src/components/DocumentationContent/DocumentationContent.tsx +11 -9
  51. package/apps/agents-server/src/components/Footer/Footer.tsx +5 -5
  52. package/apps/agents-server/src/components/ForgottenPasswordDialog/ForgottenPasswordDialog.tsx +61 -0
  53. package/apps/agents-server/src/components/Header/Header.tsx +79 -35
  54. package/apps/agents-server/src/components/Homepage/AgentCard.tsx +85 -20
  55. package/apps/agents-server/src/components/Homepage/AgentsList.tsx +72 -12
  56. package/apps/agents-server/src/components/Homepage/DeletedAgentsList.tsx +50 -0
  57. package/apps/agents-server/src/components/LayoutWrapper/LayoutWrapper.tsx +3 -2
  58. package/apps/agents-server/src/components/LoginForm/LoginForm.tsx +50 -1
  59. package/apps/agents-server/src/components/NotFoundPage/NotFoundPage.tsx +7 -2
  60. package/apps/agents-server/src/components/OpenMojiIcon/OpenMojiIcon.tsx +16 -7
  61. package/apps/agents-server/src/components/PrintHeader/PrintHeader.tsx +4 -4
  62. package/apps/agents-server/src/components/RegisterUserDialog/RegisterUserDialog.tsx +61 -0
  63. package/apps/agents-server/src/database/metadataDefaults.ts +19 -1
  64. package/apps/agents-server/src/database/migrations/2025-12-0240-agent-public-id.sql +3 -0
  65. package/apps/agents-server/src/database/migrations/2025-12-0360-agent-deleted-at.sql +1 -0
  66. package/apps/agents-server/src/database/migrations/2025-12-0370-image-table.sql +19 -0
  67. package/apps/agents-server/src/database/migrations/2025-12-0380-agent-visibility.sql +1 -0
  68. package/apps/agents-server/src/database/migrations/2025-12-0390-upload-tracking.sql +20 -0
  69. package/apps/agents-server/src/database/migrations/2025-12-0401-file-upload-status.sql +13 -0
  70. package/apps/agents-server/src/database/migrations/2025-12-0640-openai-assistant-cache.sql +12 -0
  71. package/apps/agents-server/src/database/schema.ts +109 -0
  72. package/apps/agents-server/src/generated/reservedPaths.ts +27 -0
  73. package/apps/agents-server/src/middleware.ts +7 -20
  74. package/apps/agents-server/src/tools/$provideCdnForServer.ts +6 -1
  75. package/apps/agents-server/src/utils/cdn/classes/TrackedFilesStorage.ts +57 -0
  76. package/apps/agents-server/src/utils/cdn/classes/VercelBlobStorage.ts +4 -0
  77. package/apps/agents-server/src/utils/cdn/interfaces/IFilesStorage.ts +18 -0
  78. package/apps/agents-server/src/utils/getUserIdFromRequest.ts +33 -0
  79. package/apps/agents-server/src/utils/handleChatCompletion.ts +60 -4
  80. package/apps/agents-server/src/utils/normalization/filenameToPrompt.ts +21 -0
  81. package/apps/agents-server/src/utils/validateApiKey.ts +2 -1
  82. package/esm/index.es.js +140 -27
  83. package/esm/index.es.js.map +1 -1
  84. package/esm/typings/src/_packages/types.index.d.ts +6 -2
  85. package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +6 -1
  86. package/esm/typings/src/book-components/Chat/Chat/ChatMessageItem.d.ts +5 -1
  87. package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +5 -0
  88. package/esm/typings/src/book-components/Chat/CodeBlock/CodeBlock.d.ts +13 -0
  89. package/esm/typings/src/book-components/Chat/MarkdownContent/MarkdownContent.d.ts +1 -0
  90. package/esm/typings/src/book-components/_common/Dropdown/Dropdown.d.ts +2 -2
  91. package/esm/typings/src/book-components/_common/MenuHoisting/MenuHoistingContext.d.ts +56 -0
  92. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +13 -7
  93. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentsDatabaseSchema.d.ts +6 -0
  94. package/esm/typings/src/commitments/DICTIONARY/DICTIONARY.d.ts +46 -0
  95. package/esm/typings/src/commitments/index.d.ts +2 -1
  96. package/esm/typings/src/llm-providers/ollama/OllamaExecutionTools.d.ts +1 -1
  97. package/esm/typings/src/llm-providers/openai/createOpenAiCompatibleExecutionTools.d.ts +1 -1
  98. package/esm/typings/src/types/typeAliases.d.ts +12 -0
  99. package/esm/typings/src/utils/environment/$detectRuntimeEnvironment.d.ts +4 -4
  100. package/esm/typings/src/utils/environment/$isRunningInBrowser.d.ts +1 -1
  101. package/esm/typings/src/utils/environment/$isRunningInJest.d.ts +1 -1
  102. package/esm/typings/src/utils/environment/$isRunningInNode.d.ts +1 -1
  103. package/esm/typings/src/utils/environment/$isRunningInWebWorker.d.ts +1 -1
  104. package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +2 -2
  105. package/esm/typings/src/utils/markdown/extractOneBlockFromMarkdown.d.ts +2 -2
  106. package/esm/typings/src/utils/random/$randomBase58.d.ts +12 -0
  107. package/esm/typings/src/version.d.ts +1 -1
  108. package/package.json +1 -1
  109. package/umd/index.umd.js +146 -33
  110. package/umd/index.umd.js.map +1 -1
  111. package/apps/agents-server/package-lock.json +0 -27
  112. package/apps/agents-server/public/fonts/download-font.js +0 -22
  113. package/apps/agents-server/src/components/PrintButton/PrintButton.tsx +0 -18
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.104.0-1';
50
+ const PROMPTBOOK_ENGINE_VERSION = '0.104.0-2';
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
@@ -1373,13 +1373,14 @@ class EnvironmentMismatchError extends Error {
1373
1373
  *
1374
1374
  * @public exported from `@promptbook/utils`
1375
1375
  */
1376
- const $isRunningInNode = new Function(`
1376
+ function $isRunningInNode() {
1377
1377
  try {
1378
- return this === global;
1379
- } catch (e) {
1378
+ return typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
1379
+ }
1380
+ catch (e) {
1380
1381
  return false;
1381
1382
  }
1382
- `);
1383
+ }
1383
1384
  /**
1384
1385
  * TODO: [🎺]
1385
1386
  */
@@ -1391,13 +1392,14 @@ const $isRunningInNode = new Function(`
1391
1392
  *
1392
1393
  * @public exported from `@promptbook/utils`
1393
1394
  */
1394
- const $isRunningInBrowser = new Function(`
1395
+ function $isRunningInBrowser() {
1395
1396
  try {
1396
- return this === window;
1397
- } catch (e) {
1397
+ return typeof window !== 'undefined' && typeof window.document !== 'undefined';
1398
+ }
1399
+ catch (e) {
1398
1400
  return false;
1399
1401
  }
1400
- `);
1402
+ }
1401
1403
  /**
1402
1404
  * TODO: [🎺]
1403
1405
  */
@@ -1409,13 +1411,15 @@ const $isRunningInBrowser = new Function(`
1409
1411
  *
1410
1412
  * @public exported from `@promptbook/utils`
1411
1413
  */
1412
- const $isRunningInJest = new Function(`
1414
+ function $isRunningInJest() {
1415
+ var _a;
1413
1416
  try {
1414
- return process.env.JEST_WORKER_ID !== undefined;
1415
- } catch (e) {
1417
+ return typeof process !== 'undefined' && ((_a = process.env) === null || _a === void 0 ? void 0 : _a.JEST_WORKER_ID) !== undefined;
1418
+ }
1419
+ catch (e) {
1416
1420
  return false;
1417
1421
  }
1418
- `);
1422
+ }
1419
1423
  /**
1420
1424
  * TODO: [🎺]
1421
1425
  */
@@ -1427,17 +1431,17 @@ const $isRunningInJest = new Function(`
1427
1431
  *
1428
1432
  * @public exported from `@promptbook/utils`
1429
1433
  */
1430
- const $isRunningInWebWorker = new Function(`
1434
+ function $isRunningInWebWorker() {
1431
1435
  try {
1432
- if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {
1433
- return true;
1434
- } else {
1435
- return false;
1436
- }
1437
- } catch (e) {
1436
+ // Note: Check for importScripts which is specific to workers
1437
+ // and not available in the main browser thread
1438
+ return (typeof self !== 'undefined' &&
1439
+ typeof self.importScripts === 'function');
1440
+ }
1441
+ catch (e) {
1438
1442
  return false;
1439
1443
  }
1440
- `);
1444
+ }
1441
1445
  /**
1442
1446
  * TODO: [🎺]
1443
1447
  */
@@ -1955,7 +1959,7 @@ function $registeredLlmToolsMessage() {
1955
1959
  ${i + 1}) **${title}** \`${className}\` from \`${packageName}\`
1956
1960
  ${morePieces.join('; ')}
1957
1961
  `);
1958
- if ($isRunningInNode) {
1962
+ if ($isRunningInNode()) {
1959
1963
  if (isInstalled && isFullyConfigured) {
1960
1964
  providerMessage = colors.green(providerMessage);
1961
1965
  }
@@ -20400,10 +20404,10 @@ class OllamaExecutionTools extends OpenAiCompatibleExecutionTools {
20400
20404
  // <- TODO: [🛄]
20401
20405
  }
20402
20406
  /**
20403
- * Default model for image generation variant.
20407
+ * Default model for completion variant.
20404
20408
  */
20405
20409
  getDefaultImageGenerationModel() {
20406
- return this.getDefaultModel('!!!'); // <- TODO: [🧠] Pick the best default model
20410
+ return this.getDefaultModel('dall-e-3');
20407
20411
  // <- TODO: [🛄]
20408
20412
  }
20409
20413
  }
@@ -21218,11 +21222,10 @@ class HardcodedOpenAiCompatibleExecutionTools extends OpenAiCompatibleExecutionT
21218
21222
  throw new PipelineExecutionError(`${this.title} does not support EMBEDDING model variant`);
21219
21223
  }
21220
21224
  /**
21221
- * Default model for image generation variant.
21225
+ * Default model for completion variant.
21222
21226
  */
21223
21227
  getDefaultImageGenerationModel() {
21224
- return this.getDefaultModel('!!!'); // <- TODO: [🧠] Pick the best default model
21225
- // <- TODO: [🛄]
21228
+ throw new PipelineExecutionError(`${this.title} does not support IMAGE_GENERATION model variant`);
21226
21229
  }
21227
21230
  }
21228
21231
  /**
@@ -23098,6 +23101,114 @@ class DeleteCommitmentDefinition extends BaseCommitmentDefinition {
23098
23101
  * Note: [💞] Ignore a discrepancy between file name and entity name
23099
23102
  */
23100
23103
 
23104
+ /**
23105
+ * DICTIONARY commitment definition
23106
+ *
23107
+ * The DICTIONARY commitment defines specific terms and their meanings that the agent should use correctly
23108
+ * in its reasoning and responses. This ensures consistent terminology usage.
23109
+ *
23110
+ * Key features:
23111
+ * - Multiple DICTIONARY commitments are automatically merged into one
23112
+ * - Content is placed in a dedicated section of the system message
23113
+ * - Terms and definitions are stored in metadata.DICTIONARY for debugging
23114
+ * - Agent should use the defined terms correctly in responses
23115
+ *
23116
+ * Example usage in agent source:
23117
+ *
23118
+ * ```book
23119
+ * Legal Assistant
23120
+ *
23121
+ * PERSONA You are a knowledgeable legal assistant
23122
+ * DICTIONARY Misdemeanor is a minor wrongdoing or criminal offense
23123
+ * DICTIONARY Felony is a serious crime usually punishable by imprisonment for more than one year
23124
+ * DICTIONARY Tort is a civil wrong that causes harm or loss to another person, leading to legal liability
23125
+ * ```
23126
+ *
23127
+ * @private [🪔] Maybe export the commitments through some package
23128
+ */
23129
+ class DictionaryCommitmentDefinition extends BaseCommitmentDefinition {
23130
+ constructor() {
23131
+ super('DICTIONARY');
23132
+ }
23133
+ /**
23134
+ * Short one-line description of DICTIONARY.
23135
+ */
23136
+ get description() {
23137
+ return 'Define terms and their meanings for consistent terminology usage.';
23138
+ }
23139
+ /**
23140
+ * Icon for this commitment.
23141
+ */
23142
+ get icon() {
23143
+ return '📚';
23144
+ }
23145
+ /**
23146
+ * Markdown documentation for DICTIONARY commitment.
23147
+ */
23148
+ get documentation() {
23149
+ return spaceTrim$1(`
23150
+ # DICTIONARY
23151
+
23152
+ Defines specific terms and their meanings that the agent should use correctly in reasoning and responses.
23153
+
23154
+ ## Key aspects
23155
+
23156
+ - Multiple \`DICTIONARY\` commitments are merged together.
23157
+ - Terms are defined in the format: "Term is definition"
23158
+ - The agent should use these terms consistently in responses.
23159
+ - Definitions help ensure accurate and consistent terminology.
23160
+
23161
+ ## Examples
23162
+
23163
+ \`\`\`book
23164
+ Legal Assistant
23165
+
23166
+ PERSONA You are a knowledgeable legal assistant specializing in criminal law
23167
+ DICTIONARY Misdemeanor is a minor wrongdoing or criminal offense
23168
+ DICTIONARY Felony is a serious crime usually punishable by imprisonment for more than one year
23169
+ DICTIONARY Tort is a civil wrong that causes harm or loss to another person, leading to legal liability
23170
+ \`\`\`
23171
+
23172
+ \`\`\`book
23173
+ Medical Assistant
23174
+
23175
+ PERSONA You are a helpful medical assistant
23176
+ DICTIONARY Hypertension is persistently high blood pressure
23177
+ DICTIONARY Diabetes is a chronic condition that affects how the body processes blood sugar
23178
+ DICTIONARY Vaccine is a biological preparation that provides active immunity to a particular disease
23179
+ \`\`\`
23180
+ `);
23181
+ }
23182
+ applyToAgentModelRequirements(requirements, content) {
23183
+ var _a;
23184
+ const trimmedContent = content.trim();
23185
+ if (!trimmedContent) {
23186
+ return requirements;
23187
+ }
23188
+ // Get existing dictionary entries from metadata
23189
+ const existingDictionary = ((_a = requirements.metadata) === null || _a === void 0 ? void 0 : _a.DICTIONARY) || '';
23190
+ // Merge the new dictionary entry with existing entries
23191
+ const mergedDictionary = existingDictionary
23192
+ ? `${existingDictionary}\n${trimmedContent}`
23193
+ : trimmedContent;
23194
+ // Store the merged dictionary in metadata for debugging and inspection
23195
+ const updatedMetadata = {
23196
+ ...requirements.metadata,
23197
+ DICTIONARY: mergedDictionary,
23198
+ };
23199
+ // Create the dictionary section for the system message
23200
+ // Format: "# DICTIONARY\nTerm: definition\nTerm: definition..."
23201
+ const dictionarySection = `# DICTIONARY\n${mergedDictionary}`;
23202
+ return {
23203
+ ...this.appendToSystemMessage(requirements, dictionarySection),
23204
+ metadata: updatedMetadata,
23205
+ };
23206
+ }
23207
+ }
23208
+ /**
23209
+ * Note: [💞] Ignore a discrepancy between file name and entity name
23210
+ */
23211
+
23101
23212
  /**
23102
23213
  * FORMAT commitment definition
23103
23214
  *
@@ -25918,6 +26029,7 @@ const COMMITMENT_REGISTRY = [
25918
26029
  new DeleteCommitmentDefinition('CANCEL'),
25919
26030
  new DeleteCommitmentDefinition('DISCARD'),
25920
26031
  new DeleteCommitmentDefinition('REMOVE'),
26032
+ new DictionaryCommitmentDefinition(),
25921
26033
  new OpenCommitmentDefinition(),
25922
26034
  new ClosedCommitmentDefinition(),
25923
26035
  new UseBrowserCommitmentDefinition(),
@@ -26423,6 +26535,7 @@ function parseAgentSource(agentSource) {
26423
26535
  return {
26424
26536
  agentName: normalizeAgentName(parseResult.agentName || createDefaultAgentName(agentSource)),
26425
26537
  agentHash,
26538
+ permanentId: meta.id,
26426
26539
  personaDescription,
26427
26540
  initialMessage,
26428
26541
  meta,