* fix terminal rendering and preview detection * Fix bot comments * fix: protect terminal preview URL probe --------- Co-authored-by: Konstantin Zolin <zolin_ka@vk.com> Co-authored-by: Bohdan Triapitsyn <artmore@protonmail.com>
133 lines
3.3 KiB
JavaScript
133 lines
3.3 KiB
JavaScript
export const createBootstrapRuntime = (dependencies) => {
|
|
const {
|
|
createUiAuth,
|
|
registerServerStatusRoutes,
|
|
registerCommonRequestMiddleware,
|
|
registerAuthAndAccessRoutes,
|
|
registerTtsRoutes,
|
|
registerNotificationRoutes,
|
|
registerOpenChamberRoutes,
|
|
express,
|
|
} = dependencies;
|
|
|
|
const setupBaseRoutes = (app, options) => {
|
|
const {
|
|
process,
|
|
openchamberVersion,
|
|
runtimeName,
|
|
serverStartedAt,
|
|
gracefulShutdown,
|
|
getHealthSnapshot,
|
|
verboseRequestLogs,
|
|
uiPassword,
|
|
tunnelAuthController,
|
|
readSettingsFromDiskMigrated,
|
|
normalizeTunnelSessionTtlMs,
|
|
sayTTSCapability,
|
|
ensurePushInitialized,
|
|
ensureGlobalWatcherStarted,
|
|
getOrCreateVapidKeys,
|
|
getUiSessionTokenFromRequest,
|
|
writeSettingsToDisk,
|
|
addOrUpdatePushSubscription,
|
|
removePushSubscription,
|
|
updateUiVisibility,
|
|
isUiVisible,
|
|
getUiNotificationClients,
|
|
writeSseEvent,
|
|
sessionRuntime,
|
|
setPushInitialized,
|
|
fs,
|
|
os,
|
|
path,
|
|
server,
|
|
__dirname,
|
|
openchamberDataDir,
|
|
modelsDevApiUrl,
|
|
modelsMetadataCacheTtl,
|
|
fetchFreeZenModels,
|
|
getCachedZenModels,
|
|
setAutoAcceptSession,
|
|
} = options;
|
|
|
|
registerServerStatusRoutes(app, {
|
|
express,
|
|
process,
|
|
openchamberVersion,
|
|
runtimeName,
|
|
serverStartedAt,
|
|
gracefulShutdown,
|
|
getHealthSnapshot,
|
|
});
|
|
|
|
registerCommonRequestMiddleware(app, { express, verboseRequestLogs });
|
|
|
|
const uiAuthController = createUiAuth({
|
|
password: uiPassword,
|
|
readSettingsFromDiskMigrated,
|
|
});
|
|
if (uiAuthController.enabled) {
|
|
console.log('UI password protection enabled for browser sessions');
|
|
}
|
|
|
|
registerAuthAndAccessRoutes(app, {
|
|
express,
|
|
tunnelAuthController,
|
|
uiAuthController,
|
|
readSettingsFromDiskMigrated,
|
|
normalizeTunnelSessionTtlMs,
|
|
});
|
|
|
|
registerTtsRoutes(app, { sayTTSCapability });
|
|
|
|
registerNotificationRoutes(app, {
|
|
uiAuthController,
|
|
ensurePushInitialized,
|
|
ensureGlobalWatcherStarted,
|
|
getOrCreateVapidKeys,
|
|
getUiSessionTokenFromRequest,
|
|
readSettingsFromDiskMigrated,
|
|
writeSettingsToDisk,
|
|
addOrUpdatePushSubscription,
|
|
removePushSubscription,
|
|
updateUiVisibility,
|
|
isUiVisible,
|
|
getUiNotificationClients,
|
|
writeSseEvent,
|
|
getSessionActivitySnapshot: sessionRuntime.getSessionActivitySnapshot,
|
|
getSessionStateSnapshot: sessionRuntime.getSessionStateSnapshot,
|
|
getSessionAttentionSnapshot: sessionRuntime.getSessionAttentionSnapshot,
|
|
getSessionState: sessionRuntime.getSessionState,
|
|
getSessionAttentionState: sessionRuntime.getSessionAttentionState,
|
|
markSessionViewed: sessionRuntime.markSessionViewed,
|
|
markSessionUnviewed: sessionRuntime.markSessionUnviewed,
|
|
markUserMessageSent: sessionRuntime.markUserMessageSent,
|
|
setPushInitialized,
|
|
setAutoAcceptSession,
|
|
});
|
|
|
|
registerOpenChamberRoutes(app, {
|
|
fs,
|
|
os,
|
|
path,
|
|
process,
|
|
server,
|
|
__dirname,
|
|
openchamberDataDir,
|
|
modelsDevApiUrl,
|
|
modelsMetadataCacheTtl,
|
|
readSettingsFromDiskMigrated,
|
|
fetchFreeZenModels,
|
|
getCachedZenModels,
|
|
});
|
|
|
|
return {
|
|
uiAuthController,
|
|
};
|
|
};
|
|
|
|
return {
|
|
setupBaseRoutes,
|
|
};
|
|
};
|