The task session carries containers.egress_hosts and the profile's remote MCP hosts, and the container gets ProxyEnv with the relay exempt from the proxy so the State Store and NATS dials bypass it. A host the session lists exactly may resolve to a private address; wildcard and any-host matches may not. egress_hosts moves from openshell to containers, as it applies to both runtimes.
379 lines
15 KiB
Vue
379 lines
15 KiB
Vue
<script setup lang="ts">
|
|
import { Alert, AlertDescription } from "@/components/ui/alert";
|
|
import ApplyStatusRows from "./ApplyStatusRows.vue";
|
|
import { computed, onMounted } from "vue";
|
|
import { storeToRefs } from "pinia";
|
|
import { TriangleAlert } from "@lucide/vue";
|
|
|
|
import PageHeader from "@/base/PageHeader.vue";
|
|
import { DurationInput } from "@/components/ui/duration-input";
|
|
import { parseGoDuration } from "@/components/ui/duration-input/duration";
|
|
import { Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel } from "@/components/ui/field";
|
|
import { Input } from "@/components/ui/input";
|
|
import {
|
|
NumberField,
|
|
NumberFieldContent,
|
|
NumberFieldDecrement,
|
|
NumberFieldIncrement,
|
|
NumberFieldInput,
|
|
} from "@/components/ui/number-field";
|
|
import {
|
|
TagsInput,
|
|
TagsInputInput,
|
|
TagsInputItem,
|
|
TagsInputItemDelete,
|
|
TagsInputItemText,
|
|
} from "@/components/ui/tags-input";
|
|
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
|
|
import { resourcesForPage, useSettingsStore } from "@/stores/settings";
|
|
import DraftHint from "./DraftHint.vue";
|
|
import HistoryLink from "./HistoryLink.vue";
|
|
import KindGate from "./KindGate.vue";
|
|
import SecretRefField from "./SecretRefField.vue";
|
|
import { fieldInvalid } from "./settings-form";
|
|
|
|
const KIND = "container-runtime-policies";
|
|
const EXECUTION_KIND = "workflow-execution-settings";
|
|
// The server's own default when execution settings predate the task limit.
|
|
const DEFAULT_TASK_RUNTIME_SECONDS = 4 * 60 * 60;
|
|
|
|
// The stored document is containerRuntimePolicies on the wire: snake_case keys
|
|
// and durations as Go duration strings.
|
|
interface ContainerRuntime {
|
|
image: string;
|
|
max_concurrency: number;
|
|
max_uptime: string;
|
|
volume_ttl: string;
|
|
pull_policy: string;
|
|
network: string;
|
|
runtime: string;
|
|
openshell: {
|
|
address: string;
|
|
workspace: string;
|
|
token: { engine: string; key: string };
|
|
ca_file: string;
|
|
cert_file: string;
|
|
key_file: string;
|
|
services_host: string;
|
|
};
|
|
egress_hosts: string[];
|
|
}
|
|
|
|
const store = useSettingsStore();
|
|
const { catalog, catalogError } = storeToRefs(store);
|
|
onMounted(store.load);
|
|
|
|
const resources = computed(() => resourcesForPage(catalog.value, "containers"));
|
|
const form = computed(() => store.formFor(KIND));
|
|
const runtime = computed(() => store.draftValue(KIND) as ContainerRuntime | undefined);
|
|
const error = computed(() => store.pageErrorFor(KIND));
|
|
|
|
const runtimes = [
|
|
{ value: "docker", label: "Docker" },
|
|
{ value: "openshell", label: "OpenShell" },
|
|
];
|
|
const onOpenShell = computed(() => runtime.value?.runtime === "openshell");
|
|
|
|
const pullPolicies = [
|
|
{ value: "missing", label: "If missing" },
|
|
{ value: "always", label: "Always" },
|
|
];
|
|
|
|
// The daemon kills a container at max uptime, so a task limit longer than it
|
|
// can never be reached. Mirrors the warning archied logs when it applies them.
|
|
const uptimeWarning = computed(() => {
|
|
const uptime = parseGoDuration(runtime.value?.max_uptime ?? "");
|
|
if (!uptime) return "";
|
|
const execution = store.draftValue(EXECUTION_KIND) as { max_task_runtime_seconds?: number | null } | undefined;
|
|
const limitSeconds = execution?.max_task_runtime_seconds ?? DEFAULT_TASK_RUNTIME_SECONDS;
|
|
if (limitSeconds > 0 && limitSeconds * 1000 <= uptime) return "";
|
|
const limit = limitSeconds > 0 ? `the ${formatHours(limitSeconds)} task limit` : "the task limit, which is off";
|
|
return `Shorter than ${limit}, so containers are killed before a task can finish.`;
|
|
});
|
|
|
|
function formatHours(seconds: number): string {
|
|
return seconds % 3600 === 0 ? `${seconds / 3600}h` : `${Math.round(seconds / 60)}m`;
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<div>
|
|
<PageHeader title="Container runtime">
|
|
<HistoryLink :kinds="resources.map((r) => r.kind)" />
|
|
</PageHeader>
|
|
<ApplyStatusRows v-for="resource in resources" :key="resource.kind" :kind="resource.kind" class="mb-4" />
|
|
|
|
<Alert v-if="catalogError || error" variant="destructive" class="mb-4"><AlertDescription>{{ catalogError || error }}</AlertDescription></Alert>
|
|
|
|
<KindGate v-if="!form" :kind="KIND" />
|
|
<div v-if="form" class="flex flex-col gap-5">
|
|
<FieldGroup v-if="form" class="@container/field-group">
|
|
<form.Field v-slot="{ field }" name="runtime">
|
|
<Field orientation="responsive">
|
|
<FieldContent>
|
|
<FieldLabel>Runtime</FieldLabel>
|
|
<FieldDescription>Applies on restart.</FieldDescription>
|
|
</FieldContent>
|
|
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
|
<ToggleGroup
|
|
type="single"
|
|
variant="outline"
|
|
size="sm"
|
|
:model-value="field.state.value || 'docker'"
|
|
aria-label="Runtime"
|
|
@update:model-value="(value) => { if (value) field.handleChange(value); }"
|
|
>
|
|
<ToggleGroupItem v-for="option in runtimes" :key="option.value" :value="option.value">{{ option.label }}</ToggleGroupItem>
|
|
</ToggleGroup>
|
|
<DraftHint :kind="KIND" path="runtime" />
|
|
</div>
|
|
</Field>
|
|
</form.Field>
|
|
</FieldGroup>
|
|
|
|
<FieldGroup v-if="form && onOpenShell" class="@container/field-group">
|
|
<form.Field v-slot="{ field }" name="openshell.address">
|
|
<Field orientation="responsive">
|
|
<FieldContent><FieldLabel for="cr-os-address">Gateway</FieldLabel></FieldContent>
|
|
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
|
<Input
|
|
id="cr-os-address"
|
|
:model-value="field.state.value"
|
|
class="max-w-sm font-mono"
|
|
@blur="field.handleBlur"
|
|
@update:model-value="field.handleChange"
|
|
/>
|
|
<DraftHint :kind="KIND" path="openshell.address" />
|
|
</div>
|
|
</Field>
|
|
</form.Field>
|
|
|
|
<form.Field v-slot="{ field }" name="openshell.workspace">
|
|
<Field orientation="responsive">
|
|
<FieldContent><FieldLabel for="cr-os-workspace">Workspace</FieldLabel></FieldContent>
|
|
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
|
<Input
|
|
id="cr-os-workspace"
|
|
:model-value="field.state.value"
|
|
class="max-w-sm font-mono"
|
|
placeholder="default"
|
|
@blur="field.handleBlur"
|
|
@update:model-value="field.handleChange"
|
|
/>
|
|
<DraftHint :kind="KIND" path="openshell.workspace" />
|
|
</div>
|
|
</Field>
|
|
</form.Field>
|
|
|
|
<form.Field v-slot="{ field }" name="openshell.token">
|
|
<Field orientation="responsive">
|
|
<FieldContent><FieldLabel>Token</FieldLabel></FieldContent>
|
|
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
|
<SecretRefField
|
|
:model-value="field.state.value ?? { engine: '', key: '' }"
|
|
id-prefix="cr-os-token"
|
|
@update:model-value="field.handleChange"
|
|
/>
|
|
<DraftHint :kind="KIND" path="openshell.token" />
|
|
</div>
|
|
</Field>
|
|
</form.Field>
|
|
|
|
<form.Field v-slot="{ field }" name="openshell.ca_file">
|
|
<Field orientation="responsive">
|
|
<FieldContent><FieldLabel for="cr-os-ca-file">CA file</FieldLabel></FieldContent>
|
|
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
|
<Input
|
|
id="cr-os-ca-file"
|
|
:model-value="field.state.value"
|
|
class="max-w-sm font-mono"
|
|
@blur="field.handleBlur"
|
|
@update:model-value="field.handleChange"
|
|
/>
|
|
<DraftHint :kind="KIND" path="openshell.ca_file" />
|
|
</div>
|
|
</Field>
|
|
</form.Field>
|
|
|
|
<form.Field v-slot="{ field }" name="openshell.cert_file">
|
|
<Field orientation="responsive">
|
|
<FieldContent><FieldLabel for="cr-os-cert-file">Client certificate</FieldLabel></FieldContent>
|
|
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
|
<Input
|
|
id="cr-os-cert-file"
|
|
:model-value="field.state.value"
|
|
class="max-w-sm font-mono"
|
|
@blur="field.handleBlur"
|
|
@update:model-value="field.handleChange"
|
|
/>
|
|
<DraftHint :kind="KIND" path="openshell.cert_file" />
|
|
</div>
|
|
</Field>
|
|
</form.Field>
|
|
|
|
<form.Field v-slot="{ field }" name="openshell.key_file">
|
|
<Field orientation="responsive">
|
|
<FieldContent><FieldLabel for="cr-os-key-file">Client key</FieldLabel></FieldContent>
|
|
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
|
<Input
|
|
id="cr-os-key-file"
|
|
:model-value="field.state.value"
|
|
class="max-w-sm font-mono"
|
|
@blur="field.handleBlur"
|
|
@update:model-value="field.handleChange"
|
|
/>
|
|
<DraftHint :kind="KIND" path="openshell.key_file" />
|
|
</div>
|
|
</Field>
|
|
</form.Field>
|
|
|
|
<form.Field v-slot="{ field }" name="openshell.services_host">
|
|
<Field orientation="responsive">
|
|
<FieldContent><FieldLabel for="cr-os-services-host">Services host</FieldLabel></FieldContent>
|
|
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
|
<Input
|
|
id="cr-os-services-host"
|
|
:model-value="field.state.value"
|
|
class="max-w-sm font-mono"
|
|
@blur="field.handleBlur"
|
|
@update:model-value="field.handleChange"
|
|
/>
|
|
<DraftHint :kind="KIND" path="openshell.services_host" />
|
|
</div>
|
|
</Field>
|
|
</form.Field>
|
|
</FieldGroup>
|
|
|
|
<FieldGroup v-if="form" class="@container/field-group">
|
|
<form.Field v-slot="{ field }" name="image">
|
|
<Field orientation="responsive" :data-invalid="fieldInvalid(field)">
|
|
<FieldContent><FieldLabel for="cr-image">Image</FieldLabel></FieldContent>
|
|
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
|
<Input
|
|
id="cr-image"
|
|
:model-value="field.state.value"
|
|
class="font-mono"
|
|
:aria-invalid="fieldInvalid(field)"
|
|
@blur="field.handleBlur"
|
|
@update:model-value="field.handleChange"
|
|
/>
|
|
<DraftHint :kind="KIND" path="image" />
|
|
</div>
|
|
</Field>
|
|
</form.Field>
|
|
|
|
<form.Field v-slot="{ field }" name="pull_policy">
|
|
<Field orientation="responsive">
|
|
<FieldContent><FieldLabel>Pull policy</FieldLabel></FieldContent>
|
|
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
|
<ToggleGroup
|
|
type="single"
|
|
variant="outline"
|
|
size="sm"
|
|
:model-value="field.state.value || 'missing'"
|
|
aria-label="Pull policy"
|
|
@update:model-value="(value) => { if (value) field.handleChange(value); }"
|
|
>
|
|
<ToggleGroupItem v-for="option in pullPolicies" :key="option.value" :value="option.value">{{ option.label }}</ToggleGroupItem>
|
|
</ToggleGroup>
|
|
<DraftHint :kind="KIND" path="pull_policy" />
|
|
</div>
|
|
</Field>
|
|
</form.Field>
|
|
|
|
<form.Field v-slot="{ field }" name="max_concurrency">
|
|
<Field orientation="responsive">
|
|
<FieldContent>
|
|
<FieldLabel>Max concurrency</FieldLabel>
|
|
<FieldDescription>0 = no limit.</FieldDescription>
|
|
</FieldContent>
|
|
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
|
<NumberField :model-value="field.state.value" :min="0" class="w-32" @update:model-value="field.handleChange">
|
|
<NumberFieldContent>
|
|
<NumberFieldDecrement />
|
|
<NumberFieldInput class="font-mono" aria-label="Max concurrency" />
|
|
<NumberFieldIncrement />
|
|
</NumberFieldContent>
|
|
</NumberField>
|
|
<DraftHint :kind="KIND" path="max_concurrency" />
|
|
</div>
|
|
</Field>
|
|
</form.Field>
|
|
|
|
<form.Field v-slot="{ field }" name="max_uptime">
|
|
<Field orientation="responsive" :data-invalid="fieldInvalid(field)">
|
|
<FieldContent><FieldLabel for="cr-uptime">Max uptime</FieldLabel></FieldContent>
|
|
<div class="flex min-w-0 flex-col gap-2 @md/field-group:flex-1">
|
|
<FieldDescription v-if="uptimeWarning" class="flex items-start gap-1.5 text-warn" role="status">
|
|
<TriangleAlert class="mt-0.5 size-3.5 shrink-0" />
|
|
<span>{{ uptimeWarning }}</span>
|
|
</FieldDescription>
|
|
<div class="flex flex-wrap items-center gap-3">
|
|
<DurationInput
|
|
id="cr-uptime"
|
|
:model-value="field.state.value"
|
|
:units="['m', 'h']"
|
|
:aria-invalid="fieldInvalid(field)"
|
|
@update:model-value="field.handleChange"
|
|
/>
|
|
<DraftHint :kind="KIND" path="max_uptime" />
|
|
</div>
|
|
<FieldError v-if="fieldInvalid(field)" :errors="field.state.meta.errors" />
|
|
</div>
|
|
</Field>
|
|
</form.Field>
|
|
|
|
<form.Field v-slot="{ field }" name="volume_ttl">
|
|
<Field orientation="responsive">
|
|
<FieldContent><FieldLabel for="cr-ttl">Volume retention</FieldLabel></FieldContent>
|
|
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
|
<DurationInput id="cr-ttl" :model-value="field.state.value" :units="['h']" @update:model-value="field.handleChange" />
|
|
<DraftHint :kind="KIND" path="volume_ttl" />
|
|
</div>
|
|
</Field>
|
|
</form.Field>
|
|
|
|
<form.Field v-slot="{ field }" name="network">
|
|
<Field orientation="responsive">
|
|
<FieldContent>
|
|
<FieldLabel for="cr-network">Network</FieldLabel>
|
|
<FieldDescription>Empty: auto-detect.</FieldDescription>
|
|
</FieldContent>
|
|
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
|
<Input
|
|
id="cr-network"
|
|
:model-value="field.state.value"
|
|
class="max-w-sm font-mono"
|
|
@blur="field.handleBlur"
|
|
@update:model-value="field.handleChange"
|
|
/>
|
|
<DraftHint :kind="KIND" path="network" />
|
|
</div>
|
|
</Field>
|
|
</form.Field>
|
|
|
|
<form.Field v-slot="{ field }" name="egress_hosts">
|
|
<Field orientation="responsive">
|
|
<FieldContent><FieldLabel>Egress hosts</FieldLabel></FieldContent>
|
|
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
|
<TagsInput
|
|
:model-value="field.state.value ?? []"
|
|
class="font-mono"
|
|
aria-label="Egress hosts"
|
|
@update:model-value="(v) => field.handleChange(v as string[])"
|
|
>
|
|
<TagsInputItem v-for="h in field.state.value ?? []" :key="h" :value="h">
|
|
<TagsInputItemText />
|
|
<TagsInputItemDelete />
|
|
</TagsInputItem>
|
|
<TagsInputInput placeholder="*.example.com:443" />
|
|
</TagsInput>
|
|
<DraftHint :kind="KIND" path="egress_hosts" />
|
|
</div>
|
|
</Field>
|
|
</form.Field>
|
|
</FieldGroup>
|
|
</div>
|
|
</div>
|
|
</template>
|