Skip to content

🙌 OpenHands: AI-Driven Development

feat: drive the automation UI from the interface manifest (#16222)

Hiep Lee9e52f3976e3
diff --git a/__tests__/components/automations/detail/edit-automation-modal.test.tsx b/__tests__/components/automations/detail/edit-automation-modal.test.tsx
index e1a51ea50a..7fbb176112 100644
--- a/__tests__/components/automations/detail/edit-automation-modal.test.tsx
+++ b/__tests__/components/automations/detail/edit-automation-modal.test.tsx
@@ -36,6 +36,33 @@ vi.mock("#/utils/custom-toast-handlers", () => ({
displayErrorToast: vi.fn(),
}));
+// The pinned package may publish an interface manifest whose literal copy
+// replaces the host's translations. Pin the candidate to "not published" so
+// these tests exercise the host defaults whatever the package ships.
+vi.mock("#/manifests/manifest-sources", async (importOriginal) => ({
+ ...(await importOriginal<typeof import("#/manifests/manifest-sources")>()),
+ AUTOMATION_INTERFACE_CANDIDATE: undefined,
+}));
+
+// The interface seam resolves its manifest once at module load, so the
+// manifest-driven test overrides individual attribute specs here instead of
+// installing a whole manifest. Empty overrides leave the host defaults —
+// today's form — in force for every other test.
+const specOverrides = vi.hoisted(() => ({
+ current: {} as Record<string, object>,
+}));
+vi.mock("#/manifests/automation-interface", async (importOriginal) => {
+ const actual =
+ await importOriginal<typeof import("#/manifests/automation-interface")>();
+ return {
+ ...actual,
+ getAttributeSpec: (name: Parameters<typeof actual.getAttributeSpec>[0]) => ({
+ ...actual.getAttributeSpec(name),
+ ...specOverrides.current[name],
+ }),
+ };
+});
+
const localBackend: Backend = {
id: "local-1",
name: "Local",
@@ -117,6 +144,7 @@ function renderModal(automation: Automation) {
beforeEach(() => {
vi.clearAllMocks();
+ specOverrides.current = {};
__resetActiveStoreForTests();
setRegisteredBackends([localBackend]);
setActiveSelection({ backendId: localBackend.id });
@@ -423,6 +451,22 @@ describe("EditAutomationModal", () => {
).toBeInTheDocument();
});
+ it("renders only the attributes the interface manifest declares, with its copy", async () => {
+ // Arrange — an admitted manifest that omits `prompt` and relabels `name`.
+ specOverrides.current = {
+ prompt: { present: false },
+ name: { label: "Widget name" },
+ };
+ renderModal(dailyAutomation);
+
+ // Assert — the prompt control is gone and the manifest's label shows in
+ // place of the host translation.
+ expect(
+ screen.queryByTestId("edit-automation-prompt"),
+ ).not.toBeInTheDocument();
+ expect(screen.getByText("Widget name")).toBeInTheDocument();
+ });
+
it("omits the timeout from the payload when it is left unchanged", async () => {
// Arrange
vi.mocked(AutomationService.updateAutomation).mockResolvedValue(
diff --git a/__tests__/components/features/command-menu/command-menu.test.tsx b/__tests__/components/features/command-menu/command-menu.test.tsx
index 07bdd35c6a..46f0af7390 100644
--- a/__tests__/components/features/command-menu/command-menu.test.tsx
+++ b/__tests__/components/features/command-menu/command-menu.test.tsx
@@ -17,6 +17,14 @@ const NEW_CHAT_TITLE_KEY = "COMMAND_MENU$NEW_CHAT_TITLE";
const SECRETS_TITLE_KEY = "COMMAND_MENU$SECRETS_SETTINGS_TITLE";
const TOGGLE_SIDEBAR_TITLE_KEY = "COMMAND_MENU$TOGGLE_SIDEBAR_TITLE";
+// The pinned package may publish an interface manifest whose literal copy
+// replaces the host's translations. Pin the candidate to "not published" so
+// these tests exercise the host defaults whatever the package ships.
+vi.mock("#/manifests/manifest-sources", async (importOriginal) => ({
+ ...(await importOriginal<typeof import("#/manifests/manifest-sources")>()),
+ AUTOMATION_INTERFACE_CANDIDATE: undefined,
+}));
+
const navigateMock = vi.fn();
function renderCommandMenu(navigate = navigateMock) {
diff --git a/__tests__/components/manifest/manifest-setup-dialog.test.tsx b/__tests__/components/manifest/manifest-setup-dialog.test.tsx
index 1ddb423454..5c8617a1aa 100644
--- a/__tests__/components/manifest/manifest-setup-dialog.test.tsx
+++ b/__tests__/components/manifest/manifest-setup-dialog.test.tsx
@@ -6,7 +6,10 @@ import AutomationService from "#/api/automation-service/automation-service.api";
import { SetupDialog } from "#/components/features/manifest/manifest-setup-dialog";
import type { SetupPrerequisitesResult } from "#/hooks/query/use-manifest-prerequisites";
import type { SetupEntry } from "#/manifests/types";
-import { createSetupEntry } from "../../manifests/manifest-test-data";
+import {
+ createSetup,
+ createSetupEntry,
+} from "../../manifests/manifest-test-data";
/**
* The dialog is the part of setup that is not pure: it owns the step order, the
@@ -18,6 +21,7 @@ const mocks = vi.hoisted(() => ({
navigate: vi.fn(),
runAction: vi.fn(),
prerequisites: vi.fn(),
+ capabilities: vi.fn(),
tracking: {
trackAutomationSetupOpened: vi.fn(),
trackAutomationSetupValidated: vi.fn(),
@@ -41,12 +45,7 @@ vi.mock("#/contexts/active-backend-context", () => ({
}));
vi.mock("#/hooks/query/use-manifest-capabilities", () => ({
- useSetupCapabilities: () => ({
- capabilities: null,
- supported: "unknown",
- unmet: [],
- isLoading: false,
- }),
+ useSetupCapabilities: () => mocks.capabilities(),
}));
vi.mock("#/hooks/query/use-manifest-prerequisites", () => ({
@@ -74,7 +73,7 @@ const NOTHING_TO_CONNECT: SetupPrerequisitesResult = {
const ENTRY: SetupEntry = createSetupEntry();
-function renderDialog() {
+function renderDialog(entry: SetupEntry = ENTRY) {
const user = userEvent.setup();
render(
<QueryClientProvider
@@ -82,7 +81,7 @@ function renderDialog() {
new QueryClient({ defaultOptions: { queries: { retry: false } } })
}
>
- <SetupDialog entry={ENTRY} onClose={vi.fn()} />
+ <SetupDialog entry={entry} onClose={vi.fn()} />
</QueryClientProvider>,
);
return { user };
@@ -100,12 +99,26 @@ async function fillForm(user: ReturnType<typeof userEvent.setup>) {
beforeEach(() => {
vi.clearAllMocks();
mocks.prerequisites.mockReturnValue(NOTHING_TO_CONNECT);
+ mocks.capabilities.mockReturnValue({
+ capabilities: null,
+ supported: "unknown",
+ unmet: [],
+ isLoading: false,
+ });
vi.mocked(AutomationService.validateDraft).mockResolvedValue({
valid: true,
errors: [],
});
});
+/** A deployment that answered discovery and came up short. */
+const UNSUPPORTED = {
+ capabilities: null,
+ supported: false as const,
+ unmet: ["webhookDelivery"],
+ isLoading: false,
+};
+
describe("SetupDialog", () => {
it("asks about an unconnected integration before it asks anything else", async () => {
// Arrange — an advisory integration, which is shown but does not block.
@@ -174,6 +187,43 @@ describe("SetupDialog", () => {
});
});
+ it("offers the conversation fallback when the deployment cannot run a direct entry", async () => {
+ // Arrange — capabilities answered and came up short, and the entry ships
+ // a fallback-conversation seed.
+ mocks.capabilities.mockReturnValue(UNSUPPORTED);
+ mocks.runAction.mockResolvedValue({
+ response: { conversation_id: "conv-1" },
+ });
+ const entry = createSetupEntry({
+ setup: createSetup({
+ message: "Set this up in a conversation instead.",
+ }),
+ });
+ const { user } = renderDialog(entry);
+
+ // Act
+ await user.click(screen.getByTestId("setup-fallback-conversation"));
+
+ // Assert — the action runs with no payload, the assisted outcome, and
+ // setup lands in the conversation that will finish it.
+ await waitFor(() =>
+ expect(mocks.navigate).toHaveBeenCalledWith("/conversations/conv-1", {
+ replace: true,
+ }),
+ );
+ expect(mocks.runAction).toHaveBeenCalledWith(entry, expect.anything(), null);
+ });
+
+ it("keeps the unsupported screen close-only when there is nothing to fall back to", () => {
+ // Arrange — no skill command resolves for this entry and it declares no
+ // fallback message, so a conversation would open empty-handed.
+ mocks.capabilities.mockReturnValue(UNSUPPORTED);
+ renderDialog();
+
+ // Assert
+ expect(screen.queryByTestId("setup-fallback-conversation")).toBeNull();
+ });
+
it("returns a rejected create to the field the service blamed", async () => {
// Arrange — a validation failure addressed by payload path, which only the
// derived error map can turn back into a field.
diff --git a/__tests__/manifests/automation-interface.test.ts b/__tests__/manifests/automation-interface.test.ts
new file mode 100644
index 0000000000..33e4a6c79a
--- /dev/null
+++ b/__tests__/manifests/automation-interface.test.ts
@@ -0,0 +1,123 @@
+import { afterEach, describe, expect, it, vi } from "vitest";
+import { createInterfaceManifest } from "./manifest-test-data";
+
+/**
+ * The seam resolves its source once at module load, so each case installs its
+ * candidate with a module mock and imports the seam fresh.
+ */
+async function loadSeam(candidate: unknown) {
+ vi.resetModules();
+ vi.doMock("#/manifests/manifest-sources", () => ({
+ AUTOMATION_INTERFACE_CANDIDATE: candidate,
+ }));
+ return import("#/manifests/automation-interface");
+}
+
+afterEach(() => {
+ vi.doUnmock("#/manifests/manifest-sources");
+ vi.restoreAllMocks();
+});
+
+describe("the automation interface seam", () => {
+ it("serves the host defaults when the package publishes no manifest", async () => {
+ // Arrange — the pinned package predates the interface export.
+ const seam = await loadSeam(undefined);
+
+ // Act & Assert — copy defers to host i18n; every other datum is the
+ // host's own literal, byte-identical to pre-seam behavior.
+ expect({
+ listTitle: seam.getInterfaceCopy().listTitle,
+ sidebarLabel: seam.getInterfaceCopy().sidebarLabel,
+ listPath: seam.automationListPath(),
+ setupPath: seam.automationSetupPath("github-pr-reviewer"),
+ detailPath: seam.automationDetailPath("a/b"),
+ createEndpoint: seam.getAutomationEndpoint("createPrompt"),
+ dispatchEndpoint: seam.getAutomationIdEndpoint("dispatch", "id-1"),
+ timeoutMax: seam.getAttributeSpec("timeout").max,
+ filenameSuffix: seam.getImportExportSpec().filenameSuffix,
+ featured: [...seam.getFeaturedAutomationIds()],
+ responders: [...seam.getResponderIntegrationIds()],
+ }).toEqual({
+ listTitle: null,
+ sidebarLabel: null,
+ listPath: "/automations",
+ setupPath: "/automations/new/github-pr-reviewer",
+ detailPath: "/automations/a%2Fb",
+ createEndpoint: "/v1/preset/prompt",
+ dispatchEndpoint: "/v1/id-1/dispatch",
+ timeoutMax: 1800,
+ filenameSuffix: ".automation.json",
+ featured: [
+ "github-pr-reviewer",
+ "github-repo-monitor",
+ "slack-channel-monitor",
+ ],
+ responders: ["github", "slack"],
+ });
+ });
+
+ it("serves an admitted manifest's data instead of the defaults", async () => {
+ // Arrange
+ const seam = await loadSeam(createInterfaceManifest());
+
+ // Act & Assert — copy, attribute specs, the import/export envelope, and
+ // the id lists all come from the manifest.
+ expect({
+ listTitle: seam.getInterfaceCopy().listTitle,
+ sidebarLabel: seam.getInterfaceCopy().sidebarLabel,
+ editTitle: seam.getInterfaceCopy().editTitle,
+ nameLabel: seam.getAttributeSpec("name").label,
+ timeoutMax: seam.getAttributeSpec("timeout").max,
+ importExport: seam.getImportExportSpec(),
+ docsUrl: seam.getAutomationsDocsUrl(),
+ featured: [...seam.getFeaturedAutomationIds()],
+ responders: [...seam.getResponderIntegrationIds()],
+ }).toEqual({
+ listTitle: "Widget automations",
+ sidebarLabel: "Automate everything",
+ editTitle: "Edit the widget automation",
+ nameLabel: "Widget name",
+ timeoutMax: 900,
+ importExport: {
+ fileKind: "widget",
+ fileVersion: 1,
+ filenameSuffix: ".widget.json",
+ importDefaults: {
+ repoProvider: "gitlab",
+ placeholderEventSource: "widget-import",
+ },
+ },
+ docsUrl: "https://docs.openhands.dev/widgets",
+ featured: ["github-pr-reviewer"],
+ responders: ["github"],
+ });
+ });
+
+ it("hides an attribute the admitted manifest does not declare", async () => {
+ // Arrange — the factory manifest declares only `name` and `timeout`.
+ const seam = await loadSeam(createInterfaceManifest());
+
+ // Act
+ const spec = seam.getAttributeSpec("prompt");
+
+ // Assert
+ expect(spec.present).toBe(false);
+ });
+
+ it("falls back to the defaults, loudly, when a manifest fails admission", async () => {
+ // Arrange
+ const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
+ const seam = await loadSeam(
+ createInterfaceManifest({ version: "2.0" as "1.0" }),
+ );
+
+ // Act
+ const copy = seam.getInterfaceCopy();
+
+ // Assert — nothing from the rejected manifest leaks through, and the
+ // rejection is reported rather than silent.
+ expect({ listTitle: copy.listTitle, warned: warn.mock.calls.length }).toEqual(
+ { listTitle: null, warned: 1 },
+ );
+ });
+});
diff --git a/__tests__/manifests/interface-validation.test.ts b/__tests__/manifests/interface-validation.test.ts
new file mode 100644
index 0000000000..67469ca9d7
--- /dev/null
+++ b/__tests__/manifests/interface-validation.test.ts
@@ -0,0 +1,187 @@
+import { describe, expect, it } from "vitest";
+import { validateInterfaceManifest } from "#/manifests/interface-validation";
+import type { InterfaceValidationContext } from "#/manifests/interface-validation";
+import {
+ createInterfaceManifest,
+ createInterfaceManifestWith,
+} from "./manifest-test-data";
+
+const CONTEXT: InterfaceValidationContext = {
+ catalogIds: new Set([
+ "github-pr-reviewer",
+ "github-repo-monitor",
+ "slack-channel-monitor",
+ ]),
+ mountedRoutes: {
+ list: "/automations",
+ setup: "/automations/new/:automationId",
+ detail: "/automations/:automationId",
+ },
+};
+
+describe("validateInterfaceManifest", () => {
+ it("admits a well-formed manifest", () => {
+ // Arrange
+ const manifest = createInterfaceManifest();
+
+ // Act
+ const result = validateInterfaceManifest(manifest, CONTEXT);
+
+ // Assert
+ expect(result).toEqual({ valid: true, errors: [] });
+ });
+
+ // Each case is a separate invariant the host enforces on data authored in
+ // another repository. A manifest that trips any of them reverts the whole
+ // interface to the host's defaults.
+ it.each([
+ [
+ "a version this host cannot interpret",
+ { version: "2.0" },
+ ],
+ [
+ // The host serves what it has registrations for; a manifest cannot remap
+ // the router table, only own link construction against it.
+ "a route the host has no registration for",
+ {
+ routes: {
+ list: "/automations",
+ setup: "/workflows/new/:automationId",
+ detail: "/automations/:automationId",
+ },
+ },
+ ],
+ [
+ "markup inside user-visible copy",
+ {
+ navigation: {
+ sidebar: { label: "<img src=x onerror=alert(1)>" },
+ commandMenu: {
+ title: "Automations",
+ description: "Review them.",
+ keywords: "automate",
+ },
+ },
+ },
+ ],
+ [
+ "a documentation link outside the product documentation",
+ { docsUrl: "https://evil.example/phishing" },
+ ],
+ [
+ "an endpoint that is not a rooted service-relative path",
+ {
+ endpoints: {
+ ...createInterfaceManifest().endpoints,
+ list: "https://evil.example/v1",
+ },
+ },
+ ],
+ [
+ "an id endpoint without its {id} substitution",
+ {
+ endpoints: {
+ ...createInterfaceManifest().endpoints,
+ detail: "/v1/latest",
+ },
+ },
+ ],
+ [
+ "a substitution on an endpoint the host calls without an id",
+ {
+ endpoints: {
+ ...createInterfaceManifest().endpoints,
+ list: "/v1/{id}",
+ },
+ },
+ ],
+ [
+ "a featured automation the catalog does not publish",
+ { featuredAutomationIds: ["github-pr-reviewer", "unpublished-entry"] },
+ ],
+ [
+ "an attribute the host cannot set",
+ {
+ attributes: {
+ tarballPath: { type: "text", label: "Tarball", required: false },
+ },
+ },
+ ],
+ [
+ "constraints on a non-number attribute",
+ {
+ attributes: {
+ name: {
+ type: "text",
+ label: "Name",
+ required: true,
+ constraints: { max: 50 },
+ },
+ },
+ },
+ ],
+ // The next three pin an admitted manifest to the semantics the edit
+ // dialog implements, so it can never promise a control, a requiredness,
+ // or a minimum the form would silently ignore.
+ [
+ "a control the host does not render for that attribute",
+ {
+ attributes: {
+ name: { type: "textarea", label: "Name", required: true },
+ },
+ },
+ ],
+ [
+ "a requiredness the host does not enforce",
+ {
+ attributes: {
+ prompt: { type: "textarea", label: "Prompt", required: true },
+ },
+ },
+ ],
+ [
+ "a minimum the host does not enforce",
+ {
+ attributes: {
+ timeout: {
+ type: "number",
+ label: "Timeout",
+ required: false,
+ constraints: { min: 60, max: 900 },
+ },
+ },
+ },
+ ],
+ [
+ "a responder integration id that is not a lowercase slug",
+ { responderIntegrationIds: ["GitHub!"] },
+ ],
+ [
+ "a key this host does not read",
+ { dashboards: [] },
+ ],
+ ])("refuses %s", (_case, overrides) => {
+ // Arrange
+ const candidate = createInterfaceManifestWith(overrides);
+
+ // Act
+ const result = validateInterfaceManifest(candidate, CONTEXT);
+
+ // Assert
+ expect(result.valid).toBe(false);
+ });
+
+ it("reports every problem at once so an author sees the whole picture", () => {
+ // Arrange
+ const candidate = createInterfaceManifestWith({
+ docsUrl: "https://evil.example/",
+ featuredAutomationIds: ["unpublished-entry"],
+ });
+
+ // Act
+ const { errors } = validateInterfaceManifest(candidate, CONTEXT);
+
+ // Assert
+ expect(errors).toHaveLength(2);
+ });
+});
diff --git a/__tests__/manifests/manifest-test-data.ts b/__tests__/manifests/manifest-test-data.ts
index 552cd38b88..1b7b2e2340 100644
--- a/__tests__/manifests/manifest-test-data.ts
+++ b/__tests__/manifests/manifest-test-data.ts
@@ -1,4 +1,8 @@
-import type { SetupBlock, SetupEntry } from "#/manifests/types";
+import type {
+ InterfaceManifest,
+ SetupBlock,
+ SetupEntry,
+} from "#/manifests/types";
/**
* A minimal catalog entry the host will admit.
@@ -65,3 +69,77 @@ export function createSetupEntryWith(
): unknown {
return { ...createSetupEntry(), ...overrides };
}
+
+/**
+ * A minimal interface manifest the host will admit. Featured ids are real
+ * catalog entries, because admission checks them against the published
+ * catalog. Tests override only the part they exercise.
+ */
+export function createInterfaceManifest(
+ overrides: Partial<InterfaceManifest> = {},
+): InterfaceManifest {
+ return {
+ version: "1.0",
+ routes: {
+ list: "/automations",
+ setup: "/automations/new/:automationId",
+ detail: "/automations/:automationId",
+ },
+ navigation: {
+ sidebar: { label: "Automate everything" },
+ commandMenu: {
+ title: "Automation center",
+ description: "Review the widget automations.",
+ keywords: "widgets cron",
+ },
+ },
+ pages: {
+ list: { title: "Widget automations", subtitle: "All of the widgets." },
+ detail: { backLabel: "Back to the widgets" },
+ edit: { title: "Edit the widget automation" },
+ },
+ docsUrl: "https://docs.openhands.dev/widgets",
+ attributes: {
+ name: { type: "text", label: "Widget name", required: true },
+ timeout: {
+ type: "number",
+ label: "Widget timeout",
+ required: false,
+ constraints: { min: 1, max: 900 },
+ },
+ },
+ // Every importExport datum differs from the host default, so a test that
+ // reads it back can tell manifest data from fallback data.
+ importExport: {
+ fileKind: "widget",
+ fileVersion: 1,
+ filenameSuffix: ".widget.json",
+ importDefaults: {
+ repoProvider: "gitlab",
+ placeholderEventSource: "widget-import",
+ },
+ },
+ endpoints: {
+ list: "/v1",
+ detail: "/v1/{id}",
+ dispatch: "/v1/{id}/dispatch",
+ runs: "/v1/{id}/runs",
+ tarball: "/v1/{id}/tarball",
+ health: "/health",
+ capabilities: "/v1/capabilities",
+ validate: "/v1/validate",
+ createPrompt: "/v1/preset/prompt",
+ createPlugin: "/v1/preset/plugin",
+ },
+ featuredAutomationIds: ["github-pr-reviewer"],
+ responderIntegrationIds: ["github"],
+ ...overrides,
+ };
+}
+
+/** Build an interface candidate that is invalid in one specific way. */
+export function createInterfaceManifestWith(
+ overrides: Record<string, unknown>,
+): unknown {
+ return { ...createInterfaceManifest(), ...overrides };
+}
diff --git a/__tests__/manifests/manifest-validation.test.ts b/__tests__/manifests/manifest-validation.test.ts
index 89da1649bc..e5ea1d9026 100644
--- a/__tests__/manifests/manifest-validation.test.ts
+++ b/__tests__/manifests/manifest-validation.test.ts
@@ -18,6 +18,22 @@ describe("validateSetupEntry", () => {
expect(result).toEqual({ valid: true, errors: [] });
});
+ it("admits a direct entry carrying a fallback-conversation message", () => {
+ // Arrange — the seed for the conversation offered when the deployment
+ // cannot run the direct path.
+ const entry = createSetupEntry({
+ setup: createSetup({
+ message: "Set this up in a conversation instead.",
+ }),
+ });
+
+ // Act
+ const result = validateSetupEntry(entry);
+
+ // Assert
+ expect(result).toEqual({ valid: true, errors: [] });
+ });
+
// Each case is a separate invariant the host enforces on data authored in
// another repository. A manifest that trips any of them must not render.
it.each([
@@ -33,6 +49,12 @@ describe("validateSetupEntry", () => {
"a placeholder namespace the host does not expose",
{ setup: createSetup({ prompt: "Use {{secrets.githubToken}}." }) },
],
+ [
+ // A direct entry may carry a fallback-conversation seed, but it is still
+ // copy, held to the same injection rules as an assisted message.
+ "markup inside a direct entry's fallback message",
+ { setup: createSetup({ message: "<img src=x onerror=alert(1)>" }) },
+ ],
[
// The host reads one trigger kind to build the request, so a second one
// would be silently dropped rather than refused.
diff --git a/__tests__/utils/automation-timeout.test.ts b/__tests__/utils/automation-timeout.test.ts
index 563e458269..bfea14fce3 100644
--- a/__tests__/utils/automation-timeout.test.ts
+++ b/__tests__/utils/automation-timeout.test.ts
@@ -48,4 +48,17 @@ describe("validateAutomationTimeout", () => {
errorKey: I18nKey.AUTOMATIONS$ERROR_TIMEOUT_MAX_EXCEEDED,
});
});
+
+ it("validates against a ceiling the interface manifest lowered", () => {
+ // Arrange / Act — a manifest max of 900 moves the boundary: 900 stays
+ // in range while 901, fine under the 1800 default, is now rejected.
+ const atCeiling = validateAutomationTimeout("900", 900);
+ const overCeiling = validateAutomationTimeout("901", 900);
+
+ // Assert
+ expect(atCeiling).toEqual({ value: 900 });
+ expect(overCeiling).toEqual({
+ errorKey: I18nKey.AUTOMATIONS$ERROR_TIMEOUT_MAX_EXCEEDED,
+ });
+ });
});
diff --git a/src/api/automation-service/automation-service.api.ts b/src/api/automation-service/automation-service.api.ts
index 10fc5073a4..101377d30f 100644
--- a/src/api/automation-service/automation-service.api.ts
+++ b/src/api/automation-service/automation-service.api.ts
@@ -15,6 +15,11 @@ import type {
AutomationRunsResponse,
} from "#/types/automation";
import { AUTOMATION_CREATE_ENDPOINT } from "#/manifests/automation-setup";
+import {
+ getAutomationEndpoint,
+ getAutomationIdEndpoint,
+ getImportExportSpec,
+} from "#/manifests/automation-interface";
import type {
DeploymentCapabilities,
SetupRequestBody,
@@ -152,19 +157,24 @@ function buildCreateAutomationRequest(spec: AutomationSpec) {
throw new Error("An automation prompt is required for import.");
}
+ const { importDefaults } = getImportExportSpec();
const repos = spec.repository
? [
{
url: spec.repository,
...(spec.branch && { ref: spec.branch }),
...(!spec.repository.includes("://") &&
- !spec.repository.startsWith("git@") && { provider: "github" }),
+ !spec.repository.startsWith("git@") && {
+ provider: importDefaults.repoProvider,
+ }),
},
]
: undefined;
return {
- path: `${AUTOMATION_BASE_PATH}/v1/preset/${spec.plugins?.length ? "plugin" : "prompt"}`,
+ path: `${AUTOMATION_BASE_PATH}${getAutomationEndpoint(
+ spec.plugins?.length ? "createPlugin" : "createPrompt",
+ )}`,
body: {
name: spec.name,
prompt: spec.prompt,
@@ -173,7 +183,7 @@ function buildCreateAutomationRequest(spec: AutomationSpec) {
// together in the follow-up PATCH.
trigger: {
type: "event",
- source: "agent-canvas-import",
+ source: importDefaults.placeholderEventSource,
on: generatePendingImportEvent(),
},
...(spec.model && { model: spec.model }),
@@ -261,13 +271,13 @@ class AutomationService {
return callCloudProxy<AutomationsResponse>({
backend: active,
method: "GET",
- path: `${AUTOMATION_BASE_PATH}/v1?${buildPaginationQuery(limit, offset)}`,
+ path: `${AUTOMATION_BASE_PATH}${getAutomationEndpoint("list")}?${buildPaginationQuery(limit, offset)}`,
headers: await buildAutomationRequestHeaders(),
});
}
const { data } = await localAutomationAxios.get<AutomationsResponse>(
- `${AUTOMATION_BASE_PATH}/v1`,
+ `${AUTOMATION_BASE_PATH}${getAutomationEndpoint("list")}`,
{ params: { limit, offset } },
);
return data;
@@ -282,7 +292,7 @@ class AutomationService {
static async getAutomation(id: string): Promise<Automation> {
const active = getActiveBackend().backend;
- const path = `${AUTOMATION_BASE_PATH}/v1/${encodeURIComponent(id)}`;
+ const path = `${AUTOMATION_BASE_PATH}${getAutomationIdEndpoint("detail", id)}`;
if (active.kind === "cloud") {
return callCloudProxy<Automation>({
@@ -319,7 +329,7 @@ class AutomationService {
created = data;
}
- const updatePath = `${AUTOMATION_BASE_PATH}/v1/${encodeURIComponent(created.id)}`;
+ const updatePath = `${AUTOMATION_BASE_PATH}${getAutomationIdEndpoint("detail", created.id)}`;
const updateBody: Partial<Automation> = {
trigger: buildImportedTrigger(spec),
enabled: false,
@@ -372,7 +382,7 @@ class AutomationService {
body: Partial<Automation>,
): Promise<Automation> {
const active = getActiveBackend().backend;
- const path = `${AUTOMATION_BASE_PATH}/v1/${encodeURIComponent(id)}`;
+ const path = `${AUTOMATION_BASE_PATH}${getAutomationIdEndpoint("detail", id)}`;
if (active.kind === "cloud") {
return callCloudProxy<Automation>({
@@ -390,7 +400,7 @@ class AutomationService {
static async deleteAutomation(id: string): Promise<void> {
const active = getActiveBackend().backend;
- const path = `${AUTOMATION_BASE_PATH}/v1/${encodeURIComponent(id)}`;
+ const path = `${AUTOMATION_BASE_PATH}${getAutomationIdEndpoint("detail", id)}`;
if (active.kind === "cloud") {
await callCloudProxy<unknown>({
@@ -407,7 +417,7 @@ class AutomationService {
static async dispatchAutomation(id: string): Promise<AutomationRun> {
const active = getActiveBackend().backend;
- const path = `${AUTOMATION_BASE_PATH}/v1/${encodeURIComponent(id)}/dispatch`;
+ const path = `${AUTOMATION_BASE_PATH}${getAutomationIdEndpoint("dispatch", id)}`;
if (active.kind === "cloud") {
return callCloudProxy<AutomationRun>({
@@ -428,7 +438,7 @@ class AutomationService {
): Promise<AutomationRunsResponse> {
const { limit = 50, offset = 0 } = params;
const active = getActiveBackend().backend;
- const basePath = `${AUTOMATION_BASE_PATH}/v1/${encodeURIComponent(id)}/runs`;
+ const basePath = `${AUTOMATION_BASE_PATH}${getAutomationIdEndpoint("runs", id)}`;
if (active.kind === "cloud") {
return callCloudProxy<AutomationRunsResponse>({
@@ -463,7 +473,7 @@ class AutomationService {
static async downloadTarball(id: string, name: string): Promise<void> {
const active = getActiveBackend().backend;
- const path = `${AUTOMATION_BASE_PATH}/v1/${encodeURIComponent(id)}/tarball`;
+ const path = `${AUTOMATION_BASE_PATH}${getAutomationIdEndpoint("tarball", id)}`;
let blob: Blob;
if (active.kind === "cloud") {
@@ -497,7 +507,7 @@ class AutomationService {
*/
static async getCapabilities(): Promise<DeploymentCapabilities> {
const active = getActiveBackend().backend;
- const path = `${AUTOMATION_BASE_PATH}/v1/capabilities`;
+ const path = `${AUTOMATION_BASE_PATH}${getAutomationEndpoint("capabilities")}`;
if (active.kind === "cloud") {
return callCloudProxy<DeploymentCapabilities>({
@@ -521,7 +531,7 @@ class AutomationService {
body: SetupRequestBody,
): Promise<ValidateDraftResponse> {
const active = getActiveBackend().backend;
- const path = `${AUTOMATION_BASE_PATH}/v1/validate`;
+ const path = `${AUTOMATION_BASE_PATH}${getAutomationEndpoint("validate")}`;
if (active.kind === "cloud") {
return callCloudProxy<ValidateDraftResponse>({
@@ -571,7 +581,7 @@ class AutomationService {
static async checkHealth(): Promise<AutomationHealthResponse> {
const active = getActiveBackend().backend;
- const path = `${AUTOMATION_BASE_PATH}/health`;
+ const path = `${AUTOMATION_BASE_PATH}${getAutomationEndpoint("health")}`;
try {
if (active.kind === "cloud") {
diff --git a/src/components/features/automations/create-instructions.tsx b/src/components/features/automations/create-instructions.tsx
index 3433dc0cbd..8c46e4e0e9 100644
--- a/src/components/features/automations/create-instructions.tsx
+++ b/src/components/features/automations/create-instructions.tsx
@@ -8,9 +8,9 @@ import { BrandButton } from "#/components/features/settings/brand-button";
import { useLaunchSkillInChat } from "#/hooks/use-launch-skill-in-chat";
import { useActiveBackend } from "#/contexts/active-backend-context";
import { useTracking } from "#/hooks/use-tracking";
+import { getAutomationsDocsUrl } from "#/manifests/automation-interface";
-const DOCS_URL =
- "https://docs.openhands.dev/openhands/usage/automations/overview";
+const DOCS_URL = getAutomationsDocsUrl();
function InlineExampleWrap({ children }: { children?: ReactNode }) {
return <span className="whitespace-nowrap">{children}</span>;
diff --git a/src/components/features/automations/detail/back-link.tsx b/src/components/features/automations/detail/back-link.tsx
index 43d24c2ed7..35fb1ae431 100644
--- a/src/components/features/automations/detail/back-link.tsx
+++ b/src/components/features/automations/detail/back-link.tsx
@@ -1,13 +1,18 @@
import { useTranslation } from "react-i18next";
import { I18nKey } from "#/i18n/declaration";
import { BackNavButton } from "#/components/shared/buttons/back-nav-button";
+import {
+ automationListPath,
+ getInterfaceCopy,
+} from "#/manifests/automation-interface";
export function BackLink() {
const { t } = useTranslation("openhands");
return (
- <BackNavButton to="/automations">
- {t(I18nKey.AUTOMATIONS$DETAIL$BACK_TO_LIST)}
+ <BackNavButton to={automationListPath()}>
+ {getInterfaceCopy().detailBackLabel ??
+ t(I18nKey.AUTOMATIONS$DETAIL$BACK_TO_LIST)}
</BackNavButton>
);
}
diff --git a/src/components/features/automations/detail/edit-automation-modal.tsx b/src/components/features/automations/detail/edit-automation-modal.tsx
index 34940f1b51..9fe489f0c8 100644
--- a/src/components/features/automations/detail/edit-automation-modal.tsx
+++ b/src/components/features/automations/detail/edit-automation-modal.tsx
@@ -26,6 +26,10 @@ import {
AUTOMATION_TIMEOUT_DEFAULT_SECONDS,
AUTOMATION_TIMEOUT_MAX_SECONDS,
} from "#/utils/automation-timeout";
+import {
+ getAttributeSpec,
+ getInterfaceCopy,
+} from "#/manifests/automation-interface";
import { cn } from "#/utils/utils";
import {
formControlMultilineFieldClassName,
@@ -121,6 +125,15 @@ export function EditAutomationModal({
}: EditAutomationModalProps) {
const { t } = useTranslation("openhands");
const updateMutation = useUpdateAutomation();
+ // Which attributes the dialog offers, and their copy, come from the
+ // interface manifest; absent one, the host defaults reproduce today's form.
+ const editTitle =
+ getInterfaceCopy().editTitle ?? t(I18nKey.AUTOMATIONS$EDIT_TITLE);
+ const nameSpec = getAttributeSpec("name");
+ const promptSpec = getAttributeSpec("prompt");
+ const modelSpec = getAttributeSpec("model");
+ const timeoutSpec = getAttributeSpec("timeout");
+ const scheduleSpec = getAttributeSpec("schedule");
const { data: profilesData, isLoading: isLoadingProfiles } = useLlmProfiles();
const profiles = profilesData?.profiles ?? [];
const modelItems = [
@@ -186,7 +199,10 @@ export function EditAutomationModal({
}
setNameError(null);
- const timeoutResult = validateAutomationTimeout(form.timeout);
+ const timeoutResult = validateAutomationTimeout(
+ form.timeout,
+ timeoutSpec.max ?? undefined,
+ );
if ("errorKey" in timeoutResult) {
setTimeoutError(t(timeoutResult.errorKey));
return;
@@ -274,52 +290,56 @@ export function EditAutomationModal({
<XMarkIcon className="size-5" />
</button>
- <h2 className={modalTitleLgMediumClassName}>
- {t(I18nKey.AUTOMATIONS$EDIT_TITLE)}
- </h2>
+ <h2 className={modalTitleLgMediumClassName}>{editTitle}</h2>
<form
onSubmit={handleSubmit}
noValidate
className="mt-4 flex flex-col gap-4"
- aria-label={t(I18nKey.AUTOMATIONS$EDIT_TITLE)}
+ aria-label={editTitle}
>
- <SettingsInput
- testId="edit-automation-name"
- name="name"
- type="text"
- label={t(I18nKey.AUTOMATIONS$NAME)}
- value={form.name}
- onChange={(value) => setForm((f) => ({ ...f, name: value }))}
- error={nameError ?? undefined}
- showRequiredTag
- />
-
- <label className="flex flex-col gap-2.5 w-full min-w-0">
- <span className="text-sm">{t(I18nKey.AUTOMATIONS$PROMPT)}</span>
- <textarea
- data-testid="edit-automation-prompt"
- name="prompt"
- value={form.prompt}
- onChange={(e) =>
- setForm((f) => ({ ...f, prompt: e.target.value }))
- }
- rows={4}
- className={cn(
- formControlMultilineFieldClassName,
- "placeholder:italic",
- )}
+ {nameSpec.present && (
+ <SettingsInput
+ testId="edit-automation-name"
+ name="name"
+ type="text"
+ label={nameSpec.label ?? t(I18nKey.AUTOMATIONS$NAME)}
+ value={form.name}
+ onChange={(value) => setForm((f) => ({ ...f, name: value }))}
+ error={nameError ?? undefined}
+ showRequiredTag={nameSpec.required}
/>
- <span className="text-xs text-muted">
- {t(I18nKey.AUTOMATIONS$EDIT_PROMPT_HINT)}
- </span>
- </label>
+ )}
+
+ {promptSpec.present && (
+ <label className="flex flex-col gap-2.5 w-full min-w-0">
+ <span className="text-sm">
+ {promptSpec.label ?? t(I18nKey.AUTOMATIONS$PROMPT)}
+ </span>
+ <textarea
+ data-testid="edit-automation-prompt"
+ name="prompt"
+ value={form.prompt}
+ onChange={(e) =>
+ setForm((f) => ({ ...f, prompt: e.target.value }))
+ }
+ rows={4}
+ className={cn(
+ formControlMultilineFieldClassName,
+ "placeholder:italic",
+ )}
+ />
+ <span className="text-xs text-muted">
+ {promptSpec.help ?? t(I18nKey.AUTOMATIONS$EDIT_PROMPT_HINT)}
+ </span>
+ </label>
+ )}
- {(isLoadingProfiles || profiles.length > 0) && (
+ {modelSpec.present && (isLoadingProfiles || profiles.length > 0) && (
<SettingsDropdownInput
testId="edit-automation-model"
name="model"
- label={t(I18nKey.AUTOMATIONS$DETAIL$MODEL)}
+ label={modelSpec.label ?? t(I18nKey.AUTOMATIONS$DETAIL$MODEL)}
items={modelItems}
selectedKey={form.model || ACTIVE_PROFILE_KEY}
isLoading={isLoadingProfiles}
@@ -333,28 +353,30 @@ export function EditAutomationModal({
/>
)}
- <div className="flex flex-col gap-2.5 w-full min-w-0">
- <SettingsInput
- testId="edit-automation-timeout"
- name="timeout"
- type="number"
- label={t(I18nKey.AUTOMATIONS$TIMEOUT)}
- value={form.timeout}
- onChange={(value) => setForm((f) => ({ ...f, timeout: value }))}
- error={timeoutError ?? undefined}
- showOptionalTag
- min={1}
- max={AUTOMATION_TIMEOUT_MAX_SECONDS}
- step={1}
- placeholder={String(AUTOMATION_TIMEOUT_DEFAULT_SECONDS)}
- />
- <span
- data-testid="edit-automation-timeout-hint"
- className="text-xs text-muted"
- >
- {t(I18nKey.AUTOMATIONS$TIMEOUT_HINT)}
- </span>
- </div>
+ {timeoutSpec.present && (
+ <div className="flex flex-col gap-2.5 w-full min-w-0">
+ <SettingsInput
+ testId="edit-automation-timeout"
+ name="timeout"
+ type="number"
+ label={timeoutSpec.label ?? t(I18nKey.AUTOMATIONS$TIMEOUT)}
+ value={form.timeout}
+ onChange={(value) => setForm((f) => ({ ...f, timeout: value }))}
+ error={timeoutError ?? undefined}
+ showOptionalTag
+ min={timeoutSpec.min ?? 1}
+ max={timeoutSpec.max ?? AUTOMATION_TIMEOUT_MAX_SECONDS}
+ step={1}
+ placeholder={String(AUTOMATION_TIMEOUT_DEFAULT_SECONDS)}
+ />
+ <span
+ data-testid="edit-automation-timeout-hint"
+ className="text-xs text-muted"
+ >
+ {timeoutSpec.help ?? t(I18nKey.AUTOMATIONS$TIMEOUT_HINT)}
+ </span>
+ </div>
+ )}
{automation.trigger.type === "event" ? (
<div className="flex flex-col gap-3 rounded-lg bg-[var(--oh-surface-raised)] p-3">
@@ -397,12 +419,12 @@ export function EditAutomationModal({
</div>
)}
</div>
- ) : (
+ ) : scheduleSpec.present ? (
<>
<SettingsDropdownInput
testId="edit-automation-frequency"
name="frequency"
- label={t(I18nKey.AUTOMATIONS$FREQUENCY)}
+ label={scheduleSpec.label ?? t(I18nKey.AUTOMATIONS$FREQUENCY)}
items={frequencyItems}
selectedKey={form.frequency}
isDisabled={form.isCustomSchedule}
@@ -468,7 +490,7 @@ export function EditAutomationModal({
</p>
)}
</>
- )}
+ ) : null}
<div className="mt-2 flex justify-end gap-3">
<BrandButton
diff --git a/src/components/features/automations/recommended-automations-launcher.tsx b/src/components/features/automations/recommended-automations-launcher.tsx
index ccfa48da4a..b98c9c4158 100644
--- a/src/components/features/automations/recommended-automations-launcher.tsx
+++ b/src/components/features/automations/recommended-automations-launcher.tsx
@@ -23,6 +23,7 @@ import {
} from "#/utils/mcp-marketplace-utils";
import { InstallServerModal } from "#/components/features/mcp-page/install-server-modal";
import { useTracking } from "#/hooks/use-tracking";
+import { automationSetupPath } from "#/manifests/automation-interface";
import { SETUP_REGISTRY } from "#/manifests/manifest-sources";
import {
getAutomationLaunchPrompt,
@@ -98,7 +99,7 @@ export function RecommendedAutomationsLauncher({
// form, so the answers are collected before anything is created. The rest
// still hand a slash command to an agent to interpret.
if (SETUP_REGISTRY.findById(automation.id)) {
- navigate?.(`/automations/new/${automation.id}`);
+ navigate?.(automationSetupPath(automation.id));
onLaunched?.();
return;
}
diff --git a/src/components/features/automations/recommended-automations-section.tsx b/src/components/features/automations/recommended-automations-section.tsx
index b202131a2e..701f715b9e 100644
--- a/src/components/features/automations/recommended-automations-section.tsx
+++ b/src/components/features/automations/recommended-automations-section.tsx
@@ -22,6 +22,7 @@ import {
getMarketplaceEntryById,
getMcpMarketplaceCatalog,
} from "#/utils/mcp-marketplace-utils";
+import { getFeaturedAutomationIds } from "#/manifests/automation-interface";
import {
getAutomationLaunchPrompt,
getIntegrationIds,
@@ -59,19 +60,12 @@ export function getAutomationsByPopularity(
const RECOMMENDED_AUTOMATIONS = getAutomationsByPopularity(AUTOMATION_CATALOG);
-/**
- * Launch allowlist — proven automations featured above the Beta group.
- * NOT derived from popularityRank (slack-standup-digest@94 outranks
- * slack-channel-monitor@92 yet is Beta). A future flag could swap this set.
- */
-export const PROVEN_AUTOMATION_IDS = [
- "github-pr-reviewer",
- "github-repo-monitor",
- "slack-channel-monitor",
-] as const;
-
+// Proven automations are featured above the Beta group. The set is owned by
+// the interface manifest (falling back to the host default), not derived from
+// popularityRank: slack-standup-digest@94 outranks slack-channel-monitor@92
+// yet is Beta.
function isProvenAutomation(automation: RecommendedAutomation): boolean {
- return (PROVEN_AUTOMATION_IDS as readonly string[]).includes(automation.id);
+ return getFeaturedAutomationIds().includes(automation.id);
}
/**
diff --git a/src/components/features/command-menu/command-menu-items.tsx b/src/components/features/command-menu/command-menu-items.tsx
index 52dcf49969..23dec943b0 100644
--- a/src/components/features/command-menu/command-menu-items.tsx
+++ b/src/components/features/command-menu/command-menu-items.tsx
@@ -14,13 +14,17 @@ import {
Zap,
} from "lucide-react";
import { I18nKey } from "#/i18n/declaration";
+import {
+ automationListPath,
+ getInterfaceCopy,
+} from "#/manifests/automation-interface";
const ICON_SIZE = 18;
export const COMMAND_MENU_ROUTE = {
conversations: "/conversations",
customize: "/customize",
- automations: "/automations",
+ automations: automationListPath(),
mcp: "/mcp",
settings: "/settings",
agentSettings: "/settings/agents",
@@ -52,6 +56,10 @@ export interface CommandMenuItemDefinition {
titleKey: I18nKey;
descriptionKey: I18nKey;
keywordsKey: I18nKey;
+ /** Literal copy overriding the i18n key, when a manifest owns it. */
+ title?: string;
+ description?: string;
+ keywords?: string;
icon: React.ReactElement;
to?: string;
perform?: () => void;
@@ -98,6 +106,9 @@ export const createCommandMenuItems = ({
titleKey: I18nKey.COMMAND_MENU$AUTOMATIONS_TITLE,
descriptionKey: I18nKey.COMMAND_MENU$AUTOMATIONS_DESCRIPTION,
keywordsKey: I18nKey.COMMAND_MENU$AUTOMATIONS_KEYWORDS,
+ title: getInterfaceCopy().commandMenuTitle ?? undefined,
+ description: getInterfaceCopy().commandMenuDescription ?? undefined,
+ keywords: getInterfaceCopy().commandMenuKeywords ?? undefined,
icon: <Zap size={ICON_SIZE} />,
to: COMMAND_MENU_ROUTE.automations,
},
diff --git a/src/components/features/command-menu/command-menu.tsx b/src/components/features/command-menu/command-menu.tsx
index ddd8db67c1..31288c23e1 100644
--- a/src/components/features/command-menu/command-menu.tsx
+++ b/src/components/features/command-menu/command-menu.tsx
@@ -46,9 +46,9 @@ function matchesQuery({
}
const searchableText = [
- translate(item.titleKey),
- translate(item.descriptionKey),
- translate(item.keywordsKey),
+ item.title ?? translate(item.titleKey),
+ item.description ?? translate(item.descriptionKey),
+ item.keywords ?? translate(item.keywordsKey),
]
.join(" ")
.toLocaleLowerCase();
@@ -311,10 +311,10 @@ export function CommandMenu() {
</span>
<span className="min-w-0 flex-1">
<span className="block truncate text-sm font-medium text-current">
- {t(item.titleKey)}
+ {item.title ?? t(item.titleKey)}
</span>
<span className="mt-0.5 block truncate text-xs text-[var(--oh-text-dim)]">
- {t(item.descriptionKey)}
+ {item.description ?? t(item.descriptionKey)}
</span>
</span>
<span className="hidden shrink-0 rounded-md border border-[var(--oh-border)] px-2 py-1 text-[10px] font-semibold uppercase tracking-[0.14em] text-[var(--oh-text-dim)] sm:inline-flex">
diff --git a/src/components/features/manifest/manifest-setup-dialog.tsx b/src/components/features/manifest/manifest-setup-dialog.tsx
index f300c79cbb..7092e22c94 100644
--- a/src/components/features/manifest/manifest-setup-dialog.tsx
+++ b/src/components/features/manifest/manifest-setup-dialog.tsx
@@ -32,8 +32,15 @@ import {
normalizeServiceErrors,
type MappedManifestErrors,
} from "#/manifests/manifest-error-map";
+import { automationDetailPath } from "#/manifests/automation-interface";
+import { findAutomationCommand } from "#/utils/automation-catalog";
import type { GitRepository } from "#/types/git";
-import type { SetupEntry, SetupFormValues } from "#/manifests/types";
+import type {
+ SetupEntry,
+ SetupFormValues,
+ SetupMode,
+ SetupRequestBody,
+} from "#/manifests/types";
import { SetupFormField } from "./manifest-form-field";
import { SetupPrerequisitesStep } from "./manifest-prerequisites-step";
import { SetupReviewStep } from "./manifest-review-step";
@@ -59,7 +66,7 @@ function getDestination(response: Record<string, unknown>): string | null {
if (typeof response.conversation_id === "string") {
return `/conversations/${response.conversation_id}`;
}
- if (typeof response.id === "string") return `/automations/${response.id}`;
+ if (typeof response.id === "string") return automationDetailPath(response.id);
return null;
}
@@ -185,13 +192,16 @@ export function SetupDialog({ entry, onClose }: SetupDialogProps) {
setStep("review");
};
- const handleConfirm = async () => {
+ const submitAction = async (
+ actionPayload: SetupRequestBody | null,
+ setupMode: SetupMode,
+ ) => {
setIsSubmitting(true);
try {
- const { response } = await runAction(entry, values, payload);
+ const { response } = await runAction(entry, values, actionPayload);
trackAutomationSetupCreated({
automationId: entry.id,
- setupMode: entry.setup.mode,
+ setupMode,
});
const destination = getDestination(response);
if (destination) navigate(destination, { replace: true });
@@ -199,10 +209,10 @@ export function SetupDialog({ entry, onClose }: SetupDialogProps) {
} catch (error) {
trackAutomationSetupFailed({
automationId: entry.id,
- setupMode: entry.setup.mode,
+ setupMode,
});
const mapped = mapServiceErrors(
- normalizeServiceErrors(getApiErrorBody(error), payload),
+ normalizeServiceErrors(getApiErrorBody(error), actionPayload),
errorMap,
);
setServiceErrors(
@@ -219,6 +229,17 @@ export function SetupDialog({ entry, onClose }: SetupDialogProps) {
}
};
+ const handleConfirm = () => submitAction(payload, entry.setup.mode);
+
+ // A direct entry whose deployment cannot run the direct path degrades to the
+ // assisted outcome: the skill command and the entry's fallback message seed
+ // a conversation that finishes setup instead.
+ const handleFallbackConversation = () => submitAction(null, "assisted");
+ const canFallBackToConversation =
+ entry.setup.mode === "direct" &&
+ (findAutomationCommand(entry) !== null ||
+ entry.setup.message !== undefined);
+
const resolveFieldError = (name: string): string | undefined => {
const local = localErrors[name];
return local ? formatFieldError(local, t) : serviceErrors.fieldErrors[name];
@@ -344,9 +365,27 @@ export function SetupDialog({ entry, onClose }: SetupDialogProps) {
)}
{isUnsupported ? (
- <BrandButton type="button" variant="secondary" onClick={onClose}>
- {t(I18nKey.BUTTON$CLOSE)}
- </BrandButton>
+ <>
+ <BrandButton
+ type="button"
+ variant="secondary"
+ isDisabled={isSubmitting}
+ onClick={onClose}
+ >
+ {t(I18nKey.BUTTON$CLOSE)}
+ </BrandButton>
+ {canFallBackToConversation && (
+ <BrandButton
+ testId="setup-fallback-conversation"
+ type="button"
+ variant="primary"
+ isDisabled={isSubmitting}
+ onClick={handleFallbackConversation}
+ >
+ {t(I18nKey.SETUP$FALLBACK_CONVERSATION)}
+ </BrandButton>
+ )}
+ </>
) : (
<BrandButton
testId="setup-continue-button"
diff --git a/src/components/features/sidebar/sidebar-rail-body.tsx b/src/components/features/sidebar/sidebar-rail-body.tsx
index ef4993717c..95e11d91f3 100644
--- a/src/components/features/sidebar/sidebar-rail-body.tsx
+++ b/src/components/features/sidebar/sidebar-rail-body.tsx
@@ -9,6 +9,10 @@ import {
} from "lucide-react";
import { OpenHandsLogoButton } from "#/components/shared/buttons/openhands-logo-button";
import { NavigationLink } from "#/components/shared/navigation-link";
+import {
+ automationListPath,
+ getInterfaceCopy,
+} from "#/manifests/automation-interface";
import { SidebarCollapsedIconSlot } from "./sidebar-collapsed-icon-slot";
import { SidebarNavLink } from "./sidebar-nav-link";
import { I18nKey } from "#/i18n/declaration";
@@ -199,8 +203,10 @@ export function SidebarRailBody({
}
/>
<SidebarNavLink
- to="/automations"
- label={t(I18nKey.SIDEBAR$AUTOMATIONS)}
+ to={automationListPath()}
+ label={
+ getInterfaceCopy().sidebarLabel ?? t(I18nKey.SIDEBAR$AUTOMATIONS)
+ }
testId="sidebar-automations-link"
collapsed={collapsed}
icon={<AutomationsIcon width={ICON_SIZE} height={ICON_SIZE} />}
diff --git a/src/i18n/translation.json b/src/i18n/translation.json
index 664eb4fc50..3f3131d6ec 100644
--- a/src/i18n/translation.json
+++ b/src/i18n/translation.json
@@ -35886,6 +35886,23 @@
"uk": "Підтвердити та створити",
"ca": "Confirma i crea"
},
+ "SETUP$FALLBACK_CONVERSATION": {
+ "en": "Set up in a conversation",
+ "ja": "会話でセットアップ",
+ "zh-CN": "在对话中设置",
+ "zh-TW": "在對話中設定",
+ "ko-KR": "대화에서 설정하기",
+ "no": "Sett opp i en samtale",
+ "it": "Configura in una conversazione",
+ "pt": "Configurar em uma conversa",
+ "es": "Configurar en una conversación",
+ "ar": "الإعداد في محادثة",
+ "fr": "Configurer dans une conversation",
+ "tr": "Bir konuşmada kur",
+ "de": "In einer Unterhaltung einrichten",
+ "uk": "Налаштувати в розмові",
+ "ca": "Configura en una conversa"
+ },
"SETUP$EMPTY_VALUE": {
"en": "Not set",
"ja": "未設定",
diff --git a/src/manifests/automation-interface.ts b/src/manifests/automation-interface.ts
new file mode 100644
index 0000000000..3e5020330b
--- /dev/null
+++ b/src/manifests/automation-interface.ts
@@ -0,0 +1,268 @@
+/**
+ * The automation interface seam.
+ *
+ * Every automation-specific datum the host's surfaces render — routes,
+ * navigation and page copy, the settable attributes, the import/export
+ * envelope, endpoint paths, the featured and responder id lists — is served
+ * from here.
+ * The published interface manifest supplies it when the pinned
+ * `@openhands/extensions` ships one and it passes admission; otherwise the
+ * host's own defaults do, which reproduce today's behavior exactly. Copy
+ * defaults are null, meaning "render the host's own translation".
+ */
+
+import { AUTOMATION_CATALOG } from "@openhands/extensions/automations";
+import { AUTOMATION_TIMEOUT_MAX_SECONDS } from "#/utils/automation-timeout";
+import { validateInterfaceManifest } from "./interface-validation";
+import { AUTOMATION_INTERFACE_CANDIDATE } from "./manifest-sources";
+import type {
+ AutomationAttributeName,
+ InterfaceEndpointName,
+ InterfaceImportExport,
+ InterfaceManifest,
+ InterfaceRoutes,
+} from "./types";
+
+/** The routes this host has registrations for, in `src/routes.ts`. */
+const MOUNTED_ROUTES: InterfaceRoutes = {
+ list: "/automations",
+ setup: "/automations/new/:automationId",
+ detail: "/automations/:automationId",
+};
+
+const DEFAULT_ENDPOINTS: InterfaceManifest["endpoints"] = {
+ list: "/v1",
+ detail: "/v1/{id}",
+ dispatch: "/v1/{id}/dispatch",
+ runs: "/v1/{id}/runs",
+ tarball: "/v1/{id}/tarball",
+ health: "/health",
+ capabilities: "/v1/capabilities",
+ validate: "/v1/validate",
+ createPrompt: "/v1/preset/prompt",
+ createPlugin: "/v1/preset/plugin",
+};
+
+const DEFAULT_IMPORT_EXPORT: InterfaceImportExport = {
+ fileKind: "automation",
+ fileVersion: 1,
+ filenameSuffix: ".automation.json",
+ importDefaults: {
+ repoProvider: "github",
+ placeholderEventSource: "agent-canvas-import",
+ },
+};
+
+const DEFAULT_DOCS_URL =
+ "https://docs.openhands.dev/openhands/usage/automations/overview";
+
+/**
+ * Proven automations featured above the Beta group. NOT derived from
+ * popularityRank (slack-standup-digest@94 outranks slack-channel-monitor@92
+ * yet is Beta).
+ */
+const DEFAULT_FEATURED_AUTOMATION_IDS: readonly string[] = [
+ "github-pr-reviewer",
+ "github-repo-monitor",
+ "slack-channel-monitor",
+];
+
+/**
+ * Integrations whose automations are treated as event responders that poll
+ * continuously, and so get the deployment-choice dialog.
+ */
+const DEFAULT_RESPONDER_INTEGRATION_IDS: readonly string[] = [
+ "github",
+ "slack",
+];
+
+export interface AttributeSpec {
+ present: boolean;
+ /** Null means "render the host's own translation". */
+ label: string | null;
+ help: string | null;
+ required: boolean;
+ min: number | null;
+ max: number | null;
+}
+
+const ABSENT_ATTRIBUTE: AttributeSpec = {
+ present: false,
+ label: null,
+ help: null,
+ required: false,
+ min: null,
+ max: null,
+};
+
+/** Today's edit dialog, restated as specs so absence of a manifest changes nothing. */
+const DEFAULT_ATTRIBUTES: Record<AutomationAttributeName, AttributeSpec> = {
+ name: {
+ present: true,
+ label: null,
+ help: null,
+ required: true,
+ min: null,
+ max: null,
+ },
+ prompt: {
+ present: true,
+ label: null,
+ help: null,
+ required: false,
+ min: null,
+ max: null,
+ },
+ model: {
+ present: true,
+ label: null,
+ help: null,
+ required: false,
+ min: null,
+ max: null,
+ },
+ timeout: {
+ present: true,
+ label: null,
+ help: null,
+ required: false,
+ min: 1,
+ max: AUTOMATION_TIMEOUT_MAX_SECONDS,
+ },
+ schedule: {
+ present: true,
+ label: null,
+ help: null,
+ required: false,
+ min: null,
+ max: null,
+ },
+};
+
+function isRecord(value: unknown): value is Record<string, unknown> {
+ return typeof value === "object" && value !== null && !Array.isArray(value);
+}
+
+function getCatalogIds(): ReadonlySet<string> {
+ return new Set(
+ (AUTOMATION_CATALOG as readonly unknown[]).flatMap((entry) =>
+ isRecord(entry) && typeof entry.id === "string" ? [entry.id] : [],
+ ),
+ );
+}
+
+function admitInterfaceManifest(candidate: unknown): InterfaceManifest | null {
+ if (candidate === undefined) return null;
+
+ const result = validateInterfaceManifest(candidate, {
+ catalogIds: getCatalogIds(),
+ mountedRoutes: MOUNTED_ROUTES,
+ });
+ if (!result.valid) {
+ // Mirrors the setup registry: a rejected manifest is skipped loudly, and
+ // the host's defaults stand.
+ console.warn(
+ "Rejected the automation interface manifest:",
+ result.errors.join("; "),
+ );
+ return null;
+ }
+ return candidate as InterfaceManifest;
+}
+
+const ADMITTED = admitInterfaceManifest(AUTOMATION_INTERFACE_CANDIDATE);
+
+function substituteRouteParam(pattern: string, id: string): string {
+ return pattern.replace(":automationId", encodeURIComponent(id));
+}
+
+export function automationListPath(): string {
+ return (ADMITTED?.routes ?? MOUNTED_ROUTES).list;
+}
+
+export function automationSetupPath(id: string): string {
+ return substituteRouteParam((ADMITTED?.routes ?? MOUNTED_ROUTES).setup, id);
+}
+
+export function automationDetailPath(id: string): string {
+ return substituteRouteParam((ADMITTED?.routes ?? MOUNTED_ROUTES).detail, id);
+}
+
+export function getAutomationEndpoint(name: InterfaceEndpointName): string {
+ return (ADMITTED?.endpoints ?? DEFAULT_ENDPOINTS)[name];
+}
+
+/** An id-parameterized endpoint with `{id}` substituted, encoded. */
+export function getAutomationIdEndpoint(
+ name: "detail" | "dispatch" | "runs" | "tarball",
+ id: string,
+): string {
+ return getAutomationEndpoint(name).replace("{id}", encodeURIComponent(id));
+}
+
+export interface InterfaceCopy {
+ sidebarLabel: string | null;
+ commandMenuTitle: string | null;
+ commandMenuDescription: string | null;
+ commandMenuKeywords: string | null;
+ listTitle: string | null;
+ listSubtitle: string | null;
+ detailBackLabel: string | null;
+ editTitle: string | null;
+}
+
+const HOST_COPY: InterfaceCopy = {
+ sidebarLabel: null,
+ commandMenuTitle: null,
+ commandMenuDescription: null,
+ commandMenuKeywords: null,
+ listTitle: null,
+ listSubtitle: null,
+ detailBackLabel: null,
+ editTitle: null,
+};
+
+export function getInterfaceCopy(): InterfaceCopy {
+ if (!ADMITTED) return HOST_COPY;
+ return {
+ sidebarLabel: ADMITTED.navigation.sidebar.label,
+ commandMenuTitle: ADMITTED.navigation.commandMenu.title,
+ commandMenuDescription: ADMITTED.navigation.commandMenu.description,
+ commandMenuKeywords: ADMITTED.navigation.commandMenu.keywords,
+ listTitle: ADMITTED.pages.list.title,
+ listSubtitle: ADMITTED.pages.list.subtitle,
+ detailBackLabel: ADMITTED.pages.detail.backLabel,
+ editTitle: ADMITTED.pages.edit.title,
+ };
+}
+
+export function getAttributeSpec(name: AutomationAttributeName): AttributeSpec {
+ if (!ADMITTED) return DEFAULT_ATTRIBUTES[name];
+
+ const attribute = ADMITTED.attributes[name];
+ if (!attribute) return ABSENT_ATTRIBUTE;
+ return {
+ present: true,
+ label: attribute.label,
+ help: attribute.help ?? null,
+ required: attribute.required,
+ min: attribute.constraints?.min ?? null,
+ max: attribute.constraints?.max ?? null,
+ };
+}
+
+export function getImportExportSpec(): InterfaceImportExport {
+ return ADMITTED?.importExport ?? DEFAULT_IMPORT_EXPORT;
+}
+
+export function getAutomationsDocsUrl(): string {
+ return ADMITTED?.docsUrl ?? DEFAULT_DOCS_URL;
+}
+
+export function getFeaturedAutomationIds(): readonly string[] {
+ return ADMITTED?.featuredAutomationIds ?? DEFAULT_FEATURED_AUTOMATION_IDS;
+}
+
+export function getResponderIntegrationIds(): readonly string[] {
+ return ADMITTED?.responderIntegrationIds ?? DEFAULT_RESPONDER_INTEGRATION_IDS;
+}
diff --git a/src/manifests/automation-setup.ts b/src/manifests/automation-setup.ts
index 7b9a4c3791..fbba53ae64 100644
--- a/src/manifests/automation-setup.ts
+++ b/src/manifests/automation-setup.ts
@@ -14,6 +14,7 @@
*/
import { findAutomationCommand } from "#/utils/automation-catalog";
+import { getAutomationEndpoint } from "./automation-interface";
import { collectFields } from "./manifest-local-validation";
import { interpolateText } from "./manifest-template";
import type {
@@ -25,7 +26,7 @@ import type {
} from "./types";
/** The creation endpoint a derived draft would be posted to. */
-export const AUTOMATION_CREATE_ENDPOINT = "/v1/preset/prompt";
+export const AUTOMATION_CREATE_ENDPOINT = getAutomationEndpoint("createPrompt");
/**
* Trigger properties a form field may fill, per trigger kind. A field under a
diff --git a/src/manifests/interface-validation.ts b/src/manifests/interface-validation.ts
new file mode 100644
index 0000000000..4d1cb2518f
--- /dev/null
+++ b/src/manifests/interface-validation.ts
@@ -0,0 +1,416 @@
+/**
+ * Admission policy for the extension-published Automation interface manifest.
+ *
+ * Like a setup entry, the interface manifest is data authored in a different
+ * repository that instructs this host to render copy, build links, and address
+ * requests, so the host decides what it is *permitted* to state. Admission is
+ * all-or-nothing: one bad field rejects the whole manifest, and the host falls
+ * back to its own defaults rather than rendering a partially-trusted mix.
+ */
+
+import type {
+ AutomationAttributeName,
+ InterfaceAttributeType,
+ InterfaceRoutes,
+} from "./types";
+import { INTERFACE_VERSION } from "./types";
+
+/** Copy must never be able to inject markup into the host. */
+const MARKUP_PATTERN = /<[A-Za-z/!]/;
+const SLUG_PATTERN = /^[a-z0-9]+(-[a-z0-9]+)*$/;
+/** The one URL the manifest may state, pinned to the product documentation. */
+const DOCS_URL_PREFIX = "https://docs.openhands.dev/";
+const FILE_KIND_PATTERN = /^[a-z][a-z-]*$/;
+const FILENAME_SUFFIX_PATTERN = /^\.[a-z][a-z.]*json$/;
+const EVENT_SOURCE_PATTERN = /^[a-z0-9][a-z0-9.-]*$/;
+/** Service-relative only: rooted, no traversal, no query, no fragment. */
+const ENDPOINT_PATTERN = /^\/[A-Za-z0-9/{}_-]*$/;
+/** Exactly one `{id}` substitution and no other braces. */
+const ID_ENDPOINT_PATTERN = /^[^{}]*\{id\}[^{}]*$/;
+
+const GIT_PROVIDERS = ["github", "gitlab", "bitbucket"] as const;
+/**
+ * The attribute semantics this host's edit dialog implements: the control it
+ * renders per property and the requiredness it enforces. Admission pins a
+ * declared attribute to exactly these, so an admitted manifest can never
+ * promise a control, a requiredness, or (below) a minimum the form would
+ * silently ignore.
+ */
+const HOST_ATTRIBUTES: Record<
+ AutomationAttributeName,
+ { type: InterfaceAttributeType; required: boolean }
+> = {
+ name: { type: "text", required: true },
+ prompt: { type: "textarea", required: false },
+ model: { type: "llm-profile", required: false },
+ timeout: { type: "number", required: false },
+ schedule: { type: "schedule", required: false },
+};
+const ATTRIBUTE_NAMES = Object.keys(HOST_ATTRIBUTES);
+const PLAIN_ENDPOINT_NAMES = [
+ "list",
+ "health",
+ "capabilities",
+ "validate",
+ "createPrompt",
+ "createPlugin",
+] as const;
+const ID_ENDPOINT_NAMES = ["detail", "dispatch", "runs", "tarball"] as const;
+
+export interface InterfaceValidationContext {
+ /** Ids of the published automation catalog, for the featured-list check. */
+ catalogIds: ReadonlySet<string>;
+ /** The routes this host has registrations for. A manifest must match them. */
+ mountedRoutes: InterfaceRoutes;
+}
+
+export interface InterfaceValidationResult {
+ valid: boolean;
+ errors: string[];
+}
+
+type Rec = Record<string, unknown>;
+
+function isRecord(value: unknown): value is Rec {
+ return typeof value === "object" && value !== null && !Array.isArray(value);
+}
+
+class InterfaceChecker {
+ readonly errors: string[] = [];
+
+ fail(path: string, reason: string): false {
+ this.errors.push(`${path}: ${reason}`);
+ return false;
+ }
+
+ /** Literal user-visible copy. Carries no markup. */
+ copy(value: unknown, path: string): boolean {
+ if (typeof value !== "string" || value.length === 0) {
+ return this.fail(path, "must be a non-empty string");
+ }
+ if (MARKUP_PATTERN.test(value)) {
+ return this.fail(path, "must not contain markup");
+ }
+ return true;
+ }
+
+ /** A closed object: every present key must be an expected one. */
+ closed(container: Rec, allowed: readonly string[], path: string): void {
+ Object.keys(container)
+ .filter((key) => !allowed.includes(key))
+ .forEach((key) => this.fail(`${path}.${key}`, "is not allowed"));
+ }
+
+ record(value: unknown, path: string): value is Rec {
+ if (isRecord(value)) return true;
+ this.fail(path, "must be an object");
+ return false;
+ }
+}
+
+function checkRoutes(
+ check: InterfaceChecker,
+ routes: unknown,
+ mounted: InterfaceRoutes,
+): void {
+ if (!check.record(routes, "routes")) return;
+ check.closed(routes, ["list", "setup", "detail"], "routes");
+
+ // The host serves what it has registrations for, so a declared route must be
+ // exactly the mounted shape — the manifest owns link construction, not the
+ // router table.
+ (["list", "setup", "detail"] as const).forEach((name) => {
+ if (routes[name] !== mounted[name]) {
+ check.fail(`routes.${name}`, `must be "${mounted[name]}"`);
+ }
+ });
+}
+
+function checkNavigation(check: InterfaceChecker, navigation: unknown): void {
+ if (!check.record(navigation, "navigation")) return;
+ check.closed(navigation, ["sidebar", "commandMenu"], "navigation");
+
+ if (check.record(navigation.sidebar, "navigation.sidebar")) {
+ check.closed(navigation.sidebar, ["label"], "navigation.sidebar");
+ check.copy(navigation.sidebar.label, "navigation.sidebar.label");
+ }
+ if (check.record(navigation.commandMenu, "navigation.commandMenu")) {
+ const menu = navigation.commandMenu;
+ check.closed(
+ menu,
+ ["title", "description", "keywords"],
+ "navigation.commandMenu",
+ );
+ check.copy(menu.title, "navigation.commandMenu.title");
+ check.copy(menu.description, "navigation.commandMenu.description");
+ check.copy(menu.keywords, "navigation.commandMenu.keywords");
+ }
+}
+
+function checkPages(check: InterfaceChecker, pages: unknown): void {
+ if (!check.record(pages, "pages")) return;
+ check.closed(pages, ["list", "detail", "edit"], "pages");
+
+ if (check.record(pages.list, "pages.list")) {
+ check.closed(pages.list, ["title", "subtitle"], "pages.list");
+ check.copy(pages.list.title, "pages.list.title");
+ check.copy(pages.list.subtitle, "pages.list.subtitle");
+ }
+ if (check.record(pages.detail, "pages.detail")) {
+ check.closed(pages.detail, ["backLabel"], "pages.detail");
+ check.copy(pages.detail.backLabel, "pages.detail.backLabel");
+ }
+ if (check.record(pages.edit, "pages.edit")) {
+ check.closed(pages.edit, ["title"], "pages.edit");
+ check.copy(pages.edit.title, "pages.edit.title");
+ }
+}
+
+function checkAttribute(
+ check: InterfaceChecker,
+ host: { type: InterfaceAttributeType; required: boolean },
+ attribute: unknown,
+ path: string,
+): void {
+ if (!check.record(attribute, path)) return;
+ check.closed(
+ attribute,
+ ["type", "label", "help", "required", "constraints"],
+ path,
+ );
+
+ const { type, label, help, required, constraints } = attribute;
+ if (type !== host.type) {
+ check.fail(
+ `${path}.type`,
+ `must be "${host.type}", the control this host renders`,
+ );
+ }
+ check.copy(label, `${path}.label`);
+ if (help !== undefined) check.copy(help, `${path}.help`);
+ if (required !== host.required) {
+ check.fail(
+ `${path}.required`,
+ `must be ${host.required}, what this host enforces`,
+ );
+ }
+
+ if (constraints !== undefined) {
+ if (host.type !== "number") {
+ check.fail(
+ `${path}.constraints`,
+ "is only allowed on a number attribute",
+ );
+ } else if (check.record(constraints, `${path}.constraints`)) {
+ check.closed(constraints, ["min", "max"], `${path}.constraints`);
+ const { min, max } = constraints;
+ // The form validates a positive integer, i.e. an effective minimum of 1;
+ // any other declared minimum would be a promise it does not keep.
+ if (min !== undefined && min !== 1) {
+ check.fail(
+ `${path}.constraints.min`,
+ "must be the 1 this host enforces",
+ );
+ }
+ if (
+ max !== undefined &&
+ (!Number.isInteger(max) || (max as number) < 1)
+ ) {
+ check.fail(`${path}.constraints.max`, "must be a positive integer");
+ }
+ }
+ }
+}
+
+function checkAttributes(check: InterfaceChecker, attributes: unknown): void {
+ if (!check.record(attributes, "attributes")) return;
+ const names = Object.keys(attributes);
+ if (names.length === 0) {
+ check.fail("attributes", "must declare at least one attribute");
+ }
+ names.forEach((name) => {
+ if (!ATTRIBUTE_NAMES.includes(name)) {
+ check.fail(`attributes.${name}`, "is not a settable attribute");
+ return;
+ }
+ checkAttribute(
+ check,
+ HOST_ATTRIBUTES[name as AutomationAttributeName],
+ attributes[name],
+ `attributes.${name}`,
+ );
+ });
+}
+
+function checkImportExport(
+ check: InterfaceChecker,
+ importExport: unknown,
+): void {
+ if (!check.record(importExport, "importExport")) return;
+ check.closed(
+ importExport,
+ ["fileKind", "fileVersion", "filenameSuffix", "importDefaults"],
+ "importExport",
+ );
+
+ const { fileKind, fileVersion, filenameSuffix, importDefaults } =
+ importExport;
+ if (typeof fileKind !== "string" || !FILE_KIND_PATTERN.test(fileKind)) {
+ check.fail("importExport.fileKind", "must be a lowercase slug");
+ }
+ if (fileVersion !== 1) {
+ check.fail("importExport.fileVersion", "must be 1");
+ }
+ if (
+ typeof filenameSuffix !== "string" ||
+ !FILENAME_SUFFIX_PATTERN.test(filenameSuffix)
+ ) {
+ check.fail("importExport.filenameSuffix", "must be a .json suffix");
+ }
+ if (check.record(importDefaults, "importExport.importDefaults")) {
+ check.closed(
+ importDefaults,
+ ["repoProvider", "placeholderEventSource"],
+ "importExport.importDefaults",
+ );
+ if (
+ typeof importDefaults.repoProvider !== "string" ||
+ !(GIT_PROVIDERS as readonly string[]).includes(
+ importDefaults.repoProvider,
+ )
+ ) {
+ check.fail(
+ "importExport.importDefaults.repoProvider",
+ "is not a supported provider",
+ );
+ }
+ if (
+ typeof importDefaults.placeholderEventSource !== "string" ||
+ !EVENT_SOURCE_PATTERN.test(importDefaults.placeholderEventSource)
+ ) {
+ check.fail(
+ "importExport.importDefaults.placeholderEventSource",
+ "must be a lowercase event source",
+ );
+ }
+ }
+}
+
+function checkEndpoints(check: InterfaceChecker, endpoints: unknown): void {
+ if (!check.record(endpoints, "endpoints")) return;
+ const allowed = [...PLAIN_ENDPOINT_NAMES, ...ID_ENDPOINT_NAMES];
+ check.closed(endpoints, allowed, "endpoints");
+
+ const endpointAt = (name: string): string | null => {
+ const value = endpoints[name];
+ if (
+ typeof value !== "string" ||
+ !ENDPOINT_PATTERN.test(value) ||
+ value.includes("//")
+ ) {
+ check.fail(`endpoints.${name}`, "must be a rooted service-relative path");
+ return null;
+ }
+ return value;
+ };
+
+ PLAIN_ENDPOINT_NAMES.forEach((name) => {
+ const value = endpointAt(name);
+ if (value !== null && /[{}]/.test(value)) {
+ check.fail(`endpoints.${name}`, "must not carry a substitution");
+ }
+ });
+ ID_ENDPOINT_NAMES.forEach((name) => {
+ const value = endpointAt(name);
+ if (value !== null && !ID_ENDPOINT_PATTERN.test(value)) {
+ check.fail(`endpoints.${name}`, "must carry exactly one {id}");
+ }
+ });
+}
+
+function checkSlugList(
+ check: InterfaceChecker,
+ value: unknown,
+ path: string,
+): string[] {
+ if (!Array.isArray(value) || value.length === 0) {
+ check.fail(path, "must be a non-empty array");
+ return [];
+ }
+ const slugs = value.filter((item): item is string => {
+ if (typeof item === "string" && SLUG_PATTERN.test(item)) return true;
+ check.fail(path, "must contain only lowercase slugs");
+ return false;
+ });
+ if (new Set(slugs).size !== slugs.length) {
+ check.fail(path, "must not repeat an id");
+ }
+ return slugs;
+}
+
+const TOP_LEVEL_KEYS = [
+ "version",
+ "routes",
+ "navigation",
+ "pages",
+ "docsUrl",
+ "attributes",
+ "importExport",
+ "endpoints",
+ "featuredAutomationIds",
+ "responderIntegrationIds",
+];
+
+/**
+ * Decide whether this host will act on a published interface manifest.
+ *
+ * The version is checked first and fails closed: a format this host does not
+ * recognise is refused rather than interpreted with today's rules.
+ */
+export function validateInterfaceManifest(
+ candidate: unknown,
+ context: InterfaceValidationContext,
+): InterfaceValidationResult {
+ if (!isRecord(candidate)) {
+ return { valid: false, errors: ["interface: must be an object"] };
+ }
+ if (candidate.version !== INTERFACE_VERSION) {
+ return {
+ valid: false,
+ errors: [`interface.version: must be "${INTERFACE_VERSION}"`],
+ };
+ }
+
+ const check = new InterfaceChecker();
+ check.closed(candidate, TOP_LEVEL_KEYS, "interface");
+
+ checkRoutes(check, candidate.routes, context.mountedRoutes);
+ checkNavigation(check, candidate.navigation);
+ checkPages(check, candidate.pages);
+ if (
+ typeof candidate.docsUrl !== "string" ||
+ !candidate.docsUrl.startsWith(DOCS_URL_PREFIX)
+ ) {
+ check.fail("docsUrl", `must start with ${DOCS_URL_PREFIX}`);
+ }
+ checkAttributes(check, candidate.attributes);
+ checkImportExport(check, candidate.importExport);
+ checkEndpoints(check, candidate.endpoints);
+
+ checkSlugList(
+ check,
+ candidate.featuredAutomationIds,
+ "featuredAutomationIds",
+ ).forEach((id) => {
+ if (!context.catalogIds.has(id)) {
+ check.fail("featuredAutomationIds", `${id} is not a catalog entry`);
+ }
+ });
+ checkSlugList(
+ check,
+ candidate.responderIntegrationIds,
+ "responderIntegrationIds",
+ );
+
+ return { valid: check.errors.length === 0, errors: check.errors };
+}
diff --git a/src/manifests/manifest-sources.ts b/src/manifests/manifest-sources.ts
index 1932177bca..9cd410d5c3 100644
--- a/src/manifests/manifest-sources.ts
+++ b/src/manifests/manifest-sources.ts
@@ -11,9 +11,22 @@
* types that shipped beside it.
*/
+import * as automationsModule from "@openhands/extensions/automations";
import { AUTOMATION_CATALOG } from "@openhands/extensions/automations";
import { createSetupRegistry, type SetupRegistry } from "./manifest-registry";
export const SETUP_REGISTRY: SetupRegistry = createSetupRegistry(
AUTOMATION_CATALOG as readonly unknown[],
);
+
+/**
+ * The interface manifest the pinned package publishes, if any. It is read off
+ * the module namespace so a package that predates the export yields
+ * `undefined` rather than a build error; admission in
+ * `automation-interface.ts` decides what to do with it.
+ */
+const automationsExports: object = automationsModule;
+export const AUTOMATION_INTERFACE_CANDIDATE: unknown =
+ "AUTOMATION_INTERFACE" in automationsExports
+ ? automationsExports.AUTOMATION_INTERFACE
+ : undefined;
diff --git a/src/manifests/types.ts b/src/manifests/types.ts
index 4580b9fc4c..a8e32336a2 100644
--- a/src/manifests/types.ts
+++ b/src/manifests/types.ts
@@ -153,3 +153,104 @@ export interface ValidateDraftResponse {
errors: DraftValidationError[];
sampleEventMatched?: boolean | null;
}
+
+/**
+ * Host-owned shape of the production Automation interface manifest, published
+ * by `@openhands/extensions/automations` as `AUTOMATION_INTERFACE`.
+ *
+ * The catalog states what varies per automation; this states the domain-level
+ * facts of the interface itself. As with setup entries, the published data is
+ * validated at admission rather than trusted, and a package that predates the
+ * manifest simply leaves the host on its own defaults.
+ */
+
+export const INTERFACE_VERSION = "1.0";
+
+/** The closed set of runtime-model properties a client may offer for setting. */
+export type AutomationAttributeName =
+ | "name"
+ | "prompt"
+ | "model"
+ | "timeout"
+ | "schedule";
+
+export type InterfaceAttributeType =
+ | "text"
+ | "textarea"
+ | "number"
+ | "llm-profile"
+ | "schedule";
+
+/** How one settable attribute of an existing Automation is offered. */
+export interface InterfaceAttribute {
+ type: InterfaceAttributeType;
+ label: string;
+ help?: string;
+ required: boolean;
+ /** Only a `number` attribute carries constraints. */
+ constraints?: { min?: number; max?: number };
+}
+
+export interface InterfaceRoutes {
+ list: string;
+ /** Carries the `:automationId` segment the host substitutes. */
+ setup: string;
+ /** Carries the `:automationId` segment the host substitutes. */
+ detail: string;
+}
+
+/**
+ * Service-relative paths the host calls. The base path, methods, headers, and
+ * auth remain the host's. `{id}` marks where the automation id is substituted.
+ */
+export interface InterfaceEndpoints {
+ list: string;
+ detail: string;
+ dispatch: string;
+ runs: string;
+ tarball: string;
+ health: string;
+ capabilities: string;
+ validate: string;
+ createPrompt: string;
+ createPlugin: string;
+}
+
+export type InterfaceEndpointName = keyof InterfaceEndpoints;
+
+export interface InterfaceImportExport {
+ fileKind: string;
+ fileVersion: number;
+ filenameSuffix: string;
+ importDefaults: {
+ /** Provider inferred for short owner/repo repository URLs on import. */
+ repoProvider: SetupGitProvider;
+ /** Event source of the placeholder trigger that keeps an import inert. */
+ placeholderEventSource: string;
+ };
+}
+
+export interface InterfaceManifest {
+ version: typeof INTERFACE_VERSION;
+ routes: InterfaceRoutes;
+ navigation: {
+ sidebar: { label: string };
+ commandMenu: { title: string; description: string; keywords: string };
+ };
+ pages: {
+ list: { title: string; subtitle: string };
+ detail: { backLabel: string };
+ edit: { title: string };
+ };
+ docsUrl: string;
+ /**
+ * The input surface of an existing Automation, keyed by the runtime-model
+ * property the host sends. Rendering it as an edit dialog is this host's
+ * choice, not stated here.
+ */
+ attributes: Partial<Record<AutomationAttributeName, InterfaceAttribute>>;
+ importExport: InterfaceImportExport;
+ endpoints: InterfaceEndpoints;
+ featuredAutomationIds: string[];
+ responderIntegrationIds: string[];
+}
diff --git a/src/routes/automation-detail.tsx b/src/routes/automation-detail.tsx
index b13ed136ae..da820d5cb5 100644
--- a/src/routes/automation-detail.tsx
+++ b/src/routes/automation-detail.tsx
@@ -17,6 +17,7 @@ import {
import { useAutomationHealth } from "#/hooks/query/use-automation-health";
import { useActiveBackend } from "#/contexts/active-backend-context";
import { useNavigation } from "#/context/navigation-context";
+import { automationListPath } from "#/manifests/automation-interface";
import { BackLink } from "#/components/features/automations/detail/back-link";
import { DetailHeader } from "#/components/features/automations/detail/detail-header";
import { PromptSection } from "#/components/features/automations/detail/prompt-section";
@@ -148,7 +149,7 @@ export default function AutomationDetail() {
const handleDelete = () => {
deleteMutation.mutate(automation.id, {
onSuccess: () => {
- navigate?.("/automations");
+ navigate?.(automationListPath());
},
});
};
diff --git a/src/routes/automation-setup-route.tsx b/src/routes/automation-setup-route.tsx
index e3037c2ca9..f6f568f769 100644
--- a/src/routes/automation-setup-route.tsx
+++ b/src/routes/automation-setup-route.tsx
@@ -1,11 +1,9 @@
import { useLoaderData, useLocation, useNavigate } from "react-router";
import { Route } from "./+types/automation-setup-route";
+import { automationListPath } from "#/manifests/automation-interface";
import { SETUP_REGISTRY } from "#/manifests/manifest-sources";
import { SetupDialog } from "#/components/features/manifest/manifest-setup-dialog";
-/** Where dismissing lands when the dialog was opened by a cold deep link. */
-const FALLBACK_PATH = "/automations";
-
/**
* Setup for one catalog entry.
*
@@ -33,8 +31,10 @@ export default function AutomationSetupRoute() {
if (!entry) return null;
const handleClose = () => {
- // "default" is the initial history entry, so there is nothing to go back to.
- if (location.key === "default") navigate(FALLBACK_PATH, { replace: true });
+ // "default" is the initial history entry, so there is nothing to go back
+ // to; dismissing a cold deep link lands on the list instead.
+ if (location.key === "default")
+ navigate(automationListPath(), { replace: true });
else navigate(-1);
};
diff --git a/src/routes/automations-list.tsx b/src/routes/automations-list.tsx
index a0e2618c22..14cfa17357 100644
--- a/src/routes/automations-list.tsx
+++ b/src/routes/automations-list.tsx
@@ -48,12 +48,17 @@ import {
parseAutomationFile,
serializeAutomation,
} from "#/utils/automation-export";
+import {
+ automationDetailPath,
+ getInterfaceCopy,
+} from "#/manifests/automation-interface";
import { downloadBlob } from "#/utils/utils";
const PAGE_SIZE = 50;
export default function AutomationsList() {
const { t } = useTranslation("openhands");
+ const interfaceCopy = getInterfaceCopy();
const [searchQuery, setSearchQuery] = useState("");
const [viewMode, setViewMode] = useState<AutomationViewMode>(() =>
readStoredAutomationViewMode(),
@@ -197,7 +202,7 @@ export default function AutomationsList() {
displaySuccessToastWithLink(
t(I18nKey.AUTOMATIONS$IMPORT_SUCCESS, { name: created.name }),
t(I18nKey.AUTOMATIONS$IMPORT_VIEW),
- `/automations/${encodeURIComponent(created.id)}`,
+ automationDetailPath(created.id),
);
},
onError: (error) => {
@@ -231,10 +236,10 @@ export default function AutomationsList() {
<div className="min-h-full">
<div className="p-6 max-w-4xl mx-auto">
<h1 className="text-xl font-medium text-content">
- {t(I18nKey.AUTOMATIONS$TITLE)}
+ {interfaceCopy.listTitle ?? t(I18nKey.AUTOMATIONS$TITLE)}
</h1>
<p className="mt-1 text-sm text-muted">
- {t(I18nKey.AUTOMATIONS$SUBTITLE)}
+ {interfaceCopy.listSubtitle ?? t(I18nKey.AUTOMATIONS$SUBTITLE)}
</p>
<div className="mt-6 flex flex-col gap-3">
{Array.from({ length: 3 }).map((_, i) => (
@@ -252,10 +257,10 @@ export default function AutomationsList() {
<div className="min-h-full">
<div className="p-6 max-w-4xl mx-auto">
<h1 className="text-xl font-medium text-content">
- {t(I18nKey.AUTOMATIONS$TITLE)}
+ {interfaceCopy.listTitle ?? t(I18nKey.AUTOMATIONS$TITLE)}
</h1>
<p className="mt-1 text-sm text-muted">
- {t(I18nKey.AUTOMATIONS$SUBTITLE)}
+ {interfaceCopy.listSubtitle ?? t(I18nKey.AUTOMATIONS$SUBTITLE)}
</p>
<BackendNotConfigured onRetry={refetchHealth} />
</div>
@@ -270,10 +275,10 @@ export default function AutomationsList() {
<div className="flex items-start justify-between gap-4">
<div className="min-w-0">
<h1 className="text-xl font-semibold text-content">
- {t(I18nKey.AUTOMATIONS$TITLE)}
+ {interfaceCopy.listTitle ?? t(I18nKey.AUTOMATIONS$TITLE)}
</h1>
<p className="mt-1 text-sm text-muted">
- {t(I18nKey.AUTOMATIONS$SUBTITLE)}
+ {interfaceCopy.listSubtitle ?? t(I18nKey.AUTOMATIONS$SUBTITLE)}
</p>
</div>
<div className="flex shrink-0 flex-wrap justify-end gap-2">
diff --git a/src/types/automation.ts b/src/types/automation.ts
index f366810d28..8c8d85c485 100644
--- a/src/types/automation.ts
+++ b/src/types/automation.ts
@@ -50,9 +50,10 @@ export type AutomationSpec = Omit<
"id" | "created_at" | "updated_at" | "last_triggered_at"
>;
+/** The envelope constants come from the interface manifest's import/export spec. */
export interface AutomationExportFile {
- version: 1;
- kind: "automation";
+ version: number;
+ kind: string;
spec: AutomationSpec;
}
diff --git a/src/utils/automation-export.ts b/src/utils/automation-export.ts
index f5ad2599de..57224d3212 100644
--- a/src/utils/automation-export.ts
+++ b/src/utils/automation-export.ts
@@ -1,3 +1,4 @@
+import { getImportExportSpec } from "#/manifests/automation-interface";
import type {
Automation,
AutomationExportFile,
@@ -166,7 +167,8 @@ export function serializeAutomation(a: Automation): AutomationExportFile {
...(timezone !== undefined && { timezone }),
};
- return { version: 1, kind: "automation", spec };
+ const envelope = getImportExportSpec();
+ return { version: envelope.fileVersion, kind: envelope.fileKind, spec };
}
export function getAutomationExportFilename(
@@ -177,7 +179,7 @@ export function getAutomationExportFilename(
.toLowerCase()
.replace(/[^a-z0-9]+/g, "-")
.replace(/^-+|-+$/g, "");
- return `${slug || automation.id}.automation.json`;
+ return `${slug || automation.id}${getImportExportSpec().filenameSuffix}`;
}
export function parseAutomationFile(json: unknown): AutomationSpec {
@@ -186,11 +188,12 @@ export function parseAutomationFile(json: unknown): AutomationSpec {
throw new AutomationFileValidationError(["file: expected a JSON object"]);
}
- if (json.version !== 1) {
- issues.push("version: expected 1");
+ const envelope = getImportExportSpec();
+ if (json.version !== envelope.fileVersion) {
+ issues.push(`version: expected ${envelope.fileVersion}`);
}
- if (json.kind !== "automation") {
- issues.push('kind: expected "automation"');
+ if (json.kind !== envelope.fileKind) {
+ issues.push(`kind: expected "${envelope.fileKind}"`);
}
if (!isRecord(json.spec)) {
issues.push("spec: expected an object");
diff --git a/src/utils/automation-timeout.ts b/src/utils/automation-timeout.ts
index fcef8460ce..b54714b761 100644
--- a/src/utils/automation-timeout.ts
+++ b/src/utils/automation-timeout.ts
@@ -15,10 +15,12 @@ export type AutomationTimeoutValidation =
/**
* Validate a raw timeout string from the edit form. A blank string means "use
* the server default" (resolved as `null`). Otherwise the value must be a
- * positive integer no greater than {@link AUTOMATION_TIMEOUT_MAX_SECONDS}.
+ * positive integer no greater than the ceiling, which the interface manifest
+ * may lower from {@link AUTOMATION_TIMEOUT_MAX_SECONDS}.
*/
export function validateAutomationTimeout(
raw: string,
+ maxSeconds: number = AUTOMATION_TIMEOUT_MAX_SECONDS,
): AutomationTimeoutValidation {
const trimmed = raw.trim();
if (!trimmed) return { value: null };
@@ -30,7 +32,7 @@ export function validateAutomationTimeout(
if (seconds <= 0) {
return { errorKey: I18nKey.AUTOMATIONS$ERROR_TIMEOUT_POSITIVE };
}
- if (seconds > AUTOMATION_TIMEOUT_MAX_SECONDS) {
+ if (seconds > maxSeconds) {
return { errorKey: I18nKey.AUTOMATIONS$ERROR_TIMEOUT_MAX_EXCEEDED };
}
return { value: seconds };
diff --git a/src/utils/responder-deployment.ts b/src/utils/responder-deployment.ts
index 4d9ece9282..3ff6ee24a5 100644
--- a/src/utils/responder-deployment.ts
+++ b/src/utils/responder-deployment.ts
@@ -1,32 +1,26 @@
import type { RecommendedAutomation } from "@openhands/extensions/automations";
import { I18nKey } from "#/i18n/declaration";
+import { getResponderIntegrationIds } from "#/manifests/automation-interface";
import { getRequiredIntegrationIds } from "#/utils/automation-catalog";
import { PRODUCT_URL } from "#/utils/constants";
/** OpenHands Cloud integrations page — where always-on responders are set up. */
export const OPENHANDS_CLOUD_INTEGRATIONS_URL = `${PRODUCT_URL.PRODUCTION}/settings/integrations`;
-/**
- * Integrations whose automations are treated as event "responders" that poll
- * continuously. A responder is an automation whose required integrations are
- * exclusively from this set, so multi-tool digests (e.g. slack + linear +
- * notion) are not treated as Slack responders.
- */
-const RESPONDER_INTEGRATION_IDS = ["github", "slack"];
-
/**
* Single source of truth for "does this automation get the deployment-choice
- * modal?" — true only for pure GitHub/Slack responders. An integration the
- * automation can start without does not decide where it runs, so only the
- * required ones are classified.
+ * modal?" — true only for automations whose required integrations are
+ * exclusively responder ones (owned by the interface manifest, GitHub/Slack by
+ * default), so multi-tool digests (e.g. slack + linear + notion) are not
+ * treated as Slack responders. An integration the automation can start without
+ * does not decide where it runs, so only the required ones are classified.
*/
export function isResponderAutomation(
automation: RecommendedAutomation,
): boolean {
+ const responderIds = getResponderIntegrationIds();
const ids = getRequiredIntegrationIds(automation);
- return (
- ids.length > 0 && ids.every((id) => RESPONDER_INTEGRATION_IDS.includes(id))
- );
+ return ids.length > 0 && ids.every((id) => responderIds.includes(id));
}
/**