fix(shell): separate wait, idle, and runtime limits (#6228)
* fix(shell): separate wait, idle, and runtime limits * fix(shell): separate wait, idle, and runtime limits * fix(exec): preserve settings aliases and reclaim completed sessions * fix(webui): make shell runtime limits explicit
This commit is contained in:
1 parent
70ac000ad9
commit
6310a39bac
36 files changed
+2392
-564
No files matched your search
@@ -6,6 +6,7 @@ import { SettingsGroup, SettingsRow, SettingsSectionTitle, RestartRequiredNotice
|
||||
import { ProviderPicker } from "@/components/settings/shared/ModelControls";
|
||||
import { TimezonePicker } from "@/components/settings/shared/TimezonePicker";
|
||||
import { SettingsTextEditor } from "@/components/settings/shared/SettingsTextEditor";
|
||||
import { ShellRuntimeControl } from "@/components/settings/system/ShellRuntimeControl";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { RUNTIME_CONFIG_FIELDS, RUNTIME_CONFIG_GROUPS, type RuntimeConfigField, type RuntimeConfigPage } from "@/components/settings/system/runtime-config-fields";
|
||||
import { updateRuntimeConfigSettings } from "@/lib/api";
|
||||
@@ -59,6 +60,11 @@ export function useRuntimeConfigSettings(
|
||||
setErrors((prev) => ({ ...prev, [field.group]: "" }));
|
||||
setInvalidField(null);
|
||||
};
|
||||
const reject = (field: RuntimeConfigField, message: string) => {
|
||||
setSaved((prev) => ({ ...prev, [field.group]: false }));
|
||||
setErrors((prev) => ({ ...prev, [field.group]: message }));
|
||||
setInvalidField(field.path);
|
||||
};
|
||||
const save = async (group: string) => {
|
||||
if (!settings?.runtime_config) return;
|
||||
if (saving) {
|
||||
@@ -70,12 +76,13 @@ export function useRuntimeConfigSettings(
|
||||
const values: Record<string, RuntimeConfigValue> = {};
|
||||
for (const field of changed) {
|
||||
const raw = value(field.path);
|
||||
if (field.kind === "number") {
|
||||
if (field.kind === "number" || field.kind === "duration") {
|
||||
const maximum = field.kind === "duration" ? settings.advanced.exec_max_runtime_limit : field.max;
|
||||
const parsed = Number(raw);
|
||||
if (String(raw).trim() === "" || !Number.isFinite(parsed)
|
||||
|| (field.path !== "api.timeout" && !Number.isInteger(parsed))
|
||||
|| (field.min !== undefined && parsed < field.min)
|
||||
|| (field.max !== undefined && parsed > field.max)) {
|
||||
|| (maximum !== undefined && parsed > maximum)) {
|
||||
setErrors((prev) => ({ ...prev, [group]: t("settings.runtimeConfig.numberError") }));
|
||||
setInvalidField(field.path);
|
||||
return;
|
||||
@@ -124,7 +131,7 @@ export function useRuntimeConfigSettings(
|
||||
applyPayload(payload, { preserveAgentForm: true, preserveCapabilityForms: true });
|
||||
setSaved((prev) => ({ ...prev, [field.group]: true }));
|
||||
};
|
||||
return { value, visible, dirty, discard, change, save, saveList, saving, errors, invalidField, saved };
|
||||
return { value, visible, dirty, discard, change, reject, save, saveList, saving, errors, invalidField, saved };
|
||||
}
|
||||
|
||||
export type RuntimeConfigController = ReturnType<typeof useRuntimeConfigSettings>;
|
||||
@@ -160,6 +167,7 @@ export function RuntimeConfigSettings({
|
||||
const dirty = fields.filter(state.visible).some(state.dirty);
|
||||
const title = tr(`groups.${group.id}.title`);
|
||||
const errorId = `runtime-error-${group.id}`;
|
||||
const inlineError = fields.some((field) => field.kind === "duration" && state.invalidField === field.path);
|
||||
const section = (
|
||||
<section key={group.id} aria-label={title}>
|
||||
<SettingsSectionTitle>{title}</SettingsSectionTitle>
|
||||
@@ -195,6 +203,13 @@ export function RuntimeConfigSettings({
|
||||
<div className="w-full">
|
||||
{field.path === "agents.defaults.timezone" ? (
|
||||
<TimezonePicker {...common} value={String(current)} onChange={(next) => state.change(field, next)} />
|
||||
) : field.kind === "duration" ? (
|
||||
<ShellRuntimeControl value={String(current)} maximum={settings.advanced.exec_max_runtime_limit}
|
||||
controlProps={{ ...common, disabled: disabled || state.saving === group.id || isRestarting }}
|
||||
onChange={(next) => state.change(field, next)}
|
||||
error={state.invalidField === field.path && state.errors[group.id]
|
||||
? { id: errorId, message: state.errors[group.id] } : undefined}
|
||||
onReject={(message) => state.reject(field, message)} />
|
||||
) : field.kind === "list" ? (
|
||||
<SettingsTextEditor id={id} title={text} description={help} value={String(current)}
|
||||
disabled={disabled || state.saving !== null || isRestarting}
|
||||
@@ -227,7 +242,7 @@ export function RuntimeConfigSettings({
|
||||
onRestart={onRestart} isRestarting={isRestarting} />
|
||||
</SettingsGroup>
|
||||
</fieldset>
|
||||
{state.errors[group.id] ? <p id={errorId} role="alert" className="mt-2 break-words px-1 text-[12px] text-destructive">{state.errors[group.id]}</p> : null}
|
||||
{state.errors[group.id] && !inlineError ? <p id={errorId} role="alert" className="mt-2 break-words px-1 text-[12px] text-destructive">{state.errors[group.id]}</p> : null}
|
||||
</form>
|
||||
</section>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
import { useState, type ComponentProps } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { ProviderPicker } from "@/components/settings/shared/ModelControls";
|
||||
import { Input } from "@/components/ui/input";
|
||||
|
||||
const PRESETS = [900, 1800, 3600, 21600, 43200, 86400];
|
||||
|
||||
type ControlProps = Pick<ComponentProps<typeof Input>,
|
||||
"id" | "disabled" | "aria-label" | "aria-describedby" | "aria-invalid">;
|
||||
|
||||
function formatDuration(seconds: number, locale: string): string {
|
||||
const [unit, divisor] = seconds % 3600 === 0 ? ["hour", 3600] as const
|
||||
: seconds % 60 === 0 ? ["minute", 60] as const : ["second", 1] as const;
|
||||
return new Intl.NumberFormat(locale, { style: "unit", unit, unitDisplay: "long" }).format(seconds / divisor);
|
||||
}
|
||||
|
||||
export function ShellRuntimeControl({
|
||||
value, maximum, controlProps, error, onChange, onReject,
|
||||
}: {
|
||||
value: string;
|
||||
maximum?: number;
|
||||
controlProps: ControlProps;
|
||||
error?: { id: string; message: string };
|
||||
onChange: (value: string) => void;
|
||||
onReject: (message: string) => void;
|
||||
}) {
|
||||
const { t, i18n } = useTranslation();
|
||||
const [customSelected, setCustomSelected] = useState(false);
|
||||
const presets = PRESETS.filter((seconds) => maximum === undefined || seconds <= maximum);
|
||||
if (maximum !== undefined && !presets.includes(maximum)) presets.push(maximum);
|
||||
const custom = customSelected || controlProps["aria-invalid"] === true
|
||||
|| (value !== "0" && !presets.includes(Number(value)));
|
||||
const limitId = `${controlProps.id}-limit`;
|
||||
const describedBy = `${controlProps["aria-describedby"] ?? ""}${maximum === undefined ? "" : ` ${limitId}`}`.trim();
|
||||
const unit = new Intl.NumberFormat(i18n.language, {
|
||||
style: "unit", unit: "second", unitDisplay: "short",
|
||||
}).formatToParts(2).find((part) => part.type === "unit")?.value;
|
||||
return (
|
||||
<div className="w-full space-y-1.5">
|
||||
<ProviderPicker
|
||||
triggerProps={{ ...controlProps, id: custom ? `${controlProps.id}-preset` : controlProps.id,
|
||||
"aria-describedby": describedBy }}
|
||||
value={custom ? "custom" : value}
|
||||
emptyLabel={t("settings.runtimeConfig.commandRuntime.custom")}
|
||||
providers={[
|
||||
...presets.map((seconds) => ({ name: String(seconds), label: formatDuration(seconds, i18n.language) })),
|
||||
{ name: "0", label: t("settings.runtimeConfig.commandRuntime.noLimit") },
|
||||
{ name: "custom", label: t("settings.runtimeConfig.commandRuntime.custom") },
|
||||
]}
|
||||
onChange={(next) => {
|
||||
setCustomSelected(next === "custom");
|
||||
if (next !== "custom") onChange(next);
|
||||
}}
|
||||
/>
|
||||
{custom ? <div className="relative">
|
||||
<Input {...controlProps} aria-label={t("settings.runtimeConfig.commandRuntime.customLabel")}
|
||||
aria-describedby={describedBy} type="number" inputMode="numeric"
|
||||
min={1} max={maximum} step={1} autoComplete="off" value={value === "0" ? "" : value}
|
||||
className="h-9 rounded-full pr-12 text-[13px] aria-[invalid=true]:border-destructive [&::-webkit-inner-spin-button]:appearance-none"
|
||||
onChange={(event) => {
|
||||
const next = event.target.value;
|
||||
const seconds = Number(next);
|
||||
if (next !== "" && (!Number.isSafeInteger(seconds) || seconds < 1
|
||||
|| (maximum !== undefined && seconds > maximum))) {
|
||||
onReject(maximum === undefined ? t("settings.runtimeConfig.numberError")
|
||||
: t("settings.runtimeConfig.commandRuntime.rangeError", { max: maximum.toLocaleString(i18n.language) }));
|
||||
return;
|
||||
}
|
||||
onChange(next);
|
||||
}} />
|
||||
<span aria-hidden className="pointer-events-none absolute inset-y-0 right-3 flex items-center text-[12px] text-muted-foreground">{unit}</span>
|
||||
</div> : null}
|
||||
{maximum !== undefined ? <p id={limitId} className="text-[12px] leading-4 text-muted-foreground">
|
||||
{t("settings.runtimeConfig.commandRuntime.limit", { duration: formatDuration(maximum, i18n.language) })}
|
||||
</p> : null}
|
||||
{error ? <p id={error.id} role="alert" className="text-[12px] leading-4 text-destructive">{error.message}</p> : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
export interface RuntimeConfigField {
|
||||
group: string;
|
||||
path: string;
|
||||
kind: "toggle" | "text" | "nullable" | "number" | "boolean" | "select" | "list" | "preset";
|
||||
kind: "toggle" | "text" | "nullable" | "number" | "duration" | "boolean" | "select" | "list" | "preset";
|
||||
options?: string[];
|
||||
when?: { path: string; value: string | boolean | string[] };
|
||||
manual?: boolean;
|
||||
@@ -44,7 +44,7 @@ export const RUNTIME_CONFIG_FIELDS: RuntimeConfigField[] = [
|
||||
{ group: "web", path: "tools.web.enable", kind: "boolean" },
|
||||
{ group: "tools", path: "tools.my.enable", kind: "boolean" },
|
||||
{ group: "tools", path: "tools.my.allow_set", kind: "boolean", when: { path: "tools.my.enable", value: true } },
|
||||
{ group: "shell", path: "tools.exec.timeout", kind: "number", min: 0 },
|
||||
{ group: "shell", path: "tools.exec.timeout", kind: "duration", min: 0 },
|
||||
{ group: "shell", path: "tools.exec.path_prepend", kind: "text" },
|
||||
{ group: "shell", path: "tools.exec.path_append", kind: "text" },
|
||||
{ group: "shell", path: "tools.exec.sandbox", kind: "select", options: ["", "bwrap", "seatbelt"] },
|
||||
|
||||
@@ -391,6 +391,13 @@
|
||||
},
|
||||
"runtimeConfig": {
|
||||
"apiSaved": "Saved. Restart the API service to apply changes.",
|
||||
"commandRuntime": {
|
||||
"custom": "Custom (seconds)",
|
||||
"customLabel": "Custom runtime (seconds)",
|
||||
"noLimit": "No time limit",
|
||||
"limit": "Timed runs: up to {{duration}}",
|
||||
"rangeError": "Enter whole seconds from 1 to {{max}}, or choose No time limit."
|
||||
},
|
||||
"fields": {
|
||||
"agents_defaults_timezone_mode": {
|
||||
"label": "System timezone",
|
||||
@@ -465,8 +472,8 @@
|
||||
"help": "Allow the agent to change its configuration.\n\nAllow the self-management tool to update configuration."
|
||||
},
|
||||
"tools_exec_timeout": {
|
||||
"label": "Command timeout",
|
||||
"help": "Stop commands after this many seconds; 0 means unlimited.\n\nStop commands that exceed this duration. Set to 0 for no time limit."
|
||||
"label": "Command runtime",
|
||||
"help": "Default hard runtime limit for shell commands.\n\nOutput and waiting do not extend it. Choose No time limit to remove this limit."
|
||||
},
|
||||
"tools_exec_path_prepend": {
|
||||
"label": "PATH priority",
|
||||
|
||||
@@ -391,6 +391,13 @@
|
||||
},
|
||||
"runtimeConfig": {
|
||||
"apiSaved": "Guardado. Reinicia el servicio API para aplicar los cambios.",
|
||||
"commandRuntime": {
|
||||
"custom": "Personalizada (segundos)",
|
||||
"customLabel": "Duración personalizada (segundos)",
|
||||
"noLimit": "Sin límite de tiempo",
|
||||
"limit": "Con límite: hasta {{duration}}",
|
||||
"rangeError": "Introduce un número entero de segundos entre 1 y {{max}}, o elige Sin límite de tiempo."
|
||||
},
|
||||
"fields": {
|
||||
"agents_defaults_timezone_mode": {"label": "Zona del sistema", "help": "Desactívalo para elegir una zona horaria.\n\nDesactiva esta opción para elegir la zona horaria manualmente."},
|
||||
"agents_defaults_timezone": {"label": "Zona horaria", "help": "Los desfases UTC usan la fecha actual.\n\nElige una zona horaria. La diferencia con UTC corresponde a la fecha actual."},
|
||||
@@ -410,7 +417,7 @@
|
||||
"tools_cli_apps_enable": {"label": "Apps CLI", "help": "Permite instalar, gestionar y ejecutar apps CLI.\n\nPermite al agente gestionar y ejecutar aplicaciones de línea de comandos."},
|
||||
"tools_my_enable": {"label": "Ver configuración", "help": "Permite al agente consultar su configuración."},
|
||||
"tools_my_allow_set": {"label": "Editar configuración", "help": "Permite al agente cambiar su configuración.\n\nPermite que la herramienta de autogestión modifique la configuración."},
|
||||
"tools_exec_timeout": {"label": "Tiempo límite de comandos", "help": "Detén los comandos tras estos segundos; 0 significa sin límite.\n\nDuración máxima de un comando de shell. 0 significa sin límite."},
|
||||
"tools_exec_timeout": {"label": "Duración de los comandos", "help": "Límite de duración predeterminado para los comandos de shell.\n\nLa salida y la espera no amplían este límite. Elige Sin límite de tiempo para eliminar el límite de duración."},
|
||||
"tools_exec_path_prepend": {"label": "Prioridad de PATH", "help": "Busca primero en estos directorios.\n\nDirectorios que se añaden al inicio de PATH. Sepáralos con punto y coma en Windows o con dos puntos en macOS y Linux."},
|
||||
"tools_exec_path_append": {"label": "Añadidos a PATH", "help": "Busca al final en estos directorios.\n\nDirectorios que se añaden al final de PATH. Sepáralos con punto y coma en Windows o con dos puntos en macOS y Linux."},
|
||||
"tools_exec_sandbox": {"label": "Sandbox de comandos", "help": "Aísla los procesos de comandos; requiere soporte del sistema.\n\nUsa bwrap en Linux o Seatbelt en macOS. Las comprobaciones del espacio de trabajo por sí solas no aíslan los procesos."},
|
||||
|
||||
@@ -391,6 +391,13 @@
|
||||
},
|
||||
"runtimeConfig": {
|
||||
"apiSaved": "Enregistré. Redémarrez le service API pour appliquer les modifications.",
|
||||
"commandRuntime": {
|
||||
"custom": "Personnalisée (secondes)",
|
||||
"customLabel": "Durée personnalisée (secondes)",
|
||||
"noLimit": "Sans limite de temps",
|
||||
"limit": "Durée limitée : jusqu’à {{duration}}",
|
||||
"rangeError": "Saisissez un nombre entier de secondes entre 1 et {{max}}, ou choisissez Sans limite de temps."
|
||||
},
|
||||
"fields": {
|
||||
"agents_defaults_timezone_mode": {"label": "Fuseau système", "help": "Désactivez pour choisir un fuseau horaire.\n\nDésactivez pour choisir le fuseau horaire manuellement."},
|
||||
"agents_defaults_timezone": {"label": "Fuseau horaire", "help": "Les décalages UTC utilisent la date actuelle.\n\nChoisissez un fuseau horaire. Le décalage UTC correspond à la date actuelle."},
|
||||
@@ -410,7 +417,7 @@
|
||||
"tools_cli_apps_enable": {"label": "Applications CLI", "help": "Autorisez l’installation, la gestion et l’exécution d’applications CLI.\n\nAutorise l’agent à gérer et à exécuter ces applications."},
|
||||
"tools_my_enable": {"label": "Voir la configuration", "help": "Autorisez l’agent à consulter sa configuration.\n\nAutorise l’agent à consulter sa configuration."},
|
||||
"tools_my_allow_set": {"label": "Modifier la configuration", "help": "Autorisez l’agent à modifier sa configuration.\n\nAutorise l’outil d’autogestion à modifier la configuration."},
|
||||
"tools_exec_timeout": {"label": "Délai des commandes", "help": "Arrêtez les commandes après ce nombre de secondes ; 0 signifie sans limite.\n\nDurée maximale d’une commande shell. 0 signifie aucune limite."},
|
||||
"tools_exec_timeout": {"label": "Durée des commandes", "help": "Durée maximale par défaut des commandes shell.\n\nNi la sortie des commandes ni l’attente ne prolongent cette limite. Choisissez Sans limite de temps pour supprimer la limite de durée."},
|
||||
"tools_exec_path_prepend": {"label": "Priorité PATH", "help": "Recherchez d’abord dans ces dossiers.\n\nDossiers à placer au début de PATH. Séparez-les par un point-virgule sous Windows ou par deux-points sous macOS et Linux."},
|
||||
"tools_exec_path_append": {"label": "Ajouts au PATH", "help": "Recherchez dans ces dossiers en dernier.\n\nDossiers à placer à la fin de PATH. Séparez-les par un point-virgule sous Windows ou par deux-points sous macOS et Linux."},
|
||||
"tools_exec_sandbox": {"label": "Bac à sable des commandes", "help": "Isolez les processus de commande ; nécessite une prise en charge système.\n\nUtilisez bwrap sous Linux ou Seatbelt sous macOS. Les contrôles de l’espace de travail seuls n’isolent pas les processus."},
|
||||
|
||||
@@ -391,6 +391,13 @@
|
||||
},
|
||||
"runtimeConfig": {
|
||||
"apiSaved": "Tersimpan. Mulai ulang layanan API untuk menerapkan perubahan.",
|
||||
"commandRuntime": {
|
||||
"custom": "Kustom (detik)",
|
||||
"customLabel": "Durasi kustom (detik)",
|
||||
"noLimit": "Tanpa batas waktu",
|
||||
"limit": "Dengan batas waktu: hingga {{duration}}",
|
||||
"rangeError": "Masukkan jumlah detik berupa bilangan bulat dari 1 hingga {{max}}, atau pilih Tanpa batas waktu."
|
||||
},
|
||||
"fields": {
|
||||
"agents_defaults_timezone_mode": {"label": "Zona waktu sistem", "help": "Nonaktifkan untuk memilih zona waktu.\n\nNonaktifkan untuk memilih zona waktu secara manual."},
|
||||
"agents_defaults_timezone": {"label": "Zona waktu", "help": "Selisih UTC mengikuti tanggal saat ini.\n\nPilih zona waktu. Selisih waktu dari UTC mengikuti tanggal saat ini."},
|
||||
@@ -410,7 +417,7 @@
|
||||
"tools_cli_apps_enable": {"label": "Aplikasi CLI", "help": "Izinkan pemasangan, pengelolaan, dan menjalankan aplikasi CLI.\n\nMengizinkan agen mengelola dan menjalankan aplikasi baris perintah."},
|
||||
"tools_my_enable": {"label": "Lihat konfigurasi", "help": "Izinkan agen melihat konfigurasinya.\n\nMengizinkan agen memeriksa konfigurasinya sendiri."},
|
||||
"tools_my_allow_set": {"label": "Ubah konfigurasi", "help": "Izinkan agen mengubah konfigurasinya.\n\nMengizinkan alat pengelolaan diri memperbarui konfigurasi."},
|
||||
"tools_exec_timeout": {"label": "Batas waktu perintah", "help": "Hentikan perintah setelah jumlah detik ini; 0 berarti tanpa batas.\n\nDurasi maksimum perintah shell. 0 berarti tanpa batas."},
|
||||
"tools_exec_timeout": {"label": "Durasi perintah", "help": "Batas durasi bawaan untuk perintah shell.\n\nKeluaran dan waktu tunggu tidak memperpanjang batas ini. Pilih Tanpa batas waktu untuk menghapus batas durasi."},
|
||||
"tools_exec_path_prepend": {"label": "Prioritas PATH", "help": "Cari di direktori ini terlebih dahulu.\n\nDirektori yang ditambahkan di awal PATH. Pisahkan dengan titik koma di Windows atau titik dua di macOS dan Linux."},
|
||||
"tools_exec_path_append": {"label": "Tambahan PATH", "help": "Cari di direktori ini terakhir.\n\nDirektori yang ditambahkan di akhir PATH. Pisahkan dengan titik koma di Windows atau titik dua di macOS dan Linux."},
|
||||
"tools_exec_sandbox": {"label": "Sandbox perintah", "help": "Isolasi proses perintah; memerlukan dukungan sistem.\n\nGunakan bwrap di Linux atau Seatbelt di macOS. Pemeriksaan ruang kerja saja tidak mengisolasi proses."},
|
||||
|
||||
@@ -391,6 +391,13 @@
|
||||
},
|
||||
"runtimeConfig": {
|
||||
"apiSaved": "保存しました。API サービスを再起動すると反映されます。",
|
||||
"commandRuntime": {
|
||||
"custom": "カスタム(秒)",
|
||||
"customLabel": "カスタム実行時間(秒)",
|
||||
"noLimit": "時間制限なし",
|
||||
"limit": "時間制限あり:最大 {{duration}}",
|
||||
"rangeError": "1 から {{max}} までの整数で秒数を入力するか、「時間制限なし」を選んでください。"
|
||||
},
|
||||
"fields": {
|
||||
"agents_defaults_timezone_mode": {"label": "システムの時間帯", "help": "オフにすると時間帯を指定できます。\n\nオフにすると手動でタイムゾーンを選択できます。"},
|
||||
"agents_defaults_timezone": {"label": "タイムゾーン", "help": "UTC オフセットは今日の日付に基づきます。\n\nタイムゾーンを選択します。UTC との時差は現在の日付に基づきます。"},
|
||||
@@ -410,7 +417,7 @@
|
||||
"tools_cli_apps_enable": {"label": "CLI アプリ", "help": "CLI アプリのインストール・管理・実行を許可します。\n\nエージェントによる CLI アプリの管理と実行を許可します。"},
|
||||
"tools_my_enable": {"label": "設定を確認", "help": "エージェントによる自身の設定の確認を許可します。\n\nエージェントが自身の設定を確認できるようにします。"},
|
||||
"tools_my_allow_set": {"label": "設定を変更", "help": "エージェントによる自身の設定の変更を許可します。\n\n自己管理ツールによる設定の更新を許可します。"},
|
||||
"tools_exec_timeout": {"label": "コマンドの制限時間", "help": "この秒数でコマンドを停止します。0 は無制限です。\n\nシェルコマンドの実行時間の上限。0 は無制限です。"},
|
||||
"tools_exec_timeout": {"label": "コマンドの実行時間", "help": "シェルコマンドの既定の実行時間上限です。\n\n出力や待機によって上限は延長されません。「時間制限なし」を選ぶと実行時間の上限がなくなります。"},
|
||||
"tools_exec_path_prepend": {"label": "PATH の優先検索", "help": "これらのディレクトリを先に検索します。\n\nPATH の先頭に追加するディレクトリです。Windows ではセミコロン、macOS と Linux ではコロンで区切ります。"},
|
||||
"tools_exec_path_append": {"label": "PATH の末尾追加", "help": "これらのディレクトリを最後に検索します。\n\nPATH の末尾に追加するディレクトリです。Windows ではセミコロン、macOS と Linux ではコロンで区切ります。"},
|
||||
"tools_exec_sandbox": {"label": "コマンドサンドボックス", "help": "コマンドのプロセスを隔離します。システムの対応が必要です。\n\nLinux では bwrap、macOS では Seatbelt を使用します。ワークスペースの検査だけではプロセスは隔離されません。"},
|
||||
|
||||
@@ -391,6 +391,13 @@
|
||||
},
|
||||
"runtimeConfig": {
|
||||
"apiSaved": "저장했습니다. API 서비스를 다시 시작하면 적용됩니다.",
|
||||
"commandRuntime": {
|
||||
"custom": "사용자 지정(초)",
|
||||
"customLabel": "사용자 지정 실행 시간(초)",
|
||||
"noLimit": "시간 제한 없음",
|
||||
"limit": "제한 시간: 최대 {{duration}}",
|
||||
"rangeError": "1~{{max}} 사이의 정수(초)를 입력하거나 ‘시간 제한 없음’을 선택하세요."
|
||||
},
|
||||
"fields": {
|
||||
"agents_defaults_timezone_mode": {"label": "시스템 시간대", "help": "끄면 시간대를 직접 선택할 수 있습니다."},
|
||||
"agents_defaults_timezone": {"label": "시간대", "help": "UTC 오프셋은 오늘 날짜를 기준으로 합니다.\n\n시간대를 선택하세요. UTC 시차는 현재 날짜를 기준으로 표시됩니다."},
|
||||
@@ -410,7 +417,7 @@
|
||||
"tools_cli_apps_enable": {"label": "CLI 앱", "help": "CLI 앱 설치, 관리 및 실행을 허용합니다.\n\n에이전트의 CLI 앱 관리와 실행을 허용합니다."},
|
||||
"tools_my_enable": {"label": "설정 확인", "help": "에이전트가 자신의 설정을 확인하도록 허용합니다."},
|
||||
"tools_my_allow_set": {"label": "설정 변경", "help": "에이전트가 자신의 설정을 변경하도록 허용합니다.\n\n자체 관리 도구의 설정 수정을 허용합니다."},
|
||||
"tools_exec_timeout": {"label": "명령 제한 시간", "help": "지정한 초가 지나면 명령을 멈춥니다. 0은 무제한입니다.\n\n셸 명령의 최대 실행 시간입니다. 0은 무제한입니다."},
|
||||
"tools_exec_timeout": {"label": "명령 실행 시간", "help": "셸 명령에 기본으로 적용되는 최대 실행 시간입니다.\n\n출력이나 대기로 이 제한이 늘어나지 않습니다. ‘시간 제한 없음’을 선택하면 실행 시간 제한이 해제됩니다."},
|
||||
"tools_exec_path_prepend": {"label": "PATH 우선 검색", "help": "이 디렉터리부터 검색합니다.\n\nPATH 앞에 추가할 디렉터리입니다. Windows에서는 세미콜론, macOS와 Linux에서는 콜론으로 구분하세요."},
|
||||
"tools_exec_path_append": {"label": "PATH 추가 검색", "help": "이 디렉터리를 마지막에 검색합니다.\n\nPATH 뒤에 추가할 디렉터리입니다. Windows에서는 세미콜론, macOS와 Linux에서는 콜론으로 구분하세요."},
|
||||
"tools_exec_sandbox": {"label": "명령 샌드박스", "help": "명령 프로세스를 격리합니다. 시스템 지원이 필요합니다.\n\nLinux에서는 bwrap, macOS에서는 Seatbelt를 사용합니다. 작업 공간 검사만으로는 프로세스가 격리되지 않습니다."},
|
||||
|
||||
@@ -391,6 +391,13 @@
|
||||
},
|
||||
"runtimeConfig": {
|
||||
"apiSaved": "Salvo. Reinicie o serviço de API para aplicar as alterações.",
|
||||
"commandRuntime": {
|
||||
"custom": "Personalizada (segundos)",
|
||||
"customLabel": "Duração personalizada (segundos)",
|
||||
"noLimit": "Sem limite de tempo",
|
||||
"limit": "Com limite: até {{duration}}",
|
||||
"rangeError": "Digite um número inteiro de segundos de 1 a {{max}}, ou escolha Sem limite de tempo."
|
||||
},
|
||||
"fields": {
|
||||
"agents_defaults_timezone_mode": {"label": "Fuso do sistema", "help": "Desative para escolher um fuso horário.\n\nDesative para escolher o fuso horário manualmente."},
|
||||
"agents_defaults_timezone": {"label": "Fuso horário", "help": "Os deslocamentos UTC usam a data atual.\n\nEscolha um fuso horário. A diferença em relação ao UTC considera a data atual."},
|
||||
@@ -410,7 +417,7 @@
|
||||
"tools_cli_apps_enable": {"label": "Apps CLI", "help": "Permita instalar, gerenciar e executar apps CLI.\n\nPermite que o agente gerencie e execute aplicativos de linha de comando."},
|
||||
"tools_my_enable": {"label": "Ver configuração", "help": "Permita que o agente consulte sua configuração.\n\nPermite que o agente consulte sua própria configuração."},
|
||||
"tools_my_allow_set": {"label": "Editar configuração", "help": "Permita que o agente altere sua configuração.\n\nPermite que a ferramenta de autogerenciamento atualize a configuração."},
|
||||
"tools_exec_timeout": {"label": "Tempo limite de comandos", "help": "Pare os comandos após este número de segundos; 0 significa sem limite.\n\nDuração máxima dos comandos de shell. 0 significa sem limite."},
|
||||
"tools_exec_timeout": {"label": "Duração dos comandos", "help": "Limite padrão de duração dos comandos de shell.\n\nA saída e a espera não prolongam esse limite. Escolha Sem limite de tempo para remover o limite de duração."},
|
||||
"tools_exec_path_prepend": {"label": "Prioridade no PATH", "help": "Pesquise primeiro nestas pastas.\n\nDiretórios adicionados ao início de PATH. Separe-os com ponto e vírgula no Windows ou com dois-pontos no macOS e no Linux."},
|
||||
"tools_exec_path_append": {"label": "Adições ao PATH", "help": "Pesquise nestas pastas por último.\n\nDiretórios adicionados ao final de PATH. Separe-os com ponto e vírgula no Windows ou com dois-pontos no macOS e no Linux."},
|
||||
"tools_exec_sandbox": {"label": "Sandbox de comandos", "help": "Isole os processos de comandos; requer suporte do sistema.\n\nUse bwrap no Linux ou Seatbelt no macOS. As verificações do espaço de trabalho, por si só, não isolam processos."},
|
||||
|
||||
@@ -391,6 +391,13 @@
|
||||
},
|
||||
"runtimeConfig": {
|
||||
"apiSaved": "Đã lưu. Khởi động lại dịch vụ API để áp dụng thay đổi.",
|
||||
"commandRuntime": {
|
||||
"custom": "Tùy chỉnh (giây)",
|
||||
"customLabel": "Thời gian chạy tùy chỉnh (giây)",
|
||||
"noLimit": "Không giới hạn thời gian",
|
||||
"limit": "Có giới hạn: tối đa {{duration}}",
|
||||
"rangeError": "Nhập số giây nguyên từ 1 đến {{max}}, hoặc chọn Không giới hạn thời gian."
|
||||
},
|
||||
"fields": {
|
||||
"agents_defaults_timezone_mode": {"label": "Múi giờ hệ thống", "help": "Tắt để chọn múi giờ.\n\nTắt để chọn múi giờ thủ công."},
|
||||
"agents_defaults_timezone": {"label": "Múi giờ", "help": "Độ lệch UTC theo ngày hiện tại.\n\nChọn múi giờ. Độ lệch UTC được tính theo ngày hiện tại."},
|
||||
@@ -410,7 +417,7 @@
|
||||
"tools_cli_apps_enable": {"label": "Ứng dụng CLI", "help": "Cho phép cài đặt, quản lý và chạy ứng dụng CLI.\n\nCho phép tác nhân quản lý và chạy ứng dụng dòng lệnh."},
|
||||
"tools_my_enable": {"label": "Xem cấu hình", "help": "Cho phép agent xem cấu hình của mình.\n\nCho phép tác nhân xem cấu hình của mình."},
|
||||
"tools_my_allow_set": {"label": "Sửa cấu hình", "help": "Cho phép agent thay đổi cấu hình của mình.\n\nCho phép công cụ tự quản lý cập nhật cấu hình."},
|
||||
"tools_exec_timeout": {"label": "Thời hạn lệnh", "help": "Dừng lệnh sau số giây này; 0 là không giới hạn.\n\nThời gian chạy tối đa của lệnh shell. 0 nghĩa là không giới hạn."},
|
||||
"tools_exec_timeout": {"label": "Thời gian chạy lệnh", "help": "Giới hạn thời gian chạy mặc định cho lệnh shell.\n\nĐầu ra và việc chờ đợi không kéo dài giới hạn này. Chọn Không giới hạn thời gian để bỏ giới hạn thời gian chạy."},
|
||||
"tools_exec_path_prepend": {"label": "Ưu tiên PATH", "help": "Tìm trong các thư mục này trước.\n\nCác thư mục thêm vào đầu PATH. Phân cách bằng dấu chấm phẩy trên Windows hoặc dấu hai chấm trên macOS và Linux."},
|
||||
"tools_exec_path_append": {"label": "Bổ sung PATH", "help": "Tìm trong các thư mục này sau cùng.\n\nCác thư mục thêm vào cuối PATH. Phân cách bằng dấu chấm phẩy trên Windows hoặc dấu hai chấm trên macOS và Linux."},
|
||||
"tools_exec_sandbox": {"label": "Hộp cát lệnh", "help": "Cô lập tiến trình lệnh; cần hệ thống hỗ trợ.\n\nDùng bwrap trên Linux hoặc Seatbelt trên macOS. Chỉ kiểm tra không gian làm việc không thể cô lập tiến trình."},
|
||||
|
||||
@@ -391,6 +391,13 @@
|
||||
},
|
||||
"runtimeConfig": {
|
||||
"apiSaved": "已保存,重启 API 服务后生效。",
|
||||
"commandRuntime": {
|
||||
"custom": "自定义(秒)",
|
||||
"customLabel": "自定义运行时长(秒)",
|
||||
"noLimit": "不限时",
|
||||
"limit": "限时最长 {{duration}}",
|
||||
"rangeError": "请输入 1 到 {{max}} 之间的整数秒,或选择“不限时”。"
|
||||
},
|
||||
"fields": {
|
||||
"agents_defaults_timezone_mode": {
|
||||
"label": "系统时区",
|
||||
@@ -465,8 +472,8 @@
|
||||
"help": "允许智能体修改自身配置"
|
||||
},
|
||||
"tools_exec_timeout": {
|
||||
"label": "执行超时",
|
||||
"help": "执行超时即停止;0 为不限,单位秒\n\n超过此时长后终止命令。设为 0 表示不限制执行时长。"
|
||||
"label": "运行上限",
|
||||
"help": "Shell 命令的默认运行上限\n\n命令输出或继续等待都不会延长此上限。选择“不限时”可取消运行时限。"
|
||||
},
|
||||
"tools_exec_path_prepend": {
|
||||
"label": "优先目录",
|
||||
|
||||
@@ -391,6 +391,13 @@
|
||||
},
|
||||
"runtimeConfig": {
|
||||
"apiSaved": "已儲存,重新啟動 API 服務後生效。",
|
||||
"commandRuntime": {
|
||||
"custom": "自訂(秒)",
|
||||
"customLabel": "自訂執行時間(秒)",
|
||||
"noLimit": "不限時",
|
||||
"limit": "限時最長 {{duration}}",
|
||||
"rangeError": "請輸入 1 到 {{max}} 之間的整數秒,或選擇「不限時」。"
|
||||
},
|
||||
"fields": {
|
||||
"agents_defaults_timezone_mode": {"label": "系統時區", "help": "關閉後可手動指定時區"},
|
||||
"agents_defaults_timezone": {"label": "時區", "help": "UTC 偏移按當前日期顯示"},
|
||||
@@ -410,7 +417,7 @@
|
||||
"tools_cli_apps_enable": {"label": "CLI 應用", "help": "允許安裝、管理和執行 CLI 應用"},
|
||||
"tools_my_enable": {"label": "檢視配置", "help": "允許智慧體檢視自身配置"},
|
||||
"tools_my_allow_set": {"label": "修改配置", "help": "允許智慧體修改自身配置"},
|
||||
"tools_exec_timeout": {"label": "執行超時", "help": "執行超時即停止;0 為不限,單位秒\n\n超過此時長後終止命令。設為 0 表示不限制執行時長。"},
|
||||
"tools_exec_timeout": {"label": "執行上限", "help": "Shell 命令的預設執行上限\n\n命令輸出或繼續等待都不會延長此上限。選擇「不限時」可取消執行時限。"},
|
||||
"tools_exec_path_prepend": {"label": "優先目錄", "help": "優先查詢命令的目錄\n\n新增到 PATH 開頭。多個目錄在 Windows 上用分號分隔,在 Linux 和 macOS 上用冒號分隔。"},
|
||||
"tools_exec_path_append": {"label": "追加目錄", "help": "最後查詢命令的目錄\n\n新增到 PATH 末尾。多個目錄在 Windows 上用分號分隔,在 Linux 和 macOS 上用冒號分隔。"},
|
||||
"tools_exec_sandbox": {"label": "命令沙箱", "help": "隔離命令程序,需系統支援\n\nLinux 使用 bwrap,macOS 使用 Seatbelt。工作區路徑限制本身不提供程序隔離。"},
|
||||
|
||||
@@ -957,6 +957,7 @@ export interface SettingsPayload {
|
||||
private_service_protection_enabled: boolean;
|
||||
mcp_server_count: number;
|
||||
exec_enabled: boolean;
|
||||
exec_max_runtime_limit?: number;
|
||||
exec_sandbox?: string | null;
|
||||
exec_path_prepend_set: boolean;
|
||||
exec_path_append_set: boolean;
|
||||
|
||||
@@ -6,7 +6,8 @@ import { DEFAULT_AGENT_SETTINGS_DRAFT } from "@/components/settings/models/Model
|
||||
import { installSettingsViewTestHooks, jsonResponse, renderSettingsView, requestMutationMock, settingsPayload } from "@/tests/settings-test-utils";
|
||||
|
||||
function runtimeSettings() {
|
||||
return { ...settingsPayload(), runtime_config: {
|
||||
const payload = settingsPayload();
|
||||
return { ...payload, advanced: { ...payload.advanced, exec_max_runtime_limit: 86400 }, runtime_config: {
|
||||
"agents.defaults.bot_name": "nanobot",
|
||||
"agents.defaults.bot_icon": "🐈",
|
||||
"agents.defaults.timezone_mode": "auto",
|
||||
@@ -142,7 +143,7 @@ describe("Runtime configuration settings", () => {
|
||||
requestMutationMock.mockResolvedValue({ ...payload, requires_restart: true,
|
||||
runtime_config: { ...payload.runtime_config, "tools.exec.timeout": 90 } });
|
||||
renderSettingsView({ initialSection: "advanced", initialSettings: payload });
|
||||
fireEvent.change(screen.getByRole("spinbutton", { name: "Command timeout" }), { target: { value: "90" } });
|
||||
fireEvent.change(screen.getByRole("spinbutton", { name: "Custom runtime (seconds)" }), { target: { value: "90" } });
|
||||
await waitFor(() => expect(requestMutationMock).toHaveBeenCalledWith(
|
||||
"settings.runtime_config.update", { values: { "tools.exec.timeout": 90 } }, 20_000,
|
||||
));
|
||||
@@ -152,7 +153,7 @@ describe("Runtime configuration settings", () => {
|
||||
it("validates numbers and keeps a failed draft editable", async () => {
|
||||
requestMutationMock.mockRejectedValue(new Error("Could not save settings"));
|
||||
renderSettingsView({ initialSection: "advanced", initialSettings: runtimeSettings() });
|
||||
const field = screen.getByRole("spinbutton", { name: "Command timeout" });
|
||||
const field = screen.getByRole("spinbutton", { name: "Custom runtime (seconds)" });
|
||||
fireEvent.change(field, { target: { value: "-1" } });
|
||||
await waitFor(() => expect(field).toHaveFocus());
|
||||
expect(field).toHaveAttribute("aria-invalid", "true");
|
||||
@@ -162,6 +163,104 @@ describe("Runtime configuration settings", () => {
|
||||
expect(field).toHaveValue(17);
|
||||
});
|
||||
|
||||
it.each([
|
||||
["24 hours", 86400],
|
||||
["No time limit", 0],
|
||||
])("saves the %s command runtime preset in seconds", async (label, seconds) => {
|
||||
const payload = runtimeSettings();
|
||||
payload.runtime_config["tools.exec.timeout"] = 3600;
|
||||
requestMutationMock.mockResolvedValue({ ...payload, runtime_config: {
|
||||
...payload.runtime_config, "tools.exec.timeout": seconds,
|
||||
} });
|
||||
renderSettingsView({ initialSection: "advanced", initialSettings: payload });
|
||||
|
||||
const control = screen.getByRole("combobox", { name: "Command runtime" });
|
||||
expect(control).toHaveTextContent("1 hour");
|
||||
expect(screen.getByText("Timed runs: up to 24 hours")).toBeVisible();
|
||||
fireEvent.click(control);
|
||||
fireEvent.click(screen.getByRole("option", { name: label, exact: true }));
|
||||
|
||||
await waitFor(() => expect(requestMutationMock).toHaveBeenCalledWith(
|
||||
"settings.runtime_config.update", { values: { "tools.exec.timeout": seconds } }, 20_000,
|
||||
));
|
||||
});
|
||||
|
||||
it("rejects over-limit custom input without clamping or saving it", async () => {
|
||||
const payload = runtimeSettings();
|
||||
payload.runtime_config["tools.exec.timeout"] = 3600;
|
||||
requestMutationMock.mockResolvedValue({ ...payload, runtime_config: {
|
||||
...payload.runtime_config, "tools.exec.timeout": 86400,
|
||||
} });
|
||||
renderSettingsView({ initialSection: "advanced", initialSettings: payload });
|
||||
fireEvent.click(screen.getByRole("combobox", { name: "Command runtime" }));
|
||||
fireEvent.click(screen.getByRole("option", { name: "Custom (seconds)", exact: true }));
|
||||
const field = screen.getByRole("spinbutton", { name: "Custom runtime (seconds)" });
|
||||
expect(field).toHaveAttribute("max", "86400");
|
||||
fireEvent.change(field, { target: { value: "86401" } });
|
||||
|
||||
expect(field).toHaveValue(3600);
|
||||
expect(field).toHaveAttribute("aria-invalid", "true");
|
||||
expect(screen.getByRole("alert")).toHaveTextContent("1 to 86,400");
|
||||
expect(requestMutationMock).not.toHaveBeenCalled();
|
||||
|
||||
fireEvent.change(field, { target: { value: "86400" } });
|
||||
await waitFor(() => expect(requestMutationMock).toHaveBeenCalledWith(
|
||||
"settings.runtime_config.update", { values: { "tools.exec.timeout": 86400 } }, 20_000,
|
||||
));
|
||||
await screen.findByText("Saved.", { exact: true });
|
||||
fireEvent.change(field, { target: { value: "86401" } });
|
||||
expect(field).toHaveValue(86400);
|
||||
expect(screen.getAllByRole("alert")).toHaveLength(1);
|
||||
expect(screen.queryByText("Saved.", { exact: true })).not.toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole("button", { name: "System", exact: true }));
|
||||
fireEvent.click(screen.getByRole("button", { name: "Advanced", exact: true }));
|
||||
expect(screen.getByRole("spinbutton", { name: "Custom runtime (seconds)" })).toHaveValue(86400);
|
||||
expect(screen.getByRole("alert")).toHaveTextContent("1 to 86,400");
|
||||
});
|
||||
|
||||
it("starts a custom duration from No time limit without saving an empty value", async () => {
|
||||
const payload = runtimeSettings();
|
||||
payload.runtime_config["tools.exec.timeout"] = 0;
|
||||
requestMutationMock.mockResolvedValue({ ...payload, runtime_config: {
|
||||
...payload.runtime_config, "tools.exec.timeout": 120,
|
||||
} });
|
||||
renderSettingsView({ initialSection: "advanced", initialSettings: payload });
|
||||
fireEvent.click(screen.getByRole("combobox", { name: "Command runtime" }));
|
||||
fireEvent.click(screen.getByRole("option", { name: "Custom (seconds)", exact: true }));
|
||||
const field = screen.getByRole("spinbutton", { name: "Custom runtime (seconds)" });
|
||||
expect(field).toHaveValue(null);
|
||||
expect(requestMutationMock).not.toHaveBeenCalled();
|
||||
fireEvent.change(field, { target: { value: "120" } });
|
||||
await waitFor(() => expect(requestMutationMock).toHaveBeenCalledWith(
|
||||
"settings.runtime_config.update", { values: { "tools.exec.timeout": 120 } }, 20_000,
|
||||
));
|
||||
});
|
||||
|
||||
it("uses the gateway's configured runtime limit for presets and custom input", () => {
|
||||
const payload = runtimeSettings();
|
||||
payload.advanced.exec_max_runtime_limit = 7200;
|
||||
renderSettingsView({ initialSection: "advanced", initialSettings: payload });
|
||||
expect(screen.getByText("Timed runs: up to 2 hours")).toBeVisible();
|
||||
expect(screen.getByRole("spinbutton", { name: "Custom runtime (seconds)" })).toHaveAttribute("max", "7200");
|
||||
fireEvent.click(screen.getByRole("combobox", { name: "Command runtime" }));
|
||||
expect(screen.getByRole("option", { name: "2 hours", exact: true })).toBeVisible();
|
||||
expect(screen.queryByRole("option", { name: "24 hours", exact: true })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("keeps runtime editing available on a host without limit metadata", async () => {
|
||||
const payload = runtimeSettings();
|
||||
requestMutationMock.mockResolvedValue({ ...payload, runtime_config: {
|
||||
...payload.runtime_config, "tools.exec.timeout": 90,
|
||||
} });
|
||||
renderSettingsView({ initialSection: "advanced", initialSettings: {
|
||||
...payload, advanced: settingsPayload().advanced,
|
||||
} });
|
||||
fireEvent.change(screen.getByRole("spinbutton", { name: "Custom runtime (seconds)" }), { target: { value: "90" } });
|
||||
await waitFor(() => expect(requestMutationMock).toHaveBeenCalledWith(
|
||||
"settings.runtime_config.update", { values: { "tools.exec.timeout": 90 } }, 20_000,
|
||||
));
|
||||
});
|
||||
|
||||
it("preserves drafts when navigating away and supports explicit clearing", async () => {
|
||||
renderSettingsView({ initialSection: "capabilities", initialSettings: runtimeSettings() });
|
||||
const openWebSettings = () => {
|
||||
|
||||
Reference in new issue
Block a user