feat(companion): add platform known-event-name passthrough

This commit is contained in:
William Valentin
2026-02-16 19:31:33 -08:00
parent 4f25994876
commit 9e7d3b0e13
4 changed files with 41 additions and 1 deletions
+1 -1
View File
@@ -1200,7 +1200,7 @@ Companion runtime helper:
- `createHeartbeatLoop()` convenience helper that returns a bound `CompanionHeartbeatLoop`
- optional `defaultSessionId` for canvas helper calls so `sessionId` can be omitted per call
- `dispose()` lifecycle helper for unified runtime teardown
- stream passthrough helpers (`subscribeEvents`, `clearEventSubscriptions`, `subscribeAgentStream/Typing/ContextWarning`, `waitForAnyEvent`, `waitForAgentStream/Typing/ContextWarning`)
- stream passthrough helpers (`subscribeEvents`, `clearEventSubscriptions`, `listKnownEventNames`, `subscribeAgentStream/Typing/ContextWarning`, `waitForAnyEvent`, `waitForAgentStream/Typing/ContextWarning`)
- `src/companion/heartbeatLoop.ts` provides `CompanionHeartbeatLoop` for periodic heartbeat scheduling (`publishHeartbeat`) with start/stop safety, optional interval jitter (`jitterRatio`) to spread load, `tickNow()` for manual sends, success/error hooks, failure observability (`failureCount`, `lastFailure`, `getState()`), and optional auto-stop after repeated failures.
## Canvas / A2UI Foundation
+13
View File
@@ -647,6 +647,19 @@
],
"test_status": "pnpm test:run src/companion/runtimeClient.test.ts src/companion/platformClients.test.ts src/companion/heartbeatLoop.test.ts src/companion/platformClients.integration.test.ts + pnpm typecheck passing"
},
"companion-platform-known-event-names-passthrough": {
"status": "completed",
"date": "2026-02-17",
"updated": "2026-02-17",
"summary": "Added `listKnownEventNames()` passthrough on platform clients so wrappers can expose the runtime event contract directly.",
"files_modified": [
"src/companion/platformClients.ts",
"src/companion/platformClients.test.ts",
"README.md",
"docs/plans/state.json"
],
"test_status": "pnpm test:run src/companion/platformClients.test.ts src/companion/runtimeClient.test.ts src/companion/heartbeatLoop.test.ts src/companion/platformClients.integration.test.ts + pnpm typecheck passing"
},
"browser-tools-activation-clarity": {
"status": "completed",
"date": "2026-02-17",
+14
View File
@@ -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' });
+13
View File
@@ -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?: {