Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Java/Openclaw/extensions/amazon-bedrock/   (KI Agentensystem Version 22©)  Datei vom 26.3.2026 mit Größe 3 kB image not shown  

Quelle  config-compat.ts

  Sprache: JAVA
 

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

import { isRecord } from "openclaw/plugin-sdk/text-runtime";

type JsonRecord = Record<string, unknown>;

const LEGACY_PATH = "models.bedrockDiscovery";
const TARGET_PATH = "plugins.entries.amazon-bedrock.config.discovery";
const BLOCKED_OBJECT_KEYS = new Set(["__proto__", "prototype", "constructor"]);

function isBlockedObjectKey(key: string): boolean {
  return BLOCKED_OBJECT_KEYS.has(key);
}

function getRecord(value: unknown): JsonRecord | null {
  return isRecord(value) ? value : null;
}

function ensureRecord(root: JsonRecord, key: string): JsonRecord {
  const existing = root[key];
  if (isRecord(existing)) {
    return existing;
  }
  const next: JsonRecord = {};
  root[key] = next;
  return next;
}

function mergeMissing(target: JsonRecord, source: JsonRecord): void {
  for (const [key, value] of Object.entries(source)) {
    if (value === undefined || isBlockedObjectKey(key)) {
      continue;
    }
    const existing = target[key];
    if (existing === undefined) {
      target[key] = value;
      continue;
    }
    if (isRecord(existing) && isRecord(value)) {
      mergeMissing(existing, value);
    }
  }
}

function cloneRecord<T extends JsonRecord>(value: T | undefined): T {
  return { ...value } as T;
}

function resolveLegacyBedrockDiscoveryConfig(raw: unknown): JsonRecord | undefined {
  if (!isRecord(raw)) {
    return undefined;
  }
  const models = getRecord(raw.models);
  return getRecord(models?.bedrockDiscovery) ?? undefined;
}

function pruneEmptyModelsRoot(root: JsonRecord): void {
  const models = getRecord(root.models);
  if (models && Object.keys(models).length === 0) {
    delete root.models;
  }
}

export function migrateAmazonBedrockLegacyConfig<T>(raw: T): { config: T; changes: string[] } {
  if (!isRecord(raw)) {
    return { config: raw, changes: [] };
  }

  const legacy = resolveLegacyBedrockDiscoveryConfig(raw);
  if (!legacy) {
    return { config: raw, changes: [] };
  }

  const nextRoot = structuredClone(raw) as JsonRecord;
  const models = ensureRecord(nextRoot, "models");
  delete models.bedrockDiscovery;
  pruneEmptyModelsRoot(nextRoot);

  const changes: string[] = [];
  if (Object.keys(legacy).length === 0) {
    changes.push(`Removed empty ${LEGACY_PATH}.`);
    return { config: nextRoot as T, changes };
  }

  const plugins = ensureRecord(nextRoot, "plugins");
  const entries = ensureRecord(plugins, "entries");
  const entry = ensureRecord(entries, "amazon-bedrock");
  const config = ensureRecord(entry, "config");
  const existing = getRecord(config.discovery) ?? undefined;

  if (!existing) {
    config.discovery = cloneRecord(legacy);
    changes.push(`Moved ${LEGACY_PATH} → ${TARGET_PATH}.`);
    return { config: nextRoot as T, changes };
  }

  const merged = cloneRecord(existing);
  mergeMissing(merged, legacy);
  config.discovery = merged;
  if (JSON.stringify(merged) !== JSON.stringify(existing)) {
    changes.push(
      `Merged ${LEGACY_PATH} → ${TARGET_PATH} (filled missing fields from legacy; kept explicit plugin config values).`,
    );
    return { config: nextRoot as T, changes };
  }

  changes.push(`Removed ${LEGACY_PATH} (${TARGET_PATH} already set).`);
  return { config: nextRoot as T, changes };
}

¤ Dauer der Verarbeitung: 0.18 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.