diff --git a/api/openapi.yaml b/api/openapi.yaml index 75387efb9..579ffa668 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -414,6 +414,28 @@ components: - Reversibility - Summary type: object + ConnectorsExtensionKind: + additionalProperties: false + properties: + group: + enum: + - platform + - integration + - agent + type: string + kind: + description: The API path segment that lists this kind + type: string + label: + type: string + singular: + type: string + required: + - kind + - label + - singular + - group + type: object ConnectorsExtensionView: additionalProperties: false properties: @@ -445,6 +467,12 @@ components: - "null" error: type: string + group: + enum: + - platform + - integration + - agent + type: string name: type: string path: @@ -469,6 +497,7 @@ components: required: - name - contract + - group - state - digest - egress @@ -4117,6 +4146,29 @@ paths: summary: Get an event with its payload and the runs it started tags: - Events + /api/extension-kinds: + get: + operationId: list-extension-kinds + responses: + "200": + content: + application/json: + schema: + items: + $ref: "#/components/schemas/ConnectorsExtensionKind" + type: + - array + - "null" + description: OK + default: + content: + application/problem+json: + schema: + $ref: "#/components/schemas/ErrorModel" + description: Error + summary: List the kinds of extension and the group each belongs to + tags: + - Connectors /api/groups: get: operationId: list-groups diff --git a/modules/connectors/internal/store/store.go b/modules/connectors/internal/store/store.go index 682b2377c..ba55f01a1 100644 --- a/modules/connectors/internal/store/store.go +++ b/modules/connectors/internal/store/store.go @@ -46,6 +46,45 @@ const ( ContractGuard = "guard" ) +// Group says what an extension is for, so the dashboard can list the +// extensions an operator sets up together. +type Group string + +// Groups of extensions. Workflows and playbooks are content and have none. +const ( + GroupPlatform Group = "platform" + GroupIntegration Group = "integration" + GroupAgent Group = "agent" +) + +// Contracts lists every contract with its group. Everything that enumerates +// contracts reads this table, and GroupOf is the only way to look a group up, +// so a contract without a group cannot be served. +func Contracts() []ContractGroup { + return []ContractGroup{ + {ContractConnector, GroupIntegration}, + {ContractSecretEngine, GroupPlatform}, + {ContractGuard, GroupPlatform}, + {ContractMCP, GroupAgent}, + } +} + +// ContractGroup pairs a contract with its group. +type ContractGroup struct { + Contract string + Group Group +} + +// GroupOf returns the group of a contract in Contracts. +func GroupOf(contract string) Group { + for _, c := range Contracts() { + if c.Contract == contract { + return c.Group + } + } + return "" +} + // Credential is a credential's sealed fields. type Credential struct { OrgID string `db:"org_id"` diff --git a/modules/connectors/list.go b/modules/connectors/list.go index 04ca62d6a..f0644ef61 100644 --- a/modules/connectors/list.go +++ b/modules/connectors/list.go @@ -20,6 +20,7 @@ import ( type ExtensionView struct { Name string `json:"name"` Contract string `json:"contract"` + Group string `json:"group" enum:"platform,integration,agent"` State string `json:"state"` Error string `json:"error,omitempty"` Version string `json:"version,omitempty"` @@ -61,7 +62,7 @@ func (m *Module) list(contract string) func(context.Context, *struct{}) (*httpap func (m *Module) viewOf(a store.Accepted) (ExtensionView, error) { view := ExtensionView{ - Name: a.Name, Contract: a.Contract, Digest: a.SHA256, Path: a.Path, URL: a.URL, + Name: a.Name, Contract: a.Contract, Group: string(store.GroupOf(a.Contract)), Digest: a.SHA256, Path: a.Path, URL: a.URL, Args: a.Args, Egress: a.Egress, Env: a.Env, Tools: a.Tools, Settings: map[string]string{}, Credentials: map[string]string{}, SettingsSchema: []Setting{}, } diff --git a/modules/connectors/module.go b/modules/connectors/module.go index e0aa49875..4d7508343 100644 --- a/modules/connectors/module.go +++ b/modules/connectors/module.go @@ -254,16 +254,48 @@ func (m *Module) Close() { m.host.Close() } +// extensionKinds is the one table of accepted-package kinds: the contract each +// serves, its API path and its names. The group comes from the contract. +func extensionKinds() []extensionKind { + return []extensionKind{ + {store.ContractConnector, "/api/connectors", "connector", "connector", "connectors", "Connectors"}, + {store.ContractSecretEngine, "/api/secret-engines", "secret-engine", "secret engine", "secret engines", "Secret engines"}, + {store.ContractGuard, "/api/guards", "guard", "guard", "guards", "Guards"}, + {store.ContractMCP, "/api/mcp-servers", "mcp-server", "MCP server", "MCP servers", "MCP servers"}, + } +} + +type extensionKind struct { + contract, path, noun, singular, plural, tag string +} + +// ExtensionKind is one kind of accepted package and the group it belongs to. +type ExtensionKind struct { + Kind string `json:"kind" doc:"The API path segment that lists this kind"` + Label string `json:"label"` + Singular string `json:"singular"` + Group string `json:"group" enum:"platform,integration,agent"` +} + +func listExtensionKinds(context.Context, *struct{}) (*httpapi.Reply[[]ExtensionKind], error) { + kinds := extensionKinds() + out := make([]ExtensionKind, 0, len(kinds)) + for _, k := range kinds { + out = append(out, ExtensionKind{ + Kind: strings.TrimPrefix(k.path, "/api/"), Label: k.tag, Singular: k.singular, + Group: string(store.GroupOf(k.contract)), + }) + } + return httpapi.OK(out), nil +} + // Register adds the API for accepted packages and credentials. func (m *Module) Register(api huma.API) { - for _, k := range []struct { - contract, path, noun, plural, tag string - }{ - {store.ContractConnector, "/api/connectors", "connector", "connectors", "Connectors"}, - {store.ContractSecretEngine, "/api/secret-engines", "secret-engine", "secret engines", "Secret engines"}, - {store.ContractGuard, "/api/guards", "guard", "guards", "Guards"}, - {store.ContractMCP, "/api/mcp-servers", "mcp-server", "MCP servers", "MCP servers"}, - } { + huma.Register(api, huma.Operation{ + OperationID: "list-extension-kinds", Method: http.MethodGet, Path: "/api/extension-kinds", + Summary: "List the kinds of extension and the group each belongs to", Tags: []string{"Connectors"}, + }, listExtensionKinds) + for _, k := range extensionKinds() { tags := []string{k.tag} huma.Register(api, huma.Operation{ OperationID: "list-" + k.noun + "s", Method: http.MethodGet, Path: k.path, diff --git a/ui/src/lib/api.ts b/ui/src/lib/api.ts index 2cb738bb5..bdafcc93a 100644 --- a/ui/src/lib/api.ts +++ b/ui/src/lib/api.ts @@ -210,6 +210,7 @@ export const api = { putWorkflow: (name: string, body: string) => request(`/api/workflows/${encodeURIComponent(name)}`, { method: "PUT", body: { body } }), workflowStepTypes: () => request<{ name: string; needs_repository: boolean; settings?: unknown }[]>("/api/workflow-step-types"), + extensionKinds: () => request("/api/extension-kinds"), extensions: (kind: ExtensionKind) => request(`/api/${kind}`), acceptExtension: (kind: ExtensionKind, name: string, body: ExtensionInput) => request<{ name: string; state: string }>(`/api/${kind}/${encodeURIComponent(name)}`, { method: "PUT", body, timeoutMs: 60_000 }), @@ -793,7 +794,17 @@ export interface WorkflowVersion { created_by?: string; } -export type ExtensionKind = "connectors" | "guards" | "mcp-servers" | "secret-engines"; +export type ExtensionGroup = "platform" | "integration" | "agent"; + +/** An accepted-package kind, as the server lists it: the path segment of its API. */ +export type ExtensionKind = string; + +export interface ExtensionKindInfo { + kind: ExtensionKind; + label: string; + singular: string; + group: ExtensionGroup; +} export interface SettingField { key: string; @@ -815,6 +826,7 @@ export interface Extension { digest?: string; version?: string; contract?: string; + group?: ExtensionGroup; egress?: string[]; env?: string[]; settings?: Record; diff --git a/ui/src/settings/AcceptedExtensionsPage.vue b/ui/src/settings/AcceptedExtensionsPage.vue index 70e133832..dfe9ec36e 100644 --- a/ui/src/settings/AcceptedExtensionsPage.vue +++ b/ui/src/settings/AcceptedExtensionsPage.vue @@ -1,33 +1,47 @@