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

Quelle  message-action-spec.ts

  Sprache: JAVA
 

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

import { getBootstrapChannelPlugin } from "../../channels/plugins/bootstrap-registry.js";
import type { ChannelMessageActionName } from "../../channels/plugins/types.public.js";
import {
  normalizeOptionalLowercaseString,
  normalizeOptionalString,
} from "../../shared/string-coerce.js";
import { hasPotentialPluginActionParam } from "./message-action-param-keys.js";

export type MessageActionTargetMode = "to" | "channelId" | "none";

export const MESSAGE_ACTION_TARGET_MODE: Record<ChannelMessageActionName, MessageActionTargetMode> =
  {
    send: "to",
    broadcast: "none",
    poll: "to",
    "poll-vote": "to",
    react: "to",
    reactions: "to",
    read: "to",
    edit: "to",
    unsend: "to",
    reply: "to",
    sendWithEffect: "to",
    renameGroup: "to",
    setGroupIcon: "to",
    addParticipant: "to",
    removeParticipant: "to",
    leaveGroup: "to",
    sendAttachment: "to",
    delete: "to",
    pin: "to",
    unpin: "to",
    "list-pins": "to",
    permissions: "to",
    "thread-create": "to",
    "thread-list": "none",
    "thread-reply": "to",
    search: "none",
    sticker: "to",
    "sticker-search": "none",
    "member-info": "none",
    "role-info": "none",
    "emoji-list": "none",
    "emoji-upload": "none",
    "sticker-upload": "none",
    "role-add": "none",
    "role-remove": "none",
    "channel-info": "channelId",
    "channel-list": "none",
    "channel-create": "none",
    "channel-edit": "channelId",
    "channel-delete": "channelId",
    "channel-move": "channelId",
    "category-create": "none",
    "category-edit": "none",
    "category-delete": "none",
    "topic-create": "to",
    "topic-edit": "to",
    "voice-status": "none",
    "event-list": "none",
    "event-create": "none",
    timeout: "none",
    kick: "none",
    ban: "none",
    "set-profile": "none",
    "set-presence": "none",
    "download-file": "none",
    "upload-file": "to",
  };

type ActionTargetAliasSpec = {
  aliases: string[];
};

const ACTION_TARGET_ALIASES: Partial<Record<ChannelMessageActionName, ActionTargetAliasSpec>> = {
  unsend: { aliases: ["messageId"] },
  edit: { aliases: ["messageId"] },
  react: { aliases: ["chatGuid", "chatIdentifier", "chatId"] },
  renameGroup: { aliases: ["chatGuid", "chatIdentifier", "chatId"] },
  setGroupIcon: { aliases: ["chatGuid", "chatIdentifier", "chatId"] },
  addParticipant: { aliases: ["chatGuid", "chatIdentifier", "chatId"] },
  removeParticipant: { aliases: ["chatGuid", "chatIdentifier", "chatId"] },
  leaveGroup: { aliases: ["chatGuid", "chatIdentifier", "chatId"] },
};

function listActionTargetAliasSpecs(
  action: ChannelMessageActionName,
  params: Record<string, unknown>,
  channel?: string,
): ActionTargetAliasSpec[] {
  const specs: ActionTargetAliasSpec[] = [];
  const coreSpec = ACTION_TARGET_ALIASES[action];
  if (coreSpec) {
    specs.push(coreSpec);
  }
  const normalizedChannel = normalizeOptionalLowercaseString(channel);
  if (!normalizedChannel || !hasPotentialPluginActionParam(params)) {
    return specs;
  }
  const plugin = getBootstrapChannelPlugin(normalizedChannel);
  const channelSpec = plugin?.actions?.messageActionTargetAliases?.[action];
  if (channelSpec) {
    specs.push(channelSpec);
  }
  return specs;
}

export function actionRequiresTarget(action: ChannelMessageActionName): boolean {
  return MESSAGE_ACTION_TARGET_MODE[action] !== "none";
}

export function actionHasTarget(
  action: ChannelMessageActionName,
  params: Record<string, unknown>,
  options?: { channel?: string },
): boolean {
  const to = normalizeOptionalString(params.to) ?? "";
  if (to) {
    return true;
  }
  const channelId = normalizeOptionalString(params.channelId) ?? "";
  if (channelId) {
    return true;
  }
  const specs = listActionTargetAliasSpecs(action, params, options?.channel);
  if (specs.length === 0) {
    return false;
  }
  return specs.some((spec) =>
    spec.aliases.some((alias) => {
      const value = params[alias];
      if (typeof value === "string") {
        return Boolean(normalizeOptionalString(value));
      }
      if (typeof value === "number") {
        return Number.isFinite(value);
      }
      return false;
    }),
  );
}

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