Cleanup [stage] [arm]

This commit is contained in:
crschnick
2025-08-14 11:31:39 +00:00
parent 12a58875d5
commit 1841059327
4 changed files with 2 additions and 205 deletions
@@ -76,41 +76,6 @@ public class AppMcpServer {
syncServer.notifyToolsListChanged();
});
// syncServer.addResource(McpResources.connections());
// syncServer.addResource(McpResources.categories());
//
// DataStorage.get().addListener(new StorageListener() {
// @Override
// public void onStoreListUpdate() {
// syncServer.notifyResourcesListChanged();
// }
//
// @Override
// public void onStoreAdd(DataStoreEntry... entry) {
// syncServer.notifyResourcesListChanged();
// }
//
// @Override
// public void onStoreRemove(DataStoreEntry... entry) {
// syncServer.notifyResourcesListChanged();
// }
//
// @Override
// public void onCategoryAdd(DataStoreCategory category) {
// syncServer.notifyResourcesListChanged();
// }
//
// @Override
// public void onCategoryRemove(DataStoreCategory category) {
// syncServer.notifyResourcesListChanged();
// }
//
// @Override
// public void onEntryCategoryChange() {
// syncServer.notifyResourcesListChanged();
// }
// });
INSTANCE = new AppMcpServer(syncServer, transportProvider);
}
@@ -1,168 +0,0 @@
package io.xpipe.app.beacon.mcp;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.core.JacksonMapper;
import io.xpipe.core.StorePath;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import io.modelcontextprotocol.server.McpServerFeatures;
import io.modelcontextprotocol.spec.McpSchema;
import lombok.Builder;
import lombok.NonNull;
import lombok.Value;
import lombok.extern.jackson.Jacksonized;
import org.apache.commons.lang3.ClassUtils;
import java.time.Instant;
import java.util.*;
import java.util.stream.Collectors;
public final class McpResources {
public static McpServerFeatures.SyncResourceSpecification connections() {
McpSchema.Annotations annotations = new McpSchema.Annotations(List.of(McpSchema.Role.ASSISTANT), 1.0);
var resource = McpSchema.Resource.builder()
.uri("xpipe://connections")
.name("xpipe connections")
.description("Available connections in xpipe")
.mimeType("application/json")
.annotations(annotations)
.build();
return new McpServerFeatures.SyncResourceSpecification(resource, (exchange, request) -> {
var list = new ArrayList<McpSchema.ResourceContents>();
for (var e : DataStorage.get().getStoreEntries()) {
if (!e.getValidity().isUsable()) {
continue;
}
var names = DataStorage.get()
.getStorePath(DataStorage.get()
.getStoreCategoryIfPresent(e.getCategoryUuid())
.orElseThrow())
.getNames();
var cat = new StorePath(names.subList(1, names.size()));
var cache = e.getStoreCache().entrySet().stream()
.filter(stringObjectEntry -> {
return stringObjectEntry.getValue() != null
&& (ClassUtils.isPrimitiveOrWrapper(
stringObjectEntry.getValue().getClass())
|| stringObjectEntry.getValue() instanceof String);
})
.collect(Collectors.toMap(
stringObjectEntry -> stringObjectEntry.getKey(),
stringObjectEntry -> stringObjectEntry.getValue()));
var resourceData = ConnectionResource.builder()
.lastModified(e.getLastModified())
.lastUsed(e.getLastUsed())
.category(cat)
.name(DataStorage.get().getStorePath(e))
.connectionData(e.getStore())
.usageCategory(e.getProvider().getUsageCategory())
.type(e.getProvider().getId())
.internalState(e.getStorePersistentState() != null ? e.getStorePersistentState() : new Object())
.internalCache(cache)
.build();
McpSchema.TextResourceContents c;
try {
c = new McpSchema.TextResourceContents(
"xpipe://connections/" + e.getUuid(),
"application/json",
JacksonMapper.getDefault().writeValueAsString(resourceData));
} catch (JsonProcessingException ex) {
throw new RuntimeException(ex);
}
list.add(c);
}
return new McpSchema.ReadResourceResult(list);
});
}
public static McpServerFeatures.SyncResourceSpecification categories() {
McpSchema.Annotations annotations = new McpSchema.Annotations(List.of(McpSchema.Role.ASSISTANT), 0.3);
var resource = McpSchema.Resource.builder()
.uri("xpipe://categories")
.name("xpipe categories")
.description("Available categories in xpipe")
.mimeType("application/json")
.annotations(annotations)
.build();
return new McpServerFeatures.SyncResourceSpecification(resource, (exchange, request) -> {
var list = new ArrayList<McpSchema.ResourceContents>();
for (var cat : DataStorage.get().getStoreCategories()) {
var name = DataStorage.get().getStorePath(cat);
var jsonData = CategoryResource.builder()
.lastModified(cat.getLastModified())
.lastUsed(cat.getLastUsed())
.name(name)
.config(JacksonMapper.getDefault().valueToTree(cat.getConfig()))
.build();
McpSchema.TextResourceContents c;
try {
c = new McpSchema.TextResourceContents(
"xpipe://categories/" + cat.getUuid(),
"application/json",
JacksonMapper.getDefault().writeValueAsString(jsonData));
} catch (JsonProcessingException ex) {
throw new RuntimeException(ex);
}
list.add(c);
}
return new McpSchema.ReadResourceResult(list);
});
}
@Jacksonized
@Builder
@Value
public static class ConnectionResource {
@NonNull
StorePath name;
@NonNull
StorePath category;
@NonNull
String type;
@NonNull
Object connectionData;
@NonNull
Object usageCategory;
@NonNull
Instant lastUsed;
@NonNull
Instant lastModified;
@NonNull
Object internalState;
@NonNull
Map<String, Object> internalCache;
}
@Jacksonized
@Builder
@Value
public static class CategoryResource {
@NonNull
StorePath name;
@NonNull
Instant lastUsed;
@NonNull
Instant lastModified;
@NonNull
JsonNode config;
}
}
@@ -179,7 +179,7 @@ public class TroubleshootCategory extends AppPrefsCategory {
.title("Uninstall")
.localScript(sc -> ShellScript.lines(
"echo \"+ sudo " + file + "\"",
"sudo " + file,
"sudo \"" + file + "\"",
ProcessControlProvider.get()
.getEffectiveLocalDialect()
.getPauseCommand()))
+1 -1
View File
@@ -1 +1 @@
18.0-15
18.0-16