mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-07 22:09:57 +00:00
refactor: unify restart gating and update availability sync
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -61,3 +61,7 @@ export function isNativeCommandsExplicitlyDisabled(params: {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function isRestartEnabled(config?: { commands?: { restart?: boolean } }): boolean {
|
||||
return config?.commands?.restart !== false;
|
||||
}
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user