mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-01 12:21:25 +00:00
Migrates the Teams extension from @microsoft/agents-hosting to the official Teams SDK (@microsoft/teams.apps + @microsoft/teams.api) and implements Microsoft's AI UX best practices for Teams agents. - AI-generated label on all bot messages (Teams native badge + thumbs up/down) - Streaming responses in 1:1 chats via Teams streaminfo protocol - Welcome card with configurable prompt starters on bot install - Feedback with reflective learning (negative feedback triggers background reflection) - Typing indicators for personal + group chats (disabled for channels) - Informative status updates (progress bar while LLM processes) - JWT validation via Teams SDK createServiceTokenValidator - User-Agent: teams.ts[apps]/<sdk-version> OpenClaw/<version> on outbound requests - Fix copy-pasted image downloads (smba.trafficmanager.net auth allowlist) - Pre-parse auth gate (reject unauthenticated requests before body parsing) - Reflection dispatcher lifecycle fix (prevent leaked dispatchers) - Colon-safe session filenames (Windows compatibility) - Cooldown cache eviction (prevent unbounded memory growth) Closes #51806
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import { createRequire } from "node:module";
|
|
import { getMSTeamsRuntime } from "./runtime.js";
|
|
|
|
let cachedUserAgent: string | undefined;
|
|
|
|
function resolveTeamsSdkVersion(): string {
|
|
try {
|
|
const require = createRequire(import.meta.url);
|
|
const pkg = require("@microsoft/teams.apps/package.json") as { version?: string };
|
|
return pkg.version ?? "unknown";
|
|
} catch {
|
|
return "unknown";
|
|
}
|
|
}
|
|
|
|
function resolveOpenClawVersion(): string {
|
|
try {
|
|
return getMSTeamsRuntime().version;
|
|
} catch {
|
|
return "unknown";
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Build a combined User-Agent string that preserves the Teams SDK identity
|
|
* and appends the OpenClaw version.
|
|
*
|
|
* Format: "teams.ts[apps]/<sdk-version> OpenClaw/<openclaw-version>"
|
|
* Example: "teams.ts[apps]/2.0.5 OpenClaw/2026.3.22"
|
|
*
|
|
* This lets the Teams backend track SDK usage while also identifying the
|
|
* host application.
|
|
*/
|
|
/** Reset the cached User-Agent (for testing). */
|
|
export function resetUserAgentCache(): void {
|
|
cachedUserAgent = undefined;
|
|
}
|
|
|
|
export function buildUserAgent(): string {
|
|
if (cachedUserAgent) {
|
|
return cachedUserAgent;
|
|
}
|
|
cachedUserAgent = `teams.ts[apps]/${resolveTeamsSdkVersion()} OpenClaw/${resolveOpenClawVersion()}`;
|
|
return cachedUserAgent;
|
|
}
|