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

Quelle  conversation-binding-context.test.ts

  Sprache: JAVA
 

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

import { afterEach, describe, expect, it } from "vitest";
import type { OpenClawConfig } from "../config/config.js";
import { setActivePluginRegistry } from "../plugins/runtime.js";
import { createChannelTestPluginBase, createTestRegistry } from "../test-utils/channel-plugins.js";
import { resolveConversationBindingContext } from "./conversation-binding-context.js";

describe("resolveConversationBindingContext", () => {
  afterEach(() => {
    setActivePluginRegistry(createTestRegistry());
  });

  it("uses the plugin default account when accountId is omitted", () => {
    setActivePluginRegistry(
      createTestRegistry([
        {
          pluginId: "line",
          source: "test",
          plugin: {
            ...createChannelTestPluginBase({
              id: "line",
              label: "LINE",
              config: {
                listAccountIds: () => ["default", "work"],
                defaultAccountId: () => "work",
              },
            }),
            bindings: {
              resolveCommandConversation: ({
                originatingTo,
                commandTo,
                fallbackTo,
              }: {
                originatingTo?: string;
                commandTo?: string;
                fallbackTo?: string;
              }) => {
                const conversationId = [originatingTo, commandTo, fallbackTo]
                  .map((candidate) => candidate?.trim().replace(/^line:/i, ""))
                  .map((candidate) => candidate?.replace(/^user:/i, ""))
                  .find((candidate) => candidate && candidate.length > 0);
                return conversationId ? { conversationId } : null;
              },
            },
          },
        },
      ]),
    );

    expect(
      resolveConversationBindingContext({
        cfg: {} as OpenClawConfig,
        channel: "line",
        originatingTo: "line:user:U1234567890abcdef1234567890abcdef",
      }),
    ).toEqual({
      channel: "line",
      accountId: "work",
      conversationId: "U1234567890abcdef1234567890abcdef",
    });
  });

  it("normalizes provider-resolved conversation ids before returning binding context", () => {
    setActivePluginRegistry(
      createTestRegistry([
        {
          pluginId: "line",
          source: "test",
          plugin: {
            ...createChannelTestPluginBase({
              id: "line",
              label: "LINE",
            }),
            bindings: {
              resolveCommandConversation: () => ({
                conversationId: "  user:U1234567890abcdef1234567890abcdef  ",
                parentConversationId: "  room:R1234567890abcdef1234567890abcd  ",
              }),
            },
          },
        },
      ]),
    );

    expect(
      resolveConversationBindingContext({
        cfg: {} as OpenClawConfig,
        channel: "line",
        accountId: " default ",
        originatingTo: "ignored",
      }),
    ).toEqual({
      channel: "line",
      accountId: "default",
      conversationId: "user:U1234567890abcdef1234567890abcdef",
      parentConversationId: "room:R1234567890abcdef1234567890abcd",
    });
  });

  it("normalizes focused binding conversation ids before returning binding context", () => {
    setActivePluginRegistry(
      createTestRegistry([
        {
          pluginId: "line",
          source: "test",
          plugin: {
            ...createChannelTestPluginBase({
              id: "line",
              label: "LINE",
            }),
            threading: {
              resolveFocusedBinding: () => ({
                conversationId: "  user:U99999999999999999999999999999999  ",
                parentConversationId: "  room:R999999999999999999999999999999  ",
              }),
            },
          },
        },
      ]),
    );

    expect(
      resolveConversationBindingContext({
        cfg: {} as OpenClawConfig,
        channel: "line",
        accountId: " default ",
        originatingTo: "ignored",
      }),
    ).toEqual({
      channel: "line",
      accountId: "default",
      conversationId: "user:U99999999999999999999999999999999",
      parentConversationId: "room:R999999999999999999999999999999",
    });
  });
});

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