@teamclaws/teamclaw 2026.11.6 → 2026.11.7
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 +17 -11
- package/dist/src/config.js +3 -3
- package/dist/src/controller/http-server.js +2 -2
- package/dist/src/controller/managed-gateway-process.js +17 -1
- package/dist/src/controller/provisioning/process-supervisor.js +11 -0
- package/dist/src/controller/route-table.js +2 -2
- package/dist/src/controller/security.js +30 -15
- package/dist/src/controller/task-assignment.js +62 -1
- package/dist/src/controller/task-routes.js +39 -2
- package/dist/src/controller/tunnel-manager.js +11 -0
- package/dist/src/controller/tunnel-routes.js +11 -0
- package/dist/src/controller/workspace-routes.js +16 -2
- package/dist/src/teamauto/github-client.js +19 -0
- package/dist/src/teamauto/repo-sync.js +96 -22
- package/dist/src/teamauto/scheduler.js +458 -36
- package/dist/src/teamauto/store.js +125 -3
- package/dist/src/types.js +5 -3
- package/dist/src/ui/app.js +2 -2
- package/dist/src/worker/worker-service.js +13 -1
- package/dist/src/workspace-browser.js +14 -0
- package/openclaw.plugin.json +5 -5
- package/package.json +4 -2
- package/src/config.ts +3 -3
- package/src/controller/http-server.ts +2 -2
- package/src/controller/managed-gateway-process.ts +17 -1
- package/src/controller/provisioning/process-supervisor.ts +11 -0
- package/src/controller/route-table.ts +2 -2
- package/src/controller/security.ts +30 -15
- package/src/controller/task-assignment.ts +58 -1
- package/src/controller/task-routes.ts +39 -1
- package/src/controller/tunnel-manager.ts +12 -1
- package/src/controller/tunnel-routes.ts +11 -0
- package/src/controller/workspace-routes.ts +17 -2
- package/src/teamauto/github-client.ts +21 -1
- package/src/teamauto/repo-sync.ts +85 -21
- package/src/teamauto/scheduler.ts +434 -33
- package/src/teamauto/store.ts +133 -3
- package/src/types.ts +9 -7
- package/src/ui/app.js +2 -2
- package/src/worker/worker-service.ts +15 -1
- package/src/workspace-browser.ts +15 -0
|
@@ -118,16 +118,51 @@ export function createRepoSync(auth, logger) {
|
|
|
118
118
|
async function createWorkBranch(dir, name) {
|
|
119
119
|
await run(["checkout", "-B", name], dir);
|
|
120
120
|
}
|
|
121
|
+
/** #5815: deliverable must mean commits beyond the REMOTE base tip. A
|
|
122
|
+
* stale local baseline makes a zero-commit branch look deliverable; the
|
|
123
|
+
* PR then 422s (zero diff) deterministically six times. */
|
|
124
|
+
async function branchHasCommits(dir, defaultBranch, cloneUrl) {
|
|
125
|
+
if (!defaultBranch)
|
|
126
|
+
return false;
|
|
127
|
+
try {
|
|
128
|
+
if (cloneUrl) {
|
|
129
|
+
const authed = await tokenizedUrl(cloneUrl);
|
|
130
|
+
await run(["fetch", authed, defaultBranch], dir).catch(() => { });
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
await run(["fetch", "origin", defaultBranch], dir).catch(() => { });
|
|
134
|
+
}
|
|
135
|
+
const out = await run(["rev-list", "--count", `origin/${defaultBranch}..HEAD`], dir);
|
|
136
|
+
return Number(out.trim()) > 0;
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/** #5815: is the branch an ancestor of the remote base (zero-diff shape)? */
|
|
143
|
+
async function branchIsAncestorOfRemoteBase(dir, branch, defaultBranch) {
|
|
144
|
+
await run(["fetch", "origin", defaultBranch], dir).catch(() => { });
|
|
145
|
+
const head = (await run(["rev-parse", `origin/${branch}`], dir).catch(() => "")).trim();
|
|
146
|
+
const base = (await run(["rev-parse", `origin/${defaultBranch}`], dir).catch(() => "")).trim();
|
|
147
|
+
if (!head || !base)
|
|
148
|
+
return false;
|
|
149
|
+
return run(["merge-base", "--is-ancestor", head, base], dir).then(() => true, () => false);
|
|
150
|
+
}
|
|
151
|
+
/** #5788: does the branch exist on the remote? (422 disambiguation probe) */
|
|
152
|
+
async function branchExistsRemotely(dir, branch) {
|
|
153
|
+
const out = await run(["ls-remote", "origin", `refs/heads/${branch}`], dir).catch(() => "");
|
|
154
|
+
return out.trim().length > 0;
|
|
155
|
+
}
|
|
121
156
|
async function commitAll(dir, message, authorName, authorEmail) {
|
|
122
157
|
const status = await run(["status", "--porcelain"], dir);
|
|
123
158
|
if (!status.trim()) {
|
|
124
159
|
return false;
|
|
125
160
|
}
|
|
126
161
|
await run(["add", "-A"], dir);
|
|
127
|
-
await run(["-c", `user.name=${authorName}`, "-c", `user.email=${authorEmail}`, "commit", "-m", message], dir);
|
|
162
|
+
await run(["-c", `user.name=${authorName}`, "-c", `user.email=${authorEmail}`, "-c", "core.hooksPath=", "commit", "-m", message], dir);
|
|
128
163
|
return true;
|
|
129
164
|
}
|
|
130
|
-
async function pushBranch(repoId, dir, cloneUrl, branch) {
|
|
165
|
+
async function pushBranch(repoId, dir, cloneUrl, branch, onPushError) {
|
|
131
166
|
const authed = await tokenizedUrl(cloneUrl);
|
|
132
167
|
// #stale-base follow-up: the remote task branch may ALREADY carry the
|
|
133
168
|
// delivery (previous incarnation pushed it; the PR got merged). Blindly
|
|
@@ -150,11 +185,32 @@ export function createRepoSync(auth, logger) {
|
|
|
150
185
|
catch { /* branch absent remotely or fetch failed - plain push below */ }
|
|
151
186
|
try {
|
|
152
187
|
await run(["push", authed, `HEAD:refs/heads/${branch}`], dir);
|
|
188
|
+
// #5788: verify the push LANDED - a "successful" push whose ref is
|
|
189
|
+
// missing remotely (auth edge, proxy quirk) strands the branch exactly
|
|
190
|
+
// like a failed one, and createPR would 422 on the missing head.
|
|
191
|
+
const ls = await run(["ls-remote", authed, `refs/heads/${branch}`], dir).catch(() => "");
|
|
192
|
+
const localHead = (await run(["rev-parse", "HEAD"], dir)).trim();
|
|
193
|
+
if (ls && localHead && !ls.includes(localHead)) {
|
|
194
|
+
const msg = `post-push ref verification failed: remote refs/heads/${branch} does not contain local HEAD ${localHead.slice(0, 8)}`;
|
|
195
|
+
logger.warn(`TeamAuto: ${msg}`);
|
|
196
|
+
try {
|
|
197
|
+
onPushError?.(msg);
|
|
198
|
+
}
|
|
199
|
+
catch { /* observability only */ }
|
|
200
|
+
throw new Error(msg);
|
|
201
|
+
}
|
|
153
202
|
return { alreadyDelivered: false };
|
|
154
203
|
}
|
|
155
204
|
catch (err) {
|
|
156
205
|
const msg = err instanceof Error ? err.message : String(err);
|
|
157
206
|
logger.warn(`TeamAuto: push failed for ${repoId}#${branch}: ${msg}`);
|
|
207
|
+
// #5788: the push leg was the ONLY delivery step with zero activity
|
|
208
|
+
// surface - its failure only ever showed as downstream createPR 422
|
|
209
|
+
// noise (two stranded self-fix legs). Surface it via the callback.
|
|
210
|
+
try {
|
|
211
|
+
onPushError?.(msg);
|
|
212
|
+
}
|
|
213
|
+
catch { /* observability only */ }
|
|
158
214
|
// #5651 (ggcode, 2026-11-15): a NON-FAST-FORWARD rejection is
|
|
159
215
|
// deterministic - the generic retry ladder burned 6 attempts / ~25min
|
|
160
216
|
// on it twice (#5268 family). The task branch is exclusively ours, so
|
|
@@ -258,13 +314,14 @@ export function createRepoSync(auth, logger) {
|
|
|
258
314
|
// wtName carries the teamauto/ level for the REL path; the physical dir is
|
|
259
315
|
// a SIBLING of the base checkout (path.join would nest teamauto/ twice).
|
|
260
316
|
const wtPath = path.join(path.dirname(base), path.basename(wtName));
|
|
261
|
-
|
|
317
|
+
const wtExists = await fs.access(path.join(wtPath, ".git")).then(() => true, () => false);
|
|
318
|
+
if (!wtExists) {
|
|
262
319
|
// #stale-base (user report 2026-11-14): ensureCloned (fetch + reset to
|
|
263
320
|
// the default-branch tip) only ran at BIND time (learnNorms), so the
|
|
264
321
|
// base checkout's HEAD drifted days behind origin/main and EVERY new
|
|
265
322
|
// task worktree branched from stale code. Refresh the base right
|
|
266
323
|
// before creating a new branch off it - same fetch+reset as
|
|
267
|
-
// ensureCloned.
|
|
324
|
+
// ensureCloned.
|
|
268
325
|
if (defaultBranch && cloneUrl) {
|
|
269
326
|
try {
|
|
270
327
|
const authed = await tokenizedUrl(cloneUrl);
|
|
@@ -278,6 +335,40 @@ export function createRepoSync(auth, logger) {
|
|
|
278
335
|
await run(["worktree", "add", "-b", taskBranchName(taskId), wtPath, "HEAD"], base);
|
|
279
336
|
logger.warn(`TeamAuto: worktree ${wtName} (branch ${taskBranchName(taskId)}) for ${taskId}`);
|
|
280
337
|
}
|
|
338
|
+
else {
|
|
339
|
+
// #resume-sync (user 2026-11-18): a RESUMED task (retry / review
|
|
340
|
+
// follow-up) used to continue on the ORIGINAL base untouched - the
|
|
341
|
+
// comment above explicitly left resume paths stale. On repos that
|
|
342
|
+
// move fast, a worktree alive for hours is guaranteed behind, all
|
|
343
|
+
// retried work lands on a superseded base, and the divergence only
|
|
344
|
+
// surfaces at push (single-shot #5651 rebase self-heal or dead
|
|
345
|
+
// letter). Sync BEFORE resuming: fetch the main tree, count how far
|
|
346
|
+
// behind this branch is, rebase when behind (dirty trees via
|
|
347
|
+
// autostash). Best-effort: on any failure we continue on the current
|
|
348
|
+
// base exactly as before - delivery-time self-heal still applies.
|
|
349
|
+
try {
|
|
350
|
+
await run(["fetch", "origin", "+refs/heads/main:refs/remotes/origin/main"], base).catch(async () => {
|
|
351
|
+
const db = defaultBranch || (await run(["symbolic-ref", "--short", "refs/remotes/origin/HEAD"], base).then((o) => o.trim(), () => ""));
|
|
352
|
+
if (db)
|
|
353
|
+
await run(["fetch", "origin", `+refs/heads/${db}:refs/remotes/origin/${db}`], base);
|
|
354
|
+
});
|
|
355
|
+
const behindOut = await run(["rev-list", "--count", "HEAD..origin/main"], wtPath).catch(() => "");
|
|
356
|
+
const behind = Number(behindOut.trim()) || 0;
|
|
357
|
+
if (behind > 0) {
|
|
358
|
+
logger.warn(`TeamAuto: resume-sync ${repoId}#${taskId}: branch is ${behind} commit(s) behind main - rebasing before work continues`);
|
|
359
|
+
try {
|
|
360
|
+
await run(["rebase", "--autostash", "origin/main"], wtPath);
|
|
361
|
+
}
|
|
362
|
+
catch (rebaseErr) {
|
|
363
|
+
await run(["rebase", "--abort"], wtPath).catch(() => { });
|
|
364
|
+
logger.warn(`TeamAuto: resume-sync rebase failed for ${repoId}#${taskId} (continuing on current base; delivery-time self-heal applies): ${rebaseErr instanceof Error ? rebaseErr.message : String(rebaseErr)}`);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
catch (err) {
|
|
369
|
+
logger.warn(`TeamAuto: resume-sync skipped for ${repoId}#${taskId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
281
372
|
// Refresh the in-use sentinel on create AND resume (#173 follow-up 2).
|
|
282
373
|
await writeTaskLock(wtPath);
|
|
283
374
|
return wtPath;
|
|
@@ -487,22 +578,5 @@ export function createRepoSync(auth, logger) {
|
|
|
487
578
|
function taskWorktreeRelDir(repoId, taskId) {
|
|
488
579
|
return taskWorktreeDirName(repoId, taskId);
|
|
489
580
|
}
|
|
490
|
-
|
|
491
|
-
async function branchHasCommits(dir, baseBranch) {
|
|
492
|
-
try {
|
|
493
|
-
const out = await run(["rev-list", "--count", "HEAD", "--not", baseBranch], dir);
|
|
494
|
-
return Number(out.trim()) > 0;
|
|
495
|
-
}
|
|
496
|
-
catch {
|
|
497
|
-
// Base branch name unknown/unfetched - fall back to diff against first parent chain
|
|
498
|
-
try {
|
|
499
|
-
const root = await run(["rev-list", "--max-parents=0", "HEAD"], dir);
|
|
500
|
-
return root.trim().length > 0;
|
|
501
|
-
}
|
|
502
|
-
catch {
|
|
503
|
-
return false;
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
return { ensureCloned, currentSha, recentCommitMessages, readFileIfPresent, safeRepoPath, createWorkBranch, commitAll, pushBranch, ensureTaskWorktree, removeTaskWorktree, safeRemoveTaskWorktree, gcTaskWorktrees, taskWorktreeRelDir, taskBranchName, branchHasCommits, repoDir };
|
|
581
|
+
return { ensureCloned, currentSha, recentCommitMessages, readFileIfPresent, safeRepoPath, createWorkBranch, commitAll, pushBranch, branchExistsRemotely, branchIsAncestorOfRemoteBase, ensureTaskWorktree, removeTaskWorktree, safeRemoveTaskWorktree, gcTaskWorktrees, taskWorktreeRelDir, taskBranchName, branchHasCommits, repoDir };
|
|
508
582
|
}
|