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

Quelle  abort-cutoff.ts

  Sprache: JAVA
 

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

import type { SessionEntry } from "../../config/sessions/types.js";
import { normalizeOptionalString } from "../../shared/string-coerce.js";
import type { MsgContext } from "../templating.js";

export type AbortCutoff = {
  messageSid?: string;
  timestamp?: number;
};

type SessionAbortCutoffEntry = Pick<SessionEntry, "abortCutoffMessageSid" | "abortCutoffTimestamp">;

export function resolveAbortCutoffFromContext(ctx: MsgContext): AbortCutoff | undefined {
  const messageSid =
    normalizeOptionalString(ctx.MessageSidFull) ?? normalizeOptionalString(ctx.MessageSid);
  const timestamp =
    typeof ctx.Timestamp === "number" && Number.isFinite(ctx.Timestamp) ? ctx.Timestamp : undefined;
  if (!messageSid && timestamp === undefined) {
    return undefined;
  }
  return { messageSid, timestamp };
}

export function readAbortCutoffFromSessionEntry(
  entry: SessionAbortCutoffEntry | undefined,
): AbortCutoff | undefined {
  if (!entry) {
    return undefined;
  }
  const messageSid = normalizeOptionalString(entry.abortCutoffMessageSid);
  const timestamp =
    typeof entry.abortCutoffTimestamp === "number" && Number.isFinite(entry.abortCutoffTimestamp)
      ? entry.abortCutoffTimestamp
      : undefined;
  if (!messageSid && timestamp === undefined) {
    return undefined;
  }
  return { messageSid, timestamp };
}

export function hasAbortCutoff(entry: SessionAbortCutoffEntry | undefined): boolean {
  return readAbortCutoffFromSessionEntry(entry) !== undefined;
}

export function applyAbortCutoffToSessionEntry(
  entry: SessionAbortCutoffEntry,
  cutoff: AbortCutoff | undefined,
): void {
  entry.abortCutoffMessageSid = cutoff?.messageSid;
  entry.abortCutoffTimestamp = cutoff?.timestamp;
}

function toNumericMessageSid(value: string | undefined): bigint | undefined {
  const trimmed = normalizeOptionalString(value);
  if (!trimmed || !/^\d+$/.test(trimmed)) {
    return undefined;
  }
  try {
    return BigInt(trimmed);
  } catch {
    return undefined;
  }
}

export function shouldSkipMessageByAbortCutoff(params: {
  cutoffMessageSid?: string;
  cutoffTimestamp?: number;
  messageSid?: string;
  timestamp?: number;
}): boolean {
  const cutoffSid = normalizeOptionalString(params.cutoffMessageSid);
  const currentSid = normalizeOptionalString(params.messageSid);
  if (cutoffSid && currentSid) {
    const cutoffNumeric = toNumericMessageSid(cutoffSid);
    const currentNumeric = toNumericMessageSid(currentSid);
    if (cutoffNumeric !== undefined && currentNumeric !== undefined) {
      return currentNumeric <= cutoffNumeric;
    }
    if (currentSid === cutoffSid) {
      return true;
    }
  }
  if (
    typeof params.cutoffTimestamp === "number" &&
    Number.isFinite(params.cutoffTimestamp) &&
    typeof params.timestamp === "number" &&
    Number.isFinite(params.timestamp)
  ) {
    return params.timestamp <= params.cutoffTimestamp;
  }
  return false;
}

export function shouldPersistAbortCutoff(params: {
  commandSessionKey?: string;
  targetSessionKey?: string;
}): boolean {
  const commandSessionKey = normalizeOptionalString(params.commandSessionKey);
  const targetSessionKey = normalizeOptionalString(params.targetSessionKey);
  if (!commandSessionKey || !targetSessionKey) {
    return true;
  }
  // Native targeted /stop can run from a slash/session-control key while the
  // actual target session uses different message id/timestamp spaces.
  // Persist cutoff only when command source and target are the same session.
  return commandSessionKey === targetSessionKey;
}

¤ 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.