























@@ -1,3 +1,4 @@
1+// Shared config loading and account-line formatting helpers for channel commands.
12import { hasConfiguredUnavailableCredentialStatus } from "../../channels/account-snapshot-fields.js";
23import type { ChannelId } from "../../channels/plugins/types.public.js";
34import { resolveCommandConfigWithSecrets } from "../../cli/command-config-resolution.js";
@@ -16,6 +17,7 @@ export type ChatChannel = ChannelId;
1617export { requireValidConfigSnapshot };
1718export { requireValidConfigFileSnapshot };
181920+/** Load valid channel command config with read-only secret resolution applied. */
1921export async function requireValidConfig(
2022runtime: RuntimeEnv = defaultRuntime,
2123secretResolution?: {
@@ -45,6 +47,7 @@ function formatAccountLabel(params: { accountId: string; name?: string }) {
4547return base;
4648}
474950+/** Format a channel/account label with optional display styles for terminal output. */
4851export function formatChannelAccountLabel(params: {
4952channel: ChatChannel;
5053accountId: string;
@@ -63,6 +66,7 @@ export function formatChannelAccountLabel(params: {
6366return `${styledChannel} ${styledAccount}`;
6467}
656869+/** Append common enabled/configured/linked status fragments for account output. */
6670export function appendEnabledConfiguredLinkedBits(
6771bits: string[],
6872account: Record<string, unknown>,
@@ -85,12 +89,14 @@ export function appendEnabledConfiguredLinkedBits(
8589}
8690}
879192+/** Append account mode metadata when present. */
8893export function appendModeBit(bits: string[], account: Record<string, unknown>) {
8994if (typeof account.mode === "string" && account.mode.length > 0) {
9095bits.push(`mode:${account.mode}`);
9196}
9297}
939899+/** Append credential source fragments, preserving unavailable-secret state. */
94100export function appendTokenSourceBits(bits: string[], account: Record<string, unknown>) {
95101const appendSourceBit = (label: string, sourceKey: string, statusKey: string) => {
96102const source = account[sourceKey];
@@ -108,12 +114,14 @@ export function appendTokenSourceBits(bits: string[], account: Record<string, un
108114appendSourceBit("signing", "signingSecretSource", "signingSecretStatus");
109115}
110116117+/** Append account base URL metadata when present. */
111118export function appendBaseUrlBit(bits: string[], account: Record<string, unknown>) {
112119if (typeof account.baseUrl === "string" && account.baseUrl) {
113120bits.push(`url:${account.baseUrl}`);
114121}
115122}
116123124+/** Build a complete human-readable channel account status line. */
117125export function buildChannelAccountLine(
118126provider: ChatChannel,
119127account: Record<string, unknown>,
@@ -131,6 +139,7 @@ export function buildChannelAccountLine(
131139return `- ${labelText}: ${bits.join(", ")}`;
132140}
133141142+/** Return true when the command should use its interactive wizard path. */
134143export function shouldUseWizard(params?: { hasFlags?: boolean }) {
135144return params?.hasFlags === false;
136145}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。