mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 11:00:21 +00:00
refactor(plugins): move extension seams into extensions
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { getBundledChannelContractSurfaces } from "../channels/plugins/contract-surfaces.js";
|
||||
|
||||
export type ParsedAgentSessionKey = {
|
||||
agentId: string;
|
||||
rest: string;
|
||||
@@ -16,6 +18,14 @@ export type RawSessionConversationRef = {
|
||||
prefix: string;
|
||||
};
|
||||
|
||||
type LegacySessionChatTypeSurface = {
|
||||
deriveLegacySessionChatType?: (sessionKey: string) => "direct" | "group" | "channel" | undefined;
|
||||
};
|
||||
|
||||
function listLegacySessionChatTypeSurfaces(): LegacySessionChatTypeSurface[] {
|
||||
return getBundledChannelContractSurfaces() as LegacySessionChatTypeSurface[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse agent-scoped session keys in a canonical, case-insensitive way.
|
||||
* Returned values are normalized to lowercase for stable comparisons/routing.
|
||||
@@ -61,10 +71,11 @@ export function deriveSessionChatType(sessionKey: string | undefined | null): Se
|
||||
if (tokens.has("direct") || tokens.has("dm")) {
|
||||
return "direct";
|
||||
}
|
||||
// Legacy Discord keys can be shaped like:
|
||||
// discord:<accountId>:guild-<guildId>:channel-<channelId>
|
||||
if (/^discord:(?:[^:]+:)?guild-[^:]+:channel-[^:]+$/.test(scoped)) {
|
||||
return "channel";
|
||||
for (const surface of listLegacySessionChatTypeSurfaces()) {
|
||||
const derived = surface.deriveLegacySessionChatType?.(scoped);
|
||||
if (derived) {
|
||||
return derived;
|
||||
}
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user