Skip to content

Commit 8c32b76

Browse files
authored
Merge pull request #20 from OriginTrail/feature/check-publish-status-publisher-plugin
add checking status for publisher plugin
2 parents 3f20e88 + 1abe45d commit 8c32b76

8 files changed

Lines changed: 552 additions & 52 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,4 @@ dkg-engine
4747
# RAGAS Reports
4848
apps/agent/tests/ragas/reports/
4949
tests/ragas/reports/
50+
docker-compose.knowledge-manager.yml

apps/agent/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,8 @@ playwright/.cache/
5050
data/
5151
tests/ragas/reports/
5252
ragas-results.json
53+
.env.publisher
54+
logs
55+
storage
56+
docker-compose.knowledge-manager.yml
57+
DKG_Node_Publisher_Tests.xml

apps/agent/src/components/Chat/Input.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ const styles = StyleSheet.create({
199199
},
200200
input: {
201201
borderRadius: 50,
202-
paddingHorizontal: 20,
202+
paddingLeft: 20,
203+
paddingRight: 116,
203204
paddingVertical: 16,
204205
height: 56,
205206
fontSize: 16,

packages/plugin-dkg-publisher/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ Thumbs.db
3434
.idea/
3535
.vscode/
3636
*.swp
37-
*.swo
37+
*.swo
38+
.env.publisher

packages/plugin-dkg-publisher/src/index.ts

Lines changed: 24 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ import {
88
shutdownServices,
99
ServiceContainer,
1010
AssetService,
11+
WalletService,
1112
QueueService,
1213
DkgService,
1314
} from "./services";
1415
import { openAPIRoute } from "@dkg/plugin-swagger";
15-
1616
import express from "express";
17+
import { registerMcpTools } from "./mcp/tools";
1718

1819
/**
1920
* DKG Publisher Plugin
@@ -161,6 +162,10 @@ export default defineDkgPlugin((_ctx, mcp, api) => {
161162
attemptCount: z.number(),
162163
}),
163164
},
165+
finalizeRouteConfig: (config) => ({
166+
...config,
167+
security: [],
168+
}),
164169
},
165170
async (req, res) => {
166171
if (!serviceContainer) {
@@ -199,6 +204,10 @@ export default defineDkgPlugin((_ctx, mcp, api) => {
199204
params: z.object({
200205
id: z.string().transform(Number),
201206
}),
207+
finalizeRouteConfig: (config) => ({
208+
...config,
209+
security: [],
210+
}),
202211
},
203212
async (req, res) => {
204213
if (!serviceContainer) {
@@ -232,8 +241,8 @@ export default defineDkgPlugin((_ctx, mcp, api) => {
232241

233242
try {
234243
const queueService = serviceContainer.get<QueueService>("queueService");
235-
const assetService = serviceContainer.get<any>("assetService");
236-
const walletService = serviceContainer.get<any>("walletService");
244+
const assetService = serviceContainer.get<AssetService>("assetService");
245+
const walletService = serviceContainer.get<WalletService>("walletService");
237246

238247
// Get Redis queue stats
239248
const queueStats = await queueService.getQueueStats();
@@ -260,7 +269,7 @@ export default defineDkgPlugin((_ctx, mcp, api) => {
260269
capacity: {
261270
totalWallets: walletStats.total,
262271
availableWallets: walletStats.available,
263-
lockedWallets: walletStats.locked,
272+
lockedWallets: walletStats.inUse,
264273
availableSlots: availableSlots, // Slots available for new jobs
265274
},
266275
});
@@ -275,7 +284,7 @@ export default defineDkgPlugin((_ctx, mcp, api) => {
275284
}
276285

277286
try {
278-
const walletService = serviceContainer.get<any>("walletService");
287+
const walletService = serviceContainer.get<WalletService>("walletService");
279288
const stats = await walletService.getWalletStats();
280289
res.json(stats);
281290
} catch (error: any) {
@@ -312,6 +321,10 @@ export default defineDkgPlugin((_ctx, mcp, api) => {
312321
.optional(),
313322
}),
314323
},
324+
finalizeRouteConfig: (config) => ({
325+
...config,
326+
security: [],
327+
}),
315328
},
316329
async (req, res) => {
317330
if (!serviceContainer) {
@@ -357,6 +370,10 @@ export default defineDkgPlugin((_ctx, mcp, api) => {
357370
error: z.string().optional(),
358371
}),
359372
},
373+
finalizeRouteConfig: (config) => ({
374+
...config,
375+
security: [],
376+
}),
360377
},
361378
async (req, res) => {
362379
if (!serviceContainer) {
@@ -383,51 +400,8 @@ export default defineDkgPlugin((_ctx, mcp, api) => {
383400
),
384401
);
385402

386-
// MCP tool for creating knowledge assets
387-
mcp.registerTool(
388-
"knowledge-asset-publish",
389-
{
390-
title: "Publish Knowledge Asset",
391-
description: "Register a JSON-LD asset for publishing to the DKG",
392-
inputSchema: {
393-
content: z.object({}).passthrough(),
394-
metadata: z
395-
.object({
396-
source: z.string().optional(),
397-
sourceId: z.string().optional(),
398-
})
399-
.optional(),
400-
privacy: z.enum(["private", "public"]).optional(),
401-
},
402-
},
403-
async (input) => {
404-
if (!serviceContainer) {
405-
throw new Error("DKG Publisher Plugin not configured");
406-
}
407-
408-
const assetService = serviceContainer.get<AssetService>("assetService");
409-
410-
const assetInput = {
411-
content: input.content,
412-
metadata: input.metadata,
413-
publishOptions: {
414-
privacy: input.privacy || "private",
415-
},
416-
};
417-
418-
const result = await assetService.registerAsset(assetInput);
419-
// Asset registration emits 'asset-queued' event which triggers queue addition
420-
421-
return {
422-
content: [
423-
{
424-
type: "text",
425-
text: `Asset registered for publishing: ${result.id} (Status: ${result.status})`,
426-
},
427-
],
428-
};
429-
},
430-
);
403+
// Register all MCP tools for publisher plugin
404+
registerMcpTools(mcp, serviceContainer);
431405
});
432406

433407
// Cleanup function

0 commit comments

Comments
 (0)