refactor: unify restart gating and update availability sync

This commit is contained in:
Peter Steinberger
2026-02-19 10:00:27 +01:00
parent 18179fc2c1
commit b4dbe03298
25 changed files with 288 additions and 41 deletions

View File

@@ -1,5 +1,6 @@
import { describe, expect, it } from "vitest";
import {
isRestartEnabled,
isNativeCommandsExplicitlyDisabled,
resolveNativeCommandsEnabled,
resolveNativeSkillsEnabled,
@@ -97,3 +98,13 @@ describe("isNativeCommandsExplicitlyDisabled", () => {
).toBe(false);
});
});
describe("isRestartEnabled", () => {
it("defaults to enabled unless explicitly false", () => {
expect(isRestartEnabled(undefined)).toBe(true);
expect(isRestartEnabled({})).toBe(true);
expect(isRestartEnabled({ commands: {} })).toBe(true);
expect(isRestartEnabled({ commands: { restart: true } })).toBe(true);
expect(isRestartEnabled({ commands: { restart: false } })).toBe(false);
});
});

View File

@@ -61,3 +61,7 @@ export function isNativeCommandsExplicitlyDisabled(params: {
}
return false;
}
export function isRestartEnabled(config?: { commands?: { restart?: boolean } }): boolean {
return config?.commands?.restart !== false;
}

View File

@@ -307,7 +307,7 @@ export const FIELD_HELP: Record<string, string> = {
"How long bash waits before backgrounding (default: 2000; 0 backgrounds immediately).",
"commands.config": "Allow /config chat command to read/write config on disk (default: false).",
"commands.debug": "Allow /debug chat command for runtime-only overrides (default: false).",
"commands.restart": "Allow /restart and gateway restart tool actions (default: false).",
"commands.restart": "Allow /restart and gateway restart tool actions (default: true).",
"commands.useAccessGroups": "Enforce access-group allowlists/policies for commands.",
"commands.ownerAllowFrom":
"Explicit owner allowlist for owner-only tools/commands. Use channel-native IDs (optionally prefixed like \"whatsapp:+15551234567\"). '*' is ignored.",

View File

@@ -112,7 +112,7 @@ export type CommandsConfig = {
config?: boolean;
/** Allow /debug command (default: false). */
debug?: boolean;
/** Allow restart commands/tools (default: false). */
/** Allow restart commands/tools (default: true). */
restart?: boolean;
/** Enforce access-group allowlists/policies for commands (default: true). */
useAccessGroups?: boolean;

View File

@@ -129,11 +129,11 @@ export const CommandsSchema = z
bashForegroundMs: z.number().int().min(0).max(30_000).optional(),
config: z.boolean().optional(),
debug: z.boolean().optional(),
restart: z.boolean().optional(),
restart: z.boolean().optional().default(true),
useAccessGroups: z.boolean().optional(),
ownerAllowFrom: z.array(z.union([z.string(), z.number()])).optional(),
allowFrom: ElevatedAllowFromSchema.optional(),
})
.strict()
.optional()
.default({ native: "auto", nativeSkills: "auto" });
.default({ native: "auto", nativeSkills: "auto", restart: true });