mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-22 19:31:15 +00:00
* feat(linux): add node device capabilities * fix(linux-node): actionable pending-approval error + node-host advertise integration test * fix(linux-node): map geoclue access-denied to LOCATION_DISABLED; floor camera maxWidth to avoid zero-height scale * fix(linux-node): clamp small camera maxWidth to 2 instead of default * docs(linux-node): clarify where-am-i -t is a process timeout, not update throttle * refactor(gateway): extract legacy-node filter + rejection hint to fit LOC ratchet; docs-map + deadcode baseline * fix(gateway): drop now-unused DEFAULT_DANGEROUS_NODE_COMMANDS import after hint extraction * test(node-host): drop imports orphaned by removed error-code test
63 lines
2.1 KiB
TypeScript
63 lines
2.1 KiB
TypeScript
import type { OpenClawPluginNodeHostCommandAvailabilityContext } from "openclaw/plugin-sdk/plugin-entry";
|
|
import { buildPluginConfigSchema } from "openclaw/plugin-sdk/plugin-entry";
|
|
import { z } from "zod";
|
|
|
|
const CapabilityConfigSchema = z.strictObject({
|
|
enabled: z.boolean().optional(),
|
|
});
|
|
|
|
const LinuxNodePluginConfigSchema = z.strictObject({
|
|
notify: CapabilityConfigSchema.optional(),
|
|
camera: CapabilityConfigSchema.optional(),
|
|
location: CapabilityConfigSchema.optional(),
|
|
});
|
|
|
|
export type ResolvedLinuxNodePluginConfig = {
|
|
notify: { enabled: boolean };
|
|
camera: { enabled: boolean };
|
|
location: { enabled: boolean };
|
|
};
|
|
|
|
export function createLinuxNodePluginConfigSchema() {
|
|
return buildPluginConfigSchema(LinuxNodePluginConfigSchema, {
|
|
uiHints: {
|
|
"notify.enabled": {
|
|
label: "Desktop Notifications",
|
|
help: "Expose system.notify when notify-send is installed. Enabled by default.",
|
|
},
|
|
"camera.enabled": {
|
|
label: "Camera",
|
|
help: "Expose camera commands when FFmpeg is installed. Requires a node service restart.",
|
|
},
|
|
"location.enabled": {
|
|
label: "Location",
|
|
help: "Expose location.get when the GeoClue where-am-i demo is installed. Requires a node service restart.",
|
|
},
|
|
},
|
|
});
|
|
}
|
|
|
|
export function resolveLinuxNodePluginConfig(value: unknown): ResolvedLinuxNodePluginConfig {
|
|
const parsed = LinuxNodePluginConfigSchema.safeParse(value ?? {});
|
|
if (!parsed.success) {
|
|
throw new Error(
|
|
`Invalid linux-node plugin config: ${parsed.error.issues[0]?.message ?? "invalid config"}`,
|
|
);
|
|
}
|
|
return {
|
|
notify: { enabled: parsed.data.notify?.enabled ?? true },
|
|
camera: { enabled: parsed.data.camera?.enabled ?? false },
|
|
location: { enabled: parsed.data.location?.enabled ?? false },
|
|
};
|
|
}
|
|
|
|
export function resolveLinuxNodePluginConfigFromHost(
|
|
config: OpenClawPluginNodeHostCommandAvailabilityContext["config"],
|
|
): ResolvedLinuxNodePluginConfig | null {
|
|
try {
|
|
return resolveLinuxNodePluginConfig(config.plugins?.entries?.["linux-node"]?.config);
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|