mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-07-07 11:02:12 +02:00
feat(scripts): free trusted HTTPS via sslip.io for public-IP remote i… (#460)
* feat(scripts): free trusted HTTPS via sslip.io for public-IP remote installs Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * chore: refactor setup scripts * chore: generate sdk * chore: fix messaging for setup_remote script * fix: fix ffmpeg download url * feat: centralise and simplify the url configuration * fix: force script run as sudo * fix: fix documentation --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
3309face2c
commit
78427817a6
30 changed files with 838 additions and 392 deletions
|
|
@ -6,22 +6,41 @@ import { useState } from "react";
|
|||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { useAppConfig } from "@/context/AppConfigContext";
|
||||
import { resolveBrowserBackendUrl } from "@/lib/apiClient";
|
||||
|
||||
const MCP_PATH = "/api/v1/mcp/";
|
||||
|
||||
export function MCPSection() {
|
||||
const backendUrl =
|
||||
process.env.NEXT_PUBLIC_BACKEND_URL ||
|
||||
(typeof window !== "undefined" ? window.location.origin : "");
|
||||
const endpoint = `${backendUrl}/api/v1/mcp/`;
|
||||
const { config } = useAppConfig();
|
||||
// Backend URL: the address the deployment runs on (a private IP when the backend
|
||||
// sits on one). Tunnel URL, when present: the publicly reachable Cloudflare tunnel
|
||||
// URL externally-hosted assistants should use to reach an otherwise-private host.
|
||||
const backendUrl = resolveBrowserBackendUrl(config?.backendApiEndpoint);
|
||||
const tunnelUrl = config?.tunnelUrl ?? null;
|
||||
|
||||
const [endpointCopied, setEndpointCopied] = useState(false);
|
||||
const endpoints = [
|
||||
...(tunnelUrl
|
||||
? [
|
||||
{
|
||||
key: "tunnel",
|
||||
label: "Public URL (Cloudflare tunnel)",
|
||||
url: `${tunnelUrl}${MCP_PATH}`,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{ key: "backend", label: "Backend URL", url: `${backendUrl}${MCP_PATH}` },
|
||||
];
|
||||
|
||||
const handleCopy = async (
|
||||
value: string,
|
||||
setter: (v: boolean) => void,
|
||||
) => {
|
||||
const [copiedKey, setCopiedKey] = useState<string | null>(null);
|
||||
|
||||
const handleCopy = async (value: string, key: string) => {
|
||||
await navigator.clipboard.writeText(value);
|
||||
setter(true);
|
||||
setTimeout(() => setter(false), 2000);
|
||||
setCopiedKey(key);
|
||||
setTimeout(
|
||||
() => setCopiedKey((current) => (current === key ? null : current)),
|
||||
2000,
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
|
|
@ -39,23 +58,40 @@ export function MCPSection() {
|
|||
Get your API key
|
||||
</Link>
|
||||
</p>
|
||||
<div className="flex items-center gap-2">
|
||||
<code className="text-xs break-all bg-muted px-2 py-1 rounded flex-1">
|
||||
{endpoint}
|
||||
</code>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="shrink-0"
|
||||
onClick={() => handleCopy(endpoint, setEndpointCopied)}
|
||||
>
|
||||
{endpointCopied ? (
|
||||
<Check className="h-4 w-4" />
|
||||
) : (
|
||||
<Copy className="h-4 w-4" />
|
||||
)}
|
||||
</Button>
|
||||
<div className="grid gap-3">
|
||||
{endpoints.map(({ key, label, url }) => (
|
||||
<div key={key} className="grid gap-1">
|
||||
{endpoints.length > 1 && (
|
||||
<span className="text-xs font-medium text-muted-foreground">
|
||||
{label}
|
||||
</span>
|
||||
)}
|
||||
<div className="flex items-center gap-2">
|
||||
<code className="text-xs break-all bg-muted px-2 py-1 rounded flex-1">
|
||||
{url}
|
||||
</code>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="shrink-0"
|
||||
onClick={() => handleCopy(url, key)}
|
||||
>
|
||||
{copiedKey === key ? (
|
||||
<Check className="h-4 w-4" />
|
||||
) : (
|
||||
<Copy className="h-4 w-4" />
|
||||
)}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
{tunnelUrl && (
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Use the public URL from externally-hosted assistants; the backend URL
|
||||
works from the deployment's own network.
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<p className="text-xs text-muted-foreground">
|
||||
|
|
|
|||
|
|
@ -13,7 +13,9 @@ import { FlowNodeData } from "@/components/flow/types";
|
|||
import { Button } from "@/components/ui/button";
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
import { NODE_DOCUMENTATION_URLS } from "@/constants/documentation";
|
||||
import { useAppConfig } from "@/context/AppConfigContext";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { resolveWebhookBaseUrl } from "@/lib/webhookUrl";
|
||||
|
||||
import { NodeContent } from "./common/NodeContent";
|
||||
import { NodeEditDialog } from "./common/NodeEditDialog";
|
||||
|
|
@ -90,14 +92,12 @@ interface TriggerEndpoints {
|
|||
|
||||
function buildTriggerEndpoints(
|
||||
triggerPath: string | undefined,
|
||||
baseUrl: string,
|
||||
): TriggerEndpoints {
|
||||
if (!triggerPath) return { production: "", test: "" };
|
||||
const backendUrl =
|
||||
process.env.NEXT_PUBLIC_BACKEND_URL ||
|
||||
(typeof window !== "undefined" ? window.location.origin : "");
|
||||
return {
|
||||
production: `${backendUrl}/api/v1/public/agent/${triggerPath}`,
|
||||
test: `${backendUrl}/api/v1/public/agent/test/${triggerPath}`,
|
||||
production: `${baseUrl}/api/v1/public/agent/${triggerPath}`,
|
||||
test: `${baseUrl}/api/v1/public/agent/test/${triggerPath}`,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -182,8 +182,12 @@ function CanvasPreview({
|
|||
onStaleTools: (uuids: string[]) => void;
|
||||
onStaleDocuments: (uuids: string[]) => void;
|
||||
}) {
|
||||
const { config: appConfig } = useAppConfig();
|
||||
if (spec.name === "trigger") {
|
||||
const endpoint = buildTriggerEndpoints(data.trigger_path).production;
|
||||
const endpoint = buildTriggerEndpoints(
|
||||
data.trigger_path,
|
||||
resolveWebhookBaseUrl(appConfig?.tunnelUrl),
|
||||
).production;
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
<p className="text-xs text-muted-foreground">API Endpoint:</p>
|
||||
|
|
@ -474,7 +478,9 @@ export const GenericNode = memo(({ data, selected, id, type }: GenericNodeProps)
|
|||
});
|
||||
const { saveWorkflow, tools, documents, recordings } = useWorkflow();
|
||||
const { bySpecName } = useNodeSpecs();
|
||||
const { config: appConfig } = useAppConfig();
|
||||
const spec = bySpecName.get(type);
|
||||
const webhookBaseUrl = resolveWebhookBaseUrl(appConfig?.tunnelUrl);
|
||||
|
||||
// ── Form state ─────────────────────────────────────────────────────
|
||||
// mcp_tool_filters is not a spec property, so seedValues won't carry it;
|
||||
|
|
@ -500,12 +506,12 @@ export const GenericNode = memo(({ data, selected, id, type }: GenericNodeProps)
|
|||
// ── Trigger auto-UUID + canvas copy state ──────────────────────────
|
||||
const [triggerCopied, setTriggerCopied] = useState(false);
|
||||
const handleCopyTrigger = useCallback(async () => {
|
||||
const endpoint = buildTriggerEndpoints(data.trigger_path).production;
|
||||
const endpoint = buildTriggerEndpoints(data.trigger_path, webhookBaseUrl).production;
|
||||
if (!endpoint) return;
|
||||
await navigator.clipboard.writeText(endpoint);
|
||||
setTriggerCopied(true);
|
||||
setTimeout(() => setTriggerCopied(false), 2000);
|
||||
}, [data.trigger_path]);
|
||||
}, [data.trigger_path, webhookBaseUrl]);
|
||||
|
||||
// For trigger nodes without a path yet, generate one and persist.
|
||||
useEffect(() => {
|
||||
|
|
@ -684,7 +690,7 @@ export const GenericNode = memo(({ data, selected, id, type }: GenericNodeProps)
|
|||
/>
|
||||
{type === "trigger" && (
|
||||
<TriggerWebhookUrls
|
||||
endpoints={buildTriggerEndpoints(data.trigger_path)}
|
||||
endpoints={buildTriggerEndpoints(data.trigger_path, webhookBaseUrl)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue