mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-04 23:50:20 +00:00
feat(cli): add json schema to cli tool (#54523)
Merged via squash.
Prepared head SHA: 39c15ee70d
Co-authored-by: kvokka <15954013+kvokka@users.noreply.github.com>
Co-authored-by: altaywtf <9790196+altaywtf@users.noreply.github.com>
Reviewed-by: @altaywtf
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
import { exec } from "node:child_process";
|
||||
import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../../agents/agent-scope.js";
|
||||
import { listChannelPlugins } from "../../channels/plugins/index.js";
|
||||
import {
|
||||
createConfigIO,
|
||||
loadConfig,
|
||||
parseConfigJson5,
|
||||
readConfigFileSnapshot,
|
||||
readConfigFileSnapshotForWrite,
|
||||
@@ -19,11 +16,8 @@ import {
|
||||
redactConfigSnapshot,
|
||||
restoreRedactedValues,
|
||||
} from "../../config/redact-snapshot.js";
|
||||
import {
|
||||
buildConfigSchema,
|
||||
lookupConfigSchema,
|
||||
type ConfigSchemaResponse,
|
||||
} from "../../config/schema.js";
|
||||
import { loadGatewayRuntimeConfigSchema } from "../../config/runtime-schema.js";
|
||||
import { lookupConfigSchema, type ConfigSchemaResponse } from "../../config/schema.js";
|
||||
import { extractDeliveryInfo } from "../../config/sessions.js";
|
||||
import type { ConfigValidationIssue, OpenClawConfig } from "../../config/types.openclaw.js";
|
||||
import {
|
||||
@@ -32,7 +26,6 @@ import {
|
||||
writeRestartSentinel,
|
||||
} from "../../infra/restart-sentinel.js";
|
||||
import { scheduleGatewaySigusr1Restart } from "../../infra/restart.js";
|
||||
import { loadOpenClawPlugins } from "../../plugins/loader.js";
|
||||
import { diffConfigPaths } from "../config-reload.js";
|
||||
import {
|
||||
formatControlPlaneActor,
|
||||
@@ -243,41 +236,11 @@ async function tryWriteRestartSentinelPayload(
|
||||
}
|
||||
|
||||
function loadSchemaWithPlugins(): ConfigSchemaResponse {
|
||||
const cfg = loadConfig();
|
||||
const workspaceDir = resolveAgentWorkspaceDir(cfg, resolveDefaultAgentId(cfg));
|
||||
const pluginRegistry = loadOpenClawPlugins({
|
||||
config: cfg,
|
||||
cache: true,
|
||||
workspaceDir,
|
||||
runtimeOptions: {
|
||||
allowGatewaySubagentBinding: true,
|
||||
},
|
||||
logger: {
|
||||
info: () => {},
|
||||
warn: () => {},
|
||||
error: () => {},
|
||||
debug: () => {},
|
||||
},
|
||||
});
|
||||
// Note: We can't easily cache this, as there are no callback that can invalidate
|
||||
// our cache. However, both loadConfig() and loadOpenClawPlugins() already cache
|
||||
// their results, and buildConfigSchema() is just a cheap transformation.
|
||||
return buildConfigSchema({
|
||||
plugins: pluginRegistry.plugins.map((plugin) => ({
|
||||
id: plugin.id,
|
||||
name: plugin.name,
|
||||
description: plugin.description,
|
||||
configUiHints: plugin.configUiHints,
|
||||
configSchema: plugin.configJsonSchema,
|
||||
})),
|
||||
channels: listChannelPlugins().map((entry) => ({
|
||||
id: entry.id,
|
||||
label: entry.meta.label,
|
||||
description: entry.meta.blurb,
|
||||
configSchema: entry.configSchema?.schema,
|
||||
configUiHints: entry.configSchema?.uiHints,
|
||||
})),
|
||||
});
|
||||
// our cache. However, loadConfig() and loadOpenClawPlugins() (called inside
|
||||
// loadGatewayRuntimeConfigSchema) already cache their results, and buildConfigSchema()
|
||||
// is just a cheap transformation.
|
||||
return loadGatewayRuntimeConfigSchema();
|
||||
}
|
||||
|
||||
export const configHandlers: GatewayRequestHandlers = {
|
||||
|
||||
Reference in New Issue
Block a user