Files
openchamber/packages/web/server/lib/opencode/bootstrap-runtime.js
T
Bohdan Triapitsyn a2730b793e fix(notifications): suppress permission notifs when session auto-accepts
Server now mirrors client-side Permission Auto-Accept via
POST /api/notifications/auto-accept and short-circuits permission.asked
dispatch (walking the session parent chain). Prior 500ms debounce raced
the client auto-response and leaked notifications.

Also hint under Summarize Last Message that templates must contain
{last_message} for the setting to take effect.
2026-04-22 19:22:50 +03:00

131 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,
uiPassword,
tunnelAuthController,
readSettingsFromDiskMigrated,
normalizeTunnelSessionTtlMs,
resolveZenModel,
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, {
process,
openchamberVersion,
runtimeName,
serverStartedAt,
gracefulShutdown,
getHealthSnapshot,
});
registerCommonRequestMiddleware(app, { express });
const uiAuthController = createUiAuth({
password: uiPassword,
readSettingsFromDiskMigrated,
});
if (uiAuthController.enabled) {
console.log('UI password protection enabled for browser sessions');
}
registerAuthAndAccessRoutes(app, {
tunnelAuthController,
uiAuthController,
readSettingsFromDiskMigrated,
normalizeTunnelSessionTtlMs,
});
registerTtsRoutes(app, { resolveZenModel, 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,
};
};