@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.
- package/apps/agents-server/README.md +7 -1
- package/apps/agents-server/src/database/$provideSupabaseForServer.ts +6 -0
- package/apps/agents-server/src/database/agentsServerDatabaseMode.ts +34 -0
- package/apps/agents-server/src/database/sqlite/$provideLocalSqliteSupabase.ts +1445 -0
- package/apps/agents-server/src/database/sqlite/resolveAgentsServerSqliteDatabasePath.ts +13 -0
- package/apps/agents-server/src/tools/$provideServer.ts +9 -0
- package/apps/agents-server/src/utils/serverRegistry.ts +13 -0
- package/apps/agents-server/src/utils/userChat/finalizeUserChatJob.ts +42 -0
- package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore/claimNextDueUserChatTimeout.ts +63 -0
- package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore/recoverExpiredRunningUserChatTimeouts.ts +47 -0
- package/apps/agents-server/src/utils/validateApiKey.ts +2 -18
- package/esm/apps/agents-server/src/database/agentsServerDatabaseMode.d.ts +20 -0
- package/esm/index.es.js +20 -2
- package/esm/index.es.js.map +1 -1
- package/esm/src/version.d.ts +1 -1
- package/package.json +2 -1
- package/src/book-components/Chat/save/pdf/buildChatPdf.ts +3 -26
- package/src/cli/cli-commands/agents-server/ensureAgentsServerEnvFile.ts +3 -1
- package/src/cli/cli-commands/agents-server/startAgentsServer.ts +20 -0
- package/src/other/templates/getTemplatesPipelineCollection.ts +1002 -647
- package/src/version.ts +2 -2
- package/src/versions.txt +1 -0
- package/umd/apps/agents-server/src/database/agentsServerDatabaseMode.d.ts +20 -0
- package/umd/index.umd.js +20 -2
- package/umd/index.umd.js.map +1 -1
- package/umd/src/version.d.ts +1 -1
|
@@ -12,7 +12,13 @@ ptbk agents-server init
|
|
|
12
12
|
ptbk agents-server start --agent github-copilot --model gpt-5.4 --thinking-level xhigh
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
`ptbk agents-server init` adds missing placeholders to `.env` and local runtime exclusions to `.gitignore` without deleting existing configuration.
|
|
15
|
+
`ptbk agents-server init` adds missing placeholders to `.env` and local runtime exclusions to `.gitignore` without deleting existing configuration. Use `PTBK_AGENTS_SERVER_DATABASE=supabase` for a Supabase-backed server or `PTBK_AGENTS_SERVER_DATABASE=sqlite` for a standalone local database in `.promptbook`. When using Supabase, fill the initialized values from your project before starting the server. The Supabase project URL and API keys are available in the [Supabase project API settings](https://supabase.com/docs/guides/api/api-keys), and the PostgreSQL connection string is available from the [Supabase database connection guide](https://supabase.com/docs/guides/database/connecting-to-postgres).
|
|
16
|
+
|
|
17
|
+
<a id="agents-server-env-ptbk-agents-server-database"></a>
|
|
18
|
+
- `PTBK_AGENTS_SERVER_DATABASE`: Database backend used by Agents Server. Use `supabase` for the current hosted setup or `sqlite` for a standalone local database.
|
|
19
|
+
|
|
20
|
+
<a id="agents-server-env-ptbk-agents-server-sqlite-path"></a>
|
|
21
|
+
- `PTBK_AGENTS_SERVER_SQLITE_PATH`: SQLite database file used when `PTBK_AGENTS_SERVER_DATABASE=sqlite`. Defaults to `.promptbook/agents-server.sqlite` in the launch directory.
|
|
16
22
|
|
|
17
23
|
<a id="agents-server-env-openai-api-key"></a>
|
|
18
24
|
- `OPENAI_API_KEY`: OpenAI API key used for Agents Server chat and agent execution. Create one in the [OpenAI API key settings](https://platform.openai.com/api-keys).
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { $isRunningInNode } from '@promptbook-local/utils';
|
|
2
2
|
import { createClient, SupabaseClient } from '@supabase/supabase-js';
|
|
3
|
+
import { isAgentsServerSqliteMode } from './agentsServerDatabaseMode';
|
|
4
|
+
import { $provideLocalSqliteSupabase } from './sqlite/$provideLocalSqliteSupabase';
|
|
3
5
|
import { AgentsServerDatabase } from './schema';
|
|
4
6
|
|
|
5
7
|
/**
|
|
@@ -26,6 +28,10 @@ export function $provideSupabaseForServer(): SupabaseClient<AgentsServerDatabase
|
|
|
26
28
|
);
|
|
27
29
|
}
|
|
28
30
|
|
|
31
|
+
if (isAgentsServerSqliteMode()) {
|
|
32
|
+
return $provideLocalSqliteSupabase() as SupabaseClient<AgentsServerDatabase>;
|
|
33
|
+
}
|
|
34
|
+
|
|
29
35
|
if (!supabase) {
|
|
30
36
|
// Create a single supabase client for interacting with your database
|
|
31
37
|
supabase = createClient<AgentsServerDatabase>(
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment variable selecting the Agents Server database backend.
|
|
3
|
+
*/
|
|
4
|
+
export const AGENTS_SERVER_DATABASE_ENV_NAME = 'PTBK_AGENTS_SERVER_DATABASE';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Environment variable pointing to the standalone SQLite database file.
|
|
8
|
+
*/
|
|
9
|
+
export const AGENTS_SERVER_SQLITE_PATH_ENV_NAME = 'PTBK_AGENTS_SERVER_SQLITE_PATH';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Supported Agents Server database backends.
|
|
13
|
+
*/
|
|
14
|
+
export type AgentsServerDatabaseMode = 'supabase' | 'sqlite';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Resolves the configured Agents Server database backend.
|
|
18
|
+
*/
|
|
19
|
+
export function resolveAgentsServerDatabaseMode(): AgentsServerDatabaseMode {
|
|
20
|
+
const rawMode = process.env[AGENTS_SERVER_DATABASE_ENV_NAME]?.trim().toLowerCase();
|
|
21
|
+
|
|
22
|
+
if (rawMode === 'sqlite' || rawMode === 'local') {
|
|
23
|
+
return 'sqlite';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return 'supabase';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Returns whether the Agents Server is using the local SQLite backend.
|
|
31
|
+
*/
|
|
32
|
+
export function isAgentsServerSqliteMode(): boolean {
|
|
33
|
+
return resolveAgentsServerDatabaseMode() === 'sqlite';
|
|
34
|
+
}
|