Files
wehub-resource-sync e115934061
Publish `@librechat/data-schemas` to NPM / pack (push) Failing after 8s
Publish `@librechat/client` to NPM / pack (push) Failing after 0s
GitNexus Index / index (push) Failing after 1s
Sync Locize Translations & Create Translation PR / Create Translation PR on Version Published (push) Has been skipped
Sync Helm Chart Tags / Sync chart tags (push) Failing after 2s
Publish `librechat-data-provider` to NPM / pack (push) Failing after 1s
Docker Dev Images Build / build (Dockerfile, librechat-dev, node) (push) Failing after 1s
Docker Dev Images Build / build (Dockerfile.multi, librechat-dev-api, api-build) (push) Failing after 0s
Sync Helm Chart Tags / Ignore non-main push (push) Has been skipped
Sync Locize Translations & Create Translation PR / Sync Translation Keys with Locize (push) Failing after 1s
Publish `@librechat/client` to NPM / publish-npm (push) Has been cancelled
Publish `librechat-data-provider` to NPM / publish-npm (push) Has been cancelled
GitNexus Index / post-index (push) Has been cancelled
Publish `@librechat/data-schemas` to NPM / publish-npm (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:08:12 +08:00

58 lines
1.6 KiB
JavaScript

const { EventSource } = require('eventsource');
const { Time } = require('librechat-data-provider');
const {
mcpConfig,
MCPManager,
FlowStateManager,
MCPServersRegistry,
OAuthReconnectionManager,
} = require('@librechat/api');
global.EventSource = EventSource;
/** @type {FlowStateManager} */
let flowManager = null;
/** @type {FlowStateManager} */
let actionFlowManager = null;
/**
* Flow manager for MCP OAuth flows. Uses the longer MCP OAuth TTL so the auth
* button and flow state outlive the user-completion window.
* @param {Keyv} flowsCache
* @returns {FlowStateManager}
*/
function getFlowStateManager(flowsCache) {
if (!flowManager) {
flowManager = new FlowStateManager(flowsCache, {
ttl: mcpConfig.OAUTH_FLOW_TTL,
});
}
return flowManager;
}
/**
* Flow manager for Action (custom tool) OAuth flows. Kept on the shorter TTL so an
* unclicked action login does not leave the tool call waiting for the MCP OAuth window.
* @param {Keyv} flowsCache
* @returns {FlowStateManager}
*/
function getActionFlowStateManager(flowsCache) {
if (!actionFlowManager) {
actionFlowManager = new FlowStateManager(flowsCache, {
ttl: Time.ONE_MINUTE * 3,
});
}
return actionFlowManager;
}
module.exports = {
createMCPServersRegistry: MCPServersRegistry.createInstance,
getMCPServersRegistry: MCPServersRegistry.getInstance,
createMCPManager: MCPManager.createInstance,
getMCPManager: MCPManager.getInstance,
getFlowStateManager,
getActionFlowStateManager,
createOAuthReconnectionManager: OAuthReconnectionManager.createInstance,
getOAuthReconnectionManager: OAuthReconnectionManager.getInstance,
};