Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quelle  config.ts

  Sprache: JAVA
 

Spracherkennung für: .ts vermutete Sprache: Unknown {[0] [0] [0]} [Methode: Schwerpunktbildung, einfache Gewichte, sechs Dimensionen]

import fs from "node:fs";
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime";
import { getPlatformAdapter } from "../engine/adapter/index.js";
import {
  DEFAULT_ACCOUNT_ID as ENGINE_DEFAULT_ACCOUNT_ID,
  applyAccountConfig,
  listAccountIds,
  resolveAccountBase,
  resolveDefaultAccountId,
} from "../engine/config/resolve.js";
import type { ResolvedQQBotAccount, QQBotAccountConfig } from "../types.js";

export const DEFAULT_ACCOUNT_ID = ENGINE_DEFAULT_ACCOUNT_ID;

interface QQBotChannelConfig extends QQBotAccountConfig {
  accounts?: Record<string, QQBotAccountConfig>;
  defaultAccount?: string;
}

/** List all configured QQBot account IDs. */
export function listQQBotAccountIds(cfg: OpenClawConfig): string[] {
  return listAccountIds(cfg as unknown as Record<string, unknown>);
}

/** Resolve the default QQBot account ID. */
export function resolveDefaultQQBotAccountId(cfg: OpenClawConfig): string {
  return resolveDefaultAccountId(cfg as unknown as Record<string, unknown>);
}

/** Resolve QQBot account config for runtime or setup flows. */
export function resolveQQBotAccount(
  cfg: OpenClawConfig,
  accountId?: string | null,
  opts?: { allowUnresolvedSecretRef?: boolean },
): ResolvedQQBotAccount {
  const raw = cfg as unknown as Record<string, unknown>;
  const base = resolveAccountBase(raw, accountId);

  const qqbot = cfg.channels?.qqbot as QQBotChannelConfig | undefined;
  const accountConfig: QQBotAccountConfig =
    base.accountId === DEFAULT_ACCOUNT_ID
      ? (qqbot ?? {})
      : (qqbot?.accounts?.[base.accountId] ?? {});

  let clientSecret = "";
  let secretSource: "config" | "file" | "env" | "none" = "none";

  const clientSecretPath =
    base.accountId === DEFAULT_ACCOUNT_ID
      ? "channels.qqbot.clientSecret"
      : `channels.qqbot.accounts.${base.accountId}.clientSecret`;

  const adapter = getPlatformAdapter();
  if (adapter.hasConfiguredSecret(accountConfig.clientSecret)) {
    clientSecret = opts?.allowUnresolvedSecretRef
      ? (adapter.normalizeSecretInputString(accountConfig.clientSecret) ?? "")
      : (adapter.resolveSecretInputString({
          value: accountConfig.clientSecret,
          path: clientSecretPath,
        }) ?? "");
    secretSource = "config";
  } else if (accountConfig.clientSecretFile) {
    try {
      clientSecret = fs.readFileSync(accountConfig.clientSecretFile, "utf8").trim();
      secretSource = "file";
    } catch {
      secretSource = "none";
    }
  } else if (process.env.QQBOT_CLIENT_SECRET && base.accountId === DEFAULT_ACCOUNT_ID) {
    clientSecret = process.env.QQBOT_CLIENT_SECRET;
    secretSource = "env";
  }

  return {
    accountId: base.accountId,
    name: accountConfig.name,
    enabled: base.enabled,
    appId: base.appId,
    clientSecret,
    secretSource,
    systemPrompt: base.systemPrompt,
    markdownSupport: base.markdownSupport,
    config: accountConfig,
  };
}

/** Apply account config updates back into the OpenClaw config object. */
export function applyQQBotAccountConfig(
  cfg: OpenClawConfig,
  accountId: string,
  input: {
    appId?: string;
    clientSecret?: string;
    clientSecretFile?: string;
    name?: string;
  },
): OpenClawConfig {
  return applyAccountConfig(
    cfg as unknown as Record<string, unknown>,
    accountId,
    input,
  ) as OpenClawConfig;
}

¤ Dauer der Verarbeitung: 0.23 Sekunden  (vorverarbeitet am  2026-04-27) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge