MCPcopy Create free account
hub / github.com/electric-sql/electric / resolveCurrentQuestion

Function resolveCurrentQuestion

packages/agents/src/docs/knowledge-base.ts:882–904  ·  view source on GitHub ↗
(
    wake: WakeEvent,
    events: Array<Pick<ChangeEvent, `type` | `value`>>,
    inbox: Array<{ payload?: unknown }>
  )

Source from the content-addressed store, hash-verified

880 })
881
882 function resolveCurrentQuestion(
883 wake: WakeEvent,
884 events: Array<Pick<ChangeEvent, `type` | `value`>>,
885 inbox: Array<{ payload?: unknown }>
886 ): string {
887 if (wake.type === `inbox`) {
888 const eventQuestion = findLatestQuestion(
889 events
890 .filter((event) => event.type === `inbox`)
891 .map((event) => event.value as { payload?: unknown } | undefined)
892 )
893 if (eventQuestion) {
894 return eventQuestion
895 }
896 }
897
898 const wakeQuestion = payloadToText(wake.payload).trim()
899 if (wakeQuestion.length > 0) {
900 return wakeQuestion
901 }
902
903 return findLatestQuestion(inbox) ?? ``
904 }
905
906 return {
907 async ensureReady(): Promise<void> {

Callers 1

Calls 4

findLatestQuestionFunction · 0.85
filterMethod · 0.80
payloadToTextFunction · 0.70
mapMethod · 0.45

Tested by

no test coverage detected