Skip to content
Closed
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
2 changes: 2 additions & 0 deletions helm/kagent/templates/ui-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ spec:
env:
- name: NEXT_PUBLIC_BACKEND_URL
value: {{ .Values.ui.publicBackendUrl | quote }}
- name: NEXT_PUBLIC_ALLOW_HTTP
value: {{ .Values.ui.allowHttp | default false | quote }}
- name: BACKEND_INTERNAL_URL
value: {{ .Values.ui.backendInternalUrl | default (include "kagent.controllerInternalHttpApiBase" .) | quote }}
{{- if .Values.ui.auth }}
Expand Down
5 changes: 5 additions & 0 deletions helm/kagent/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,11 @@ controller:

ui:
replicas: 1
# -- Allow the UI to run over plain HTTP (non-HTTPS).
# When false (default), the UI uses crypto.randomUUID() which requires a Secure Context (HTTPS).
# Set to true for deployments served over plain HTTP (e.g. internal clusters without TLS).
# This switches to a uuid package fallback that uses crypto.getRandomValues() instead.
allowHttp: false
image:
registry: ""
repository: kagent-dev/kagent/ui
Expand Down
5 changes: 3 additions & 2 deletions ui/src/app/agents/new/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { formAgentTypeFromApi, formUsesByoSections, formUsesDeclarativeSections
import { ModelConfig, AgentType, ContextConfig, type DeclarativeRuntime } from "@/types";
import { SystemPromptSection } from "@/components/create/SystemPromptSection";
import { newPromptSourceRow, type PromptSourceRow } from "@/lib/promptSourceRow";
import { generateId } from "@/lib/utils";
import { ModelSelectionSection } from "@/components/create/ModelSelectionSection";
import { ToolsSection } from "@/components/create/ToolsSection";
import { MemorySection } from "@/components/create/MemorySection";
Expand Down Expand Up @@ -162,7 +163,7 @@ function AgentPageContent({ isEditMode, agentName, agentNamespace }: AgentPageCo
return {
...prev,
errors: { ...prev.errors, promptSources: undefined },
promptSourceRows: [...nonEmpty, { id: crypto.randomUUID(), name: t, alias: "" }],
promptSourceRows: [...nonEmpty, { id: generateId(), name: t, alias: "" }],
};
});
}, []);
Expand Down Expand Up @@ -207,7 +208,7 @@ function AgentPageContent({ isEditMode, agentName, agentNamespace }: AgentPageCo
const pt = decl?.promptTemplate;
const srcRows: PromptSourceRow[] =
pt?.dataSources?.map((ds) => ({
id: crypto.randomUUID(),
id: generateId(),
name: ds.name || "",
alias: ds.alias || "",
})) ?? [newPromptSourceRow()];
Expand Down
9 changes: 5 additions & 4 deletions ui/src/components/prompts/FragmentEntriesEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Input } from "@/components/ui/input";
import { Textarea } from "@/components/ui/textarea";
import { Label } from "@/components/ui/label";
import { Plus, Trash2 } from "lucide-react";
import { generateId } from "@/lib/utils";

export interface FragmentRow {
id: string;
Expand All @@ -16,10 +17,10 @@ export interface FragmentRow {
export function rowsFromData(data: Record<string, string>): FragmentRow[] {
const keys = Object.keys(data);
if (keys.length === 0) {
return [{ id: crypto.randomUUID(), key: "", value: "" }];
return [{ id: generateId(), key: "", value: "" }];
}
return keys.map((key) => ({
id: crypto.randomUUID(),
id: generateId(),
key,
value: data[key] ?? "",
}));
Expand Down Expand Up @@ -51,11 +52,11 @@ export function FragmentEntriesEditor({

const removeRow = (id: string) => {
const next = rows.filter((r) => r.id !== id);
onRowsChange(next.length > 0 ? next : [{ id: crypto.randomUUID(), key: "", value: "" }]);
onRowsChange(next.length > 0 ? next : [{ id: generateId(), key: "", value: "" }]);
};

const addRow = () => {
onRowsChange([...rows, { id: crypto.randomUUID(), key: "", value: "" }]);
onRowsChange([...rows, { id: generateId(), key: "", value: "" }]);
};

return (
Expand Down
3 changes: 2 additions & 1 deletion ui/src/lib/openClawSandboxForm.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { ValueSource } from "@/types";
import { k8sRefUtils } from "@/lib/k8sUtils";
import { generateId } from "@/lib/utils";

/** Sandbox CR backend; UI always uses openclaw for now. */
const SANDBOX_BACKEND_OPENCLAW = "openclaw" as const;
Expand All @@ -26,7 +27,7 @@ export interface OpenClawChannelRow {

export function newOpenClawChannelRow(): OpenClawChannelRow {
return {
id: crypto.randomUUID(),
id: generateId(),
name: "",
channelType: "telegram",
botTokenSource: "inline",
Expand Down
4 changes: 3 additions & 1 deletion ui/src/lib/promptSourceRow.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { generateId } from "@/lib/utils";

export interface PromptSourceRow {
id: string;
name: string;
alias: string;
}

export function newPromptSourceRow(): PromptSourceRow {
return { id: crypto.randomUUID(), name: "", alias: "" };
return { id: generateId(), name: "", alias: "" };
}
8 changes: 8 additions & 0 deletions ui/src/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
import { v4 as uuidv4 } from "uuid";
import { Message as A2AMessage, Task as A2ATask, TaskStatusUpdateEvent as A2ATaskStatusUpdateEvent, TaskArtifactUpdateEvent as A2ATaskArtifactUpdateEvent } from "@a2a-js/sdk";

export function cn(...inputs: ClassValue[]) {
Expand Down Expand Up @@ -36,6 +37,13 @@ export function getBackendUrl() {
return "http://localhost:8083/api";
}

export function generateId(): string {
if (typeof crypto.randomUUID === "function") {
return crypto.randomUUID();
}
return uuidv4();
}

export function getRelativeTimeString(date: string | number | Date): string {
const now = new Date();
const past = new Date(date);
Expand Down
Loading