refactor(plugins): move extension seams into extensions

This commit is contained in:
Peter Steinberger
2026-04-04 00:08:13 +01:00
parent c19321ed9e
commit e4b5027c5e
234 changed files with 7726 additions and 5493 deletions

View File

@@ -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";
}