Skip to content

Commit a94df76

Browse files
committed
Added the Wanaku version in multiple places where it would be useful
This closes #140
1 parent 7ac5f8a commit a94df76

File tree

16 files changed

+229
-1
lines changed

16 files changed

+229
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package ai.wanaku.api.types.management;
2+
3+
public class ServerInfo {
4+
private String version;
5+
6+
public String getVersion() {
7+
return version;
8+
}
9+
10+
public void setVersion(String version) {
11+
this.version = version;
12+
}
13+
}

cli/src/main/java/ai/wanaku/cli/main/CliMain.java

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import jakarta.inject.Inject;
44

5+
import ai.wanaku.core.util.VersionHelper;
56
import io.quarkus.picocli.runtime.annotations.TopCommand;
67
import io.quarkus.runtime.QuarkusApplication;
78
import ai.wanaku.cli.main.commands.targets.Targets;
@@ -21,12 +22,18 @@ public class CliMain implements Runnable, QuarkusApplication {
2122
@CommandLine.Option(names = { "-h", "--help" }, usageHelp = true, description = "Display the help and sub-commands")
2223
private boolean helpRequested = false;
2324

25+
@CommandLine.Option(names = { "-v", "--version" }, description = "Display the current version of Wanaku CLI")
26+
private boolean versionRequested = false;
27+
2428
@Override
2529
public int run(String... args) throws Exception {
2630
return new CommandLine(this, factory).execute(args);
2731
}
2832

2933
@Override
3034
public void run() {
35+
if (versionRequested) {
36+
System.out.println("Wanaku CLI version " + VersionHelper.VERSION);
37+
}
3138
}
3239
}

core/core-util/pom.xml

+9
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@
4343
</dependencies>
4444

4545
<build>
46+
<resources>
47+
<resource>
48+
<directory>src/main/resources</directory>
49+
<filtering>true</filtering>
50+
<includes>
51+
<include>**/version.txt</include>
52+
</includes>
53+
</resource>
54+
</resources>
4655
<plugins>
4756
<plugin>
4857
<groupId>org.apache.maven.plugins</groupId>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package ai.wanaku.core.util;
2+
3+
import java.io.IOException;
4+
5+
public final class VersionHelper {
6+
public static final String VERSION;
7+
8+
static {
9+
VERSION = initVersion();
10+
}
11+
12+
13+
private VersionHelper() {}
14+
15+
private static String initVersion() {
16+
try {
17+
byte[] bytes = VersionHelper.class.getResourceAsStream("/version.txt").readAllBytes();
18+
return new String(bytes);
19+
} catch (IOException e) {
20+
throw new RuntimeException(e);
21+
}
22+
}
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
${project.version}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package ai.wanaku.core.util;
2+
3+
import org.junit.jupiter.api.Assertions;
4+
import org.junit.jupiter.api.Test;
5+
6+
public class VersionHelperTest {
7+
8+
@Test
9+
public void testVersion() {
10+
Assertions.assertNotNull(VersionHelper.VERSION);
11+
Assertions.assertNotEquals("", VersionHelper.VERSION);
12+
Assertions.assertNotEquals("${project.version}", VersionHelper.VERSION);
13+
}
14+
}

routers/wanaku-router/src/main/java/ai/wanaku/routers/ToolsProvider.java

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package ai.wanaku.routers;
22

33
import ai.wanaku.core.mcp.providers.ServiceRegistry;
4+
import ai.wanaku.core.util.VersionHelper;
45
import java.io.File;
56

67
import jakarta.enterprise.context.ApplicationScoped;
@@ -42,6 +43,7 @@ public ToolsResolver devResolver() {
4243
return new NoopToolsResolver();
4344
}
4445

46+
LOG.infof("Wanaku version %s is starting", VersionHelper.VERSION);
4547
File resourcesIndexFile = initializeResourcesIndex(config.indexesPath(), DEFAULT_TOOLS_INDEX_FILE_NAME);
4648
LOG.infof("Using resources index file: %s", resourcesIndexFile.getAbsolutePath());
4749

@@ -58,6 +60,7 @@ ToolsResolver getResolver() {
5860

5961
File resourcesIndexFile = initializeIndex();
6062

63+
LOG.infof("Wanaku version %s is starting", VersionHelper.VERSION);
6164
return new WanakuToolsResolver(resourcesIndexFile, new InvokerProxy(serviceRegistry));
6265
}
6366

routers/wanaku-router/src/main/resources/application.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ quarkus.mcp.server.traffic-logging.enabled=true
1515
quarkus.mcp.server.traffic-logging.text-limit=500
1616
quarkus.mcp.server.server-info.name=Wanaku
1717
quarkus.mcp.server.client-logging.default-level=debug
18-
quarkus.mcp.server.server-info.version=1.0.0
18+
quarkus.mcp.server.server-info.version=0.0.2
1919

2020
quarkus.grpc.server.use-separate-server=false
2121

routers/wanaku-router/src/main/webui/openapi.json

+37
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,14 @@
9292
}
9393
}
9494
},
95+
"ServerInfo" : {
96+
"type" : "object",
97+
"properties" : {
98+
"version" : {
99+
"type" : "string"
100+
}
101+
}
102+
},
95103
"Service" : {
96104
"type" : "object",
97105
"properties" : {
@@ -181,10 +189,39 @@
181189
}
182190
}
183191
}
192+
},
193+
"WanakuResponseServerInfo" : {
194+
"type" : "object",
195+
"properties" : {
196+
"error" : {
197+
"$ref" : "#/components/schemas/WanakuError"
198+
},
199+
"data" : {
200+
"$ref" : "#/components/schemas/ServerInfo"
201+
}
202+
}
184203
}
185204
}
186205
},
187206
"paths" : {
207+
"/api/v1/management/info/version" : {
208+
"get" : {
209+
"responses" : {
210+
"200" : {
211+
"description" : "OK",
212+
"content" : {
213+
"application/json" : {
214+
"schema" : {
215+
"$ref" : "#/components/schemas/WanakuResponseServerInfo"
216+
}
217+
}
218+
}
219+
}
220+
},
221+
"summary" : "Version",
222+
"tags" : [ "Info Resource" ]
223+
}
224+
},
188225
"/api/v1/management/targets/resources/configure/{service}" : {
189226
"put" : {
190227
"parameters" : [ {

routers/wanaku-router/src/main/webui/openapi.yaml

+24
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ components:
6060
type: array
6161
items:
6262
$ref: "#/components/schemas/Param"
63+
ServerInfo:
64+
type: object
65+
properties:
66+
version:
67+
type: string
6368
Service:
6469
type: object
6570
properties:
@@ -118,7 +123,26 @@ components:
118123
type: object
119124
additionalProperties:
120125
$ref: "#/components/schemas/Service"
126+
WanakuResponseServerInfo:
127+
type: object
128+
properties:
129+
error:
130+
$ref: "#/components/schemas/WanakuError"
131+
data:
132+
$ref: "#/components/schemas/ServerInfo"
121133
paths:
134+
/api/v1/management/info/version:
135+
get:
136+
responses:
137+
"200":
138+
description: OK
139+
content:
140+
application/json:
141+
schema:
142+
$ref: "#/components/schemas/WanakuResponseServerInfo"
143+
summary: Version
144+
tags:
145+
- Info Resource
122146
/api/v1/management/targets/resources/configure/{service}:
123147
put:
124148
parameters:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package ai.wanaku.server.quarkus.api.v1.management.info;
2+
3+
import jakarta.enterprise.context.ApplicationScoped;
4+
import jakarta.ws.rs.GET;
5+
import jakarta.ws.rs.Path;
6+
import jakarta.ws.rs.Produces;
7+
import jakarta.ws.rs.core.MediaType;
8+
9+
import ai.wanaku.api.types.WanakuResponse;
10+
import ai.wanaku.api.types.management.ServerInfo;
11+
import ai.wanaku.core.util.VersionHelper;
12+
13+
@ApplicationScoped
14+
@Path("/api/v1/management/info")
15+
public class InfoResource {
16+
17+
@Path("/version")
18+
@GET
19+
@Produces(MediaType.APPLICATION_JSON)
20+
public WanakuResponse<ServerInfo> version() {
21+
ServerInfo si = new ServerInfo();
22+
si.setVersion(VersionHelper.VERSION);
23+
24+
return new WanakuResponse<>(si);
25+
}
26+
}

ui/src/api/wanaku-router-api.ts

+33
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,42 @@ import type {
1414
WanakuResponseListResourceReference,
1515
WanakuResponseListToolReference,
1616
WanakuResponseMapStringService,
17+
WanakuResponseServerInfo,
1718
} from "../models";
1819

1920
import { customFetch } from "../custom-fetch";
21+
/**
22+
* @summary Version
23+
*/
24+
export type getApiV1ManagementInfoVersionResponse200 = {
25+
data: WanakuResponseServerInfo;
26+
status: 200;
27+
};
28+
29+
export type getApiV1ManagementInfoVersionResponseComposite =
30+
getApiV1ManagementInfoVersionResponse200;
31+
32+
export type getApiV1ManagementInfoVersionResponse =
33+
getApiV1ManagementInfoVersionResponseComposite & {
34+
headers: Headers;
35+
};
36+
37+
export const getGetApiV1ManagementInfoVersionUrl = () => {
38+
return `/api/v1/management/info/version`;
39+
};
40+
41+
export const getApiV1ManagementInfoVersion = async (
42+
options?: RequestInit,
43+
): Promise<getApiV1ManagementInfoVersionResponse> => {
44+
return customFetch<getApiV1ManagementInfoVersionResponse>(
45+
getGetApiV1ManagementInfoVersionUrl(),
46+
{
47+
...options,
48+
method: "GET",
49+
},
50+
);
51+
};
52+
2053
/**
2154
* @summary Resources Configure
2255
*/

ui/src/models/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export * from "./putApiV1ManagementTargetsToolsUnlinkParams";
2323
export * from "./putApiV1ResourcesRemoveParams";
2424
export * from "./putApiV1ToolsRemoveParams";
2525
export * from "./resourceReference";
26+
export * from "./serverInfo";
2627
export * from "./service";
2728
export * from "./toolReference";
2829
export * from "./wanakuError";
@@ -31,3 +32,5 @@ export * from "./wanakuResponseListResourceReference";
3132
export * from "./wanakuResponseListToolReference";
3233
export * from "./wanakuResponseMapStringService";
3334
export * from "./wanakuResponseMapStringServiceData";
35+
export * from "./wanakuResponseServerInfo";
36+
export * from "./wanakuResponseString";

ui/src/models/serverInfo.ts

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* Generated by orval v7.6.0 🍺
3+
* Do not edit manually.
4+
* wanaku-router API
5+
* OpenAPI spec version: 0.0.2-SNAPSHOT
6+
*/
7+
8+
export interface ServerInfo {
9+
version?: string;
10+
}
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* Generated by orval v7.6.0 🍺
3+
* Do not edit manually.
4+
* wanaku-router API
5+
* OpenAPI spec version: 0.0.2-SNAPSHOT
6+
*/
7+
import type { WanakuError } from "./wanakuError";
8+
import type { ServerInfo } from "./serverInfo";
9+
10+
export interface WanakuResponseServerInfo {
11+
error?: WanakuError;
12+
data?: ServerInfo;
13+
}

ui/src/models/wanakuResponseString.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* Generated by orval v7.6.0 🍺
3+
* Do not edit manually.
4+
* wanaku-router API
5+
* OpenAPI spec version: 0.0.2-SNAPSHOT
6+
*/
7+
import type { WanakuError } from "./wanakuError";
8+
9+
export interface WanakuResponseString {
10+
error?: WanakuError;
11+
data?: string;
12+
}

0 commit comments

Comments
 (0)