refactor(api)!: remove the standalone API server (#6614)
This commit is contained in:
1 parent
5c72ced2fe
commit
220d5e6970
99 files changed
+240
-4133
No files matched your search
@@ -17,7 +17,6 @@ import {
|
||||
fetchAutomations,
|
||||
fetchAutomationChats,
|
||||
fetchAutomationRunResult,
|
||||
fetchApiService,
|
||||
fetchCliApps,
|
||||
fetchInstalledCliApps,
|
||||
fetchMcpOAuthStatus,
|
||||
@@ -27,6 +26,7 @@ import {
|
||||
fetchProviderModels,
|
||||
fetchPromptIndex,
|
||||
fetchSessionAutomations,
|
||||
fetchSettings,
|
||||
fetchSettingsUsage,
|
||||
fetchSidebarState,
|
||||
fetchSkillDetail,
|
||||
@@ -50,9 +50,7 @@ import {
|
||||
runMcpPresetAction,
|
||||
saveCustomMcpServer,
|
||||
searchMarketplaceSkills,
|
||||
startApiService,
|
||||
startMcpOAuth,
|
||||
stopApiService,
|
||||
cancelChannelConnect,
|
||||
pollChannelConnect,
|
||||
startChannelConnect,
|
||||
@@ -781,7 +779,7 @@ describe("webui API helpers", () => {
|
||||
}),
|
||||
);
|
||||
|
||||
await expect(fetchApiService("tok")).rejects.toMatchObject({
|
||||
await expect(fetchSettings("tok")).rejects.toMatchObject({
|
||||
status: 200,
|
||||
message: "Gateway returned WebUI HTML instead of JSON. Restart nanobot gateway and try again.",
|
||||
});
|
||||
@@ -1101,41 +1099,6 @@ describe("webui API helpers", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("manages the API service capability", async () => {
|
||||
await fetchApiService("tok");
|
||||
expect(fetch).toHaveBeenCalledWith(
|
||||
"/api/settings/api-service",
|
||||
expect.objectContaining({ headers: { Authorization: "Bearer tok" } }),
|
||||
);
|
||||
|
||||
await startApiService(
|
||||
mutationTransport,
|
||||
{ host: "127.0.0.1", port: 8900, timeout: 120 },
|
||||
);
|
||||
expect(requestMutation).toHaveBeenLastCalledWith(
|
||||
"settings.api_service.start",
|
||||
{ host: "127.0.0.1", port: 8900, timeout: 120 },
|
||||
150_000,
|
||||
);
|
||||
|
||||
await startApiService(
|
||||
mutationTransport,
|
||||
{ host: "0.0.0.0", port: 8900, timeout: 120, apiKey: "secret-token" },
|
||||
);
|
||||
expect(requestMutation).toHaveBeenLastCalledWith(
|
||||
"settings.api_service.start",
|
||||
{ host: "0.0.0.0", port: 8900, timeout: 120, api_key: "secret-token" },
|
||||
150_000,
|
||||
);
|
||||
|
||||
await stopApiService(mutationTransport);
|
||||
expect(requestMutation).toHaveBeenLastCalledWith(
|
||||
"settings.api_service.stop",
|
||||
{},
|
||||
20_000,
|
||||
);
|
||||
});
|
||||
|
||||
it("reads MCP presets and serializes actions", async () => {
|
||||
vi.mocked(fetch).mockResolvedValueOnce({
|
||||
ok: true,
|
||||
|
||||
@@ -496,10 +496,8 @@ function renderMcpActions() {
|
||||
state,
|
||||
featureCatalog: [],
|
||||
client,
|
||||
token: "tok",
|
||||
getToken: () => "tok",
|
||||
t: i18n.t,
|
||||
applyPayload: vi.fn(),
|
||||
maybeRestartHostEngine: vi.fn(),
|
||||
setPendingRestartSections: vi.fn(),
|
||||
refreshAutomations: vi.fn(),
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import { fireEvent, render, screen, waitFor, within } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { RuntimeSettings } from "@/components/settings/system/RuntimeSettings";
|
||||
import { RUNTIME_CONFIG_FIELDS, RUNTIME_CONFIG_GROUPS } from "@/components/settings/system/runtime-config-fields";
|
||||
import runtimeConfigKeys from "../../../tests/webui/fixtures/runtime-config-keys.json";
|
||||
import { TimezonePicker } from "@/components/settings/shared/TimezonePicker";
|
||||
import { DEFAULT_AGENT_SETTINGS_DRAFT } from "@/components/settings/models/ModelsSettings";
|
||||
import type { SettingsPayload } from "@/lib/types";
|
||||
import { installSettingsViewTestHooks, jsonResponse, renderSettingsView, requestMutationMock, settingsPayload } from "@/tests/settings-test-utils";
|
||||
|
||||
@@ -136,24 +134,6 @@ describe("Runtime configuration settings", () => {
|
||||
expect(within(screen.getByRole("dialog")).getByRole("textbox")).toHaveValue("TERM\nCOLORTERM");
|
||||
});
|
||||
|
||||
it("starts the API with newly saved advanced settings", async () => {
|
||||
const payload = runtimeSettings();
|
||||
payload.api = { ...payload.api, host: "192.168.1.7", port: 8900, timeout: 77.5, api_key_hint: "set" };
|
||||
const action = vi.fn();
|
||||
render(<RuntimeSettings form={DEFAULT_AGENT_SETTINGS_DRAFT} settings={payload}
|
||||
requiresRestartPending={false} apiService={{
|
||||
installed: true, running: false, managed: false, host: "127.0.0.1", port: 8900,
|
||||
timeout: 120, endpoint: "http://127.0.0.1:8900/v1", command: "nanobot serve",
|
||||
api_key_hint: "set",
|
||||
}} apiServiceLoading={false} apiServiceAction={null} apiServiceError={null}
|
||||
capabilitiesLoading={false} capabilityAction={null} capabilityError={null}
|
||||
onApiServiceAction={action} onInstallCapability={() => {}} />);
|
||||
fireEvent.click(screen.getByRole("button", { name: "Start API server" }));
|
||||
expect(action).toHaveBeenCalledWith("start", {
|
||||
host: "192.168.1.7", port: 8900, timeout: 77.5, apiKey: undefined,
|
||||
});
|
||||
});
|
||||
|
||||
it("saves only edited fields using the existing settings footer", async () => {
|
||||
const payload = runtimeSettings();
|
||||
requestMutationMock.mockResolvedValue({ ...payload, requires_restart: true,
|
||||
|
||||
@@ -487,51 +487,6 @@ describe("Settings system domains", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("starts the managed API server from System", async () => {
|
||||
const base = settingsPayload();
|
||||
const stopped = {
|
||||
installed: false,
|
||||
running: false,
|
||||
managed: false,
|
||||
host: "127.0.0.1",
|
||||
port: 8900,
|
||||
timeout: 120,
|
||||
api_key_hint: null,
|
||||
endpoint: "http://127.0.0.1:8900/v1",
|
||||
command: "nanobot serve",
|
||||
};
|
||||
const fetchMock = vi.fn(async (input: RequestInfo | URL) => {
|
||||
const url = String(input);
|
||||
if (url === "/api/settings") return jsonResponse(base);
|
||||
if (url === "/api/settings/api-service") return jsonResponse(stopped);
|
||||
if (url === "/api/settings/nanobot-features") {
|
||||
return jsonResponse({ features: [], enabled_count: 0 });
|
||||
}
|
||||
return jsonResponse({});
|
||||
});
|
||||
vi.stubGlobal("fetch", fetchMock);
|
||||
requestMutationMock.mockResolvedValueOnce({
|
||||
...stopped,
|
||||
installed: true,
|
||||
running: true,
|
||||
managed: true,
|
||||
});
|
||||
|
||||
renderSettingsView({ initialSection: "runtime", initialSettings: base, showSidebar: true });
|
||||
|
||||
const startButton = await screen.findByRole("button", { name: "Start API server" });
|
||||
await waitFor(() => expect(startButton).toBeEnabled());
|
||||
fireEvent.click(startButton);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(requestMutationMock).toHaveBeenCalledWith(
|
||||
"settings.api_service.start",
|
||||
{ host: "127.0.0.1", port: 8900, timeout: 120 },
|
||||
150_000,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it("shows a visible uninstall button for installed CLI apps and calls uninstall", async () => {
|
||||
const fetchMock = vi.fn(async (input: RequestInfo | URL) => {
|
||||
const url = String(input);
|
||||
|
||||
@@ -64,12 +64,6 @@ export function settingsPayload(): SettingsPayload {
|
||||
search: { max_results: 5, timeout: 30 },
|
||||
fetch: { use_jina_reader: true },
|
||||
},
|
||||
api: {
|
||||
host: "127.0.0.1",
|
||||
port: 8900,
|
||||
timeout: 120,
|
||||
api_key_hint: null,
|
||||
},
|
||||
observability: {
|
||||
provider: "langfuse",
|
||||
configured: false,
|
||||
|
||||
Reference in new issue
Block a user