diff --git a/README.md b/README.md index 028bfbb..a32aca4 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/docs/plans/state.json b/docs/plans/state.json index 470440f..75ddeb4 100644 --- a/docs/plans/state.json +++ b/docs/plans/state.json @@ -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", diff --git a/src/companion/platformClients.test.ts b/src/companion/platformClients.test.ts index fd06718..5e67688 100644 --- a/src/companion/platformClients.test.ts +++ b/src/companion/platformClients.test.ts @@ -30,6 +30,7 @@ function createRuntimeMock(): { subscribeContextWarning: ReturnType; subscribeEvents: ReturnType; clearEventSubscriptions: ReturnType; + listKnownEventNames: ReturnType; waitForAgentStream: ReturnType; waitForAgentTyping: ReturnType; waitForContextWarning: ReturnType; @@ -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' }); diff --git a/src/companion/platformClients.ts b/src/companion/platformClients.ts index 1d83c22..7a23d84 100644 --- a/src/companion/platformClients.ts +++ b/src/companion/platformClients.ts @@ -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( eventNames: readonly string[], options?: { @@ -467,6 +472,10 @@ export class IOSCompanionClient { this.runtime.clearEventSubscriptions(); } + listKnownEventNames(): CompanionEventName[] { + return this.runtime.listKnownEventNames(); + } + waitForAnyEvent( eventNames: readonly string[], options?: { @@ -677,6 +686,10 @@ export class AndroidCompanionClient { this.runtime.clearEventSubscriptions(); } + listKnownEventNames(): CompanionEventName[] { + return this.runtime.listKnownEventNames(); + } + waitForAnyEvent( eventNames: readonly string[], options?: {