feat(companion): add platform event subscription count passthrough
This commit is contained in:
@@ -1200,7 +1200,7 @@ Companion runtime helper:
|
|||||||
- `createHeartbeatLoop()` convenience helper that returns a bound `CompanionHeartbeatLoop`
|
- `createHeartbeatLoop()` convenience helper that returns a bound `CompanionHeartbeatLoop`
|
||||||
- optional `defaultSessionId` for canvas helper calls so `sessionId` can be omitted per call
|
- optional `defaultSessionId` for canvas helper calls so `sessionId` can be omitted per call
|
||||||
- `dispose()` lifecycle helper for unified runtime teardown
|
- `dispose()` lifecycle helper for unified runtime teardown
|
||||||
- stream passthrough helpers (`subscribeEvents`, `clearEventSubscriptions`, `listKnownEventNames`, `subscribeAgentStream/Typing/ContextWarning`, `waitForAnyEvent`, `waitForAgentStream/Typing/ContextWarning`)
|
- stream passthrough helpers (`subscribeEvents`, `clearEventSubscriptions`, `listKnownEventNames`, `eventSubscriptionCount`, `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.
|
- `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
|
## Canvas / A2UI Foundation
|
||||||
|
|||||||
@@ -673,6 +673,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"
|
"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-event-subscription-count-passthrough": {
|
||||||
|
"status": "completed",
|
||||||
|
"date": "2026-02-17",
|
||||||
|
"updated": "2026-02-17",
|
||||||
|
"summary": "Added `eventSubscriptionCount` passthrough on platform companion clients so wrappers expose active runtime event-listener cardinality for observability and debugging.",
|
||||||
|
"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": {
|
"browser-tools-activation-clarity": {
|
||||||
"status": "completed",
|
"status": "completed",
|
||||||
"date": "2026-02-17",
|
"date": "2026-02-17",
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ function createRuntimeMock(): {
|
|||||||
waitForAgentTyping: ReturnType<typeof vi.fn>;
|
waitForAgentTyping: ReturnType<typeof vi.fn>;
|
||||||
waitForContextWarning: ReturnType<typeof vi.fn>;
|
waitForContextWarning: ReturnType<typeof vi.fn>;
|
||||||
waitForAnyEvent: ReturnType<typeof vi.fn>;
|
waitForAnyEvent: ReturnType<typeof vi.fn>;
|
||||||
|
eventSubscriptionCount: number;
|
||||||
} {
|
} {
|
||||||
const connect = vi.fn(async () => undefined);
|
const connect = vi.fn(async () => undefined);
|
||||||
const disconnect = vi.fn(() => undefined);
|
const disconnect = vi.fn(() => undefined);
|
||||||
@@ -70,6 +71,7 @@ function createRuntimeMock(): {
|
|||||||
const waitForAgentTyping = vi.fn(async () => ({ active: true }));
|
const waitForAgentTyping = vi.fn(async () => ({ active: true }));
|
||||||
const waitForContextWarning = vi.fn(async () => ({ thresholdPct: 75, estimatedPct: 90 }));
|
const waitForContextWarning = vi.fn(async () => ({ thresholdPct: 75, estimatedPct: 90 }));
|
||||||
const waitForAnyEvent = vi.fn(async () => ({ event: 'agent.stream', data: { token: 'any' } }));
|
const waitForAnyEvent = vi.fn(async () => ({ event: 'agent.stream', data: { token: 'any' } }));
|
||||||
|
const eventSubscriptionCount = 3;
|
||||||
|
|
||||||
const runtime = {
|
const runtime = {
|
||||||
connect,
|
connect,
|
||||||
@@ -99,6 +101,9 @@ function createRuntimeMock(): {
|
|||||||
waitForAgentTyping,
|
waitForAgentTyping,
|
||||||
waitForContextWarning,
|
waitForContextWarning,
|
||||||
waitForAnyEvent,
|
waitForAnyEvent,
|
||||||
|
get eventSubscriptionCount() {
|
||||||
|
return eventSubscriptionCount;
|
||||||
|
},
|
||||||
} as unknown as CompanionRuntimeClient;
|
} as unknown as CompanionRuntimeClient;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -130,6 +135,7 @@ function createRuntimeMock(): {
|
|||||||
waitForAgentTyping,
|
waitForAgentTyping,
|
||||||
waitForContextWarning,
|
waitForContextWarning,
|
||||||
waitForAnyEvent,
|
waitForAnyEvent,
|
||||||
|
eventSubscriptionCount,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,6 +250,13 @@ describe('platform companion clients', () => {
|
|||||||
expect(events).toEqual(['agent.stream', 'agent.typing', 'context_warning']);
|
expect(events).toEqual(['agent.stream', 'agent.typing', 'context_warning']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('platform eventSubscriptionCount forwards runtime getter value', async () => {
|
||||||
|
const mock = createRuntimeMock();
|
||||||
|
const client = new IOSCompanionClient({ runtime: mock.runtime, nodeId: 'ios-node' });
|
||||||
|
|
||||||
|
expect(client.eventSubscriptionCount).toBe(mock.eventSubscriptionCount);
|
||||||
|
});
|
||||||
|
|
||||||
it('macOS client forwards canvas methods to runtime client', async () => {
|
it('macOS client forwards canvas methods to runtime client', async () => {
|
||||||
const mock = createRuntimeMock();
|
const mock = createRuntimeMock();
|
||||||
const client = new MacOSCompanionClient({ runtime: mock.runtime, nodeId: 'mac-node' });
|
const client = new MacOSCompanionClient({ runtime: mock.runtime, nodeId: 'mac-node' });
|
||||||
|
|||||||
@@ -260,6 +260,10 @@ export class MacOSCompanionClient {
|
|||||||
return this.runtime.listKnownEventNames();
|
return this.runtime.listKnownEventNames();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get eventSubscriptionCount(): number {
|
||||||
|
return this.runtime.eventSubscriptionCount;
|
||||||
|
}
|
||||||
|
|
||||||
waitForAnyEvent<TData = unknown>(
|
waitForAnyEvent<TData = unknown>(
|
||||||
eventNames: readonly string[],
|
eventNames: readonly string[],
|
||||||
options?: {
|
options?: {
|
||||||
@@ -476,6 +480,10 @@ export class IOSCompanionClient {
|
|||||||
return this.runtime.listKnownEventNames();
|
return this.runtime.listKnownEventNames();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get eventSubscriptionCount(): number {
|
||||||
|
return this.runtime.eventSubscriptionCount;
|
||||||
|
}
|
||||||
|
|
||||||
waitForAnyEvent<TData = unknown>(
|
waitForAnyEvent<TData = unknown>(
|
||||||
eventNames: readonly string[],
|
eventNames: readonly string[],
|
||||||
options?: {
|
options?: {
|
||||||
@@ -690,6 +698,10 @@ export class AndroidCompanionClient {
|
|||||||
return this.runtime.listKnownEventNames();
|
return this.runtime.listKnownEventNames();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get eventSubscriptionCount(): number {
|
||||||
|
return this.runtime.eventSubscriptionCount;
|
||||||
|
}
|
||||||
|
|
||||||
waitForAnyEvent<TData = unknown>(
|
waitForAnyEvent<TData = unknown>(
|
||||||
eventNames: readonly string[],
|
eventNames: readonly string[],
|
||||||
options?: {
|
options?: {
|
||||||
|
|||||||
Reference in New Issue
Block a user