feat(harness): add chat application use case

This commit is contained in:
zhuyongxin
2026-07-22 00:57:39 +08:00
parent ee0949d464
commit f8809cb7dd
56 changed files with 2815 additions and 6 deletions
@@ -0,0 +1,39 @@
package com.superbiz.agent.harness.application;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.superbiz.agent.harness.contract.IntentType;
import com.superbiz.agent.harness.contract.ReleaseOutcome;
import java.util.Objects;
public record ChatApplicationResult(
@JsonProperty("session_id") String sessionId,
@JsonProperty("run_id") String runId,
@JsonProperty("intent") IntentType intent,
@JsonProperty("outcome") ReleaseOutcome outcome,
@JsonProperty("content_type") ChatContentType contentType,
@JsonProperty("content") ChatApplicationContent content) {
public ChatApplicationResult {
requireText(sessionId, "sessionId");
requireText(runId, "runId");
Objects.requireNonNull(intent, "intent must not be null");
Objects.requireNonNull(outcome, "outcome must not be null");
Objects.requireNonNull(content, "content must not be null");
if (outcome != ReleaseOutcome.SUCCESS && outcome != ReleaseOutcome.FALLBACK) {
throw new IllegalArgumentException("application result must be SUCCESS or FALLBACK");
}
if (contentType != content.contentType()) {
throw new IllegalArgumentException("contentType does not match content");
}
if (outcome == ReleaseOutcome.FALLBACK && contentType != ChatContentType.SAFE_FALLBACK) {
throw new IllegalArgumentException("fallback outcome requires safe fallback content");
}
}
private static void requireText(String value, String name) {
if (value == null || value.isBlank()) {
throw new IllegalArgumentException(name + " must not be blank");
}
}
}