@promptbook/cli 0.112.0-95 → 0.112.0-97
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 +3 -3
- package/apps/agents-server/next.config.ts +8 -1
- package/apps/agents-server/playwright.config.ts +4 -1
- package/apps/agents-server/src/app/admin/code-runners/CodeRunnersClient.tsx +358 -19
- package/apps/agents-server/src/app/admin/database/DatabaseAdminClient.tsx +38 -0
- package/apps/agents-server/src/app/admin/database/DatabaseAdminStudioSurface.tsx +42 -0
- package/apps/agents-server/src/app/admin/database/page.tsx +34 -0
- package/apps/agents-server/src/app/admin/servers/CreateServerDialog.tsx +46 -505
- package/apps/agents-server/src/app/admin/servers/ServersClient.tsx +23 -11
- package/apps/agents-server/src/app/admin/servers/ServersRegistryApi.ts +5 -0
- package/apps/agents-server/src/app/admin/servers/ServersRegistryDnsTypes.ts +87 -0
- package/apps/agents-server/src/app/admin/servers/ServersRegistryTable.tsx +258 -128
- package/apps/agents-server/src/app/admin/servers/useCreateServerWizard.ts +46 -334
- package/apps/agents-server/src/app/admin/servers/useServersRegistryState.ts +26 -2
- package/apps/agents-server/src/app/admin/update/UpdateClient.tsx +435 -0
- package/apps/agents-server/src/app/admin/update/page.tsx +14 -0
- package/apps/agents-server/src/app/api/admin/code-runners/authentication/route.ts +197 -0
- package/apps/agents-server/src/app/api/admin/code-runners/route.ts +4 -35
- package/apps/agents-server/src/app/api/admin/database/studio/route.ts +113 -0
- package/apps/agents-server/src/app/api/admin/servers/[serverId]/route.ts +10 -5
- package/apps/agents-server/src/app/api/admin/servers/route.ts +97 -6
- package/apps/agents-server/src/app/api/admin/update/route.ts +52 -0
- package/apps/agents-server/src/app/api/auth/login/route.ts +8 -0
- package/apps/agents-server/src/app/api/auth/logout/route.ts +10 -2
- package/apps/agents-server/src/app/layout.tsx +1 -0
- package/apps/agents-server/src/app/page.tsx +10 -0
- package/apps/agents-server/src/components/Header/buildHeaderSystemMenuItems.ts +10 -0
- package/apps/agents-server/src/database/$provideClientSql.ts +4 -21
- package/apps/agents-server/src/database/$provideDatabaseAdminExecutor.ts +252 -0
- package/apps/agents-server/src/database/$providePostgresPool.ts +27 -0
- package/apps/agents-server/src/database/$provideSupabaseForServer.ts +11 -1
- package/apps/agents-server/src/database/agentsServerDatabaseMode.ts +20 -1
- package/apps/agents-server/src/database/postgres/$provideLocalPostgresSupabase.ts +1261 -0
- package/apps/agents-server/src/database/resolvePostgresConnectionString.ts +26 -0
- package/apps/agents-server/src/database/sqlite/$provideAgentsServerSqliteDatabase.ts +83 -0
- package/apps/agents-server/src/database/sqlite/$provideLocalSqliteSupabase.ts +20 -71
- package/apps/agents-server/src/languages/ServerTranslationKeys.ts +2 -0
- package/apps/agents-server/src/languages/translations/czech.yaml +2 -0
- package/apps/agents-server/src/languages/translations/english.yaml +2 -0
- package/apps/agents-server/src/middleware.ts +32 -0
- package/apps/agents-server/src/tools/$provideServer.ts +2 -2
- package/apps/agents-server/src/utils/codeRunnerAuthentication.ts +394 -0
- package/apps/agents-server/src/utils/codeRunnerConfiguration.ts +67 -0
- package/apps/agents-server/src/utils/serverManagement/standaloneVpsServerMetadata.ts +145 -0
- package/apps/agents-server/src/utils/serverRegistry.ts +7 -6
- package/apps/agents-server/src/utils/session.ts +37 -9
- package/apps/agents-server/src/utils/shibboleth/createShibbolethAuthenticationLogPayload.ts +173 -0
- package/apps/agents-server/src/utils/shibboleth/writeShibbolethAuthenticationLog.ts +27 -0
- package/apps/agents-server/src/utils/standaloneVpsDnsDiagnostics.ts +258 -0
- package/apps/agents-server/src/utils/standaloneVpsRawIpBootstrap.ts +87 -0
- package/apps/agents-server/src/utils/vpsConfiguration.ts +87 -15
- package/apps/agents-server/src/utils/vpsSelfUpdate.ts +664 -0
- package/esm/apps/agents-server/src/database/agentsServerDatabaseMode.d.ts +9 -1
- package/esm/apps/agents-server/src/utils/serverRegistry.d.ts +1 -1
- package/esm/index.es.js +8 -6
- 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/utils/renderMarkdown.ts +1 -3
- package/src/cli/cli-commands/agents-server/ensureAgentsServerEnvFile.ts +1 -1
- package/src/other/templates/getTemplatesPipelineCollection.ts +767 -745
- package/src/scrapers/document/DocumentScraper.ts +1 -1
- package/src/scrapers/document-legacy/LegacyDocumentScraper.ts +1 -1
- package/src/version.ts +2 -2
- package/src/versions.txt +2 -1
- package/umd/apps/agents-server/src/database/agentsServerDatabaseMode.d.ts +9 -1
- package/umd/apps/agents-server/src/utils/serverRegistry.d.ts +1 -1
- package/umd/index.umd.js +8 -6
- package/umd/index.umd.js.map +1 -1
- package/umd/src/version.d.ts +1 -1
|
@@ -6,6 +6,7 @@ import { promisify } from 'util';
|
|
|
6
6
|
import { spaceTrim } from 'spacetrim';
|
|
7
7
|
import { NotAllowed } from '../../../../src/errors/NotAllowed';
|
|
8
8
|
import { normalizeServerDomain } from './serverRegistry';
|
|
9
|
+
import { isStandaloneVpsRawIpBootstrapActive } from './standaloneVpsRawIpBootstrap';
|
|
9
10
|
|
|
10
11
|
const execFileAsync = promisify(execFile);
|
|
11
12
|
|
|
@@ -31,8 +32,6 @@ export const VPS_ENVIRONMENT_VARIABLE_KEYS = [
|
|
|
31
32
|
'PTBK_PM2_APP_NAME',
|
|
32
33
|
'PTBK_NGINX_SITE_NAME',
|
|
33
34
|
'LETS_ENCRYPT_EMAIL',
|
|
34
|
-
'PTBK_AGENTS_SERVER_DATABASE',
|
|
35
|
-
'PTBK_AGENTS_SERVER_SQLITE_PATH',
|
|
36
35
|
'SUPABASE_TABLE_PREFIX',
|
|
37
36
|
'SUPABASE_AUTO_MIGRATE',
|
|
38
37
|
'COPILOT_GITHUB_TOKEN',
|
|
@@ -87,6 +86,21 @@ export type VpsCommandResult = {
|
|
|
87
86
|
readonly output: string;
|
|
88
87
|
};
|
|
89
88
|
|
|
89
|
+
/**
|
|
90
|
+
* Runtime-installer execution options used by VPS admin actions.
|
|
91
|
+
*/
|
|
92
|
+
type RunVpsInstallerCommandOptions = {
|
|
93
|
+
/**
|
|
94
|
+
* Whether the installer should disable interactive prompts.
|
|
95
|
+
*/
|
|
96
|
+
readonly isNonInteractiveModeEnabled?: boolean;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Whether the installer may restart the running Agents Server process.
|
|
100
|
+
*/
|
|
101
|
+
readonly isProcessRestartEnabled?: boolean;
|
|
102
|
+
};
|
|
103
|
+
|
|
90
104
|
/**
|
|
91
105
|
* Parsed `.env` line representation used to preserve comments and ordering.
|
|
92
106
|
*/
|
|
@@ -191,30 +205,51 @@ export async function listConfiguredVpsDomains(): Promise<Array<string>> {
|
|
|
191
205
|
return parseDomainsCsv(rawServers);
|
|
192
206
|
}
|
|
193
207
|
|
|
208
|
+
/**
|
|
209
|
+
* Options used when updating the standalone VPS domain list.
|
|
210
|
+
*/
|
|
211
|
+
type UpdateConfiguredVpsDomainsOptions = {
|
|
212
|
+
/**
|
|
213
|
+
* Optional server-level table prefix to persist together with the domain list.
|
|
214
|
+
*/
|
|
215
|
+
readonly tablePrefix?: string | null;
|
|
216
|
+
};
|
|
217
|
+
|
|
194
218
|
/**
|
|
195
219
|
* Replaces the standalone VPS domain list in `.env`.
|
|
196
220
|
*
|
|
197
221
|
* @param domains - Domains to store in `SERVERS`.
|
|
222
|
+
* @param options - Optional server-level settings to persist.
|
|
198
223
|
* @returns Safe environment snapshot after writing.
|
|
199
224
|
*/
|
|
200
225
|
export async function updateConfiguredVpsDomains(
|
|
201
226
|
domains: ReadonlyArray<string>,
|
|
227
|
+
options?: UpdateConfiguredVpsDomainsOptions,
|
|
202
228
|
): Promise<Awaited<ReturnType<typeof listVpsEnvironmentVariables>>> {
|
|
203
229
|
const normalizedDomains = normalizeDomains(domains);
|
|
204
230
|
const primaryDomain = normalizedDomains[0] ?? '';
|
|
231
|
+
const envValues = await readVpsEnvironmentMap(resolveVpsEnvironmentFilePath());
|
|
232
|
+
const currentPublicSiteUrl = envValues.get('NEXT_PUBLIC_SITE_URL') ?? process.env.NEXT_PUBLIC_SITE_URL ?? '';
|
|
233
|
+
const publicIpAddress = envValues.get('PTBK_PUBLIC_IP_ADDRESS') ?? process.env.PTBK_PUBLIC_IP_ADDRESS ?? '';
|
|
205
234
|
const updates: Record<string, string> = {
|
|
206
235
|
SERVERS: normalizedDomains.join(','),
|
|
207
236
|
};
|
|
208
237
|
|
|
209
238
|
if (primaryDomain) {
|
|
210
|
-
updates.NEXT_PUBLIC_SITE_URL =
|
|
211
|
-
|
|
239
|
+
updates.NEXT_PUBLIC_SITE_URL = isStandaloneVpsRawIpBootstrapActive({
|
|
240
|
+
nextPublicSiteUrl: currentPublicSiteUrl,
|
|
241
|
+
publicIpAddress,
|
|
242
|
+
})
|
|
243
|
+
? currentPublicSiteUrl
|
|
244
|
+
: `https://${primaryDomain}`;
|
|
212
245
|
} else {
|
|
213
|
-
const publicIpAddress = process.env.PTBK_PUBLIC_IP_ADDRESS?.trim();
|
|
214
246
|
updates.NEXT_PUBLIC_SITE_URL = publicIpAddress
|
|
215
247
|
? `http://${publicIpAddress}`
|
|
216
248
|
: '';
|
|
217
|
-
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if (options && Object.prototype.hasOwnProperty.call(options, 'tablePrefix')) {
|
|
252
|
+
updates.SUPABASE_TABLE_PREFIX = options.tablePrefix?.trim() || '';
|
|
218
253
|
}
|
|
219
254
|
|
|
220
255
|
return updateVpsEnvironmentVariables(updates);
|
|
@@ -225,8 +260,14 @@ export async function updateConfiguredVpsDomains(
|
|
|
225
260
|
*
|
|
226
261
|
* @returns Command output or a skipped reason when not running on a Linux VPS.
|
|
227
262
|
*/
|
|
228
|
-
export async function applyVpsRuntimeConfiguration(
|
|
229
|
-
|
|
263
|
+
export async function applyVpsRuntimeConfiguration(
|
|
264
|
+
options?: RunVpsInstallerCommandOptions,
|
|
265
|
+
): Promise<VpsCommandResult> {
|
|
266
|
+
return runVpsInstallerCommand(
|
|
267
|
+
'apply-domains',
|
|
268
|
+
'VPS runtime configuration can only be applied on Linux.',
|
|
269
|
+
options,
|
|
270
|
+
);
|
|
230
271
|
}
|
|
231
272
|
|
|
232
273
|
/**
|
|
@@ -270,7 +311,11 @@ export async function readVpsPm2Logs(lineCount = 200): Promise<VpsCommandResult>
|
|
|
270
311
|
* @param unavailableOutput - Message returned on non-Linux platforms.
|
|
271
312
|
* @returns Command output or unavailable reason.
|
|
272
313
|
*/
|
|
273
|
-
async function runVpsInstallerCommand(
|
|
314
|
+
async function runVpsInstallerCommand(
|
|
315
|
+
command: string,
|
|
316
|
+
unavailableOutput: string,
|
|
317
|
+
options?: RunVpsInstallerCommandOptions,
|
|
318
|
+
): Promise<VpsCommandResult> {
|
|
274
319
|
if (process.platform !== 'linux') {
|
|
275
320
|
return {
|
|
276
321
|
isAvailable: false,
|
|
@@ -288,10 +333,7 @@ async function runVpsInstallerCommand(command: string, unavailableOutput: string
|
|
|
288
333
|
|
|
289
334
|
try {
|
|
290
335
|
const { stdout, stderr } = await execFileAsync('bash', [scriptPath, command], {
|
|
291
|
-
env:
|
|
292
|
-
...process.env,
|
|
293
|
-
PTBK_NON_INTERACTIVE: '1',
|
|
294
|
-
},
|
|
336
|
+
env: createVpsInstallerCommandEnvironment(options),
|
|
295
337
|
maxBuffer: 1024 * 1024,
|
|
296
338
|
});
|
|
297
339
|
|
|
@@ -316,6 +358,31 @@ async function runVpsInstallerCommand(command: string, unavailableOutput: string
|
|
|
316
358
|
}
|
|
317
359
|
}
|
|
318
360
|
|
|
361
|
+
/**
|
|
362
|
+
* Creates the environment passed to the shared VPS installer script.
|
|
363
|
+
*
|
|
364
|
+
* @param options - Installer execution options.
|
|
365
|
+
* @returns Child-process environment.
|
|
366
|
+
*
|
|
367
|
+
* @private internal helper of `vpsConfiguration`
|
|
368
|
+
*/
|
|
369
|
+
export function createVpsInstallerCommandEnvironment(
|
|
370
|
+
options?: RunVpsInstallerCommandOptions,
|
|
371
|
+
): NodeJS.ProcessEnv {
|
|
372
|
+
const environment: NodeJS.ProcessEnv = {
|
|
373
|
+
...process.env,
|
|
374
|
+
...(options?.isProcessRestartEnabled === false ? { PTBK_SKIP_PM2_RESTART: '1' } : {}),
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
if (options?.isNonInteractiveModeEnabled === false) {
|
|
378
|
+
delete environment.PTBK_NON_INTERACTIVE;
|
|
379
|
+
} else {
|
|
380
|
+
environment.PTBK_NON_INTERACTIVE = '1';
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
return environment;
|
|
384
|
+
}
|
|
385
|
+
|
|
319
386
|
/**
|
|
320
387
|
* Returns whether an environment variable must be masked in the UI.
|
|
321
388
|
*
|
|
@@ -477,7 +544,12 @@ function parseEnvLines(content: string): Array<ParsedEnvLine> {
|
|
|
477
544
|
return { type: 'raw', raw };
|
|
478
545
|
}
|
|
479
546
|
|
|
480
|
-
const
|
|
547
|
+
const key = match[1];
|
|
548
|
+
const rawValue = match[2] ?? '';
|
|
549
|
+
if (!key) {
|
|
550
|
+
return { type: 'raw', raw };
|
|
551
|
+
}
|
|
552
|
+
|
|
481
553
|
return {
|
|
482
554
|
type: 'entry',
|
|
483
555
|
raw,
|
|
@@ -528,7 +600,7 @@ async function readOptionalTextFile(filePath: string): Promise<string> {
|
|
|
528
600
|
*
|
|
529
601
|
* @returns Script path or `null` when unavailable.
|
|
530
602
|
*/
|
|
531
|
-
async function resolveVpsInstallerScriptPath(): Promise<string | null> {
|
|
603
|
+
export async function resolveVpsInstallerScriptPath(): Promise<string | null> {
|
|
532
604
|
const candidates = [
|
|
533
605
|
process.env.PTBK_VPS_INSTALL_SCRIPT?.trim(),
|
|
534
606
|
process.env.PTBK_REPOSITORY_DIR ? join(process.env.PTBK_REPOSITORY_DIR, 'other/vps/install.sh') : '',
|