feat(companion): add platform known-event-name passthrough
This commit is contained in:
@@ -30,6 +30,7 @@ function createRuntimeMock(): {
|
||||
subscribeContextWarning: ReturnType<typeof vi.fn>;
|
||||
subscribeEvents: ReturnType<typeof vi.fn>;
|
||||
clearEventSubscriptions: ReturnType<typeof vi.fn>;
|
||||
listKnownEventNames: ReturnType<typeof vi.fn>;
|
||||
waitForAgentStream: ReturnType<typeof vi.fn>;
|
||||
waitForAgentTyping: ReturnType<typeof vi.fn>;
|
||||
waitForContextWarning: ReturnType<typeof vi.fn>;
|
||||
@@ -64,6 +65,7 @@ function createRuntimeMock(): {
|
||||
const subscribeContextWarning = vi.fn(() => () => undefined);
|
||||
const subscribeEvents = vi.fn(() => () => undefined);
|
||||
const clearEventSubscriptions = vi.fn(() => undefined);
|
||||
const listKnownEventNames = vi.fn(() => ['agent.stream', 'agent.typing', 'context_warning']);
|
||||
const waitForAgentStream = vi.fn(async () => ({ token: 'streamed' }));
|
||||
const waitForAgentTyping = vi.fn(async () => ({ active: true }));
|
||||
const waitForContextWarning = vi.fn(async () => ({ thresholdPct: 75, estimatedPct: 90 }));
|
||||
@@ -92,6 +94,7 @@ function createRuntimeMock(): {
|
||||
subscribeContextWarning,
|
||||
subscribeEvents,
|
||||
clearEventSubscriptions,
|
||||
listKnownEventNames,
|
||||
waitForAgentStream,
|
||||
waitForAgentTyping,
|
||||
waitForContextWarning,
|
||||
@@ -122,6 +125,7 @@ function createRuntimeMock(): {
|
||||
subscribeContextWarning,
|
||||
subscribeEvents,
|
||||
clearEventSubscriptions,
|
||||
listKnownEventNames,
|
||||
waitForAgentStream,
|
||||
waitForAgentTyping,
|
||||
waitForContextWarning,
|
||||
@@ -230,6 +234,16 @@ describe('platform companion clients', () => {
|
||||
expect(mock.clearEventSubscriptions).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it('platform listKnownEventNames forwards to runtime client', async () => {
|
||||
const mock = createRuntimeMock();
|
||||
const client = new IOSCompanionClient({ runtime: mock.runtime, nodeId: 'ios-node' });
|
||||
|
||||
const events = client.listKnownEventNames();
|
||||
|
||||
expect(mock.listKnownEventNames).toHaveBeenCalledOnce();
|
||||
expect(events).toEqual(['agent.stream', 'agent.typing', 'context_warning']);
|
||||
});
|
||||
|
||||
it('macOS client forwards canvas methods to runtime client', async () => {
|
||||
const mock = createRuntimeMock();
|
||||
const client = new MacOSCompanionClient({ runtime: mock.runtime, nodeId: 'mac-node' });
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type {
|
||||
CompanionEventName,
|
||||
CompanionEventEnvelope,
|
||||
CompanionEventHandler,
|
||||
CanvasClearResult,
|
||||
@@ -255,6 +256,10 @@ export class MacOSCompanionClient {
|
||||
this.runtime.clearEventSubscriptions();
|
||||
}
|
||||
|
||||
listKnownEventNames(): CompanionEventName[] {
|
||||
return this.runtime.listKnownEventNames();
|
||||
}
|
||||
|
||||
waitForAnyEvent<TData = unknown>(
|
||||
eventNames: readonly string[],
|
||||
options?: {
|
||||
@@ -467,6 +472,10 @@ export class IOSCompanionClient {
|
||||
this.runtime.clearEventSubscriptions();
|
||||
}
|
||||
|
||||
listKnownEventNames(): CompanionEventName[] {
|
||||
return this.runtime.listKnownEventNames();
|
||||
}
|
||||
|
||||
waitForAnyEvent<TData = unknown>(
|
||||
eventNames: readonly string[],
|
||||
options?: {
|
||||
@@ -677,6 +686,10 @@ export class AndroidCompanionClient {
|
||||
this.runtime.clearEventSubscriptions();
|
||||
}
|
||||
|
||||
listKnownEventNames(): CompanionEventName[] {
|
||||
return this.runtime.listKnownEventNames();
|
||||
}
|
||||
|
||||
waitForAnyEvent<TData = unknown>(
|
||||
eventNames: readonly string[],
|
||||
options?: {
|
||||
|
||||
Reference in New Issue
Block a user