Class EventStreamAiGrounding

java.lang.Object
com.inductiveautomation.eventstream.designer.ai.EventStreamAiGrounding

public final class EventStreamAiGrounding extends Object

Provides AI groundings for the Scripting surfaces for following stages:

  • Filter
  • Transform
  • Error Handler
  • Handler Editors

The Filter, Transform, and Error sections use callerContextFor(EventStreamSurface) with sampleToolFor(EventStreamSurface) to get their grounds.

Handlers own their overall framing, using EventStreamAiContext.handlerEventDataShape() and EventStreamAiContext.lateStageSampleTool()

The grounding comes is split into 2 main tasks:

  • The type-level description of the event a body receives, embedded straight into the caller context.

    • It is resolved from the current configuration shown in the editor: which source encoder, which transform encoder, whether the Transform is enabled. All read through liveConfig on every prompt, with the source's display name resolved through sourceRegistry. Whatever cannot be read is left null, and the framing degrades to generic prose for that part alone.
  • An on-demand tool the agent calls when it wants a real sample of the last captured event. That is a blocking Gateway round-trip, so it rides a tool rather than being embedded.

    • The whole of that half lives in the tools subpackage, behind SampleTools. This class supplies what only the Designer knows — the RPC, the resource's coordinates, and liveConfig — and hands out the resulting tool per EventStreamSurface; how a sample is decided, fetched, and worded is not its business.
    • The Filter matters because the Transform and the late stages only ever see events an enabled Filter forwarded, so a Filter that rejects everything means there is no sample — not a different one. An agent may pass applyFilter=false to bypass it for a single fetch, but only when the user asks.
  • Constructor Details

    • EventStreamAiGrounding

      public EventStreamAiGrounding(EventStreamRpc rpc, String projectName, String resourceFolderPath, @Nullable DesignerAiContext aiContext, Supplier<@Nullable EventStreamConfig> liveConfig, SourceRegistry sourceRegistry)
      Parameters:
      rpc - the gateway RPC used to encode the stream's last captured events.
      projectName - the project the stream belongs to.
      resourceFolderPath - the stream resource's folder path.
      aiContext - the Designer AI context, or null when the AI module is absent — in which case this grounding is inert and never builds a sample tool.
      liveConfig - the Event Stream configuration as currently edited, or null when it cannot be read.
      sourceRegistry - provide additional info on the Source from, such as name
  • Method Details

    • callerContextFor

      public Supplier<String> callerContextFor(EventStreamSurface surface)

      The finished framing string for surface, grounded in the event shape read from the live configuration. Sections take the assembled framing rather than a shape they would have to pair with EventStreamCallerContext.forSurface(EventStreamSurface, EventStreamCallerContext.EventShapeInfo) themselves, so a section and its framing cannot drift apart.

      One entry point keyed by EventStreamSurface rather than one method per surface, so a caller cannot pair a surface with another surface's framing. The returned supplier defers the read to prompt-submit time; invoke it on the EDT.

    • lateStageSampleTool

      public ToolBundle lateStageSampleTool()
      The sample tool for the handlers, which receive the same late-stage event the error handler does. Reached by handler editors (built-in or third-party) through EventStreamAiContext.
    • sampleToolFor

      public ToolBundle sampleToolFor(EventStreamSurface surface)
      The on-demand sample tool surface should contribute, deferred to prompt-submit time so it is only built once the AI assist is actually ready().
    • createAiContext

      public EventStreamAiContext createAiContext()