@stamn/stamn-plugin 0.1.0-alpha.26 → 0.1.0-alpha.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +45 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5084,12 +5084,38 @@ function ensurePluginConfig(config) {
|
|
|
5084
5084
|
function readOpenclawConfig() {
|
|
5085
5085
|
return readJsonFile(getConfigPath()) ?? {};
|
|
5086
5086
|
}
|
|
5087
|
+
var STAMN_TOOL_NAMES = [
|
|
5088
|
+
"stamn_ping",
|
|
5089
|
+
"stamn_world_status",
|
|
5090
|
+
"stamn_get_events",
|
|
5091
|
+
"stamn_get_balance",
|
|
5092
|
+
"stamn_move",
|
|
5093
|
+
"stamn_claim_land",
|
|
5094
|
+
"stamn_register_service",
|
|
5095
|
+
"stamn_service_respond",
|
|
5096
|
+
"stamn_request_service",
|
|
5097
|
+
"stamn_create_service_listing",
|
|
5098
|
+
"stamn_update_service_listing",
|
|
5099
|
+
"stamn_list_service_listings",
|
|
5100
|
+
"stamn_chat_reply",
|
|
5101
|
+
"stamn_spend"
|
|
5102
|
+
];
|
|
5087
5103
|
function ensureToolsAllowed() {
|
|
5088
5104
|
const config = readOpenclawConfig();
|
|
5089
5105
|
if (!config.tools) config.tools = {};
|
|
5090
5106
|
if (!Array.isArray(config.tools.alsoAllow)) config.tools.alsoAllow = [];
|
|
5107
|
+
let changed = false;
|
|
5091
5108
|
if (!config.tools.alsoAllow.includes("group:plugins")) {
|
|
5092
5109
|
config.tools.alsoAllow.push("group:plugins");
|
|
5110
|
+
changed = true;
|
|
5111
|
+
}
|
|
5112
|
+
for (const name of STAMN_TOOL_NAMES) {
|
|
5113
|
+
if (!config.tools.alsoAllow.includes(name)) {
|
|
5114
|
+
config.tools.alsoAllow.push(name);
|
|
5115
|
+
changed = true;
|
|
5116
|
+
}
|
|
5117
|
+
}
|
|
5118
|
+
if (changed) {
|
|
5093
5119
|
writeJsonFile(getConfigPath(), config);
|
|
5094
5120
|
}
|
|
5095
5121
|
}
|
|
@@ -5256,7 +5282,7 @@ function move(ws, agentId) {
|
|
|
5256
5282
|
},
|
|
5257
5283
|
required: ["direction"]
|
|
5258
5284
|
},
|
|
5259
|
-
execute: (args) => {
|
|
5285
|
+
execute: (_id, args) => {
|
|
5260
5286
|
ws.send("participant:move", { participantId: agentId, direction: args.direction });
|
|
5261
5287
|
return text(`Moving ${args.direction}.`);
|
|
5262
5288
|
}
|
|
@@ -5286,7 +5312,7 @@ function registerService(ws, agentId) {
|
|
|
5286
5312
|
},
|
|
5287
5313
|
required: ["serviceTag", "description", "priceCents"]
|
|
5288
5314
|
},
|
|
5289
|
-
execute: (args) => {
|
|
5315
|
+
execute: (_id, args) => {
|
|
5290
5316
|
ws.send("participant:service_register", {
|
|
5291
5317
|
participantId: agentId,
|
|
5292
5318
|
serviceTag: args.serviceTag,
|
|
@@ -5310,7 +5336,7 @@ function respondToService(ws) {
|
|
|
5310
5336
|
},
|
|
5311
5337
|
required: ["requestId", "output", "success"]
|
|
5312
5338
|
},
|
|
5313
|
-
execute: (args) => {
|
|
5339
|
+
execute: (_id, args) => {
|
|
5314
5340
|
ws.send("participant:service_result", {
|
|
5315
5341
|
requestId: args.requestId,
|
|
5316
5342
|
output: args.output,
|
|
@@ -5334,7 +5360,7 @@ function requestService(ws) {
|
|
|
5334
5360
|
},
|
|
5335
5361
|
required: ["toParticipantId", "serviceTag", "input", "offeredPriceCents"]
|
|
5336
5362
|
},
|
|
5337
|
-
execute: (args) => {
|
|
5363
|
+
execute: (_id, args) => {
|
|
5338
5364
|
const requestId = randomUUID();
|
|
5339
5365
|
ws.send("participant:service_request", {
|
|
5340
5366
|
requestId,
|
|
@@ -5373,7 +5399,7 @@ function createServiceListing(ws, agentId) {
|
|
|
5373
5399
|
},
|
|
5374
5400
|
required: ["serviceTag", "name", "description", "priceCents"]
|
|
5375
5401
|
},
|
|
5376
|
-
execute: (args) => {
|
|
5402
|
+
execute: (_id, args) => {
|
|
5377
5403
|
const payload = {
|
|
5378
5404
|
participantId: agentId,
|
|
5379
5405
|
serviceTag: args.serviceTag,
|
|
@@ -5427,7 +5453,7 @@ function updateServiceListing(ws) {
|
|
|
5427
5453
|
},
|
|
5428
5454
|
required: ["serviceId"]
|
|
5429
5455
|
},
|
|
5430
|
-
execute: (args) => {
|
|
5456
|
+
execute: (_id, args) => {
|
|
5431
5457
|
const payload = {
|
|
5432
5458
|
serviceId: args.serviceId
|
|
5433
5459
|
};
|
|
@@ -5479,7 +5505,7 @@ function chatReply(ws, agentId) {
|
|
|
5479
5505
|
},
|
|
5480
5506
|
required: ["text"]
|
|
5481
5507
|
},
|
|
5482
|
-
execute: (args) => {
|
|
5508
|
+
execute: (_id, args) => {
|
|
5483
5509
|
ws.send("participant:owner_chat_reply", {
|
|
5484
5510
|
participantId: agentId,
|
|
5485
5511
|
text: args.text,
|
|
@@ -5509,7 +5535,7 @@ function spend(ws) {
|
|
|
5509
5535
|
},
|
|
5510
5536
|
required: ["amountCents", "description", "category", "rail"]
|
|
5511
5537
|
},
|
|
5512
|
-
execute: (args) => {
|
|
5538
|
+
execute: (_id, args) => {
|
|
5513
5539
|
const requestId = randomUUID();
|
|
5514
5540
|
ws.send("participant:spend_request", {
|
|
5515
5541
|
requestId,
|
|
@@ -5525,6 +5551,14 @@ function spend(ws) {
|
|
|
5525
5551
|
}
|
|
5526
5552
|
};
|
|
5527
5553
|
}
|
|
5554
|
+
function ping() {
|
|
5555
|
+
return {
|
|
5556
|
+
name: "stamn_ping",
|
|
5557
|
+
description: "Diagnostic ping. Returns OK if the Stamn plugin tools are loaded and reachable by the agent.",
|
|
5558
|
+
parameters: NO_PARAMS,
|
|
5559
|
+
execute: () => text("pong \u2014 stamn plugin tools are loaded and reachable.")
|
|
5560
|
+
};
|
|
5561
|
+
}
|
|
5528
5562
|
function allTools(ws, agentId) {
|
|
5529
5563
|
return [
|
|
5530
5564
|
worldStatus(ws),
|
|
@@ -5546,15 +5580,16 @@ function withAuthGuard(tool, ws) {
|
|
|
5546
5580
|
const originalExecute = tool.execute;
|
|
5547
5581
|
return {
|
|
5548
5582
|
...tool,
|
|
5549
|
-
execute: async (args) => {
|
|
5583
|
+
execute: async (toolCallId, args) => {
|
|
5550
5584
|
if (!ws.getConnectionStatus().authenticated) {
|
|
5551
5585
|
return text('Not connected to Stamn server. Run "stamn status" to check.');
|
|
5552
5586
|
}
|
|
5553
|
-
return originalExecute(args);
|
|
5587
|
+
return originalExecute(toolCallId, args);
|
|
5554
5588
|
}
|
|
5555
5589
|
};
|
|
5556
5590
|
}
|
|
5557
5591
|
function registerTools(api, wsService, config) {
|
|
5592
|
+
api.registerTool(ping());
|
|
5558
5593
|
for (const tool of allTools(wsService, config.agentId)) {
|
|
5559
5594
|
api.registerTool(withAuthGuard(tool, wsService));
|
|
5560
5595
|
}
|