Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { AsyncLoaderRegistry } from "@/plugins/__async-deps__/async-loaders";
import { spaRouteChangeCompleteSubscribe } from "@/plugins/__core__/_main-world/spa-router/utils";
import { internalSearchStatesObserverStore } from "@/plugins/__core__/dom-observers/internal-search-states/store";
import { whereAmI } from "@/utils/misc/utils";

declare module "@/plugins/__async-deps__/async-loaders" {
interface AsyncLoadersRegistry {
"plugin:queryBox:connectorsAlwaysOn": void;
}
}

export default function () {
AsyncLoaderRegistry.register({
id: "plugin:queryBox:connectorsAlwaysOn",
dependencies: [
"cache:pluginsEnableStates",
"cache:extensionSettings",
"corePlugin:domObservers:mainWorldActions",
],
loader: async ({
"cache:pluginsEnableStates": pluginsEnableStates,
"cache:extensionSettings": extensionSettings,
}) => {
if (!pluginsEnableStates["connectorsAlwaysOn"]) return;

const settings = extensionSettings.plugins["connectorsAlwaysOn"];
const connectorsToEnable = settings.connectors;

spaRouteChangeCompleteSubscribe(
async (url) => {
const location = whereAmI(url);

// Only apply to home page, not spaces
if (location !== "home") return;

// Get current sources
const currentState = internalSearchStatesObserverStore.getState();
let currentSources = currentState.sources;

// If sources is empty (Perplexity hasn't initialized yet), use web as default
if (currentSources.length === 0) {
currentSources = ["web"];
}

// Add all configured connectors that aren't already present
const connectorsToAdd = connectorsToEnable.filter(
(connector) => !currentSources.includes(connector),
);

if (connectorsToAdd.length > 0) {
const updatedSources = [...currentSources, ...connectorsToAdd];
internalSearchStatesObserverStore.getState().setInternalSearchStates({
sources: updatedSources,
});
console.log(
"[Complexity] Added connectors to sources:",
connectorsToAdd,
"-> Result:",
updatedSources,
);
} else {
console.log("[Complexity] All configured connectors already enabled");
}
},
{
immediate: true,
},
);
},
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { z } from "zod";

import { definePlugin } from "@/__registries__/plugins/utils";

declare module "@/__registries__/plugins/meta.types" {
interface PluginsSettingsRegistry {
connectorsAlwaysOn: z.infer<typeof schema>;
}
}

// Known connector IDs (found in Perplexity source):
//
// Basic Sources:
// - "web" - Web search (default)
// - "academic" - Academic sources
// - "reddit" - Reddit
// - "youtube" - YouTube
// - "writing" - Writing mode
// - "social" - Social media
// - "edgar" - SEC EDGAR filings
//
// MCP Connectors (Model Context Protocol):
// - "github_mcp_direct" - GitHub MCP (default in this plugin)
// - "notion" - Notion
// - "notion_mcp" - Notion MCP
// - "linear" - Linear
// - "linear_alt" - Linear (alternative)
// - "slack" - Slack
// - "slack_direct" - Slack Direct
// - "google_drive" - Google Drive
// - "asana_mcp_direct" - Asana MCP
// - "asana_mcp_merge" - Asana MCP (merge)
// - "atlassian_mcp_direct" - Atlassian/Jira/Confluence
// - "confluence_mcp_merge" - Confluence MCP (merge)
// - "jira_mcp_merge" - Jira MCP (merge)
// - "microsoft_teams_mcp_merge" - Microsoft Teams MCP
//
// Premium/Enterprise:
// - "cbinsights_mcp_cashmere" - CB Insights
// - "pitchbook_mcp_cashmere" - PitchBook
// - "statista_mcp_cashmere" - Statista
// - "wiley_mcp_cashmere" - Wiley

const schema = z.object({
enabled: z.boolean(),
connectors: z.array(z.string()).default(["github_mcp_direct"]),
});

export default definePlugin({
meta: {
id: "connectorsAlwaysOn",
title: "Connectors Always On",
description:
"Automatically enables selected connectors on page load (does not affect Spaces)",
dashboardMeta: {
tags: ["new"],
categories: ["featured", "queryBox"],
uiRouteSegment: "connectors-always-on",
},
dependencies: {
corePlugins: ["spaRouter", "domObservers:internalSearchStates"],
},
},
settingsSchema: {
schema,
fallback: {
enabled: true,
connectors: ["github_mcp_direct"], // GitHub MCP always enabled by default
},
},
});