Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,24 @@ public McpProbeResponse probe(McpEndpoint endpoint) {
try {
Map<String, Object> payload = endpointPayload(endpoint);
Map<String, Object> response = post(baseUrl + "/proxy/probe", payload);
boolean success = readSuccess(response);
int latencyMs = readLatency(response, (int) (System.currentTimeMillis() - start));
if (!success) {

Boolean success = readSuccessNullable(response);
if (success != null) {
if (!success) {
return McpProbeResponse.failure(readMessage(response), latencyMs);
}
return McpProbeResponse.success(latencyMs);
}

String status = readStatus(response);
if ("online".equals(status) || "degraded".equals(status)) {
return McpProbeResponse.success(latencyMs);
}
if (StringUtils.hasText(status)) {
return McpProbeResponse.failure(readMessage(response), latencyMs);
}
return McpProbeResponse.success(latencyMs);
return McpProbeResponse.failure("mcp gateway probe returned unknown response", latencyMs);
} catch (Exception ex) {
int latencyMs = (int) Math.max(1, System.currentTimeMillis() - start);
return McpProbeResponse.failure(ex.getMessage(), latencyMs);
Expand Down Expand Up @@ -144,6 +156,28 @@ private boolean readSuccess(Map<String, Object> body) {
return Boolean.TRUE.equals(success);
}

private Boolean readSuccessNullable(Map<String, Object> body) {
if (body == null || !body.containsKey("success")) {
return null;
}
Object success = body.get("success");
if (success instanceof Boolean bool) {
return bool;
}
if (success == null) {
return null;
}
return Boolean.parseBoolean(String.valueOf(success));
}

private String readStatus(Map<String, Object> body) {
Object status = body.get("status");
if (status == null) {
return null;
}
return String.valueOf(status).trim().toLowerCase();
}

private String readMessage(Map<String, Object> body) {
Object message = body.get("message");
if (message == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ public List<CommitInfo> listCommits(String skillName, int page, int pageSize) {
}

private SkillException unsupported() {
return new SkillException("agent.skill.provider='" + provider + "' is not supported yet");
return new SkillException("linkwork.agent.skill.provider='" + provider + "' is not supported yet");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.linkwork.agent.skill.provider.gitlab.GitLabProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;

@ConfigurationProperties(prefix = "agent.skill")
@ConfigurationProperties(prefix = "linkwork.agent.skill")
public class AgentSkillProperties {
private boolean enabled = true;
private String provider = "gitlab";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@

@AutoConfiguration
@EnableConfigurationProperties(AgentSkillProperties.class)
@ConditionalOnProperty(prefix = "agent.skill", name = "enabled", havingValue = "true", matchIfMissing = true)
@ConditionalOnProperty(prefix = "linkwork.agent.skill", name = "enabled", havingValue = "true", matchIfMissing = true)
public class SkillAutoConfiguration {

@Bean
@ConditionalOnMissingBean(name = "skillGitLabRestClient")
@ConditionalOnProperty(prefix = "agent.skill", name = "provider", havingValue = "gitlab", matchIfMissing = true)
@ConditionalOnProperty(prefix = "linkwork.agent.skill", name = "provider", havingValue = "gitlab", matchIfMissing = true)
public RestClient skillGitLabRestClient(AgentSkillProperties properties,
ObjectProvider<RestClient.Builder> builderProvider) {
String baseUrl = properties.getGitlab().effectiveUrl();
Expand All @@ -36,7 +36,7 @@ public RestClient skillGitLabRestClient(AgentSkillProperties properties,

@Bean
@ConditionalOnMissingBean
@ConditionalOnProperty(prefix = "agent.skill", name = "provider", havingValue = "gitlab", matchIfMissing = true)
@ConditionalOnProperty(prefix = "linkwork.agent.skill", name = "provider", havingValue = "gitlab", matchIfMissing = true)
public SkillProvider skillProvider(RestClient skillGitLabRestClient,
AgentSkillProperties properties) {
return new GitLabProviderImpl(skillGitLabRestClient, properties.getGitlab());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,13 +342,13 @@ private String trimSlashes(String value) {

private void validate() {
if (properties.effectiveUrl() == null || properties.effectiveUrl().isBlank()) {
throw new SkillException("agent.skill.gitlab.url or agent.skill.gitlab.repo-url is required");
throw new SkillException("linkwork.agent.skill.gitlab.url or linkwork.agent.skill.gitlab.repo-url is required");
}
if (properties.effectiveToken() == null || properties.effectiveToken().isBlank()) {
throw new SkillException("agent.skill.gitlab.token or agent.skill.gitlab.deploy-token is required");
throw new SkillException("linkwork.agent.skill.gitlab.token or linkwork.agent.skill.gitlab.deploy-token is required");
}
if (properties.getProjectId() == null || properties.getProjectId().isBlank()) {
throw new SkillException("agent.skill.gitlab.project-id is required");
throw new SkillException("linkwork.agent.skill.gitlab.project-id is required");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ public StorageVolumeDef generateSandboxMountConfig(String workspaceId) {
}

private StorageException unsupported() {
return new StorageException("agent.storage.provider='" + provider + "' is not supported yet");
return new StorageException("linkwork.agent.storage.provider='" + provider + "' is not supported yet");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.linkwork.agent.storage.provider.nfs.NfsStorageProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;

@ConfigurationProperties(prefix = "agent.storage")
@ConfigurationProperties(prefix = "linkwork.agent.storage")
public class AgentStorageProperties {
private boolean enabled = true;
private String provider = "nfs";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@

@AutoConfiguration
@EnableConfigurationProperties(AgentStorageProperties.class)
@ConditionalOnProperty(prefix = "agent.storage", name = "enabled", havingValue = "true", matchIfMissing = true)
@ConditionalOnProperty(prefix = "linkwork.agent.storage", name = "enabled", havingValue = "true", matchIfMissing = true)
public class StorageAutoConfiguration {

@Bean
@ConditionalOnMissingBean
@ConditionalOnProperty(prefix = "agent.storage", name = "provider", havingValue = "nfs", matchIfMissing = true)
@ConditionalOnProperty(prefix = "linkwork.agent.storage", name = "provider", havingValue = "nfs", matchIfMissing = true)
public StorageProvider storageProvider(AgentStorageProperties properties) {
return new NfsStorageProviderImpl(properties.getNfs());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ private void assertWithinBase(Path path) {

private Path resolveBaseRoot(String basePath) {
if (basePath == null || basePath.isBlank()) {
throw new StorageException("agent.storage.nfs.base-path is required");
throw new StorageException("linkwork.agent.storage.nfs.base-path is required");
}
return Path.of(basePath).toAbsolutePath().normalize();
}
Expand Down