feat(webui): Plugins and Container runtime settings pages; Advanced keeps only dangerous actions

Plugins: the four extension directories. Container runtime: image, pull
policy (missing or always, the two the daemon accepts), concurrency,
uptime and volume retention as durations, network, and named profiles
with their image and tool allowlist. Advanced now holds only stop and
rollback, and the Managed elsewhere card goes. With every settings kind on
its own page, the generic schema-driven resource editor had no consumer
and is deleted.
This commit is contained in:
sam committed 2026-09-25 15:32:20 +10:00
1 parent b5c98a0ccc
commit 049bbf2a7d
14 files changed
+265 -755

No files matched your search

+7 -2
View File
@@ -34,7 +34,6 @@ const settings: NavSpec = {
"/settings/curators",
"/settings/schedules",
"/settings/scheduling-policy",
"/settings/advanced",
],
},
{
@@ -44,11 +43,17 @@ const settings: NavSpec = {
"/settings/repositories",
"/settings/identities",
"/settings/tools",
"/settings/plugins",
],
},
{
label: "Runtime",
paths: ["/settings/task-execution", "/settings/status"],
paths: [
"/settings/task-execution",
"/settings/container-runtime",
"/settings/status",
"/settings/advanced",
],
},
{ paths: ["/settings/history"] },
],
+27 -1
View File
@@ -10,6 +10,8 @@ import ToolsPage from "@/settings/ToolsPage.vue";
import HistoryPage from "@/settings/HistoryPage.vue";
import PersonasPage from "@/settings/PersonasPage.vue";
import SchedulesPage from "@/settings/SchedulesPage.vue";
import PluginsPage from "@/settings/PluginsPage.vue";
import ContainerRuntimePage from "@/settings/ContainerRuntimePage.vue";
import SystemAdvancedPage from "@/settings/SystemAdvancedPage.vue";
import SystemIdentitiesPage from "@/settings/SystemIdentitiesPage.vue";
import SystemAppearancePage from "@/settings/SystemAppearancePage.vue";
@@ -244,6 +246,30 @@ const routes = [
section: "settings",
},
},
{
path: "/settings/plugins",
name: "settings-plugins",
component: PluginsPage,
meta: {
navPath: "/settings",
settings: true,
label: "Plugins",
description: "Directories Archie loads extensions from at startup.",
section: "settings",
},
},
{
path: "/settings/container-runtime",
name: "settings-container-runtime",
component: ContainerRuntimePage,
meta: {
navPath: "/settings",
settings: true,
label: "Container runtime",
description: "The containers agents run in.",
section: "settings",
},
},
{
path: "/settings/advanced",
name: "system-advanced",
@@ -252,7 +278,7 @@ const routes = [
navPath: "/settings",
settings: true,
label: "Advanced",
description: "Identity, storage, sandboxing, and dangerous actions.",
description: "Actions that stop or roll back archied.",
section: "settings",
},
},
+146
View File
@@ -0,0 +1,146 @@
<script setup lang="ts">
import { computed, onMounted, ref } from "vue";
import { storeToRefs } from "pinia";
import { Plus, Trash2 } from "@lucide/vue";
import PageHeader from "@/base/PageHeader.vue";
import { Button } from "@/components/ui/button";
import { DurationInput } from "@/components/ui/duration-input";
import { Input } from "@/components/ui/input";
import {
NumberField,
NumberFieldContent,
NumberFieldDecrement,
NumberFieldIncrement,
NumberFieldInput,
} from "@/components/ui/number-field";
import { SegmentedControl } from "@/components/ui/segmented-control";
import { SettingRow } from "@/components/ui/setting-row";
import { StatusPill } from "@/components/ui/status-pill";
import {
TagsInput,
TagsInputInput,
TagsInputItem,
TagsInputItemDelete,
TagsInputItemText,
} from "@/components/ui/tags-input";
import { resourcesForPage, useControlPlaneStore } from "@/stores/control-plane";
import HistoryLink from "./HistoryLink.vue";
const KIND = "container-runtime-policies";
// The document is config.ContainerConfig on the wire, so its keys are Go
// field names until archie-core-qna6 gives it a snake_case contract.
interface ContainerRuntime {
Image: string;
MaxConcurrency: number;
MaxUptime: string;
VolumeTTL: string;
PullPolicy: string;
Network: string;
Profiles: Record<string, { Image: string; Tools: string[] | null }> | null;
}
const store = useControlPlaneStore();
const { catalog, catalogError } = storeToRefs(store);
onMounted(store.load);
const resources = computed(() => resourcesForPage(catalog.value, "containers"));
const runtime = computed(() => store.drafts[KIND]?.value as ContainerRuntime | undefined);
const error = computed(() => store.stateFor(KIND).error);
const pullPolicies = [
{ value: "missing", label: "If missing" },
{ value: "always", label: "Always" },
];
const pullPolicy = computed({
get: () => runtime.value?.PullPolicy || "missing",
set: (value: string) => {
if (runtime.value) runtime.value.PullPolicy = value;
},
});
const newProfile = ref("");
function addProfile() {
const name = newProfile.value.trim();
if (!runtime.value || !name) return;
runtime.value.Profiles ??= {};
if (runtime.value.Profiles[name]) return;
runtime.value.Profiles[name] = { Image: "", Tools: [] };
newProfile.value = "";
}
</script>
<template>
<div>
<PageHeader title="Container runtime">
<HistoryLink :kinds="resources.map((r) => r.kind)" />
<StatusPill tone="warn">Applies after restart</StatusPill>
</PageHeader>
<p class="-mt-4 mb-8 text-sm text-fg-muted">The containers agents run in.</p>
<p v-if="catalogError || error" class="mb-4 text-sm text-danger" role="alert">{{ catalogError || error }}</p>
<template v-if="runtime">
<SettingRow label="Image" for="cr-image" hint="The agent image tasks run in by default.">
<Input id="cr-image" v-model="runtime.Image" class="font-mono" />
</SettingRow>
<SettingRow label="Pull policy" hint="If missing pulls only when the image is not present locally.">
<SegmentedControl v-model="pullPolicy" label="Pull policy" :options="pullPolicies" />
</SettingRow>
<SettingRow label="Max concurrency" hint="Tasks and containers at once. Tasks in one repository still run one at a time. 0 means no limit.">
<NumberField v-model="runtime.MaxConcurrency" :min="0" class="w-32">
<NumberFieldContent>
<NumberFieldDecrement />
<NumberFieldInput class="font-mono" aria-label="Max concurrency" />
<NumberFieldIncrement />
</NumberFieldContent>
</NumberField>
</SettingRow>
<SettingRow label="Max uptime" for="cr-uptime" hint="A container is recycled after running this long.">
<DurationInput id="cr-uptime" v-model="runtime.MaxUptime" :units="['m', 'h']" />
</SettingRow>
<SettingRow label="Volume retention" for="cr-ttl" hint="Per-repository storage and the Git object cache are cleaned up after this long.">
<DurationInput id="cr-ttl" v-model="runtime.VolumeTTL" :units="['h']" />
</SettingRow>
<SettingRow label="Network" for="cr-network" hint="Docker network agents join. Empty uses the daemon's own network, then the default bridge.">
<Input id="cr-network" v-model="runtime.Network" class="max-w-sm font-mono" />
</SettingRow>
<h2 class="mt-10 mb-1 text-[11px] font-medium tracking-[0.06em] text-fg-subtle uppercase">Profiles</h2>
<p class="mb-3 text-xs text-fg-subtle">Named environments a workflow picks with <span class="font-mono">profile:</span>.</p>
<section
v-for="(profile, name) in runtime.Profiles ?? {}"
:key="name"
class="mb-3 rounded-lg border border-border bg-card px-5 pt-3 pb-2"
:aria-label="`Profile ${name}`"
>
<header class="flex items-center">
<h3 class="flex-1 font-mono text-sm font-medium">{{ name }}</h3>
<Button variant="ghost" size="icon" :aria-label="`Remove profile ${name}`" @click="delete runtime.Profiles![name]"><Trash2 /></Button>
</header>
<SettingRow label="Image" :for="`prof-${name}-image`" hint="Empty uses the default image.">
<Input :id="`prof-${name}-image`" v-model="profile.Image" class="font-mono" />
</SettingRow>
<SettingRow label="Tools" hint="MCP servers, repository scripts and skills allowed by name. Empty allows all.">
<TagsInput
:model-value="profile.Tools ?? []"
class="font-mono"
:aria-label="`Tools for ${name}`"
@update:model-value="(v) => (profile.Tools = v as string[])"
>
<TagsInputItem v-for="tool in profile.Tools ?? []" :key="tool" :value="tool">
<TagsInputItemText />
<TagsInputItemDelete />
</TagsInputItem>
<TagsInputInput placeholder="tool name" />
</TagsInput>
</SettingRow>
</section>
<div class="flex gap-2">
<Input v-model="newProfile" class="max-w-56 font-mono" placeholder="profile name" aria-label="New profile" @keydown.enter="addProfile" />
<Button variant="outline" size="sm" :disabled="!newProfile.trim()" @click="addProfile"><Plus data-icon="inline-start" /> Add profile</Button>
</div>
</template>
</div>
</template>
+55
View File
@@ -0,0 +1,55 @@
<script setup lang="ts">
import { computed, onMounted } from "vue";
import { storeToRefs } from "pinia";
import PageHeader from "@/base/PageHeader.vue";
import { Input } from "@/components/ui/input";
import { SettingRow } from "@/components/ui/setting-row";
import { StatusPill } from "@/components/ui/status-pill";
import { resourcesForPage, useControlPlaneStore } from "@/stores/control-plane";
import HistoryLink from "./HistoryLink.vue";
const KIND = "plugin-settings";
interface PluginSettings {
plugin_dir: string;
module_dir: string;
secret_engine_dir: string;
skills_dir: string;
}
const store = useControlPlaneStore();
const { catalog, catalogError } = storeToRefs(store);
onMounted(store.load);
const resources = computed(() => resourcesForPage(catalog.value, "plugins"));
const dirs = computed(() => store.drafts[KIND]?.value as PluginSettings | undefined);
const error = computed(() => store.stateFor(KIND).error);
</script>
<template>
<div>
<PageHeader title="Plugins">
<HistoryLink :kinds="resources.map((r) => r.kind)" />
<StatusPill tone="warn">Applies after restart</StatusPill>
</PageHeader>
<p class="-mt-4 mb-8 text-sm text-fg-muted">Directories Archie loads extensions from at startup.</p>
<p v-if="catalogError || error" class="mb-4 text-sm text-danger" role="alert">{{ catalogError || error }}</p>
<template v-if="dirs">
<SettingRow label="Plugin directory" for="pl-plugins" hint="Daemon plugins. Empty loads none.">
<Input id="pl-plugins" v-model="dirs.plugin_dir" class="max-w-md font-mono" />
</SettingRow>
<SettingRow label="Module directory" for="pl-modules" hint="Workflow modules. Empty loads none.">
<Input id="pl-modules" v-model="dirs.module_dir" class="max-w-md font-mono" />
</SettingRow>
<SettingRow label="Secret engine directory" for="pl-secrets" hint="Secret engine plugins. Empty uses the built-in engines only.">
<Input id="pl-secrets" v-model="dirs.secret_engine_dir" class="max-w-md font-mono" />
</SettingRow>
<SettingRow label="Skills directory" for="pl-skills" hint="Shared SKILL.md skills. Empty uses the work directory.">
<Input id="pl-skills" v-model="dirs.skills_dir" class="max-w-md font-mono" />
</SettingRow>
</template>
</div>
</template>
@@ -1,55 +0,0 @@
<script setup lang="ts">
import { computed } from "vue";
import { StatusPill } from "@/components/ui/status-pill";
import {
useControlPlaneStore,
type ResourceDescriptor,
} from "@/stores/control-plane";
import ConfigCard from "./ConfigCard.vue";
import StructuredValueEditor from "./StructuredValueEditor.vue";
import { parseSchema } from "./resource-schema";
const props = defineProps<{
descriptor: ResourceDescriptor;
rootPath?: string;
}>();
const store = useControlPlaneStore();
const state = computed(() => store.stateFor(props.descriptor.kind));
// The schema the descriptor derives from its document type: the editor reads
// it for labels, hints, formatted placeholders and the shape of a new row. A
// descriptor that carries none reads as null, and the editor falls back to
// rendering the value alone.
const schema = computed(() => parseSchema(props.descriptor.schema_json));
// Edits land in the store's draft; the Settings save bar saves every edited
// resource together.
const draft = computed({
get: () => store.drafts[props.descriptor.kind]?.value,
set: (value) => {
const current = store.drafts[props.descriptor.kind];
if (current) current.value = value;
},
});
const edited = computed(() => store.changesFor(props.descriptor.kind).length > 0);
</script>
<template>
<ConfigCard :title="descriptor.title" :edited="edited">
<template v-if="descriptor.apply_mode === 'restart-required'" #action>
<StatusPill tone="warn">Applies after restart</StatusPill>
</template>
<div v-if="draft !== undefined" class="space-y-5">
<StructuredValueEditor
v-model="draft"
:path="rootPath ?? descriptor.kind"
:root-path="rootPath ?? descriptor.kind"
:schema="schema"
/>
<p v-if="state.error" class="text-sm text-destructive" role="alert">
{{ state.error }}
</p>
</div>
</ConfigCard>
</template>
-266
View File
@@ -1,266 +0,0 @@
<script setup lang="ts">
import { computed } from "vue";
import { Plus, Trash2 } from "@lucide/vue";
import { Button } from "@/components/ui/button";
import { Checkbox } from "@/components/ui/checkbox";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { Textarea } from "@/components/ui/textarea";
import {
blankFromSchema,
fieldHint,
fieldPlaceholder,
fieldTitle,
schemaAt,
type SchemaProperty,
} from "./resource-schema";
/**
* The document editor, driven by the value it was given and annotated by the
* schema the descriptor carries.
*
* The value decides which fields exist (this walks what is stored, so a
* document with a field the schema has not caught up with still edits); the
* schema decides what those fields are called, what example a formatted field
* shows, what prose qualifies it, and what a newly added row starts as. A
* descriptor with no schema, or one describing nothing, renders exactly as it
* did before there was a reader.
*/
const props = withDefaults(
defineProps<{
modelValue: unknown;
path?: string;
rootPath?: string;
schema?: SchemaProperty | null;
locked?: boolean;
}>(),
{ path: "value", rootPath: "", schema: null, locked: false },
);
const emit = defineEmits<{ "update:modelValue": [value: unknown] }>();
const isArray = computed(() => Array.isArray(props.modelValue));
const isObject = computed(
() =>
props.modelValue !== null &&
typeof props.modelValue === "object" &&
!isArray.value,
);
const entries = computed(() =>
Object.entries((props.modelValue ?? {}) as Record<string, unknown>),
);
const readOnly = computed(
() =>
props.locked ||
/(^|\.)(has_credential|credential_configured|headers_configured)$/.test(
props.path,
),
);
/** The schema node for this editor, and for one of its keys. */
const property = computed(() =>
schemaAt(props.schema, props.path, props.rootPath),
);
function propertyFor(key: string): SchemaProperty | null {
return schemaAt(props.schema, `${props.path}.${key}`, props.rootPath);
}
function label(value: string): string {
return value
.replaceAll("_", " ")
.replace(/^./, (character) => character.toUpperCase());
}
function setObject(key: string, value: unknown): void {
emit("update:modelValue", {
...(props.modelValue as Record<string, unknown>),
[key]: value,
});
}
function renameObject(oldKey: string, newKey: string): void {
const current = { ...(props.modelValue as Record<string, unknown>) };
const value = current[oldKey];
delete current[oldKey];
current[newKey] = value;
emit("update:modelValue", current);
}
function removeObject(key: string): void {
const current = { ...(props.modelValue as Record<string, unknown>) };
delete current[key];
emit("update:modelValue", current);
}
function addObject(): void {
const current = props.modelValue as Record<string, unknown>;
let index = 1;
while (`new_${index}` in current) index++;
emit("update:modelValue", { ...current, [`new_${index}`]: "" });
}
function setArray(index: number, value: unknown): void {
const current = [...(props.modelValue as unknown[])];
current[index] = value;
emit("update:modelValue", current);
}
// A new row comes from the schema rather than from the path that holds it: the
// editor used to carry a literal skeleton per array path (a repository, an MCP
// server), which went stale the moment the document changed and said nothing
// about fields it did not know.
function addArray(): void {
const current = props.modelValue as unknown[];
emit("update:modelValue", [
...current,
blankFromSchema(property.value?.items),
]);
}
function removeArray(index: number): void {
emit(
"update:modelValue",
(props.modelValue as unknown[]).filter(
(_, itemIndex) => itemIndex !== index,
),
);
}
function scalar(value: string | number): void {
emit(
"update:modelValue",
typeof props.modelValue === "number" ? Number(value) : value,
);
}
</script>
<template>
<div v-if="isArray" class="space-y-2 rounded-lg border border-border/70 p-3">
<div
v-for="(item, index) in modelValue as unknown[]"
:key="index"
class="flex items-start gap-2"
>
<div class="min-w-0 flex-1">
<StructuredValueEditor
:model-value="item"
:path="`${path}.${index}`"
:root-path="rootPath"
:schema="schema"
@update:model-value="setArray(index, $event)"
/>
</div>
<Button
type="button"
variant="ghost"
size="icon-sm"
:aria-label="`Remove ${label(path)} row ${index + 1}`"
@click="removeArray(index)"
>
<Trash2 />
</Button>
</div>
<Button type="button" variant="outline" size="sm" @click="addArray"
><Plus /> Add row</Button
>
</div>
<fieldset
v-else-if="isObject"
class="space-y-4 rounded-lg border border-border/70 p-3"
>
<div v-for="[key, value] in entries" :key="key" class="space-y-1.5">
<div class="flex items-center gap-2">
<Label :for="`${path}.${key}`" class="flex-1">{{
fieldTitle(key, propertyFor(key))
}}</Label>
<template
v-if="
path.endsWith('_map') ||
path.endsWith('labels') ||
path === 'providers' ||
path === 'roles'
"
>
<Input
class="h-7 max-w-48"
:model-value="key"
aria-label="Entry key"
@change="
renameObject(key, ($event.target as HTMLInputElement).value)
"
/>
<Button
type="button"
variant="ghost"
size="icon-sm"
:aria-label="`Remove ${key}`"
@click="removeObject(key)"
><Trash2
/></Button>
</template>
</div>
<p v-if="fieldHint(propertyFor(key))" class="text-xs text-fg-subtle">
{{ fieldHint(propertyFor(key)) }}
</p>
<StructuredValueEditor
:id="`${path}.${key}`"
:model-value="value"
:path="`${path}.${key}`"
:root-path="rootPath"
:schema="schema"
@update:model-value="setObject(key, $event)"
/>
</div>
<Button
v-if="
path.endsWith('_map') ||
path.endsWith('labels') ||
path === 'providers' ||
path === 'roles'
"
type="button"
variant="outline"
size="sm"
@click="addObject"
><Plus /> Add entry</Button
>
</fieldset>
<div
v-else-if="typeof modelValue === 'boolean'"
class="flex min-h-9 items-center gap-2"
>
<Checkbox
:id="path"
:model-value="modelValue"
:disabled="readOnly"
@update:model-value="emit('update:modelValue', $event === true)"
/>
<span v-if="readOnly" class="text-xs text-muted-foreground"
>Reported by Archie</span
>
</div>
<Textarea
v-else-if="path.endsWith('.prompt')"
:id="path"
:model-value="modelValue as string"
:readonly="readOnly"
autocomplete="off"
@update:model-value="scalar"
/>
<div v-else class="space-y-1">
<Input
:id="path"
:model-value="modelValue as string | number"
:type="typeof modelValue === 'number' ? 'number' : 'text'"
:readonly="readOnly"
:placeholder="fieldPlaceholder(property)"
autocomplete="off"
@update:model-value="scalar"
/>
<p v-if="fieldHint(property)" class="text-xs text-fg-subtle">
{{ fieldHint(property) }}
</p>
</div>
</template>
+3 -46
View File
@@ -1,59 +1,16 @@
<script setup lang="ts">
import HistoryLink from "@/settings/HistoryLink.vue";
import { computed, onMounted } from "vue";
import { storeToRefs } from "pinia";
import { onMounted } from "vue";
import PageHeader from "@/base/PageHeader.vue";
import { Button } from "@/components/ui/button";
import { resourcesForPage, useControlPlaneStore } from "@/stores/control-plane";
import ConfigCard from "./ConfigCard.vue";
import DangerousActionsCard from "./DangerousActionsCard.vue";
import StructuredResourceCard from "./StructuredResourceCard.vue";
import { loadDangerous } from "./state";
const controlPlane = useControlPlaneStore();
const { catalog, catalogError } = storeToRefs(controlPlane);
const resources = computed(() => resourcesForPage(catalog.value, "advanced"));
async function load(): Promise<void> {
await Promise.all([controlPlane.load(), loadDangerous()]);
}
onMounted(load);
onMounted(loadDangerous);
</script>
<template>
<div>
<PageHeader title="Advanced">
<HistoryLink :kinds="resources.map((r) => r.kind)" />
</PageHeader>
<p v-if="catalogError" class="text-sm text-destructive" role="alert">
{{ catalogError }}
</p>
<StructuredResourceCard
v-for="descriptor in resources"
:key="descriptor.kind"
:descriptor="descriptor"
/>
<ConfigCard title="Managed elsewhere">
<div class="flex flex-wrap gap-2">
<Button as-child variant="outline"
><RouterLink :to="'/events?tab=inspector'"
>Captured events</RouterLink
></Button
>
<Button as-child variant="outline"
><RouterLink :to="'/events?tab=mappings'"
>Capture mappings</RouterLink
></Button
>
<Button as-child variant="outline"
><RouterLink :to="'/events?tab=bindings'"
>Capture bindings</RouterLink
></Button
>
</div>
</ConfigCard>
<PageHeader title="Advanced" />
<DangerousActionsCard />
</div>
</template>
-164
View File
@@ -1,164 +0,0 @@
/**
* Reading the JSON Schema a control-plane descriptor advertises.
*
* The descriptor's schema is derived in internal/app/controlplane/schema.go
* from the Go type of the document itself, so it is structure only: keys,
* types, and the `format`/`title`/`doc` annotations a field declares in its own
* tags. It carries no prose of its own -- field descriptions have one home in
* internal/webui/config_schema.go -- so everything here treats a missing
* annotation as absent rather than inventing one.
*
* The live editor is value-driven (it walks the document it was given), so this
* is metadata layered onto fields that exist, never a field list. A document
* whose schema describes no properties renders exactly as it did before.
*/
/** One node of the derived schema. Only what the derivation emits is read. */
export interface SchemaProperty {
type?: string;
format?: string;
title?: string;
description?: string;
properties?: Record<string, SchemaProperty>;
items?: SchemaProperty;
additionalProperties?: SchemaProperty | boolean;
}
/**
* parseSchema reads a descriptor's schema_json. A descriptor that carries none,
* or carries one this reader cannot parse, reports null: an unreadable schema
* costs a placeholder, never a field.
*/
export function parseSchema(
json: string | null | undefined,
): SchemaProperty | null {
if (!json) return null;
try {
const parsed: unknown = JSON.parse(json);
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed))
return null;
return parsed as SchemaProperty;
} catch {
return null;
}
}
function isKeyed(property: SchemaProperty): boolean {
return (
property.type === "object" &&
!property.properties &&
typeof property.additionalProperties === "object"
);
}
/**
* schemaAt resolves the property that describes one editor path.
*
* Paths are the editor's own (`repositories.0.owner`): dotted, with an array
* item addressed by its index. `rootPath` is stripped first, because the
* editor's path starts at the document rather than inside it -- the schema
* describes the document, not a field of it.
*/
export function schemaAt(
schema: SchemaProperty | null,
path: string,
rootPath = "",
): SchemaProperty | null {
if (!schema) return null;
const root = rootPath.split(".").filter(Boolean);
let segments = path.split(".").filter(Boolean);
if (
root.length &&
root.every((segment, index) => segments[index] === segment)
) {
segments = segments.slice(root.length);
}
let current: SchemaProperty | null = schema;
for (const segment of segments) {
if (!current) return null;
if (/^\d+$/.test(segment)) {
current = current.items ?? null;
continue;
}
const named = current.properties?.[segment];
if (named) {
current = named;
continue;
}
// A keyed collection's keys belong to the operator, so the value's
// schema describes whatever key they typed.
current =
typeof current.additionalProperties === "object"
? current.additionalProperties
: null;
}
return current;
}
/** fieldTitle is the schema's own label for a key, or the dashed-key fallback
* the editor has always used. */
export function fieldTitle(
key: string,
property: SchemaProperty | null | undefined,
): string {
if (property?.title) return property.title;
return key
.replaceAll("_", " ")
.replace(/^./, (character) => character.toUpperCase());
}
/**
* fieldPlaceholder offers an example only where the schema declares a format
* the field's value must match. A duration column is a string to the document
* and a duration to the operator, and the example is what says so.
*/
export function fieldPlaceholder(
property: SchemaProperty | null | undefined,
): string | undefined {
if (property?.format === "duration") return "1m0s";
if (property?.format === "date-time") return "2026-01-01T00:00:00Z";
return undefined;
}
/** fieldHint is the schema's own prose for a field, empty when it has none. */
export function fieldHint(property: SchemaProperty | null | undefined): string {
return property?.description ?? "";
}
/** isKeyedCollection reports a document whose keys are the operator's: a map
* with no fixed properties, which the schema marks with additionalProperties. */
export function isKeyedCollection(
property: SchemaProperty | null | undefined,
): boolean {
return Boolean(property) && isKeyed(property as SchemaProperty);
}
/**
* blankFromSchema synthesises a new row from the schema rather than from the
* path that happens to hold it.
*
* The editor used to carry a literal template per array path -- a repository
* skeleton, an MCP server skeleton -- which went stale the moment the document
* was reshaped, and said nothing about the fields it did not know. A blank from
* the schema cannot be stale, because the schema is derived from the document.
* What it loses is the seeded convenience value (a default branch name, say):
* a schema that wants those emits a default, which is the same single source of
* truth this reader exists to honour.
*/
export function blankFromSchema(
property: SchemaProperty | null | undefined,
): unknown {
if (!property) return "";
if (property.type === "object") {
const blank: Record<string, unknown> = {};
for (const [key, child] of Object.entries(property.properties ?? {})) {
blank[key] = blankFromSchema(child);
}
return blank;
}
if (property.type === "array") return [];
if (property.type === "boolean") return false;
if (property.type === "integer" || property.type === "number") return 0;
return "";
}
+4 -5
View File
@@ -167,7 +167,8 @@ export type ControlPlanePage =
| "tools"
| "personas"
| "schedules"
| "advanced"
| "plugins"
| "containers"
| "workflows";
const PAGE_RESOURCES: Record<ControlPlanePage, string[]> = {
@@ -179,10 +180,8 @@ const PAGE_RESOURCES: Record<ControlPlanePage, string[]> = {
tools: ["tool-settings"],
personas: ["personas"],
schedules: ["schedules"],
advanced: [
"plugin-settings",
"container-runtime-policies",
],
plugins: ["plugin-settings"],
containers: ["container-runtime-policies"],
workflows: ["workflow-definitions"],
};