@promptbook/cli 0.104.0-0 → 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 (118) 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/WebsiteIntegrationTabs.tsx +26 -0
  27. package/apps/agents-server/src/app/agents/[agentName]/integration/page.tsx +23 -6
  28. package/apps/agents-server/src/app/agents/[agentName]/links/page.tsx +2 -2
  29. package/apps/agents-server/src/app/agents/[agentName]/page.tsx +12 -6
  30. package/apps/agents-server/src/app/agents/[agentName]/system-message/page.tsx +87 -0
  31. package/apps/agents-server/src/app/agents/[agentName]/website-integration/page.tsx +35 -18
  32. package/apps/agents-server/src/app/api/admin-email/route.ts +12 -0
  33. package/apps/agents-server/src/app/api/agents/[agentName]/restore/route.ts +19 -0
  34. package/apps/agents-server/src/app/api/agents/[agentName]/route.ts +42 -0
  35. package/apps/agents-server/src/app/api/agents/route.ts +29 -4
  36. package/apps/agents-server/src/app/api/docs/book.md/route.ts +58 -0
  37. package/apps/agents-server/src/app/api/embed.js/route.ts +87 -67
  38. package/apps/agents-server/src/app/api/federated-agents/route.ts +12 -0
  39. package/apps/agents-server/src/app/api/images/[filename]/route.ts +107 -0
  40. package/apps/agents-server/src/app/api/upload/route.ts +119 -45
  41. package/apps/agents-server/src/app/docs/[docId]/page.tsx +2 -3
  42. package/apps/agents-server/src/app/docs/page.tsx +12 -12
  43. package/apps/agents-server/src/app/embed/layout.tsx +31 -0
  44. package/apps/agents-server/src/app/embed/page.tsx +22 -9
  45. package/apps/agents-server/src/app/globals.css +140 -33
  46. package/apps/agents-server/src/app/layout.tsx +27 -22
  47. package/apps/agents-server/src/app/page.tsx +50 -4
  48. package/apps/agents-server/src/app/recycle-bin/actions.ts +20 -14
  49. package/apps/agents-server/src/app/recycle-bin/page.tsx +25 -41
  50. package/apps/agents-server/src/app/sitemap.xml/route.ts +6 -3
  51. package/apps/agents-server/src/components/AgentProfile/AgentProfile.tsx +6 -97
  52. package/apps/agents-server/src/components/AgentProfile/useAgentBackground.ts +97 -0
  53. package/apps/agents-server/src/components/DeletedAgentBanner.tsx +26 -0
  54. package/apps/agents-server/src/components/DocsToolbar/DocsToolbar.tsx +38 -0
  55. package/apps/agents-server/src/components/DocumentationContent/DocumentationContent.tsx +11 -9
  56. package/apps/agents-server/src/components/Footer/Footer.tsx +5 -5
  57. package/apps/agents-server/src/components/ForgottenPasswordDialog/ForgottenPasswordDialog.tsx +61 -0
  58. package/apps/agents-server/src/components/Header/Header.tsx +79 -35
  59. package/apps/agents-server/src/components/Homepage/AgentCard.tsx +85 -20
  60. package/apps/agents-server/src/components/Homepage/AgentsList.tsx +72 -12
  61. package/apps/agents-server/src/components/Homepage/DeletedAgentsList.tsx +50 -0
  62. package/apps/agents-server/src/components/LayoutWrapper/LayoutWrapper.tsx +3 -2
  63. package/apps/agents-server/src/components/LoginForm/LoginForm.tsx +50 -1
  64. package/apps/agents-server/src/components/NotFoundPage/NotFoundPage.tsx +7 -2
  65. package/apps/agents-server/src/components/OpenMojiIcon/OpenMojiIcon.tsx +16 -7
  66. package/apps/agents-server/src/components/PrintHeader/PrintHeader.tsx +4 -4
  67. package/apps/agents-server/src/components/RegisterUserDialog/RegisterUserDialog.tsx +61 -0
  68. package/apps/agents-server/src/database/metadataDefaults.ts +19 -1
  69. package/apps/agents-server/src/database/migrations/2025-12-0240-agent-public-id.sql +3 -0
  70. package/apps/agents-server/src/database/migrations/2025-12-0360-agent-deleted-at.sql +1 -0
  71. package/apps/agents-server/src/database/migrations/2025-12-0370-image-table.sql +19 -0
  72. package/apps/agents-server/src/database/migrations/2025-12-0380-agent-visibility.sql +1 -0
  73. package/apps/agents-server/src/database/migrations/2025-12-0390-upload-tracking.sql +20 -0
  74. package/apps/agents-server/src/database/migrations/2025-12-0401-file-upload-status.sql +13 -0
  75. package/apps/agents-server/src/database/migrations/2025-12-0640-openai-assistant-cache.sql +12 -0
  76. package/apps/agents-server/src/database/schema.ts +109 -0
  77. package/apps/agents-server/src/generated/reservedPaths.ts +27 -0
  78. package/apps/agents-server/src/middleware.ts +7 -20
  79. package/apps/agents-server/src/tools/$provideCdnForServer.ts +6 -1
  80. package/apps/agents-server/src/utils/cdn/classes/TrackedFilesStorage.ts +57 -0
  81. package/apps/agents-server/src/utils/cdn/classes/VercelBlobStorage.ts +4 -0
  82. package/apps/agents-server/src/utils/cdn/interfaces/IFilesStorage.ts +18 -0
  83. package/apps/agents-server/src/utils/getUserIdFromRequest.ts +33 -0
  84. package/apps/agents-server/src/utils/handleChatCompletion.ts +60 -4
  85. package/apps/agents-server/src/utils/normalization/filenameToPrompt.ts +21 -0
  86. package/apps/agents-server/src/utils/validateApiKey.ts +2 -1
  87. package/esm/index.es.js +140 -27
  88. package/esm/index.es.js.map +1 -1
  89. package/esm/typings/src/_packages/types.index.d.ts +6 -2
  90. package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +6 -1
  91. package/esm/typings/src/book-components/Chat/Chat/ChatMessageItem.d.ts +5 -1
  92. package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +5 -0
  93. package/esm/typings/src/book-components/Chat/CodeBlock/CodeBlock.d.ts +13 -0
  94. package/esm/typings/src/book-components/Chat/MarkdownContent/MarkdownContent.d.ts +1 -0
  95. package/esm/typings/src/book-components/_common/Dropdown/Dropdown.d.ts +2 -2
  96. package/esm/typings/src/book-components/_common/MenuHoisting/MenuHoistingContext.d.ts +56 -0
  97. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +13 -7
  98. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentsDatabaseSchema.d.ts +6 -0
  99. package/esm/typings/src/commitments/DICTIONARY/DICTIONARY.d.ts +46 -0
  100. package/esm/typings/src/commitments/index.d.ts +2 -1
  101. package/esm/typings/src/llm-providers/ollama/OllamaExecutionTools.d.ts +1 -1
  102. package/esm/typings/src/llm-providers/openai/createOpenAiCompatibleExecutionTools.d.ts +1 -1
  103. package/esm/typings/src/types/typeAliases.d.ts +12 -0
  104. package/esm/typings/src/utils/environment/$detectRuntimeEnvironment.d.ts +4 -4
  105. package/esm/typings/src/utils/environment/$isRunningInBrowser.d.ts +1 -1
  106. package/esm/typings/src/utils/environment/$isRunningInJest.d.ts +1 -1
  107. package/esm/typings/src/utils/environment/$isRunningInNode.d.ts +1 -1
  108. package/esm/typings/src/utils/environment/$isRunningInWebWorker.d.ts +1 -1
  109. package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +2 -2
  110. package/esm/typings/src/utils/markdown/extractOneBlockFromMarkdown.d.ts +2 -2
  111. package/esm/typings/src/utils/random/$randomBase58.d.ts +12 -0
  112. package/esm/typings/src/version.d.ts +1 -1
  113. package/package.json +1 -1
  114. package/umd/index.umd.js +146 -33
  115. package/umd/index.umd.js.map +1 -1
  116. package/apps/agents-server/package-lock.json +0 -27
  117. package/apps/agents-server/public/fonts/download-font.js +0 -22
  118. package/apps/agents-server/src/components/PrintButton/PrintButton.tsx +0 -18
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.104.0-0';
59
+ const PROMPTBOOK_ENGINE_VERSION = '0.104.0-2';
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
@@ -1382,13 +1382,14 @@
1382
1382
  *
1383
1383
  * @public exported from `@promptbook/utils`
1384
1384
  */
1385
- const $isRunningInNode = new Function(`
1386
- try {
1387
- return this === global;
1388
- } catch (e) {
1389
- return false;
1385
+ function $isRunningInNode() {
1386
+ try {
1387
+ return typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
1388
+ }
1389
+ catch (e) {
1390
+ return false;
1391
+ }
1390
1392
  }
1391
- `);
1392
1393
  /**
1393
1394
  * TODO: [🎺]
1394
1395
  */
@@ -1400,13 +1401,14 @@
1400
1401
  *
1401
1402
  * @public exported from `@promptbook/utils`
1402
1403
  */
1403
- const $isRunningInBrowser = new Function(`
1404
- try {
1405
- return this === window;
1406
- } catch (e) {
1407
- return false;
1404
+ function $isRunningInBrowser() {
1405
+ try {
1406
+ return typeof window !== 'undefined' && typeof window.document !== 'undefined';
1407
+ }
1408
+ catch (e) {
1409
+ return false;
1410
+ }
1408
1411
  }
1409
- `);
1410
1412
  /**
1411
1413
  * TODO: [🎺]
1412
1414
  */
@@ -1418,13 +1420,15 @@
1418
1420
  *
1419
1421
  * @public exported from `@promptbook/utils`
1420
1422
  */
1421
- const $isRunningInJest = new Function(`
1422
- try {
1423
- return process.env.JEST_WORKER_ID !== undefined;
1424
- } catch (e) {
1425
- return false;
1423
+ function $isRunningInJest() {
1424
+ var _a;
1425
+ try {
1426
+ return typeof process !== 'undefined' && ((_a = process.env) === null || _a === void 0 ? void 0 : _a.JEST_WORKER_ID) !== undefined;
1427
+ }
1428
+ catch (e) {
1429
+ return false;
1430
+ }
1426
1431
  }
1427
- `);
1428
1432
  /**
1429
1433
  * TODO: [🎺]
1430
1434
  */
@@ -1436,17 +1440,17 @@
1436
1440
  *
1437
1441
  * @public exported from `@promptbook/utils`
1438
1442
  */
1439
- const $isRunningInWebWorker = new Function(`
1440
- try {
1441
- if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {
1442
- return true;
1443
- } else {
1443
+ function $isRunningInWebWorker() {
1444
+ try {
1445
+ // Note: Check for importScripts which is specific to workers
1446
+ // and not available in the main browser thread
1447
+ return (typeof self !== 'undefined' &&
1448
+ typeof self.importScripts === 'function');
1449
+ }
1450
+ catch (e) {
1444
1451
  return false;
1445
1452
  }
1446
- } catch (e) {
1447
- return false;
1448
1453
  }
1449
- `);
1450
1454
  /**
1451
1455
  * TODO: [🎺]
1452
1456
  */
@@ -1964,7 +1968,7 @@
1964
1968
  ${i + 1}) **${title}** \`${className}\` from \`${packageName}\`
1965
1969
  ${morePieces.join('; ')}
1966
1970
  `);
1967
- if ($isRunningInNode) {
1971
+ if ($isRunningInNode()) {
1968
1972
  if (isInstalled && isFullyConfigured) {
1969
1973
  providerMessage = colors__default["default"].green(providerMessage);
1970
1974
  }
@@ -20409,10 +20413,10 @@
20409
20413
  // <- TODO: [🛄]
20410
20414
  }
20411
20415
  /**
20412
- * Default model for image generation variant.
20416
+ * Default model for completion variant.
20413
20417
  */
20414
20418
  getDefaultImageGenerationModel() {
20415
- return this.getDefaultModel('!!!'); // <- TODO: [🧠] Pick the best default model
20419
+ return this.getDefaultModel('dall-e-3');
20416
20420
  // <- TODO: [🛄]
20417
20421
  }
20418
20422
  }
@@ -21227,11 +21231,10 @@
21227
21231
  throw new PipelineExecutionError(`${this.title} does not support EMBEDDING model variant`);
21228
21232
  }
21229
21233
  /**
21230
- * Default model for image generation variant.
21234
+ * Default model for completion variant.
21231
21235
  */
21232
21236
  getDefaultImageGenerationModel() {
21233
- return this.getDefaultModel('!!!'); // <- TODO: [🧠] Pick the best default model
21234
- // <- TODO: [🛄]
21237
+ throw new PipelineExecutionError(`${this.title} does not support IMAGE_GENERATION model variant`);
21235
21238
  }
21236
21239
  }
21237
21240
  /**
@@ -23107,6 +23110,114 @@
23107
23110
  * Note: [💞] Ignore a discrepancy between file name and entity name
23108
23111
  */
23109
23112
 
23113
+ /**
23114
+ * DICTIONARY commitment definition
23115
+ *
23116
+ * The DICTIONARY commitment defines specific terms and their meanings that the agent should use correctly
23117
+ * in its reasoning and responses. This ensures consistent terminology usage.
23118
+ *
23119
+ * Key features:
23120
+ * - Multiple DICTIONARY commitments are automatically merged into one
23121
+ * - Content is placed in a dedicated section of the system message
23122
+ * - Terms and definitions are stored in metadata.DICTIONARY for debugging
23123
+ * - Agent should use the defined terms correctly in responses
23124
+ *
23125
+ * Example usage in agent source:
23126
+ *
23127
+ * ```book
23128
+ * Legal Assistant
23129
+ *
23130
+ * PERSONA You are a knowledgeable legal assistant
23131
+ * DICTIONARY Misdemeanor is a minor wrongdoing or criminal offense
23132
+ * DICTIONARY Felony is a serious crime usually punishable by imprisonment for more than one year
23133
+ * DICTIONARY Tort is a civil wrong that causes harm or loss to another person, leading to legal liability
23134
+ * ```
23135
+ *
23136
+ * @private [🪔] Maybe export the commitments through some package
23137
+ */
23138
+ class DictionaryCommitmentDefinition extends BaseCommitmentDefinition {
23139
+ constructor() {
23140
+ super('DICTIONARY');
23141
+ }
23142
+ /**
23143
+ * Short one-line description of DICTIONARY.
23144
+ */
23145
+ get description() {
23146
+ return 'Define terms and their meanings for consistent terminology usage.';
23147
+ }
23148
+ /**
23149
+ * Icon for this commitment.
23150
+ */
23151
+ get icon() {
23152
+ return '📚';
23153
+ }
23154
+ /**
23155
+ * Markdown documentation for DICTIONARY commitment.
23156
+ */
23157
+ get documentation() {
23158
+ return spaceTrim$1.spaceTrim(`
23159
+ # DICTIONARY
23160
+
23161
+ Defines specific terms and their meanings that the agent should use correctly in reasoning and responses.
23162
+
23163
+ ## Key aspects
23164
+
23165
+ - Multiple \`DICTIONARY\` commitments are merged together.
23166
+ - Terms are defined in the format: "Term is definition"
23167
+ - The agent should use these terms consistently in responses.
23168
+ - Definitions help ensure accurate and consistent terminology.
23169
+
23170
+ ## Examples
23171
+
23172
+ \`\`\`book
23173
+ Legal Assistant
23174
+
23175
+ PERSONA You are a knowledgeable legal assistant specializing in criminal law
23176
+ DICTIONARY Misdemeanor is a minor wrongdoing or criminal offense
23177
+ DICTIONARY Felony is a serious crime usually punishable by imprisonment for more than one year
23178
+ DICTIONARY Tort is a civil wrong that causes harm or loss to another person, leading to legal liability
23179
+ \`\`\`
23180
+
23181
+ \`\`\`book
23182
+ Medical Assistant
23183
+
23184
+ PERSONA You are a helpful medical assistant
23185
+ DICTIONARY Hypertension is persistently high blood pressure
23186
+ DICTIONARY Diabetes is a chronic condition that affects how the body processes blood sugar
23187
+ DICTIONARY Vaccine is a biological preparation that provides active immunity to a particular disease
23188
+ \`\`\`
23189
+ `);
23190
+ }
23191
+ applyToAgentModelRequirements(requirements, content) {
23192
+ var _a;
23193
+ const trimmedContent = content.trim();
23194
+ if (!trimmedContent) {
23195
+ return requirements;
23196
+ }
23197
+ // Get existing dictionary entries from metadata
23198
+ const existingDictionary = ((_a = requirements.metadata) === null || _a === void 0 ? void 0 : _a.DICTIONARY) || '';
23199
+ // Merge the new dictionary entry with existing entries
23200
+ const mergedDictionary = existingDictionary
23201
+ ? `${existingDictionary}\n${trimmedContent}`
23202
+ : trimmedContent;
23203
+ // Store the merged dictionary in metadata for debugging and inspection
23204
+ const updatedMetadata = {
23205
+ ...requirements.metadata,
23206
+ DICTIONARY: mergedDictionary,
23207
+ };
23208
+ // Create the dictionary section for the system message
23209
+ // Format: "# DICTIONARY\nTerm: definition\nTerm: definition..."
23210
+ const dictionarySection = `# DICTIONARY\n${mergedDictionary}`;
23211
+ return {
23212
+ ...this.appendToSystemMessage(requirements, dictionarySection),
23213
+ metadata: updatedMetadata,
23214
+ };
23215
+ }
23216
+ }
23217
+ /**
23218
+ * Note: [💞] Ignore a discrepancy between file name and entity name
23219
+ */
23220
+
23110
23221
  /**
23111
23222
  * FORMAT commitment definition
23112
23223
  *
@@ -25927,6 +26038,7 @@
25927
26038
  new DeleteCommitmentDefinition('CANCEL'),
25928
26039
  new DeleteCommitmentDefinition('DISCARD'),
25929
26040
  new DeleteCommitmentDefinition('REMOVE'),
26041
+ new DictionaryCommitmentDefinition(),
25930
26042
  new OpenCommitmentDefinition(),
25931
26043
  new ClosedCommitmentDefinition(),
25932
26044
  new UseBrowserCommitmentDefinition(),
@@ -26432,6 +26544,7 @@
26432
26544
  return {
26433
26545
  agentName: normalizeAgentName(parseResult.agentName || createDefaultAgentName(agentSource)),
26434
26546
  agentHash,
26547
+ permanentId: meta.id,
26435
26548
  personaDescription,
26436
26549
  initialMessage,
26437
26550
  meta,