@teamclaws/teamclaw 2026.4.3-2 → 2026.5.0
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 -2
- package/cli.mjs +116 -19
- package/index.ts +17 -0
- package/openclaw.plugin.json +57 -3
- package/package.json +8 -3
- package/src/config.ts +32 -1
- package/src/controller/controller-service.ts +66 -2
- package/src/controller/controller-tools.ts +34 -22
- package/src/controller/github-auth.ts +699 -0
- package/src/controller/http-server.ts +1454 -34
- package/src/controller/orchestration-manifest.ts +1 -0
- package/src/controller/prompt-injector.ts +7 -1
- package/src/controller/websocket.ts +5 -0
- package/src/controller/worker-provisioning.ts +2 -2
- package/src/discovery.ts +6 -4
- package/src/git-collaboration.ts +33 -0
- package/src/interaction-contracts.ts +2 -2
- package/src/openclaw-workspace.ts +477 -32
- package/src/prompt-policy.ts +11 -1
- package/src/roles.ts +52 -0
- package/src/state.ts +66 -34
- package/src/task-executor.ts +110 -3
- package/src/teamauto/github-client.ts +254 -0
- package/src/teamauto/norms.ts +103 -0
- package/src/teamauto/repo-sync.ts +218 -0
- package/src/teamauto/scanner.ts +221 -0
- package/src/teamauto/scheduler.ts +585 -0
- package/src/teamauto/store.ts +242 -0
- package/src/types.ts +90 -4
- package/src/ui/app.js +801 -11
- package/src/ui/github-login.html +296 -0
- package/src/ui/index.html +99 -2
- package/src/ui/style.css +344 -58
- package/src/worker/prompt-injector.ts +8 -0
- package/src/worker/tools.ts +48 -45
- package/src/worker/worker-service.ts +37 -1
- package/tsconfig.build.json +13 -0
- package/tsconfig.json +1 -5
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
import { resolveTeamClawProjectsDir } from "../openclaw-workspace.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* TeamAuto persistence: bound repos, schedules, policies, cursors, norms,
|
|
9
|
+
* and write-back bookkeeping. Mirrors the plugin state-dir resolution used by
|
|
10
|
+
* state.ts / github-auth.ts. See TEAMAUTO_DESIGN.md for the design contract.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export const TEAMAUTO_STORE_VERSION = 1;
|
|
14
|
+
|
|
15
|
+
export type TeamAutoActionPolicy = {
|
|
16
|
+
issueReview: boolean;
|
|
17
|
+
takeOwnership: boolean;
|
|
18
|
+
prReview: boolean;
|
|
19
|
+
createPR: boolean;
|
|
20
|
+
fullReview: "off" | "weekly" | "daily";
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type TeamAutoKeywordFilter = {
|
|
24
|
+
include: string[];
|
|
25
|
+
exclude: string[];
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type TeamAutoRepoPolicy = {
|
|
29
|
+
maxTasksPerSweep: number;
|
|
30
|
+
actions: TeamAutoActionPolicy;
|
|
31
|
+
skipAssignedToHumans: boolean;
|
|
32
|
+
labelFilter: TeamAutoKeywordFilter;
|
|
33
|
+
keywordFilter: TeamAutoKeywordFilter;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type TeamAutoCursors = {
|
|
37
|
+
lastIssueSince: number;
|
|
38
|
+
lastPrSince: number;
|
|
39
|
+
lastCommitSha: string;
|
|
40
|
+
lastFullReviewAt: number;
|
|
41
|
+
seen: Record<string, number>;
|
|
42
|
+
etags: Record<string, string>;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export type TeamAutoRepoNorms = {
|
|
46
|
+
commitStyle: string;
|
|
47
|
+
issueTemplate: string | null;
|
|
48
|
+
prTemplate: string | null;
|
|
49
|
+
contributing: string | null;
|
|
50
|
+
learnedAt: number;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export type TeamAutoRepoProvision = {
|
|
54
|
+
status: "provisioning" | "ready" | "failed";
|
|
55
|
+
/** Current stage label for UI display, e.g. "cloning repo". */
|
|
56
|
+
message: string;
|
|
57
|
+
startedAt: number;
|
|
58
|
+
updatedAt: number;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export type TeamAutoRepo = {
|
|
62
|
+
id: string; // "owner/repo"
|
|
63
|
+
enabled: boolean;
|
|
64
|
+
schedule: string; // cron, default "*/30 * * * *"
|
|
65
|
+
addedAt: number;
|
|
66
|
+
lastSweepAt: number;
|
|
67
|
+
lastSweepSummary: string | null;
|
|
68
|
+
pausedReason: string | null;
|
|
69
|
+
dryRunDone: boolean;
|
|
70
|
+
/** Bind-time provisioning state; ready/undefined means sweepable. */
|
|
71
|
+
provision?: TeamAutoRepoProvision;
|
|
72
|
+
policy: TeamAutoRepoPolicy;
|
|
73
|
+
cursors: TeamAutoCursors;
|
|
74
|
+
norms: TeamAutoRepoNorms | null;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export type TeamAutoWriteBack = {
|
|
78
|
+
taskId: string;
|
|
79
|
+
action: "issueComment" | "prComment" | "createIssue" | "createPR";
|
|
80
|
+
repoId: string;
|
|
81
|
+
targetId: number | null;
|
|
82
|
+
doneAt: number | null;
|
|
83
|
+
prUrl: string | null;
|
|
84
|
+
error: string | null;
|
|
85
|
+
/** Joint full-review cycle id: same-cycle sections share one umbrella issue. */
|
|
86
|
+
cycleKey?: string;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export type TeamAutoActivityKind = "bind" | "provision" | "sweep" | "task" | "writeback";
|
|
90
|
+
|
|
91
|
+
export type TeamAutoActivityEntry = {
|
|
92
|
+
at: number;
|
|
93
|
+
repoId: string;
|
|
94
|
+
kind: TeamAutoActivityKind;
|
|
95
|
+
text: string;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export const TEAMAUTO_ACTIVITY_LIMIT = 100;
|
|
99
|
+
|
|
100
|
+
export function pushTeamAutoActivity(store: TeamAutoStore, entry: TeamAutoActivityEntry): void {
|
|
101
|
+
store.activity = store.activity ?? [];
|
|
102
|
+
store.activity.push(entry);
|
|
103
|
+
if (store.activity.length > TEAMAUTO_ACTIVITY_LIMIT) {
|
|
104
|
+
store.activity = store.activity.slice(store.activity.length - TEAMAUTO_ACTIVITY_LIMIT);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export type TeamAutoStore = {
|
|
109
|
+
version: number;
|
|
110
|
+
repos: TeamAutoRepo[];
|
|
111
|
+
writebacks: TeamAutoWriteBack[];
|
|
112
|
+
/** Bounded activity log for the UI feed (persists across restarts). */
|
|
113
|
+
activity?: TeamAutoActivityEntry[];
|
|
114
|
+
budget: {
|
|
115
|
+
maxTasksPerDay: number;
|
|
116
|
+
firstSweepDryRun: boolean;
|
|
117
|
+
tasksToday: number;
|
|
118
|
+
dayStamp: string;
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export function defaultPolicy(): TeamAutoRepoPolicy {
|
|
123
|
+
return {
|
|
124
|
+
maxTasksPerSweep: 5,
|
|
125
|
+
actions: { issueReview: true, takeOwnership: true, prReview: true, createPR: true, fullReview: "weekly" },
|
|
126
|
+
skipAssignedToHumans: true,
|
|
127
|
+
labelFilter: { include: [], exclude: ["wontfix", "teamclaw-skip", "do-not-automate"] },
|
|
128
|
+
keywordFilter: { include: [], exclude: [] },
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export function defaultCursors(): TeamAutoCursors {
|
|
133
|
+
return { lastIssueSince: 0, lastPrSince: 0, lastCommitSha: "", lastFullReviewAt: 0, seen: {}, etags: {} };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function emptyStore(): TeamAutoStore {
|
|
137
|
+
const now = new Date();
|
|
138
|
+
return {
|
|
139
|
+
version: TEAMAUTO_STORE_VERSION,
|
|
140
|
+
repos: [],
|
|
141
|
+
writebacks: [],
|
|
142
|
+
activity: [],
|
|
143
|
+
budget: {
|
|
144
|
+
maxTasksPerDay: 50,
|
|
145
|
+
firstSweepDryRun: true,
|
|
146
|
+
tasksToday: 0,
|
|
147
|
+
dayStamp: now.toISOString().slice(0, 10),
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export function resolveTeamAutoPaths(): { storeFile: string; reposRoot: string; legacyReposRoot: string } {
|
|
153
|
+
const explicitStateDir = process.env.OPENCLAW_STATE_DIR?.trim();
|
|
154
|
+
let base: string;
|
|
155
|
+
if (explicitStateDir) {
|
|
156
|
+
base = path.join(path.resolve(explicitStateDir), "plugins", "teamclaw");
|
|
157
|
+
} else {
|
|
158
|
+
const explicitHome = process.env.OPENCLAW_HOME?.trim() || process.env.HOME?.trim();
|
|
159
|
+
const homeDir = explicitHome ? path.resolve(explicitHome) : os.homedir();
|
|
160
|
+
base = path.join(homeDir, ".openclaw", "plugins", "teamclaw");
|
|
161
|
+
}
|
|
162
|
+
// Repos live inside the TeamClaw workspace projects tree so workers and
|
|
163
|
+
// the workspace browser can actually operate on them (TEAMAUTO_DESIGN.md).
|
|
164
|
+
// The pre-workspace location is kept only to migrate existing clones.
|
|
165
|
+
let reposRoot: string;
|
|
166
|
+
try {
|
|
167
|
+
reposRoot = path.join(resolveTeamClawProjectsDir(), "teamauto");
|
|
168
|
+
} catch {
|
|
169
|
+
reposRoot = path.join(base, "teamauto", "repos");
|
|
170
|
+
}
|
|
171
|
+
return {
|
|
172
|
+
storeFile: path.join(base, "teamauto.json"),
|
|
173
|
+
reposRoot,
|
|
174
|
+
legacyReposRoot: path.join(base, "teamauto", "repos"),
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const writeQueue: Promise<void>[] = [];
|
|
179
|
+
|
|
180
|
+
export async function loadTeamAutoStore(): Promise<TeamAutoStore> {
|
|
181
|
+
const { storeFile } = resolveTeamAutoPaths();
|
|
182
|
+
try {
|
|
183
|
+
const raw = await fs.readFile(storeFile, "utf8");
|
|
184
|
+
const parsed = JSON.parse(raw) as Partial<TeamAutoStore>;
|
|
185
|
+
const store = emptyStore();
|
|
186
|
+
if (Array.isArray(parsed.repos)) {
|
|
187
|
+
store.repos = parsed.repos
|
|
188
|
+
.filter((r): r is TeamAutoRepo => Boolean(r && typeof r.id === "string"))
|
|
189
|
+
.map((r) => ({
|
|
190
|
+
...r,
|
|
191
|
+
policy: { ...defaultPolicy(), ...(r.policy ?? {}), actions: { ...defaultPolicy().actions, ...(r.policy?.actions ?? {}) } },
|
|
192
|
+
cursors: { ...defaultCursors(), ...(r.cursors ?? {}) },
|
|
193
|
+
}));
|
|
194
|
+
}
|
|
195
|
+
if (Array.isArray(parsed.writebacks)) {
|
|
196
|
+
store.writebacks = parsed.writebacks as TeamAutoWriteBack[];
|
|
197
|
+
}
|
|
198
|
+
if (Array.isArray(parsed.activity)) {
|
|
199
|
+
store.activity = parsed.activity.slice(-TEAMAUTO_ACTIVITY_LIMIT);
|
|
200
|
+
}
|
|
201
|
+
store.budget = { ...store.budget, ...(parsed.budget ?? {}) };
|
|
202
|
+
return store;
|
|
203
|
+
} catch {
|
|
204
|
+
return emptyStore();
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export async function saveTeamAutoStore(store: TeamAutoStore): Promise<void> {
|
|
209
|
+
const { storeFile } = resolveTeamAutoPaths();
|
|
210
|
+
await fs.mkdir(path.dirname(storeFile), { recursive: true });
|
|
211
|
+
const tmp = `${storeFile}.tmp-${process.pid}-${Date.now()}`;
|
|
212
|
+
const next = writeQueue.length ? writeQueue[writeQueue.length - 1].catch(() => {}) : Promise.resolve();
|
|
213
|
+
const job = next.then(async () => {
|
|
214
|
+
await fs.writeFile(tmp, JSON.stringify(store, null, 2) + "\n", { encoding: "utf8", mode: 0o600 });
|
|
215
|
+
await fs.rename(tmp, storeFile);
|
|
216
|
+
});
|
|
217
|
+
writeQueue.push(job);
|
|
218
|
+
writeQueue.splice(0, Math.max(0, writeQueue.length - 20));
|
|
219
|
+
await job;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export function repoSlugToDirName(repoId: string): string {
|
|
223
|
+
return repoId.replace(/[/\\]/g, "__");
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export function todayStamp(now = new Date()): string {
|
|
227
|
+
return now.toISOString().slice(0, 10);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** Budget accounting: resets the daily counter on date rollover. */
|
|
231
|
+
export function consumeDailyBudget(store: TeamAutoStore, count: number, now = new Date()): boolean {
|
|
232
|
+
const stamp = todayStamp(now);
|
|
233
|
+
if (store.budget.dayStamp !== stamp) {
|
|
234
|
+
store.budget.dayStamp = stamp;
|
|
235
|
+
store.budget.tasksToday = 0;
|
|
236
|
+
}
|
|
237
|
+
if (store.budget.tasksToday + count > store.budget.maxTasksPerDay) {
|
|
238
|
+
return false;
|
|
239
|
+
}
|
|
240
|
+
store.budget.tasksToday += count;
|
|
241
|
+
return true;
|
|
242
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TEAMCLAW_PUBLISHED_RUNTIME_IMAGE } from "./install-defaults.js";
|
|
2
|
+
import { DEFAULT_GITHUB_CLIENT_ID } from "./controller/github-auth.js";
|
|
2
3
|
|
|
3
4
|
export type TeamClawMode = "controller" | "worker";
|
|
4
5
|
|
|
@@ -15,7 +16,7 @@ export type TaskStatus =
|
|
|
15
16
|
|
|
16
17
|
export type TaskPriority = "low" | "medium" | "high" | "critical";
|
|
17
18
|
|
|
18
|
-
export type TaskExecutionEventType = "lifecycle" | "progress" | "output" | "error";
|
|
19
|
+
export type TaskExecutionEventType = "lifecycle" | "progress" | "output" | "error" | "warning";
|
|
19
20
|
|
|
20
21
|
export type TaskExecutionStatus = "pending" | "running" | "completed" | "failed";
|
|
21
22
|
|
|
@@ -73,7 +74,8 @@ export type RoleId =
|
|
|
73
74
|
| "devops"
|
|
74
75
|
| "security-engineer"
|
|
75
76
|
| "designer"
|
|
76
|
-
| "marketing"
|
|
77
|
+
| "marketing"
|
|
78
|
+
| "data-engineer";
|
|
77
79
|
|
|
78
80
|
export type RoleDefinition = {
|
|
79
81
|
id: RoleId;
|
|
@@ -109,6 +111,7 @@ export type TaskInfo = {
|
|
|
109
111
|
assignedWorkerId?: string;
|
|
110
112
|
createdBy: string;
|
|
111
113
|
recommendedSkills?: string[];
|
|
114
|
+
controllerRunId?: string;
|
|
112
115
|
controllerSessionKey?: string;
|
|
113
116
|
projectId?: string;
|
|
114
117
|
projectDir?: string;
|
|
@@ -124,6 +127,11 @@ export type TaskInfo = {
|
|
|
124
127
|
lastHandoff?: TaskHandoffContract;
|
|
125
128
|
clarificationRequestId?: string;
|
|
126
129
|
execution?: TaskExecution;
|
|
130
|
+
/** Collaboration contract: read-only tasks never mutate the checkout; write tasks run in a dedicated git worktree and deliver via PR. */
|
|
131
|
+
writeMode?: "read-only" | "write";
|
|
132
|
+
/** Surviving progress snapshot for interrupted executions (resume support). */
|
|
133
|
+
checkpoint?: TaskCheckpoint;
|
|
134
|
+
resumeAttempt?: number;
|
|
127
135
|
};
|
|
128
136
|
|
|
129
137
|
export type TaskExecutionEvent = {
|
|
@@ -138,6 +146,19 @@ export type TaskExecutionEvent = {
|
|
|
138
146
|
workerId?: string;
|
|
139
147
|
};
|
|
140
148
|
|
|
149
|
+
export type TaskCheckpoint = {
|
|
150
|
+
/** Epoch ms of the last checkpoint update. */
|
|
151
|
+
updatedAt: number;
|
|
152
|
+
/** Monotonic resume counter; controller increments on each orphan reset. */
|
|
153
|
+
attempt: number;
|
|
154
|
+
/** OpenClaw session key hosting the persisted conversation for this task. */
|
|
155
|
+
sessionKey: string;
|
|
156
|
+
/** Last assistant message observed before the interruption. */
|
|
157
|
+
lastAssistantMessage: string;
|
|
158
|
+
/** Human-readable notes of verified work already done (latest last). */
|
|
159
|
+
progressNotes: string[];
|
|
160
|
+
};
|
|
161
|
+
|
|
141
162
|
export type TaskAssignmentPayload = {
|
|
142
163
|
taskId: string;
|
|
143
164
|
title: string;
|
|
@@ -147,6 +168,9 @@ export type TaskAssignmentPayload = {
|
|
|
147
168
|
projectDir?: string;
|
|
148
169
|
executionSessionKey?: string;
|
|
149
170
|
executionIdempotencyKey?: string;
|
|
171
|
+
/** Present when this assignment resumes an interrupted execution. */
|
|
172
|
+
checkpoint?: TaskCheckpoint;
|
|
173
|
+
resumeAttempt?: number;
|
|
150
174
|
repo?: RepoSyncInfo;
|
|
151
175
|
teamContext?: {
|
|
152
176
|
requirementSummary?: string;
|
|
@@ -156,6 +180,7 @@ export type TaskAssignmentPayload = {
|
|
|
156
180
|
blockedTasks?: Array<{ id: string; title: string; assignedRole?: RoleId; status: TaskStatus; summary?: string }>;
|
|
157
181
|
recentCompletedTasks?: Array<{ id: string; title: string; assignedRole?: RoleId; status: TaskStatus; summary?: string }>;
|
|
158
182
|
pendingClarifications?: Array<{ question: string; blockingReason?: string }>;
|
|
183
|
+
answeredClarifications?: Array<{ question: string; answer: string; answeredBy?: string; blockingReason?: string }>;
|
|
159
184
|
handoffPlan?: string;
|
|
160
185
|
notes?: string;
|
|
161
186
|
kickoffSummary?: string;
|
|
@@ -272,6 +297,10 @@ export type KickoffPlan = {
|
|
|
272
297
|
assessments: KickoffAssessment[];
|
|
273
298
|
/** Whether the kickoff phase has completed. */
|
|
274
299
|
completed: boolean;
|
|
300
|
+
/** Optional controller summary captured after the kickoff phase. */
|
|
301
|
+
summary?: string;
|
|
302
|
+
/** Timestamp (ms) recording when the kickoff phase was triggered. */
|
|
303
|
+
triggeredAt?: number;
|
|
275
304
|
};
|
|
276
305
|
|
|
277
306
|
export type ControllerManifestCreatedTask = {
|
|
@@ -470,12 +499,25 @@ export type PluginConfig = {
|
|
|
470
499
|
teamName: string;
|
|
471
500
|
heartbeatIntervalMs: number;
|
|
472
501
|
processModel: ProcessModel;
|
|
502
|
+
/**
|
|
503
|
+
* Optional per-role model overrides as "provider/model" strings. When set,
|
|
504
|
+
* task execution for that role passes provider/model to subagent.run;
|
|
505
|
+
* otherwise the teamclaw agent entry model applies.
|
|
506
|
+
*/
|
|
507
|
+
roleModelOverrides?: Partial<Record<RoleId, string>>;
|
|
473
508
|
taskTimeoutMs: number;
|
|
474
509
|
gitEnabled: boolean;
|
|
475
510
|
gitRemoteUrl: string;
|
|
476
511
|
gitDefaultBranch: string;
|
|
477
512
|
gitAuthorName: string;
|
|
478
513
|
gitAuthorEmail: string;
|
|
514
|
+
/** GitHub App OAuth client ID used by the GitHub login feature. */
|
|
515
|
+
githubClientId: string;
|
|
516
|
+
/**
|
|
517
|
+
* GitHub App OAuth client secret. The TEAMCLAW_GITHUB_CLIENT_SECRET
|
|
518
|
+
* environment variable takes precedence when set.
|
|
519
|
+
*/
|
|
520
|
+
githubClientSecret: string;
|
|
479
521
|
agentIsolationMode: AgentIsolationMode;
|
|
480
522
|
workerProvisioningType: WorkerProvisioningType;
|
|
481
523
|
workerProvisioningDisabled: boolean;
|
|
@@ -499,6 +541,7 @@ export type PluginConfig = {
|
|
|
499
541
|
workerProvisioningKubernetesWorkspacePersistentVolumeClaim: string;
|
|
500
542
|
workerProvisioningKubernetesLabels: Record<string, string>;
|
|
501
543
|
workerProvisioningKubernetesAnnotations: Record<string, string>;
|
|
544
|
+
maxConcurrentTasks: number;
|
|
502
545
|
};
|
|
503
546
|
|
|
504
547
|
export type WorkerIdentity = {
|
|
@@ -509,6 +552,8 @@ export type WorkerIdentity = {
|
|
|
509
552
|
};
|
|
510
553
|
|
|
511
554
|
export type TeamState = {
|
|
555
|
+
/** Schema version for forward-compatible state migration. */
|
|
556
|
+
version?: number;
|
|
512
557
|
teamName: string;
|
|
513
558
|
workers: Record<string, WorkerInfo>;
|
|
514
559
|
tasks: Record<string, TaskInfo>;
|
|
@@ -569,6 +614,21 @@ export type HeartbeatPayload = {
|
|
|
569
614
|
timestamp: number;
|
|
570
615
|
};
|
|
571
616
|
|
|
617
|
+
function parseRoleModelOverrides(raw: unknown): Partial<Record<RoleId, string>> | undefined {
|
|
618
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
|
|
619
|
+
return undefined;
|
|
620
|
+
}
|
|
621
|
+
const result: Partial<Record<RoleId, string>> = {};
|
|
622
|
+
let hasAny = false;
|
|
623
|
+
for (const [key, value] of Object.entries(raw as Record<string, unknown>)) {
|
|
624
|
+
if (VALID_ROLES.includes(key as RoleId) && typeof value === "string" && value.trim()) {
|
|
625
|
+
result[key as RoleId] = value.trim();
|
|
626
|
+
hasAny = true;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
return hasAny ? result : undefined;
|
|
630
|
+
}
|
|
631
|
+
|
|
572
632
|
export function parsePluginConfig(raw: Record<string, unknown> = {}): PluginConfig {
|
|
573
633
|
const mode = (typeof raw.mode === "string" && (raw.mode === "controller" || raw.mode === "worker"))
|
|
574
634
|
? raw.mode
|
|
@@ -598,7 +658,7 @@ export function parsePluginConfig(raw: Record<string, unknown> = {}): PluginConf
|
|
|
598
658
|
|
|
599
659
|
const taskTimeoutMs = typeof raw.taskTimeoutMs === "number" && raw.taskTimeoutMs >= 1000
|
|
600
660
|
? raw.taskTimeoutMs
|
|
601
|
-
:
|
|
661
|
+
: 600_000;
|
|
602
662
|
|
|
603
663
|
const gitEnabled = typeof raw.gitEnabled === "boolean" ? raw.gitEnabled : true;
|
|
604
664
|
|
|
@@ -618,6 +678,14 @@ export function parsePluginConfig(raw: Record<string, unknown> = {}): PluginConf
|
|
|
618
678
|
? raw.gitAuthorEmail.trim()
|
|
619
679
|
: "teamclaw@local";
|
|
620
680
|
|
|
681
|
+
const githubClientId = typeof raw.githubClientId === "string" && raw.githubClientId.trim()
|
|
682
|
+
? raw.githubClientId.trim()
|
|
683
|
+
: DEFAULT_GITHUB_CLIENT_ID;
|
|
684
|
+
|
|
685
|
+
const githubClientSecret = typeof raw.githubClientSecret === "string"
|
|
686
|
+
? raw.githubClientSecret.trim()
|
|
687
|
+
: "";
|
|
688
|
+
|
|
621
689
|
const agentIsolationMode: AgentIsolationMode =
|
|
622
690
|
typeof raw.agentIsolationMode === "string" && (raw.agentIsolationMode === "independent" || raw.agentIsolationMode === "main")
|
|
623
691
|
? raw.agentIsolationMode
|
|
@@ -695,6 +763,20 @@ export function parsePluginConfig(raw: Record<string, unknown> = {}): PluginConf
|
|
|
695
763
|
const workerProvisioningKubernetesLabels = parseStringRecord(raw.workerProvisioningKubernetesLabels);
|
|
696
764
|
const workerProvisioningKubernetesAnnotations = parseStringRecord(raw.workerProvisioningKubernetesAnnotations);
|
|
697
765
|
|
|
766
|
+
const rawMaxConcurrentTasks = raw.maxConcurrentTasks;
|
|
767
|
+
let maxConcurrentTasks: number;
|
|
768
|
+
if (rawMaxConcurrentTasks === undefined) {
|
|
769
|
+
maxConcurrentTasks = 5;
|
|
770
|
+
} else if (typeof rawMaxConcurrentTasks !== "number" || !Number.isInteger(rawMaxConcurrentTasks)) {
|
|
771
|
+
throw new Error(`maxConcurrentTasks must be an integer between 1 and 50, got ${rawMaxConcurrentTasks}`);
|
|
772
|
+
} else if (rawMaxConcurrentTasks < 1) {
|
|
773
|
+
throw new Error(`maxConcurrentTasks must be an integer between 1 and 50, got ${rawMaxConcurrentTasks}`);
|
|
774
|
+
} else if (rawMaxConcurrentTasks > 50) {
|
|
775
|
+
throw new Error(`maxConcurrentTasks must be an integer between 1 and 50, got ${rawMaxConcurrentTasks}`);
|
|
776
|
+
} else {
|
|
777
|
+
maxConcurrentTasks = rawMaxConcurrentTasks;
|
|
778
|
+
}
|
|
779
|
+
|
|
698
780
|
return {
|
|
699
781
|
mode,
|
|
700
782
|
port,
|
|
@@ -703,12 +785,15 @@ export function parsePluginConfig(raw: Record<string, unknown> = {}): PluginConf
|
|
|
703
785
|
teamName,
|
|
704
786
|
heartbeatIntervalMs,
|
|
705
787
|
processModel,
|
|
788
|
+
roleModelOverrides: parseRoleModelOverrides(raw.roleModelOverrides),
|
|
706
789
|
taskTimeoutMs,
|
|
707
790
|
gitEnabled,
|
|
708
791
|
gitRemoteUrl,
|
|
709
792
|
gitDefaultBranch,
|
|
710
793
|
gitAuthorName,
|
|
711
794
|
gitAuthorEmail,
|
|
795
|
+
githubClientId,
|
|
796
|
+
githubClientSecret,
|
|
712
797
|
agentIsolationMode,
|
|
713
798
|
workerProvisioningType,
|
|
714
799
|
workerProvisioningDisabled,
|
|
@@ -732,6 +817,7 @@ export function parsePluginConfig(raw: Record<string, unknown> = {}): PluginConf
|
|
|
732
817
|
workerProvisioningKubernetesWorkspacePersistentVolumeClaim,
|
|
733
818
|
workerProvisioningKubernetesLabels,
|
|
734
819
|
workerProvisioningKubernetesAnnotations,
|
|
820
|
+
maxConcurrentTasks,
|
|
735
821
|
};
|
|
736
822
|
}
|
|
737
823
|
|
|
@@ -794,5 +880,5 @@ const VALID_PROVISIONING_TYPES: WorkerProvisioningType[] = [
|
|
|
794
880
|
const VALID_ROLES: RoleId[] = [
|
|
795
881
|
"pm", "architect", "developer", "qa",
|
|
796
882
|
"release-engineer", "infra-engineer", "devops", "security-engineer",
|
|
797
|
-
"designer", "marketing",
|
|
883
|
+
"designer", "marketing", "data-engineer",
|
|
798
884
|
];
|