squad-openclaw 2026.2.2002 → 2026.2.2003
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 +109 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,3 +1,107 @@
|
|
|
1
|
+
// src/agents.ts
|
|
2
|
+
import { execSync } from "child_process";
|
|
3
|
+
function registerAgentMethods(api) {
|
|
4
|
+
api.registerGatewayMethod(
|
|
5
|
+
"squad.agents.add",
|
|
6
|
+
async ({ params, respond }) => {
|
|
7
|
+
const name = params?.name;
|
|
8
|
+
const model = params?.model;
|
|
9
|
+
if (!name || typeof name !== "string" || !name.trim()) {
|
|
10
|
+
respond(false, { error: "Missing or empty 'name' parameter" });
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const safeName = name.trim();
|
|
14
|
+
if (!/^[a-zA-Z0-9][a-zA-Z0-9 _-]*$/.test(safeName)) {
|
|
15
|
+
respond(false, { error: "Agent name must start with a letter/number and contain only letters, numbers, spaces, hyphens, or underscores" });
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
let cmd = `openclaw agents add ${JSON.stringify(safeName)} --non-interactive`;
|
|
20
|
+
if (model) {
|
|
21
|
+
cmd += ` --model ${JSON.stringify(model)}`;
|
|
22
|
+
}
|
|
23
|
+
const output = execSync(cmd, {
|
|
24
|
+
timeout: 3e4,
|
|
25
|
+
encoding: "utf-8",
|
|
26
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
27
|
+
});
|
|
28
|
+
respond(true, { ok: true, output: output.slice(0, 1e3) });
|
|
29
|
+
} catch (err2) {
|
|
30
|
+
const msg = err2 instanceof Error ? err2.message : String(err2);
|
|
31
|
+
const stderr = err2?.stderr;
|
|
32
|
+
respond(false, {
|
|
33
|
+
error: `Failed to add agent: ${stderr || msg}`.slice(0, 500)
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
api.registerGatewayMethod(
|
|
39
|
+
"squad.agents.delete",
|
|
40
|
+
async ({ params, respond }) => {
|
|
41
|
+
const agentId = params?.agentId;
|
|
42
|
+
if (!agentId || typeof agentId !== "string" || !agentId.trim()) {
|
|
43
|
+
respond(false, { error: "Missing or empty 'agentId' parameter" });
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (agentId === "main") {
|
|
47
|
+
respond(false, { error: "Cannot delete the main agent" });
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (!/^[a-z0-9][a-z0-9-]*$/.test(agentId)) {
|
|
51
|
+
respond(false, { error: "Invalid agent ID format" });
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
const output = execSync(
|
|
56
|
+
`openclaw agents delete ${JSON.stringify(agentId)} --non-interactive 2>&1`,
|
|
57
|
+
{ timeout: 3e4, encoding: "utf-8" }
|
|
58
|
+
);
|
|
59
|
+
respond(true, { ok: true, output: output.slice(0, 1e3) });
|
|
60
|
+
} catch (err2) {
|
|
61
|
+
const msg = err2 instanceof Error ? err2.message : String(err2);
|
|
62
|
+
const stderr = err2?.stderr;
|
|
63
|
+
respond(false, {
|
|
64
|
+
error: `Failed to delete agent: ${stderr || msg}`.slice(0, 500)
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
api.registerGatewayMethod(
|
|
70
|
+
"squad.agents.set-identity",
|
|
71
|
+
async ({ params, respond }) => {
|
|
72
|
+
const agentId = params?.agentId;
|
|
73
|
+
const name = params?.name;
|
|
74
|
+
const emoji = params?.emoji;
|
|
75
|
+
const theme = params?.theme;
|
|
76
|
+
if (!agentId || typeof agentId !== "string") {
|
|
77
|
+
respond(false, { error: "Missing 'agentId' parameter" });
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const args = [`--agent`, JSON.stringify(agentId)];
|
|
81
|
+
if (name) args.push(`--name`, JSON.stringify(name));
|
|
82
|
+
if (emoji) args.push(`--emoji`, JSON.stringify(emoji));
|
|
83
|
+
if (theme) args.push(`--theme`, JSON.stringify(theme));
|
|
84
|
+
if (args.length <= 2) {
|
|
85
|
+
respond(false, { error: "No identity fields provided (name, emoji, or theme)" });
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
const output = execSync(
|
|
90
|
+
`openclaw agents set-identity ${args.join(" ")} 2>&1`,
|
|
91
|
+
{ timeout: 15e3, encoding: "utf-8" }
|
|
92
|
+
);
|
|
93
|
+
respond(true, { ok: true, output: output.slice(0, 1e3) });
|
|
94
|
+
} catch (err2) {
|
|
95
|
+
const msg = err2 instanceof Error ? err2.message : String(err2);
|
|
96
|
+
const stderr = err2?.stderr;
|
|
97
|
+
respond(false, {
|
|
98
|
+
error: `Failed to set identity: ${stderr || msg}`.slice(0, 500)
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
1
105
|
// src/entities.ts
|
|
2
106
|
import { Type as T } from "@sinclair/typebox";
|
|
3
107
|
import path3 from "path";
|
|
@@ -1111,7 +1215,7 @@ function registerSqlTools(api) {
|
|
|
1111
1215
|
}
|
|
1112
1216
|
|
|
1113
1217
|
// src/version.ts
|
|
1114
|
-
import { execSync } from "child_process";
|
|
1218
|
+
import { execSync as execSync2 } from "child_process";
|
|
1115
1219
|
import fs5 from "fs";
|
|
1116
1220
|
import path5 from "path";
|
|
1117
1221
|
import { fileURLToPath } from "url";
|
|
@@ -1176,13 +1280,13 @@ function registerVersionMethods(api) {
|
|
|
1176
1280
|
const before = getCurrentVersion();
|
|
1177
1281
|
let updateOutput = "";
|
|
1178
1282
|
try {
|
|
1179
|
-
updateOutput =
|
|
1283
|
+
updateOutput = execSync2(
|
|
1180
1284
|
`openclaw plugins update ${PACKAGE_NAME} 2>&1`,
|
|
1181
1285
|
{ timeout: 12e4, encoding: "utf-8" }
|
|
1182
1286
|
);
|
|
1183
1287
|
} catch {
|
|
1184
1288
|
try {
|
|
1185
|
-
updateOutput =
|
|
1289
|
+
updateOutput = execSync2(
|
|
1186
1290
|
`npm install -g ${PACKAGE_NAME}@latest 2>&1`,
|
|
1187
1291
|
{ timeout: 12e4, encoding: "utf-8" }
|
|
1188
1292
|
);
|
|
@@ -1208,7 +1312,7 @@ function registerVersionMethods(api) {
|
|
|
1208
1312
|
);
|
|
1209
1313
|
setTimeout(() => {
|
|
1210
1314
|
try {
|
|
1211
|
-
|
|
1315
|
+
execSync2("openclaw gateway restart 2>&1", {
|
|
1212
1316
|
timeout: 3e4,
|
|
1213
1317
|
encoding: "utf-8"
|
|
1214
1318
|
});
|
|
@@ -1895,6 +1999,7 @@ function squadAppPlugin(api) {
|
|
|
1895
1999
|
registerFilesystemTools(api);
|
|
1896
2000
|
registerSqlTools(api);
|
|
1897
2001
|
registerVersionMethods(api);
|
|
2002
|
+
registerAgentMethods(api);
|
|
1898
2003
|
api.registerGatewayMethod(
|
|
1899
2004
|
"tools.invoke",
|
|
1900
2005
|
async ({ params, respond }) => {
|
package/package.json
CHANGED