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

Quelle  channel-inbound-roots.fast-path.test.ts

  Sprache: JAVA
 

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

import { beforeEach, describe, expect, it, vi } from "vitest";
import type { MsgContext } from "../auto-reply/templating.js";
import type { OpenClawConfig } from "../config/types.js";

const publicSurfaceLoaderMocks = vi.hoisted(() => ({
  loadBundledPluginPublicArtifactModuleSync: vi.fn(),
}));

vi.mock("../plugins/public-surface-loader.js", () => publicSurfaceLoaderMocks);

import {
  resolveChannelInboundAttachmentRoots,
  resolveChannelRemoteInboundAttachmentRoots,
} from "./channel-inbound-roots.js";

const cfg = {
  channels: {},
} as OpenClawConfig;

function unableToResolve(dirName: string, artifactBasename: string): Error {
  return new Error(
    `Unable to resolve bundled plugin public surface ${dirName}/${artifactBasename}`,
  );
}

function createContext(provider: string, accountId = "work"): MsgContext {
  return {
    Body: "hi",
    From: "localchat:work:demo",
    To: "+2000",
    ChatType: "direct",
    Provider: provider,
    AccountId: accountId,
  };
}

beforeEach(() => {
  publicSurfaceLoaderMocks.loadBundledPluginPublicArtifactModuleSync.mockReset();
});

describe("channel inbound roots fast path", () => {
  it("prefers media contract artifacts over full channel bootstrap", () => {
    publicSurfaceLoaderMocks.loadBundledPluginPublicArtifactModuleSync.mockImplementation(
      ({ artifactBasename, dirName }: { artifactBasename: string; dirName: string }) => {
        if (dirName === "localchat" && artifactBasename === "media-contract-api.js") {
          return {
            resolveInboundAttachmentRoots: ({ accountId }: { accountId?: string }) => [
              `/local/${accountId}`,
            ],
            resolveRemoteInboundAttachmentRoots: ({ accountId }: { accountId?: string }) => [
              `/remote/${accountId}`,
            ],
          };
        }
        throw unableToResolve(dirName, artifactBasename);
      },
    );

    expect(
      resolveChannelInboundAttachmentRoots({
        cfg,
        ctx: createContext("localchat"),
      }),
    ).toEqual(["/local/work"]);
    expect(
      resolveChannelRemoteInboundAttachmentRoots({
        cfg,
        ctx: createContext("localchat"),
      }),
    ).toEqual(["/remote/work"]);
    expect(publicSurfaceLoaderMocks.loadBundledPluginPublicArtifactModuleSync).toHaveBeenCalledWith(
      {
        dirName: "localchat",
        artifactBasename: "media-contract-api.js",
      },
    );
  });

  it("does not load broad generic contract artifacts on the media-root path", () => {
    publicSurfaceLoaderMocks.loadBundledPluginPublicArtifactModuleSync.mockImplementation(
      ({ artifactBasename, dirName }: { artifactBasename: string; dirName: string }) => {
        throw unableToResolve(dirName, artifactBasename);
      },
    );

    expect(
      resolveChannelRemoteInboundAttachmentRoots({
        cfg,
        ctx: createContext("mobilechat"),
      }),
    ).toBeUndefined();
    expect(publicSurfaceLoaderMocks.loadBundledPluginPublicArtifactModuleSync).toHaveBeenCalledWith(
      {
        dirName: "mobilechat",
        artifactBasename: "media-contract-api.js",
      },
    );
    expect(
      publicSurfaceLoaderMocks.loadBundledPluginPublicArtifactModuleSync,
    ).not.toHaveBeenCalledWith({
      dirName: "mobilechat",
      artifactBasename: "contract-api.js",
    });
    expect(
      publicSurfaceLoaderMocks.loadBundledPluginPublicArtifactModuleSync,
    ).not.toHaveBeenCalledWith({
      dirName: "mobilechat",
      artifactBasename: "index.js",
    });
  });
});

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