Spaces:
Running
Running
Deploy ML Intern Slack worker (5)
Browse filesFiles changed (2)
4 unmodified lines56789101122 unmodified lines3435363738394034 unmodified lines7576777879804 unmodified linesimport { collections } from "$lib/server/database";import { connectAccount, readConnectionLink, ConnectionError } from "$lib/server/slack/connections";import { identity } from "$lib/server/slack/viewer/auth";import { setMcpSyncEnabled } from "$lib/server/mcp/savedSelection";import type { Actions, PageServerLoad } from "./$types";export const load: PageServerLoad = async ({ locals, url, setHeaders, cookies }) => {22 unmodified linesuserTeamId: 1,}).toArray();const mcpSync = Boolean(await collections.mcpSelections.findOne({ _id: locals.user._id }));const settings = slackConfig();if (!settings && (ticket || connections.length)) error(503, "Slack is unavailable.");const client = new WebClient(settings?.botToken, { retryConfig: { retries: 0 }, timeout: 10000 });34 unmodified linesconnections: namedConnections,slackNames,mcpSync,};};export const actions: Actions = {4 unmodified lines56789101122 unmodified lines34353637383940414234 unmodified lines777879808182834 unmodified linesimport { collections } from "$lib/server/database";import { connectAccount, readConnectionLink, ConnectionError } from "$lib/server/slack/connections";import { identity } from "$lib/server/slack/viewer/auth";import { setMcpSyncEnabled, slackMcpSyncAvailable } from "$lib/server/mcp/savedSelection";import type { Actions, PageServerLoad } from "./$types";export const load: PageServerLoad = async ({ locals, url, setHeaders, cookies }) => {22 unmodified linesuserTeamId: 1,}).toArray();const mcpSyncAvailable = slackMcpSyncAvailable();const mcpSync =mcpSyncAvailable && Boolean(await collections.mcpSelections.findOne({ _id: locals.user._id }));const settings = slackConfig();if (!settings && (ticket || connections.length)) error(503, "Slack is unavailable.");const client = new WebClient(settings?.botToken, { retryConfig: { retries: 0 }, timeout: 10000 });34 unmodified linesconnections: namedConnections,slackNames,mcpSync,mcpSyncAvailable,};};export const actions: Actions = {
44 unmodified lines454647484950515253542 unmodified lines575859606162636465666768697071727374757644 unmodified lines</p><form method="POST"><input type="hidden" name="ticket" value={data.ticket} /><label class="mb-4 flex items-start gap-2"><input type="checkbox" name="useMcpServers" class="mt-1" checked={data.mcpSync} /><span>Also use my enabled HuggingChat MCP servers in Slack. {mcpSyncNote}</span></label><button class="rounded bg-black px-4 py-2 text-white" type="submit">Connect Hugging Face</button>2 unmodified lines<p>Your account is connected. Return to Slack and mention ML Intern again to start your request.</p><form method="POST" class="space-y-2"><input type="hidden" name="action" value="mcp" /><input type="hidden" name="enabled" value={data.mcpSync ? "false" : "true"} /><p>{data.mcpSync? "ML Intern uses your enabled HuggingChat MCP servers in your personal Slack sessions. Information returned by those tools may be posted in the Slack thread.": `ML Intern uses only its built-in tools in Slack. You can let it use your enabled HuggingChat MCP servers too. ${mcpSyncNote}`}</p><button class="rounded border px-4 py-2" type="submit">{data.mcpSync? "Stop using my MCP servers in Slack": "Use my MCP servers in Slack"}</button></form>{#each data.connections as connection}<p>Slack user {connection.displayName} ({connection.slackUserId}) in workspace {connection.workspaceName}44 unmodified lines4546474849505152535455562 unmodified lines59606162636465666768697071727374757677787980818283848544 unmodified lines</p><form method="POST"><input type="hidden" name="ticket" value={data.ticket} />{#if data.mcpSyncAvailable}<label class="mb-4 flex items-start gap-2"><input type="checkbox" name="useMcpServers" class="mt-1" checked={data.mcpSync} /><span>Also use my enabled HuggingChat MCP servers in Slack. {mcpSyncNote}</span></label>{/if}<button class="rounded bg-black px-4 py-2 text-white" type="submit">Connect Hugging Face</button>2 unmodified lines<p>Your account is connected. Return to Slack and mention ML Intern again to start your request.</p>{#if !data.mcpSyncAvailable}<p>ML Intern uses only its built-in tools in Slack. Using your HuggingChat MCP servers in Slackis not enabled on this server.</p>{:else}<form method="POST" class="space-y-2"><input type="hidden" name="action" value="mcp" /><input type="hidden" name="enabled" value={data.mcpSync ? "false" : "true"} /><p>{data.mcpSync? "ML Intern uses your enabled HuggingChat MCP servers in your personal Slack sessions. Information returned by those tools may be posted in the Slack thread.": `ML Intern uses only its built-in tools in Slack. You can let it use your enabled HuggingChat MCP servers too. ${mcpSyncNote}`}</p><button class="rounded border px-4 py-2" type="submit">{data.mcpSync? "Stop using my MCP servers in Slack": "Use my MCP servers in Slack"}</button></form>{/if}{#each data.connections as connection}<p>Slack user {connection.displayName} ({connection.slackUserId}) in workspace {connection.workspaceName}
src/routes/slack/connect/+page.server.ts+5-2
src/routes/slack/connect/+page.svelte+25-16