mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-08 22:22:17 +02:00
MCP consolidation: - Route all MCP-capable connectors (Slack, Jira, Linear, ClickUp, Airtable, Notion, Confluence, interim Gmail/Calendar, custom MCP) through a single `mcp_discovery` subagent. Drive/OneDrive/Dropbox stay native to enrich the KB. - Deprecate Discord/Teams/Luma: no viable official MCP server. Google-only web search: - Remove the main-agent `web_search` tool and the SearXNG platform service; all public web search now flows through the `google_search` subagent via task(). - Deprecate the Tavily/SearXNG/Linkup/Baidu search connectors (HTTP 410 on create, "Deprecated" badge); guide heavy users to the custom MCP connector. - Remove web search from anonymous chat (pure Q&A). - Tear SearXNG out of docker compose + install scripts; drop tavily-python and linkup-sdk deps and their config/env vars. Fix: - metrics._package_version() now swallows any metadata lookup failure. A malformed editable-install distribution with no `Version` field raised KeyError deep in importlib.metadata, and since it runs on every record_subagent_invoke_duration call it was crashing every task() delegation. Verified end-to-end against live GPT-5.4. Co-authored-by: Cursor <cursoragent@cursor.com>
74 lines
1.9 KiB
TypeScript
74 lines
1.9 KiB
TypeScript
"use client";
|
|
|
|
import { createContext, type ReactNode, useContext, useEffect, useMemo, useState } from "react";
|
|
import { anonymousChatApiService } from "@/lib/apis/anonymous-chat-api.service";
|
|
|
|
export interface AnonymousModeContextValue {
|
|
isAnonymous: true;
|
|
modelSlug: string;
|
|
setModelSlug: (slug: string) => void;
|
|
uploadedDoc: { filename: string; sizeBytes: number } | null;
|
|
setUploadedDoc: (doc: { filename: string; sizeBytes: number } | null) => void;
|
|
resetKey: number;
|
|
resetChat: () => void;
|
|
}
|
|
|
|
interface AuthenticatedContextValue {
|
|
isAnonymous: false;
|
|
}
|
|
|
|
type ContextValue = AnonymousModeContextValue | AuthenticatedContextValue;
|
|
|
|
const DEFAULT_VALUE: AuthenticatedContextValue = { isAnonymous: false };
|
|
|
|
const AnonymousModeContext = createContext<ContextValue>(DEFAULT_VALUE);
|
|
|
|
export function AnonymousModeProvider({
|
|
initialModelSlug,
|
|
children,
|
|
}: {
|
|
initialModelSlug: string;
|
|
children: ReactNode;
|
|
}) {
|
|
const [modelSlug, setModelSlug] = useState(initialModelSlug);
|
|
const [uploadedDoc, setUploadedDoc] = useState<{ filename: string; sizeBytes: number } | null>(
|
|
null
|
|
);
|
|
const [resetKey, setResetKey] = useState(0);
|
|
|
|
const resetChat = () => setResetKey((k) => k + 1);
|
|
|
|
useEffect(() => {
|
|
anonymousChatApiService
|
|
.getDocument()
|
|
.then((doc) => {
|
|
if (doc) {
|
|
setUploadedDoc({ filename: doc.filename, sizeBytes: doc.size_bytes });
|
|
}
|
|
})
|
|
.catch(() => {});
|
|
}, []);
|
|
|
|
const value = useMemo<AnonymousModeContextValue>(
|
|
() => ({
|
|
isAnonymous: true,
|
|
modelSlug,
|
|
setModelSlug,
|
|
uploadedDoc,
|
|
setUploadedDoc,
|
|
resetKey,
|
|
resetChat,
|
|
}),
|
|
[modelSlug, uploadedDoc, resetKey]
|
|
);
|
|
|
|
return <AnonymousModeContext.Provider value={value}>{children}</AnonymousModeContext.Provider>;
|
|
}
|
|
|
|
export function useAnonymousMode(): ContextValue {
|
|
return useContext(AnonymousModeContext);
|
|
}
|
|
|
|
export function useIsAnonymous(): boolean {
|
|
return useContext(AnonymousModeContext).isAnonymous;
|
|
}
|