- Refines the overall structure of the CLI tools and MITM server functionalities.
- Add buildQwenBaseUrl function to construct URLs for Qwen resources. - Update buildProviderUrl to support Qwen model requests. - Enhance token refresh logic to include provider-specific data for Qwen. - Refactor CLI Tools page to exclude MITM tools and streamline model retrieval. - Introduce new components for MITM server management. - Update API routes to handle Qwen-specific resource URLs and improve error handling.
This commit is contained in:
1 parent
40a53fbd33
commit
573b0f0241
29 files changed
+1490
-438
No files matched your search
@@ -0,0 +1,93 @@
|
||||
"use client";
|
||||
|
||||
import { useState, useEffect } from "react";
|
||||
import { CLI_TOOLS } from "@/shared/constants/cliTools";
|
||||
import { getModelsByProviderId, PROVIDER_ID_TO_ALIAS } from "@/shared/constants/models";
|
||||
import { MitmServerCard, MitmToolCard } from "@/app/(dashboard)/dashboard/cli-tools/components";
|
||||
|
||||
const MITM_TOOL_IDS = ["antigravity", "copilot"];
|
||||
|
||||
export default function MitmPageClient() {
|
||||
const [connections, setConnections] = useState([]);
|
||||
const [apiKeys, setApiKeys] = useState([]);
|
||||
const [cloudEnabled, setCloudEnabled] = useState(false);
|
||||
const [expandedTool, setExpandedTool] = useState(null);
|
||||
const [mitmStatus, setMitmStatus] = useState({ running: false, certExists: false, dnsStatus: {}, certCoversTools: {}, hasCachedPassword: false });
|
||||
|
||||
useEffect(() => {
|
||||
fetchConnections();
|
||||
fetchApiKeys();
|
||||
fetchCloudSettings();
|
||||
}, []);
|
||||
|
||||
const fetchConnections = async () => {
|
||||
try {
|
||||
const res = await fetch("/api/providers");
|
||||
if (res.ok) {
|
||||
const data = await res.json();
|
||||
setConnections(data.connections || []);
|
||||
}
|
||||
} catch { /* ignore */ }
|
||||
};
|
||||
|
||||
const fetchApiKeys = async () => {
|
||||
try {
|
||||
const res = await fetch("/api/keys");
|
||||
if (res.ok) {
|
||||
const data = await res.json();
|
||||
setApiKeys(data.keys || []);
|
||||
}
|
||||
} catch { /* ignore */ }
|
||||
};
|
||||
|
||||
const fetchCloudSettings = async () => {
|
||||
try {
|
||||
const res = await fetch("/api/settings");
|
||||
if (res.ok) {
|
||||
const data = await res.json();
|
||||
setCloudEnabled(data.cloudEnabled || false);
|
||||
}
|
||||
} catch { /* ignore */ }
|
||||
};
|
||||
|
||||
const getActiveProviders = () => connections.filter(c => c.isActive !== false);
|
||||
|
||||
const hasActiveProviders = () => {
|
||||
const active = getActiveProviders();
|
||||
return active.some(conn => getModelsByProviderId(conn.provider).length > 0);
|
||||
};
|
||||
|
||||
const mitmTools = Object.entries(CLI_TOOLS).filter(([id]) => MITM_TOOL_IDS.includes(id));
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-6">
|
||||
{/* MITM Server Card */}
|
||||
<MitmServerCard
|
||||
apiKeys={apiKeys}
|
||||
cloudEnabled={cloudEnabled}
|
||||
onStatusChange={setMitmStatus}
|
||||
/>
|
||||
|
||||
{/* Tool Cards */}
|
||||
<div className="flex flex-col gap-2">
|
||||
{mitmTools.map(([toolId, tool]) => (
|
||||
<MitmToolCard
|
||||
key={toolId}
|
||||
tool={tool}
|
||||
isExpanded={expandedTool === toolId}
|
||||
onToggle={() => setExpandedTool(expandedTool === toolId ? null : toolId)}
|
||||
serverRunning={mitmStatus.running}
|
||||
dnsActive={mitmStatus.dnsStatus?.[toolId] || false}
|
||||
certCovered={mitmStatus.certCoversTools?.[toolId] || false}
|
||||
hasCachedPassword={mitmStatus.hasCachedPassword || false}
|
||||
apiKeys={apiKeys}
|
||||
activeProviders={getActiveProviders()}
|
||||
hasActiveProviders={hasActiveProviders()}
|
||||
cloudEnabled={cloudEnabled}
|
||||
onDnsChange={(data) => setMitmStatus(prev => ({ ...prev, dnsStatus: data.dnsStatus ?? prev.dnsStatus }))}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import MitmPageClient from "./MitmPageClient";
|
||||
|
||||
export default function MitmPage() {
|
||||
return <MitmPageClient />;
|
||||
}
|
||||
Reference in new issue
Block a user