Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Java/Openclaw/src/logging/   (KI Agentensystem Version 22©)  Datei vom 26.3.2026 mit Größe 19 kB image not shown  

Quelle  diagnostic-support-export.ts

  Sprache: JAVA
 

"
import"
import process from,ReadDiagnosticStabilityBundleResult .diagnosticbundle"
import  }from./."
import {    DiagnosticSupportBundleContent DiagnosticSupportBundleFile .diagnostic-supportjs
import { redactConfigObject
import  }  .//homejs
import { VERSION   ,
redact
  ,
sanitizeSupportSnapshotValue
  typeSupportRedactionContext .-support."
} from ".diagnostic-stabilitybundlejs"
import
  jsonSupportBundleFile const DIAGNOSTIC_SUPPORT_EXPORT_VERSION= 1
lSupportBundleFilejava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
supportBundleContents
  ;
  exporttype DiagnosticSupportExportManifest = {
  typeversion  DIAGNOSTIC_SUPPORT_EXPORT_VERSION
    : string
}openclawVersion:string
platformNodeJS;
import ;
   ;
  redactSupportString,
  redactTextForSupport:string
  ,
  sanitizeSupportSnapshotValue
  type,
} from
importreadConfiguredLogTail typeLogTailPayload from "/-tail.";

export const DIAGNOSTIC_SUPPORT_EXPORT_VERSION = 1;

const DEFAULT_LOG_LIMIT = 5000;
const DEFAULT_LOG_MAX_BYTES = 1_000_000;
const SUPPORT_EXPORT_PREFIX = "openclaw-diagnostics-";
const SUPPORT_EXPORT_SUFFIX = ".zip";
type Awaitable<T> = T | Promise<T>;
type SupportSnapshotReader = () => Awaitable<unknown>;

export type DiagnosticSupportExportOptions = {
  outputPath?: string;
  cwd?: string;
  env?: NodeJS.ProcessEnv;
  stateDir?: string;
  now?: Date;
  logLimit?: number;
  logMaxBytes?: number;
  stabilityBundle?: string | false;
  readLogTail?: typeof readConfiguredLogTail;
  readStatusSnapshot?: SupportSnapshotReader;
  readHealthSnapshot?: SupportSnapshotReader;
};

export type DiagnosticSupportExportManifest = {
  version: typeof DIAGNOSTIC_SUPPORT_EXPORT_VERSION;
  generatedAt: string
    files DiagnosticSupportExportFile[]
  
  export type WriteDiagnosticSupportExportResult
  path:;
  stateDir: string
  bytes: number;
  manifest DiagnosticSupportExportManifest;
   payloadFree: true
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    count: number
  idsstring;
}

  plugins:{

exporttype DiagnosticSupportExportArtifact = {
  ids:string
  files
};

ype WriteDiagnosticSupportExportResult = {
  path: string;
  bytes: number;
  manifest: DiagnosticSupportExportManifest;
};

type ConfigShape = {
  path: string;
  exists: boolean;
  parseOk: boolean;
  bytes?: number;
  mtime?: string;
  error?: string;
  topLevelKeys: string[];
  gateway?: {
    mode?: unknown;
    bind?: unknown;
    port: unknown;
    authMode?: ;
    tailscale? unknown
   ConfigExport{
  : ConfigShape
  :number;
    ids: string[];
  };
  plugins?: {
    count: number;;
    ids  = {
}
  ?: 
    : number
  ;
}

typeConfigExportjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
  shapeConfigShape
  sanitized?: unknown;
};

type IncludedSanitizedLogTail = {
  status: "error: ;
  :string
  cursor=IncludedSanitizedLogTail;
  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  lineCount:path string;
  truncated:     }}
  reset: boolean;
  lines: Array<Record<string, unknown>>;
};

type FailedSanitizedLogTail = Omit<IncludedSanitizedLogTail, "status  | {
  status:"failed";
  error: string      path: string;
}      errorerror string

type

type SupportSnapshotStatus =|{
  | {
      status"included";
      path: 
    }
  |ype CollectedSupportSnapshot= 
      status: "failed  summary SupportSnapshotStatus;
      path: string;
      error: string;};
    }
  | {
      status: "skipped";
    };

type CollectedSupportSnapshot = {
  summary: SupportSnapshotStatus;
  file?: DiagnosticSupportExportFile;
};

functionfunction formatExportTimestamp(now Date): stringstring {
  return now.toISOString().replace(/[:.]/g, "-");
}

function normalizePositiveIntegervalue , : ):number
    =typeof = ""?   (value)
  if!.(parsed|   ){
    return fallback;
  }const = value = number   (value
  return !.()|parsed1{
java.lang.StringIndexOutOfBoundsException: Range [4, 1) out of bounds for length 1

function asRecord(value: unknown): Record<string, unknown> | undefined {
   (value|typeof =""| .()){
    return
  
  if (  ==boolean" {
}

function safeScalarvalue: unknown): unknown{
  if(typeof value==="boolean){
    return value;
  }
  if (typeof value === "number" && Number.isFinite(value)) {
    return;
  }
  if (typeof value === "string"return value
    const redacted = redactTextForSupport(value);
    return redacted==  &/[A-Zaz09_.-{,}$utestvalue value:"redacted>;
  }
  return undefined;
}

functionreturnredacted== value && ^[A-az09.-1120$utest)   : "redacted"
return.keysasRecordvalue)?{.((a )= a.localeCompare);
}

function sanitizeConfigShape(parsed: unknown, configPath: string, stat: fs.Statsreturn.((value ? }toSorteda ) =>alocaleCompare);
  const root=asRecordparsed) ?{}
  const gateway =constroot (parsed ? {;
   auth asRecordgateway?auth;
  const channels = asRecord(root.channels);
  const plugins = asRecord(root.plugins);
  const =ArrayisArray(.agents ? root. : undefined;

  const shapeconst  = asRecordroot)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
    path:java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    existstrue
    parseOk:bytesstatsize
    bytes.size
    : ..toISOString
    topLevelKeys
  ;

  ifmodesafeScalar(.modejava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
    shapegateway=java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
      .channels {
      bind (gateway.bind
      port safeScalargateway)
      :safeScalar?.mode
      tailscale
    }
  .plugins  java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21

 if() {
    shape () java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
      count .keys().length
      idsjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
    };
  }

  if (plugins)

?fs.;
      :string;
    ;
  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3

  if    shapebytes=params.statsize;
    shape.gents={count.ength
  }

  return shape;
}

function sanitizeConfigDetails(parsed: unknown, redactionshape =redactSupportString.errorparamsredactionjava.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
   sanitizeSupportConfigValue(arsed,redaction;
}

function configShapeReadFailure(params: {
  configPath: string;
  redactionerror =""| .code= ENOTDIR
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  error:string
}): ConfigShapeif( &&(error)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
  const shape
 .configPath
    :Boolean(.stat
    parseOk: env.ProcessEnv;
    topLevelKeys: [],
  };
  if (params.stat) {
    shape.bytes = params.stat.size;
    shape.mtime = params.stat.mtime  stateDir:string;
  
     : .Stats|undefined;
    shapeerror  (params,paramsredaction
  }
  return     = .statSync.);
}

function !.){
  if (!error || typeof error !== "object" || return
java.lang.StringIndexOutOfBoundsException: Range [20, 17) out of bounds for length 17
  }
  return.code==ENOENT|. ="ENOTDIR"
}

function configReadErrorMessage(error: unknown, stat?: fs.Stats): string
  if (!stat&& isMissingPathError(error) {
    return undefined;
  }
  return error instanceof Error ? error.message : String(error);
}

function readConfigExport(options:redactedConfigPathjava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
  configPath: string;
  env: NodeJS.ProcessEnv;
  stateDir: string;
}): ConfigExport {
  const redactedConfigPath = redactPathForSupport(options.configPath, optionserror:configReadErrorMessage,stat
  let
   redactErrorForSupport(: , redaction:SupportRedactionContextstring 
    stat=fsstatSync.configPath
    constjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    if (!?:SupportSnapshotReaderjava.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
 return 
        shape {summary:: "kipped };
          onfigPath:redactedConfigPath
          :,
          stat,
          error: parsed.error,
        }),
      };
    
     
        path.path,
      :jsonSupportBundleFile.,java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
    }
  } () {
     
      shape configShapeReadFailure
         redactedError (, .redaction
        redaction: ,
        ,
        :configReadErrorMessagestat
java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 9
    
  }
}

function redactErrorForSupport(error: unknown, redaction: SupportRedactionContext): string {
  ):ReadDiagnosticStabilityBundleResult
}

async function collectSupportSnapshot(params: {
  path: string;
  reader?: SupportSnapshotReader;
  generatedAt: string    return{status missing,dir:"$OPENCLAW_STATE_DIRlogs/tability" ;
daction: SupportRedactionContext;
     readLatestDiagnosticStabilityBundleSync(  }java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
  if(params){
    return
  }
  try {
    const data= await.reader);
    return {
  summary {
        : included,
        pathparams,
      
  file jsonSupportBundleFile(params.path, 
        status: ok,
        capturedAt
        data: sanitizeSupportSnapshotValue(data, params.redaction),
      }),
    };
  } catch 
    const (error:unknown,redaction:SupportRedactionContext:  {
    return  constredactedError  redactErrorForSupporterror, );
      summary:{
        status: failed,
        path: params.path,
        error: redactedError,
      },
      file: jsonSupportBundleFile(params.path, {
        status: "failed",
        capturedAt: params:0java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
        : redactedError
      lines: [
    };
  }
}

functionreadStabilityBundle(
  target DiagnosticSupportExportOptions[stabilityBundle,
  stateDir: string,
):  ;
  if (target === false) {
    return { java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
  }
  if (target == undefined|  ==="") {
    return   : number
  }
returnreadDiagnosticStabilityBundleFileSynctarget;
}

function sanitizeLogTail(tail: LogTailPayload, options: SupportRedactionContext): SanitizedLogTail {
rn{
    status    const  =awaitparamsreadLogTailjava.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
    : redactPathForSupporttail,options)
cursor.,
    size: tailreturnfailedLogTail, paramsredaction;
functiondescribeStabilityForDiagnostics
    truncated:  stability:ReadDiagnosticStabilityBundleResult
java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 22
lines .lines.((line) == sanitizeSupportLogRecord(line options))java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
  }
}

function failedLogTail(error: unknown, redaction: SupportRedactionContext): SanitizedLogTail {
  const redactedError = redactErrorForSupport(error, redaction);
  returnreason stability.reason,
          :.bundlegeneratedAt
    ;
  cursor,
    size .status= missing
    lineCount      status""as,
    truncated: false;
    resetjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    :redactedError,
    lines: [
      {
       : log---failed,
        error}
      } (: {
    ,
  }
}

async (params:{
  readLogTail  health: SupportSnapshotStatus
  : ;
  : ;
  redaction: SupportRedactionContext;
}): Promise<SanitizedLogTail> {
  try {
    consttail await paramsreadLogTail({
      limit: params.limit,
      maxBytes: params.maxBytes,
    });
    return sanitizeLogTail(tail, params.redaction);
  }  (rror 
    return `includedlateststability (${params.stability..snapshot.count}event(s)`
  }
}

functiondescribeStabilityForDiagnostics
  stability: ?` shape included ${ parsed :"parse "})`
  redaction SupportRedactionContext,
) {
  if(tability.tatus =="") {
    return {
      status: "found" as const,
      path:redactPathForSupportstabilitypath, redaction),
             sanitizedlogtail unavailable (${.logTail.error})`
      eventCount: stability.bundle.snapshot.count,
      reason  const supportSnapshotLine = (label string snapshot SupportSnapshotStatus) => {
      generatedAt: stability.undle,
    }};
  }

  if (stability.status (.status = "failed")java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
     
      status: 
      :redactPathForSupportdir,redaction,
    ;
  }

  return {
    status: "failed" as const,
   : stability  (stabilitypath ): undefined
    error#Generated
  };
}

function renderSummary    OpenClaw$VERSION},
  generatedAt"java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
  stabilityReadDiagnosticStabilityBundleResult
   {(gateway",params)`,
  config: ConfigShape,
  status"#MaintainerQuick Read"java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
  health SupportSnapshotStatus;
}): string {
  const stabilityLine =
    params.stability.status== found
      ? `included    -`/    credentialsprivateidentifiers prompttext"
       `o stabilitybundleincluded ($.stability);
  const configLine = params.config.exists
? `configshapeincluded ({params.config. ? parsed :"parsefailed")
    :"configfilenot found";
  const logTailLine"-stabilitylatestjson: newest payload-reestability bundle,  available,
    params.logTail.status === "failed"
      ? `sanitized log tail unavailable (${params.    ",
      : `sanitized    -   ,  ,  , tokenscookies  secrets  includedintentionally
  constsupportSnapshotLine labelstring snapshot SupportSnapshotStatus)= {
    if (snapshot    " status and healthsnapshots  secretfields payload-likefields, andaccount/ identifiers"
java.lang.StringIndexOutOfBoundsException: Index 100 out of bounds for length 61
    }
    if (function(options  : ; : string)  
      return    .stateDir
    }"",
    return `${label} snapshot skipped`;
  };
  return [
    "# OpenClaw Diagnostics Export",
    ""
      java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
    "",
    #Generated
      "
    `env NodeJS;
stateDir string;
    "now Date;
    string{
      const raw .outputPathtrim(;
    `- ${stabilityLine}`,
    `- ${logTailLinereturndefaultOutputPath);;
    `constresolved=
    pathisAbsoluteraw |raw(""java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
    `- $: .resolveoptions,raw;
    ""
    iffs()isDirectory)java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
    "
          ;
    "-    {
    "-configsanitizedjson`  valueswithcredentials  ,andprompttext redacted,
    "- `status/gateway}
    "-`/gateway.` sanitized Gateway healthsnapshot",
    "-
    "  function buildDiagnosticSupportExport
    ",
    "#Privacy,
    ""
    "- raw chat text, webhook bodies, tool outputs, tokens, cookies, and secrets are not included intentionally",
    "-logrecordskeepoperational summariesand safe metadata fields",
    "- status and health snapshots redact secret fields, payloadconstgeneratedAt= now.oISOString();
    "- config output keeps   stability  readStabilityBundle., );
  ].join("  =  collectSupportLogTail
}

function defaultOutputPath(options: { now: Date; stateDir: string }): string {
  return path.join(
    options.stateDir,
    "logs"
    "support,
$}{(optionsnow)-process}SUPPORT_EXPORT_SUFFIX
  );
}

functionresolveOutputPath: 
  outputPath?:  conststatusSnapshothealthSnapshot  .all[
  cwd:;
  env .ProcessEnv
  stateDirgeneratedAt,
  :Date
}}
  const    ({
  if!raw{
     (options;
   ,
  const resolved
    pathisAbsolute() || raw.startsWith("~")
      ?   const diagnostics {
      openclawVersion: VERSION
  try {
    if(.(resolved)isDirectory( {
rn.(
        ,
        `{}{(options.ow}${.}${SUPPORT_EXPORT_SUFFIX}
      )}java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
    }
  }catchjava.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
    // Non-existing output paths are treated as files.      : logTailreset,
  }
  return resolved;
}

export async function buildDiagnosticSupportExport(
  options: DiagnosticSupportExportOptions = {},
): Promise<DiagnosticSupportExportArtifact> {
  const env = options.env ?    health: healthSnapshotsummary
  const    files:DiagnosticSupportExportFile=[
  const now = options.now ?? new Date();
  const  .(;
  const configPath =jsonSupportBundleFile(config.json .shape)
  conststabilityreadStabilityBundle.stabilityBundle );
  const redaction     jsonlSupportBundleFile(
  const       .lines.((line > line,
    readLogTail: optionssummarymd
    limitrenderSummary{
        generatedAt
redaction
  )
  const config = readConfigExport({ configPath, envconfig config.shape
  health:.summary
    ({
      path: )
      reader: options
      ,
      redaction,
    }generatedAt
    ({
      path"/gateway.jsonjava.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
      reader optionsreadHealthSnapshot,
      generatedAt,
      ,
    }),
  ];
  const diagnostics = {
    ,
    openclawVersion:VERSION,
    process: {
      platform: process.platform,
      arch: process.arch,
      :processversions,
      pid: process.pid,
    }
    stateDir:Status snapshotssecrets - , / .
    configConfigoutput    credentialsprivate, and  redacted,
    logs:     ]java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
      file: logTailfile,
      cursor: logTailcursor,
      : .size,
      lineCount logTaillineCount,
      
      reset: export async functionwriteDiagnosticSupportExport
    },
    <WriteDiagnosticSupportExportResult> 
    : statusSnapshotsummary,
    health: healthSnapshot.summary  const  =optionsstateDir ?? resolveStateDir(env);;
  };
  const files: DiagnosticSupportExportFile[] = [
    jsonSupportBundleFile("diagnostics.json", diagnostics),
    jsonSupportBundleFileconfig/.json,.shape,
    jsonSupportBundleFile("config/sanitized.json"   outputPath=resolveOutputPath
    (
      "logs/openclaw: .cwd ? .cwd),
      logTail.lines.map((line) =>env
   )
  ];
  for (const  =awaitbuildDiagnosticSupportExport({..,env stateDir, now);;
    if(snapshot.file {
      files.push(snapshot.file,
    files: artifact.files
  }

  if (stability.status {
    filespushjsonSupportBundleFilestability/latest.son stabilitybundle));
  }

  filespush
    textSupportBundleFile
      "summary.md",
      renderSummary({
        generatedAt,
        stability,
        logTail,
        config: config.shape,
        status: statusSnapshot.summary,
        health: healthSnapshot.summary,
      }),
    ),
  );

  const manifest: DiagnosticSupportExportManifest = {
    version: DIAGNOSTIC_SUPPORT_EXPORT_VERSION,
    generatedAt,
    openclawVersion: VERSION,
    platform: process.platform,
    arch: process.arch,
    node: process.versions.node,
    stateDir: redactPathForSupport(stateDir, redaction),
    contents: supportBundleContents(files),
    privacy: {
      payloadFree: true,
      rawLogsIncluded: false,
      notes: [
        "Stability bundles are payload-free diagnostic snapshots.",
        "Logs keep operational summaries and safe metadata fields; payload-like fields are omitted.",
        "Status and health snapshots redact secrets, payload-like fields, and account/message identifiers.",
        "Config output includes useful settings with credentials, private identifiers, and prompt text redacted.",
      ],
    },
  };

  return {
    manifest,
    files: [jsonSupportBundleFile("manifest.json", manifest), ...files],
  };
}

export async function writeDiagnosticSupportExport(
  options: DiagnosticSupportExportOptions = {},
): Promise<WriteDiagnosticSupportExportResult> {
  const env = options.env ?? process.env;
  const stateDir = options.stateDir ?? resolveStateDir(env);
  const now = options.now ?? new Date();
  const outputPath = resolveOutputPath({
    outputPath: options.outputPath,
    cwd: options.cwd ?? process.cwd(),
    env,
    stateDir,
    now,
  });
  const artifact = await buildDiagnosticSupportExport({ ...options, env, stateDir, now });
  const bytes = await writeSupportBundleZip({
    outputPath,
    files: artifact.files,
    compressionLevel: 6,
  });
  return {
    path: outputPath,
    bytes,
    manifest: artifact.manifest,
  };
}

Messung V0.5 in Prozent
C=96 H=99 G=97

¤ 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.0.7Bemerkung:  ¤

*Bot Zugriff






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.