@teamclaws/teamclaw 2026.7.1 → 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/README.md +8 -0
- 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 +9 -7
- package/src/controller/http-server.ts +26 -1
- package/src/controller/tunnel-manager.ts +139 -15
- package/src/ui/app.js +97 -20
- package/src/ui/index.html +16 -4
- package/src/ui/style.css +49 -0
|
@@ -0,0 +1,541 @@
|
|
|
1
|
+
import { Type } from "@sinclair/typebox";
|
|
2
|
+
import { backfillWorkerProgressContract, ensureTeamMessageContract, normalizeContractRole, normalizeContractStringList, normalizeTaskHandoffContract, normalizeWorkerProgressContract, normalizeWorkerTaskResultContract, renderWorkerProgressText, } from "../interaction-contracts.js";
|
|
3
|
+
import { loadWorkerIdentity } from "../state.js";
|
|
4
|
+
import { normalizeClarificationQuestionSchema } from "../controller/orchestration-manifest.js";
|
|
5
|
+
const ALLOWED_PROGRESS_STATUSES = new Set(["in_progress", "review"]);
|
|
6
|
+
function normalizeProgressText(params) {
|
|
7
|
+
if (typeof params.progress === "string" && params.progress.trim()) {
|
|
8
|
+
return params.progress.trim();
|
|
9
|
+
}
|
|
10
|
+
if (typeof params.summary === "string" && params.summary.trim()) {
|
|
11
|
+
return params.summary.trim();
|
|
12
|
+
}
|
|
13
|
+
if (typeof params.currentStep === "string" && params.currentStep.trim()) {
|
|
14
|
+
return params.currentStep.trim();
|
|
15
|
+
}
|
|
16
|
+
if (typeof params.message === "string" && params.message.trim()) {
|
|
17
|
+
return params.message.trim();
|
|
18
|
+
}
|
|
19
|
+
return "";
|
|
20
|
+
}
|
|
21
|
+
export function createWorkerTools(deps) {
|
|
22
|
+
const { config, getIdentity } = deps;
|
|
23
|
+
async function resolveIdentity() {
|
|
24
|
+
return getIdentity() ?? await loadWorkerIdentity();
|
|
25
|
+
}
|
|
26
|
+
return [
|
|
27
|
+
{
|
|
28
|
+
name: "teamclaw_ask_peer",
|
|
29
|
+
label: "Ask Team Peer",
|
|
30
|
+
description: "Send a question to another team member by role",
|
|
31
|
+
parameters: Type.Object({
|
|
32
|
+
targetRole: Type.String({ description: "Exact target role ID (pm, architect, developer, qa, release-engineer, infra-engineer, devops, security-engineer, designer, marketing, data-engineer)" }),
|
|
33
|
+
question: Type.String({ description: "The question to ask" }),
|
|
34
|
+
taskId: Type.Optional(Type.String({ description: "Related task ID if any" })),
|
|
35
|
+
summary: Type.Optional(Type.String({ description: "Short structured summary for this question" })),
|
|
36
|
+
details: Type.Optional(Type.String({ description: "Optional extra context for the peer" })),
|
|
37
|
+
requestedAction: Type.Optional(Type.String({ description: "Concrete response/action needed from the peer" })),
|
|
38
|
+
references: Type.Optional(Type.Array(Type.String({ description: "Relevant task IDs, file paths, or artifact references" }))),
|
|
39
|
+
}),
|
|
40
|
+
async execute(_id, params) {
|
|
41
|
+
const identity = await resolveIdentity();
|
|
42
|
+
if (!identity) {
|
|
43
|
+
return { details: {}, content: [{ type: "text", text: "Not registered with a team. Cannot send messages." }] };
|
|
44
|
+
}
|
|
45
|
+
const targetRole = String(params.targetRole ?? "");
|
|
46
|
+
const question = String(params.question ?? "");
|
|
47
|
+
const normalizedTargetRole = normalizeContractRole(targetRole);
|
|
48
|
+
if (!targetRole || !question) {
|
|
49
|
+
return { details: {}, content: [{ type: "text", text: "targetRole and question are required." }] };
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
const contract = ensureTeamMessageContract(null, {
|
|
53
|
+
type: "direct",
|
|
54
|
+
content: question,
|
|
55
|
+
toRole: normalizedTargetRole,
|
|
56
|
+
taskId: typeof params.taskId === "string" ? params.taskId : undefined,
|
|
57
|
+
summary: typeof params.summary === "string" ? params.summary : undefined,
|
|
58
|
+
details: typeof params.details === "string" ? params.details : undefined,
|
|
59
|
+
requestedAction: typeof params.requestedAction === "string" ? params.requestedAction : undefined,
|
|
60
|
+
references: normalizeContractStringList(params.references),
|
|
61
|
+
intent: "question",
|
|
62
|
+
needsResponse: true,
|
|
63
|
+
});
|
|
64
|
+
const res = await fetch(`${identity.controllerUrl}/api/v1/messages/direct`, {
|
|
65
|
+
method: "POST",
|
|
66
|
+
headers: { "Content-Type": "application/json" },
|
|
67
|
+
body: JSON.stringify({
|
|
68
|
+
from: identity.workerId,
|
|
69
|
+
fromRole: identity.role,
|
|
70
|
+
toRole: targetRole,
|
|
71
|
+
content: question,
|
|
72
|
+
taskId: params.taskId ?? null,
|
|
73
|
+
contract,
|
|
74
|
+
}),
|
|
75
|
+
});
|
|
76
|
+
if (!res.ok) {
|
|
77
|
+
return { details: {}, content: [{ type: "text", text: `Failed to send message: ${res.status}` }] };
|
|
78
|
+
}
|
|
79
|
+
return { details: {}, content: [{ type: "text", text: `Message sent to ${targetRole}.` }] };
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
return { details: {}, content: [{ type: "text", text: `Error: ${err instanceof Error ? err.message : String(err)}` }] };
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: "teamclaw_broadcast",
|
|
88
|
+
label: "Broadcast to Team",
|
|
89
|
+
description: "Send a message to all team members",
|
|
90
|
+
parameters: Type.Object({
|
|
91
|
+
message: Type.String({ description: "The message to broadcast" }),
|
|
92
|
+
taskId: Type.Optional(Type.String({ description: "Related task ID if any" })),
|
|
93
|
+
summary: Type.Optional(Type.String({ description: "Short structured summary for the broadcast" })),
|
|
94
|
+
details: Type.Optional(Type.String({ description: "Optional extra context for the team" })),
|
|
95
|
+
requestedAction: Type.Optional(Type.String({ description: "Optional action the team should take after reading this message" })),
|
|
96
|
+
needsResponse: Type.Optional(Type.Boolean({ description: "Whether the broadcast expects a response from recipients" })),
|
|
97
|
+
references: Type.Optional(Type.Array(Type.String({ description: "Relevant task IDs, file paths, or artifact references" }))),
|
|
98
|
+
}),
|
|
99
|
+
async execute(_id, params) {
|
|
100
|
+
const identity = await resolveIdentity();
|
|
101
|
+
if (!identity) {
|
|
102
|
+
return { details: {}, content: [{ type: "text", text: "Not registered with a team." }] };
|
|
103
|
+
}
|
|
104
|
+
const message = String(params.message ?? "");
|
|
105
|
+
if (!message) {
|
|
106
|
+
return { details: {}, content: [{ type: "text", text: "message is required." }] };
|
|
107
|
+
}
|
|
108
|
+
try {
|
|
109
|
+
const contract = ensureTeamMessageContract(null, {
|
|
110
|
+
type: "broadcast",
|
|
111
|
+
content: message,
|
|
112
|
+
taskId: typeof params.taskId === "string" ? params.taskId : undefined,
|
|
113
|
+
summary: typeof params.summary === "string" ? params.summary : undefined,
|
|
114
|
+
details: typeof params.details === "string" ? params.details : undefined,
|
|
115
|
+
requestedAction: typeof params.requestedAction === "string" ? params.requestedAction : undefined,
|
|
116
|
+
needsResponse: typeof params.needsResponse === "boolean" ? params.needsResponse : undefined,
|
|
117
|
+
references: normalizeContractStringList(params.references),
|
|
118
|
+
intent: "announcement",
|
|
119
|
+
});
|
|
120
|
+
const res = await fetch(`${identity.controllerUrl}/api/v1/messages/broadcast`, {
|
|
121
|
+
method: "POST",
|
|
122
|
+
headers: { "Content-Type": "application/json" },
|
|
123
|
+
body: JSON.stringify({
|
|
124
|
+
from: identity.workerId,
|
|
125
|
+
fromRole: identity.role,
|
|
126
|
+
content: message,
|
|
127
|
+
taskId: params.taskId ?? null,
|
|
128
|
+
contract,
|
|
129
|
+
}),
|
|
130
|
+
});
|
|
131
|
+
if (!res.ok) {
|
|
132
|
+
return { details: {}, content: [{ type: "text", text: `Failed to broadcast: ${res.status}` }] };
|
|
133
|
+
}
|
|
134
|
+
return { details: {}, content: [{ type: "text", text: "Broadcast sent to all team members." }] };
|
|
135
|
+
}
|
|
136
|
+
catch (err) {
|
|
137
|
+
return { details: {}, content: [{ type: "text", text: `Error: ${err instanceof Error ? err.message : String(err)}` }] };
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: "teamclaw_request_review",
|
|
143
|
+
label: "Request Review",
|
|
144
|
+
description: "Request a review from a specific role (e.g., qa for testing, architect for design review)",
|
|
145
|
+
parameters: Type.Object({
|
|
146
|
+
targetRole: Type.String({ description: "Exact target role ID to request review from" }),
|
|
147
|
+
reviewContent: Type.String({ description: "Content to review or description of what needs review" }),
|
|
148
|
+
taskId: Type.String({ description: "Related task ID" }),
|
|
149
|
+
summary: Type.Optional(Type.String({ description: "Short structured summary for the review request" })),
|
|
150
|
+
requestedAction: Type.Optional(Type.String({ description: "Concrete review action expected from the target role" })),
|
|
151
|
+
references: Type.Optional(Type.Array(Type.String({ description: "Relevant file paths, artifacts, or checks to review" }))),
|
|
152
|
+
}),
|
|
153
|
+
async execute(_id, params) {
|
|
154
|
+
const identity = await resolveIdentity();
|
|
155
|
+
if (!identity) {
|
|
156
|
+
return { details: {}, content: [{ type: "text", text: "Not registered with a team." }] };
|
|
157
|
+
}
|
|
158
|
+
const targetRole = String(params.targetRole ?? "");
|
|
159
|
+
const reviewContent = String(params.reviewContent ?? "");
|
|
160
|
+
const taskId = String(params.taskId ?? "");
|
|
161
|
+
if (!targetRole || !reviewContent) {
|
|
162
|
+
return { details: {}, content: [{ type: "text", text: "targetRole and reviewContent are required." }] };
|
|
163
|
+
}
|
|
164
|
+
try {
|
|
165
|
+
const contract = ensureTeamMessageContract(null, {
|
|
166
|
+
type: "review-request",
|
|
167
|
+
content: reviewContent,
|
|
168
|
+
toRole: normalizeContractRole(targetRole),
|
|
169
|
+
taskId,
|
|
170
|
+
summary: typeof params.summary === "string" ? params.summary : undefined,
|
|
171
|
+
requestedAction: typeof params.requestedAction === "string" ? params.requestedAction : undefined,
|
|
172
|
+
references: normalizeContractStringList(params.references),
|
|
173
|
+
intent: "review-request",
|
|
174
|
+
needsResponse: true,
|
|
175
|
+
});
|
|
176
|
+
const res = await fetch(`${identity.controllerUrl}/api/v1/messages/review-request`, {
|
|
177
|
+
method: "POST",
|
|
178
|
+
headers: { "Content-Type": "application/json" },
|
|
179
|
+
body: JSON.stringify({
|
|
180
|
+
from: identity.workerId,
|
|
181
|
+
fromRole: identity.role,
|
|
182
|
+
toRole: targetRole,
|
|
183
|
+
content: reviewContent,
|
|
184
|
+
taskId,
|
|
185
|
+
contract,
|
|
186
|
+
}),
|
|
187
|
+
});
|
|
188
|
+
if (!res.ok) {
|
|
189
|
+
return { details: {}, content: [{ type: "text", text: `Failed to request review: ${res.status}` }] };
|
|
190
|
+
}
|
|
191
|
+
return { details: {}, content: [{ type: "text", text: `Review request sent to ${targetRole}.` }] };
|
|
192
|
+
}
|
|
193
|
+
catch (err) {
|
|
194
|
+
return { details: {}, content: [{ type: "text", text: `Error: ${err instanceof Error ? err.message : String(err)}` }] };
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
name: "teamclaw_suggest_handoff",
|
|
200
|
+
label: "Suggest Handoff",
|
|
201
|
+
description: "Suggest handing off the current task to another role",
|
|
202
|
+
parameters: Type.Object({
|
|
203
|
+
taskId: Type.String({ description: "Task ID to hand off" }),
|
|
204
|
+
targetRole: Type.String({ description: "Exact target role ID to hand off to" }),
|
|
205
|
+
reason: Type.String({ description: "Reason for the handoff" }),
|
|
206
|
+
summary: Type.Optional(Type.String({ description: "Short structured summary for the handoff" })),
|
|
207
|
+
expectedNextStep: Type.Optional(Type.String({ description: "Concrete next step the receiving role should take" })),
|
|
208
|
+
artifacts: Type.Optional(Type.Array(Type.String({ description: "Files, task IDs, or artifacts the next role should inspect first" }))),
|
|
209
|
+
}),
|
|
210
|
+
async execute(_id, params) {
|
|
211
|
+
const identity = await resolveIdentity();
|
|
212
|
+
if (!identity) {
|
|
213
|
+
return { details: {}, content: [{ type: "text", text: "Not registered with a team." }] };
|
|
214
|
+
}
|
|
215
|
+
const taskId = String(params.taskId ?? "");
|
|
216
|
+
const targetRole = String(params.targetRole ?? "");
|
|
217
|
+
const reason = String(params.reason ?? "");
|
|
218
|
+
if (!taskId || !targetRole) {
|
|
219
|
+
return { details: {}, content: [{ type: "text", text: "taskId and targetRole are required." }] };
|
|
220
|
+
}
|
|
221
|
+
try {
|
|
222
|
+
const contract = normalizeTaskHandoffContract(null, {
|
|
223
|
+
targetRole: normalizeContractRole(targetRole),
|
|
224
|
+
reason,
|
|
225
|
+
summary: typeof params.summary === "string" ? params.summary : undefined,
|
|
226
|
+
expectedNextStep: typeof params.expectedNextStep === "string" ? params.expectedNextStep : undefined,
|
|
227
|
+
artifacts: normalizeContractStringList(params.artifacts),
|
|
228
|
+
});
|
|
229
|
+
const res = await fetch(`${identity.controllerUrl}/api/v1/tasks/${taskId}/handoff`, {
|
|
230
|
+
method: "POST",
|
|
231
|
+
headers: { "Content-Type": "application/json" },
|
|
232
|
+
body: JSON.stringify({
|
|
233
|
+
fromWorkerId: identity.workerId,
|
|
234
|
+
targetRole,
|
|
235
|
+
reason,
|
|
236
|
+
contract,
|
|
237
|
+
}),
|
|
238
|
+
});
|
|
239
|
+
if (!res.ok) {
|
|
240
|
+
return { details: {}, content: [{ type: "text", text: `Failed to suggest handoff: ${res.status}` }] };
|
|
241
|
+
}
|
|
242
|
+
return { details: {}, content: [{ type: "text", text: `Handoff suggested to ${targetRole}.` }] };
|
|
243
|
+
}
|
|
244
|
+
catch (err) {
|
|
245
|
+
return { details: {}, content: [{ type: "text", text: `Error: ${err instanceof Error ? err.message : String(err)}` }] };
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
name: "teamclaw_submit_result_contract",
|
|
251
|
+
label: "Submit Result Contract",
|
|
252
|
+
description: "Record the structured completion/blocker contract for the current task before the final worker reply is returned",
|
|
253
|
+
parameters: Type.Object({
|
|
254
|
+
taskId: Type.String({ description: "Task ID" }),
|
|
255
|
+
outcome: Type.Optional(Type.String({ description: "Outcome: completed, blocked, or failed" })),
|
|
256
|
+
summary: Type.String({ description: "Short structured summary of the worker result" }),
|
|
257
|
+
deliverables: Type.Optional(Type.Array(Type.Object({
|
|
258
|
+
kind: Type.String({ description: "Deliverable kind: file, directory, command, artifact, or note" }),
|
|
259
|
+
value: Type.String({ description: "Deliverable identifier, path, or note" }),
|
|
260
|
+
summary: Type.Optional(Type.String({ description: "Optional short note about this deliverable" })),
|
|
261
|
+
artifactType: Type.Optional(Type.String({ description: "Artifact type: web-app, static-site, binary, or document" })),
|
|
262
|
+
previewCommand: Type.Optional(Type.String({ description: "Command to start a live preview server (for web-app artifacts)" })),
|
|
263
|
+
previewCwd: Type.Optional(Type.String({ description: "Working directory for the preview command" })),
|
|
264
|
+
previewReadyPath: Type.Optional(Type.String({ description: "Path to poll for health (default /)" })),
|
|
265
|
+
}))),
|
|
266
|
+
keyPoints: Type.Optional(Type.Array(Type.String({ description: "Important decisions, findings, or implementation notes" }))),
|
|
267
|
+
discoveredPatterns: Type.Optional(Type.Array(Type.String({ description: "Reusable codebase patterns discovered during this task (e.g. 'This codebase uses X for Y', 'Always update Z when changing W'). These are consolidated into workspace memory for future tasks." }))),
|
|
268
|
+
blockers: Type.Optional(Type.Array(Type.String({ description: "Any unresolved blockers or risks" }))),
|
|
269
|
+
followUps: Type.Optional(Type.Array(Type.Object({
|
|
270
|
+
type: Type.String({ description: "Follow-up type: review, handoff, clarification, downstream-task" }),
|
|
271
|
+
targetRole: Type.Optional(Type.String({ description: "Role that should handle the follow-up" })),
|
|
272
|
+
reason: Type.String({ description: "Why this follow-up is needed" }),
|
|
273
|
+
}))),
|
|
274
|
+
questions: Type.Optional(Type.Array(Type.String({ description: "Any remaining open questions" }))),
|
|
275
|
+
notes: Type.Optional(Type.String({ description: "Optional extra delivery notes" })),
|
|
276
|
+
}),
|
|
277
|
+
async execute(_id, params) {
|
|
278
|
+
const identity = await resolveIdentity();
|
|
279
|
+
if (!identity) {
|
|
280
|
+
return { details: {}, content: [{ type: "text", text: "Not registered with a team." }] };
|
|
281
|
+
}
|
|
282
|
+
const taskId = String(params.taskId ?? "");
|
|
283
|
+
if (!taskId) {
|
|
284
|
+
return { details: {}, content: [{ type: "text", text: "taskId is required." }] };
|
|
285
|
+
}
|
|
286
|
+
const contract = normalizeWorkerTaskResultContract({
|
|
287
|
+
version: "1.0",
|
|
288
|
+
outcome: typeof params.outcome === "string" ? params.outcome : "completed",
|
|
289
|
+
summary: params.summary,
|
|
290
|
+
deliverables: params.deliverables,
|
|
291
|
+
keyPoints: params.keyPoints,
|
|
292
|
+
discoveredPatterns: params.discoveredPatterns,
|
|
293
|
+
blockers: params.blockers,
|
|
294
|
+
followUps: params.followUps,
|
|
295
|
+
questions: params.questions,
|
|
296
|
+
notes: params.notes,
|
|
297
|
+
});
|
|
298
|
+
if (!contract) {
|
|
299
|
+
return { details: {}, content: [{ type: "text", text: "summary is required for teamclaw_submit_result_contract." }] };
|
|
300
|
+
}
|
|
301
|
+
try {
|
|
302
|
+
const res = await fetch(`${identity.controllerUrl}/api/v1/tasks/${taskId}/result-contract`, {
|
|
303
|
+
method: "POST",
|
|
304
|
+
headers: { "Content-Type": "application/json" },
|
|
305
|
+
body: JSON.stringify({ contract, workerId: identity.workerId }),
|
|
306
|
+
});
|
|
307
|
+
if (!res.ok) {
|
|
308
|
+
return { details: {}, content: [{ type: "text", text: `Failed to submit result contract: ${res.status}` }] };
|
|
309
|
+
}
|
|
310
|
+
return {
|
|
311
|
+
details: {},
|
|
312
|
+
content: [{
|
|
313
|
+
type: "text",
|
|
314
|
+
text: `Result contract recorded for ${taskId}: ${contract.outcome} / ${contract.summary}`,
|
|
315
|
+
}],
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
catch (err) {
|
|
319
|
+
return { details: {}, content: [{ type: "text", text: `Error: ${err instanceof Error ? err.message : String(err)}` }] };
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
name: "teamclaw_request_parallel_help",
|
|
325
|
+
label: "Request Parallel Help",
|
|
326
|
+
description: "Ask the controller to spawn more same-role or target-role workers for parallel work on this requirement",
|
|
327
|
+
parameters: Type.Object({
|
|
328
|
+
taskId: Type.String({ description: "Current task ID" }),
|
|
329
|
+
reason: Type.String({ description: "Why this task should be split across more workers now" }),
|
|
330
|
+
requestedWorkerCount: Type.Optional(Type.Number({ description: "Desired total worker count for this role after expansion" })),
|
|
331
|
+
targetRole: Type.Optional(Type.String({ description: "Role that should receive more workers; defaults to the current worker role" })),
|
|
332
|
+
suggestedWorkstreams: Type.Optional(Type.Array(Type.String({ description: "Concrete parallel workstreams or module slices the controller should fan out" }))),
|
|
333
|
+
}),
|
|
334
|
+
async execute(_id, params) {
|
|
335
|
+
const identity = await resolveIdentity();
|
|
336
|
+
if (!identity) {
|
|
337
|
+
return { details: {}, content: [{ type: "text", text: "Not registered with a team." }] };
|
|
338
|
+
}
|
|
339
|
+
const taskId = String(params.taskId ?? "");
|
|
340
|
+
const reason = String(params.reason ?? "").trim();
|
|
341
|
+
const targetRole = typeof params.targetRole === "string" && params.targetRole.trim()
|
|
342
|
+
? params.targetRole.trim()
|
|
343
|
+
: identity.role;
|
|
344
|
+
const requestedWorkerCount = typeof params.requestedWorkerCount === "number"
|
|
345
|
+
? Math.max(2, Math.min(10, Math.floor(params.requestedWorkerCount)))
|
|
346
|
+
: undefined;
|
|
347
|
+
const suggestedWorkstreams = Array.isArray(params.suggestedWorkstreams)
|
|
348
|
+
? params.suggestedWorkstreams.map((entry) => String(entry ?? "").trim()).filter(Boolean)
|
|
349
|
+
: [];
|
|
350
|
+
if (!taskId || !reason) {
|
|
351
|
+
return { details: {}, content: [{ type: "text", text: "taskId and reason are required." }] };
|
|
352
|
+
}
|
|
353
|
+
try {
|
|
354
|
+
const res = await fetch(`${identity.controllerUrl}/api/v1/tasks/${taskId}/parallel-help`, {
|
|
355
|
+
method: "POST",
|
|
356
|
+
headers: { "Content-Type": "application/json" },
|
|
357
|
+
body: JSON.stringify({
|
|
358
|
+
requestedBy: identity.workerId,
|
|
359
|
+
requestedByRole: identity.role,
|
|
360
|
+
targetRole,
|
|
361
|
+
reason,
|
|
362
|
+
requestedWorkerCount,
|
|
363
|
+
suggestedWorkstreams,
|
|
364
|
+
}),
|
|
365
|
+
});
|
|
366
|
+
if (!res.ok) {
|
|
367
|
+
return { details: {}, content: [{ type: "text", text: `Failed to request parallel help: ${res.status}` }] };
|
|
368
|
+
}
|
|
369
|
+
return {
|
|
370
|
+
details: {},
|
|
371
|
+
content: [{
|
|
372
|
+
type: "text",
|
|
373
|
+
text: `Parallel help requested for ${taskId}${requestedWorkerCount ? ` (target ${targetRole} workers: ${requestedWorkerCount})` : ""}.`,
|
|
374
|
+
}],
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
catch (err) {
|
|
378
|
+
return { details: {}, content: [{ type: "text", text: `Error: ${err instanceof Error ? err.message : String(err)}` }] };
|
|
379
|
+
}
|
|
380
|
+
},
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
name: "teamclaw_request_clarification",
|
|
384
|
+
label: "Request Clarification",
|
|
385
|
+
description: "Block the current task and send an explicit clarification question to the controller/human",
|
|
386
|
+
parameters: Type.Object({
|
|
387
|
+
taskId: Type.String({ description: "Task ID that is blocked" }),
|
|
388
|
+
question: Type.String({ description: "The exact question that must be answered before work can continue" }),
|
|
389
|
+
blockingReason: Type.String({ description: "Why this task cannot proceed safely without clarification" }),
|
|
390
|
+
context: Type.Optional(Type.String({ description: "Optional brief context or the specific decision that is missing" })),
|
|
391
|
+
questionSchema: Type.Optional(Type.Object({
|
|
392
|
+
kind: Type.String({ description: "Question kind: single-select, multi-select, number, or text" }),
|
|
393
|
+
title: Type.String({ description: "Question title shown to the human" }),
|
|
394
|
+
description: Type.Optional(Type.String({ description: "Optional supporting context for the question" })),
|
|
395
|
+
required: Type.Optional(Type.Boolean({ description: "Whether the question must be answered" })),
|
|
396
|
+
options: Type.Optional(Type.Array(Type.Object({
|
|
397
|
+
value: Type.String({ description: "Stable option value" }),
|
|
398
|
+
label: Type.String({ description: "Human-visible option label" }),
|
|
399
|
+
hint: Type.Optional(Type.String({ description: "Optional helper text for this option" })),
|
|
400
|
+
}))),
|
|
401
|
+
allowOther: Type.Optional(Type.Boolean({ description: "Whether freeform 'other' text is allowed" })),
|
|
402
|
+
placeholder: Type.Optional(Type.String({ description: "Optional placeholder or hint for text/number input" })),
|
|
403
|
+
unit: Type.Optional(Type.String({ description: "Optional unit label for number questions" })),
|
|
404
|
+
min: Type.Optional(Type.Number({ description: "Optional minimum numeric value" })),
|
|
405
|
+
max: Type.Optional(Type.Number({ description: "Optional maximum numeric value" })),
|
|
406
|
+
step: Type.Optional(Type.Number({ description: "Optional numeric step size" })),
|
|
407
|
+
})),
|
|
408
|
+
}),
|
|
409
|
+
async execute(_id, params) {
|
|
410
|
+
const identity = await resolveIdentity();
|
|
411
|
+
if (!identity) {
|
|
412
|
+
return { details: {}, content: [{ type: "text", text: "Not registered with a team." }] };
|
|
413
|
+
}
|
|
414
|
+
const taskId = String(params.taskId ?? "");
|
|
415
|
+
const question = String(params.question ?? "");
|
|
416
|
+
const blockingReason = String(params.blockingReason ?? "");
|
|
417
|
+
const context = typeof params.context === "string" ? params.context : undefined;
|
|
418
|
+
const questionSchema = normalizeClarificationQuestionSchema(params.questionSchema);
|
|
419
|
+
if (!taskId || !question || !blockingReason) {
|
|
420
|
+
return { details: {}, content: [{ type: "text", text: "taskId, question, and blockingReason are required." }] };
|
|
421
|
+
}
|
|
422
|
+
try {
|
|
423
|
+
const res = await fetch(`${identity.controllerUrl}/api/v1/clarifications`, {
|
|
424
|
+
method: "POST",
|
|
425
|
+
headers: { "Content-Type": "application/json" },
|
|
426
|
+
body: JSON.stringify({
|
|
427
|
+
taskId,
|
|
428
|
+
requestedBy: identity.workerId,
|
|
429
|
+
requestedByWorkerId: identity.workerId,
|
|
430
|
+
requestedByRole: identity.role,
|
|
431
|
+
question,
|
|
432
|
+
questionSchema,
|
|
433
|
+
blockingReason,
|
|
434
|
+
context,
|
|
435
|
+
}),
|
|
436
|
+
});
|
|
437
|
+
if (!res.ok) {
|
|
438
|
+
return { details: {}, content: [{ type: "text", text: `Failed to request clarification: ${res.status}` }] };
|
|
439
|
+
}
|
|
440
|
+
return { details: {}, content: [{ type: "text", text: "Clarification requested. The task is now blocked until a human answers." }] };
|
|
441
|
+
}
|
|
442
|
+
catch (err) {
|
|
443
|
+
return { details: {}, content: [{ type: "text", text: `Error: ${err instanceof Error ? err.message : String(err)}` }] };
|
|
444
|
+
}
|
|
445
|
+
},
|
|
446
|
+
},
|
|
447
|
+
{
|
|
448
|
+
name: "teamclaw_get_team_status",
|
|
449
|
+
label: "Get Team Status",
|
|
450
|
+
description: "Get current team status including all workers and tasks",
|
|
451
|
+
parameters: Type.Object({}),
|
|
452
|
+
async execute(_id) {
|
|
453
|
+
const identity = await resolveIdentity();
|
|
454
|
+
if (!identity) {
|
|
455
|
+
return { details: {}, content: [{ type: "text", text: "Not registered with a team." }] };
|
|
456
|
+
}
|
|
457
|
+
try {
|
|
458
|
+
const res = await fetch(`${identity.controllerUrl}/api/v1/team/status`);
|
|
459
|
+
if (!res.ok) {
|
|
460
|
+
return { details: {}, content: [{ type: "text", text: `Failed to get status: ${res.status}` }] };
|
|
461
|
+
}
|
|
462
|
+
const data = await res.json();
|
|
463
|
+
return { details: {}, content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
|
|
464
|
+
}
|
|
465
|
+
catch (err) {
|
|
466
|
+
return { details: {}, content: [{ type: "text", text: `Error: ${err instanceof Error ? err.message : String(err)}` }] };
|
|
467
|
+
}
|
|
468
|
+
},
|
|
469
|
+
},
|
|
470
|
+
{
|
|
471
|
+
name: "teamclaw_report_progress",
|
|
472
|
+
label: "Report Progress",
|
|
473
|
+
description: "Report progress on an assigned task",
|
|
474
|
+
parameters: Type.Object({
|
|
475
|
+
taskId: Type.String({ description: "Task ID" }),
|
|
476
|
+
progress: Type.Optional(Type.String({ description: "Progress update message" })),
|
|
477
|
+
message: Type.Optional(Type.String({ description: "Alias for progress when the runtime sends a generic message field" })),
|
|
478
|
+
status: Type.Optional(Type.String({ description: "Optional non-terminal status: in_progress or review. Do not use completed or failed here." })),
|
|
479
|
+
summary: Type.Optional(Type.String({ description: "Short structured progress summary" })),
|
|
480
|
+
currentStep: Type.Optional(Type.String({ description: "What the worker is doing right now" })),
|
|
481
|
+
nextStep: Type.Optional(Type.String({ description: "What the worker plans to do next" })),
|
|
482
|
+
blockers: Type.Optional(Type.Array(Type.String({ description: "Any blockers slowing progress" }))),
|
|
483
|
+
}),
|
|
484
|
+
async execute(_id, params) {
|
|
485
|
+
const identity = await resolveIdentity();
|
|
486
|
+
if (!identity) {
|
|
487
|
+
return { details: {}, content: [{ type: "text", text: "Not registered with a team." }] };
|
|
488
|
+
}
|
|
489
|
+
const taskId = String(params.taskId ?? "");
|
|
490
|
+
const progress = normalizeProgressText(params);
|
|
491
|
+
const status = typeof params.status === "string" ? params.status : undefined;
|
|
492
|
+
if (!taskId) {
|
|
493
|
+
return { details: {}, content: [{ type: "text", text: "taskId is required." }] };
|
|
494
|
+
}
|
|
495
|
+
if (!progress) {
|
|
496
|
+
return { details: {}, content: [{ type: "text", text: "progress or summary is required." }] };
|
|
497
|
+
}
|
|
498
|
+
if (status && !ALLOWED_PROGRESS_STATUSES.has(status)) {
|
|
499
|
+
return {
|
|
500
|
+
details: {},
|
|
501
|
+
content: [{
|
|
502
|
+
type: "text",
|
|
503
|
+
text: "status must be in_progress or review. Do not mark tasks completed or failed via teamclaw_report_progress; finish by returning the deliverable or surfacing the error.",
|
|
504
|
+
}],
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
try {
|
|
508
|
+
const progressContract = normalizeWorkerProgressContract({
|
|
509
|
+
version: "1.0",
|
|
510
|
+
summary: typeof params.summary === "string" ? params.summary : progress,
|
|
511
|
+
status,
|
|
512
|
+
currentStep: params.currentStep,
|
|
513
|
+
nextStep: params.nextStep,
|
|
514
|
+
blockers: params.blockers,
|
|
515
|
+
}) ?? backfillWorkerProgressContract(progress, status);
|
|
516
|
+
const patch = {
|
|
517
|
+
progress: renderWorkerProgressText(progressContract, progress),
|
|
518
|
+
};
|
|
519
|
+
if (status) {
|
|
520
|
+
patch.status = status;
|
|
521
|
+
}
|
|
522
|
+
if (progressContract) {
|
|
523
|
+
patch.progressContract = progressContract;
|
|
524
|
+
}
|
|
525
|
+
const res = await fetch(`${identity.controllerUrl}/api/v1/tasks/${taskId}`, {
|
|
526
|
+
method: "PATCH",
|
|
527
|
+
headers: { "Content-Type": "application/json" },
|
|
528
|
+
body: JSON.stringify(patch),
|
|
529
|
+
});
|
|
530
|
+
if (!res.ok) {
|
|
531
|
+
return { details: {}, content: [{ type: "text", text: `Failed to report progress: ${res.status}` }] };
|
|
532
|
+
}
|
|
533
|
+
return { details: {}, content: [{ type: "text", text: "Progress reported." }] };
|
|
534
|
+
}
|
|
535
|
+
catch (err) {
|
|
536
|
+
return { details: {}, content: [{ type: "text", text: `Error: ${err instanceof Error ? err.message : String(err)}` }] };
|
|
537
|
+
}
|
|
538
|
+
},
|
|
539
|
+
},
|
|
540
|
+
];
|
|
541
|
+
}
|