@teamclaws/teamclaw 2026.8.0 → 2026.8.1
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/api.js +1 -0
- package/dist/index.js +325 -0
- package/dist/src/config.js +381 -0
- package/dist/src/controller/controller-capacity.js +14 -0
- package/dist/src/controller/controller-service.js +393 -0
- package/dist/src/controller/controller-tools.js +582 -0
- package/dist/src/controller/delivery-report.js +458 -0
- package/dist/src/controller/github-auth.js +564 -0
- package/dist/src/controller/http-server.js +6032 -0
- package/dist/src/controller/kickoff-orchestrator.js +220 -0
- package/dist/src/controller/managed-gateway-process.js +286 -0
- package/dist/src/controller/message-router.js +38 -0
- package/dist/src/controller/orchestration-manifest.js +173 -0
- package/dist/src/controller/preview-manager.js +586 -0
- package/dist/src/controller/prompt-injector.js +187 -0
- package/dist/src/controller/role-inference.js +35 -0
- package/dist/src/controller/task-router.js +67 -0
- package/dist/src/controller/tunnel-manager.js +548 -0
- package/dist/src/controller/websocket.js +42 -0
- package/dist/src/controller/worker-provisioning.js +1648 -0
- package/dist/src/discovery.js +86 -0
- package/dist/src/git-collaboration.js +694 -0
- package/dist/src/identity.js +131 -0
- package/dist/src/install-defaults.js +1 -0
- package/dist/src/interaction-contracts.js +531 -0
- package/dist/src/networking.js +91 -0
- package/dist/src/openclaw-workspace.js +903 -0
- package/dist/src/prompt-policy.js +373 -0
- package/dist/src/protocol.js +58 -0
- package/dist/src/roles.js +349 -0
- package/dist/src/state.js +183 -0
- package/dist/src/task-executor.js +1033 -0
- package/dist/src/teamauto/github-client.js +192 -0
- package/dist/src/teamauto/norms.js +85 -0
- package/dist/src/teamauto/repo-sync.js +201 -0
- package/dist/src/teamauto/scanner.js +179 -0
- package/dist/src/teamauto/schedule.js +123 -0
- package/dist/src/teamauto/scheduler.js +688 -0
- package/dist/src/teamauto/store.js +133 -0
- package/dist/src/types.js +243 -0
- package/dist/src/ui/app.js +4292 -0
- package/dist/src/ui/assets/teamclaw-app-icon.png +0 -0
- package/dist/src/ui/github-login.html +296 -0
- package/dist/src/ui/index.html +414 -0
- package/dist/src/ui/style.css +2611 -0
- package/dist/src/worker/http-handler.js +146 -0
- package/dist/src/worker/message-queue.js +24 -0
- package/dist/src/worker/prompt-injector.js +42 -0
- package/dist/src/worker/skill-installer.js +253 -0
- package/dist/src/worker/tools.js +541 -0
- package/dist/src/worker/worker-service.js +234 -0
- package/dist/src/workspace-browser.js +269 -0
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/dist/api.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { definePluginEntry, emptyPluginConfigSchema } from "openclaw/plugin-sdk/plugin-entry";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { definePluginEntry } from "./api.js";
|
|
4
|
+
import { parsePluginConfig } from "./src/types.js";
|
|
5
|
+
import { buildConfigSchema } from "./src/config.js";
|
|
6
|
+
import { loadTeamState } from "./src/state.js";
|
|
7
|
+
import { createRoleTaskExecutor } from "./src/task-executor.js";
|
|
8
|
+
import { createWorkerService } from "./src/worker/worker-service.js";
|
|
9
|
+
import { createWorkerPromptInjector } from "./src/worker/prompt-injector.js";
|
|
10
|
+
import { createWorkerTools } from "./src/worker/tools.js";
|
|
11
|
+
import { MessageQueue } from "./src/worker/message-queue.js";
|
|
12
|
+
import { createControllerService } from "./src/controller/controller-service.js";
|
|
13
|
+
import { createControllerPromptInjector } from "./src/controller/prompt-injector.js";
|
|
14
|
+
import { createControllerTools } from "./src/controller/controller-tools.js";
|
|
15
|
+
import { publishWorkerRepo, syncWorkerRepo } from "./src/git-collaboration.js";
|
|
16
|
+
import { resolveTeamClawProjectsDir } from "./src/openclaw-workspace.js";
|
|
17
|
+
import { installRecommendedSkills } from "./src/worker/skill-installer.js";
|
|
18
|
+
export default definePluginEntry({
|
|
19
|
+
id: "teamclaw",
|
|
20
|
+
name: "TeamClaw",
|
|
21
|
+
description: "Virtual team collaboration - multiple OpenClaw instances form a virtual software company with role-based task routing.",
|
|
22
|
+
configSchema: buildConfigSchema,
|
|
23
|
+
register(api) {
|
|
24
|
+
const config = parsePluginConfig(api.pluginConfig);
|
|
25
|
+
if (config.mode === "controller") {
|
|
26
|
+
registerController(api, config);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
registerWorker(api, config);
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
function registerController(api, config) {
|
|
34
|
+
const logger = api.logger;
|
|
35
|
+
let getControllerTeamState = () => null;
|
|
36
|
+
let controllerUrl = `http://127.0.0.1:${config.port}`;
|
|
37
|
+
let kickoffHandler;
|
|
38
|
+
let getTeamAutoScheduler = () => null;
|
|
39
|
+
// Service (starts HTTP server + mDNS + WebSocket)
|
|
40
|
+
api.registerService(createControllerService({
|
|
41
|
+
config,
|
|
42
|
+
logger,
|
|
43
|
+
runtime: api.runtime,
|
|
44
|
+
onTeamStateAvailable: (getter) => {
|
|
45
|
+
getControllerTeamState = getter;
|
|
46
|
+
},
|
|
47
|
+
onActualPort: (port) => {
|
|
48
|
+
controllerUrl = `http://127.0.0.1:${port}`;
|
|
49
|
+
},
|
|
50
|
+
onKickoffHandlerAvailable: (handler) => {
|
|
51
|
+
kickoffHandler = handler;
|
|
52
|
+
logger.info("TeamClaw: kickoff handler registered successfully");
|
|
53
|
+
},
|
|
54
|
+
onTeamAutoSchedulerAvailable: (getter) => {
|
|
55
|
+
getTeamAutoScheduler = getter;
|
|
56
|
+
},
|
|
57
|
+
}));
|
|
58
|
+
// Prompt injection
|
|
59
|
+
api.on("before_prompt_build", async (_event, ctx) => {
|
|
60
|
+
const state = getControllerTeamState() ?? await loadTeamState(config.teamName);
|
|
61
|
+
const injector = createControllerPromptInjector({
|
|
62
|
+
config,
|
|
63
|
+
getTeamState: () => state,
|
|
64
|
+
});
|
|
65
|
+
return injector() ?? {};
|
|
66
|
+
});
|
|
67
|
+
// Tools - register all controller tools via factory returning an array
|
|
68
|
+
api.registerTool((ctx) => {
|
|
69
|
+
return createControllerTools({
|
|
70
|
+
config,
|
|
71
|
+
controllerUrl,
|
|
72
|
+
getTeamState: getControllerTeamState,
|
|
73
|
+
sessionKey: ctx.sessionKey ?? null,
|
|
74
|
+
getKickoffHandler: () => kickoffHandler,
|
|
75
|
+
getTeamAutoScheduler: () => getTeamAutoScheduler(),
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function registerWorker(api, config) {
|
|
80
|
+
const logger = api.logger;
|
|
81
|
+
const messageQueue = new MessageQueue();
|
|
82
|
+
let currentControllerUrl = null;
|
|
83
|
+
let currentWorkerId = null;
|
|
84
|
+
function getIdentity() {
|
|
85
|
+
if (!currentWorkerId || !currentControllerUrl)
|
|
86
|
+
return null;
|
|
87
|
+
return {
|
|
88
|
+
workerId: currentWorkerId,
|
|
89
|
+
role: config.role,
|
|
90
|
+
controllerUrl: currentControllerUrl,
|
|
91
|
+
registeredAt: Date.now(),
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
async function reportExecutionEvent(taskId, event) {
|
|
95
|
+
if (!currentControllerUrl) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
try {
|
|
99
|
+
const res = await fetch(`${currentControllerUrl}/api/v1/tasks/${taskId}/execution`, {
|
|
100
|
+
method: "POST",
|
|
101
|
+
headers: { "Content-Type": "application/json" },
|
|
102
|
+
body: JSON.stringify({
|
|
103
|
+
...event,
|
|
104
|
+
workerId: currentWorkerId ?? undefined,
|
|
105
|
+
role: config.role,
|
|
106
|
+
}),
|
|
107
|
+
});
|
|
108
|
+
if (!res.ok) {
|
|
109
|
+
logger.warn(`Worker: failed to record execution event for ${taskId} (${res.status})`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
catch (err) {
|
|
113
|
+
logger.warn(`Worker: failed to POST execution event for ${taskId}: ${String(err)}`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
async function reportCheckpoint(taskId, checkpoint) {
|
|
117
|
+
if (!currentControllerUrl) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
try {
|
|
121
|
+
await fetch(`${currentControllerUrl}/api/v1/tasks/${taskId}/checkpoint`, {
|
|
122
|
+
method: "POST",
|
|
123
|
+
headers: { "Content-Type": "application/json" },
|
|
124
|
+
body: JSON.stringify({ ...checkpoint, workerId: currentWorkerId ?? undefined }),
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
// Checkpointing is best-effort; a lost heartbeat only costs resume freshness.
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const getWorkerSessionKey = (assignment) => assignment.executionSessionKey?.trim() || `teamclaw-task-${assignment.taskId}`;
|
|
132
|
+
const taskExecutor = createRoleTaskExecutor({
|
|
133
|
+
runtime: api.runtime,
|
|
134
|
+
logger,
|
|
135
|
+
role: config.role,
|
|
136
|
+
taskTimeoutMs: config.taskTimeoutMs,
|
|
137
|
+
config,
|
|
138
|
+
getSessionKey: getWorkerSessionKey,
|
|
139
|
+
getIdempotencyKey: (assignment) => assignment.executionIdempotencyKey?.trim() || `teamclaw-${assignment.taskId}`,
|
|
140
|
+
reportExecutionEvent,
|
|
141
|
+
reportCheckpoint,
|
|
142
|
+
});
|
|
143
|
+
function resolveProjectSyncPaths(projectDir) {
|
|
144
|
+
const normalizedProjectDir = projectDir?.trim();
|
|
145
|
+
const sharedWorkspaceOverride = process.env.TEAMCLAW_WORKSPACE_DIR?.trim();
|
|
146
|
+
if (!normalizedProjectDir || !sharedWorkspaceOverride) {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
const sharedProjectDir = path.join(resolveTeamClawProjectsDir(), normalizedProjectDir);
|
|
150
|
+
const localEnv = { ...process.env };
|
|
151
|
+
delete localEnv.TEAMCLAW_WORKSPACE_DIR;
|
|
152
|
+
const localProjectDir = path.join(resolveTeamClawProjectsDir(localEnv), normalizedProjectDir);
|
|
153
|
+
if (sharedProjectDir === localProjectDir) {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
return { sharedProjectDir, localProjectDir };
|
|
157
|
+
}
|
|
158
|
+
async function pathExists(targetPath) {
|
|
159
|
+
try {
|
|
160
|
+
await fs.access(targetPath);
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
catch {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
async function syncProjectDir(sourceDir, destinationDir) {
|
|
168
|
+
if (!await pathExists(sourceDir)) {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
await fs.mkdir(path.dirname(destinationDir), { recursive: true });
|
|
172
|
+
await fs.cp(sourceDir, destinationDir, { recursive: true, force: true });
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
// Service
|
|
176
|
+
api.registerService(createWorkerService({
|
|
177
|
+
config,
|
|
178
|
+
logger,
|
|
179
|
+
onIdentityEstablished: (identity) => {
|
|
180
|
+
currentControllerUrl = identity.controllerUrl;
|
|
181
|
+
currentWorkerId = identity.workerId;
|
|
182
|
+
},
|
|
183
|
+
prepareTaskAssignment: async (assignment) => {
|
|
184
|
+
const controllerUrl = currentControllerUrl || config.controllerUrl.trim();
|
|
185
|
+
if (assignment.recommendedSkills?.length) {
|
|
186
|
+
try {
|
|
187
|
+
const skillInstall = await installRecommendedSkills(assignment, logger);
|
|
188
|
+
for (const event of skillInstall.events) {
|
|
189
|
+
await reportExecutionEvent(assignment.taskId, event);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
catch (err) {
|
|
193
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
194
|
+
await reportExecutionEvent(assignment.taskId, {
|
|
195
|
+
type: "error",
|
|
196
|
+
phase: "skills_preflight_failed",
|
|
197
|
+
source: "worker",
|
|
198
|
+
status: "running",
|
|
199
|
+
message,
|
|
200
|
+
});
|
|
201
|
+
logger.warn(`Worker: skill preflight failed for ${assignment.taskId}: ${message}`);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
const syncPaths = resolveProjectSyncPaths(assignment.projectDir);
|
|
205
|
+
if (syncPaths) {
|
|
206
|
+
const restored = await syncProjectDir(syncPaths.sharedProjectDir, syncPaths.localProjectDir);
|
|
207
|
+
if (restored) {
|
|
208
|
+
await reportExecutionEvent(assignment.taskId, {
|
|
209
|
+
type: "lifecycle",
|
|
210
|
+
phase: "project_sync_restored",
|
|
211
|
+
source: "worker",
|
|
212
|
+
status: "running",
|
|
213
|
+
message: `Restored shared project files into the worker runtime from ${syncPaths.sharedProjectDir}.`,
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
if (!assignment.repo?.enabled || !controllerUrl) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
await reportExecutionEvent(assignment.taskId, {
|
|
221
|
+
type: "lifecycle",
|
|
222
|
+
phase: "repo_sync_started",
|
|
223
|
+
source: "worker",
|
|
224
|
+
status: "running",
|
|
225
|
+
message: `Preparing ${assignment.repo.mode} git workspace sync before task execution.`,
|
|
226
|
+
});
|
|
227
|
+
try {
|
|
228
|
+
const syncResult = await syncWorkerRepo(config, logger, controllerUrl, assignment.repo);
|
|
229
|
+
await reportExecutionEvent(assignment.taskId, {
|
|
230
|
+
type: "lifecycle",
|
|
231
|
+
phase: "repo_sync_completed",
|
|
232
|
+
source: "worker",
|
|
233
|
+
status: "running",
|
|
234
|
+
message: syncResult.message,
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
catch (err) {
|
|
238
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
239
|
+
await reportExecutionEvent(assignment.taskId, {
|
|
240
|
+
type: "error",
|
|
241
|
+
phase: "repo_sync_failed",
|
|
242
|
+
source: "worker",
|
|
243
|
+
status: "running",
|
|
244
|
+
message,
|
|
245
|
+
});
|
|
246
|
+
throw err;
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
publishTaskAssignment: async (assignment) => {
|
|
250
|
+
const syncPaths = resolveProjectSyncPaths(assignment.projectDir);
|
|
251
|
+
if (syncPaths) {
|
|
252
|
+
const published = await syncProjectDir(syncPaths.localProjectDir, syncPaths.sharedProjectDir);
|
|
253
|
+
if (published) {
|
|
254
|
+
await reportExecutionEvent(assignment.taskId, {
|
|
255
|
+
type: "lifecycle",
|
|
256
|
+
phase: "project_sync_published",
|
|
257
|
+
source: "worker",
|
|
258
|
+
status: "running",
|
|
259
|
+
message: `Published worker runtime project files back to the shared workspace at ${syncPaths.sharedProjectDir}.`,
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
const controllerUrl = currentControllerUrl || config.controllerUrl.trim();
|
|
264
|
+
if (!assignment.repo?.enabled || !controllerUrl) {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
const workerId = currentWorkerId || "unknown-worker";
|
|
268
|
+
await reportExecutionEvent(assignment.taskId, {
|
|
269
|
+
type: "lifecycle",
|
|
270
|
+
phase: "repo_publish_started",
|
|
271
|
+
source: "worker",
|
|
272
|
+
status: "running",
|
|
273
|
+
message: `Publishing task changes through ${assignment.repo.mode} git collaboration.`,
|
|
274
|
+
});
|
|
275
|
+
try {
|
|
276
|
+
const publishResult = await publishWorkerRepo(config, logger, controllerUrl, assignment.repo, {
|
|
277
|
+
taskId: assignment.taskId,
|
|
278
|
+
workerId,
|
|
279
|
+
role: config.role,
|
|
280
|
+
});
|
|
281
|
+
await reportExecutionEvent(assignment.taskId, {
|
|
282
|
+
type: "lifecycle",
|
|
283
|
+
phase: publishResult.published ? "repo_publish_completed" : "repo_publish_skipped",
|
|
284
|
+
source: "worker",
|
|
285
|
+
status: "running",
|
|
286
|
+
message: publishResult.message,
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
catch (err) {
|
|
290
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
291
|
+
await reportExecutionEvent(assignment.taskId, {
|
|
292
|
+
type: "error",
|
|
293
|
+
phase: "repo_publish_failed",
|
|
294
|
+
source: "worker",
|
|
295
|
+
status: "running",
|
|
296
|
+
message,
|
|
297
|
+
});
|
|
298
|
+
throw err;
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
taskExecutor,
|
|
302
|
+
cancelTaskExecution: async (taskId, sessionKey) => {
|
|
303
|
+
const resolvedSessionKey = sessionKey || `teamclaw-task-${taskId}`;
|
|
304
|
+
try {
|
|
305
|
+
await api.runtime.subagent.deleteSession({ sessionKey: resolvedSessionKey });
|
|
306
|
+
logger.info(`Worker: cancelled subagent session ${resolvedSessionKey} for task ${taskId}`);
|
|
307
|
+
return true;
|
|
308
|
+
}
|
|
309
|
+
catch (err) {
|
|
310
|
+
logger.warn(`Worker: failed to cancel session ${resolvedSessionKey} for task ${taskId}: ${String(err)}`);
|
|
311
|
+
return false;
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
messageQueue,
|
|
315
|
+
}));
|
|
316
|
+
// Prompt injection
|
|
317
|
+
api.on("before_prompt_build", async () => {
|
|
318
|
+
const injector = createWorkerPromptInjector(config, getIdentity, messageQueue);
|
|
319
|
+
return injector() ?? {};
|
|
320
|
+
});
|
|
321
|
+
// Tools - register all worker tools via factory returning an array
|
|
322
|
+
api.registerTool(() => {
|
|
323
|
+
return createWorkerTools({ config, getIdentity });
|
|
324
|
+
});
|
|
325
|
+
}
|