@remnic/server 9.54.5 → 9.54.7
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/dist/index.js +21 -3
- package/dist/index.js.map +1 -1
- package/package.json +10 -4
- package/src/index.ts +1207 -0
- package/src/oauth.ts +1078 -0
- package/src/server-env.ts +68 -0
- package/src/startup-readiness.ts +238 -0
- package/src/support-passport-runtime.ts +29 -0
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
import fs from "fs";
|
|
5
5
|
import path from "path";
|
|
6
|
-
import { parseConfig, isOpenaiApiKeyDisabled, resolveRemnicConfigRecord, Orchestrator,
|
|
6
|
+
import { parseConfig, isOpenaiApiKeyDisabled, resolveRemnicConfigRecord, Orchestrator, EngramAccessHttpServer, initLogger, log as log3, getAllValidTokens, getAllValidTokenEntriesCached, loadTokenStore, expandTildePath } from "@remnic/core";
|
|
7
7
|
import { probeBetterSqlite3Driver } from "@remnic/core/runtime/better-sqlite";
|
|
8
8
|
|
|
9
9
|
// src/oauth.ts
|
|
@@ -879,6 +879,23 @@ async function completeStartupReadiness(options) {
|
|
|
879
879
|
}
|
|
880
880
|
}
|
|
881
881
|
|
|
882
|
+
// src/support-passport-runtime.ts
|
|
883
|
+
import {
|
|
884
|
+
EngramAccessService,
|
|
885
|
+
SupportPassportModelBridge,
|
|
886
|
+
composeSupportPassportExternalRequestHandlers
|
|
887
|
+
} from "@remnic/core";
|
|
888
|
+
function createSupportPassportServerRuntime(orchestrator, config, fallbackHandler) {
|
|
889
|
+
const bridge = config.supportPassport.enabled ? new SupportPassportModelBridge() : null;
|
|
890
|
+
return {
|
|
891
|
+
service: new EngramAccessService(orchestrator, {
|
|
892
|
+
supportPassportGatewayRoute: bridge?.route
|
|
893
|
+
}),
|
|
894
|
+
externalRequestHandler: composeSupportPassportExternalRequestHandlers(bridge?.requestHandler, fallbackHandler),
|
|
895
|
+
close: () => bridge?.close()
|
|
896
|
+
};
|
|
897
|
+
}
|
|
898
|
+
|
|
882
899
|
// src/index.ts
|
|
883
900
|
function parseServerPort(value, source) {
|
|
884
901
|
const port = typeof value === "string" ? Number(value.trim()) : value;
|
|
@@ -1458,7 +1475,6 @@ async function startServer(options) {
|
|
|
1458
1475
|
log3.debug(`debug logging enabled from config (${resolvedConfigPath.source})`);
|
|
1459
1476
|
const orchestrator = new Orchestrator(config);
|
|
1460
1477
|
await orchestrator.initialize();
|
|
1461
|
-
const service = new EngramAccessService(orchestrator);
|
|
1462
1478
|
const readiness = { ready: false, warmupAttempts: 0, lastError: null, degraded: false };
|
|
1463
1479
|
const authToken = parsedServerConfig.authToken ?? readCompatEnv("REMNIC_AUTH_TOKEN", "ENGRAM_AUTH_TOKEN") ?? "";
|
|
1464
1480
|
if (!authToken && getAllValidTokens().length === 0) {
|
|
@@ -1466,6 +1482,7 @@ async function startServer(options) {
|
|
|
1466
1482
|
}
|
|
1467
1483
|
const oauthConfig = applyOAuthEnvOverrides(serverConfig.oauth);
|
|
1468
1484
|
const oauthRequestHandler = buildOAuthRequestHandler(oauthConfig);
|
|
1485
|
+
const supportPassportRuntime = createSupportPassportServerRuntime(orchestrator, config, oauthRequestHandler), { service } = supportPassportRuntime;
|
|
1469
1486
|
const httpServer = new EngramAccessHttpServer({
|
|
1470
1487
|
service,
|
|
1471
1488
|
host: parsedServerConfig.host,
|
|
@@ -1490,8 +1507,8 @@ async function startServer(options) {
|
|
|
1490
1507
|
citationsEnabled: config.citationsEnabled,
|
|
1491
1508
|
citationsAutoDetect: config.citationsAutoDetect,
|
|
1492
1509
|
emitLegacyTools: config.emitLegacyTools,
|
|
1510
|
+
externalRequestHandler: supportPassportRuntime.externalRequestHandler,
|
|
1493
1511
|
...oauthConfig.enabled ? {
|
|
1494
|
-
externalRequestHandler: oauthRequestHandler,
|
|
1495
1512
|
resourceMetadataUrl: new URL(
|
|
1496
1513
|
"/.well-known/oauth-protected-resource/mcp",
|
|
1497
1514
|
oauthConfig.issuerUrl
|
|
@@ -1556,6 +1573,7 @@ async function startServer(options) {
|
|
|
1556
1573
|
stopPromise = (async () => {
|
|
1557
1574
|
startupSyncAbort.abort();
|
|
1558
1575
|
readinessAbort.abort();
|
|
1576
|
+
supportPassportRuntime.close();
|
|
1559
1577
|
orchestrator.abortDeferredInit();
|
|
1560
1578
|
try {
|
|
1561
1579
|
await originalStop();
|