From 1841059327d4e521046597331bdb03ae55077c05 Mon Sep 17 00:00:00 2001 From: crschnick Date: Thu, 14 Aug 2025 11:31:39 +0000 Subject: [PATCH] Cleanup [stage] [arm] --- .../io/xpipe/app/beacon/mcp/AppMcpServer.java | 35 ---- .../io/xpipe/app/beacon/mcp/McpResources.java | 168 ------------------ .../xpipe/app/prefs/TroubleshootCategory.java | 2 +- version | 2 +- 4 files changed, 2 insertions(+), 205 deletions(-) delete mode 100644 app/src/main/java/io/xpipe/app/beacon/mcp/McpResources.java diff --git a/app/src/main/java/io/xpipe/app/beacon/mcp/AppMcpServer.java b/app/src/main/java/io/xpipe/app/beacon/mcp/AppMcpServer.java index 4d3288cdc..cb47634d5 100644 --- a/app/src/main/java/io/xpipe/app/beacon/mcp/AppMcpServer.java +++ b/app/src/main/java/io/xpipe/app/beacon/mcp/AppMcpServer.java @@ -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); } diff --git a/app/src/main/java/io/xpipe/app/beacon/mcp/McpResources.java b/app/src/main/java/io/xpipe/app/beacon/mcp/McpResources.java deleted file mode 100644 index fb8eb846e..000000000 --- a/app/src/main/java/io/xpipe/app/beacon/mcp/McpResources.java +++ /dev/null @@ -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(); - 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(); - 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 internalCache; - } - - @Jacksonized - @Builder - @Value - public static class CategoryResource { - @NonNull - StorePath name; - - @NonNull - Instant lastUsed; - - @NonNull - Instant lastModified; - - @NonNull - JsonNode config; - } -} diff --git a/app/src/main/java/io/xpipe/app/prefs/TroubleshootCategory.java b/app/src/main/java/io/xpipe/app/prefs/TroubleshootCategory.java index 14af30f22..79b03b360 100644 --- a/app/src/main/java/io/xpipe/app/prefs/TroubleshootCategory.java +++ b/app/src/main/java/io/xpipe/app/prefs/TroubleshootCategory.java @@ -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())) diff --git a/version b/version index 14a2667a8..bda92376d 100644 --- a/version +++ b/version @@ -1 +1 @@ -18.0-15 +18.0-16