refactor(runner): load different policy provider according to os, now support bwrap sandbox in linux only

This commit is contained in:
2026-03-17 12:21:31 +08:00
parent a6682a7719
commit 5a717dbdda

View File

@@ -1,5 +1,7 @@
package work.slhaf.partner.core.action.runner;
import cn.hutool.system.OsInfo;
import cn.hutool.system.SystemUtil;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.jetbrains.annotations.Nullable;
@@ -71,7 +73,8 @@ public class LocalRunnerClient extends RunnerClient implements AutoCloseable {
McpConfigWatcher configWatcher = null;
try {
ExecutionPolicyRegistry.INSTANCE.registerPolicyProvider(BwrapPolicyProvider.INSTANCE);
registerPolicyProviders();
metaRegistry = new McpMetaRegistry(existedMetaActions);
registerMcpClient(clientRegistry, transportFactory, MCP_NAME_DESC, metaRegistry.clientConfig(MCP_NAME_DESC, 10));
@@ -123,6 +126,13 @@ public class LocalRunnerClient extends RunnerClient implements AutoCloseable {
setupShutdownHook();
}
private void registerPolicyProviders() {
OsInfo os = SystemUtil.getOsInfo();
if (os.isLinux()) {
ExecutionPolicyRegistry.INSTANCE.registerPolicyProvider(BwrapPolicyProvider.INSTANCE);
}
}
@Override
protected RunnerResponse doRun(MetaAction metaAction) {
log.debug("执行行动: {}", metaAction);