feat(connectors): group extensions as platform, integration or agent (#2084)
This commit is contained in:
6 files changed
+176
-26
No files matched your search
@@ -414,6 +414,28 @@ components:
|
|||||||
- Reversibility
|
- Reversibility
|
||||||
- Summary
|
- Summary
|
||||||
type: object
|
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:
|
ConnectorsExtensionView:
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
properties:
|
properties:
|
||||||
@@ -445,6 +467,12 @@ components:
|
|||||||
- "null"
|
- "null"
|
||||||
error:
|
error:
|
||||||
type: string
|
type: string
|
||||||
|
group:
|
||||||
|
enum:
|
||||||
|
- platform
|
||||||
|
- integration
|
||||||
|
- agent
|
||||||
|
type: string
|
||||||
name:
|
name:
|
||||||
type: string
|
type: string
|
||||||
path:
|
path:
|
||||||
@@ -469,6 +497,7 @@ components:
|
|||||||
required:
|
required:
|
||||||
- name
|
- name
|
||||||
- contract
|
- contract
|
||||||
|
- group
|
||||||
- state
|
- state
|
||||||
- digest
|
- digest
|
||||||
- egress
|
- egress
|
||||||
@@ -4117,6 +4146,29 @@ paths:
|
|||||||
summary: Get an event with its payload and the runs it started
|
summary: Get an event with its payload and the runs it started
|
||||||
tags:
|
tags:
|
||||||
- Events
|
- 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:
|
/api/groups:
|
||||||
get:
|
get:
|
||||||
operationId: list-groups
|
operationId: list-groups
|
||||||
|
|||||||
@@ -46,6 +46,45 @@ const (
|
|||||||
ContractGuard = "guard"
|
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.
|
// Credential is a credential's sealed fields.
|
||||||
type Credential struct {
|
type Credential struct {
|
||||||
OrgID string `db:"org_id"`
|
OrgID string `db:"org_id"`
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import (
|
|||||||
type ExtensionView struct {
|
type ExtensionView struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Contract string `json:"contract"`
|
Contract string `json:"contract"`
|
||||||
|
Group string `json:"group" enum:"platform,integration,agent"`
|
||||||
State string `json:"state"`
|
State string `json:"state"`
|
||||||
Error string `json:"error,omitempty"`
|
Error string `json:"error,omitempty"`
|
||||||
Version string `json:"version,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) {
|
func (m *Module) viewOf(a store.Accepted) (ExtensionView, error) {
|
||||||
view := ExtensionView{
|
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,
|
Args: a.Args, Egress: a.Egress, Env: a.Env, Tools: a.Tools,
|
||||||
Settings: map[string]string{}, Credentials: map[string]string{}, SettingsSchema: []Setting{},
|
Settings: map[string]string{}, Credentials: map[string]string{}, SettingsSchema: []Setting{},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -254,16 +254,48 @@ func (m *Module) Close() {
|
|||||||
m.host.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.
|
// Register adds the API for accepted packages and credentials.
|
||||||
func (m *Module) Register(api huma.API) {
|
func (m *Module) Register(api huma.API) {
|
||||||
for _, k := range []struct {
|
huma.Register(api, huma.Operation{
|
||||||
contract, path, noun, plural, tag string
|
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"},
|
||||||
{store.ContractConnector, "/api/connectors", "connector", "connectors", "Connectors"},
|
}, listExtensionKinds)
|
||||||
{store.ContractSecretEngine, "/api/secret-engines", "secret-engine", "secret engines", "Secret engines"},
|
for _, k := range extensionKinds() {
|
||||||
{store.ContractGuard, "/api/guards", "guard", "guards", "Guards"},
|
|
||||||
{store.ContractMCP, "/api/mcp-servers", "mcp-server", "MCP servers", "MCP servers"},
|
|
||||||
} {
|
|
||||||
tags := []string{k.tag}
|
tags := []string{k.tag}
|
||||||
huma.Register(api, huma.Operation{
|
huma.Register(api, huma.Operation{
|
||||||
OperationID: "list-" + k.noun + "s", Method: http.MethodGet, Path: k.path,
|
OperationID: "list-" + k.noun + "s", Method: http.MethodGet, Path: k.path,
|
||||||
|
|||||||
+13
-1
@@ -210,6 +210,7 @@ export const api = {
|
|||||||
putWorkflow: (name: string, body: string) =>
|
putWorkflow: (name: string, body: string) =>
|
||||||
request<WorkflowVersion>(`/api/workflows/${encodeURIComponent(name)}`, { method: "PUT", body: { body } }),
|
request<WorkflowVersion>(`/api/workflows/${encodeURIComponent(name)}`, { method: "PUT", body: { body } }),
|
||||||
workflowStepTypes: () => request<{ name: string; needs_repository: boolean; settings?: unknown }[]>("/api/workflow-step-types"),
|
workflowStepTypes: () => request<{ name: string; needs_repository: boolean; settings?: unknown }[]>("/api/workflow-step-types"),
|
||||||
|
extensionKinds: () => request<ExtensionKindInfo[]>("/api/extension-kinds"),
|
||||||
extensions: (kind: ExtensionKind) => request<Extension[]>(`/api/${kind}`),
|
extensions: (kind: ExtensionKind) => request<Extension[]>(`/api/${kind}`),
|
||||||
acceptExtension: (kind: ExtensionKind, name: string, body: ExtensionInput) =>
|
acceptExtension: (kind: ExtensionKind, name: string, body: ExtensionInput) =>
|
||||||
request<{ name: string; state: string }>(`/api/${kind}/${encodeURIComponent(name)}`, { method: "PUT", body, timeoutMs: 60_000 }),
|
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;
|
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 {
|
export interface SettingField {
|
||||||
key: string;
|
key: string;
|
||||||
@@ -815,6 +826,7 @@ export interface Extension {
|
|||||||
digest?: string;
|
digest?: string;
|
||||||
version?: string;
|
version?: string;
|
||||||
contract?: string;
|
contract?: string;
|
||||||
|
group?: ExtensionGroup;
|
||||||
egress?: string[];
|
egress?: string[];
|
||||||
env?: string[];
|
env?: string[];
|
||||||
settings?: Record<string, string>;
|
settings?: Record<string, string>;
|
||||||
|
|||||||
@@ -1,33 +1,47 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed } from "vue";
|
import { computed, onMounted } from "vue";
|
||||||
import { useRoute, useRouter } from "vue-router";
|
import { useRoute, useRouter } from "vue-router";
|
||||||
|
|
||||||
import PageHeader from "@/base/PageHeader.vue";
|
import PageHeader from "@/base/PageHeader.vue";
|
||||||
|
import { ReadError } from "@/components/ui/read-error";
|
||||||
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||||
import type { ExtensionKind } from "@/lib/api";
|
import { api, type ExtensionGroup } from "@/lib/api";
|
||||||
|
import { useRead } from "@/lib/use-read";
|
||||||
import ExtensionList from "./ExtensionList.vue";
|
import ExtensionList from "./ExtensionList.vue";
|
||||||
|
|
||||||
/** Connectors, guards and MCP servers: the packages Archie acts and judges
|
/** The packages Archie runs, listed by group. The open tab is `?kind=`. */
|
||||||
* through. The open tab is `?kind=`. */
|
const GROUPS: { id: ExtensionGroup; label: string }[] = [
|
||||||
const KINDS: { kind: ExtensionKind; label: string; noun: string }[] = [
|
{ id: "platform", label: "Platform extensions" },
|
||||||
{ kind: "connectors", label: "Connectors", noun: "connector" },
|
{ id: "integration", label: "Integration extensions" },
|
||||||
{ kind: "guards", label: "Guards", noun: "guard" },
|
{ id: "agent", label: "Agent extensions" },
|
||||||
{ kind: "mcp-servers", label: "MCP servers", noun: "MCP server" },
|
|
||||||
{ kind: "secret-engines", label: "Secret engines", noun: "secret engine" },
|
|
||||||
];
|
];
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const active = computed(() => KINDS.find((k) => k.kind === route.query.kind) ?? KINDS[0]);
|
const { data: kinds, error, reload } = useRead(() => api.extensionKinds());
|
||||||
|
onMounted(reload);
|
||||||
|
|
||||||
|
const groups = computed(() =>
|
||||||
|
GROUPS.map((group) => ({ ...group, kinds: (kinds.value ?? []).filter((k) => k.group === group.id) })).filter((group) => group.kinds.length),
|
||||||
|
);
|
||||||
|
const active = computed(() => kinds.value?.find((k) => k.kind === route.query.kind) ?? kinds.value?.[0]);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<PageHeader title="Extensions" />
|
<PageHeader title="Extensions" />
|
||||||
<Tabs :model-value="active.kind" class="mb-4" @update:model-value="(k) => router.replace({ query: { kind: String(k) } })">
|
<ReadError v-if="error" :message="error" retry-label="Retry" @retry="reload" />
|
||||||
<TabsList variant="line" class="w-full justify-start">
|
<template v-else-if="active">
|
||||||
<TabsTrigger v-for="k in KINDS" :key="k.kind" :value="k.kind" class="flex-none px-3">{{ k.label }}</TabsTrigger>
|
<Tabs :model-value="active.kind" class="mb-4" @update:model-value="(k) => router.replace({ query: { kind: String(k) } })">
|
||||||
</TabsList>
|
<div class="flex flex-wrap gap-x-6 gap-y-3">
|
||||||
</Tabs>
|
<div v-for="group in groups" :key="group.id">
|
||||||
<ExtensionList :key="active.kind" :kind="active.kind" :noun="active.noun" />
|
<h2 class="mb-1 text-caption text-fg-subtle">{{ group.label }}</h2>
|
||||||
|
<TabsList variant="line" class="justify-start">
|
||||||
|
<TabsTrigger v-for="k in group.kinds" :key="k.kind" :value="k.kind" class="flex-none px-3">{{ k.label }}</TabsTrigger>
|
||||||
|
</TabsList>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Tabs>
|
||||||
|
<ExtensionList :key="active.kind" :kind="active.kind" :noun="active.singular" />
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
Reference in new issue
Block a user