refactor: route channel runtime via plugin api

This commit is contained in:
Peter Steinberger
2026-01-18 11:00:19 +00:00
parent 676d41d415
commit ee6e534ccb
82 changed files with 1253 additions and 3167 deletions

View File

@@ -1,4 +1,4 @@
import { detectMime, saveMediaBuffer } from "clawdbot/plugin-sdk";
import { getMSTeamsRuntime } from "../runtime.js";
import {
extractInlineImageCandidates,
inferPlaceholder,
@@ -141,7 +141,7 @@ export async function downloadMSTeamsImageAttachments(params: {
if (inline.kind !== "data") continue;
if (inline.data.byteLength > params.maxBytes) continue;
try {
const saved = await saveMediaBuffer(
const saved = await getMSTeamsRuntime().channel.media.saveMediaBuffer(
inline.data,
inline.contentType,
"inbound",
@@ -167,12 +167,12 @@ export async function downloadMSTeamsImageAttachments(params: {
if (!res.ok) continue;
const buffer = Buffer.from(await res.arrayBuffer());
if (buffer.byteLength > params.maxBytes) continue;
const mime = await detectMime({
const mime = await getMSTeamsRuntime().media.detectMime({
buffer,
headerMime: res.headers.get("content-type"),
filePath: candidate.fileHint ?? candidate.url,
});
const saved = await saveMediaBuffer(
const saved = await getMSTeamsRuntime().channel.media.saveMediaBuffer(
buffer,
mime ?? candidate.contentTypeHint,
"inbound",

View File

@@ -1,4 +1,4 @@
import { detectMime, saveMediaBuffer } from "clawdbot/plugin-sdk";
import { getMSTeamsRuntime } from "../runtime.js";
import { downloadMSTeamsImageAttachments } from "./download.js";
import { GRAPH_ROOT, isRecord, normalizeContentType, resolveAllowedHosts } from "./shared.js";
import type {
@@ -154,13 +154,13 @@ async function downloadGraphHostedImages(params: {
continue;
}
if (buffer.byteLength > params.maxBytes) continue;
const mime = await detectMime({
const mime = await getMSTeamsRuntime().media.detectMime({
buffer,
headerMime: item.contentType ?? undefined,
});
if (mime && !mime.startsWith("image/")) continue;
try {
const saved = await saveMediaBuffer(
const saved = await getMSTeamsRuntime().channel.media.saveMediaBuffer(
buffer,
mime ?? item.contentType ?? undefined,
"inbound",