/** * Shared helpers for FileConsentCard flow in MSTeams. * * FileConsentCard is required for: * - Personal (1:1) chats with large files (>=4MB) * - Personal chats with non-image files (PDFs, documents, etc.) * * This module consolidates the logic used by both send.ts (proactive sends) * and messenger.ts (reply path) to avoid duplication.
*/
import { normalizeOptionalLowercaseString } from "openclaw/plugin-sdk/text-runtime"; import { buildFileConsentCard } from "./file-consent.js"; import { storePendingUploadFs } from "./pending-uploads-fs.js"; import { storePendingUpload } from "./pending-uploads.js";
/** * Prepare a FileConsentCard activity for large files or non-images in personal chats. * Returns the activity object and uploadId - caller is responsible for sending. * * This variant only writes to the in-memory store. Use it when the caller and * the `fileConsent/invoke` handler share the same process (for example the * messenger reply path). For proactive CLI sends where the invoke arrives in * a different process, use {@link prepareFileConsentActivityFs} instead.
*/
export function prepareFileConsentActivity(params: {
media: FileConsentMedia;
conversationId: string;
description?: string;
}): FileConsentActivityResult { const { media, conversationId, description } = params;
/** * Prepare a FileConsentCard activity and persist the pending upload to the * filesystem so a different process can read it when the user accepts. * * This is used by the proactive CLI `message send --media` path: the CLI * process sends the card and exits, but the `fileConsent/invoke` callback is * delivered to the long-lived gateway monitor process. The FS-backed store * bridges those two processes. The in-memory store is also populated so * same-process flows keep the fast path.
*/
export async function prepareFileConsentActivityFs(params: {
media: FileConsentMedia;
conversationId: string;
description?: string;
}): Promise<FileConsentActivityResult> { const { media, conversationId, description } = params;
// Populate the in-memory store first so the uploadId is consistent, then // mirror the same entry to the FS store under the same id so an invoke // handler in another process can find it. const uploadId = storePendingUpload({
buffer: media.buffer,
filename: media.filename,
contentType: media.contentType,
conversationId,
});
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.