first commit
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
plugins { id("java-library-conventions") }
|
||||
dependencies {
|
||||
implementation(project(":gateway-module-tool-registry:tool-registry-contract-subjects"))
|
||||
implementation("org.springframework.boot:spring-boot-starter")
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package net.bquarkz.ai.gateway.providers.database;
|
||||
|
||||
import net.bquarkz.ai.gateway.tools.contracts.ToolProvider;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class DatabaseExecuteScriptProvider implements ToolProvider {
|
||||
@Override
|
||||
public String getName() { return "db.executeScript"; }
|
||||
|
||||
@Override
|
||||
public String getDescription() { return "Execute an arbitrary database script"; }
|
||||
|
||||
@Override
|
||||
public List<String> getActions() { return List.of("execute"); }
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getInputSchema() {
|
||||
return Map.of(
|
||||
"type", "object",
|
||||
"properties", Map.of(
|
||||
"script", Map.of("type", "string", "description", "SQL script to execute")
|
||||
),
|
||||
"required", List.of("script")
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> execute(String action, Map<String, Object> arguments) {
|
||||
return Map.of("status", "executed");
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package net.bquarkz.ai.gateway.providers.database;
|
||||
|
||||
import net.bquarkz.ai.gateway.tools.contracts.ToolProvider;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class DatabaseQueryReadonlyProvider implements ToolProvider {
|
||||
@Override
|
||||
public String getName() { return "db.queryReadonly"; }
|
||||
|
||||
@Override
|
||||
public String getDescription() { return "Execute a read-only database query"; }
|
||||
|
||||
@Override
|
||||
public List<String> getActions() { return List.of("query"); }
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getInputSchema() {
|
||||
return Map.of(
|
||||
"type", "object",
|
||||
"properties", Map.of(
|
||||
"sql", Map.of("type", "string", "description", "SQL query to execute")
|
||||
),
|
||||
"required", List.of("sql")
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> execute(String action, Map<String, Object> arguments) {
|
||||
return Map.of(
|
||||
"rows", List.of(Map.of("id", 1, "name", "test")),
|
||||
"count", 1
|
||||
);
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package net.bquarkz.ai.gateway.providers.database;
|
||||
|
||||
import net.bquarkz.ai.gateway.tools.contracts.ToolProvider;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class DatabaseRunLiquibaseProvider implements ToolProvider {
|
||||
@Override
|
||||
public String getName() { return "db.runLiquibase"; }
|
||||
|
||||
@Override
|
||||
public String getDescription() { return "Run a Liquibase changelog migration"; }
|
||||
|
||||
@Override
|
||||
public List<String> getActions() { return List.of("migrate"); }
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getInputSchema() {
|
||||
return Map.of(
|
||||
"type", "object",
|
||||
"properties", Map.of(
|
||||
"changelog", Map.of("type", "string", "description", "Changelog file to apply")
|
||||
),
|
||||
"required", List.of("changelog")
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> execute(String action, Map<String, Object> arguments) {
|
||||
return Map.of(
|
||||
"status", "migration applied",
|
||||
"changelog", arguments.getOrDefault("changelog", "unknown")
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user