feat: add channels support

This commit is contained in:
Jack Wotherspoon
2026-03-20 15:52:29 -04:00
parent 52250c162d
commit 0b94546ee4
14 changed files with 290 additions and 0 deletions
+12
View File
@@ -13,6 +13,7 @@ import type {
TokenStorageInitializationEvent,
KeychainAvailabilityEvent,
} from '../telemetry/types.js';
import type { ChannelMessagePayload } from '../channels/types.js';
import { debugLogger } from './debugLogger.js';
/**
@@ -192,6 +193,7 @@ export enum CoreEvent {
QuotaChanged = 'quota-changed',
TelemetryKeychainAvailability = 'telemetry-keychain-availability',
TelemetryTokenStorageType = 'telemetry-token-storage-type',
ChannelMessage = 'channel-message',
}
/**
@@ -225,6 +227,7 @@ export interface CoreEvents extends ExtensionEvents {
[CoreEvent.SlashCommandConflicts]: [SlashCommandConflictsPayload];
[CoreEvent.TelemetryKeychainAvailability]: [KeychainAvailabilityEvent];
[CoreEvent.TelemetryTokenStorageType]: [TokenStorageInitializationEvent];
[CoreEvent.ChannelMessage]: [ChannelMessagePayload];
}
type EventBacklogItem = {
@@ -400,6 +403,15 @@ export class CoreEventEmitter extends EventEmitter<CoreEvents> {
this.emit(CoreEvent.QuotaChanged, payload);
}
/**
* Forwards a channel message from an MCP server that declared the
* `gemini/channel` experimental capability.
* Buffers automatically if the UI hasn't subscribed yet.
*/
emitChannelMessage(payload: ChannelMessagePayload): void {
this._emitOrQueue(CoreEvent.ChannelMessage, payload);
}
/**
* Flushes buffered messages. Call this immediately after primary UI listener
* subscribes.