@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
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { ROLES } from "../roles.js";
|
|
2
|
+
import { buildControllerCompletionRules, buildControllerDisciplineRules, buildControllerEvidenceMemoryRules, buildControllerIntakeRules, buildControllerStructuredContractRules, buildControllerToolRules, buildControllerWorkflowRules, composePrompt, } from "../prompt-policy.js";
|
|
3
|
+
import { hasOnDemandWorkerProvisioning, shouldBlockControllerWithoutWorkers } from "./controller-capacity.js";
|
|
4
|
+
import { resolveTeamClawWorkspaceDir } from "../openclaw-workspace.js";
|
|
5
|
+
import fs from "node:fs";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
const TEAMCLAW_ROLE_IDS_TEXT = [
|
|
8
|
+
"pm", "architect", "developer", "qa",
|
|
9
|
+
"release-engineer", "infra-engineer", "devops", "security-engineer",
|
|
10
|
+
"designer", "marketing", "data-engineer",
|
|
11
|
+
];
|
|
12
|
+
export function createControllerPromptInjector(deps) {
|
|
13
|
+
return () => {
|
|
14
|
+
const state = deps.getTeamState();
|
|
15
|
+
const workers = Object.values(state?.workers ?? {});
|
|
16
|
+
const tasks = Object.values(state?.tasks ?? {});
|
|
17
|
+
const pendingTasks = tasks.filter((t) => t.status === "pending");
|
|
18
|
+
const activeTasks = tasks.filter((t) => t.status === "in_progress" || t.status === "assigned");
|
|
19
|
+
const blockedTasks = tasks.filter((t) => t.status === "blocked");
|
|
20
|
+
const completedTasks = tasks.filter((t) => t.status === "completed");
|
|
21
|
+
const pendingClarifications = Object.values(state?.clarifications ?? {}).filter((c) => c.status === "pending");
|
|
22
|
+
const canProvisionWithoutWorkers = hasOnDemandWorkerProvisioning(deps.config);
|
|
23
|
+
const parts = [
|
|
24
|
+
"## TeamClaw Controller Mode",
|
|
25
|
+
"You are the Team Controller and the first-pass requirements analyst for the human.",
|
|
26
|
+
"Treat human input as raw requirements unless it is already explicitly phrased as an execution-ready TeamClaw task.",
|
|
27
|
+
...buildControllerToolRules(),
|
|
28
|
+
"",
|
|
29
|
+
"### Current Team Status",
|
|
30
|
+
];
|
|
31
|
+
if (!state) {
|
|
32
|
+
parts.push("- Team state is not loaded yet; treat this as a fresh controller intake and establish execution-ready tasks from the human requirement.");
|
|
33
|
+
}
|
|
34
|
+
else if (workers.length === 0) {
|
|
35
|
+
if (shouldBlockControllerWithoutWorkers(deps.config, state)) {
|
|
36
|
+
parts.push("- No workers are registered and on-demand provisioning is disabled.");
|
|
37
|
+
parts.push("- Blocking rule: you may analyze the requirement and identify the needed roles, but do not create TeamClaw tasks yet.");
|
|
38
|
+
parts.push("- Do not start doing the worker-role work yourself. Tell the human to bring workers online or enable process/docker/kubernetes provisioning first.");
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
parts.push("- No workers are registered yet, but on-demand provisioning is enabled.");
|
|
42
|
+
parts.push("- You may still create execution-ready TeamClaw tasks for the required roles; the controller will provision workers on demand.");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
for (const w of workers) {
|
|
47
|
+
const roleDef = ROLES.find((r) => r.id === w.role);
|
|
48
|
+
const statusIcon = w.status === "idle" ? "[idle]" : w.status === "busy" ? "[busy]" : "[offline]";
|
|
49
|
+
const currentTask = w.currentTaskId ? ` (task: ${w.currentTaskId})` : "";
|
|
50
|
+
parts.push(`- ${roleDef?.icon ?? ""} ${w.label} (${w.id}) ${statusIcon}${currentTask}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
parts.push("");
|
|
54
|
+
parts.push(`### Tasks Summary`);
|
|
55
|
+
parts.push(`- Pending: ${pendingTasks.length} | Active: ${activeTasks.length} | Blocked: ${blockedTasks.length} | Completed: ${completedTasks.length}`);
|
|
56
|
+
if (pendingClarifications.length > 0) {
|
|
57
|
+
parts.push("");
|
|
58
|
+
parts.push("Pending clarification requests:");
|
|
59
|
+
for (const clarification of pendingClarifications.slice(0, 10)) {
|
|
60
|
+
parts.push(`- Task ${clarification.taskId}: ${clarification.question}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (pendingTasks.length > 0) {
|
|
64
|
+
parts.push("");
|
|
65
|
+
parts.push("Pending tasks:");
|
|
66
|
+
for (const t of pendingTasks.slice(0, 10)) {
|
|
67
|
+
parts.push(`- [${t.priority}] ${t.title} (role: ${t.assignedRole ?? "any"})`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
parts.push("");
|
|
71
|
+
parts.push("### Available Roles");
|
|
72
|
+
for (const role of ROLES) {
|
|
73
|
+
const skillLine = role.recommendedSkills.length > 0
|
|
74
|
+
? ` Recommended skills: ${role.recommendedSkills.join(", ")}.`
|
|
75
|
+
: "";
|
|
76
|
+
parts.push(`- ${role.icon} ${role.label}: ${role.description}.${skillLine}`);
|
|
77
|
+
}
|
|
78
|
+
// List existing projects so the controller can distinguish new vs. existing
|
|
79
|
+
parts.push("");
|
|
80
|
+
parts.push("### Existing Projects in Workspace");
|
|
81
|
+
const existingProjects = listExistingProjects(state);
|
|
82
|
+
if (existingProjects.length === 0) {
|
|
83
|
+
parts.push("- No existing projects yet.");
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
for (const proj of existingProjects) {
|
|
87
|
+
parts.push(`- 📂 ${proj.dir}: ${proj.summary}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
parts.push("");
|
|
91
|
+
parts.push("## New vs. Existing Project Detection");
|
|
92
|
+
parts.push("- Before creating tasks, determine if the user's request relates to an existing project listed above.");
|
|
93
|
+
parts.push("- If the request mentions a technology, feature, or project name that matches an existing project, treat it as an enhancement/bugfix for that project — reuse the same projectDir.");
|
|
94
|
+
parts.push("- If the request is clearly a new, unrelated requirement, create a fresh projectDir with a new projectName.");
|
|
95
|
+
parts.push("- When enhancing an existing project, include context about what already exists so the worker can extend rather than rebuild.");
|
|
96
|
+
parts.push("- NEVER let a worker's deliverables reference files from a different project. Each task's deliverables must be scoped to its own projectDir.");
|
|
97
|
+
parts.push(...buildControllerWorkflowRules());
|
|
98
|
+
parts.push("");
|
|
99
|
+
parts.push("## Team Kickoff Meeting (Collaborative Planning)");
|
|
100
|
+
parts.push("- **IMPORTANT**: When the requirement involves 3 or more roles, you MUST call teamclaw_request_kickoff as your FIRST tool call, BEFORE creating any tasks.");
|
|
101
|
+
parts.push("- The kickoff provisions candidate role workers and asks each for a structured assessment from their professional perspective.");
|
|
102
|
+
parts.push("- Each role evaluates: whether they're needed, their scope of work, suggested tasks, dependencies on other roles, risks, and open questions.");
|
|
103
|
+
parts.push("- Use the team's assessments to make informed decisions about which roles to actually involve and how to structure the task pipeline.");
|
|
104
|
+
parts.push("- Roles that assessed themselves as not needed will be automatically reclaimed after their idle timeout.");
|
|
105
|
+
parts.push("- Adaptive kickoff rules:");
|
|
106
|
+
parts.push(" - **Simple** (single clear task, 1 role): Skip kickoff, create task directly.");
|
|
107
|
+
parts.push(" - **Medium** (2-3 roles likely): Call kickoff with the 2-3 most relevant roles.");
|
|
108
|
+
parts.push(" - **Complex** (4+ potential roles, multi-domain, unclear scope): ALWAYS call kickoff with all candidate roles. Do NOT skip.");
|
|
109
|
+
parts.push("- For task_follow_up runs (triggered by completed tasks), do NOT call kickoff again — the team plan was already established.");
|
|
110
|
+
parts.push("- Example: 'Build an e-commerce platform' → complex (architect+developer+designer+qa+security) → MUST call teamclaw_request_kickoff first");
|
|
111
|
+
parts.push("");
|
|
112
|
+
parts.push("## Out-of-Scope Requests");
|
|
113
|
+
parts.push("- TeamClaw is a software development team. You handle: coding, architecture, design, testing, deployment, documentation, security review, and related technical work.");
|
|
114
|
+
parts.push("- Do not infer that the user lacks rights to work on a codebase just because it contains binaries, bundles, minified code, generated artifacts, proprietary branding, or unusual repository structure. Unless the user explicitly states a restriction, keep the decision technical rather than ownership-based.");
|
|
115
|
+
parts.push("- If the human asks for something clearly non-technical (cooking, weather, personal advice, general knowledge, creative writing unrelated to software), politely decline in your reply text AND still call teamclaw_submit_manifest with createdTasks=[], requiredRoles=[], and requirementSummary explaining why you declined.");
|
|
116
|
+
parts.push("- If the request is borderline (e.g. 'write a blog post about our API'), lean toward accepting it and assigning to the appropriate role (marketing, pm).");
|
|
117
|
+
parts.push("- REMEMBER: You must ALWAYS call teamclaw_submit_manifest, even when declining. The system cannot record your decision without it.");
|
|
118
|
+
parts.push("");
|
|
119
|
+
parts.push("## Clarification & Follow-up Awareness");
|
|
120
|
+
parts.push("- If this session has prior messages where you asked clarification questions, the human's new message is likely a response to those questions.");
|
|
121
|
+
parts.push("- Do NOT treat a follow-up human message as a brand-new requirement if there are pending clarification questions in this session. Instead, interpret the message as an answer and proceed with task creation.");
|
|
122
|
+
parts.push("- If the human's follow-up is clearly irrelevant to the pending questions (e.g. random chitchat), acknowledge it briefly and re-state the pending questions so the human knows what you still need.");
|
|
123
|
+
parts.push("- For automatic task_follow_up runs (triggered by task completion), focus on advancing the pipeline — do not re-ask questions already answered.");
|
|
124
|
+
parts.push("");
|
|
125
|
+
parts.push("## Deliverable Presentation");
|
|
126
|
+
parts.push("- When a task completes with a result contract, review the deliverables and present a clear, actionable summary to the human.");
|
|
127
|
+
parts.push("- For web applications: include the preview URL if available (deliverable.liveUrl). The human should be able to click and verify.");
|
|
128
|
+
parts.push("- For CLI tools: include the command to run with example arguments.");
|
|
129
|
+
parts.push("- For documents: highlight the key decisions or structure.");
|
|
130
|
+
parts.push("- When ALL tasks for the requirement are complete (requirementFullyComplete=true), provide a final delivery summary:");
|
|
131
|
+
parts.push(" - What was built (1-2 sentence overview)");
|
|
132
|
+
parts.push(" - How to access/run it (URLs, commands)");
|
|
133
|
+
parts.push(" - File locations (project directory)");
|
|
134
|
+
parts.push(" - Any caveats or next steps");
|
|
135
|
+
parts.push(...buildControllerStructuredContractRules());
|
|
136
|
+
parts.push(...buildControllerEvidenceMemoryRules());
|
|
137
|
+
parts.push(...buildControllerIntakeRules());
|
|
138
|
+
parts.push(...buildControllerDisciplineRules({ canProvisionWithoutWorkers }));
|
|
139
|
+
parts.push(...buildControllerCompletionRules());
|
|
140
|
+
return {
|
|
141
|
+
prependSystemContext: composePrompt(parts),
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
function listExistingProjects(state) {
|
|
146
|
+
const projects = [];
|
|
147
|
+
const seenDirs = new Set();
|
|
148
|
+
if (state) {
|
|
149
|
+
for (const project of Object.values(state.projects ?? {})) {
|
|
150
|
+
if (project.projectDir && !seenDirs.has(project.projectDir)) {
|
|
151
|
+
seenDirs.add(project.projectDir);
|
|
152
|
+
const aliases = project.aliases.filter(Boolean);
|
|
153
|
+
const aliasSummary = aliases.length > 0 ? `aliases: ${aliases.join(", ")}` : "";
|
|
154
|
+
const summary = [project.summary, aliasSummary].filter(Boolean).join(" | ") || "(registered project)";
|
|
155
|
+
projects.push({ dir: project.projectDir, summary });
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
for (const task of Object.values(state.tasks)) {
|
|
159
|
+
if (task.projectDir && !seenDirs.has(task.projectDir)) {
|
|
160
|
+
seenDirs.add(task.projectDir);
|
|
161
|
+
const summary = task.resultContract?.summary ?? task.title;
|
|
162
|
+
projects.push({ dir: task.projectDir, summary });
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
// Also scan the filesystem for project directories not tracked in state
|
|
167
|
+
try {
|
|
168
|
+
const workspaceDir = resolveTeamClawWorkspaceDir();
|
|
169
|
+
const projectsRoot = path.join(workspaceDir, "projects");
|
|
170
|
+
if (fs.existsSync(projectsRoot)) {
|
|
171
|
+
const entries = fs.readdirSync(projectsRoot, { withFileTypes: true });
|
|
172
|
+
for (const entry of entries) {
|
|
173
|
+
if (entry.isDirectory() && !entry.name.startsWith(".")) {
|
|
174
|
+
const fullDir = `projects/${entry.name}`;
|
|
175
|
+
if (!seenDirs.has(entry.name) && !seenDirs.has(fullDir)) {
|
|
176
|
+
seenDirs.add(fullDir);
|
|
177
|
+
projects.push({ dir: fullDir, summary: "(discovered on filesystem)" });
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
catch {
|
|
184
|
+
// Workspace not available — skip filesystem scan
|
|
185
|
+
}
|
|
186
|
+
return projects.slice(0, 20);
|
|
187
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ROLES } from "../roles.js";
|
|
2
|
+
/**
|
|
3
|
+
* Infer the most appropriate role for a task based on text analysis.
|
|
4
|
+
*
|
|
5
|
+
* If `task.assignedRole` is already set, returns it directly.
|
|
6
|
+
* Otherwise, tokenizes the task title + description and scores each known
|
|
7
|
+
* role by overlap with its id, label, and capabilities.
|
|
8
|
+
*/
|
|
9
|
+
export function inferTaskRole(task) {
|
|
10
|
+
if (task.assignedRole) {
|
|
11
|
+
return task.assignedRole;
|
|
12
|
+
}
|
|
13
|
+
const text = `${task.title} ${task.description}`.toLowerCase();
|
|
14
|
+
let bestRole = null;
|
|
15
|
+
let bestScore = 0;
|
|
16
|
+
for (const role of ROLES) {
|
|
17
|
+
const roleTokens = [
|
|
18
|
+
role.id,
|
|
19
|
+
role.label,
|
|
20
|
+
...role.capabilities,
|
|
21
|
+
].flatMap((entry) => entry.toLowerCase().split(/[^a-z0-9]+/).filter((token) => token.length > 2));
|
|
22
|
+
const uniqueTokens = [...new Set(roleTokens)];
|
|
23
|
+
const score = uniqueTokens.reduce((count, token) => count + (text.includes(token) ? 1 : 0), 0);
|
|
24
|
+
if (score > bestScore) {
|
|
25
|
+
bestScore = score;
|
|
26
|
+
bestRole = role.id;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return bestScore > 0 ? bestRole : null;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Fallback role when inference produces no match.
|
|
33
|
+
* The developer role is the most versatile generalist.
|
|
34
|
+
*/
|
|
35
|
+
export const FALLBACK_ROLE = "developer";
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { getRole } from "../roles.js";
|
|
2
|
+
export class TaskRouter {
|
|
3
|
+
logger;
|
|
4
|
+
constructor(logger) {
|
|
5
|
+
this.logger = logger;
|
|
6
|
+
}
|
|
7
|
+
routeTask(task, workers) {
|
|
8
|
+
// First try exact role match with idle workers
|
|
9
|
+
if (task.assignedRole) {
|
|
10
|
+
const candidates = Object.values(workers).filter((w) => w.role === task.assignedRole && w.status === "idle");
|
|
11
|
+
if (candidates.length > 0) {
|
|
12
|
+
return candidates[0];
|
|
13
|
+
}
|
|
14
|
+
this.logger.info(`TaskRouter: no idle worker for explicitly assigned role ${task.assignedRole} on task ${task.id}; keeping task pending`);
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
// Try keyword matching on capabilities
|
|
18
|
+
const keywords = this.extractKeywords(task.description + " " + task.title);
|
|
19
|
+
const scored = Object.values(workers)
|
|
20
|
+
.filter((w) => w.status === "idle")
|
|
21
|
+
.map((w) => {
|
|
22
|
+
const roleDef = getRole(w.role);
|
|
23
|
+
const capabilities = roleDef?.capabilities ?? [];
|
|
24
|
+
const matchCount = keywords.filter((k) => capabilities.some((c) => c.includes(k) || k.includes(c))).length;
|
|
25
|
+
return { worker: w, score: matchCount };
|
|
26
|
+
})
|
|
27
|
+
.filter((s) => s.score > 0)
|
|
28
|
+
.sort((a, b) => b.score - a.score);
|
|
29
|
+
if (scored.length > 0) {
|
|
30
|
+
return scored[0].worker;
|
|
31
|
+
}
|
|
32
|
+
// Fallback: any idle worker
|
|
33
|
+
const anyIdle = Object.values(workers).find((w) => w.status === "idle");
|
|
34
|
+
if (anyIdle) {
|
|
35
|
+
return anyIdle;
|
|
36
|
+
}
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
autoAssignPendingTasks(tasks, workers) {
|
|
40
|
+
const pendingTasks = Object.values(tasks).filter((t) => t.status === "pending" || t.status === "assigned");
|
|
41
|
+
const assignments = [];
|
|
42
|
+
for (const task of pendingTasks) {
|
|
43
|
+
if (task.assignedWorkerId && workers[task.assignedWorkerId]) {
|
|
44
|
+
continue; // Already assigned to a valid worker
|
|
45
|
+
}
|
|
46
|
+
const worker = this.routeTask(task, workers);
|
|
47
|
+
if (worker) {
|
|
48
|
+
assignments.push({ task, worker });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return assignments;
|
|
52
|
+
}
|
|
53
|
+
extractKeywords(text) {
|
|
54
|
+
const common = new Set([
|
|
55
|
+
"the", "a", "an", "and", "or", "but", "in", "on", "at", "to", "for",
|
|
56
|
+
"of", "with", "by", "is", "are", "was", "were", "be", "been", "being",
|
|
57
|
+
"have", "has", "had", "do", "does", "did", "will", "would", "could",
|
|
58
|
+
"should", "may", "might", "must", "shall", "can", "this", "that",
|
|
59
|
+
"these", "those", "it", "its", "we", "our", "you", "your", "they",
|
|
60
|
+
"their", "create", "implement", "build", "make", "add", "update", "fix",
|
|
61
|
+
]);
|
|
62
|
+
return text
|
|
63
|
+
.toLowerCase()
|
|
64
|
+
.split(/[^a-z0-9]+/)
|
|
65
|
+
.filter((w) => w.length > 2 && !common.has(w));
|
|
66
|
+
}
|
|
67
|
+
}
|