mirror of
http://192.168.0.88:13333/lywsvip/openclaw-zero-token.git
synced 2026-05-10 00:56:22 +08:00
Major upgrade from e26988a38 to upstream v2026.3.28 (f9b107928).
Key changes:
- Upstream src/, ui/, extensions/ (89 bundled extensions)
- Zero-token web providers preserved in src/zero-token/
- AskOnce plugin restored and registered as CLI command
- Added missing packages: @anthropic-ai/vertex-sdk, @modelcontextprotocol/sdk
- Fixed tsconfig rootDir, skipLibCheck for plugin-sdk DTS build
- Added askonce to bundled plugin metadata and package.json exports
- Fixed AskOnce CLI command registration (missing commands metadata)
- Restored AskOnce adapter imports (correct 5-level relative paths)
- Removed stale migration artifacts from root directory
72 lines
2.4 KiB
TypeScript
72 lines
2.4 KiB
TypeScript
import { type ChannelId, getChannelPlugin } from "../../channels/plugins/index.js";
|
|
import {
|
|
type CommandSecretResolutionMode,
|
|
resolveCommandSecretRefsViaGateway,
|
|
} from "../../cli/command-secret-gateway.js";
|
|
import { getChannelsCommandSecretTargetIds } from "../../cli/command-secret-targets.js";
|
|
import type { OpenClawConfig } from "../../config/config.js";
|
|
import { DEFAULT_ACCOUNT_ID } from "../../routing/session-key.js";
|
|
import { defaultRuntime, type RuntimeEnv } from "../../runtime.js";
|
|
import { requireValidConfigSnapshot } from "../config-validation.js";
|
|
|
|
export type ChatChannel = ChannelId;
|
|
|
|
export { requireValidConfigSnapshot };
|
|
|
|
export async function requireValidConfig(
|
|
runtime: RuntimeEnv = defaultRuntime,
|
|
secretResolution?: {
|
|
commandName?: string;
|
|
mode?: CommandSecretResolutionMode;
|
|
},
|
|
): Promise<OpenClawConfig | null> {
|
|
const cfg = await requireValidConfigSnapshot(runtime);
|
|
if (!cfg) {
|
|
return null;
|
|
}
|
|
const { resolvedConfig, diagnostics } = await resolveCommandSecretRefsViaGateway({
|
|
config: cfg,
|
|
commandName: secretResolution?.commandName ?? "channels",
|
|
targetIds: getChannelsCommandSecretTargetIds(),
|
|
mode: secretResolution?.mode,
|
|
});
|
|
for (const entry of diagnostics) {
|
|
runtime.log(`[secrets] ${entry}`);
|
|
}
|
|
return resolvedConfig;
|
|
}
|
|
|
|
export function formatAccountLabel(params: { accountId: string; name?: string }) {
|
|
const base = params.accountId || DEFAULT_ACCOUNT_ID;
|
|
if (params.name?.trim()) {
|
|
return `${base} (${params.name.trim()})`;
|
|
}
|
|
return base;
|
|
}
|
|
|
|
export const channelLabel = (channel: ChatChannel) => {
|
|
const plugin = getChannelPlugin(channel);
|
|
return plugin?.meta.label ?? channel;
|
|
};
|
|
|
|
export function formatChannelAccountLabel(params: {
|
|
channel: ChatChannel;
|
|
accountId: string;
|
|
name?: string;
|
|
channelStyle?: (value: string) => string;
|
|
accountStyle?: (value: string) => string;
|
|
}): string {
|
|
const channelText = channelLabel(params.channel);
|
|
const accountText = formatAccountLabel({
|
|
accountId: params.accountId,
|
|
name: params.name,
|
|
});
|
|
const styledChannel = params.channelStyle ? params.channelStyle(channelText) : channelText;
|
|
const styledAccount = params.accountStyle ? params.accountStyle(accountText) : accountText;
|
|
return `${styledChannel} ${styledAccount}`;
|
|
}
|
|
|
|
export function shouldUseWizard(params?: { hasFlags?: boolean }) {
|
|
return params?.hasFlags === false;
|
|
}
|