Class AgentTimelinePdfService
java.lang.Object
com.flowable.platform.service.agent.AgentTimelinePdfService
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordHeader details for a single-agent-invocation PDF.static final recordOptional details about the work instance (case/process) the timeline belongs to. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AgentModelPricingServiceprotected final tools.jackson.databind.ObjectMapperprotected final AgentTimelinePdfRendererprotected final PlatformAgentService -
Constructor Summary
ConstructorsConstructorDescriptionAgentTimelinePdfService(PlatformAgentService platformAgentService, AgentModelPricingService agentModelPricingService, AgentTimelinePdfRenderer pdfRenderer, tools.jackson.databind.ObjectMapper objectMapper) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddGuardrail(AgentInvocationReport invocationReport, AgentExchangeTimelineResponse exchange) Records one guardrail evaluation on the invocation: updates the evaluated/fired/passed counts and appends a parsedAgentGuardrailReport.protected AgentExchangeReportbuildExchange(AgentExchangeTimelineResponse exchange, List<AgentModelPrice> prices) protected AgentInvocationReportbuildInvocation(AgentInvocationTimelineResponse invocation, List<AgentModelPrice> prices, AgentTimelineReport report) protected AgentTimelineReportbuildInvocationReport(String agentInstanceId, String invocationId, AgentTimelinePdfService.AgentInstanceInfo header, AgentInstanceTimelineResponse instance, List<AgentModelPrice> prices) protected AgentTimelineReportbuildReport(String scopeId, String scopeType, AgentTimelinePdfService.ScopeInfo scopeInfo, List<AgentInstanceTimelineResponse> timeline, List<AgentModelPrice> prices) protected doublecomputeCost(long inputTokens, long outputTokens, long cachedTokens, AgentModelPrice price) Cost for the given (disjoint) token buckets against the given price.protected LongdurationMillis(Instant start, Instant end) protected StringvoidgenerateInvocationPdf(String agentInstanceId, String invocationId, AgentTimelinePdfService.AgentInstanceInfo header, OutputStream outputStream) Generates a PDF for a single agent invocation: fetches the agent instance timeline, keeps only the target invocation and renders it in single-agent-instance mode (agent-instance header, no multi-agent overview).voidgenerateTimelinePdf(String scopeId, String scopeType, AgentTimelinePdfService.ScopeInfo scopeInfo, OutputStream outputStream) protected StringReturns the content of the exchange's output/result part, which carries the guardrail evaluation JSON.protected booleanisGuardrailFired(String subType) protected AgentModelPricematchPrice(String model, List<AgentModelPrice> prices) Returns the price whose model prefix is the longest prefix ofmodel, ornullif none matches.protected longprotected voidparseGuardrailContent(AgentExchangeTimelineResponse exchange, AgentGuardrailReport guardrail) Parses the guardrail's output part content (a JSON object) into the report, tolerating any missing field.protected StringResolves the Flowable product/build version to display in the report.protected StringtextOrNull(tools.jackson.databind.JsonNode node, String field)
-
Field Details
-
platformAgentService
-
agentModelPricingService
-
pdfRenderer
-
objectMapper
protected final tools.jackson.databind.ObjectMapper objectMapper
-
-
Constructor Details
-
AgentTimelinePdfService
public AgentTimelinePdfService(PlatformAgentService platformAgentService, AgentModelPricingService agentModelPricingService, AgentTimelinePdfRenderer pdfRenderer, tools.jackson.databind.ObjectMapper objectMapper)
-
-
Method Details
-
generateTimelinePdf
public void generateTimelinePdf(String scopeId, String scopeType, AgentTimelinePdfService.ScopeInfo scopeInfo, OutputStream outputStream) -
generateInvocationPdf
public void generateInvocationPdf(String agentInstanceId, String invocationId, AgentTimelinePdfService.AgentInstanceInfo header, OutputStream outputStream) Generates a PDF for a single agent invocation: fetches the agent instance timeline, keeps only the target invocation and renders it in single-agent-instance mode (agent-instance header, no multi-agent overview). -
buildInvocationReport
protected AgentTimelineReport buildInvocationReport(String agentInstanceId, String invocationId, AgentTimelinePdfService.AgentInstanceInfo header, AgentInstanceTimelineResponse instance, List<AgentModelPrice> prices) -
buildReport
protected AgentTimelineReport buildReport(String scopeId, String scopeType, AgentTimelinePdfService.ScopeInfo scopeInfo, List<AgentInstanceTimelineResponse> timeline, List<AgentModelPrice> prices) -
buildInvocation
protected AgentInvocationReport buildInvocation(AgentInvocationTimelineResponse invocation, List<AgentModelPrice> prices, AgentTimelineReport report) -
buildExchange
protected AgentExchangeReport buildExchange(AgentExchangeTimelineResponse exchange, List<AgentModelPrice> prices) -
addGuardrail
protected void addGuardrail(AgentInvocationReport invocationReport, AgentExchangeTimelineResponse exchange) Records one guardrail evaluation on the invocation: updates the evaluated/fired/passed counts and appends a parsedAgentGuardrailReport. A guardrail is considered "fired" when its exchange subType is one of theguardrail*subtypes; the detail is parsed best-effort from the exchange's output part JSON content. -
isGuardrailFired
-
parseGuardrailContent
protected void parseGuardrailContent(AgentExchangeTimelineResponse exchange, AgentGuardrailReport guardrail) Parses the guardrail's output part content (a JSON object) into the report, tolerating any missing field. -
guardrailOutputContent
Returns the content of the exchange's output/result part, which carries the guardrail evaluation JSON. -
textOrNull
-
firstText
-
resolveFlowableVersion
Resolves the Flowable product/build version to display in the report. Prefers the platform build version from this service's own JAR manifest (Implementation-Version); when that is absent (e.g. running from source in development) it falls back to the bundled Flowable engine version constant. May returnnull. -
durationMillis
-
nz
-
matchPrice
Returns the price whose model prefix is the longest prefix ofmodel, ornullif none matches. -
computeCost
protected double computeCost(long inputTokens, long outputTokens, long cachedTokens, AgentModelPrice price) Cost for the given (disjoint) token buckets against the given price. Returns 0 when the price isnull.
-