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 2 kB image not shown  

Quelle  commands-context.test.ts

  Sprache: JAVA
 

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

import { describe, expect, it } from "vitest";
import type { OpenClawConfig } from "../../config/config.js";
import { buildCommandContext } from "./commands-context.js";
import { stripStructuralPrefixes } from "./mentions.js";
import { buildTestCtx } from "./test-ctx.js";

describe("buildCommandContext", () => {
  it("canonicalizes registered aliases like /id to their primary command", () => {
    const ctx = buildTestCtx({
      Provider: "webchat",
      Surface: "webchat",
      From: "user",
      To: "bot",
      Body: "/id",
      RawBody: "/id",
      CommandBody: "/id",
      BodyForCommands: "/id",
    });

    const result = buildCommandContext({
      ctx,
      cfg: {} as OpenClawConfig,
      isGroup: false,
      triggerBodyNormalized: "/id",
      commandAuthorized: true,
    });

    expect(result.commandBodyNormalized).toBe("/whoami");
  });

  it("preserves multiline soft reset tails after structural normalization", () => {
    const ctx = buildTestCtx({
      Provider: "whatsapp",
      Surface: "whatsapp",
      From: "user",
      To: "bot",
      Body: "/reset soft\nre-read persona files",
      RawBody: "/reset soft\nre-read persona files",
      CommandBody: "/reset soft\nre-read persona files",
      BodyForCommands: "/reset soft\nre-read persona files",
    });

    const result = buildCommandContext({
      ctx,
      cfg: {} as OpenClawConfig,
      isGroup: false,
      triggerBodyNormalized: stripStructuralPrefixes("/reset soft\nre-read persona files"),
      commandAuthorized: true,
    });

    expect(result.commandBodyNormalized).toBe("/reset soft re-read persona files");
  });

  it("maps explicit gateway origin into command context", () => {
    const ctx = buildTestCtx({
      Provider: "internal",
      Surface: "internal",
      OriginatingChannel: "slack",
      OriginatingTo: "user:U123",
      SenderId: "gateway-client",
      From: undefined,
      To: undefined,
      Body: "/codex bind",
      RawBody: "/codex bind",
      CommandBody: "/codex bind",
      BodyForCommands: "/codex bind",
    });

    const result = buildCommandContext({
      ctx,
      cfg: {} as OpenClawConfig,
      isGroup: false,
      triggerBodyNormalized: "/codex bind",
      commandAuthorized: true,
    });

    expect(result.channel).toBe("slack");
    expect(result.channelId).toBe("slack");
    expect(result.from).toBe("gateway-client");
    expect(result.to).toBe("user:U123");
  });
});

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