@promptbook/cli 0.112.0-82 → 0.112.0-85

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 (26) hide show
  1. package/apps/agents-server/README.md +7 -1
  2. package/apps/agents-server/src/database/$provideSupabaseForServer.ts +6 -0
  3. package/apps/agents-server/src/database/agentsServerDatabaseMode.ts +34 -0
  4. package/apps/agents-server/src/database/sqlite/$provideLocalSqliteSupabase.ts +1445 -0
  5. package/apps/agents-server/src/database/sqlite/resolveAgentsServerSqliteDatabasePath.ts +13 -0
  6. package/apps/agents-server/src/tools/$provideServer.ts +9 -0
  7. package/apps/agents-server/src/utils/serverRegistry.ts +13 -0
  8. package/apps/agents-server/src/utils/userChat/finalizeUserChatJob.ts +42 -0
  9. package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore/claimNextDueUserChatTimeout.ts +63 -0
  10. package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore/recoverExpiredRunningUserChatTimeouts.ts +47 -0
  11. package/apps/agents-server/src/utils/validateApiKey.ts +2 -18
  12. package/esm/apps/agents-server/src/database/agentsServerDatabaseMode.d.ts +20 -0
  13. package/esm/index.es.js +20 -2
  14. package/esm/index.es.js.map +1 -1
  15. package/esm/src/version.d.ts +1 -1
  16. package/package.json +2 -1
  17. package/src/book-components/Chat/save/pdf/buildChatPdf.ts +3 -26
  18. package/src/cli/cli-commands/agents-server/ensureAgentsServerEnvFile.ts +3 -1
  19. package/src/cli/cli-commands/agents-server/startAgentsServer.ts +20 -0
  20. package/src/other/templates/getTemplatesPipelineCollection.ts +1002 -647
  21. package/src/version.ts +2 -2
  22. package/src/versions.txt +1 -0
  23. package/umd/apps/agents-server/src/database/agentsServerDatabaseMode.d.ts +20 -0
  24. package/umd/index.umd.js +20 -2
  25. package/umd/index.umd.js.map +1 -1
  26. package/umd/src/version.d.ts +1 -1
package/src/version.ts CHANGED
@@ -16,11 +16,11 @@ export const BOOK_LANGUAGE_VERSION: string_semantic_version = '2.0.0';
16
16
  * @generated
17
17
  * @see https://github.com/webgptorg/promptbook
18
18
  */
19
- export const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version = '0.112.0-82';
19
+ export const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version = '0.112.0-85';
20
20
 
21
21
  /**
22
22
  * Represents the version string of the Promptbook engine.
23
- * It follows semantic versioning (e.g., `0.112.0-81`).
23
+ * It follows semantic versioning (e.g., `0.112.0-82`).
24
24
  *
25
25
  * @generated
26
26
  */
package/src/versions.txt CHANGED
@@ -1124,3 +1124,4 @@
1124
1124
  0.112.0-79
1125
1125
  0.112.0-81
1126
1126
  0.112.0-82
1127
+ 0.112.0-85
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Environment variable selecting the Agents Server database backend.
3
+ */
4
+ export declare const AGENTS_SERVER_DATABASE_ENV_NAME = "PTBK_AGENTS_SERVER_DATABASE";
5
+ /**
6
+ * Environment variable pointing to the standalone SQLite database file.
7
+ */
8
+ export declare const AGENTS_SERVER_SQLITE_PATH_ENV_NAME = "PTBK_AGENTS_SERVER_SQLITE_PATH";
9
+ /**
10
+ * Supported Agents Server database backends.
11
+ */
12
+ export type AgentsServerDatabaseMode = 'supabase' | 'sqlite';
13
+ /**
14
+ * Resolves the configured Agents Server database backend.
15
+ */
16
+ export declare function resolveAgentsServerDatabaseMode(): AgentsServerDatabaseMode;
17
+ /**
18
+ * Returns whether the Agents Server is using the local SQLite backend.
19
+ */
20
+ export declare function isAgentsServerSqliteMode(): boolean;
package/umd/index.umd.js CHANGED
@@ -60,7 +60,7 @@
60
60
  * @generated
61
61
  * @see https://github.com/webgptorg/promptbook
62
62
  */
63
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-82';
63
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-85';
64
64
  /**
65
65
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
66
66
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -2471,9 +2471,11 @@
2471
2471
  */
2472
2472
  const AGENTS_SERVER_ENV_CREATED_COMMENT = '# Created by `ptbk agents-server init` command';
2473
2473
  /**
2474
- * Variables required for a local Agents Server backed by a Supabase project.
2474
+ * Variables required for a local Agents Server backed by Supabase or standalone SQLite.
2475
2475
  */
2476
2476
  const REQUIRED_AGENTS_SERVER_ENV_VARIABLES = [
2477
+ createAgentsServerEnvVariable('PTBK_AGENTS_SERVER_DATABASE', 'supabase'),
2478
+ createAgentsServerEnvVariable('PTBK_AGENTS_SERVER_SQLITE_PATH', '.promptbook/agents-server.sqlite'),
2477
2479
  createAgentsServerEnvVariable('OPENAI_API_KEY', ''),
2478
2480
  createAgentsServerEnvVariable('POSTGRES_URL', ''),
2479
2481
  createAgentsServerEnvVariable('NEXT_PUBLIC_SUPABASE_URL', ''),
@@ -35868,6 +35870,18 @@
35868
35870
  * @private internal constant of `ptbk agents-server`
35869
35871
  */
35870
35872
  const PTBK_AGENTS_SERVER_AGENT_ROOT_ENV = 'PTBK_AGENTS_SERVER_AGENT_ROOT';
35873
+ /**
35874
+ * Public database mode environment name consumed by the Agents Server app.
35875
+ *
35876
+ * @private internal constant of `ptbk agents-server`
35877
+ */
35878
+ const PTBK_AGENTS_SERVER_DATABASE_ENV = 'PTBK_AGENTS_SERVER_DATABASE';
35879
+ /**
35880
+ * Local SQLite file environment name consumed by the Agents Server app.
35881
+ *
35882
+ * @private internal constant of `ptbk agents-server`
35883
+ */
35884
+ const PTBK_AGENTS_SERVER_SQLITE_PATH_ENV = 'PTBK_AGENTS_SERVER_SQLITE_PATH';
35871
35885
  /**
35872
35886
  * Entropy size for the local-only token shared by the CLI pump and the Next app.
35873
35887
  *
@@ -36037,11 +36051,15 @@
36037
36051
  * Creates the subprocess environment for Next and its internal local runner bridge.
36038
36052
  */
36039
36053
  function createAgentsServerChildEnvironment(port, agentRootPath) {
36054
+ const launchWorkingDirectory = process.cwd();
36040
36055
  return {
36041
36056
  ...process.env,
36042
36057
  PORT: String(port),
36043
36058
  NEXT_PUBLIC_SITE_URL: process.env.NEXT_PUBLIC_SITE_URL || `http://localhost:${port}`,
36044
36059
  [PTBK_AGENTS_SERVER_AGENT_ROOT_ENV]: agentRootPath,
36060
+ [PTBK_AGENTS_SERVER_SQLITE_PATH_ENV]: process.env[PTBK_AGENTS_SERVER_SQLITE_PATH_ENV] ||
36061
+ path.join(launchWorkingDirectory, '.promptbook', 'agents-server.sqlite'),
36062
+ [PTBK_AGENTS_SERVER_DATABASE_ENV]: process.env[PTBK_AGENTS_SERVER_DATABASE_ENV] || 'supabase',
36045
36063
  // Next loads app-local `.env` values after the CLI has prepared this bridge environment.
36046
36064
  PTBK_AGENTS_SERVER_USER_CHAT_WORKER_TOKEN: process.env.PTBK_AGENTS_SERVER_USER_CHAT_WORKER_TOKEN ||
36047
36065
  crypto.randomBytes(LOCAL_USER_CHAT_WORKER_TOKEN_BYTE_LENGTH).toString('hex'),