chore: remove legacy exception handler and adjust runtime class location

This commit is contained in:
2026-04-10 14:31:56 +08:00
parent d29dad4691
commit 663d66fdea
45 changed files with 27 additions and 525 deletions

View File

@@ -1,6 +0,0 @@
package work.slhaf.partner.framework.agent.common.entity;
import java.io.Serializable;
public abstract class PersistableObject implements Serializable {
}

View File

@@ -3,8 +3,8 @@ package work.slhaf.partner.framework.agent.config
import com.alibaba.fastjson2.JSON
import com.alibaba.fastjson2.JSONObject
import org.slf4j.LoggerFactory
import work.slhaf.partner.framework.agent.common.support.DirectoryWatchSupport
import work.slhaf.partner.framework.agent.exception.AgentLaunchFailedException
import work.slhaf.partner.framework.agent.support.DirectoryWatchSupport
import java.io.IOException
import java.lang.reflect.Field
import java.lang.reflect.Modifier

View File

@@ -1,7 +0,0 @@
package work.slhaf.partner.framework.agent.exception;
public interface AgentExceptionCallback {
void onRuntimeException(AgentRuntimeException e);
void onFailedException(AgentLaunchFailedException e);
}

View File

@@ -1,39 +0,0 @@
package work.slhaf.partner.framework.agent.exception;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class GlobalExceptionHandler {
public static GlobalExceptionHandler INSTANCE = new GlobalExceptionHandler();
private AgentExceptionCallback exceptionCallback = new LogAgentExceptionCallback();
public static void setExceptionCallback(AgentExceptionCallback callback) {
INSTANCE.exceptionCallback = callback;
}
public boolean handle(Throwable e) {
boolean exit;
Throwable cause = e.getCause();
switch (cause) {
case AgentRunningFailedException arfe -> {
exit = true;
exceptionCallback.onRuntimeException((AgentRuntimeException) cause);
}
case AgentRuntimeException are -> {
exit = false;
exceptionCallback.onRuntimeException((AgentRuntimeException) cause);
}
case AgentLaunchFailedException alfe -> {
exit = true;
exceptionCallback.onFailedException((AgentLaunchFailedException) cause);
}
default -> {
exit = true;
log.error("意外异常: ", cause);
}
}
return exit;
}
}

View File

@@ -1,17 +0,0 @@
package work.slhaf.partner.framework.agent.exception;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class LogAgentExceptionCallback implements AgentExceptionCallback {
@Override
public void onRuntimeException(AgentRuntimeException e) {
log.error("Agent 运行异常: ", e);
}
@Override
public void onFailedException(AgentLaunchFailedException e) {
throw e;
}
}

View File

@@ -1,11 +0,0 @@
package work.slhaf.partner.framework.agent.factory.exception;
public class ExternalModulePathNotExistException extends AgentRegisterFactoryFailedException {
public ExternalModulePathNotExistException(String message) {
super(message);
}
public ExternalModulePathNotExistException(String message, Throwable cause) {
super(message, cause);
}
}

View File

@@ -4,13 +4,11 @@ import com.alibaba.fastjson2.annotation.JSONCreator
import com.alibaba.fastjson2.annotation.JSONField
import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonValue
import work.slhaf.partner.framework.agent.common.entity.PersistableObject
import java.io.Serial
data class Message(
val role: Character,
val content: String
) : PersistableObject() {
) {
fun roleValue(): String = role.value
@@ -34,8 +32,4 @@ data class Message(
}
}
companion object {
@Serial
private const val serialVersionUID = 1L
}
}

View File

@@ -1,4 +1,4 @@
package work.slhaf.partner.framework.agent.common.support;
package work.slhaf.partner.framework.agent.support;
import lombok.extern.slf4j.Slf4j;

View File

@@ -3,7 +3,7 @@ package work.slhaf.partner.framework.common.support;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import work.slhaf.partner.framework.agent.common.support.DirectoryWatchSupport;
import work.slhaf.partner.framework.agent.support.DirectoryWatchSupport;
import java.io.IOException;
import java.nio.file.Files;