refactor: register channel bootstrap capabilities

This commit is contained in:
Peter Steinberger
2026-04-05 09:13:30 +01:00
parent a5b6b71468
commit 41e39eb46f
58 changed files with 444 additions and 949 deletions

View File

@@ -1,16 +1,8 @@
import { getBundledChannelContractSurfaces } from "../channels/plugins/contract-surfaces.js";
import { listBootstrapChannelPlugins } from "../channels/plugins/bootstrap-registry.js";
import { parseAgentSessionKey } from "./session-key-utils.js";
export type SessionKeyChatType = "direct" | "group" | "channel" | "unknown";
type LegacySessionChatTypeSurface = {
deriveLegacySessionChatType?: (sessionKey: string) => "direct" | "group" | "channel" | undefined;
};
function listLegacySessionChatTypeSurfaces(): LegacySessionChatTypeSurface[] {
return getBundledChannelContractSurfaces() as LegacySessionChatTypeSurface[];
}
function deriveBuiltInLegacySessionChatType(
scopedSessionKey: string,
): SessionKeyChatType | undefined {
@@ -52,8 +44,8 @@ export function deriveSessionChatType(sessionKey: string | undefined | null): Se
if (builtInLegacy) {
return builtInLegacy;
}
for (const surface of listLegacySessionChatTypeSurfaces()) {
const derived = surface.deriveLegacySessionChatType?.(scoped);
for (const plugin of listBootstrapChannelPlugins()) {
const derived = plugin.messaging?.deriveLegacySessionChatType?.(scoped);
if (derived) {
return derived;
}