Add observability for LLM topic context inclusion (#1038)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: thomasnordquist <7721625+thomasnordquist@users.noreply.github.com> Co-authored-by: Thomas Nordquist <thomasnordquist@users.noreply.github.com>
This commit is contained in:
@@ -7,6 +7,7 @@ interface CallbackStore {
|
||||
|
||||
export class EventDispatcher<Message> {
|
||||
private emitter = new EventEmitter()
|
||||
|
||||
private callbacks: Array<CallbackStore> = []
|
||||
|
||||
public dispatch(msg: Message) {
|
||||
|
||||
@@ -4,8 +4,11 @@ import { EventBusInterface } from './EventBusInterface'
|
||||
|
||||
export class IpcMainEventBus implements EventBusInterface {
|
||||
private ipc: IpcMain
|
||||
|
||||
private clients: Map<number, WebContents> = new Map() // webContentsId -> WebContents
|
||||
|
||||
private connectionOwners: Map<string, number> = new Map() // connectionId -> webContentsId
|
||||
|
||||
private currentClient: WebContents | undefined
|
||||
|
||||
constructor(ipc: IpcMain) {
|
||||
@@ -57,7 +60,7 @@ export class IpcMainEventBus implements EventBusInterface {
|
||||
}
|
||||
|
||||
public emit<MessageType>(event: Event<MessageType>, msg: MessageType) {
|
||||
const topic = event.topic
|
||||
const { topic } = event
|
||||
|
||||
// RPC responses go only to the requesting client
|
||||
if (topic.includes('/response/')) {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { IpcRenderer } from 'electron'
|
||||
import { CallbackStore } from './CallbackStore'
|
||||
import { EventBusInterface } from './EventBusInterface'
|
||||
import { Event } from '../Events'
|
||||
import { IpcRenderer } from 'electron'
|
||||
|
||||
export class IpcRendererEventBus implements EventBusInterface {
|
||||
private ipc: IpcRenderer
|
||||
|
||||
private callbacks: Array<CallbackStore> = []
|
||||
|
||||
constructor(ipc: IpcRenderer) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { v4 } from 'uuid'
|
||||
import { Event } from '../Events'
|
||||
import { EventBusInterface } from './EventBusInterface'
|
||||
import { v4 } from 'uuid'
|
||||
|
||||
export type RpcEvent<RequestType, ResponseType> = {
|
||||
topic: string
|
||||
@@ -54,7 +54,7 @@ export class Rpc {
|
||||
} catch (e) {
|
||||
error = e
|
||||
}
|
||||
const id = (request as any).id
|
||||
const { id } = request as any
|
||||
console.log(`${event.topic}/response/${id}`, payload, error)
|
||||
this.participant.emit({ topic: `${event.topic}/response/${id}` }, { id, payload, error })
|
||||
})
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Server as SocketIOServer, Socket } from 'socket.io'
|
||||
import Debug from 'debug'
|
||||
import { Event } from '../Events'
|
||||
import { EventBusInterface } from './EventBusInterface'
|
||||
import Debug from 'debug'
|
||||
|
||||
const debug = Debug('mqtt-explorer:socketio')
|
||||
const debugConnect = Debug('mqtt-explorer:socketio:connect')
|
||||
@@ -17,6 +17,7 @@ interface SocketSubscription {
|
||||
|
||||
export class SocketIOServerEventBus implements EventBusInterface {
|
||||
private io: SocketIOServer
|
||||
|
||||
private clients: Map<string, Socket> = new Map() // socketId -> Socket
|
||||
|
||||
// Global handlers that apply to ALL sockets (like RPC endpoints)
|
||||
@@ -232,7 +233,7 @@ export class SocketIOServerEventBus implements EventBusInterface {
|
||||
}
|
||||
|
||||
public emit<MessageType>(event: Event<MessageType>, msg: MessageType) {
|
||||
const topic = event.topic
|
||||
const { topic } = event
|
||||
|
||||
// Check if this is an RPC response (contains /response/ in topic)
|
||||
if (topic.includes('/response/')) {
|
||||
|
||||
Reference in New Issue
Block a user